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>
54 #include <rte_eth_bond.h>
55 #include <rte_eth_bond_8023ad.h>
57 #if defined RTE_BUS_DPAA && defined RTE_NET_DPAA
58 #include <rte_pmd_dpaa.h>
61 #include <rte_pmd_ixgbe.h>
64 #include <rte_pmd_i40e.h>
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|rxoffs|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 rxoffs (x[,y]*)\n"
298 " Set the offset of each packet segment on"
299 " receiving if split feature is engaged."
300 " Affects only the queues configured with split"
303 "set rxpkts (x[,y]*)\n"
304 " Set the length of each segment to scatter"
305 " packets on receiving if split feature is engaged."
306 " Affects only the queues configured with split"
309 "set txpkts (x[,y]*)\n"
310 " Set the length of each segment of TXONLY"
311 " and optionally CSUM packets.\n\n"
313 "set txsplit (off|on|rand)\n"
314 " Set the split policy for the TX packets."
315 " Right now only applicable for CSUM and TXONLY"
318 "set txtimes (x, y)\n"
319 " Set the scheduling on timestamps"
320 " timings for the TXONLY mode\n\n"
322 "set corelist (x[,y]*)\n"
323 " Set the list of forwarding cores.\n\n"
325 "set portlist (x[,y]*)\n"
326 " Set the list of forwarding ports.\n\n"
328 "set port setup on (iterator|event)\n"
329 " Select how attached port is retrieved for setup.\n\n"
331 "set tx loopback (port_id) (on|off)\n"
332 " Enable or disable tx loopback.\n\n"
334 "set all queues drop (port_id) (on|off)\n"
335 " Set drop enable bit for all queues.\n\n"
337 "set vf split drop (port_id) (vf_id) (on|off)\n"
338 " Set split drop enable bit for a VF from the PF.\n\n"
340 "set vf mac antispoof (port_id) (vf_id) (on|off).\n"
341 " Set MAC antispoof for a VF from the PF.\n\n"
343 "set macsec offload (port_id) on encrypt (on|off) replay-protect (on|off)\n"
344 " Enable MACsec offload.\n\n"
346 "set macsec offload (port_id) off\n"
347 " Disable MACsec offload.\n\n"
349 "set macsec sc (tx|rx) (port_id) (mac) (pi)\n"
350 " Configure MACsec secure connection (SC).\n\n"
352 "set macsec sa (tx|rx) (port_id) (idx) (an) (pn) (key)\n"
353 " Configure MACsec secure association (SA).\n\n"
355 "set vf broadcast (port_id) (vf_id) (on|off)\n"
356 " Set VF broadcast for a VF from the PF.\n\n"
358 "vlan set stripq (on|off) (port_id,queue_id)\n"
359 " Set the VLAN strip for a queue on a port.\n\n"
361 "set vf vlan stripq (port_id) (vf_id) (on|off)\n"
362 " Set the VLAN strip for all queues in a pool for a VF from the PF.\n\n"
364 "set vf vlan insert (port_id) (vf_id) (vlan_id)\n"
365 " Set VLAN insert for a VF from the PF.\n\n"
367 "set vf vlan antispoof (port_id) (vf_id) (on|off)\n"
368 " Set VLAN antispoof for a VF from the PF.\n\n"
370 "set vf vlan tag (port_id) (vf_id) (on|off)\n"
371 " Set VLAN tag for a VF from the PF.\n\n"
373 "set vf tx max-bandwidth (port_id) (vf_id) (bandwidth)\n"
374 " Set a VF's max bandwidth(Mbps).\n\n"
376 "set vf tc tx min-bandwidth (port_id) (vf_id) (bw1, bw2, ...)\n"
377 " Set all TCs' min bandwidth(%%) on a VF.\n\n"
379 "set vf tc tx max-bandwidth (port_id) (vf_id) (tc_no) (bandwidth)\n"
380 " Set a TC's max bandwidth(Mbps) on a VF.\n\n"
382 "set tx strict-link-priority (port_id) (tc_bitmap)\n"
383 " Set some TCs' strict link priority mode on a physical port.\n\n"
385 "set tc tx min-bandwidth (port_id) (bw1, bw2, ...)\n"
386 " Set all TCs' min bandwidth(%%) for all PF and VFs.\n\n"
388 "vlan set (strip|filter|qinq_strip|extend) (on|off) (port_id)\n"
389 " Set the VLAN strip or filter or qinq strip or extend\n\n"
391 "vlan set (inner|outer) tpid (value) (port_id)\n"
392 " Set the VLAN TPID for Packet Filtering on"
395 "rx_vlan add (vlan_id|all) (port_id)\n"
396 " Add a vlan_id, or all identifiers, to the set"
397 " of VLAN identifiers filtered by port_id.\n\n"
399 "rx_vlan rm (vlan_id|all) (port_id)\n"
400 " Remove a vlan_id, or all identifiers, from the set"
401 " of VLAN identifiers filtered by port_id.\n\n"
403 "rx_vlan add (vlan_id) port (port_id) vf (vf_mask)\n"
404 " Add a vlan_id, to the set of VLAN identifiers"
405 "filtered for VF(s) from port_id.\n\n"
407 "rx_vlan rm (vlan_id) port (port_id) vf (vf_mask)\n"
408 " Remove a vlan_id, to the set of VLAN identifiers"
409 "filtered for VF(s) from port_id.\n\n"
411 "tunnel_filter add (port_id) (outer_mac) (inner_mac) (ip_addr) "
412 "(inner_vlan) (vxlan|nvgre|ipingre|vxlan-gpe) (imac-ivlan|imac-ivlan-tenid|"
413 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n"
414 " add a tunnel filter of a port.\n\n"
416 "tunnel_filter rm (port_id) (outer_mac) (inner_mac) (ip_addr) "
417 "(inner_vlan) (vxlan|nvgre|ipingre|vxlan-gpe) (imac-ivlan|imac-ivlan-tenid|"
418 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n"
419 " remove a tunnel filter of a port.\n\n"
421 "rx_vxlan_port add (udp_port) (port_id)\n"
422 " Add an UDP port for VXLAN packet filter on a port\n\n"
424 "rx_vxlan_port rm (udp_port) (port_id)\n"
425 " Remove an UDP port for VXLAN packet filter on a port\n\n"
427 "tx_vlan set (port_id) vlan_id[, vlan_id_outer]\n"
428 " Set hardware insertion of VLAN IDs (single or double VLAN "
429 "depends on the number of VLAN IDs) in packets sent on a port.\n\n"
431 "tx_vlan set pvid port_id vlan_id (on|off)\n"
432 " Set port based TX VLAN insertion.\n\n"
434 "tx_vlan reset (port_id)\n"
435 " Disable hardware insertion of a VLAN header in"
436 " packets sent on a port.\n\n"
438 "csum set (ip|udp|tcp|sctp|outer-ip|outer-udp) (hw|sw) (port_id)\n"
439 " Select hardware or software calculation of the"
440 " checksum when transmitting a packet using the"
441 " csum forward engine.\n"
442 " ip|udp|tcp|sctp always concern the inner layer.\n"
443 " outer-ip concerns the outer IP layer in"
444 " outer-udp concerns the outer UDP layer in"
445 " case the packet is recognized as a tunnel packet by"
446 " the forward engine (vxlan, gre and ipip are supported)\n"
447 " Please check the NIC datasheet for HW limits.\n\n"
449 "csum parse-tunnel (on|off) (tx_port_id)\n"
450 " If disabled, treat tunnel packets as non-tunneled"
451 " packets (treat inner headers as payload). The port\n"
452 " argument is the port used for TX in csum forward"
455 "csum show (port_id)\n"
456 " Display tx checksum offload configuration\n\n"
458 "tso set (segsize) (portid)\n"
459 " Enable TCP Segmentation Offload in csum forward"
461 " Please check the NIC datasheet for HW limits.\n\n"
464 " Display the status of TCP Segmentation Offload.\n\n"
466 "set port (port_id) gro on|off\n"
467 " Enable or disable Generic Receive Offload in"
468 " csum forwarding engine.\n\n"
470 "show port (port_id) gro\n"
471 " Display GRO configuration.\n\n"
473 "set gro flush (cycles)\n"
474 " Set the cycle to flush GROed packets from"
475 " reassembly tables.\n\n"
477 "set port (port_id) gso (on|off)"
478 " Enable or disable Generic Segmentation Offload in"
479 " csum forwarding engine.\n\n"
481 "set gso segsz (length)\n"
482 " Set max packet length for output GSO segments,"
483 " including packet header and payload.\n\n"
485 "show port (port_id) gso\n"
486 " Show GSO configuration.\n\n"
489 " Set packet forwarding mode.\n\n"
491 "mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n"
492 " Add a MAC address on port_id.\n\n"
494 "mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n"
495 " Remove a MAC address from port_id.\n\n"
497 "mac_addr set (port_id) (XX:XX:XX:XX:XX:XX)\n"
498 " Set the default MAC address for port_id.\n\n"
500 "mac_addr add port (port_id) vf (vf_id) (mac_address)\n"
501 " Add a MAC address for a VF on the port.\n\n"
503 "set vf mac addr (port_id) (vf_id) (XX:XX:XX:XX:XX:XX)\n"
504 " Set the MAC address for a VF from the PF.\n\n"
506 "set eth-peer (port_id) (peer_addr)\n"
507 " set the peer address for certain port.\n\n"
509 "set port (port_id) uta (mac_address|all) (on|off)\n"
510 " Add/Remove a or all unicast hash filter(s)"
513 "set promisc (port_id|all) (on|off)\n"
514 " Set the promiscuous mode on port_id, or all.\n\n"
516 "set allmulti (port_id|all) (on|off)\n"
517 " Set the allmulti mode on port_id, or all.\n\n"
519 "set vf promisc (port_id) (vf_id) (on|off)\n"
520 " Set unicast promiscuous mode for a VF from the PF.\n\n"
522 "set vf allmulti (port_id) (vf_id) (on|off)\n"
523 " Set multicast promiscuous mode for a VF from the PF.\n\n"
525 "set flow_ctrl rx (on|off) tx (on|off) (high_water)"
526 " (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd"
527 " (on|off) autoneg (on|off) (port_id)\n"
528 "set flow_ctrl rx (on|off) (portid)\n"
529 "set flow_ctrl tx (on|off) (portid)\n"
530 "set flow_ctrl high_water (high_water) (portid)\n"
531 "set flow_ctrl low_water (low_water) (portid)\n"
532 "set flow_ctrl pause_time (pause_time) (portid)\n"
533 "set flow_ctrl send_xon (send_xon) (portid)\n"
534 "set flow_ctrl mac_ctrl_frame_fwd (on|off) (portid)\n"
535 "set flow_ctrl autoneg (on|off) (port_id)\n"
536 " Set the link flow control parameter on a port.\n\n"
538 "set pfc_ctrl rx (on|off) tx (on|off) (high_water)"
539 " (low_water) (pause_time) (priority) (port_id)\n"
540 " Set the priority flow control parameter on a"
543 "set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n"
544 " Set statistics mapping (qmapping 0..15) for RX/TX"
546 " e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2"
547 " on port 0 to mapping 5.\n\n"
549 "set xstats-hide-zero on|off\n"
550 " Set the option to hide the zero values"
551 " for xstats display.\n"
553 "set record-core-cycles on|off\n"
554 " Set the option to enable measurement of CPU cycles.\n"
556 "set record-burst-stats on|off\n"
557 " Set the option to enable display of RX and TX bursts.\n"
559 "set port (port_id) vf (vf_id) rx|tx on|off\n"
560 " Enable/Disable a VF receive/tranmit from a port\n\n"
562 "set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM"
564 " AUPE:accepts untagged VLAN;"
565 "ROPE:accept unicast hash\n\n"
566 " BAM:accepts broadcast packets;"
567 "MPE:accepts all multicast packets\n\n"
568 " Enable/Disable a VF receive mode of a port\n\n"
570 "set port (port_id) queue (queue_id) rate (rate_num)\n"
571 " Set rate limit for a queue of a port\n\n"
573 "set port (port_id) vf (vf_id) rate (rate_num) "
574 "queue_mask (queue_mask_value)\n"
575 " Set rate limit for queues in VF of a port\n\n"
577 "set port (port_id) mirror-rule (rule_id)"
578 " (pool-mirror-up|pool-mirror-down|vlan-mirror)"
579 " (poolmask|vlanid[,vlanid]*) dst-pool (pool_id) (on|off)\n"
580 " Set pool or vlan type mirror rule on a port.\n"
581 " e.g., 'set port 0 mirror-rule 0 vlan-mirror 0,1"
582 " dst-pool 0 on' enable mirror traffic with vlan 0,1"
585 "set port (port_id) mirror-rule (rule_id)"
586 " (uplink-mirror|downlink-mirror) dst-pool"
587 " (pool_id) (on|off)\n"
588 " Set uplink or downlink type mirror rule on a port.\n"
589 " e.g., 'set port 0 mirror-rule 0 uplink-mirror dst-pool"
590 " 0 on' enable mirror income traffic to pool 0.\n\n"
592 "reset port (port_id) mirror-rule (rule_id)\n"
593 " Reset a mirror rule.\n\n"
595 "set flush_rx (on|off)\n"
596 " Flush (default) or don't flush RX streams before"
597 " forwarding. Mainly used with PCAP drivers.\n\n"
599 "set bypass mode (normal|bypass|isolate) (port_id)\n"
600 " Set the bypass mode for the lowest port on bypass enabled"
603 "set bypass event (timeout|os_on|os_off|power_on|power_off) "
604 "mode (normal|bypass|isolate) (port_id)\n"
605 " Set the event required to initiate specified bypass mode for"
606 " the lowest port on a bypass enabled NIC where:\n"
607 " timeout = enable bypass after watchdog timeout.\n"
608 " os_on = enable bypass when OS/board is powered on.\n"
609 " os_off = enable bypass when OS/board is powered off.\n"
610 " power_on = enable bypass when power supply is turned on.\n"
611 " power_off = enable bypass when power supply is turned off."
614 "set bypass timeout (0|1.5|2|3|4|8|16|32)\n"
615 " Set the bypass watchdog timeout to 'n' seconds"
616 " where 0 = instant.\n\n"
618 "show bypass config (port_id)\n"
619 " Show the bypass configuration for a bypass enabled NIC"
620 " using the lowest port on the NIC.\n\n"
623 "create bonded device (mode) (socket)\n"
624 " Create a new bonded device with specific bonding mode and socket.\n\n"
626 "add bonding slave (slave_id) (port_id)\n"
627 " Add a slave device to a bonded device.\n\n"
629 "remove bonding slave (slave_id) (port_id)\n"
630 " Remove a slave device from a bonded device.\n\n"
632 "set bonding mode (value) (port_id)\n"
633 " Set the bonding mode on a bonded device.\n\n"
635 "set bonding primary (slave_id) (port_id)\n"
636 " Set the primary slave for a bonded device.\n\n"
638 "show bonding config (port_id)\n"
639 " Show the bonding config for port_id.\n\n"
641 "set bonding mac_addr (port_id) (address)\n"
642 " Set the MAC address of a bonded device.\n\n"
644 "set bonding mode IEEE802.3AD aggregator policy (port_id) (agg_name)"
645 " Set Aggregation mode for IEEE802.3AD (mode 4)"
647 "set bonding balance_xmit_policy (port_id) (l2|l23|l34)\n"
648 " Set the transmit balance policy for bonded device running in balance mode.\n\n"
650 "set bonding mon_period (port_id) (value)\n"
651 " Set the bonding link status monitoring polling period in ms.\n\n"
653 "set bonding lacp dedicated_queues <port_id> (enable|disable)\n"
654 " Enable/disable dedicated queues for LACP control traffic.\n\n"
657 "set link-up port (port_id)\n"
658 " Set link up for a port.\n\n"
660 "set link-down port (port_id)\n"
661 " Set link down for a port.\n\n"
663 "E-tag set insertion on port-tag-id (value)"
664 " port (port_id) vf (vf_id)\n"
665 " Enable E-tag insertion for a VF on a port\n\n"
667 "E-tag set insertion off port (port_id) vf (vf_id)\n"
668 " Disable E-tag insertion for a VF on a port\n\n"
670 "E-tag set stripping (on|off) port (port_id)\n"
671 " Enable/disable E-tag stripping on a port\n\n"
673 "E-tag set forwarding (on|off) port (port_id)\n"
674 " Enable/disable E-tag based forwarding"
677 "E-tag set filter add e-tag-id (value) dst-pool"
678 " (pool_id) port (port_id)\n"
679 " Add an E-tag forwarding filter on a port\n\n"
681 "E-tag set filter del e-tag-id (value) port (port_id)\n"
682 " Delete an E-tag forwarding filter on a port\n\n"
684 "ddp add (port_id) (profile_path[,backup_profile_path])\n"
685 " Load a profile package on a port\n\n"
687 "ddp del (port_id) (backup_profile_path)\n"
688 " Delete a profile package from a port\n\n"
690 "ptype mapping get (port_id) (valid_only)\n"
691 " Get ptype mapping on a port\n\n"
693 "ptype mapping replace (port_id) (target) (mask) (pky_type)\n"
694 " Replace target with the pkt_type in ptype mapping\n\n"
696 "ptype mapping reset (port_id)\n"
697 " Reset ptype mapping on a port\n\n"
699 "ptype mapping update (port_id) (hw_ptype) (sw_ptype)\n"
700 " Update a ptype mapping item on a port\n\n"
702 "set port (port_id) ptype_mask (ptype_mask)\n"
703 " set packet types classification for a specific port\n\n"
705 "set port (port_id) queue-region region_id (value) "
706 "queue_start_index (value) queue_num (value)\n"
707 " Set a queue region on a port\n\n"
709 "set port (port_id) queue-region region_id (value) "
711 " Set a flowtype region index on a port\n\n"
713 "set port (port_id) queue-region UP (value) region_id (value)\n"
714 " Set the mapping of User Priority to "
715 "queue region on a port\n\n"
717 "set port (port_id) queue-region flush (on|off)\n"
718 " flush all queue region related configuration\n\n"
720 "show port meter cap (port_id)\n"
721 " Show port meter capability information\n\n"
723 "add port meter profile srtcm_rfc2697 (port_id) (profile_id) (cir) (cbs) (ebs)\n"
724 " meter profile add - srtcm rfc 2697\n\n"
726 "add port meter profile trtcm_rfc2698 (port_id) (profile_id) (cir) (pir) (cbs) (pbs)\n"
727 " meter profile add - trtcm rfc 2698\n\n"
729 "add port meter profile trtcm_rfc4115 (port_id) (profile_id) (cir) (eir) (cbs) (ebs)\n"
730 " meter profile add - trtcm rfc 4115\n\n"
732 "del port meter profile (port_id) (profile_id)\n"
733 " meter profile delete\n\n"
735 "create port meter (port_id) (mtr_id) (profile_id) (meter_enable)\n"
736 "(g_action) (y_action) (r_action) (stats_mask) (shared)\n"
737 "(use_pre_meter_color) [(dscp_tbl_entry0) (dscp_tbl_entry1)...\n"
738 "(dscp_tbl_entry63)]\n"
741 "enable port meter (port_id) (mtr_id)\n"
744 "disable port meter (port_id) (mtr_id)\n"
747 "del port meter (port_id) (mtr_id)\n"
750 "set port meter profile (port_id) (mtr_id) (profile_id)\n"
751 " meter update meter profile\n\n"
753 "set port meter dscp table (port_id) (mtr_id) [(dscp_tbl_entry0)\n"
754 "(dscp_tbl_entry1)...(dscp_tbl_entry63)]\n"
755 " update meter dscp table entries\n\n"
757 "set port meter policer action (port_id) (mtr_id) (action_mask)\n"
758 "(action0) [(action1) (action2)]\n"
759 " meter update policer action\n\n"
761 "set port meter stats mask (port_id) (mtr_id) (stats_mask)\n"
762 " meter update stats\n\n"
764 "show port (port_id) queue-region\n"
765 " show all queue region related configuration info\n\n"
767 "set port (port_id) fec_mode auto|off|rs|baser\n"
768 " set fec mode for a specific port\n\n"
770 , list_pkt_forwarding_modes()
774 if (show_all || !strcmp(res->section, "ports")) {
780 "----------------\n\n"
782 "port start (port_id|all)\n"
783 " Start all ports or port_id.\n\n"
785 "port stop (port_id|all)\n"
786 " Stop all ports or port_id.\n\n"
788 "port close (port_id|all)\n"
789 " Close all ports or port_id.\n\n"
791 "port reset (port_id|all)\n"
792 " Reset all ports or port_id.\n\n"
794 "port attach (ident)\n"
795 " Attach physical or virtual dev by pci address or virtual device name\n\n"
797 "port detach (port_id)\n"
798 " Detach physical or virtual dev by port_id\n\n"
800 "port config (port_id|all)"
801 " speed (10|100|1000|10000|25000|40000|50000|100000|200000|auto)"
802 " duplex (half|full|auto)\n"
803 " Set speed and duplex for all ports or port_id\n\n"
805 "port config (port_id|all) loopback (mode)\n"
806 " Set loopback mode for all ports or port_id\n\n"
808 "port config all (rxq|txq|rxd|txd) (value)\n"
809 " Set number for rxq/txq/rxd/txd.\n\n"
811 "port config all max-pkt-len (value)\n"
812 " Set the max packet length.\n\n"
814 "port config all max-lro-pkt-size (value)\n"
815 " Set the max LRO aggregated packet size.\n\n"
817 "port config all drop-en (on|off)\n"
818 " Enable or disable packet drop on all RX queues of all ports when no "
819 "receive buffers available.\n\n"
821 "port config all rss (all|default|ip|tcp|udp|sctp|"
822 "ether|port|vxlan|geneve|nvgre|vxlan-gpe|none|level-default|"
823 "level-outer|level-inner|<flowtype_id>)\n"
824 " Set the RSS mode.\n\n"
826 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
827 " Set the RSS redirection table.\n\n"
829 "port config (port_id) dcb vt (on|off) (traffic_class)"
831 " Set the DCB mode.\n\n"
833 "port config all burst (value)\n"
834 " Set the number of packets per burst.\n\n"
836 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
838 " Set the ring prefetch/host/writeback threshold"
839 " for tx/rx queue.\n\n"
841 "port config all (txfreet|txrst|rxfreet) (value)\n"
842 " Set free threshold for rx/tx, or set"
843 " tx rs bit threshold.\n\n"
844 "port config mtu X value\n"
845 " Set the MTU of port X to a given value\n\n"
847 "port config (port_id) (rxq|txq) (queue_id) ring_size (value)\n"
848 " Set a rx/tx queue's ring size configuration, the new"
849 " value will take effect after command that (re-)start the port"
850 " or command that setup the specific queue\n\n"
852 "port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
853 " Start/stop a rx/tx queue of port X. Only take effect"
854 " when port X is started\n\n"
856 "port (port_id) (rxq|txq) (queue_id) deferred_start (on|off)\n"
857 " Switch on/off a deferred start of port X rx/tx queue. Only"
858 " take effect when port X is stopped.\n\n"
860 "port (port_id) (rxq|txq) (queue_id) setup\n"
861 " Setup a rx/tx queue of port X.\n\n"
863 "port config (port_id|all) l2-tunnel E-tag ether-type"
865 " Set the value of E-tag ether-type.\n\n"
867 "port config (port_id|all) l2-tunnel E-tag"
868 " (enable|disable)\n"
869 " Enable/disable the E-tag support.\n\n"
871 "port config (port_id) pctype mapping reset\n"
872 " Reset flow type to pctype mapping on a port\n\n"
874 "port config (port_id) pctype mapping update"
875 " (pctype_id_0[,pctype_id_1]*) (flow_type_id)\n"
876 " Update a flow type to pctype mapping item on a port\n\n"
878 "port config (port_id) pctype (pctype_id) hash_inset|"
879 "fdir_inset|fdir_flx_inset get|set|clear field\n"
881 " Configure RSS|FDIR|FDIR_FLX input set for some pctype\n\n"
883 "port config (port_id) pctype (pctype_id) hash_inset|"
884 "fdir_inset|fdir_flx_inset clear all"
885 " Clear RSS|FDIR|FDIR_FLX input set completely for some pctype\n\n"
887 "port config (port_id) udp_tunnel_port add|rm vxlan|geneve (udp_port)\n\n"
888 " Add/remove UDP tunnel port for tunneling offload\n\n"
890 "port config <port_id> rx_offload vlan_strip|"
891 "ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|"
892 "outer_ipv4_cksum|macsec_strip|header_split|"
893 "vlan_filter|vlan_extend|jumbo_frame|scatter|"
894 "buffer_split|timestamp|security|keep_crc on|off\n"
895 " Enable or disable a per port Rx offloading"
896 " on all Rx queues of a port\n\n"
898 "port (port_id) rxq (queue_id) rx_offload vlan_strip|"
899 "ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|"
900 "outer_ipv4_cksum|macsec_strip|header_split|"
901 "vlan_filter|vlan_extend|jumbo_frame|scatter|"
902 "buffer_split|timestamp|security|keep_crc on|off\n"
903 " Enable or disable a per queue Rx offloading"
904 " only on a specific Rx queue\n\n"
906 "port config (port_id) tx_offload vlan_insert|"
907 "ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|"
908 "udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|"
909 "gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|"
910 "macsec_insert|mt_lockfree|multi_segs|mbuf_fast_free|"
912 " Enable or disable a per port Tx offloading"
913 " on all Tx queues of a port\n\n"
915 "port (port_id) txq (queue_id) tx_offload vlan_insert|"
916 "ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|"
917 "udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|"
918 "gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|macsec_insert"
919 "|mt_lockfree|multi_segs|mbuf_fast_free|security"
921 " Enable or disable a per queue Tx offloading"
922 " only on a specific Tx queue\n\n"
924 "bpf-load rx|tx (port) (queue) (J|M|B) (file_name)\n"
925 " Load an eBPF program as a callback"
926 " for particular RX/TX queue\n\n"
928 "bpf-unload rx|tx (port) (queue)\n"
929 " Unload previously loaded eBPF program"
930 " for particular RX/TX queue\n\n"
932 "port config (port_id) tx_metadata (value)\n"
933 " Set Tx metadata value per port. Testpmd will add this value"
934 " to any Tx packet sent from this port\n\n"
936 "port config (port_id) dynf (name) set|clear\n"
937 " Register a dynf and Set/clear this flag on Tx. "
938 "Testpmd will set this value to any Tx packet "
939 "sent from this port\n\n"
943 if (show_all || !strcmp(res->section, "registers")) {
951 "read reg (port_id) (address)\n"
952 " Display value of a port register.\n\n"
954 "read regfield (port_id) (address) (bit_x) (bit_y)\n"
955 " Display a port register bit field.\n\n"
957 "read regbit (port_id) (address) (bit_x)\n"
958 " Display a single port register bit.\n\n"
960 "write reg (port_id) (address) (value)\n"
961 " Set value of a port register.\n\n"
963 "write regfield (port_id) (address) (bit_x) (bit_y)"
965 " Set bit field of a port register.\n\n"
967 "write regbit (port_id) (address) (bit_x) (value)\n"
968 " Set single bit value of a port register.\n\n"
971 if (show_all || !strcmp(res->section, "filters")) {
979 "2tuple_filter (port_id) (add|del)"
980 " dst_port (dst_port_value) protocol (protocol_value)"
981 " mask (mask_value) tcp_flags (tcp_flags_value)"
982 " priority (prio_value) queue (queue_id)\n"
983 " Add/Del a 2tuple filter.\n\n"
985 "5tuple_filter (port_id) (add|del)"
986 " dst_ip (dst_address) src_ip (src_address)"
987 " dst_port (dst_port_value) src_port (src_port_value)"
988 " protocol (protocol_value)"
989 " mask (mask_value) tcp_flags (tcp_flags_value)"
990 " priority (prio_value) queue (queue_id)\n"
991 " Add/Del a 5tuple filter.\n\n"
993 "flow_director_filter (port_id) mode IP (add|del|update)"
994 " flow (ipv4-other|ipv4-frag|ipv6-other|ipv6-frag)"
995 " src (src_ip_address) dst (dst_ip_address)"
996 " tos (tos_value) proto (proto_value) ttl (ttl_value)"
997 " vlan (vlan_value) flexbytes (flexbytes_value)"
998 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
999 " fd_id (fd_id_value)\n"
1000 " Add/Del an IP type flow director filter.\n\n"
1002 "flow_director_filter (port_id) mode IP (add|del|update)"
1003 " flow (ipv4-tcp|ipv4-udp|ipv6-tcp|ipv6-udp)"
1004 " src (src_ip_address) (src_port)"
1005 " dst (dst_ip_address) (dst_port)"
1006 " tos (tos_value) ttl (ttl_value)"
1007 " vlan (vlan_value) flexbytes (flexbytes_value)"
1008 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
1009 " fd_id (fd_id_value)\n"
1010 " Add/Del an UDP/TCP type flow director filter.\n\n"
1012 "flow_director_filter (port_id) mode IP (add|del|update)"
1013 " flow (ipv4-sctp|ipv6-sctp)"
1014 " src (src_ip_address) (src_port)"
1015 " dst (dst_ip_address) (dst_port)"
1016 " tag (verification_tag) "
1017 " tos (tos_value) ttl (ttl_value)"
1018 " vlan (vlan_value)"
1019 " flexbytes (flexbytes_value) (drop|fwd)"
1020 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
1021 " Add/Del a SCTP type flow director filter.\n\n"
1023 "flow_director_filter (port_id) mode IP (add|del|update)"
1024 " flow l2_payload ether (ethertype)"
1025 " flexbytes (flexbytes_value) (drop|fwd)"
1026 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
1027 " Add/Del a l2 payload type flow director filter.\n\n"
1029 "flow_director_filter (port_id) mode MAC-VLAN (add|del|update)"
1030 " mac (mac_address) vlan (vlan_value)"
1031 " flexbytes (flexbytes_value) (drop|fwd)"
1032 " queue (queue_id) fd_id (fd_id_value)\n"
1033 " Add/Del a MAC-VLAN flow director filter.\n\n"
1035 "flow_director_filter (port_id) mode Tunnel (add|del|update)"
1036 " mac (mac_address) vlan (vlan_value)"
1037 " tunnel (NVGRE|VxLAN) tunnel-id (tunnel_id_value)"
1038 " flexbytes (flexbytes_value) (drop|fwd)"
1039 " queue (queue_id) fd_id (fd_id_value)\n"
1040 " Add/Del a Tunnel flow director filter.\n\n"
1042 "flow_director_filter (port_id) mode raw (add|del|update)"
1043 " flow (flow_id) (drop|fwd) queue (queue_id)"
1044 " fd_id (fd_id_value) packet (packet file name)\n"
1045 " Add/Del a raw type flow director filter.\n\n"
1047 "flush_flow_director (port_id)\n"
1048 " Flush all flow director entries of a device.\n\n"
1050 "flow_director_mask (port_id) mode IP vlan (vlan_value)"
1051 " src_mask (ipv4_src) (ipv6_src) (src_port)"
1052 " dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n"
1053 " Set flow director IP mask.\n\n"
1055 "flow_director_mask (port_id) mode MAC-VLAN"
1056 " vlan (vlan_value)\n"
1057 " Set flow director MAC-VLAN mask.\n\n"
1059 "flow_director_mask (port_id) mode Tunnel"
1060 " vlan (vlan_value) mac (mac_value)"
1061 " tunnel-type (tunnel_type_value)"
1062 " tunnel-id (tunnel_id_value)\n"
1063 " Set flow director Tunnel mask.\n\n"
1065 "flow_director_flex_mask (port_id)"
1066 " flow (none|ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
1067 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|l2_payload|all)"
1069 " Configure mask of flex payload.\n\n"
1071 "flow_director_flex_payload (port_id)"
1072 " (raw|l2|l3|l4) (config)\n"
1073 " Configure flex payload selection.\n\n"
1075 "get_sym_hash_ena_per_port (port_id)\n"
1076 " get symmetric hash enable configuration per port.\n\n"
1078 "set_sym_hash_ena_per_port (port_id) (enable|disable)\n"
1079 " set symmetric hash enable configuration per port"
1080 " to enable or disable.\n\n"
1082 "get_hash_global_config (port_id)\n"
1083 " Get the global configurations of hash filters.\n\n"
1085 "set_hash_global_config (port_id) (toeplitz|simple_xor|symmetric_toeplitz|default)"
1086 " (ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
1087 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload)"
1088 " (enable|disable)\n"
1089 " Set the global configurations of hash filters.\n\n"
1091 "set_hash_input_set (port_id) (ipv4|ipv4-frag|"
1092 "ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
1093 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1094 "l2_payload|<flowtype_id>) (ovlan|ivlan|src-ipv4|dst-ipv4|"
1095 "src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|ipv6-tc|"
1096 "ipv6-next-header|udp-src-port|udp-dst-port|"
1097 "tcp-src-port|tcp-dst-port|sctp-src-port|"
1098 "sctp-dst-port|sctp-veri-tag|udp-key|gre-key|fld-1st|"
1099 "fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|fld-7th|"
1100 "fld-8th|none) (select|add)\n"
1101 " Set the input set for hash.\n\n"
1103 "set_fdir_input_set (port_id) "
1104 "(ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
1105 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1106 "l2_payload) (ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|"
1107 "dst-ipv6|ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|"
1108 "ipv6-next-header|ipv6-hop-limits|udp-src-port|"
1109 "udp-dst-port|tcp-src-port|tcp-dst-port|"
1110 "sctp-src-port|sctp-dst-port|sctp-veri-tag|none)"
1112 " Set the input set for FDir.\n\n"
1114 "flow validate {port_id}"
1115 " [group {group_id}] [priority {level}]"
1116 " [ingress] [egress]"
1117 " pattern {item} [/ {item} [...]] / end"
1118 " actions {action} [/ {action} [...]] / end\n"
1119 " Check whether a flow rule can be created.\n\n"
1121 "flow create {port_id}"
1122 " [group {group_id}] [priority {level}]"
1123 " [ingress] [egress]"
1124 " pattern {item} [/ {item} [...]] / end"
1125 " actions {action} [/ {action} [...]] / end\n"
1126 " Create a flow rule.\n\n"
1128 "flow destroy {port_id} rule {rule_id} [...]\n"
1129 " Destroy specific flow rules.\n\n"
1131 "flow flush {port_id}\n"
1132 " Destroy all flow rules.\n\n"
1134 "flow query {port_id} {rule_id} {action}\n"
1135 " Query an existing flow rule.\n\n"
1137 "flow list {port_id} [group {group_id}] [...]\n"
1138 " List existing flow rules sorted by priority,"
1139 " filtered by group identifiers.\n\n"
1141 "flow isolate {port_id} {boolean}\n"
1142 " Restrict ingress traffic to the defined"
1145 "flow aged {port_id} [destroy]\n"
1146 " List and destroy aged flows"
1149 "flow shared_action {port_id} create"
1150 " [action_id {shared_action_id}]"
1151 " [ingress] [egress]"
1152 " action {action} / end\n"
1153 " Create shared action.\n\n"
1155 "flow shared_action {port_id} update"
1156 " {shared_action_id} action {action} / end\n"
1157 " Update shared action.\n\n"
1159 "flow shared_action {port_id} destroy"
1160 " action_id {shared_action_id} [...]\n"
1161 " Destroy specific shared actions.\n\n"
1163 "flow shared_action {port_id} query"
1164 " {shared_action_id}\n"
1165 " Query an existing shared action.\n\n"
1167 "set vxlan ip-version (ipv4|ipv6) vni (vni) udp-src"
1168 " (udp-src) udp-dst (udp-dst) ip-src (ip-src) ip-dst"
1169 " (ip-dst) eth-src (eth-src) eth-dst (eth-dst)\n"
1170 " Configure the VXLAN encapsulation for flows.\n\n"
1172 "set vxlan-with-vlan ip-version (ipv4|ipv6) vni (vni)"
1173 " udp-src (udp-src) udp-dst (udp-dst) ip-src (ip-src)"
1174 " ip-dst (ip-dst) vlan-tci (vlan-tci) eth-src (eth-src)"
1175 " eth-dst (eth-dst)\n"
1176 " Configure the VXLAN encapsulation for flows.\n\n"
1178 "set vxlan-tos-ttl ip-version (ipv4|ipv6) vni (vni) udp-src"
1179 " (udp-src) udp-dst (udp-dst) ip-tos (ip-tos) ip-ttl (ip-ttl)"
1180 " ip-src (ip-src) ip-dst (ip-dst) eth-src (eth-src)"
1181 " eth-dst (eth-dst)\n"
1182 " Configure the VXLAN encapsulation for flows.\n\n"
1184 "set nvgre ip-version (ipv4|ipv6) tni (tni) ip-src"
1185 " (ip-src) ip-dst (ip-dst) eth-src (eth-src) eth-dst"
1187 " Configure the NVGRE encapsulation for flows.\n\n"
1189 "set nvgre-with-vlan ip-version (ipv4|ipv6) tni (tni)"
1190 " ip-src (ip-src) ip-dst (ip-dst) vlan-tci (vlan-tci)"
1191 " eth-src (eth-src) eth-dst (eth-dst)\n"
1192 " Configure the NVGRE encapsulation for flows.\n\n"
1194 "set raw_encap {flow items}\n"
1195 " Configure the encapsulation with raw data.\n\n"
1197 "set raw_decap {flow items}\n"
1198 " Configure the decapsulation with raw data.\n\n"
1203 if (show_all || !strcmp(res->section, "traffic_management")) {
1207 "Traffic Management:\n"
1209 "show port tm cap (port_id)\n"
1210 " Display the port TM capability.\n\n"
1212 "show port tm level cap (port_id) (level_id)\n"
1213 " Display the port TM hierarchical level capability.\n\n"
1215 "show port tm node cap (port_id) (node_id)\n"
1216 " Display the port TM node capability.\n\n"
1218 "show port tm node type (port_id) (node_id)\n"
1219 " Display the port TM node type.\n\n"
1221 "show port tm node stats (port_id) (node_id) (clear)\n"
1222 " Display the port TM node stats.\n\n"
1224 "add port tm node shaper profile (port_id) (shaper_profile_id)"
1225 " (cmit_tb_rate) (cmit_tb_size) (peak_tb_rate) (peak_tb_size)"
1226 " (packet_length_adjust) (packet_mode)\n"
1227 " Add port tm node private shaper profile.\n\n"
1229 "del port tm node shaper profile (port_id) (shaper_profile_id)\n"
1230 " Delete port tm node private shaper profile.\n\n"
1232 "add port tm node shared shaper (port_id) (shared_shaper_id)"
1233 " (shaper_profile_id)\n"
1234 " Add/update port tm node shared shaper.\n\n"
1236 "del port tm node shared shaper (port_id) (shared_shaper_id)\n"
1237 " Delete port tm node shared shaper.\n\n"
1239 "set port tm node shaper profile (port_id) (node_id)"
1240 " (shaper_profile_id)\n"
1241 " Set port tm node shaper profile.\n\n"
1243 "add port tm node wred profile (port_id) (wred_profile_id)"
1244 " (color_g) (min_th_g) (max_th_g) (maxp_inv_g) (wq_log2_g)"
1245 " (color_y) (min_th_y) (max_th_y) (maxp_inv_y) (wq_log2_y)"
1246 " (color_r) (min_th_r) (max_th_r) (maxp_inv_r) (wq_log2_r)\n"
1247 " Add port tm node wred profile.\n\n"
1249 "del port tm node wred profile (port_id) (wred_profile_id)\n"
1250 " Delete port tm node wred profile.\n\n"
1252 "add port tm nonleaf node (port_id) (node_id) (parent_node_id)"
1253 " (priority) (weight) (level_id) (shaper_profile_id)"
1254 " (n_sp_priorities) (stats_mask) (n_shared_shapers)"
1255 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1256 " Add port tm nonleaf node.\n\n"
1258 "add port tm nonleaf node pktmode (port_id) (node_id) (parent_node_id)"
1259 " (priority) (weight) (level_id) (shaper_profile_id)"
1260 " (n_sp_priorities) (stats_mask) (n_shared_shapers)"
1261 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1262 " Add port tm nonleaf node with pkt mode enabled.\n\n"
1264 "add port tm leaf node (port_id) (node_id) (parent_node_id)"
1265 " (priority) (weight) (level_id) (shaper_profile_id)"
1266 " (cman_mode) (wred_profile_id) (stats_mask) (n_shared_shapers)"
1267 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1268 " Add port tm leaf node.\n\n"
1270 "del port tm node (port_id) (node_id)\n"
1271 " Delete port tm node.\n\n"
1273 "set port tm node parent (port_id) (node_id) (parent_node_id)"
1274 " (priority) (weight)\n"
1275 " Set port tm node parent.\n\n"
1277 "suspend port tm node (port_id) (node_id)"
1278 " Suspend tm node.\n\n"
1280 "resume port tm node (port_id) (node_id)"
1281 " Resume tm node.\n\n"
1283 "port tm hierarchy commit (port_id) (clean_on_fail)\n"
1284 " Commit tm hierarchy.\n\n"
1286 "set port tm mark ip_ecn (port) (green) (yellow)"
1288 " Enables/Disables the traffic management marking"
1289 " for IP ECN (Explicit Congestion Notification)"
1290 " packets on a given port\n\n"
1292 "set port tm mark ip_dscp (port) (green) (yellow)"
1294 " Enables/Disables the traffic management marking"
1295 " on the port for IP dscp packets\n\n"
1297 "set port tm mark vlan_dei (port) (green) (yellow)"
1299 " Enables/Disables the traffic management marking"
1300 " on the port for VLAN packets with DEI enabled\n\n"
1304 if (show_all || !strcmp(res->section, "devices")) {
1308 "Device Operations:\n"
1310 "device detach (identifier)\n"
1311 " Detach device by identifier.\n\n"
1317 cmdline_parse_token_string_t cmd_help_long_help =
1318 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
1320 cmdline_parse_token_string_t cmd_help_long_section =
1321 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
1322 "all#control#display#config#"
1323 "ports#registers#filters#traffic_management#devices");
1325 cmdline_parse_inst_t cmd_help_long = {
1326 .f = cmd_help_long_parsed,
1328 .help_str = "help all|control|display|config|ports|register|"
1329 "filters|traffic_management|devices: "
1332 (void *)&cmd_help_long_help,
1333 (void *)&cmd_help_long_section,
1339 /* *** start/stop/close all ports *** */
1340 struct cmd_operate_port_result {
1341 cmdline_fixed_string_t keyword;
1342 cmdline_fixed_string_t name;
1343 cmdline_fixed_string_t value;
1346 static void cmd_operate_port_parsed(void *parsed_result,
1347 __rte_unused struct cmdline *cl,
1348 __rte_unused void *data)
1350 struct cmd_operate_port_result *res = parsed_result;
1352 if (!strcmp(res->name, "start"))
1353 start_port(RTE_PORT_ALL);
1354 else if (!strcmp(res->name, "stop"))
1355 stop_port(RTE_PORT_ALL);
1356 else if (!strcmp(res->name, "close"))
1357 close_port(RTE_PORT_ALL);
1358 else if (!strcmp(res->name, "reset"))
1359 reset_port(RTE_PORT_ALL);
1361 printf("Unknown parameter\n");
1364 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
1365 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
1367 cmdline_parse_token_string_t cmd_operate_port_all_port =
1368 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
1369 "start#stop#close#reset");
1370 cmdline_parse_token_string_t cmd_operate_port_all_all =
1371 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
1373 cmdline_parse_inst_t cmd_operate_port = {
1374 .f = cmd_operate_port_parsed,
1376 .help_str = "port start|stop|close all: Start/Stop/Close/Reset all ports",
1378 (void *)&cmd_operate_port_all_cmd,
1379 (void *)&cmd_operate_port_all_port,
1380 (void *)&cmd_operate_port_all_all,
1385 /* *** start/stop/close specific port *** */
1386 struct cmd_operate_specific_port_result {
1387 cmdline_fixed_string_t keyword;
1388 cmdline_fixed_string_t name;
1392 static void cmd_operate_specific_port_parsed(void *parsed_result,
1393 __rte_unused struct cmdline *cl,
1394 __rte_unused void *data)
1396 struct cmd_operate_specific_port_result *res = parsed_result;
1398 if (!strcmp(res->name, "start"))
1399 start_port(res->value);
1400 else if (!strcmp(res->name, "stop"))
1401 stop_port(res->value);
1402 else if (!strcmp(res->name, "close"))
1403 close_port(res->value);
1404 else if (!strcmp(res->name, "reset"))
1405 reset_port(res->value);
1407 printf("Unknown parameter\n");
1410 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
1411 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1413 cmdline_parse_token_string_t cmd_operate_specific_port_port =
1414 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1415 name, "start#stop#close#reset");
1416 cmdline_parse_token_num_t cmd_operate_specific_port_id =
1417 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
1420 cmdline_parse_inst_t cmd_operate_specific_port = {
1421 .f = cmd_operate_specific_port_parsed,
1423 .help_str = "port start|stop|close <port_id>: Start/Stop/Close/Reset port_id",
1425 (void *)&cmd_operate_specific_port_cmd,
1426 (void *)&cmd_operate_specific_port_port,
1427 (void *)&cmd_operate_specific_port_id,
1432 /* *** enable port setup (after attach) via iterator or event *** */
1433 struct cmd_set_port_setup_on_result {
1434 cmdline_fixed_string_t set;
1435 cmdline_fixed_string_t port;
1436 cmdline_fixed_string_t setup;
1437 cmdline_fixed_string_t on;
1438 cmdline_fixed_string_t mode;
1441 static void cmd_set_port_setup_on_parsed(void *parsed_result,
1442 __rte_unused struct cmdline *cl,
1443 __rte_unused void *data)
1445 struct cmd_set_port_setup_on_result *res = parsed_result;
1447 if (strcmp(res->mode, "event") == 0)
1448 setup_on_probe_event = true;
1449 else if (strcmp(res->mode, "iterator") == 0)
1450 setup_on_probe_event = false;
1452 printf("Unknown mode\n");
1455 cmdline_parse_token_string_t cmd_set_port_setup_on_set =
1456 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1458 cmdline_parse_token_string_t cmd_set_port_setup_on_port =
1459 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1461 cmdline_parse_token_string_t cmd_set_port_setup_on_setup =
1462 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1464 cmdline_parse_token_string_t cmd_set_port_setup_on_on =
1465 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1467 cmdline_parse_token_string_t cmd_set_port_setup_on_mode =
1468 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1469 mode, "iterator#event");
1471 cmdline_parse_inst_t cmd_set_port_setup_on = {
1472 .f = cmd_set_port_setup_on_parsed,
1474 .help_str = "set port setup on iterator|event",
1476 (void *)&cmd_set_port_setup_on_set,
1477 (void *)&cmd_set_port_setup_on_port,
1478 (void *)&cmd_set_port_setup_on_setup,
1479 (void *)&cmd_set_port_setup_on_on,
1480 (void *)&cmd_set_port_setup_on_mode,
1485 /* *** attach a specified port *** */
1486 struct cmd_operate_attach_port_result {
1487 cmdline_fixed_string_t port;
1488 cmdline_fixed_string_t keyword;
1489 cmdline_multi_string_t identifier;
1492 static void cmd_operate_attach_port_parsed(void *parsed_result,
1493 __rte_unused struct cmdline *cl,
1494 __rte_unused void *data)
1496 struct cmd_operate_attach_port_result *res = parsed_result;
1498 if (!strcmp(res->keyword, "attach"))
1499 attach_port(res->identifier);
1501 printf("Unknown parameter\n");
1504 cmdline_parse_token_string_t cmd_operate_attach_port_port =
1505 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1507 cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
1508 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1510 cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
1511 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1512 identifier, TOKEN_STRING_MULTI);
1514 cmdline_parse_inst_t cmd_operate_attach_port = {
1515 .f = cmd_operate_attach_port_parsed,
1517 .help_str = "port attach <identifier>: "
1518 "(identifier: pci address or virtual dev name)",
1520 (void *)&cmd_operate_attach_port_port,
1521 (void *)&cmd_operate_attach_port_keyword,
1522 (void *)&cmd_operate_attach_port_identifier,
1527 /* *** detach a specified port *** */
1528 struct cmd_operate_detach_port_result {
1529 cmdline_fixed_string_t port;
1530 cmdline_fixed_string_t keyword;
1534 static void cmd_operate_detach_port_parsed(void *parsed_result,
1535 __rte_unused struct cmdline *cl,
1536 __rte_unused void *data)
1538 struct cmd_operate_detach_port_result *res = parsed_result;
1540 if (!strcmp(res->keyword, "detach")) {
1541 RTE_ETH_VALID_PORTID_OR_RET(res->port_id);
1542 detach_port_device(res->port_id);
1544 printf("Unknown parameter\n");
1548 cmdline_parse_token_string_t cmd_operate_detach_port_port =
1549 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1551 cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
1552 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1554 cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
1555 TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
1558 cmdline_parse_inst_t cmd_operate_detach_port = {
1559 .f = cmd_operate_detach_port_parsed,
1561 .help_str = "port detach <port_id>",
1563 (void *)&cmd_operate_detach_port_port,
1564 (void *)&cmd_operate_detach_port_keyword,
1565 (void *)&cmd_operate_detach_port_port_id,
1570 /* *** detach device by identifier *** */
1571 struct cmd_operate_detach_device_result {
1572 cmdline_fixed_string_t device;
1573 cmdline_fixed_string_t keyword;
1574 cmdline_fixed_string_t identifier;
1577 static void cmd_operate_detach_device_parsed(void *parsed_result,
1578 __rte_unused struct cmdline *cl,
1579 __rte_unused void *data)
1581 struct cmd_operate_detach_device_result *res = parsed_result;
1583 if (!strcmp(res->keyword, "detach"))
1584 detach_devargs(res->identifier);
1586 printf("Unknown parameter\n");
1589 cmdline_parse_token_string_t cmd_operate_detach_device_device =
1590 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1592 cmdline_parse_token_string_t cmd_operate_detach_device_keyword =
1593 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1595 cmdline_parse_token_string_t cmd_operate_detach_device_identifier =
1596 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1599 cmdline_parse_inst_t cmd_operate_detach_device = {
1600 .f = cmd_operate_detach_device_parsed,
1602 .help_str = "device detach <identifier>:"
1603 "(identifier: pci address or virtual dev name)",
1605 (void *)&cmd_operate_detach_device_device,
1606 (void *)&cmd_operate_detach_device_keyword,
1607 (void *)&cmd_operate_detach_device_identifier,
1611 /* *** configure speed for all ports *** */
1612 struct cmd_config_speed_all {
1613 cmdline_fixed_string_t port;
1614 cmdline_fixed_string_t keyword;
1615 cmdline_fixed_string_t all;
1616 cmdline_fixed_string_t item1;
1617 cmdline_fixed_string_t item2;
1618 cmdline_fixed_string_t value1;
1619 cmdline_fixed_string_t value2;
1623 parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed)
1628 if (!strcmp(duplexstr, "half")) {
1629 duplex = ETH_LINK_HALF_DUPLEX;
1630 } else if (!strcmp(duplexstr, "full")) {
1631 duplex = ETH_LINK_FULL_DUPLEX;
1632 } else if (!strcmp(duplexstr, "auto")) {
1633 duplex = ETH_LINK_FULL_DUPLEX;
1635 printf("Unknown duplex parameter\n");
1639 if (!strcmp(speedstr, "10")) {
1640 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1641 ETH_LINK_SPEED_10M_HD : ETH_LINK_SPEED_10M;
1642 } else if (!strcmp(speedstr, "100")) {
1643 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1644 ETH_LINK_SPEED_100M_HD : ETH_LINK_SPEED_100M;
1646 if (duplex != ETH_LINK_FULL_DUPLEX) {
1647 printf("Invalid speed/duplex parameters\n");
1650 if (!strcmp(speedstr, "1000")) {
1651 *speed = ETH_LINK_SPEED_1G;
1652 } else if (!strcmp(speedstr, "10000")) {
1653 *speed = ETH_LINK_SPEED_10G;
1654 } else if (!strcmp(speedstr, "25000")) {
1655 *speed = ETH_LINK_SPEED_25G;
1656 } else if (!strcmp(speedstr, "40000")) {
1657 *speed = ETH_LINK_SPEED_40G;
1658 } else if (!strcmp(speedstr, "50000")) {
1659 *speed = ETH_LINK_SPEED_50G;
1660 } else if (!strcmp(speedstr, "100000")) {
1661 *speed = ETH_LINK_SPEED_100G;
1662 } else if (!strcmp(speedstr, "200000")) {
1663 *speed = ETH_LINK_SPEED_200G;
1664 } else if (!strcmp(speedstr, "auto")) {
1665 *speed = ETH_LINK_SPEED_AUTONEG;
1667 printf("Unknown speed parameter\n");
1676 cmd_config_speed_all_parsed(void *parsed_result,
1677 __rte_unused struct cmdline *cl,
1678 __rte_unused void *data)
1680 struct cmd_config_speed_all *res = parsed_result;
1681 uint32_t link_speed;
1684 if (!all_ports_stopped()) {
1685 printf("Please stop all ports first\n");
1689 if (parse_and_check_speed_duplex(res->value1, res->value2,
1693 RTE_ETH_FOREACH_DEV(pid) {
1694 ports[pid].dev_conf.link_speeds = link_speed;
1697 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1700 cmdline_parse_token_string_t cmd_config_speed_all_port =
1701 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1702 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1703 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1705 cmdline_parse_token_string_t cmd_config_speed_all_all =
1706 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1707 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1708 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1709 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1710 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1711 "10#100#1000#10000#25000#40000#50000#100000#200000#auto");
1712 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1713 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1714 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1715 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1718 cmdline_parse_inst_t cmd_config_speed_all = {
1719 .f = cmd_config_speed_all_parsed,
1721 .help_str = "port config all speed "
1722 "10|100|1000|10000|25000|40000|50000|100000|200000|auto duplex "
1725 (void *)&cmd_config_speed_all_port,
1726 (void *)&cmd_config_speed_all_keyword,
1727 (void *)&cmd_config_speed_all_all,
1728 (void *)&cmd_config_speed_all_item1,
1729 (void *)&cmd_config_speed_all_value1,
1730 (void *)&cmd_config_speed_all_item2,
1731 (void *)&cmd_config_speed_all_value2,
1736 /* *** configure speed for specific port *** */
1737 struct cmd_config_speed_specific {
1738 cmdline_fixed_string_t port;
1739 cmdline_fixed_string_t keyword;
1741 cmdline_fixed_string_t item1;
1742 cmdline_fixed_string_t item2;
1743 cmdline_fixed_string_t value1;
1744 cmdline_fixed_string_t value2;
1748 cmd_config_speed_specific_parsed(void *parsed_result,
1749 __rte_unused struct cmdline *cl,
1750 __rte_unused void *data)
1752 struct cmd_config_speed_specific *res = parsed_result;
1753 uint32_t link_speed;
1755 if (!all_ports_stopped()) {
1756 printf("Please stop all ports first\n");
1760 if (port_id_is_invalid(res->id, ENABLED_WARN))
1763 if (parse_and_check_speed_duplex(res->value1, res->value2,
1767 ports[res->id].dev_conf.link_speeds = link_speed;
1769 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1773 cmdline_parse_token_string_t cmd_config_speed_specific_port =
1774 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1776 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1777 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1779 cmdline_parse_token_num_t cmd_config_speed_specific_id =
1780 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT16);
1781 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1782 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1784 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1785 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1786 "10#100#1000#10000#25000#40000#50000#100000#200000#auto");
1787 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1788 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1790 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1791 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1794 cmdline_parse_inst_t cmd_config_speed_specific = {
1795 .f = cmd_config_speed_specific_parsed,
1797 .help_str = "port config <port_id> speed "
1798 "10|100|1000|10000|25000|40000|50000|100000|200000|auto duplex "
1801 (void *)&cmd_config_speed_specific_port,
1802 (void *)&cmd_config_speed_specific_keyword,
1803 (void *)&cmd_config_speed_specific_id,
1804 (void *)&cmd_config_speed_specific_item1,
1805 (void *)&cmd_config_speed_specific_value1,
1806 (void *)&cmd_config_speed_specific_item2,
1807 (void *)&cmd_config_speed_specific_value2,
1812 /* *** configure loopback for all ports *** */
1813 struct cmd_config_loopback_all {
1814 cmdline_fixed_string_t port;
1815 cmdline_fixed_string_t keyword;
1816 cmdline_fixed_string_t all;
1817 cmdline_fixed_string_t item;
1822 cmd_config_loopback_all_parsed(void *parsed_result,
1823 __rte_unused struct cmdline *cl,
1824 __rte_unused void *data)
1826 struct cmd_config_loopback_all *res = parsed_result;
1829 if (!all_ports_stopped()) {
1830 printf("Please stop all ports first\n");
1834 RTE_ETH_FOREACH_DEV(pid) {
1835 ports[pid].dev_conf.lpbk_mode = res->mode;
1838 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1841 cmdline_parse_token_string_t cmd_config_loopback_all_port =
1842 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, port, "port");
1843 cmdline_parse_token_string_t cmd_config_loopback_all_keyword =
1844 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, keyword,
1846 cmdline_parse_token_string_t cmd_config_loopback_all_all =
1847 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, all, "all");
1848 cmdline_parse_token_string_t cmd_config_loopback_all_item =
1849 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, item,
1851 cmdline_parse_token_num_t cmd_config_loopback_all_mode =
1852 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_all, mode, UINT32);
1854 cmdline_parse_inst_t cmd_config_loopback_all = {
1855 .f = cmd_config_loopback_all_parsed,
1857 .help_str = "port config all loopback <mode>",
1859 (void *)&cmd_config_loopback_all_port,
1860 (void *)&cmd_config_loopback_all_keyword,
1861 (void *)&cmd_config_loopback_all_all,
1862 (void *)&cmd_config_loopback_all_item,
1863 (void *)&cmd_config_loopback_all_mode,
1868 /* *** configure loopback for specific port *** */
1869 struct cmd_config_loopback_specific {
1870 cmdline_fixed_string_t port;
1871 cmdline_fixed_string_t keyword;
1873 cmdline_fixed_string_t item;
1878 cmd_config_loopback_specific_parsed(void *parsed_result,
1879 __rte_unused struct cmdline *cl,
1880 __rte_unused void *data)
1882 struct cmd_config_loopback_specific *res = parsed_result;
1884 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
1887 if (!port_is_stopped(res->port_id)) {
1888 printf("Please stop port %u first\n", res->port_id);
1892 ports[res->port_id].dev_conf.lpbk_mode = res->mode;
1894 cmd_reconfig_device_queue(res->port_id, 1, 1);
1898 cmdline_parse_token_string_t cmd_config_loopback_specific_port =
1899 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, port,
1901 cmdline_parse_token_string_t cmd_config_loopback_specific_keyword =
1902 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, keyword,
1904 cmdline_parse_token_num_t cmd_config_loopback_specific_id =
1905 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, port_id,
1907 cmdline_parse_token_string_t cmd_config_loopback_specific_item =
1908 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, item,
1910 cmdline_parse_token_num_t cmd_config_loopback_specific_mode =
1911 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, mode,
1914 cmdline_parse_inst_t cmd_config_loopback_specific = {
1915 .f = cmd_config_loopback_specific_parsed,
1917 .help_str = "port config <port_id> loopback <mode>",
1919 (void *)&cmd_config_loopback_specific_port,
1920 (void *)&cmd_config_loopback_specific_keyword,
1921 (void *)&cmd_config_loopback_specific_id,
1922 (void *)&cmd_config_loopback_specific_item,
1923 (void *)&cmd_config_loopback_specific_mode,
1928 /* *** configure txq/rxq, txd/rxd *** */
1929 struct cmd_config_rx_tx {
1930 cmdline_fixed_string_t port;
1931 cmdline_fixed_string_t keyword;
1932 cmdline_fixed_string_t all;
1933 cmdline_fixed_string_t name;
1938 cmd_config_rx_tx_parsed(void *parsed_result,
1939 __rte_unused struct cmdline *cl,
1940 __rte_unused void *data)
1942 struct cmd_config_rx_tx *res = parsed_result;
1944 if (!all_ports_stopped()) {
1945 printf("Please stop all ports first\n");
1948 if (!strcmp(res->name, "rxq")) {
1949 if (!res->value && !nb_txq) {
1950 printf("Warning: Either rx or tx queues should be non zero\n");
1953 if (check_nb_rxq(res->value) != 0)
1955 nb_rxq = res->value;
1957 else if (!strcmp(res->name, "txq")) {
1958 if (!res->value && !nb_rxq) {
1959 printf("Warning: Either rx or tx queues should be non zero\n");
1962 if (check_nb_txq(res->value) != 0)
1964 nb_txq = res->value;
1966 else if (!strcmp(res->name, "rxd")) {
1967 if (check_nb_rxd(res->value) != 0)
1969 nb_rxd = res->value;
1970 } else if (!strcmp(res->name, "txd")) {
1971 if (check_nb_txd(res->value) != 0)
1974 nb_txd = res->value;
1976 printf("Unknown parameter\n");
1984 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1987 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1988 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1989 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1990 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1991 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1992 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1993 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1994 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1996 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1997 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
1999 cmdline_parse_inst_t cmd_config_rx_tx = {
2000 .f = cmd_config_rx_tx_parsed,
2002 .help_str = "port config all rxq|txq|rxd|txd <value>",
2004 (void *)&cmd_config_rx_tx_port,
2005 (void *)&cmd_config_rx_tx_keyword,
2006 (void *)&cmd_config_rx_tx_all,
2007 (void *)&cmd_config_rx_tx_name,
2008 (void *)&cmd_config_rx_tx_value,
2013 /* *** config max packet length *** */
2014 struct cmd_config_max_pkt_len_result {
2015 cmdline_fixed_string_t port;
2016 cmdline_fixed_string_t keyword;
2017 cmdline_fixed_string_t all;
2018 cmdline_fixed_string_t name;
2023 cmd_config_max_pkt_len_parsed(void *parsed_result,
2024 __rte_unused struct cmdline *cl,
2025 __rte_unused void *data)
2027 struct cmd_config_max_pkt_len_result *res = parsed_result;
2030 if (!all_ports_stopped()) {
2031 printf("Please stop all ports first\n");
2035 RTE_ETH_FOREACH_DEV(pid) {
2036 struct rte_port *port = &ports[pid];
2037 uint64_t rx_offloads = port->dev_conf.rxmode.offloads;
2039 if (!strcmp(res->name, "max-pkt-len")) {
2040 if (res->value < RTE_ETHER_MIN_LEN) {
2041 printf("max-pkt-len can not be less than %d\n",
2045 if (res->value == port->dev_conf.rxmode.max_rx_pkt_len)
2048 port->dev_conf.rxmode.max_rx_pkt_len = res->value;
2049 if (res->value > RTE_ETHER_MAX_LEN)
2050 rx_offloads |= DEV_RX_OFFLOAD_JUMBO_FRAME;
2052 rx_offloads &= ~DEV_RX_OFFLOAD_JUMBO_FRAME;
2053 port->dev_conf.rxmode.offloads = rx_offloads;
2055 printf("Unknown parameter\n");
2062 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2065 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
2066 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
2068 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
2069 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
2071 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
2072 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
2074 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
2075 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
2077 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
2078 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
2081 cmdline_parse_inst_t cmd_config_max_pkt_len = {
2082 .f = cmd_config_max_pkt_len_parsed,
2084 .help_str = "port config all max-pkt-len <value>",
2086 (void *)&cmd_config_max_pkt_len_port,
2087 (void *)&cmd_config_max_pkt_len_keyword,
2088 (void *)&cmd_config_max_pkt_len_all,
2089 (void *)&cmd_config_max_pkt_len_name,
2090 (void *)&cmd_config_max_pkt_len_value,
2095 /* *** config max LRO aggregated packet size *** */
2096 struct cmd_config_max_lro_pkt_size_result {
2097 cmdline_fixed_string_t port;
2098 cmdline_fixed_string_t keyword;
2099 cmdline_fixed_string_t all;
2100 cmdline_fixed_string_t name;
2105 cmd_config_max_lro_pkt_size_parsed(void *parsed_result,
2106 __rte_unused struct cmdline *cl,
2107 __rte_unused void *data)
2109 struct cmd_config_max_lro_pkt_size_result *res = parsed_result;
2112 if (!all_ports_stopped()) {
2113 printf("Please stop all ports first\n");
2117 RTE_ETH_FOREACH_DEV(pid) {
2118 struct rte_port *port = &ports[pid];
2120 if (!strcmp(res->name, "max-lro-pkt-size")) {
2122 port->dev_conf.rxmode.max_lro_pkt_size)
2125 port->dev_conf.rxmode.max_lro_pkt_size = res->value;
2127 printf("Unknown parameter\n");
2134 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2137 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_port =
2138 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2140 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_keyword =
2141 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2143 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_all =
2144 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2146 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_name =
2147 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2148 name, "max-lro-pkt-size");
2149 cmdline_parse_token_num_t cmd_config_max_lro_pkt_size_value =
2150 TOKEN_NUM_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2153 cmdline_parse_inst_t cmd_config_max_lro_pkt_size = {
2154 .f = cmd_config_max_lro_pkt_size_parsed,
2156 .help_str = "port config all max-lro-pkt-size <value>",
2158 (void *)&cmd_config_max_lro_pkt_size_port,
2159 (void *)&cmd_config_max_lro_pkt_size_keyword,
2160 (void *)&cmd_config_max_lro_pkt_size_all,
2161 (void *)&cmd_config_max_lro_pkt_size_name,
2162 (void *)&cmd_config_max_lro_pkt_size_value,
2167 /* *** configure port MTU *** */
2168 struct cmd_config_mtu_result {
2169 cmdline_fixed_string_t port;
2170 cmdline_fixed_string_t keyword;
2171 cmdline_fixed_string_t mtu;
2177 cmd_config_mtu_parsed(void *parsed_result,
2178 __rte_unused struct cmdline *cl,
2179 __rte_unused void *data)
2181 struct cmd_config_mtu_result *res = parsed_result;
2183 if (res->value < RTE_ETHER_MIN_LEN) {
2184 printf("mtu cannot be less than %d\n", RTE_ETHER_MIN_LEN);
2187 port_mtu_set(res->port_id, res->value);
2190 cmdline_parse_token_string_t cmd_config_mtu_port =
2191 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
2193 cmdline_parse_token_string_t cmd_config_mtu_keyword =
2194 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2196 cmdline_parse_token_string_t cmd_config_mtu_mtu =
2197 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2199 cmdline_parse_token_num_t cmd_config_mtu_port_id =
2200 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT16);
2201 cmdline_parse_token_num_t cmd_config_mtu_value =
2202 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
2204 cmdline_parse_inst_t cmd_config_mtu = {
2205 .f = cmd_config_mtu_parsed,
2207 .help_str = "port config mtu <port_id> <value>",
2209 (void *)&cmd_config_mtu_port,
2210 (void *)&cmd_config_mtu_keyword,
2211 (void *)&cmd_config_mtu_mtu,
2212 (void *)&cmd_config_mtu_port_id,
2213 (void *)&cmd_config_mtu_value,
2218 /* *** configure rx mode *** */
2219 struct cmd_config_rx_mode_flag {
2220 cmdline_fixed_string_t port;
2221 cmdline_fixed_string_t keyword;
2222 cmdline_fixed_string_t all;
2223 cmdline_fixed_string_t name;
2224 cmdline_fixed_string_t value;
2228 cmd_config_rx_mode_flag_parsed(void *parsed_result,
2229 __rte_unused struct cmdline *cl,
2230 __rte_unused void *data)
2232 struct cmd_config_rx_mode_flag *res = parsed_result;
2234 if (!all_ports_stopped()) {
2235 printf("Please stop all ports first\n");
2239 if (!strcmp(res->name, "drop-en")) {
2240 if (!strcmp(res->value, "on"))
2242 else if (!strcmp(res->value, "off"))
2245 printf("Unknown parameter\n");
2249 printf("Unknown parameter\n");
2255 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2258 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
2259 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
2260 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
2261 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
2263 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
2264 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
2265 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
2266 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
2268 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
2269 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
2272 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
2273 .f = cmd_config_rx_mode_flag_parsed,
2275 .help_str = "port config all drop-en on|off",
2277 (void *)&cmd_config_rx_mode_flag_port,
2278 (void *)&cmd_config_rx_mode_flag_keyword,
2279 (void *)&cmd_config_rx_mode_flag_all,
2280 (void *)&cmd_config_rx_mode_flag_name,
2281 (void *)&cmd_config_rx_mode_flag_value,
2286 /* *** configure rss *** */
2287 struct cmd_config_rss {
2288 cmdline_fixed_string_t port;
2289 cmdline_fixed_string_t keyword;
2290 cmdline_fixed_string_t all;
2291 cmdline_fixed_string_t name;
2292 cmdline_fixed_string_t value;
2296 cmd_config_rss_parsed(void *parsed_result,
2297 __rte_unused struct cmdline *cl,
2298 __rte_unused void *data)
2300 struct cmd_config_rss *res = parsed_result;
2301 struct rte_eth_rss_conf rss_conf = { .rss_key_len = 0, };
2302 struct rte_eth_dev_info dev_info = { .flow_type_rss_offloads = 0, };
2303 int use_default = 0;
2304 int all_updated = 1;
2309 if (!strcmp(res->value, "all"))
2310 rss_conf.rss_hf = ETH_RSS_ETH | ETH_RSS_VLAN | ETH_RSS_IP |
2311 ETH_RSS_TCP | ETH_RSS_UDP | ETH_RSS_SCTP |
2312 ETH_RSS_L2_PAYLOAD | ETH_RSS_L2TPV3 | ETH_RSS_ESP |
2313 ETH_RSS_AH | ETH_RSS_PFCP | ETH_RSS_GTPU;
2314 else if (!strcmp(res->value, "eth"))
2315 rss_conf.rss_hf = ETH_RSS_ETH;
2316 else if (!strcmp(res->value, "vlan"))
2317 rss_conf.rss_hf = ETH_RSS_VLAN;
2318 else if (!strcmp(res->value, "ip"))
2319 rss_conf.rss_hf = ETH_RSS_IP;
2320 else if (!strcmp(res->value, "udp"))
2321 rss_conf.rss_hf = ETH_RSS_UDP;
2322 else if (!strcmp(res->value, "tcp"))
2323 rss_conf.rss_hf = ETH_RSS_TCP;
2324 else if (!strcmp(res->value, "sctp"))
2325 rss_conf.rss_hf = ETH_RSS_SCTP;
2326 else if (!strcmp(res->value, "ether"))
2327 rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD;
2328 else if (!strcmp(res->value, "port"))
2329 rss_conf.rss_hf = ETH_RSS_PORT;
2330 else if (!strcmp(res->value, "vxlan"))
2331 rss_conf.rss_hf = ETH_RSS_VXLAN;
2332 else if (!strcmp(res->value, "geneve"))
2333 rss_conf.rss_hf = ETH_RSS_GENEVE;
2334 else if (!strcmp(res->value, "nvgre"))
2335 rss_conf.rss_hf = ETH_RSS_NVGRE;
2336 else if (!strcmp(res->value, "l3-pre32"))
2337 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE32;
2338 else if (!strcmp(res->value, "l3-pre40"))
2339 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE40;
2340 else if (!strcmp(res->value, "l3-pre48"))
2341 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE48;
2342 else if (!strcmp(res->value, "l3-pre56"))
2343 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE56;
2344 else if (!strcmp(res->value, "l3-pre64"))
2345 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE64;
2346 else if (!strcmp(res->value, "l3-pre96"))
2347 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE96;
2348 else if (!strcmp(res->value, "l3-src-only"))
2349 rss_conf.rss_hf = ETH_RSS_L3_SRC_ONLY;
2350 else if (!strcmp(res->value, "l3-dst-only"))
2351 rss_conf.rss_hf = ETH_RSS_L3_DST_ONLY;
2352 else if (!strcmp(res->value, "l4-src-only"))
2353 rss_conf.rss_hf = ETH_RSS_L4_SRC_ONLY;
2354 else if (!strcmp(res->value, "l4-dst-only"))
2355 rss_conf.rss_hf = ETH_RSS_L4_DST_ONLY;
2356 else if (!strcmp(res->value, "l2-src-only"))
2357 rss_conf.rss_hf = ETH_RSS_L2_SRC_ONLY;
2358 else if (!strcmp(res->value, "l2-dst-only"))
2359 rss_conf.rss_hf = ETH_RSS_L2_DST_ONLY;
2360 else if (!strcmp(res->value, "l2tpv3"))
2361 rss_conf.rss_hf = ETH_RSS_L2TPV3;
2362 else if (!strcmp(res->value, "esp"))
2363 rss_conf.rss_hf = ETH_RSS_ESP;
2364 else if (!strcmp(res->value, "ah"))
2365 rss_conf.rss_hf = ETH_RSS_AH;
2366 else if (!strcmp(res->value, "pfcp"))
2367 rss_conf.rss_hf = ETH_RSS_PFCP;
2368 else if (!strcmp(res->value, "pppoe"))
2369 rss_conf.rss_hf = ETH_RSS_PPPOE;
2370 else if (!strcmp(res->value, "gtpu"))
2371 rss_conf.rss_hf = ETH_RSS_GTPU;
2372 else if (!strcmp(res->value, "none"))
2373 rss_conf.rss_hf = 0;
2374 else if (!strcmp(res->value, "level-default")) {
2375 rss_hf &= (~ETH_RSS_LEVEL_MASK);
2376 rss_conf.rss_hf = (rss_hf | ETH_RSS_LEVEL_PMD_DEFAULT);
2377 } else if (!strcmp(res->value, "level-outer")) {
2378 rss_hf &= (~ETH_RSS_LEVEL_MASK);
2379 rss_conf.rss_hf = (rss_hf | ETH_RSS_LEVEL_OUTERMOST);
2380 } else if (!strcmp(res->value, "level-inner")) {
2381 rss_hf &= (~ETH_RSS_LEVEL_MASK);
2382 rss_conf.rss_hf = (rss_hf | ETH_RSS_LEVEL_INNERMOST);
2383 } else if (!strcmp(res->value, "default"))
2385 else if (isdigit(res->value[0]) && atoi(res->value) > 0 &&
2386 atoi(res->value) < 64)
2387 rss_conf.rss_hf = 1ULL << atoi(res->value);
2389 printf("Unknown parameter\n");
2392 rss_conf.rss_key = NULL;
2393 /* Update global configuration for RSS types. */
2394 RTE_ETH_FOREACH_DEV(i) {
2395 struct rte_eth_rss_conf local_rss_conf;
2397 ret = eth_dev_info_get_print_err(i, &dev_info);
2402 rss_conf.rss_hf = dev_info.flow_type_rss_offloads;
2404 local_rss_conf = rss_conf;
2405 local_rss_conf.rss_hf = rss_conf.rss_hf &
2406 dev_info.flow_type_rss_offloads;
2407 if (local_rss_conf.rss_hf != rss_conf.rss_hf) {
2408 printf("Port %u modified RSS hash function based on hardware support,"
2409 "requested:%#"PRIx64" configured:%#"PRIx64"\n",
2410 i, rss_conf.rss_hf, local_rss_conf.rss_hf);
2412 diag = rte_eth_dev_rss_hash_update(i, &local_rss_conf);
2415 printf("Configuration of RSS hash at ethernet port %d "
2416 "failed with error (%d): %s.\n",
2417 i, -diag, strerror(-diag));
2420 if (all_updated && !use_default) {
2421 rss_hf = rss_conf.rss_hf;
2422 printf("rss_hf %#"PRIx64"\n", rss_hf);
2426 cmdline_parse_token_string_t cmd_config_rss_port =
2427 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
2428 cmdline_parse_token_string_t cmd_config_rss_keyword =
2429 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
2430 cmdline_parse_token_string_t cmd_config_rss_all =
2431 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
2432 cmdline_parse_token_string_t cmd_config_rss_name =
2433 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
2434 cmdline_parse_token_string_t cmd_config_rss_value =
2435 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, NULL);
2437 cmdline_parse_inst_t cmd_config_rss = {
2438 .f = cmd_config_rss_parsed,
2440 .help_str = "port config all rss "
2441 "all|default|eth|vlan|ip|tcp|udp|sctp|ether|port|vxlan|geneve|"
2442 "nvgre|vxlan-gpe|l2tpv3|esp|ah|pfcp|none|level-default|"
2443 "level-outer|level-inner|<flowtype_id>",
2445 (void *)&cmd_config_rss_port,
2446 (void *)&cmd_config_rss_keyword,
2447 (void *)&cmd_config_rss_all,
2448 (void *)&cmd_config_rss_name,
2449 (void *)&cmd_config_rss_value,
2454 /* *** configure rss hash key *** */
2455 struct cmd_config_rss_hash_key {
2456 cmdline_fixed_string_t port;
2457 cmdline_fixed_string_t config;
2459 cmdline_fixed_string_t rss_hash_key;
2460 cmdline_fixed_string_t rss_type;
2461 cmdline_fixed_string_t key;
2465 hexa_digit_to_value(char hexa_digit)
2467 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
2468 return (uint8_t) (hexa_digit - '0');
2469 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
2470 return (uint8_t) ((hexa_digit - 'a') + 10);
2471 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
2472 return (uint8_t) ((hexa_digit - 'A') + 10);
2473 /* Invalid hexa digit */
2478 parse_and_check_key_hexa_digit(char *key, int idx)
2482 hexa_v = hexa_digit_to_value(key[idx]);
2484 printf("invalid key: character %c at position %d is not a "
2485 "valid hexa digit\n", key[idx], idx);
2490 cmd_config_rss_hash_key_parsed(void *parsed_result,
2491 __rte_unused struct cmdline *cl,
2492 __rte_unused void *data)
2494 struct cmd_config_rss_hash_key *res = parsed_result;
2495 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
2499 struct rte_eth_dev_info dev_info;
2500 uint8_t hash_key_size;
2504 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
2508 if (dev_info.hash_key_size > 0 &&
2509 dev_info.hash_key_size <= sizeof(hash_key))
2510 hash_key_size = dev_info.hash_key_size;
2512 printf("dev_info did not provide a valid hash key size\n");
2515 /* Check the length of the RSS hash key */
2516 key_len = strlen(res->key);
2517 if (key_len != (hash_key_size * 2)) {
2518 printf("key length: %d invalid - key must be a string of %d"
2519 " hexa-decimal numbers\n",
2520 (int) key_len, hash_key_size * 2);
2523 /* Translate RSS hash key into binary representation */
2524 for (i = 0; i < hash_key_size; i++) {
2525 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
2528 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
2531 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
2533 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
2537 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
2538 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
2539 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
2540 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
2542 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
2543 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT16);
2544 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
2545 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
2546 rss_hash_key, "rss-hash-key");
2547 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
2548 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
2549 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2550 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2551 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2552 "ipv6-tcp-ex#ipv6-udp-ex#"
2553 "l3-src-only#l3-dst-only#l4-src-only#l4-dst-only#"
2554 "l2-src-only#l2-dst-only#s-vlan#c-vlan#"
2555 "l2tpv3#esp#ah#pfcp#pppoe#gtpu");
2556 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
2557 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
2559 cmdline_parse_inst_t cmd_config_rss_hash_key = {
2560 .f = cmd_config_rss_hash_key_parsed,
2562 .help_str = "port config <port_id> rss-hash-key "
2563 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2564 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2565 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex|"
2566 "l3-src-only|l3-dst-only|l4-src-only|l4-dst-only|"
2567 "l2-src-only|l2-dst-only|s-vlan|c-vlan|"
2568 "l2tpv3|esp|ah|pfcp|pppoe|gtpu "
2569 "<string of hex digits (variable length, NIC dependent)>",
2571 (void *)&cmd_config_rss_hash_key_port,
2572 (void *)&cmd_config_rss_hash_key_config,
2573 (void *)&cmd_config_rss_hash_key_port_id,
2574 (void *)&cmd_config_rss_hash_key_rss_hash_key,
2575 (void *)&cmd_config_rss_hash_key_rss_type,
2576 (void *)&cmd_config_rss_hash_key_value,
2581 /* *** configure port rxq/txq ring size *** */
2582 struct cmd_config_rxtx_ring_size {
2583 cmdline_fixed_string_t port;
2584 cmdline_fixed_string_t config;
2586 cmdline_fixed_string_t rxtxq;
2588 cmdline_fixed_string_t rsize;
2593 cmd_config_rxtx_ring_size_parsed(void *parsed_result,
2594 __rte_unused struct cmdline *cl,
2595 __rte_unused void *data)
2597 struct cmd_config_rxtx_ring_size *res = parsed_result;
2598 struct rte_port *port;
2601 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2604 if (res->portid == (portid_t)RTE_PORT_ALL) {
2605 printf("Invalid port id\n");
2609 port = &ports[res->portid];
2611 if (!strcmp(res->rxtxq, "rxq"))
2613 else if (!strcmp(res->rxtxq, "txq"))
2616 printf("Unknown parameter\n");
2620 if (isrx && rx_queue_id_is_invalid(res->qid))
2622 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2625 if (isrx && res->size != 0 && res->size <= rx_free_thresh) {
2626 printf("Invalid rx ring_size, must > rx_free_thresh: %d\n",
2632 port->nb_rx_desc[res->qid] = res->size;
2634 port->nb_tx_desc[res->qid] = res->size;
2636 cmd_reconfig_device_queue(res->portid, 0, 1);
2639 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_port =
2640 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2642 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_config =
2643 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2645 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_portid =
2646 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2648 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rxtxq =
2649 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2651 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_qid =
2652 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2654 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rsize =
2655 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2656 rsize, "ring_size");
2657 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_size =
2658 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2661 cmdline_parse_inst_t cmd_config_rxtx_ring_size = {
2662 .f = cmd_config_rxtx_ring_size_parsed,
2664 .help_str = "port config <port_id> rxq|txq <queue_id> ring_size <value>",
2666 (void *)&cmd_config_rxtx_ring_size_port,
2667 (void *)&cmd_config_rxtx_ring_size_config,
2668 (void *)&cmd_config_rxtx_ring_size_portid,
2669 (void *)&cmd_config_rxtx_ring_size_rxtxq,
2670 (void *)&cmd_config_rxtx_ring_size_qid,
2671 (void *)&cmd_config_rxtx_ring_size_rsize,
2672 (void *)&cmd_config_rxtx_ring_size_size,
2677 /* *** configure port rxq/txq start/stop *** */
2678 struct cmd_config_rxtx_queue {
2679 cmdline_fixed_string_t port;
2681 cmdline_fixed_string_t rxtxq;
2683 cmdline_fixed_string_t opname;
2687 cmd_config_rxtx_queue_parsed(void *parsed_result,
2688 __rte_unused struct cmdline *cl,
2689 __rte_unused void *data)
2691 struct cmd_config_rxtx_queue *res = parsed_result;
2696 if (test_done == 0) {
2697 printf("Please stop forwarding first\n");
2701 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2704 if (port_is_started(res->portid) != 1) {
2705 printf("Please start port %u first\n", res->portid);
2709 if (!strcmp(res->rxtxq, "rxq"))
2711 else if (!strcmp(res->rxtxq, "txq"))
2714 printf("Unknown parameter\n");
2718 if (isrx && rx_queue_id_is_invalid(res->qid))
2720 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2723 if (!strcmp(res->opname, "start"))
2725 else if (!strcmp(res->opname, "stop"))
2728 printf("Unknown parameter\n");
2732 if (isstart && isrx)
2733 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
2734 else if (!isstart && isrx)
2735 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
2736 else if (isstart && !isrx)
2737 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
2739 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
2741 if (ret == -ENOTSUP)
2742 printf("Function not supported in PMD driver\n");
2745 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
2746 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
2747 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
2748 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT16);
2749 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
2750 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
2751 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
2752 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
2753 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
2754 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
2757 cmdline_parse_inst_t cmd_config_rxtx_queue = {
2758 .f = cmd_config_rxtx_queue_parsed,
2760 .help_str = "port <port_id> rxq|txq <queue_id> start|stop",
2762 (void *)&cmd_config_rxtx_queue_port,
2763 (void *)&cmd_config_rxtx_queue_portid,
2764 (void *)&cmd_config_rxtx_queue_rxtxq,
2765 (void *)&cmd_config_rxtx_queue_qid,
2766 (void *)&cmd_config_rxtx_queue_opname,
2771 /* *** configure port rxq/txq deferred start on/off *** */
2772 struct cmd_config_deferred_start_rxtx_queue {
2773 cmdline_fixed_string_t port;
2775 cmdline_fixed_string_t rxtxq;
2777 cmdline_fixed_string_t opname;
2778 cmdline_fixed_string_t state;
2782 cmd_config_deferred_start_rxtx_queue_parsed(void *parsed_result,
2783 __rte_unused struct cmdline *cl,
2784 __rte_unused void *data)
2786 struct cmd_config_deferred_start_rxtx_queue *res = parsed_result;
2787 struct rte_port *port;
2790 uint8_t needreconfig = 0;
2792 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
2795 if (port_is_started(res->port_id) != 0) {
2796 printf("Please stop port %u first\n", res->port_id);
2800 port = &ports[res->port_id];
2802 isrx = !strcmp(res->rxtxq, "rxq");
2804 if (isrx && rx_queue_id_is_invalid(res->qid))
2806 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2809 ison = !strcmp(res->state, "on");
2811 if (isrx && port->rx_conf[res->qid].rx_deferred_start != ison) {
2812 port->rx_conf[res->qid].rx_deferred_start = ison;
2814 } else if (!isrx && port->tx_conf[res->qid].tx_deferred_start != ison) {
2815 port->tx_conf[res->qid].tx_deferred_start = ison;
2820 cmd_reconfig_device_queue(res->port_id, 0, 1);
2823 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_port =
2824 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2826 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_port_id =
2827 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2829 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_rxtxq =
2830 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2832 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_qid =
2833 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2835 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_opname =
2836 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2837 opname, "deferred_start");
2838 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_state =
2839 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2842 cmdline_parse_inst_t cmd_config_deferred_start_rxtx_queue = {
2843 .f = cmd_config_deferred_start_rxtx_queue_parsed,
2845 .help_str = "port <port_id> rxq|txq <queue_id> deferred_start on|off",
2847 (void *)&cmd_config_deferred_start_rxtx_queue_port,
2848 (void *)&cmd_config_deferred_start_rxtx_queue_port_id,
2849 (void *)&cmd_config_deferred_start_rxtx_queue_rxtxq,
2850 (void *)&cmd_config_deferred_start_rxtx_queue_qid,
2851 (void *)&cmd_config_deferred_start_rxtx_queue_opname,
2852 (void *)&cmd_config_deferred_start_rxtx_queue_state,
2857 /* *** configure port rxq/txq setup *** */
2858 struct cmd_setup_rxtx_queue {
2859 cmdline_fixed_string_t port;
2861 cmdline_fixed_string_t rxtxq;
2863 cmdline_fixed_string_t setup;
2866 /* Common CLI fields for queue setup */
2867 cmdline_parse_token_string_t cmd_setup_rxtx_queue_port =
2868 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, port, "port");
2869 cmdline_parse_token_num_t cmd_setup_rxtx_queue_portid =
2870 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, portid, UINT16);
2871 cmdline_parse_token_string_t cmd_setup_rxtx_queue_rxtxq =
2872 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, rxtxq, "rxq#txq");
2873 cmdline_parse_token_num_t cmd_setup_rxtx_queue_qid =
2874 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, qid, UINT16);
2875 cmdline_parse_token_string_t cmd_setup_rxtx_queue_setup =
2876 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, setup, "setup");
2879 cmd_setup_rxtx_queue_parsed(
2880 void *parsed_result,
2881 __rte_unused struct cmdline *cl,
2882 __rte_unused void *data)
2884 struct cmd_setup_rxtx_queue *res = parsed_result;
2885 struct rte_port *port;
2886 struct rte_mempool *mp;
2887 unsigned int socket_id;
2891 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2894 if (res->portid == (portid_t)RTE_PORT_ALL) {
2895 printf("Invalid port id\n");
2899 if (!strcmp(res->rxtxq, "rxq"))
2901 else if (!strcmp(res->rxtxq, "txq"))
2904 printf("Unknown parameter\n");
2908 if (isrx && rx_queue_id_is_invalid(res->qid)) {
2909 printf("Invalid rx queue\n");
2911 } else if (!isrx && tx_queue_id_is_invalid(res->qid)) {
2912 printf("Invalid tx queue\n");
2916 port = &ports[res->portid];
2918 socket_id = rxring_numa[res->portid];
2919 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2920 socket_id = port->socket_id;
2922 mp = mbuf_pool_find(socket_id, 0);
2924 printf("Failed to setup RX queue: "
2925 "No mempool allocation"
2926 " on the socket %d\n",
2927 rxring_numa[res->portid]);
2930 ret = rx_queue_setup(res->portid,
2932 port->nb_rx_desc[res->qid],
2934 &port->rx_conf[res->qid],
2937 printf("Failed to setup RX queue\n");
2939 socket_id = txring_numa[res->portid];
2940 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2941 socket_id = port->socket_id;
2943 ret = rte_eth_tx_queue_setup(res->portid,
2945 port->nb_tx_desc[res->qid],
2947 &port->tx_conf[res->qid]);
2949 printf("Failed to setup TX queue\n");
2953 cmdline_parse_inst_t cmd_setup_rxtx_queue = {
2954 .f = cmd_setup_rxtx_queue_parsed,
2956 .help_str = "port <port_id> rxq|txq <queue_idx> setup",
2958 (void *)&cmd_setup_rxtx_queue_port,
2959 (void *)&cmd_setup_rxtx_queue_portid,
2960 (void *)&cmd_setup_rxtx_queue_rxtxq,
2961 (void *)&cmd_setup_rxtx_queue_qid,
2962 (void *)&cmd_setup_rxtx_queue_setup,
2968 /* *** Configure RSS RETA *** */
2969 struct cmd_config_rss_reta {
2970 cmdline_fixed_string_t port;
2971 cmdline_fixed_string_t keyword;
2973 cmdline_fixed_string_t name;
2974 cmdline_fixed_string_t list_name;
2975 cmdline_fixed_string_t list_of_items;
2979 parse_reta_config(const char *str,
2980 struct rte_eth_rss_reta_entry64 *reta_conf,
2981 uint16_t nb_entries)
2985 uint16_t hash_index, idx, shift;
2988 const char *p, *p0 = str;
2995 unsigned long int_fld[_NUM_FLD];
2996 char *str_fld[_NUM_FLD];
2998 while ((p = strchr(p0,'(')) != NULL) {
3000 if((p0 = strchr(p,')')) == NULL)
3004 if(size >= sizeof(s))
3007 snprintf(s, sizeof(s), "%.*s", size, p);
3008 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
3010 for (i = 0; i < _NUM_FLD; i++) {
3012 int_fld[i] = strtoul(str_fld[i], &end, 0);
3013 if (errno != 0 || end == str_fld[i] ||
3018 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
3019 nb_queue = (uint16_t)int_fld[FLD_QUEUE];
3021 if (hash_index >= nb_entries) {
3022 printf("Invalid RETA hash index=%d\n", hash_index);
3026 idx = hash_index / RTE_RETA_GROUP_SIZE;
3027 shift = hash_index % RTE_RETA_GROUP_SIZE;
3028 reta_conf[idx].mask |= (1ULL << shift);
3029 reta_conf[idx].reta[shift] = nb_queue;
3036 cmd_set_rss_reta_parsed(void *parsed_result,
3037 __rte_unused struct cmdline *cl,
3038 __rte_unused void *data)
3041 struct rte_eth_dev_info dev_info;
3042 struct rte_eth_rss_reta_entry64 reta_conf[8];
3043 struct cmd_config_rss_reta *res = parsed_result;
3045 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
3049 if (dev_info.reta_size == 0) {
3050 printf("Redirection table size is 0 which is "
3051 "invalid for RSS\n");
3054 printf("The reta size of port %d is %u\n",
3055 res->port_id, dev_info.reta_size);
3056 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
3057 printf("Currently do not support more than %u entries of "
3058 "redirection table\n", ETH_RSS_RETA_SIZE_512);
3062 memset(reta_conf, 0, sizeof(reta_conf));
3063 if (!strcmp(res->list_name, "reta")) {
3064 if (parse_reta_config(res->list_of_items, reta_conf,
3065 dev_info.reta_size)) {
3066 printf("Invalid RSS Redirection Table "
3067 "config entered\n");
3070 ret = rte_eth_dev_rss_reta_update(res->port_id,
3071 reta_conf, dev_info.reta_size);
3073 printf("Bad redirection table parameter, "
3074 "return code = %d \n", ret);
3078 cmdline_parse_token_string_t cmd_config_rss_reta_port =
3079 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
3080 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
3081 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
3082 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
3083 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT16);
3084 cmdline_parse_token_string_t cmd_config_rss_reta_name =
3085 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
3086 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
3087 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
3088 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
3089 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
3091 cmdline_parse_inst_t cmd_config_rss_reta = {
3092 .f = cmd_set_rss_reta_parsed,
3094 .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
3096 (void *)&cmd_config_rss_reta_port,
3097 (void *)&cmd_config_rss_reta_keyword,
3098 (void *)&cmd_config_rss_reta_port_id,
3099 (void *)&cmd_config_rss_reta_name,
3100 (void *)&cmd_config_rss_reta_list_name,
3101 (void *)&cmd_config_rss_reta_list_of_items,
3106 /* *** SHOW PORT RETA INFO *** */
3107 struct cmd_showport_reta {
3108 cmdline_fixed_string_t show;
3109 cmdline_fixed_string_t port;
3111 cmdline_fixed_string_t rss;
3112 cmdline_fixed_string_t reta;
3114 cmdline_fixed_string_t list_of_items;
3118 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
3119 uint16_t nb_entries,
3123 const char *p, *p0 = str;
3128 uint16_t num = (nb_entries + RTE_RETA_GROUP_SIZE - 1) /
3129 RTE_RETA_GROUP_SIZE;
3132 p = strchr(p0, '(');
3136 p0 = strchr(p, ')');
3140 if (size >= sizeof(s)) {
3141 printf("The string size exceeds the internal buffer size\n");
3144 snprintf(s, sizeof(s), "%.*s", size, p);
3145 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
3146 if (ret <= 0 || ret != num) {
3147 printf("The bits of masks do not match the number of "
3148 "reta entries: %u\n", num);
3151 for (i = 0; i < ret; i++)
3152 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
3158 cmd_showport_reta_parsed(void *parsed_result,
3159 __rte_unused struct cmdline *cl,
3160 __rte_unused void *data)
3162 struct cmd_showport_reta *res = parsed_result;
3163 struct rte_eth_rss_reta_entry64 reta_conf[8];
3164 struct rte_eth_dev_info dev_info;
3165 uint16_t max_reta_size;
3168 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
3172 max_reta_size = RTE_MIN(dev_info.reta_size, ETH_RSS_RETA_SIZE_512);
3173 if (res->size == 0 || res->size > max_reta_size) {
3174 printf("Invalid redirection table size: %u (1-%u)\n",
3175 res->size, max_reta_size);
3179 memset(reta_conf, 0, sizeof(reta_conf));
3180 if (showport_parse_reta_config(reta_conf, res->size,
3181 res->list_of_items) < 0) {
3182 printf("Invalid string: %s for reta masks\n",
3183 res->list_of_items);
3186 port_rss_reta_info(res->port_id, reta_conf, res->size);
3189 cmdline_parse_token_string_t cmd_showport_reta_show =
3190 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
3191 cmdline_parse_token_string_t cmd_showport_reta_port =
3192 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
3193 cmdline_parse_token_num_t cmd_showport_reta_port_id =
3194 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT16);
3195 cmdline_parse_token_string_t cmd_showport_reta_rss =
3196 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
3197 cmdline_parse_token_string_t cmd_showport_reta_reta =
3198 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
3199 cmdline_parse_token_num_t cmd_showport_reta_size =
3200 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16);
3201 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
3202 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
3203 list_of_items, NULL);
3205 cmdline_parse_inst_t cmd_showport_reta = {
3206 .f = cmd_showport_reta_parsed,
3208 .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
3210 (void *)&cmd_showport_reta_show,
3211 (void *)&cmd_showport_reta_port,
3212 (void *)&cmd_showport_reta_port_id,
3213 (void *)&cmd_showport_reta_rss,
3214 (void *)&cmd_showport_reta_reta,
3215 (void *)&cmd_showport_reta_size,
3216 (void *)&cmd_showport_reta_list_of_items,
3221 /* *** Show RSS hash configuration *** */
3222 struct cmd_showport_rss_hash {
3223 cmdline_fixed_string_t show;
3224 cmdline_fixed_string_t port;
3226 cmdline_fixed_string_t rss_hash;
3227 cmdline_fixed_string_t rss_type;
3228 cmdline_fixed_string_t key; /* optional argument */
3231 static void cmd_showport_rss_hash_parsed(void *parsed_result,
3232 __rte_unused struct cmdline *cl,
3235 struct cmd_showport_rss_hash *res = parsed_result;
3237 port_rss_hash_conf_show(res->port_id, show_rss_key != NULL);
3240 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
3241 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
3242 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
3243 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
3244 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
3245 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT16);
3246 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
3247 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
3249 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
3250 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
3252 cmdline_parse_inst_t cmd_showport_rss_hash = {
3253 .f = cmd_showport_rss_hash_parsed,
3255 .help_str = "show port <port_id> rss-hash",
3257 (void *)&cmd_showport_rss_hash_show,
3258 (void *)&cmd_showport_rss_hash_port,
3259 (void *)&cmd_showport_rss_hash_port_id,
3260 (void *)&cmd_showport_rss_hash_rss_hash,
3265 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
3266 .f = cmd_showport_rss_hash_parsed,
3268 .help_str = "show port <port_id> rss-hash key",
3270 (void *)&cmd_showport_rss_hash_show,
3271 (void *)&cmd_showport_rss_hash_port,
3272 (void *)&cmd_showport_rss_hash_port_id,
3273 (void *)&cmd_showport_rss_hash_rss_hash,
3274 (void *)&cmd_showport_rss_hash_rss_key,
3279 /* *** Configure DCB *** */
3280 struct cmd_config_dcb {
3281 cmdline_fixed_string_t port;
3282 cmdline_fixed_string_t config;
3284 cmdline_fixed_string_t dcb;
3285 cmdline_fixed_string_t vt;
3286 cmdline_fixed_string_t vt_en;
3288 cmdline_fixed_string_t pfc;
3289 cmdline_fixed_string_t pfc_en;
3293 cmd_config_dcb_parsed(void *parsed_result,
3294 __rte_unused struct cmdline *cl,
3295 __rte_unused void *data)
3297 struct cmd_config_dcb *res = parsed_result;
3298 portid_t port_id = res->port_id;
3299 struct rte_port *port;
3303 port = &ports[port_id];
3304 /** Check if the port is not started **/
3305 if (port->port_status != RTE_PORT_STOPPED) {
3306 printf("Please stop port %d first\n", port_id);
3310 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
3311 printf("The invalid number of traffic class,"
3312 " only 4 or 8 allowed.\n");
3316 if (nb_fwd_lcores < res->num_tcs) {
3317 printf("nb_cores shouldn't be less than number of TCs.\n");
3320 if (!strncmp(res->pfc_en, "on", 2))
3325 /* DCB in VT mode */
3326 if (!strncmp(res->vt_en, "on", 2))
3327 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
3328 (enum rte_eth_nb_tcs)res->num_tcs,
3331 ret = init_port_dcb_config(port_id, DCB_ENABLED,
3332 (enum rte_eth_nb_tcs)res->num_tcs,
3337 printf("Cannot initialize network ports.\n");
3341 cmd_reconfig_device_queue(port_id, 1, 1);
3344 cmdline_parse_token_string_t cmd_config_dcb_port =
3345 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
3346 cmdline_parse_token_string_t cmd_config_dcb_config =
3347 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
3348 cmdline_parse_token_num_t cmd_config_dcb_port_id =
3349 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT16);
3350 cmdline_parse_token_string_t cmd_config_dcb_dcb =
3351 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
3352 cmdline_parse_token_string_t cmd_config_dcb_vt =
3353 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
3354 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
3355 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
3356 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
3357 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
3358 cmdline_parse_token_string_t cmd_config_dcb_pfc=
3359 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
3360 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
3361 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
3363 cmdline_parse_inst_t cmd_config_dcb = {
3364 .f = cmd_config_dcb_parsed,
3366 .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
3368 (void *)&cmd_config_dcb_port,
3369 (void *)&cmd_config_dcb_config,
3370 (void *)&cmd_config_dcb_port_id,
3371 (void *)&cmd_config_dcb_dcb,
3372 (void *)&cmd_config_dcb_vt,
3373 (void *)&cmd_config_dcb_vt_en,
3374 (void *)&cmd_config_dcb_num_tcs,
3375 (void *)&cmd_config_dcb_pfc,
3376 (void *)&cmd_config_dcb_pfc_en,
3381 /* *** configure number of packets per burst *** */
3382 struct cmd_config_burst {
3383 cmdline_fixed_string_t port;
3384 cmdline_fixed_string_t keyword;
3385 cmdline_fixed_string_t all;
3386 cmdline_fixed_string_t name;
3391 cmd_config_burst_parsed(void *parsed_result,
3392 __rte_unused struct cmdline *cl,
3393 __rte_unused void *data)
3395 struct cmd_config_burst *res = parsed_result;
3396 struct rte_eth_dev_info dev_info;
3397 uint16_t rec_nb_pkts;
3400 if (!all_ports_stopped()) {
3401 printf("Please stop all ports first\n");
3405 if (!strcmp(res->name, "burst")) {
3406 if (res->value == 0) {
3407 /* If user gives a value of zero, query the PMD for
3408 * its recommended Rx burst size. Testpmd uses a single
3409 * size for all ports, so assume all ports are the same
3410 * NIC model and use the values from Port 0.
3412 ret = eth_dev_info_get_print_err(0, &dev_info);
3416 rec_nb_pkts = dev_info.default_rxportconf.burst_size;
3418 if (rec_nb_pkts == 0) {
3419 printf("PMD does not recommend a burst size.\n"
3420 "User provided value must be between"
3421 " 1 and %d\n", MAX_PKT_BURST);
3423 } else if (rec_nb_pkts > MAX_PKT_BURST) {
3424 printf("PMD recommended burst size of %d"
3425 " exceeds maximum value of %d\n",
3426 rec_nb_pkts, MAX_PKT_BURST);
3429 printf("Using PMD-provided burst value of %d\n",
3431 nb_pkt_per_burst = rec_nb_pkts;
3432 } else if (res->value > MAX_PKT_BURST) {
3433 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
3436 nb_pkt_per_burst = res->value;
3438 printf("Unknown parameter\n");
3444 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3447 cmdline_parse_token_string_t cmd_config_burst_port =
3448 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
3449 cmdline_parse_token_string_t cmd_config_burst_keyword =
3450 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
3451 cmdline_parse_token_string_t cmd_config_burst_all =
3452 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
3453 cmdline_parse_token_string_t cmd_config_burst_name =
3454 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
3455 cmdline_parse_token_num_t cmd_config_burst_value =
3456 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
3458 cmdline_parse_inst_t cmd_config_burst = {
3459 .f = cmd_config_burst_parsed,
3461 .help_str = "port config all burst <value>",
3463 (void *)&cmd_config_burst_port,
3464 (void *)&cmd_config_burst_keyword,
3465 (void *)&cmd_config_burst_all,
3466 (void *)&cmd_config_burst_name,
3467 (void *)&cmd_config_burst_value,
3472 /* *** configure rx/tx queues *** */
3473 struct cmd_config_thresh {
3474 cmdline_fixed_string_t port;
3475 cmdline_fixed_string_t keyword;
3476 cmdline_fixed_string_t all;
3477 cmdline_fixed_string_t name;
3482 cmd_config_thresh_parsed(void *parsed_result,
3483 __rte_unused struct cmdline *cl,
3484 __rte_unused void *data)
3486 struct cmd_config_thresh *res = parsed_result;
3488 if (!all_ports_stopped()) {
3489 printf("Please stop all ports first\n");
3493 if (!strcmp(res->name, "txpt"))
3494 tx_pthresh = res->value;
3495 else if(!strcmp(res->name, "txht"))
3496 tx_hthresh = res->value;
3497 else if(!strcmp(res->name, "txwt"))
3498 tx_wthresh = res->value;
3499 else if(!strcmp(res->name, "rxpt"))
3500 rx_pthresh = res->value;
3501 else if(!strcmp(res->name, "rxht"))
3502 rx_hthresh = res->value;
3503 else if(!strcmp(res->name, "rxwt"))
3504 rx_wthresh = res->value;
3506 printf("Unknown parameter\n");
3512 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3515 cmdline_parse_token_string_t cmd_config_thresh_port =
3516 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
3517 cmdline_parse_token_string_t cmd_config_thresh_keyword =
3518 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
3519 cmdline_parse_token_string_t cmd_config_thresh_all =
3520 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
3521 cmdline_parse_token_string_t cmd_config_thresh_name =
3522 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
3523 "txpt#txht#txwt#rxpt#rxht#rxwt");
3524 cmdline_parse_token_num_t cmd_config_thresh_value =
3525 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
3527 cmdline_parse_inst_t cmd_config_thresh = {
3528 .f = cmd_config_thresh_parsed,
3530 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
3532 (void *)&cmd_config_thresh_port,
3533 (void *)&cmd_config_thresh_keyword,
3534 (void *)&cmd_config_thresh_all,
3535 (void *)&cmd_config_thresh_name,
3536 (void *)&cmd_config_thresh_value,
3541 /* *** configure free/rs threshold *** */
3542 struct cmd_config_threshold {
3543 cmdline_fixed_string_t port;
3544 cmdline_fixed_string_t keyword;
3545 cmdline_fixed_string_t all;
3546 cmdline_fixed_string_t name;
3551 cmd_config_threshold_parsed(void *parsed_result,
3552 __rte_unused struct cmdline *cl,
3553 __rte_unused void *data)
3555 struct cmd_config_threshold *res = parsed_result;
3557 if (!all_ports_stopped()) {
3558 printf("Please stop all ports first\n");
3562 if (!strcmp(res->name, "txfreet"))
3563 tx_free_thresh = res->value;
3564 else if (!strcmp(res->name, "txrst"))
3565 tx_rs_thresh = res->value;
3566 else if (!strcmp(res->name, "rxfreet"))
3567 rx_free_thresh = res->value;
3569 printf("Unknown parameter\n");
3575 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3578 cmdline_parse_token_string_t cmd_config_threshold_port =
3579 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
3580 cmdline_parse_token_string_t cmd_config_threshold_keyword =
3581 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
3583 cmdline_parse_token_string_t cmd_config_threshold_all =
3584 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
3585 cmdline_parse_token_string_t cmd_config_threshold_name =
3586 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
3587 "txfreet#txrst#rxfreet");
3588 cmdline_parse_token_num_t cmd_config_threshold_value =
3589 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
3591 cmdline_parse_inst_t cmd_config_threshold = {
3592 .f = cmd_config_threshold_parsed,
3594 .help_str = "port config all txfreet|txrst|rxfreet <value>",
3596 (void *)&cmd_config_threshold_port,
3597 (void *)&cmd_config_threshold_keyword,
3598 (void *)&cmd_config_threshold_all,
3599 (void *)&cmd_config_threshold_name,
3600 (void *)&cmd_config_threshold_value,
3606 struct cmd_stop_result {
3607 cmdline_fixed_string_t stop;
3610 static void cmd_stop_parsed(__rte_unused void *parsed_result,
3611 __rte_unused struct cmdline *cl,
3612 __rte_unused void *data)
3614 stop_packet_forwarding();
3617 cmdline_parse_token_string_t cmd_stop_stop =
3618 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
3620 cmdline_parse_inst_t cmd_stop = {
3621 .f = cmd_stop_parsed,
3623 .help_str = "stop: Stop packet forwarding",
3625 (void *)&cmd_stop_stop,
3630 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
3633 parse_item_list(char* str, const char* item_name, unsigned int max_items,
3634 unsigned int *parsed_items, int check_unique_values)
3636 unsigned int nb_item;
3644 * First parse all items in the list and store their value.
3649 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
3651 if ((c >= '0') && (c <= '9')) {
3652 value = (unsigned int) (value * 10 + (c - '0'));
3657 printf("character %c is not a decimal digit\n", c);
3661 printf("No valid value before comma\n");
3664 if (nb_item < max_items) {
3665 parsed_items[nb_item] = value;
3671 if (nb_item >= max_items) {
3672 printf("Number of %s = %u > %u (maximum items)\n",
3673 item_name, nb_item + 1, max_items);
3676 parsed_items[nb_item++] = value;
3677 if (! check_unique_values)
3681 * Then, check that all values in the list are differents.
3682 * No optimization here...
3684 for (i = 0; i < nb_item; i++) {
3685 for (j = i + 1; j < nb_item; j++) {
3686 if (parsed_items[j] == parsed_items[i]) {
3687 printf("duplicated %s %u at index %u and %u\n",
3688 item_name, parsed_items[i], i, j);
3696 struct cmd_set_list_result {
3697 cmdline_fixed_string_t cmd_keyword;
3698 cmdline_fixed_string_t list_name;
3699 cmdline_fixed_string_t list_of_items;
3702 static void cmd_set_list_parsed(void *parsed_result,
3703 __rte_unused struct cmdline *cl,
3704 __rte_unused void *data)
3706 struct cmd_set_list_result *res;
3708 unsigned int lcorelist[RTE_MAX_LCORE];
3709 unsigned int portlist[RTE_MAX_ETHPORTS];
3711 unsigned int nb_item;
3713 if (test_done == 0) {
3714 printf("Please stop forwarding first\n");
3718 res = parsed_result;
3719 if (!strcmp(res->list_name, "corelist")) {
3720 nb_item = parse_item_list(res->list_of_items, "core",
3722 parsed_items.lcorelist, 1);
3724 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
3729 if (!strcmp(res->list_name, "portlist")) {
3730 nb_item = parse_item_list(res->list_of_items, "port",
3732 parsed_items.portlist, 1);
3734 set_fwd_ports_list(parsed_items.portlist, nb_item);
3740 cmdline_parse_token_string_t cmd_set_list_keyword =
3741 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
3743 cmdline_parse_token_string_t cmd_set_list_name =
3744 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
3745 "corelist#portlist");
3746 cmdline_parse_token_string_t cmd_set_list_of_items =
3747 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
3750 cmdline_parse_inst_t cmd_set_fwd_list = {
3751 .f = cmd_set_list_parsed,
3753 .help_str = "set corelist|portlist <list0[,list1]*>",
3755 (void *)&cmd_set_list_keyword,
3756 (void *)&cmd_set_list_name,
3757 (void *)&cmd_set_list_of_items,
3762 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
3764 struct cmd_setmask_result {
3765 cmdline_fixed_string_t set;
3766 cmdline_fixed_string_t mask;
3770 static void cmd_set_mask_parsed(void *parsed_result,
3771 __rte_unused struct cmdline *cl,
3772 __rte_unused void *data)
3774 struct cmd_setmask_result *res = parsed_result;
3776 if (test_done == 0) {
3777 printf("Please stop forwarding first\n");
3780 if (!strcmp(res->mask, "coremask")) {
3781 set_fwd_lcores_mask(res->hexavalue);
3783 } else if (!strcmp(res->mask, "portmask")) {
3784 set_fwd_ports_mask(res->hexavalue);
3789 cmdline_parse_token_string_t cmd_setmask_set =
3790 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
3791 cmdline_parse_token_string_t cmd_setmask_mask =
3792 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
3793 "coremask#portmask");
3794 cmdline_parse_token_num_t cmd_setmask_value =
3795 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
3797 cmdline_parse_inst_t cmd_set_fwd_mask = {
3798 .f = cmd_set_mask_parsed,
3800 .help_str = "set coremask|portmask <hexadecimal value>",
3802 (void *)&cmd_setmask_set,
3803 (void *)&cmd_setmask_mask,
3804 (void *)&cmd_setmask_value,
3810 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
3812 struct cmd_set_result {
3813 cmdline_fixed_string_t set;
3814 cmdline_fixed_string_t what;
3818 static void cmd_set_parsed(void *parsed_result,
3819 __rte_unused struct cmdline *cl,
3820 __rte_unused void *data)
3822 struct cmd_set_result *res = parsed_result;
3823 if (!strcmp(res->what, "nbport")) {
3824 set_fwd_ports_number(res->value);
3826 } else if (!strcmp(res->what, "nbcore")) {
3827 set_fwd_lcores_number(res->value);
3829 } else if (!strcmp(res->what, "burst"))
3830 set_nb_pkt_per_burst(res->value);
3831 else if (!strcmp(res->what, "verbose"))
3832 set_verbose_level(res->value);
3835 cmdline_parse_token_string_t cmd_set_set =
3836 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
3837 cmdline_parse_token_string_t cmd_set_what =
3838 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
3839 "nbport#nbcore#burst#verbose");
3840 cmdline_parse_token_num_t cmd_set_value =
3841 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
3843 cmdline_parse_inst_t cmd_set_numbers = {
3844 .f = cmd_set_parsed,
3846 .help_str = "set nbport|nbcore|burst|verbose <value>",
3848 (void *)&cmd_set_set,
3849 (void *)&cmd_set_what,
3850 (void *)&cmd_set_value,
3855 /* *** SET LOG LEVEL CONFIGURATION *** */
3857 struct cmd_set_log_result {
3858 cmdline_fixed_string_t set;
3859 cmdline_fixed_string_t log;
3860 cmdline_fixed_string_t type;
3865 cmd_set_log_parsed(void *parsed_result,
3866 __rte_unused struct cmdline *cl,
3867 __rte_unused void *data)
3869 struct cmd_set_log_result *res;
3872 res = parsed_result;
3873 if (!strcmp(res->type, "global"))
3874 rte_log_set_global_level(res->level);
3876 ret = rte_log_set_level_regexp(res->type, res->level);
3878 printf("Unable to set log level\n");
3882 cmdline_parse_token_string_t cmd_set_log_set =
3883 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, set, "set");
3884 cmdline_parse_token_string_t cmd_set_log_log =
3885 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, log, "log");
3886 cmdline_parse_token_string_t cmd_set_log_type =
3887 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, type, NULL);
3888 cmdline_parse_token_num_t cmd_set_log_level =
3889 TOKEN_NUM_INITIALIZER(struct cmd_set_log_result, level, UINT32);
3891 cmdline_parse_inst_t cmd_set_log = {
3892 .f = cmd_set_log_parsed,
3894 .help_str = "set log global|<type> <level>",
3896 (void *)&cmd_set_log_set,
3897 (void *)&cmd_set_log_log,
3898 (void *)&cmd_set_log_type,
3899 (void *)&cmd_set_log_level,
3904 /* *** SET SEGMENT OFFSETS OF RX PACKETS SPLIT *** */
3906 struct cmd_set_rxoffs_result {
3907 cmdline_fixed_string_t cmd_keyword;
3908 cmdline_fixed_string_t rxoffs;
3909 cmdline_fixed_string_t seg_offsets;
3913 cmd_set_rxoffs_parsed(void *parsed_result,
3914 __rte_unused struct cmdline *cl,
3915 __rte_unused void *data)
3917 struct cmd_set_rxoffs_result *res;
3918 unsigned int seg_offsets[MAX_SEGS_BUFFER_SPLIT];
3919 unsigned int nb_segs;
3921 res = parsed_result;
3922 nb_segs = parse_item_list(res->seg_offsets, "segment offsets",
3923 MAX_SEGS_BUFFER_SPLIT, seg_offsets, 0);
3925 set_rx_pkt_offsets(seg_offsets, nb_segs);
3928 cmdline_parse_token_string_t cmd_set_rxoffs_keyword =
3929 TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
3930 cmd_keyword, "set");
3931 cmdline_parse_token_string_t cmd_set_rxoffs_name =
3932 TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
3934 cmdline_parse_token_string_t cmd_set_rxoffs_offsets =
3935 TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
3938 cmdline_parse_inst_t cmd_set_rxoffs = {
3939 .f = cmd_set_rxoffs_parsed,
3941 .help_str = "set rxoffs <len0[,len1]*>",
3943 (void *)&cmd_set_rxoffs_keyword,
3944 (void *)&cmd_set_rxoffs_name,
3945 (void *)&cmd_set_rxoffs_offsets,
3950 /* *** SET SEGMENT LENGTHS OF RX PACKETS SPLIT *** */
3952 struct cmd_set_rxpkts_result {
3953 cmdline_fixed_string_t cmd_keyword;
3954 cmdline_fixed_string_t rxpkts;
3955 cmdline_fixed_string_t seg_lengths;
3959 cmd_set_rxpkts_parsed(void *parsed_result,
3960 __rte_unused struct cmdline *cl,
3961 __rte_unused void *data)
3963 struct cmd_set_rxpkts_result *res;
3964 unsigned int seg_lengths[MAX_SEGS_BUFFER_SPLIT];
3965 unsigned int nb_segs;
3967 res = parsed_result;
3968 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
3969 MAX_SEGS_BUFFER_SPLIT, seg_lengths, 0);
3971 set_rx_pkt_segments(seg_lengths, nb_segs);
3974 cmdline_parse_token_string_t cmd_set_rxpkts_keyword =
3975 TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
3976 cmd_keyword, "set");
3977 cmdline_parse_token_string_t cmd_set_rxpkts_name =
3978 TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
3980 cmdline_parse_token_string_t cmd_set_rxpkts_lengths =
3981 TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
3984 cmdline_parse_inst_t cmd_set_rxpkts = {
3985 .f = cmd_set_rxpkts_parsed,
3987 .help_str = "set rxpkts <len0[,len1]*>",
3989 (void *)&cmd_set_rxpkts_keyword,
3990 (void *)&cmd_set_rxpkts_name,
3991 (void *)&cmd_set_rxpkts_lengths,
3996 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
3998 struct cmd_set_txpkts_result {
3999 cmdline_fixed_string_t cmd_keyword;
4000 cmdline_fixed_string_t txpkts;
4001 cmdline_fixed_string_t seg_lengths;
4005 cmd_set_txpkts_parsed(void *parsed_result,
4006 __rte_unused struct cmdline *cl,
4007 __rte_unused void *data)
4009 struct cmd_set_txpkts_result *res;
4010 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
4011 unsigned int nb_segs;
4013 res = parsed_result;
4014 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
4015 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
4017 set_tx_pkt_segments(seg_lengths, nb_segs);
4020 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
4021 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
4022 cmd_keyword, "set");
4023 cmdline_parse_token_string_t cmd_set_txpkts_name =
4024 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
4026 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
4027 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
4030 cmdline_parse_inst_t cmd_set_txpkts = {
4031 .f = cmd_set_txpkts_parsed,
4033 .help_str = "set txpkts <len0[,len1]*>",
4035 (void *)&cmd_set_txpkts_keyword,
4036 (void *)&cmd_set_txpkts_name,
4037 (void *)&cmd_set_txpkts_lengths,
4042 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
4044 struct cmd_set_txsplit_result {
4045 cmdline_fixed_string_t cmd_keyword;
4046 cmdline_fixed_string_t txsplit;
4047 cmdline_fixed_string_t mode;
4051 cmd_set_txsplit_parsed(void *parsed_result,
4052 __rte_unused struct cmdline *cl,
4053 __rte_unused void *data)
4055 struct cmd_set_txsplit_result *res;
4057 res = parsed_result;
4058 set_tx_pkt_split(res->mode);
4061 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
4062 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
4063 cmd_keyword, "set");
4064 cmdline_parse_token_string_t cmd_set_txsplit_name =
4065 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
4066 txsplit, "txsplit");
4067 cmdline_parse_token_string_t cmd_set_txsplit_mode =
4068 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
4071 cmdline_parse_inst_t cmd_set_txsplit = {
4072 .f = cmd_set_txsplit_parsed,
4074 .help_str = "set txsplit on|off|rand",
4076 (void *)&cmd_set_txsplit_keyword,
4077 (void *)&cmd_set_txsplit_name,
4078 (void *)&cmd_set_txsplit_mode,
4083 /* *** SET TIMES FOR TXONLY PACKETS SCHEDULING ON TIMESTAMPS *** */
4085 struct cmd_set_txtimes_result {
4086 cmdline_fixed_string_t cmd_keyword;
4087 cmdline_fixed_string_t txtimes;
4088 cmdline_fixed_string_t tx_times;
4092 cmd_set_txtimes_parsed(void *parsed_result,
4093 __rte_unused struct cmdline *cl,
4094 __rte_unused void *data)
4096 struct cmd_set_txtimes_result *res;
4097 unsigned int tx_times[2] = {0, 0};
4098 unsigned int n_times;
4100 res = parsed_result;
4101 n_times = parse_item_list(res->tx_times, "tx times",
4104 set_tx_pkt_times(tx_times);
4107 cmdline_parse_token_string_t cmd_set_txtimes_keyword =
4108 TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
4109 cmd_keyword, "set");
4110 cmdline_parse_token_string_t cmd_set_txtimes_name =
4111 TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
4112 txtimes, "txtimes");
4113 cmdline_parse_token_string_t cmd_set_txtimes_value =
4114 TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
4117 cmdline_parse_inst_t cmd_set_txtimes = {
4118 .f = cmd_set_txtimes_parsed,
4120 .help_str = "set txtimes <inter_burst>,<intra_burst>",
4122 (void *)&cmd_set_txtimes_keyword,
4123 (void *)&cmd_set_txtimes_name,
4124 (void *)&cmd_set_txtimes_value,
4129 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
4130 struct cmd_rx_vlan_filter_all_result {
4131 cmdline_fixed_string_t rx_vlan;
4132 cmdline_fixed_string_t what;
4133 cmdline_fixed_string_t all;
4138 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
4139 __rte_unused struct cmdline *cl,
4140 __rte_unused void *data)
4142 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
4144 if (!strcmp(res->what, "add"))
4145 rx_vlan_all_filter_set(res->port_id, 1);
4147 rx_vlan_all_filter_set(res->port_id, 0);
4150 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
4151 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4152 rx_vlan, "rx_vlan");
4153 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
4154 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4156 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
4157 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4159 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
4160 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4163 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
4164 .f = cmd_rx_vlan_filter_all_parsed,
4166 .help_str = "rx_vlan add|rm all <port_id>: "
4167 "Add/Remove all identifiers to/from the set of VLAN "
4168 "identifiers filtered by a port",
4170 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
4171 (void *)&cmd_rx_vlan_filter_all_what,
4172 (void *)&cmd_rx_vlan_filter_all_all,
4173 (void *)&cmd_rx_vlan_filter_all_portid,
4178 /* *** VLAN OFFLOAD SET ON A PORT *** */
4179 struct cmd_vlan_offload_result {
4180 cmdline_fixed_string_t vlan;
4181 cmdline_fixed_string_t set;
4182 cmdline_fixed_string_t vlan_type;
4183 cmdline_fixed_string_t what;
4184 cmdline_fixed_string_t on;
4185 cmdline_fixed_string_t port_id;
4189 cmd_vlan_offload_parsed(void *parsed_result,
4190 __rte_unused struct cmdline *cl,
4191 __rte_unused void *data)
4194 struct cmd_vlan_offload_result *res = parsed_result;
4197 portid_t port_id = 0;
4201 len = strnlen(str, STR_TOKEN_SIZE);
4203 /* Get port_id first */
4211 tmp = strtoul(str, NULL, 0);
4212 /* If port_id greater that what portid_t can represent, return */
4213 if(tmp >= RTE_MAX_ETHPORTS)
4215 port_id = (portid_t)tmp;
4217 if (!strcmp(res->on, "on"))
4222 if (!strcmp(res->what, "strip"))
4223 rx_vlan_strip_set(port_id, on);
4224 else if(!strcmp(res->what, "stripq")){
4225 uint16_t queue_id = 0;
4227 /* No queue_id, return */
4229 printf("must specify (port,queue_id)\n");
4232 tmp = strtoul(str + i + 1, NULL, 0);
4233 /* If queue_id greater that what 16-bits can represent, return */
4237 queue_id = (uint16_t)tmp;
4238 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
4240 else if (!strcmp(res->what, "filter"))
4241 rx_vlan_filter_set(port_id, on);
4242 else if (!strcmp(res->what, "qinq_strip"))
4243 rx_vlan_qinq_strip_set(port_id, on);
4245 vlan_extend_set(port_id, on);
4250 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
4251 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4253 cmdline_parse_token_string_t cmd_vlan_offload_set =
4254 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4256 cmdline_parse_token_string_t cmd_vlan_offload_what =
4257 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4258 what, "strip#filter#qinq_strip#extend#stripq");
4259 cmdline_parse_token_string_t cmd_vlan_offload_on =
4260 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4262 cmdline_parse_token_string_t cmd_vlan_offload_portid =
4263 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4266 cmdline_parse_inst_t cmd_vlan_offload = {
4267 .f = cmd_vlan_offload_parsed,
4269 .help_str = "vlan set strip|filter|qinq_strip|extend|stripq on|off "
4270 "<port_id[,queue_id]>: "
4271 "Strip/Filter/QinQ for rx side Extend for both rx/tx sides",
4273 (void *)&cmd_vlan_offload_vlan,
4274 (void *)&cmd_vlan_offload_set,
4275 (void *)&cmd_vlan_offload_what,
4276 (void *)&cmd_vlan_offload_on,
4277 (void *)&cmd_vlan_offload_portid,
4282 /* *** VLAN TPID SET ON A PORT *** */
4283 struct cmd_vlan_tpid_result {
4284 cmdline_fixed_string_t vlan;
4285 cmdline_fixed_string_t set;
4286 cmdline_fixed_string_t vlan_type;
4287 cmdline_fixed_string_t what;
4293 cmd_vlan_tpid_parsed(void *parsed_result,
4294 __rte_unused struct cmdline *cl,
4295 __rte_unused void *data)
4297 struct cmd_vlan_tpid_result *res = parsed_result;
4298 enum rte_vlan_type vlan_type;
4300 if (!strcmp(res->vlan_type, "inner"))
4301 vlan_type = ETH_VLAN_TYPE_INNER;
4302 else if (!strcmp(res->vlan_type, "outer"))
4303 vlan_type = ETH_VLAN_TYPE_OUTER;
4305 printf("Unknown vlan type\n");
4308 vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
4311 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
4312 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4314 cmdline_parse_token_string_t cmd_vlan_tpid_set =
4315 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4317 cmdline_parse_token_string_t cmd_vlan_type =
4318 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4319 vlan_type, "inner#outer");
4320 cmdline_parse_token_string_t cmd_vlan_tpid_what =
4321 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4323 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
4324 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4326 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
4327 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4330 cmdline_parse_inst_t cmd_vlan_tpid = {
4331 .f = cmd_vlan_tpid_parsed,
4333 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
4334 "Set the VLAN Ether type",
4336 (void *)&cmd_vlan_tpid_vlan,
4337 (void *)&cmd_vlan_tpid_set,
4338 (void *)&cmd_vlan_type,
4339 (void *)&cmd_vlan_tpid_what,
4340 (void *)&cmd_vlan_tpid_tpid,
4341 (void *)&cmd_vlan_tpid_portid,
4346 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
4347 struct cmd_rx_vlan_filter_result {
4348 cmdline_fixed_string_t rx_vlan;
4349 cmdline_fixed_string_t what;
4355 cmd_rx_vlan_filter_parsed(void *parsed_result,
4356 __rte_unused struct cmdline *cl,
4357 __rte_unused void *data)
4359 struct cmd_rx_vlan_filter_result *res = parsed_result;
4361 if (!strcmp(res->what, "add"))
4362 rx_vft_set(res->port_id, res->vlan_id, 1);
4364 rx_vft_set(res->port_id, res->vlan_id, 0);
4367 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
4368 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4369 rx_vlan, "rx_vlan");
4370 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
4371 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4373 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
4374 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4376 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
4377 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4380 cmdline_parse_inst_t cmd_rx_vlan_filter = {
4381 .f = cmd_rx_vlan_filter_parsed,
4383 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
4384 "Add/Remove a VLAN identifier to/from the set of VLAN "
4385 "identifiers filtered by a port",
4387 (void *)&cmd_rx_vlan_filter_rx_vlan,
4388 (void *)&cmd_rx_vlan_filter_what,
4389 (void *)&cmd_rx_vlan_filter_vlanid,
4390 (void *)&cmd_rx_vlan_filter_portid,
4395 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4396 struct cmd_tx_vlan_set_result {
4397 cmdline_fixed_string_t tx_vlan;
4398 cmdline_fixed_string_t set;
4404 cmd_tx_vlan_set_parsed(void *parsed_result,
4405 __rte_unused struct cmdline *cl,
4406 __rte_unused void *data)
4408 struct cmd_tx_vlan_set_result *res = parsed_result;
4410 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4413 if (!port_is_stopped(res->port_id)) {
4414 printf("Please stop port %d first\n", res->port_id);
4418 tx_vlan_set(res->port_id, res->vlan_id);
4420 cmd_reconfig_device_queue(res->port_id, 1, 1);
4423 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
4424 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4425 tx_vlan, "tx_vlan");
4426 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
4427 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4429 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
4430 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4432 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
4433 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4436 cmdline_parse_inst_t cmd_tx_vlan_set = {
4437 .f = cmd_tx_vlan_set_parsed,
4439 .help_str = "tx_vlan set <port_id> <vlan_id>: "
4440 "Enable hardware insertion of a single VLAN header "
4441 "with a given TAG Identifier in packets sent on a port",
4443 (void *)&cmd_tx_vlan_set_tx_vlan,
4444 (void *)&cmd_tx_vlan_set_set,
4445 (void *)&cmd_tx_vlan_set_portid,
4446 (void *)&cmd_tx_vlan_set_vlanid,
4451 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
4452 struct cmd_tx_vlan_set_qinq_result {
4453 cmdline_fixed_string_t tx_vlan;
4454 cmdline_fixed_string_t set;
4457 uint16_t vlan_id_outer;
4461 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
4462 __rte_unused struct cmdline *cl,
4463 __rte_unused void *data)
4465 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
4467 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4470 if (!port_is_stopped(res->port_id)) {
4471 printf("Please stop port %d first\n", res->port_id);
4475 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
4477 cmd_reconfig_device_queue(res->port_id, 1, 1);
4480 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
4481 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4482 tx_vlan, "tx_vlan");
4483 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
4484 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4486 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
4487 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4489 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
4490 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4492 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
4493 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4494 vlan_id_outer, UINT16);
4496 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
4497 .f = cmd_tx_vlan_set_qinq_parsed,
4499 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
4500 "Enable hardware insertion of double VLAN header "
4501 "with given TAG Identifiers in packets sent on a port",
4503 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
4504 (void *)&cmd_tx_vlan_set_qinq_set,
4505 (void *)&cmd_tx_vlan_set_qinq_portid,
4506 (void *)&cmd_tx_vlan_set_qinq_vlanid,
4507 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
4512 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
4513 struct cmd_tx_vlan_set_pvid_result {
4514 cmdline_fixed_string_t tx_vlan;
4515 cmdline_fixed_string_t set;
4516 cmdline_fixed_string_t pvid;
4519 cmdline_fixed_string_t mode;
4523 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
4524 __rte_unused struct cmdline *cl,
4525 __rte_unused void *data)
4527 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
4529 if (strcmp(res->mode, "on") == 0)
4530 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
4532 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
4535 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
4536 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4537 tx_vlan, "tx_vlan");
4538 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
4539 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4541 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
4542 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4544 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
4545 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4547 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
4548 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4550 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
4551 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4554 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
4555 .f = cmd_tx_vlan_set_pvid_parsed,
4557 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
4559 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
4560 (void *)&cmd_tx_vlan_set_pvid_set,
4561 (void *)&cmd_tx_vlan_set_pvid_pvid,
4562 (void *)&cmd_tx_vlan_set_pvid_port_id,
4563 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
4564 (void *)&cmd_tx_vlan_set_pvid_mode,
4569 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4570 struct cmd_tx_vlan_reset_result {
4571 cmdline_fixed_string_t tx_vlan;
4572 cmdline_fixed_string_t reset;
4577 cmd_tx_vlan_reset_parsed(void *parsed_result,
4578 __rte_unused struct cmdline *cl,
4579 __rte_unused void *data)
4581 struct cmd_tx_vlan_reset_result *res = parsed_result;
4583 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4586 if (!port_is_stopped(res->port_id)) {
4587 printf("Please stop port %d first\n", res->port_id);
4591 tx_vlan_reset(res->port_id);
4593 cmd_reconfig_device_queue(res->port_id, 1, 1);
4596 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
4597 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4598 tx_vlan, "tx_vlan");
4599 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
4600 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4602 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
4603 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
4606 cmdline_parse_inst_t cmd_tx_vlan_reset = {
4607 .f = cmd_tx_vlan_reset_parsed,
4609 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
4610 "VLAN header in packets sent on a port",
4612 (void *)&cmd_tx_vlan_reset_tx_vlan,
4613 (void *)&cmd_tx_vlan_reset_reset,
4614 (void *)&cmd_tx_vlan_reset_portid,
4620 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
4621 struct cmd_csum_result {
4622 cmdline_fixed_string_t csum;
4623 cmdline_fixed_string_t mode;
4624 cmdline_fixed_string_t proto;
4625 cmdline_fixed_string_t hwsw;
4630 csum_show(int port_id)
4632 struct rte_eth_dev_info dev_info;
4633 uint64_t tx_offloads;
4636 tx_offloads = ports[port_id].dev_conf.txmode.offloads;
4637 printf("Parse tunnel is %s\n",
4638 (ports[port_id].parse_tunnel) ? "on" : "off");
4639 printf("IP checksum offload is %s\n",
4640 (tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) ? "hw" : "sw");
4641 printf("UDP checksum offload is %s\n",
4642 (tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
4643 printf("TCP checksum offload is %s\n",
4644 (tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
4645 printf("SCTP checksum offload is %s\n",
4646 (tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
4647 printf("Outer-Ip checksum offload is %s\n",
4648 (tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) ? "hw" : "sw");
4649 printf("Outer-Udp checksum offload is %s\n",
4650 (tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) ? "hw" : "sw");
4652 /* display warnings if configuration is not supported by the NIC */
4653 ret = eth_dev_info_get_print_err(port_id, &dev_info);
4657 if ((tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) &&
4658 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
4659 printf("Warning: hardware IP checksum enabled but not "
4660 "supported by port %d\n", port_id);
4662 if ((tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) &&
4663 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
4664 printf("Warning: hardware UDP checksum enabled but not "
4665 "supported by port %d\n", port_id);
4667 if ((tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) &&
4668 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
4669 printf("Warning: hardware TCP checksum enabled but not "
4670 "supported by port %d\n", port_id);
4672 if ((tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) &&
4673 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
4674 printf("Warning: hardware SCTP checksum enabled but not "
4675 "supported by port %d\n", port_id);
4677 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) &&
4678 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
4679 printf("Warning: hardware outer IP checksum enabled but not "
4680 "supported by port %d\n", port_id);
4682 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) &&
4683 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)
4685 printf("Warning: hardware outer UDP checksum enabled but not "
4686 "supported by port %d\n", port_id);
4691 cmd_config_queue_tx_offloads(struct rte_port *port)
4695 /* Apply queue tx offloads configuration */
4696 for (k = 0; k < port->dev_info.max_rx_queues; k++)
4697 port->tx_conf[k].offloads =
4698 port->dev_conf.txmode.offloads;
4702 cmd_csum_parsed(void *parsed_result,
4703 __rte_unused struct cmdline *cl,
4704 __rte_unused void *data)
4706 struct cmd_csum_result *res = parsed_result;
4708 uint64_t csum_offloads = 0;
4709 struct rte_eth_dev_info dev_info;
4712 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
4713 printf("invalid port %d\n", res->port_id);
4716 if (!port_is_stopped(res->port_id)) {
4717 printf("Please stop port %d first\n", res->port_id);
4721 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4725 if (!strcmp(res->mode, "set")) {
4727 if (!strcmp(res->hwsw, "hw"))
4730 if (!strcmp(res->proto, "ip")) {
4731 if (hw == 0 || (dev_info.tx_offload_capa &
4732 DEV_TX_OFFLOAD_IPV4_CKSUM)) {
4733 csum_offloads |= DEV_TX_OFFLOAD_IPV4_CKSUM;
4735 printf("IP checksum offload is not supported "
4736 "by port %u\n", res->port_id);
4738 } else if (!strcmp(res->proto, "udp")) {
4739 if (hw == 0 || (dev_info.tx_offload_capa &
4740 DEV_TX_OFFLOAD_UDP_CKSUM)) {
4741 csum_offloads |= DEV_TX_OFFLOAD_UDP_CKSUM;
4743 printf("UDP checksum offload is not supported "
4744 "by port %u\n", res->port_id);
4746 } else if (!strcmp(res->proto, "tcp")) {
4747 if (hw == 0 || (dev_info.tx_offload_capa &
4748 DEV_TX_OFFLOAD_TCP_CKSUM)) {
4749 csum_offloads |= DEV_TX_OFFLOAD_TCP_CKSUM;
4751 printf("TCP checksum offload is not supported "
4752 "by port %u\n", res->port_id);
4754 } else if (!strcmp(res->proto, "sctp")) {
4755 if (hw == 0 || (dev_info.tx_offload_capa &
4756 DEV_TX_OFFLOAD_SCTP_CKSUM)) {
4757 csum_offloads |= DEV_TX_OFFLOAD_SCTP_CKSUM;
4759 printf("SCTP checksum offload is not supported "
4760 "by port %u\n", res->port_id);
4762 } else if (!strcmp(res->proto, "outer-ip")) {
4763 if (hw == 0 || (dev_info.tx_offload_capa &
4764 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM)) {
4766 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM;
4768 printf("Outer IP checksum offload is not "
4769 "supported by port %u\n", res->port_id);
4771 } else if (!strcmp(res->proto, "outer-udp")) {
4772 if (hw == 0 || (dev_info.tx_offload_capa &
4773 DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)) {
4775 DEV_TX_OFFLOAD_OUTER_UDP_CKSUM;
4777 printf("Outer UDP checksum offload is not "
4778 "supported by port %u\n", res->port_id);
4783 ports[res->port_id].dev_conf.txmode.offloads |=
4786 ports[res->port_id].dev_conf.txmode.offloads &=
4789 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4791 csum_show(res->port_id);
4793 cmd_reconfig_device_queue(res->port_id, 1, 1);
4796 cmdline_parse_token_string_t cmd_csum_csum =
4797 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4799 cmdline_parse_token_string_t cmd_csum_mode =
4800 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4802 cmdline_parse_token_string_t cmd_csum_proto =
4803 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4804 proto, "ip#tcp#udp#sctp#outer-ip#outer-udp");
4805 cmdline_parse_token_string_t cmd_csum_hwsw =
4806 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4808 cmdline_parse_token_num_t cmd_csum_portid =
4809 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
4812 cmdline_parse_inst_t cmd_csum_set = {
4813 .f = cmd_csum_parsed,
4815 .help_str = "csum set ip|tcp|udp|sctp|outer-ip|outer-udp hw|sw <port_id>: "
4816 "Enable/Disable hardware calculation of L3/L4 checksum when "
4817 "using csum forward engine",
4819 (void *)&cmd_csum_csum,
4820 (void *)&cmd_csum_mode,
4821 (void *)&cmd_csum_proto,
4822 (void *)&cmd_csum_hwsw,
4823 (void *)&cmd_csum_portid,
4828 cmdline_parse_token_string_t cmd_csum_mode_show =
4829 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4832 cmdline_parse_inst_t cmd_csum_show = {
4833 .f = cmd_csum_parsed,
4835 .help_str = "csum show <port_id>: Show checksum offload configuration",
4837 (void *)&cmd_csum_csum,
4838 (void *)&cmd_csum_mode_show,
4839 (void *)&cmd_csum_portid,
4844 /* Enable/disable tunnel parsing */
4845 struct cmd_csum_tunnel_result {
4846 cmdline_fixed_string_t csum;
4847 cmdline_fixed_string_t parse;
4848 cmdline_fixed_string_t onoff;
4853 cmd_csum_tunnel_parsed(void *parsed_result,
4854 __rte_unused struct cmdline *cl,
4855 __rte_unused void *data)
4857 struct cmd_csum_tunnel_result *res = parsed_result;
4859 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4862 if (!strcmp(res->onoff, "on"))
4863 ports[res->port_id].parse_tunnel = 1;
4865 ports[res->port_id].parse_tunnel = 0;
4867 csum_show(res->port_id);
4870 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
4871 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4873 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
4874 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4875 parse, "parse-tunnel");
4876 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
4877 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4879 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
4880 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
4883 cmdline_parse_inst_t cmd_csum_tunnel = {
4884 .f = cmd_csum_tunnel_parsed,
4886 .help_str = "csum parse-tunnel on|off <port_id>: "
4887 "Enable/Disable parsing of tunnels for csum engine",
4889 (void *)&cmd_csum_tunnel_csum,
4890 (void *)&cmd_csum_tunnel_parse,
4891 (void *)&cmd_csum_tunnel_onoff,
4892 (void *)&cmd_csum_tunnel_portid,
4897 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
4898 struct cmd_tso_set_result {
4899 cmdline_fixed_string_t tso;
4900 cmdline_fixed_string_t mode;
4906 cmd_tso_set_parsed(void *parsed_result,
4907 __rte_unused struct cmdline *cl,
4908 __rte_unused void *data)
4910 struct cmd_tso_set_result *res = parsed_result;
4911 struct rte_eth_dev_info dev_info;
4914 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4916 if (!port_is_stopped(res->port_id)) {
4917 printf("Please stop port %d first\n", res->port_id);
4921 if (!strcmp(res->mode, "set"))
4922 ports[res->port_id].tso_segsz = res->tso_segsz;
4924 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4928 if ((ports[res->port_id].tso_segsz != 0) &&
4929 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4930 printf("Error: TSO is not supported by port %d\n",
4935 if (ports[res->port_id].tso_segsz == 0) {
4936 ports[res->port_id].dev_conf.txmode.offloads &=
4937 ~DEV_TX_OFFLOAD_TCP_TSO;
4938 printf("TSO for non-tunneled packets is disabled\n");
4940 ports[res->port_id].dev_conf.txmode.offloads |=
4941 DEV_TX_OFFLOAD_TCP_TSO;
4942 printf("TSO segment size for non-tunneled packets is %d\n",
4943 ports[res->port_id].tso_segsz);
4945 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4947 /* display warnings if configuration is not supported by the NIC */
4948 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4952 if ((ports[res->port_id].tso_segsz != 0) &&
4953 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4954 printf("Warning: TSO enabled but not "
4955 "supported by port %d\n", res->port_id);
4958 cmd_reconfig_device_queue(res->port_id, 1, 1);
4961 cmdline_parse_token_string_t cmd_tso_set_tso =
4962 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4964 cmdline_parse_token_string_t cmd_tso_set_mode =
4965 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4967 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
4968 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4970 cmdline_parse_token_num_t cmd_tso_set_portid =
4971 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4974 cmdline_parse_inst_t cmd_tso_set = {
4975 .f = cmd_tso_set_parsed,
4977 .help_str = "tso set <tso_segsz> <port_id>: "
4978 "Set TSO segment size of non-tunneled packets for csum engine "
4981 (void *)&cmd_tso_set_tso,
4982 (void *)&cmd_tso_set_mode,
4983 (void *)&cmd_tso_set_tso_segsz,
4984 (void *)&cmd_tso_set_portid,
4989 cmdline_parse_token_string_t cmd_tso_show_mode =
4990 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4994 cmdline_parse_inst_t cmd_tso_show = {
4995 .f = cmd_tso_set_parsed,
4997 .help_str = "tso show <port_id>: "
4998 "Show TSO segment size of non-tunneled packets for csum engine",
5000 (void *)&cmd_tso_set_tso,
5001 (void *)&cmd_tso_show_mode,
5002 (void *)&cmd_tso_set_portid,
5007 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
5008 struct cmd_tunnel_tso_set_result {
5009 cmdline_fixed_string_t tso;
5010 cmdline_fixed_string_t mode;
5015 static struct rte_eth_dev_info
5016 check_tunnel_tso_nic_support(portid_t port_id)
5018 struct rte_eth_dev_info dev_info;
5020 if (eth_dev_info_get_print_err(port_id, &dev_info) != 0)
5023 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO))
5024 printf("Warning: VXLAN TUNNEL TSO not supported therefore "
5025 "not enabled for port %d\n", port_id);
5026 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO))
5027 printf("Warning: GRE TUNNEL TSO not supported therefore "
5028 "not enabled for port %d\n", port_id);
5029 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO))
5030 printf("Warning: IPIP TUNNEL TSO not supported therefore "
5031 "not enabled for port %d\n", port_id);
5032 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
5033 printf("Warning: GENEVE TUNNEL TSO not supported therefore "
5034 "not enabled for port %d\n", port_id);
5035 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IP_TNL_TSO))
5036 printf("Warning: IP TUNNEL TSO not supported therefore "
5037 "not enabled for port %d\n", port_id);
5038 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_TNL_TSO))
5039 printf("Warning: UDP TUNNEL TSO not supported therefore "
5040 "not enabled for port %d\n", port_id);
5045 cmd_tunnel_tso_set_parsed(void *parsed_result,
5046 __rte_unused struct cmdline *cl,
5047 __rte_unused void *data)
5049 struct cmd_tunnel_tso_set_result *res = parsed_result;
5050 struct rte_eth_dev_info dev_info;
5052 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
5054 if (!port_is_stopped(res->port_id)) {
5055 printf("Please stop port %d first\n", res->port_id);
5059 if (!strcmp(res->mode, "set"))
5060 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
5062 dev_info = check_tunnel_tso_nic_support(res->port_id);
5063 if (ports[res->port_id].tunnel_tso_segsz == 0) {
5064 ports[res->port_id].dev_conf.txmode.offloads &=
5065 ~(DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
5066 DEV_TX_OFFLOAD_GRE_TNL_TSO |
5067 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
5068 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
5069 DEV_TX_OFFLOAD_IP_TNL_TSO |
5070 DEV_TX_OFFLOAD_UDP_TNL_TSO);
5071 printf("TSO for tunneled packets is disabled\n");
5073 uint64_t tso_offloads = (DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
5074 DEV_TX_OFFLOAD_GRE_TNL_TSO |
5075 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
5076 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
5077 DEV_TX_OFFLOAD_IP_TNL_TSO |
5078 DEV_TX_OFFLOAD_UDP_TNL_TSO);
5080 ports[res->port_id].dev_conf.txmode.offloads |=
5081 (tso_offloads & dev_info.tx_offload_capa);
5082 printf("TSO segment size for tunneled packets is %d\n",
5083 ports[res->port_id].tunnel_tso_segsz);
5085 /* Below conditions are needed to make it work:
5086 * (1) tunnel TSO is supported by the NIC;
5087 * (2) "csum parse_tunnel" must be set so that tunneled pkts
5089 * (3) for tunneled pkts with outer L3 of IPv4,
5090 * "csum set outer-ip" must be set to hw, because after tso,
5091 * total_len of outer IP header is changed, and the checksum
5092 * of outer IP header calculated by sw should be wrong; that
5093 * is not necessary for IPv6 tunneled pkts because there's no
5094 * checksum in IP header anymore.
5097 if (!ports[res->port_id].parse_tunnel)
5098 printf("Warning: csum parse_tunnel must be set "
5099 "so that tunneled packets are recognized\n");
5100 if (!(ports[res->port_id].dev_conf.txmode.offloads &
5101 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM))
5102 printf("Warning: csum set outer-ip must be set to hw "
5103 "if outer L3 is IPv4; not necessary for IPv6\n");
5106 cmd_config_queue_tx_offloads(&ports[res->port_id]);
5107 cmd_reconfig_device_queue(res->port_id, 1, 1);
5110 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
5111 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
5113 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
5114 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
5116 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
5117 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
5119 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
5120 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
5123 cmdline_parse_inst_t cmd_tunnel_tso_set = {
5124 .f = cmd_tunnel_tso_set_parsed,
5126 .help_str = "tunnel_tso set <tso_segsz> <port_id>: "
5127 "Set TSO segment size of tunneled packets for csum engine "
5130 (void *)&cmd_tunnel_tso_set_tso,
5131 (void *)&cmd_tunnel_tso_set_mode,
5132 (void *)&cmd_tunnel_tso_set_tso_segsz,
5133 (void *)&cmd_tunnel_tso_set_portid,
5138 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
5139 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
5143 cmdline_parse_inst_t cmd_tunnel_tso_show = {
5144 .f = cmd_tunnel_tso_set_parsed,
5146 .help_str = "tunnel_tso show <port_id> "
5147 "Show TSO segment size of tunneled packets for csum engine",
5149 (void *)&cmd_tunnel_tso_set_tso,
5150 (void *)&cmd_tunnel_tso_show_mode,
5151 (void *)&cmd_tunnel_tso_set_portid,
5156 /* *** SET GRO FOR A PORT *** */
5157 struct cmd_gro_enable_result {
5158 cmdline_fixed_string_t cmd_set;
5159 cmdline_fixed_string_t cmd_port;
5160 cmdline_fixed_string_t cmd_keyword;
5161 cmdline_fixed_string_t cmd_onoff;
5166 cmd_gro_enable_parsed(void *parsed_result,
5167 __rte_unused struct cmdline *cl,
5168 __rte_unused void *data)
5170 struct cmd_gro_enable_result *res;
5172 res = parsed_result;
5173 if (!strcmp(res->cmd_keyword, "gro"))
5174 setup_gro(res->cmd_onoff, res->cmd_pid);
5177 cmdline_parse_token_string_t cmd_gro_enable_set =
5178 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5180 cmdline_parse_token_string_t cmd_gro_enable_port =
5181 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5182 cmd_keyword, "port");
5183 cmdline_parse_token_num_t cmd_gro_enable_pid =
5184 TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result,
5186 cmdline_parse_token_string_t cmd_gro_enable_keyword =
5187 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5188 cmd_keyword, "gro");
5189 cmdline_parse_token_string_t cmd_gro_enable_onoff =
5190 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5191 cmd_onoff, "on#off");
5193 cmdline_parse_inst_t cmd_gro_enable = {
5194 .f = cmd_gro_enable_parsed,
5196 .help_str = "set port <port_id> gro on|off",
5198 (void *)&cmd_gro_enable_set,
5199 (void *)&cmd_gro_enable_port,
5200 (void *)&cmd_gro_enable_pid,
5201 (void *)&cmd_gro_enable_keyword,
5202 (void *)&cmd_gro_enable_onoff,
5207 /* *** DISPLAY GRO CONFIGURATION *** */
5208 struct cmd_gro_show_result {
5209 cmdline_fixed_string_t cmd_show;
5210 cmdline_fixed_string_t cmd_port;
5211 cmdline_fixed_string_t cmd_keyword;
5216 cmd_gro_show_parsed(void *parsed_result,
5217 __rte_unused struct cmdline *cl,
5218 __rte_unused void *data)
5220 struct cmd_gro_show_result *res;
5222 res = parsed_result;
5223 if (!strcmp(res->cmd_keyword, "gro"))
5224 show_gro(res->cmd_pid);
5227 cmdline_parse_token_string_t cmd_gro_show_show =
5228 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5230 cmdline_parse_token_string_t cmd_gro_show_port =
5231 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5233 cmdline_parse_token_num_t cmd_gro_show_pid =
5234 TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result,
5236 cmdline_parse_token_string_t cmd_gro_show_keyword =
5237 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5238 cmd_keyword, "gro");
5240 cmdline_parse_inst_t cmd_gro_show = {
5241 .f = cmd_gro_show_parsed,
5243 .help_str = "show port <port_id> gro",
5245 (void *)&cmd_gro_show_show,
5246 (void *)&cmd_gro_show_port,
5247 (void *)&cmd_gro_show_pid,
5248 (void *)&cmd_gro_show_keyword,
5253 /* *** SET FLUSH CYCLES FOR GRO *** */
5254 struct cmd_gro_flush_result {
5255 cmdline_fixed_string_t cmd_set;
5256 cmdline_fixed_string_t cmd_keyword;
5257 cmdline_fixed_string_t cmd_flush;
5262 cmd_gro_flush_parsed(void *parsed_result,
5263 __rte_unused struct cmdline *cl,
5264 __rte_unused void *data)
5266 struct cmd_gro_flush_result *res;
5268 res = parsed_result;
5269 if ((!strcmp(res->cmd_keyword, "gro")) &&
5270 (!strcmp(res->cmd_flush, "flush")))
5271 setup_gro_flush_cycles(res->cmd_cycles);
5274 cmdline_parse_token_string_t cmd_gro_flush_set =
5275 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5277 cmdline_parse_token_string_t cmd_gro_flush_keyword =
5278 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5279 cmd_keyword, "gro");
5280 cmdline_parse_token_string_t cmd_gro_flush_flush =
5281 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5282 cmd_flush, "flush");
5283 cmdline_parse_token_num_t cmd_gro_flush_cycles =
5284 TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result,
5287 cmdline_parse_inst_t cmd_gro_flush = {
5288 .f = cmd_gro_flush_parsed,
5290 .help_str = "set gro flush <cycles>",
5292 (void *)&cmd_gro_flush_set,
5293 (void *)&cmd_gro_flush_keyword,
5294 (void *)&cmd_gro_flush_flush,
5295 (void *)&cmd_gro_flush_cycles,
5300 /* *** ENABLE/DISABLE GSO *** */
5301 struct cmd_gso_enable_result {
5302 cmdline_fixed_string_t cmd_set;
5303 cmdline_fixed_string_t cmd_port;
5304 cmdline_fixed_string_t cmd_keyword;
5305 cmdline_fixed_string_t cmd_mode;
5310 cmd_gso_enable_parsed(void *parsed_result,
5311 __rte_unused struct cmdline *cl,
5312 __rte_unused void *data)
5314 struct cmd_gso_enable_result *res;
5316 res = parsed_result;
5317 if (!strcmp(res->cmd_keyword, "gso"))
5318 setup_gso(res->cmd_mode, res->cmd_pid);
5321 cmdline_parse_token_string_t cmd_gso_enable_set =
5322 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5324 cmdline_parse_token_string_t cmd_gso_enable_port =
5325 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5327 cmdline_parse_token_string_t cmd_gso_enable_keyword =
5328 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5329 cmd_keyword, "gso");
5330 cmdline_parse_token_string_t cmd_gso_enable_mode =
5331 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5332 cmd_mode, "on#off");
5333 cmdline_parse_token_num_t cmd_gso_enable_pid =
5334 TOKEN_NUM_INITIALIZER(struct cmd_gso_enable_result,
5337 cmdline_parse_inst_t cmd_gso_enable = {
5338 .f = cmd_gso_enable_parsed,
5340 .help_str = "set port <port_id> gso on|off",
5342 (void *)&cmd_gso_enable_set,
5343 (void *)&cmd_gso_enable_port,
5344 (void *)&cmd_gso_enable_pid,
5345 (void *)&cmd_gso_enable_keyword,
5346 (void *)&cmd_gso_enable_mode,
5351 /* *** SET MAX PACKET LENGTH FOR GSO SEGMENTS *** */
5352 struct cmd_gso_size_result {
5353 cmdline_fixed_string_t cmd_set;
5354 cmdline_fixed_string_t cmd_keyword;
5355 cmdline_fixed_string_t cmd_segsz;
5360 cmd_gso_size_parsed(void *parsed_result,
5361 __rte_unused struct cmdline *cl,
5362 __rte_unused void *data)
5364 struct cmd_gso_size_result *res = parsed_result;
5366 if (test_done == 0) {
5367 printf("Before setting GSO segsz, please first"
5368 " stop forwarding\n");
5372 if (!strcmp(res->cmd_keyword, "gso") &&
5373 !strcmp(res->cmd_segsz, "segsz")) {
5374 if (res->cmd_size < RTE_GSO_SEG_SIZE_MIN)
5375 printf("gso_size should be larger than %zu."
5376 " Please input a legal value\n",
5377 RTE_GSO_SEG_SIZE_MIN);
5379 gso_max_segment_size = res->cmd_size;
5383 cmdline_parse_token_string_t cmd_gso_size_set =
5384 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5386 cmdline_parse_token_string_t cmd_gso_size_keyword =
5387 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5388 cmd_keyword, "gso");
5389 cmdline_parse_token_string_t cmd_gso_size_segsz =
5390 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5391 cmd_segsz, "segsz");
5392 cmdline_parse_token_num_t cmd_gso_size_size =
5393 TOKEN_NUM_INITIALIZER(struct cmd_gso_size_result,
5396 cmdline_parse_inst_t cmd_gso_size = {
5397 .f = cmd_gso_size_parsed,
5399 .help_str = "set gso segsz <length>",
5401 (void *)&cmd_gso_size_set,
5402 (void *)&cmd_gso_size_keyword,
5403 (void *)&cmd_gso_size_segsz,
5404 (void *)&cmd_gso_size_size,
5409 /* *** SHOW GSO CONFIGURATION *** */
5410 struct cmd_gso_show_result {
5411 cmdline_fixed_string_t cmd_show;
5412 cmdline_fixed_string_t cmd_port;
5413 cmdline_fixed_string_t cmd_keyword;
5418 cmd_gso_show_parsed(void *parsed_result,
5419 __rte_unused struct cmdline *cl,
5420 __rte_unused void *data)
5422 struct cmd_gso_show_result *res = parsed_result;
5424 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
5425 printf("invalid port id %u\n", res->cmd_pid);
5428 if (!strcmp(res->cmd_keyword, "gso")) {
5429 if (gso_ports[res->cmd_pid].enable) {
5430 printf("Max GSO'd packet size: %uB\n"
5431 "Supported GSO types: TCP/IPv4, "
5432 "UDP/IPv4, VxLAN with inner "
5433 "TCP/IPv4 packet, GRE with inner "
5434 "TCP/IPv4 packet\n",
5435 gso_max_segment_size);
5437 printf("GSO is not enabled on Port %u\n", res->cmd_pid);
5441 cmdline_parse_token_string_t cmd_gso_show_show =
5442 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5444 cmdline_parse_token_string_t cmd_gso_show_port =
5445 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5447 cmdline_parse_token_string_t cmd_gso_show_keyword =
5448 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5449 cmd_keyword, "gso");
5450 cmdline_parse_token_num_t cmd_gso_show_pid =
5451 TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result,
5454 cmdline_parse_inst_t cmd_gso_show = {
5455 .f = cmd_gso_show_parsed,
5457 .help_str = "show port <port_id> gso",
5459 (void *)&cmd_gso_show_show,
5460 (void *)&cmd_gso_show_port,
5461 (void *)&cmd_gso_show_pid,
5462 (void *)&cmd_gso_show_keyword,
5467 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
5468 struct cmd_set_flush_rx {
5469 cmdline_fixed_string_t set;
5470 cmdline_fixed_string_t flush_rx;
5471 cmdline_fixed_string_t mode;
5475 cmd_set_flush_rx_parsed(void *parsed_result,
5476 __rte_unused struct cmdline *cl,
5477 __rte_unused void *data)
5479 struct cmd_set_flush_rx *res = parsed_result;
5480 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5483 cmdline_parse_token_string_t cmd_setflushrx_set =
5484 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5486 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
5487 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5488 flush_rx, "flush_rx");
5489 cmdline_parse_token_string_t cmd_setflushrx_mode =
5490 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5494 cmdline_parse_inst_t cmd_set_flush_rx = {
5495 .f = cmd_set_flush_rx_parsed,
5496 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
5499 (void *)&cmd_setflushrx_set,
5500 (void *)&cmd_setflushrx_flush_rx,
5501 (void *)&cmd_setflushrx_mode,
5506 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
5507 struct cmd_set_link_check {
5508 cmdline_fixed_string_t set;
5509 cmdline_fixed_string_t link_check;
5510 cmdline_fixed_string_t mode;
5514 cmd_set_link_check_parsed(void *parsed_result,
5515 __rte_unused struct cmdline *cl,
5516 __rte_unused void *data)
5518 struct cmd_set_link_check *res = parsed_result;
5519 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5522 cmdline_parse_token_string_t cmd_setlinkcheck_set =
5523 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5525 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
5526 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5527 link_check, "link_check");
5528 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
5529 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5533 cmdline_parse_inst_t cmd_set_link_check = {
5534 .f = cmd_set_link_check_parsed,
5535 .help_str = "set link_check on|off: Enable/Disable link status check "
5536 "when starting/stopping a port",
5539 (void *)&cmd_setlinkcheck_set,
5540 (void *)&cmd_setlinkcheck_link_check,
5541 (void *)&cmd_setlinkcheck_mode,
5546 /* *** SET NIC BYPASS MODE *** */
5547 struct cmd_set_bypass_mode_result {
5548 cmdline_fixed_string_t set;
5549 cmdline_fixed_string_t bypass;
5550 cmdline_fixed_string_t mode;
5551 cmdline_fixed_string_t value;
5556 cmd_set_bypass_mode_parsed(void *parsed_result,
5557 __rte_unused struct cmdline *cl,
5558 __rte_unused void *data)
5560 struct cmd_set_bypass_mode_result *res = parsed_result;
5561 portid_t port_id = res->port_id;
5562 int32_t rc = -EINVAL;
5564 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5565 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5567 if (!strcmp(res->value, "bypass"))
5568 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5569 else if (!strcmp(res->value, "isolate"))
5570 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5572 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5574 /* Set the bypass mode for the relevant port. */
5575 rc = rte_pmd_ixgbe_bypass_state_set(port_id, &bypass_mode);
5578 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
5581 cmdline_parse_token_string_t cmd_setbypass_mode_set =
5582 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5584 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
5585 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5587 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
5588 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5590 cmdline_parse_token_string_t cmd_setbypass_mode_value =
5591 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5592 value, "normal#bypass#isolate");
5593 cmdline_parse_token_num_t cmd_setbypass_mode_port =
5594 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
5597 cmdline_parse_inst_t cmd_set_bypass_mode = {
5598 .f = cmd_set_bypass_mode_parsed,
5599 .help_str = "set bypass mode normal|bypass|isolate <port_id>: "
5600 "Set the NIC bypass mode for port_id",
5603 (void *)&cmd_setbypass_mode_set,
5604 (void *)&cmd_setbypass_mode_bypass,
5605 (void *)&cmd_setbypass_mode_mode,
5606 (void *)&cmd_setbypass_mode_value,
5607 (void *)&cmd_setbypass_mode_port,
5612 /* *** SET NIC BYPASS EVENT *** */
5613 struct cmd_set_bypass_event_result {
5614 cmdline_fixed_string_t set;
5615 cmdline_fixed_string_t bypass;
5616 cmdline_fixed_string_t event;
5617 cmdline_fixed_string_t event_value;
5618 cmdline_fixed_string_t mode;
5619 cmdline_fixed_string_t mode_value;
5624 cmd_set_bypass_event_parsed(void *parsed_result,
5625 __rte_unused struct cmdline *cl,
5626 __rte_unused void *data)
5628 int32_t rc = -EINVAL;
5629 struct cmd_set_bypass_event_result *res = parsed_result;
5630 portid_t port_id = res->port_id;
5632 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5633 uint32_t bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5634 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5636 if (!strcmp(res->event_value, "timeout"))
5637 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT;
5638 else if (!strcmp(res->event_value, "os_on"))
5639 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_ON;
5640 else if (!strcmp(res->event_value, "os_off"))
5641 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_OFF;
5642 else if (!strcmp(res->event_value, "power_on"))
5643 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_ON;
5644 else if (!strcmp(res->event_value, "power_off"))
5645 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_OFF;
5647 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5649 if (!strcmp(res->mode_value, "bypass"))
5650 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5651 else if (!strcmp(res->mode_value, "isolate"))
5652 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5654 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5656 /* Set the watchdog timeout. */
5657 if (bypass_event == RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT) {
5660 if (RTE_PMD_IXGBE_BYPASS_TMT_VALID(bypass_timeout)) {
5661 rc = rte_pmd_ixgbe_bypass_wd_timeout_store(port_id,
5665 printf("Failed to set timeout value %u "
5666 "for port %d, errto code: %d.\n",
5667 bypass_timeout, port_id, rc);
5671 /* Set the bypass event to transition to bypass mode. */
5672 rc = rte_pmd_ixgbe_bypass_event_store(port_id, bypass_event,
5677 printf("\t Failed to set bypass event for port = %d.\n",
5681 cmdline_parse_token_string_t cmd_setbypass_event_set =
5682 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5684 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
5685 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5687 cmdline_parse_token_string_t cmd_setbypass_event_event =
5688 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5690 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
5691 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5692 event_value, "none#timeout#os_off#os_on#power_on#power_off");
5693 cmdline_parse_token_string_t cmd_setbypass_event_mode =
5694 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5696 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
5697 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5698 mode_value, "normal#bypass#isolate");
5699 cmdline_parse_token_num_t cmd_setbypass_event_port =
5700 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
5703 cmdline_parse_inst_t cmd_set_bypass_event = {
5704 .f = cmd_set_bypass_event_parsed,
5705 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
5706 "power_off mode normal|bypass|isolate <port_id>: "
5707 "Set the NIC bypass event mode for port_id",
5710 (void *)&cmd_setbypass_event_set,
5711 (void *)&cmd_setbypass_event_bypass,
5712 (void *)&cmd_setbypass_event_event,
5713 (void *)&cmd_setbypass_event_event_value,
5714 (void *)&cmd_setbypass_event_mode,
5715 (void *)&cmd_setbypass_event_mode_value,
5716 (void *)&cmd_setbypass_event_port,
5722 /* *** SET NIC BYPASS TIMEOUT *** */
5723 struct cmd_set_bypass_timeout_result {
5724 cmdline_fixed_string_t set;
5725 cmdline_fixed_string_t bypass;
5726 cmdline_fixed_string_t timeout;
5727 cmdline_fixed_string_t value;
5731 cmd_set_bypass_timeout_parsed(void *parsed_result,
5732 __rte_unused struct cmdline *cl,
5733 __rte_unused void *data)
5735 __rte_unused struct cmd_set_bypass_timeout_result *res = parsed_result;
5737 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5738 if (!strcmp(res->value, "1.5"))
5739 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_1_5_SEC;
5740 else if (!strcmp(res->value, "2"))
5741 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_2_SEC;
5742 else if (!strcmp(res->value, "3"))
5743 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_3_SEC;
5744 else if (!strcmp(res->value, "4"))
5745 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_4_SEC;
5746 else if (!strcmp(res->value, "8"))
5747 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_8_SEC;
5748 else if (!strcmp(res->value, "16"))
5749 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_16_SEC;
5750 else if (!strcmp(res->value, "32"))
5751 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_32_SEC;
5753 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5757 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
5758 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5760 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
5761 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5763 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
5764 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5765 timeout, "timeout");
5766 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
5767 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5768 value, "0#1.5#2#3#4#8#16#32");
5770 cmdline_parse_inst_t cmd_set_bypass_timeout = {
5771 .f = cmd_set_bypass_timeout_parsed,
5772 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
5773 "Set the NIC bypass watchdog timeout in seconds",
5776 (void *)&cmd_setbypass_timeout_set,
5777 (void *)&cmd_setbypass_timeout_bypass,
5778 (void *)&cmd_setbypass_timeout_timeout,
5779 (void *)&cmd_setbypass_timeout_value,
5784 /* *** SHOW NIC BYPASS MODE *** */
5785 struct cmd_show_bypass_config_result {
5786 cmdline_fixed_string_t show;
5787 cmdline_fixed_string_t bypass;
5788 cmdline_fixed_string_t config;
5793 cmd_show_bypass_config_parsed(void *parsed_result,
5794 __rte_unused struct cmdline *cl,
5795 __rte_unused void *data)
5797 struct cmd_show_bypass_config_result *res = parsed_result;
5798 portid_t port_id = res->port_id;
5800 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5801 uint32_t event_mode;
5802 uint32_t bypass_mode;
5803 uint32_t timeout = bypass_timeout;
5806 static const char * const timeouts[RTE_PMD_IXGBE_BYPASS_TMT_NUM] =
5807 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
5808 static const char * const modes[RTE_PMD_IXGBE_BYPASS_MODE_NUM] =
5809 {"UNKNOWN", "normal", "bypass", "isolate"};
5810 static const char * const events[RTE_PMD_IXGBE_BYPASS_EVENT_NUM] = {
5818 /* Display the bypass mode.*/
5819 if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) != 0) {
5820 printf("\tFailed to get bypass mode for port = %d\n", port_id);
5824 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(bypass_mode))
5825 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5827 printf("\tbypass mode = %s\n", modes[bypass_mode]);
5830 /* Display the bypass timeout.*/
5831 if (!RTE_PMD_IXGBE_BYPASS_TMT_VALID(timeout))
5832 timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5834 printf("\tbypass timeout = %s\n", timeouts[timeout]);
5836 /* Display the bypass events and associated modes. */
5837 for (i = RTE_PMD_IXGBE_BYPASS_EVENT_START; i < RTE_DIM(events); i++) {
5839 if (rte_pmd_ixgbe_bypass_event_show(port_id, i, &event_mode)) {
5840 printf("\tFailed to get bypass mode for event = %s\n",
5843 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(event_mode))
5844 event_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5846 printf("\tbypass event: %-16s = %s\n", events[i],
5852 printf("\tFailed to get bypass configuration for port = %d\n",
5856 cmdline_parse_token_string_t cmd_showbypass_config_show =
5857 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5859 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
5860 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5862 cmdline_parse_token_string_t cmd_showbypass_config_config =
5863 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5865 cmdline_parse_token_num_t cmd_showbypass_config_port =
5866 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
5869 cmdline_parse_inst_t cmd_show_bypass_config = {
5870 .f = cmd_show_bypass_config_parsed,
5871 .help_str = "show bypass config <port_id>: "
5872 "Show the NIC bypass config for port_id",
5875 (void *)&cmd_showbypass_config_show,
5876 (void *)&cmd_showbypass_config_bypass,
5877 (void *)&cmd_showbypass_config_config,
5878 (void *)&cmd_showbypass_config_port,
5884 /* *** SET BONDING MODE *** */
5885 struct cmd_set_bonding_mode_result {
5886 cmdline_fixed_string_t set;
5887 cmdline_fixed_string_t bonding;
5888 cmdline_fixed_string_t mode;
5893 static void cmd_set_bonding_mode_parsed(void *parsed_result,
5894 __rte_unused struct cmdline *cl,
5895 __rte_unused void *data)
5897 struct cmd_set_bonding_mode_result *res = parsed_result;
5898 portid_t port_id = res->port_id;
5900 /* Set the bonding mode for the relevant port. */
5901 if (0 != rte_eth_bond_mode_set(port_id, res->value))
5902 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
5905 cmdline_parse_token_string_t cmd_setbonding_mode_set =
5906 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5908 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
5909 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5910 bonding, "bonding");
5911 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
5912 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5914 cmdline_parse_token_num_t cmd_setbonding_mode_value =
5915 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5917 cmdline_parse_token_num_t cmd_setbonding_mode_port =
5918 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5921 cmdline_parse_inst_t cmd_set_bonding_mode = {
5922 .f = cmd_set_bonding_mode_parsed,
5923 .help_str = "set bonding mode <mode_value> <port_id>: "
5924 "Set the bonding mode for port_id",
5927 (void *) &cmd_setbonding_mode_set,
5928 (void *) &cmd_setbonding_mode_bonding,
5929 (void *) &cmd_setbonding_mode_mode,
5930 (void *) &cmd_setbonding_mode_value,
5931 (void *) &cmd_setbonding_mode_port,
5936 /* *** SET BONDING SLOW_QUEUE SW/HW *** */
5937 struct cmd_set_bonding_lacp_dedicated_queues_result {
5938 cmdline_fixed_string_t set;
5939 cmdline_fixed_string_t bonding;
5940 cmdline_fixed_string_t lacp;
5941 cmdline_fixed_string_t dedicated_queues;
5943 cmdline_fixed_string_t mode;
5946 static void cmd_set_bonding_lacp_dedicated_queues_parsed(void *parsed_result,
5947 __rte_unused struct cmdline *cl,
5948 __rte_unused void *data)
5950 struct cmd_set_bonding_lacp_dedicated_queues_result *res = parsed_result;
5951 portid_t port_id = res->port_id;
5952 struct rte_port *port;
5954 port = &ports[port_id];
5956 /** Check if the port is not started **/
5957 if (port->port_status != RTE_PORT_STOPPED) {
5958 printf("Please stop port %d first\n", port_id);
5962 if (!strcmp(res->mode, "enable")) {
5963 if (rte_eth_bond_8023ad_dedicated_queues_enable(port_id) == 0)
5964 printf("Dedicate queues for LACP control packets"
5967 printf("Enabling dedicate queues for LACP control "
5968 "packets on port %d failed\n", port_id);
5969 } else if (!strcmp(res->mode, "disable")) {
5970 if (rte_eth_bond_8023ad_dedicated_queues_disable(port_id) == 0)
5971 printf("Dedicated queues for LACP control packets "
5974 printf("Disabling dedicated queues for LACP control "
5975 "traffic on port %d failed\n", port_id);
5979 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_set =
5980 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5982 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_bonding =
5983 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5984 bonding, "bonding");
5985 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_lacp =
5986 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5988 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_dedicated_queues =
5989 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5990 dedicated_queues, "dedicated_queues");
5991 cmdline_parse_token_num_t cmd_setbonding_lacp_dedicated_queues_port_id =
5992 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5994 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_mode =
5995 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5996 mode, "enable#disable");
5998 cmdline_parse_inst_t cmd_set_lacp_dedicated_queues = {
5999 .f = cmd_set_bonding_lacp_dedicated_queues_parsed,
6000 .help_str = "set bonding lacp dedicated_queues <port_id> "
6002 "Enable/disable dedicated queues for LACP control traffic for port_id",
6005 (void *)&cmd_setbonding_lacp_dedicated_queues_set,
6006 (void *)&cmd_setbonding_lacp_dedicated_queues_bonding,
6007 (void *)&cmd_setbonding_lacp_dedicated_queues_lacp,
6008 (void *)&cmd_setbonding_lacp_dedicated_queues_dedicated_queues,
6009 (void *)&cmd_setbonding_lacp_dedicated_queues_port_id,
6010 (void *)&cmd_setbonding_lacp_dedicated_queues_mode,
6015 /* *** SET BALANCE XMIT POLICY *** */
6016 struct cmd_set_bonding_balance_xmit_policy_result {
6017 cmdline_fixed_string_t set;
6018 cmdline_fixed_string_t bonding;
6019 cmdline_fixed_string_t balance_xmit_policy;
6021 cmdline_fixed_string_t policy;
6024 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
6025 __rte_unused struct cmdline *cl,
6026 __rte_unused void *data)
6028 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
6029 portid_t port_id = res->port_id;
6032 if (!strcmp(res->policy, "l2")) {
6033 policy = BALANCE_XMIT_POLICY_LAYER2;
6034 } else if (!strcmp(res->policy, "l23")) {
6035 policy = BALANCE_XMIT_POLICY_LAYER23;
6036 } else if (!strcmp(res->policy, "l34")) {
6037 policy = BALANCE_XMIT_POLICY_LAYER34;
6039 printf("\t Invalid xmit policy selection");
6043 /* Set the bonding mode for the relevant port. */
6044 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
6045 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
6050 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
6051 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6053 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
6054 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6055 bonding, "bonding");
6056 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
6057 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6058 balance_xmit_policy, "balance_xmit_policy");
6059 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
6060 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6062 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
6063 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6064 policy, "l2#l23#l34");
6066 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
6067 .f = cmd_set_bonding_balance_xmit_policy_parsed,
6068 .help_str = "set bonding balance_xmit_policy <port_id> "
6070 "Set the bonding balance_xmit_policy for port_id",
6073 (void *)&cmd_setbonding_balance_xmit_policy_set,
6074 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
6075 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
6076 (void *)&cmd_setbonding_balance_xmit_policy_port,
6077 (void *)&cmd_setbonding_balance_xmit_policy_policy,
6082 /* *** SHOW NIC BONDING CONFIGURATION *** */
6083 struct cmd_show_bonding_config_result {
6084 cmdline_fixed_string_t show;
6085 cmdline_fixed_string_t bonding;
6086 cmdline_fixed_string_t config;
6090 static void cmd_show_bonding_config_parsed(void *parsed_result,
6091 __rte_unused struct cmdline *cl,
6092 __rte_unused void *data)
6094 struct cmd_show_bonding_config_result *res = parsed_result;
6095 int bonding_mode, agg_mode;
6096 portid_t slaves[RTE_MAX_ETHPORTS];
6097 int num_slaves, num_active_slaves;
6100 portid_t port_id = res->port_id;
6102 /* Display the bonding mode.*/
6103 bonding_mode = rte_eth_bond_mode_get(port_id);
6104 if (bonding_mode < 0) {
6105 printf("\tFailed to get bonding mode for port = %d\n", port_id);
6108 printf("\tBonding mode: %d\n", bonding_mode);
6110 if (bonding_mode == BONDING_MODE_BALANCE) {
6111 int balance_xmit_policy;
6113 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
6114 if (balance_xmit_policy < 0) {
6115 printf("\tFailed to get balance xmit policy for port = %d\n",
6119 printf("\tBalance Xmit Policy: ");
6121 switch (balance_xmit_policy) {
6122 case BALANCE_XMIT_POLICY_LAYER2:
6123 printf("BALANCE_XMIT_POLICY_LAYER2");
6125 case BALANCE_XMIT_POLICY_LAYER23:
6126 printf("BALANCE_XMIT_POLICY_LAYER23");
6128 case BALANCE_XMIT_POLICY_LAYER34:
6129 printf("BALANCE_XMIT_POLICY_LAYER34");
6136 if (bonding_mode == BONDING_MODE_8023AD) {
6137 agg_mode = rte_eth_bond_8023ad_agg_selection_get(port_id);
6138 printf("\tIEEE802.3AD Aggregator Mode: ");
6141 printf("bandwidth");
6153 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
6155 if (num_slaves < 0) {
6156 printf("\tFailed to get slave list for port = %d\n", port_id);
6159 if (num_slaves > 0) {
6160 printf("\tSlaves (%d): [", num_slaves);
6161 for (i = 0; i < num_slaves - 1; i++)
6162 printf("%d ", slaves[i]);
6164 printf("%d]\n", slaves[num_slaves - 1]);
6166 printf("\tSlaves: []\n");
6170 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
6173 if (num_active_slaves < 0) {
6174 printf("\tFailed to get active slave list for port = %d\n", port_id);
6177 if (num_active_slaves > 0) {
6178 printf("\tActive Slaves (%d): [", num_active_slaves);
6179 for (i = 0; i < num_active_slaves - 1; i++)
6180 printf("%d ", slaves[i]);
6182 printf("%d]\n", slaves[num_active_slaves - 1]);
6185 printf("\tActive Slaves: []\n");
6189 primary_id = rte_eth_bond_primary_get(port_id);
6190 if (primary_id < 0) {
6191 printf("\tFailed to get primary slave for port = %d\n", port_id);
6194 printf("\tPrimary: [%d]\n", primary_id);
6198 cmdline_parse_token_string_t cmd_showbonding_config_show =
6199 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6201 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
6202 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6203 bonding, "bonding");
6204 cmdline_parse_token_string_t cmd_showbonding_config_config =
6205 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6207 cmdline_parse_token_num_t cmd_showbonding_config_port =
6208 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
6211 cmdline_parse_inst_t cmd_show_bonding_config = {
6212 .f = cmd_show_bonding_config_parsed,
6213 .help_str = "show bonding config <port_id>: "
6214 "Show the bonding config for port_id",
6217 (void *)&cmd_showbonding_config_show,
6218 (void *)&cmd_showbonding_config_bonding,
6219 (void *)&cmd_showbonding_config_config,
6220 (void *)&cmd_showbonding_config_port,
6225 /* *** SET BONDING PRIMARY *** */
6226 struct cmd_set_bonding_primary_result {
6227 cmdline_fixed_string_t set;
6228 cmdline_fixed_string_t bonding;
6229 cmdline_fixed_string_t primary;
6234 static void cmd_set_bonding_primary_parsed(void *parsed_result,
6235 __rte_unused struct cmdline *cl,
6236 __rte_unused void *data)
6238 struct cmd_set_bonding_primary_result *res = parsed_result;
6239 portid_t master_port_id = res->port_id;
6240 portid_t slave_port_id = res->slave_id;
6242 /* Set the primary slave for a bonded device. */
6243 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
6244 printf("\t Failed to set primary slave for port = %d.\n",
6251 cmdline_parse_token_string_t cmd_setbonding_primary_set =
6252 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6254 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
6255 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6256 bonding, "bonding");
6257 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
6258 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6259 primary, "primary");
6260 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
6261 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
6263 cmdline_parse_token_num_t cmd_setbonding_primary_port =
6264 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
6267 cmdline_parse_inst_t cmd_set_bonding_primary = {
6268 .f = cmd_set_bonding_primary_parsed,
6269 .help_str = "set bonding primary <slave_id> <port_id>: "
6270 "Set the primary slave for port_id",
6273 (void *)&cmd_setbonding_primary_set,
6274 (void *)&cmd_setbonding_primary_bonding,
6275 (void *)&cmd_setbonding_primary_primary,
6276 (void *)&cmd_setbonding_primary_slave,
6277 (void *)&cmd_setbonding_primary_port,
6282 /* *** ADD SLAVE *** */
6283 struct cmd_add_bonding_slave_result {
6284 cmdline_fixed_string_t add;
6285 cmdline_fixed_string_t bonding;
6286 cmdline_fixed_string_t slave;
6291 static void cmd_add_bonding_slave_parsed(void *parsed_result,
6292 __rte_unused struct cmdline *cl,
6293 __rte_unused void *data)
6295 struct cmd_add_bonding_slave_result *res = parsed_result;
6296 portid_t master_port_id = res->port_id;
6297 portid_t slave_port_id = res->slave_id;
6299 /* add the slave for a bonded device. */
6300 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
6301 printf("\t Failed to add slave %d to master port = %d.\n",
6302 slave_port_id, master_port_id);
6306 set_port_slave_flag(slave_port_id);
6309 cmdline_parse_token_string_t cmd_addbonding_slave_add =
6310 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6312 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
6313 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6314 bonding, "bonding");
6315 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
6316 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6318 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
6319 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
6321 cmdline_parse_token_num_t cmd_addbonding_slave_port =
6322 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
6325 cmdline_parse_inst_t cmd_add_bonding_slave = {
6326 .f = cmd_add_bonding_slave_parsed,
6327 .help_str = "add bonding slave <slave_id> <port_id>: "
6328 "Add a slave device to a bonded device",
6331 (void *)&cmd_addbonding_slave_add,
6332 (void *)&cmd_addbonding_slave_bonding,
6333 (void *)&cmd_addbonding_slave_slave,
6334 (void *)&cmd_addbonding_slave_slaveid,
6335 (void *)&cmd_addbonding_slave_port,
6340 /* *** REMOVE SLAVE *** */
6341 struct cmd_remove_bonding_slave_result {
6342 cmdline_fixed_string_t remove;
6343 cmdline_fixed_string_t bonding;
6344 cmdline_fixed_string_t slave;
6349 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
6350 __rte_unused struct cmdline *cl,
6351 __rte_unused void *data)
6353 struct cmd_remove_bonding_slave_result *res = parsed_result;
6354 portid_t master_port_id = res->port_id;
6355 portid_t slave_port_id = res->slave_id;
6357 /* remove the slave from a bonded device. */
6358 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
6359 printf("\t Failed to remove slave %d from master port = %d.\n",
6360 slave_port_id, master_port_id);
6364 clear_port_slave_flag(slave_port_id);
6367 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
6368 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6370 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
6371 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6372 bonding, "bonding");
6373 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
6374 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6376 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
6377 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6379 cmdline_parse_token_num_t cmd_removebonding_slave_port =
6380 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6383 cmdline_parse_inst_t cmd_remove_bonding_slave = {
6384 .f = cmd_remove_bonding_slave_parsed,
6385 .help_str = "remove bonding slave <slave_id> <port_id>: "
6386 "Remove a slave device from a bonded device",
6389 (void *)&cmd_removebonding_slave_remove,
6390 (void *)&cmd_removebonding_slave_bonding,
6391 (void *)&cmd_removebonding_slave_slave,
6392 (void *)&cmd_removebonding_slave_slaveid,
6393 (void *)&cmd_removebonding_slave_port,
6398 /* *** CREATE BONDED DEVICE *** */
6399 struct cmd_create_bonded_device_result {
6400 cmdline_fixed_string_t create;
6401 cmdline_fixed_string_t bonded;
6402 cmdline_fixed_string_t device;
6407 static int bond_dev_num = 0;
6409 static void cmd_create_bonded_device_parsed(void *parsed_result,
6410 __rte_unused struct cmdline *cl,
6411 __rte_unused void *data)
6413 struct cmd_create_bonded_device_result *res = parsed_result;
6414 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
6418 if (test_done == 0) {
6419 printf("Please stop forwarding first\n");
6423 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bonding_testpmd_%d",
6426 /* Create a new bonded device. */
6427 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
6429 printf("\t Failed to create bonded device.\n");
6432 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
6435 /* Update number of ports */
6436 nb_ports = rte_eth_dev_count_avail();
6437 reconfig(port_id, res->socket);
6438 ret = rte_eth_promiscuous_enable(port_id);
6440 printf("Failed to enable promiscuous mode for port %u: %s - ignore\n",
6441 port_id, rte_strerror(-ret));
6443 ports[port_id].need_setup = 0;
6444 ports[port_id].port_status = RTE_PORT_STOPPED;
6449 cmdline_parse_token_string_t cmd_createbonded_device_create =
6450 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6452 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
6453 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6455 cmdline_parse_token_string_t cmd_createbonded_device_device =
6456 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6458 cmdline_parse_token_num_t cmd_createbonded_device_mode =
6459 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6461 cmdline_parse_token_num_t cmd_createbonded_device_socket =
6462 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6465 cmdline_parse_inst_t cmd_create_bonded_device = {
6466 .f = cmd_create_bonded_device_parsed,
6467 .help_str = "create bonded device <mode> <socket>: "
6468 "Create a new bonded device with specific bonding mode and socket",
6471 (void *)&cmd_createbonded_device_create,
6472 (void *)&cmd_createbonded_device_bonded,
6473 (void *)&cmd_createbonded_device_device,
6474 (void *)&cmd_createbonded_device_mode,
6475 (void *)&cmd_createbonded_device_socket,
6480 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
6481 struct cmd_set_bond_mac_addr_result {
6482 cmdline_fixed_string_t set;
6483 cmdline_fixed_string_t bonding;
6484 cmdline_fixed_string_t mac_addr;
6486 struct rte_ether_addr address;
6489 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
6490 __rte_unused struct cmdline *cl,
6491 __rte_unused void *data)
6493 struct cmd_set_bond_mac_addr_result *res = parsed_result;
6496 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
6499 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
6501 /* check the return value and print it if is < 0 */
6503 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
6506 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
6507 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
6508 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
6509 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
6511 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
6512 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
6514 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
6515 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result,
6517 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
6518 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
6520 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
6521 .f = cmd_set_bond_mac_addr_parsed,
6523 .help_str = "set bonding mac_addr <port_id> <mac_addr>",
6525 (void *)&cmd_set_bond_mac_addr_set,
6526 (void *)&cmd_set_bond_mac_addr_bonding,
6527 (void *)&cmd_set_bond_mac_addr_mac,
6528 (void *)&cmd_set_bond_mac_addr_portnum,
6529 (void *)&cmd_set_bond_mac_addr_addr,
6535 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
6536 struct cmd_set_bond_mon_period_result {
6537 cmdline_fixed_string_t set;
6538 cmdline_fixed_string_t bonding;
6539 cmdline_fixed_string_t mon_period;
6544 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
6545 __rte_unused struct cmdline *cl,
6546 __rte_unused void *data)
6548 struct cmd_set_bond_mon_period_result *res = parsed_result;
6551 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
6553 /* check the return value and print it if is < 0 */
6555 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
6558 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
6559 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6561 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
6562 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6563 bonding, "bonding");
6564 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
6565 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6566 mon_period, "mon_period");
6567 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
6568 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6570 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
6571 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6574 cmdline_parse_inst_t cmd_set_bond_mon_period = {
6575 .f = cmd_set_bond_mon_period_parsed,
6577 .help_str = "set bonding mon_period <port_id> <period_ms>",
6579 (void *)&cmd_set_bond_mon_period_set,
6580 (void *)&cmd_set_bond_mon_period_bonding,
6581 (void *)&cmd_set_bond_mon_period_mon_period,
6582 (void *)&cmd_set_bond_mon_period_portnum,
6583 (void *)&cmd_set_bond_mon_period_period_ms,
6590 struct cmd_set_bonding_agg_mode_policy_result {
6591 cmdline_fixed_string_t set;
6592 cmdline_fixed_string_t bonding;
6593 cmdline_fixed_string_t agg_mode;
6595 cmdline_fixed_string_t policy;
6600 cmd_set_bonding_agg_mode(void *parsed_result,
6601 __rte_unused struct cmdline *cl,
6602 __rte_unused void *data)
6604 struct cmd_set_bonding_agg_mode_policy_result *res = parsed_result;
6605 uint8_t policy = AGG_BANDWIDTH;
6607 if (!strcmp(res->policy, "bandwidth"))
6608 policy = AGG_BANDWIDTH;
6609 else if (!strcmp(res->policy, "stable"))
6610 policy = AGG_STABLE;
6611 else if (!strcmp(res->policy, "count"))
6614 rte_eth_bond_8023ad_agg_selection_set(res->port_num, policy);
6618 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_set =
6619 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6621 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_bonding =
6622 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6623 bonding, "bonding");
6625 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_agg_mode =
6626 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6627 agg_mode, "agg_mode");
6629 cmdline_parse_token_num_t cmd_set_bonding_agg_mode_portnum =
6630 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6633 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_policy_string =
6634 TOKEN_STRING_INITIALIZER(
6635 struct cmd_set_bonding_balance_xmit_policy_result,
6636 policy, "stable#bandwidth#count");
6638 cmdline_parse_inst_t cmd_set_bonding_agg_mode_policy = {
6639 .f = cmd_set_bonding_agg_mode,
6641 .help_str = "set bonding mode IEEE802.3AD aggregator policy <port_id> <agg_name>",
6643 (void *)&cmd_set_bonding_agg_mode_set,
6644 (void *)&cmd_set_bonding_agg_mode_bonding,
6645 (void *)&cmd_set_bonding_agg_mode_agg_mode,
6646 (void *)&cmd_set_bonding_agg_mode_portnum,
6647 (void *)&cmd_set_bonding_agg_mode_policy_string,
6653 #endif /* RTE_NET_BOND */
6655 /* *** SET FORWARDING MODE *** */
6656 struct cmd_set_fwd_mode_result {
6657 cmdline_fixed_string_t set;
6658 cmdline_fixed_string_t fwd;
6659 cmdline_fixed_string_t mode;
6662 static void cmd_set_fwd_mode_parsed(void *parsed_result,
6663 __rte_unused struct cmdline *cl,
6664 __rte_unused void *data)
6666 struct cmd_set_fwd_mode_result *res = parsed_result;
6669 set_pkt_forwarding_mode(res->mode);
6672 cmdline_parse_token_string_t cmd_setfwd_set =
6673 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
6674 cmdline_parse_token_string_t cmd_setfwd_fwd =
6675 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
6676 cmdline_parse_token_string_t cmd_setfwd_mode =
6677 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
6678 "" /* defined at init */);
6680 cmdline_parse_inst_t cmd_set_fwd_mode = {
6681 .f = cmd_set_fwd_mode_parsed,
6683 .help_str = NULL, /* defined at init */
6685 (void *)&cmd_setfwd_set,
6686 (void *)&cmd_setfwd_fwd,
6687 (void *)&cmd_setfwd_mode,
6692 static void cmd_set_fwd_mode_init(void)
6695 static char token[128];
6696 static char help[256];
6697 cmdline_parse_token_string_t *token_struct;
6699 modes = list_pkt_forwarding_modes();
6700 snprintf(help, sizeof(help), "set fwd %s: "
6701 "Set packet forwarding mode", modes);
6702 cmd_set_fwd_mode.help_str = help;
6704 /* string token separator is # */
6705 for (c = token; *modes != '\0'; modes++)
6710 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
6711 token_struct->string_data.str = token;
6714 /* *** SET RETRY FORWARDING MODE *** */
6715 struct cmd_set_fwd_retry_mode_result {
6716 cmdline_fixed_string_t set;
6717 cmdline_fixed_string_t fwd;
6718 cmdline_fixed_string_t mode;
6719 cmdline_fixed_string_t retry;
6722 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
6723 __rte_unused struct cmdline *cl,
6724 __rte_unused void *data)
6726 struct cmd_set_fwd_retry_mode_result *res = parsed_result;
6729 set_pkt_forwarding_mode(res->mode);
6732 cmdline_parse_token_string_t cmd_setfwd_retry_set =
6733 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6735 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
6736 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6738 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
6739 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6741 "" /* defined at init */);
6742 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
6743 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6746 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
6747 .f = cmd_set_fwd_retry_mode_parsed,
6749 .help_str = NULL, /* defined at init */
6751 (void *)&cmd_setfwd_retry_set,
6752 (void *)&cmd_setfwd_retry_fwd,
6753 (void *)&cmd_setfwd_retry_mode,
6754 (void *)&cmd_setfwd_retry_retry,
6759 static void cmd_set_fwd_retry_mode_init(void)
6762 static char token[128];
6763 static char help[256];
6764 cmdline_parse_token_string_t *token_struct;
6766 modes = list_pkt_forwarding_retry_modes();
6767 snprintf(help, sizeof(help), "set fwd %s retry: "
6768 "Set packet forwarding mode with retry", modes);
6769 cmd_set_fwd_retry_mode.help_str = help;
6771 /* string token separator is # */
6772 for (c = token; *modes != '\0'; modes++)
6777 token_struct = (cmdline_parse_token_string_t *)
6778 cmd_set_fwd_retry_mode.tokens[2];
6779 token_struct->string_data.str = token;
6782 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
6783 struct cmd_set_burst_tx_retry_result {
6784 cmdline_fixed_string_t set;
6785 cmdline_fixed_string_t burst;
6786 cmdline_fixed_string_t tx;
6787 cmdline_fixed_string_t delay;
6789 cmdline_fixed_string_t retry;
6793 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
6794 __rte_unused struct cmdline *cl,
6795 __rte_unused void *data)
6797 struct cmd_set_burst_tx_retry_result *res = parsed_result;
6799 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
6800 && !strcmp(res->tx, "tx")) {
6801 if (!strcmp(res->delay, "delay"))
6802 burst_tx_delay_time = res->time;
6803 if (!strcmp(res->retry, "retry"))
6804 burst_tx_retry_num = res->retry_num;
6809 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
6810 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
6811 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
6812 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
6814 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
6815 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
6816 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
6817 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
6818 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
6819 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
6820 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
6821 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
6822 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
6823 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
6825 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
6826 .f = cmd_set_burst_tx_retry_parsed,
6827 .help_str = "set burst tx delay <delay_usec> retry <num_retry>",
6829 (void *)&cmd_set_burst_tx_retry_set,
6830 (void *)&cmd_set_burst_tx_retry_burst,
6831 (void *)&cmd_set_burst_tx_retry_tx,
6832 (void *)&cmd_set_burst_tx_retry_delay,
6833 (void *)&cmd_set_burst_tx_retry_time,
6834 (void *)&cmd_set_burst_tx_retry_retry,
6835 (void *)&cmd_set_burst_tx_retry_retry_num,
6840 /* *** SET PROMISC MODE *** */
6841 struct cmd_set_promisc_mode_result {
6842 cmdline_fixed_string_t set;
6843 cmdline_fixed_string_t promisc;
6844 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6845 uint16_t port_num; /* valid if "allports" argument == 0 */
6846 cmdline_fixed_string_t mode;
6849 static void cmd_set_promisc_mode_parsed(void *parsed_result,
6850 __rte_unused struct cmdline *cl,
6853 struct cmd_set_promisc_mode_result *res = parsed_result;
6857 if (!strcmp(res->mode, "on"))
6864 RTE_ETH_FOREACH_DEV(i)
6865 eth_set_promisc_mode(i, enable);
6867 eth_set_promisc_mode(res->port_num, enable);
6871 cmdline_parse_token_string_t cmd_setpromisc_set =
6872 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
6873 cmdline_parse_token_string_t cmd_setpromisc_promisc =
6874 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
6876 cmdline_parse_token_string_t cmd_setpromisc_portall =
6877 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
6879 cmdline_parse_token_num_t cmd_setpromisc_portnum =
6880 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
6882 cmdline_parse_token_string_t cmd_setpromisc_mode =
6883 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
6886 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
6887 .f = cmd_set_promisc_mode_parsed,
6889 .help_str = "set promisc all on|off: Set promisc mode for all ports",
6891 (void *)&cmd_setpromisc_set,
6892 (void *)&cmd_setpromisc_promisc,
6893 (void *)&cmd_setpromisc_portall,
6894 (void *)&cmd_setpromisc_mode,
6899 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
6900 .f = cmd_set_promisc_mode_parsed,
6902 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
6904 (void *)&cmd_setpromisc_set,
6905 (void *)&cmd_setpromisc_promisc,
6906 (void *)&cmd_setpromisc_portnum,
6907 (void *)&cmd_setpromisc_mode,
6912 /* *** SET ALLMULTI MODE *** */
6913 struct cmd_set_allmulti_mode_result {
6914 cmdline_fixed_string_t set;
6915 cmdline_fixed_string_t allmulti;
6916 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6917 uint16_t port_num; /* valid if "allports" argument == 0 */
6918 cmdline_fixed_string_t mode;
6921 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
6922 __rte_unused struct cmdline *cl,
6925 struct cmd_set_allmulti_mode_result *res = parsed_result;
6929 if (!strcmp(res->mode, "on"))
6936 RTE_ETH_FOREACH_DEV(i) {
6937 eth_set_allmulticast_mode(i, enable);
6941 eth_set_allmulticast_mode(res->port_num, enable);
6945 cmdline_parse_token_string_t cmd_setallmulti_set =
6946 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
6947 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
6948 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
6950 cmdline_parse_token_string_t cmd_setallmulti_portall =
6951 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
6953 cmdline_parse_token_num_t cmd_setallmulti_portnum =
6954 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
6956 cmdline_parse_token_string_t cmd_setallmulti_mode =
6957 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
6960 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
6961 .f = cmd_set_allmulti_mode_parsed,
6963 .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
6965 (void *)&cmd_setallmulti_set,
6966 (void *)&cmd_setallmulti_allmulti,
6967 (void *)&cmd_setallmulti_portall,
6968 (void *)&cmd_setallmulti_mode,
6973 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
6974 .f = cmd_set_allmulti_mode_parsed,
6976 .help_str = "set allmulti <port_id> on|off: "
6977 "Set allmulti mode on port_id",
6979 (void *)&cmd_setallmulti_set,
6980 (void *)&cmd_setallmulti_allmulti,
6981 (void *)&cmd_setallmulti_portnum,
6982 (void *)&cmd_setallmulti_mode,
6987 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
6988 struct cmd_link_flow_ctrl_set_result {
6989 cmdline_fixed_string_t set;
6990 cmdline_fixed_string_t flow_ctrl;
6991 cmdline_fixed_string_t rx;
6992 cmdline_fixed_string_t rx_lfc_mode;
6993 cmdline_fixed_string_t tx;
6994 cmdline_fixed_string_t tx_lfc_mode;
6995 cmdline_fixed_string_t mac_ctrl_frame_fwd;
6996 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
6997 cmdline_fixed_string_t autoneg_str;
6998 cmdline_fixed_string_t autoneg;
6999 cmdline_fixed_string_t hw_str;
7000 uint32_t high_water;
7001 cmdline_fixed_string_t lw_str;
7003 cmdline_fixed_string_t pt_str;
7004 uint16_t pause_time;
7005 cmdline_fixed_string_t xon_str;
7010 cmdline_parse_token_string_t cmd_lfc_set_set =
7011 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7013 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
7014 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7015 flow_ctrl, "flow_ctrl");
7016 cmdline_parse_token_string_t cmd_lfc_set_rx =
7017 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7019 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
7020 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7021 rx_lfc_mode, "on#off");
7022 cmdline_parse_token_string_t cmd_lfc_set_tx =
7023 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7025 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
7026 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7027 tx_lfc_mode, "on#off");
7028 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
7029 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7030 hw_str, "high_water");
7031 cmdline_parse_token_num_t cmd_lfc_set_high_water =
7032 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7033 high_water, UINT32);
7034 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
7035 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7036 lw_str, "low_water");
7037 cmdline_parse_token_num_t cmd_lfc_set_low_water =
7038 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7040 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
7041 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7042 pt_str, "pause_time");
7043 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
7044 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7045 pause_time, UINT16);
7046 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
7047 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7048 xon_str, "send_xon");
7049 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
7050 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7052 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
7053 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7054 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
7055 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
7056 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7057 mac_ctrl_frame_fwd_mode, "on#off");
7058 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
7059 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7060 autoneg_str, "autoneg");
7061 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
7062 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7064 cmdline_parse_token_num_t cmd_lfc_set_portid =
7065 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7068 /* forward declaration */
7070 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
7073 cmdline_parse_inst_t cmd_link_flow_control_set = {
7074 .f = cmd_link_flow_ctrl_set_parsed,
7076 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
7077 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
7078 "autoneg on|off <port_id>: Configure the Ethernet flow control",
7080 (void *)&cmd_lfc_set_set,
7081 (void *)&cmd_lfc_set_flow_ctrl,
7082 (void *)&cmd_lfc_set_rx,
7083 (void *)&cmd_lfc_set_rx_mode,
7084 (void *)&cmd_lfc_set_tx,
7085 (void *)&cmd_lfc_set_tx_mode,
7086 (void *)&cmd_lfc_set_high_water,
7087 (void *)&cmd_lfc_set_low_water,
7088 (void *)&cmd_lfc_set_pause_time,
7089 (void *)&cmd_lfc_set_send_xon,
7090 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
7091 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
7092 (void *)&cmd_lfc_set_autoneg_str,
7093 (void *)&cmd_lfc_set_autoneg,
7094 (void *)&cmd_lfc_set_portid,
7099 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
7100 .f = cmd_link_flow_ctrl_set_parsed,
7101 .data = (void *)&cmd_link_flow_control_set_rx,
7102 .help_str = "set flow_ctrl rx on|off <port_id>: "
7103 "Change rx flow control parameter",
7105 (void *)&cmd_lfc_set_set,
7106 (void *)&cmd_lfc_set_flow_ctrl,
7107 (void *)&cmd_lfc_set_rx,
7108 (void *)&cmd_lfc_set_rx_mode,
7109 (void *)&cmd_lfc_set_portid,
7114 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
7115 .f = cmd_link_flow_ctrl_set_parsed,
7116 .data = (void *)&cmd_link_flow_control_set_tx,
7117 .help_str = "set flow_ctrl tx on|off <port_id>: "
7118 "Change tx flow control parameter",
7120 (void *)&cmd_lfc_set_set,
7121 (void *)&cmd_lfc_set_flow_ctrl,
7122 (void *)&cmd_lfc_set_tx,
7123 (void *)&cmd_lfc_set_tx_mode,
7124 (void *)&cmd_lfc_set_portid,
7129 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
7130 .f = cmd_link_flow_ctrl_set_parsed,
7131 .data = (void *)&cmd_link_flow_control_set_hw,
7132 .help_str = "set flow_ctrl high_water <value> <port_id>: "
7133 "Change high water flow control parameter",
7135 (void *)&cmd_lfc_set_set,
7136 (void *)&cmd_lfc_set_flow_ctrl,
7137 (void *)&cmd_lfc_set_high_water_str,
7138 (void *)&cmd_lfc_set_high_water,
7139 (void *)&cmd_lfc_set_portid,
7144 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
7145 .f = cmd_link_flow_ctrl_set_parsed,
7146 .data = (void *)&cmd_link_flow_control_set_lw,
7147 .help_str = "set flow_ctrl low_water <value> <port_id>: "
7148 "Change low water flow control parameter",
7150 (void *)&cmd_lfc_set_set,
7151 (void *)&cmd_lfc_set_flow_ctrl,
7152 (void *)&cmd_lfc_set_low_water_str,
7153 (void *)&cmd_lfc_set_low_water,
7154 (void *)&cmd_lfc_set_portid,
7159 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
7160 .f = cmd_link_flow_ctrl_set_parsed,
7161 .data = (void *)&cmd_link_flow_control_set_pt,
7162 .help_str = "set flow_ctrl pause_time <value> <port_id>: "
7163 "Change pause time flow control parameter",
7165 (void *)&cmd_lfc_set_set,
7166 (void *)&cmd_lfc_set_flow_ctrl,
7167 (void *)&cmd_lfc_set_pause_time_str,
7168 (void *)&cmd_lfc_set_pause_time,
7169 (void *)&cmd_lfc_set_portid,
7174 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
7175 .f = cmd_link_flow_ctrl_set_parsed,
7176 .data = (void *)&cmd_link_flow_control_set_xon,
7177 .help_str = "set flow_ctrl send_xon <value> <port_id>: "
7178 "Change send_xon flow control parameter",
7180 (void *)&cmd_lfc_set_set,
7181 (void *)&cmd_lfc_set_flow_ctrl,
7182 (void *)&cmd_lfc_set_send_xon_str,
7183 (void *)&cmd_lfc_set_send_xon,
7184 (void *)&cmd_lfc_set_portid,
7189 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
7190 .f = cmd_link_flow_ctrl_set_parsed,
7191 .data = (void *)&cmd_link_flow_control_set_macfwd,
7192 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
7193 "Change mac ctrl fwd flow control parameter",
7195 (void *)&cmd_lfc_set_set,
7196 (void *)&cmd_lfc_set_flow_ctrl,
7197 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
7198 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
7199 (void *)&cmd_lfc_set_portid,
7204 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
7205 .f = cmd_link_flow_ctrl_set_parsed,
7206 .data = (void *)&cmd_link_flow_control_set_autoneg,
7207 .help_str = "set flow_ctrl autoneg on|off <port_id>: "
7208 "Change autoneg flow control parameter",
7210 (void *)&cmd_lfc_set_set,
7211 (void *)&cmd_lfc_set_flow_ctrl,
7212 (void *)&cmd_lfc_set_autoneg_str,
7213 (void *)&cmd_lfc_set_autoneg,
7214 (void *)&cmd_lfc_set_portid,
7220 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
7221 __rte_unused struct cmdline *cl,
7224 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
7225 cmdline_parse_inst_t *cmd = data;
7226 struct rte_eth_fc_conf fc_conf;
7232 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
7233 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
7234 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
7235 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
7237 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
7238 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
7241 /* Partial command line, retrieve current configuration */
7243 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
7245 printf("cannot get current flow ctrl parameters, return"
7246 "code = %d\n", ret);
7250 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
7251 (fc_conf.mode == RTE_FC_FULL))
7253 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
7254 (fc_conf.mode == RTE_FC_FULL))
7258 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
7259 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
7261 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
7262 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
7264 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
7266 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
7267 fc_conf.high_water = res->high_water;
7269 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
7270 fc_conf.low_water = res->low_water;
7272 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
7273 fc_conf.pause_time = res->pause_time;
7275 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
7276 fc_conf.send_xon = res->send_xon;
7278 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
7279 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
7280 fc_conf.mac_ctrl_frame_fwd = 1;
7282 fc_conf.mac_ctrl_frame_fwd = 0;
7285 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
7286 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
7288 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
7290 printf("bad flow contrl parameter, return code = %d \n", ret);
7293 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
7294 struct cmd_priority_flow_ctrl_set_result {
7295 cmdline_fixed_string_t set;
7296 cmdline_fixed_string_t pfc_ctrl;
7297 cmdline_fixed_string_t rx;
7298 cmdline_fixed_string_t rx_pfc_mode;
7299 cmdline_fixed_string_t tx;
7300 cmdline_fixed_string_t tx_pfc_mode;
7301 uint32_t high_water;
7303 uint16_t pause_time;
7309 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
7310 __rte_unused struct cmdline *cl,
7311 __rte_unused void *data)
7313 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
7314 struct rte_eth_pfc_conf pfc_conf;
7315 int rx_fc_enable, tx_fc_enable;
7319 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
7320 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
7321 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
7322 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
7324 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
7325 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
7328 memset(&pfc_conf, 0, sizeof(struct rte_eth_pfc_conf));
7329 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
7330 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
7331 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
7332 pfc_conf.fc.high_water = res->high_water;
7333 pfc_conf.fc.low_water = res->low_water;
7334 pfc_conf.fc.pause_time = res->pause_time;
7335 pfc_conf.priority = res->priority;
7337 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
7339 printf("bad priority flow contrl parameter, return code = %d \n", ret);
7342 cmdline_parse_token_string_t cmd_pfc_set_set =
7343 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7345 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
7346 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7347 pfc_ctrl, "pfc_ctrl");
7348 cmdline_parse_token_string_t cmd_pfc_set_rx =
7349 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7351 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
7352 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7353 rx_pfc_mode, "on#off");
7354 cmdline_parse_token_string_t cmd_pfc_set_tx =
7355 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7357 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
7358 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7359 tx_pfc_mode, "on#off");
7360 cmdline_parse_token_num_t cmd_pfc_set_high_water =
7361 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7362 high_water, UINT32);
7363 cmdline_parse_token_num_t cmd_pfc_set_low_water =
7364 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7366 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
7367 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7368 pause_time, UINT16);
7369 cmdline_parse_token_num_t cmd_pfc_set_priority =
7370 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7372 cmdline_parse_token_num_t cmd_pfc_set_portid =
7373 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7376 cmdline_parse_inst_t cmd_priority_flow_control_set = {
7377 .f = cmd_priority_flow_ctrl_set_parsed,
7379 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
7380 "<pause_time> <priority> <port_id>: "
7381 "Configure the Ethernet priority flow control",
7383 (void *)&cmd_pfc_set_set,
7384 (void *)&cmd_pfc_set_flow_ctrl,
7385 (void *)&cmd_pfc_set_rx,
7386 (void *)&cmd_pfc_set_rx_mode,
7387 (void *)&cmd_pfc_set_tx,
7388 (void *)&cmd_pfc_set_tx_mode,
7389 (void *)&cmd_pfc_set_high_water,
7390 (void *)&cmd_pfc_set_low_water,
7391 (void *)&cmd_pfc_set_pause_time,
7392 (void *)&cmd_pfc_set_priority,
7393 (void *)&cmd_pfc_set_portid,
7398 /* *** RESET CONFIGURATION *** */
7399 struct cmd_reset_result {
7400 cmdline_fixed_string_t reset;
7401 cmdline_fixed_string_t def;
7404 static void cmd_reset_parsed(__rte_unused void *parsed_result,
7406 __rte_unused void *data)
7408 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
7409 set_def_fwd_config();
7412 cmdline_parse_token_string_t cmd_reset_set =
7413 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
7414 cmdline_parse_token_string_t cmd_reset_def =
7415 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
7418 cmdline_parse_inst_t cmd_reset = {
7419 .f = cmd_reset_parsed,
7421 .help_str = "set default: Reset default forwarding configuration",
7423 (void *)&cmd_reset_set,
7424 (void *)&cmd_reset_def,
7429 /* *** START FORWARDING *** */
7430 struct cmd_start_result {
7431 cmdline_fixed_string_t start;
7434 cmdline_parse_token_string_t cmd_start_start =
7435 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
7437 static void cmd_start_parsed(__rte_unused void *parsed_result,
7438 __rte_unused struct cmdline *cl,
7439 __rte_unused void *data)
7441 start_packet_forwarding(0);
7444 cmdline_parse_inst_t cmd_start = {
7445 .f = cmd_start_parsed,
7447 .help_str = "start: Start packet forwarding",
7449 (void *)&cmd_start_start,
7454 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
7455 struct cmd_start_tx_first_result {
7456 cmdline_fixed_string_t start;
7457 cmdline_fixed_string_t tx_first;
7461 cmd_start_tx_first_parsed(__rte_unused void *parsed_result,
7462 __rte_unused struct cmdline *cl,
7463 __rte_unused void *data)
7465 start_packet_forwarding(1);
7468 cmdline_parse_token_string_t cmd_start_tx_first_start =
7469 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
7471 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
7472 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
7473 tx_first, "tx_first");
7475 cmdline_parse_inst_t cmd_start_tx_first = {
7476 .f = cmd_start_tx_first_parsed,
7478 .help_str = "start tx_first: Start packet forwarding, "
7479 "after sending 1 burst of packets",
7481 (void *)&cmd_start_tx_first_start,
7482 (void *)&cmd_start_tx_first_tx_first,
7487 /* *** START FORWARDING WITH N TX BURST FIRST *** */
7488 struct cmd_start_tx_first_n_result {
7489 cmdline_fixed_string_t start;
7490 cmdline_fixed_string_t tx_first;
7495 cmd_start_tx_first_n_parsed(void *parsed_result,
7496 __rte_unused struct cmdline *cl,
7497 __rte_unused void *data)
7499 struct cmd_start_tx_first_n_result *res = parsed_result;
7501 start_packet_forwarding(res->tx_num);
7504 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
7505 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7507 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
7508 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7509 tx_first, "tx_first");
7510 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
7511 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
7514 cmdline_parse_inst_t cmd_start_tx_first_n = {
7515 .f = cmd_start_tx_first_n_parsed,
7517 .help_str = "start tx_first <num>: "
7518 "packet forwarding, after sending <num> bursts of packets",
7520 (void *)&cmd_start_tx_first_n_start,
7521 (void *)&cmd_start_tx_first_n_tx_first,
7522 (void *)&cmd_start_tx_first_n_tx_num,
7527 /* *** SET LINK UP *** */
7528 struct cmd_set_link_up_result {
7529 cmdline_fixed_string_t set;
7530 cmdline_fixed_string_t link_up;
7531 cmdline_fixed_string_t port;
7535 cmdline_parse_token_string_t cmd_set_link_up_set =
7536 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
7537 cmdline_parse_token_string_t cmd_set_link_up_link_up =
7538 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
7540 cmdline_parse_token_string_t cmd_set_link_up_port =
7541 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
7542 cmdline_parse_token_num_t cmd_set_link_up_port_id =
7543 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT16);
7545 static void cmd_set_link_up_parsed(__rte_unused void *parsed_result,
7546 __rte_unused struct cmdline *cl,
7547 __rte_unused void *data)
7549 struct cmd_set_link_up_result *res = parsed_result;
7550 dev_set_link_up(res->port_id);
7553 cmdline_parse_inst_t cmd_set_link_up = {
7554 .f = cmd_set_link_up_parsed,
7556 .help_str = "set link-up port <port id>",
7558 (void *)&cmd_set_link_up_set,
7559 (void *)&cmd_set_link_up_link_up,
7560 (void *)&cmd_set_link_up_port,
7561 (void *)&cmd_set_link_up_port_id,
7566 /* *** SET LINK DOWN *** */
7567 struct cmd_set_link_down_result {
7568 cmdline_fixed_string_t set;
7569 cmdline_fixed_string_t link_down;
7570 cmdline_fixed_string_t port;
7574 cmdline_parse_token_string_t cmd_set_link_down_set =
7575 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
7576 cmdline_parse_token_string_t cmd_set_link_down_link_down =
7577 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
7579 cmdline_parse_token_string_t cmd_set_link_down_port =
7580 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
7581 cmdline_parse_token_num_t cmd_set_link_down_port_id =
7582 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT16);
7584 static void cmd_set_link_down_parsed(
7585 __rte_unused void *parsed_result,
7586 __rte_unused struct cmdline *cl,
7587 __rte_unused void *data)
7589 struct cmd_set_link_down_result *res = parsed_result;
7590 dev_set_link_down(res->port_id);
7593 cmdline_parse_inst_t cmd_set_link_down = {
7594 .f = cmd_set_link_down_parsed,
7596 .help_str = "set link-down port <port id>",
7598 (void *)&cmd_set_link_down_set,
7599 (void *)&cmd_set_link_down_link_down,
7600 (void *)&cmd_set_link_down_port,
7601 (void *)&cmd_set_link_down_port_id,
7606 /* *** SHOW CFG *** */
7607 struct cmd_showcfg_result {
7608 cmdline_fixed_string_t show;
7609 cmdline_fixed_string_t cfg;
7610 cmdline_fixed_string_t what;
7613 static void cmd_showcfg_parsed(void *parsed_result,
7614 __rte_unused struct cmdline *cl,
7615 __rte_unused void *data)
7617 struct cmd_showcfg_result *res = parsed_result;
7618 if (!strcmp(res->what, "rxtx"))
7619 rxtx_config_display();
7620 else if (!strcmp(res->what, "cores"))
7621 fwd_lcores_config_display();
7622 else if (!strcmp(res->what, "fwd"))
7623 pkt_fwd_config_display(&cur_fwd_config);
7624 else if (!strcmp(res->what, "rxoffs"))
7625 show_rx_pkt_offsets();
7626 else if (!strcmp(res->what, "rxpkts"))
7627 show_rx_pkt_segments();
7628 else if (!strcmp(res->what, "txpkts"))
7629 show_tx_pkt_segments();
7630 else if (!strcmp(res->what, "txtimes"))
7631 show_tx_pkt_times();
7634 cmdline_parse_token_string_t cmd_showcfg_show =
7635 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
7636 cmdline_parse_token_string_t cmd_showcfg_port =
7637 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
7638 cmdline_parse_token_string_t cmd_showcfg_what =
7639 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
7640 "rxtx#cores#fwd#rxoffs#rxpkts#txpkts#txtimes");
7642 cmdline_parse_inst_t cmd_showcfg = {
7643 .f = cmd_showcfg_parsed,
7645 .help_str = "show config rxtx|cores|fwd|rxoffs|rxpkts|txpkts|txtimes",
7647 (void *)&cmd_showcfg_show,
7648 (void *)&cmd_showcfg_port,
7649 (void *)&cmd_showcfg_what,
7654 /* *** SHOW ALL PORT INFO *** */
7655 struct cmd_showportall_result {
7656 cmdline_fixed_string_t show;
7657 cmdline_fixed_string_t port;
7658 cmdline_fixed_string_t what;
7659 cmdline_fixed_string_t all;
7662 static void cmd_showportall_parsed(void *parsed_result,
7663 __rte_unused struct cmdline *cl,
7664 __rte_unused void *data)
7668 struct cmd_showportall_result *res = parsed_result;
7669 if (!strcmp(res->show, "clear")) {
7670 if (!strcmp(res->what, "stats"))
7671 RTE_ETH_FOREACH_DEV(i)
7673 else if (!strcmp(res->what, "xstats"))
7674 RTE_ETH_FOREACH_DEV(i)
7675 nic_xstats_clear(i);
7676 } else if (!strcmp(res->what, "info"))
7677 RTE_ETH_FOREACH_DEV(i)
7678 port_infos_display(i);
7679 else if (!strcmp(res->what, "summary")) {
7680 port_summary_header_display();
7681 RTE_ETH_FOREACH_DEV(i)
7682 port_summary_display(i);
7684 else if (!strcmp(res->what, "stats"))
7685 RTE_ETH_FOREACH_DEV(i)
7686 nic_stats_display(i);
7687 else if (!strcmp(res->what, "xstats"))
7688 RTE_ETH_FOREACH_DEV(i)
7689 nic_xstats_display(i);
7690 else if (!strcmp(res->what, "fdir"))
7691 RTE_ETH_FOREACH_DEV(i)
7693 else if (!strcmp(res->what, "stat_qmap"))
7694 RTE_ETH_FOREACH_DEV(i)
7695 nic_stats_mapping_display(i);
7696 else if (!strcmp(res->what, "dcb_tc"))
7697 RTE_ETH_FOREACH_DEV(i)
7698 port_dcb_info_display(i);
7699 else if (!strcmp(res->what, "cap"))
7700 RTE_ETH_FOREACH_DEV(i)
7701 port_offload_cap_display(i);
7704 cmdline_parse_token_string_t cmd_showportall_show =
7705 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
7707 cmdline_parse_token_string_t cmd_showportall_port =
7708 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
7709 cmdline_parse_token_string_t cmd_showportall_what =
7710 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
7711 "info#summary#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
7712 cmdline_parse_token_string_t cmd_showportall_all =
7713 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
7714 cmdline_parse_inst_t cmd_showportall = {
7715 .f = cmd_showportall_parsed,
7717 .help_str = "show|clear port "
7718 "info|summary|stats|xstats|fdir|stat_qmap|dcb_tc|cap all",
7720 (void *)&cmd_showportall_show,
7721 (void *)&cmd_showportall_port,
7722 (void *)&cmd_showportall_what,
7723 (void *)&cmd_showportall_all,
7728 /* *** SHOW PORT INFO *** */
7729 struct cmd_showport_result {
7730 cmdline_fixed_string_t show;
7731 cmdline_fixed_string_t port;
7732 cmdline_fixed_string_t what;
7736 static void cmd_showport_parsed(void *parsed_result,
7737 __rte_unused struct cmdline *cl,
7738 __rte_unused void *data)
7740 struct cmd_showport_result *res = parsed_result;
7741 if (!strcmp(res->show, "clear")) {
7742 if (!strcmp(res->what, "stats"))
7743 nic_stats_clear(res->portnum);
7744 else if (!strcmp(res->what, "xstats"))
7745 nic_xstats_clear(res->portnum);
7746 } else if (!strcmp(res->what, "info"))
7747 port_infos_display(res->portnum);
7748 else if (!strcmp(res->what, "summary")) {
7749 port_summary_header_display();
7750 port_summary_display(res->portnum);
7752 else if (!strcmp(res->what, "stats"))
7753 nic_stats_display(res->portnum);
7754 else if (!strcmp(res->what, "xstats"))
7755 nic_xstats_display(res->portnum);
7756 else if (!strcmp(res->what, "fdir"))
7757 fdir_get_infos(res->portnum);
7758 else if (!strcmp(res->what, "stat_qmap"))
7759 nic_stats_mapping_display(res->portnum);
7760 else if (!strcmp(res->what, "dcb_tc"))
7761 port_dcb_info_display(res->portnum);
7762 else if (!strcmp(res->what, "cap"))
7763 port_offload_cap_display(res->portnum);
7766 cmdline_parse_token_string_t cmd_showport_show =
7767 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
7769 cmdline_parse_token_string_t cmd_showport_port =
7770 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
7771 cmdline_parse_token_string_t cmd_showport_what =
7772 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
7773 "info#summary#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
7774 cmdline_parse_token_num_t cmd_showport_portnum =
7775 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT16);
7777 cmdline_parse_inst_t cmd_showport = {
7778 .f = cmd_showport_parsed,
7780 .help_str = "show|clear port "
7781 "info|summary|stats|xstats|fdir|stat_qmap|dcb_tc|cap "
7784 (void *)&cmd_showport_show,
7785 (void *)&cmd_showport_port,
7786 (void *)&cmd_showport_what,
7787 (void *)&cmd_showport_portnum,
7792 /* *** SHOW DEVICE INFO *** */
7793 struct cmd_showdevice_result {
7794 cmdline_fixed_string_t show;
7795 cmdline_fixed_string_t device;
7796 cmdline_fixed_string_t what;
7797 cmdline_fixed_string_t identifier;
7800 static void cmd_showdevice_parsed(void *parsed_result,
7801 __rte_unused struct cmdline *cl,
7802 __rte_unused void *data)
7804 struct cmd_showdevice_result *res = parsed_result;
7805 if (!strcmp(res->what, "info")) {
7806 if (!strcmp(res->identifier, "all"))
7807 device_infos_display(NULL);
7809 device_infos_display(res->identifier);
7813 cmdline_parse_token_string_t cmd_showdevice_show =
7814 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, show,
7816 cmdline_parse_token_string_t cmd_showdevice_device =
7817 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, device, "device");
7818 cmdline_parse_token_string_t cmd_showdevice_what =
7819 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, what,
7821 cmdline_parse_token_string_t cmd_showdevice_identifier =
7822 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result,
7825 cmdline_parse_inst_t cmd_showdevice = {
7826 .f = cmd_showdevice_parsed,
7828 .help_str = "show device info <identifier>|all",
7830 (void *)&cmd_showdevice_show,
7831 (void *)&cmd_showdevice_device,
7832 (void *)&cmd_showdevice_what,
7833 (void *)&cmd_showdevice_identifier,
7838 /* *** SHOW MODULE EEPROM/EEPROM port INFO *** */
7839 struct cmd_showeeprom_result {
7840 cmdline_fixed_string_t show;
7841 cmdline_fixed_string_t port;
7843 cmdline_fixed_string_t type;
7846 static void cmd_showeeprom_parsed(void *parsed_result,
7847 __rte_unused struct cmdline *cl,
7848 __rte_unused void *data)
7850 struct cmd_showeeprom_result *res = parsed_result;
7852 if (!strcmp(res->type, "eeprom"))
7853 port_eeprom_display(res->portnum);
7854 else if (!strcmp(res->type, "module_eeprom"))
7855 port_module_eeprom_display(res->portnum);
7857 printf("Unknown argument\n");
7860 cmdline_parse_token_string_t cmd_showeeprom_show =
7861 TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, show, "show");
7862 cmdline_parse_token_string_t cmd_showeeprom_port =
7863 TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, port, "port");
7864 cmdline_parse_token_num_t cmd_showeeprom_portnum =
7865 TOKEN_NUM_INITIALIZER(struct cmd_showeeprom_result, portnum, UINT16);
7866 cmdline_parse_token_string_t cmd_showeeprom_type =
7867 TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, type, "module_eeprom#eeprom");
7869 cmdline_parse_inst_t cmd_showeeprom = {
7870 .f = cmd_showeeprom_parsed,
7872 .help_str = "show port <port_id> module_eeprom|eeprom",
7874 (void *)&cmd_showeeprom_show,
7875 (void *)&cmd_showeeprom_port,
7876 (void *)&cmd_showeeprom_portnum,
7877 (void *)&cmd_showeeprom_type,
7882 /* *** SHOW QUEUE INFO *** */
7883 struct cmd_showqueue_result {
7884 cmdline_fixed_string_t show;
7885 cmdline_fixed_string_t type;
7886 cmdline_fixed_string_t what;
7892 cmd_showqueue_parsed(void *parsed_result,
7893 __rte_unused struct cmdline *cl,
7894 __rte_unused void *data)
7896 struct cmd_showqueue_result *res = parsed_result;
7898 if (!strcmp(res->type, "rxq"))
7899 rx_queue_infos_display(res->portnum, res->queuenum);
7900 else if (!strcmp(res->type, "txq"))
7901 tx_queue_infos_display(res->portnum, res->queuenum);
7904 cmdline_parse_token_string_t cmd_showqueue_show =
7905 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
7906 cmdline_parse_token_string_t cmd_showqueue_type =
7907 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
7908 cmdline_parse_token_string_t cmd_showqueue_what =
7909 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
7910 cmdline_parse_token_num_t cmd_showqueue_portnum =
7911 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, UINT16);
7912 cmdline_parse_token_num_t cmd_showqueue_queuenum =
7913 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, UINT16);
7915 cmdline_parse_inst_t cmd_showqueue = {
7916 .f = cmd_showqueue_parsed,
7918 .help_str = "show rxq|txq info <port_id> <queue_id>",
7920 (void *)&cmd_showqueue_show,
7921 (void *)&cmd_showqueue_type,
7922 (void *)&cmd_showqueue_what,
7923 (void *)&cmd_showqueue_portnum,
7924 (void *)&cmd_showqueue_queuenum,
7929 /* show/clear fwd engine statistics */
7931 cmdline_fixed_string_t action;
7932 cmdline_fixed_string_t fwd;
7933 cmdline_fixed_string_t stats;
7934 cmdline_fixed_string_t all;
7937 cmdline_parse_token_string_t cmd_fwd_action =
7938 TOKEN_STRING_INITIALIZER(struct fwd_result, action, "show#clear");
7939 cmdline_parse_token_string_t cmd_fwd_fwd =
7940 TOKEN_STRING_INITIALIZER(struct fwd_result, fwd, "fwd");
7941 cmdline_parse_token_string_t cmd_fwd_stats =
7942 TOKEN_STRING_INITIALIZER(struct fwd_result, stats, "stats");
7943 cmdline_parse_token_string_t cmd_fwd_all =
7944 TOKEN_STRING_INITIALIZER(struct fwd_result, all, "all");
7947 cmd_showfwdall_parsed(void *parsed_result,
7948 __rte_unused struct cmdline *cl,
7949 __rte_unused void *data)
7951 struct fwd_result *res = parsed_result;
7953 if (!strcmp(res->action, "show"))
7954 fwd_stats_display();
7959 static cmdline_parse_inst_t cmd_showfwdall = {
7960 .f = cmd_showfwdall_parsed,
7962 .help_str = "show|clear fwd stats all",
7964 (void *)&cmd_fwd_action,
7965 (void *)&cmd_fwd_fwd,
7966 (void *)&cmd_fwd_stats,
7967 (void *)&cmd_fwd_all,
7972 /* *** READ PORT REGISTER *** */
7973 struct cmd_read_reg_result {
7974 cmdline_fixed_string_t read;
7975 cmdline_fixed_string_t reg;
7981 cmd_read_reg_parsed(void *parsed_result,
7982 __rte_unused struct cmdline *cl,
7983 __rte_unused void *data)
7985 struct cmd_read_reg_result *res = parsed_result;
7986 port_reg_display(res->port_id, res->reg_off);
7989 cmdline_parse_token_string_t cmd_read_reg_read =
7990 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
7991 cmdline_parse_token_string_t cmd_read_reg_reg =
7992 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
7993 cmdline_parse_token_num_t cmd_read_reg_port_id =
7994 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT16);
7995 cmdline_parse_token_num_t cmd_read_reg_reg_off =
7996 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
7998 cmdline_parse_inst_t cmd_read_reg = {
7999 .f = cmd_read_reg_parsed,
8001 .help_str = "read reg <port_id> <reg_off>",
8003 (void *)&cmd_read_reg_read,
8004 (void *)&cmd_read_reg_reg,
8005 (void *)&cmd_read_reg_port_id,
8006 (void *)&cmd_read_reg_reg_off,
8011 /* *** READ PORT REGISTER BIT FIELD *** */
8012 struct cmd_read_reg_bit_field_result {
8013 cmdline_fixed_string_t read;
8014 cmdline_fixed_string_t regfield;
8022 cmd_read_reg_bit_field_parsed(void *parsed_result,
8023 __rte_unused struct cmdline *cl,
8024 __rte_unused void *data)
8026 struct cmd_read_reg_bit_field_result *res = parsed_result;
8027 port_reg_bit_field_display(res->port_id, res->reg_off,
8028 res->bit1_pos, res->bit2_pos);
8031 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
8032 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
8034 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
8035 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
8036 regfield, "regfield");
8037 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
8038 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
8040 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
8041 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
8043 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
8044 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
8046 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
8047 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
8050 cmdline_parse_inst_t cmd_read_reg_bit_field = {
8051 .f = cmd_read_reg_bit_field_parsed,
8053 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
8054 "Read register bit field between bit_x and bit_y included",
8056 (void *)&cmd_read_reg_bit_field_read,
8057 (void *)&cmd_read_reg_bit_field_regfield,
8058 (void *)&cmd_read_reg_bit_field_port_id,
8059 (void *)&cmd_read_reg_bit_field_reg_off,
8060 (void *)&cmd_read_reg_bit_field_bit1_pos,
8061 (void *)&cmd_read_reg_bit_field_bit2_pos,
8066 /* *** READ PORT REGISTER BIT *** */
8067 struct cmd_read_reg_bit_result {
8068 cmdline_fixed_string_t read;
8069 cmdline_fixed_string_t regbit;
8076 cmd_read_reg_bit_parsed(void *parsed_result,
8077 __rte_unused struct cmdline *cl,
8078 __rte_unused void *data)
8080 struct cmd_read_reg_bit_result *res = parsed_result;
8081 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
8084 cmdline_parse_token_string_t cmd_read_reg_bit_read =
8085 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
8086 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
8087 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
8089 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
8090 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT16);
8091 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
8092 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
8093 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
8094 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
8096 cmdline_parse_inst_t cmd_read_reg_bit = {
8097 .f = cmd_read_reg_bit_parsed,
8099 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
8101 (void *)&cmd_read_reg_bit_read,
8102 (void *)&cmd_read_reg_bit_regbit,
8103 (void *)&cmd_read_reg_bit_port_id,
8104 (void *)&cmd_read_reg_bit_reg_off,
8105 (void *)&cmd_read_reg_bit_bit_pos,
8110 /* *** WRITE PORT REGISTER *** */
8111 struct cmd_write_reg_result {
8112 cmdline_fixed_string_t write;
8113 cmdline_fixed_string_t reg;
8120 cmd_write_reg_parsed(void *parsed_result,
8121 __rte_unused struct cmdline *cl,
8122 __rte_unused void *data)
8124 struct cmd_write_reg_result *res = parsed_result;
8125 port_reg_set(res->port_id, res->reg_off, res->value);
8128 cmdline_parse_token_string_t cmd_write_reg_write =
8129 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
8130 cmdline_parse_token_string_t cmd_write_reg_reg =
8131 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
8132 cmdline_parse_token_num_t cmd_write_reg_port_id =
8133 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT16);
8134 cmdline_parse_token_num_t cmd_write_reg_reg_off =
8135 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
8136 cmdline_parse_token_num_t cmd_write_reg_value =
8137 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
8139 cmdline_parse_inst_t cmd_write_reg = {
8140 .f = cmd_write_reg_parsed,
8142 .help_str = "write reg <port_id> <reg_off> <reg_value>",
8144 (void *)&cmd_write_reg_write,
8145 (void *)&cmd_write_reg_reg,
8146 (void *)&cmd_write_reg_port_id,
8147 (void *)&cmd_write_reg_reg_off,
8148 (void *)&cmd_write_reg_value,
8153 /* *** WRITE PORT REGISTER BIT FIELD *** */
8154 struct cmd_write_reg_bit_field_result {
8155 cmdline_fixed_string_t write;
8156 cmdline_fixed_string_t regfield;
8165 cmd_write_reg_bit_field_parsed(void *parsed_result,
8166 __rte_unused struct cmdline *cl,
8167 __rte_unused void *data)
8169 struct cmd_write_reg_bit_field_result *res = parsed_result;
8170 port_reg_bit_field_set(res->port_id, res->reg_off,
8171 res->bit1_pos, res->bit2_pos, res->value);
8174 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
8175 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
8177 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
8178 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
8179 regfield, "regfield");
8180 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
8181 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
8183 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
8184 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
8186 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
8187 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
8189 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
8190 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
8192 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
8193 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
8196 cmdline_parse_inst_t cmd_write_reg_bit_field = {
8197 .f = cmd_write_reg_bit_field_parsed,
8199 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
8201 "Set register bit field between bit_x and bit_y included",
8203 (void *)&cmd_write_reg_bit_field_write,
8204 (void *)&cmd_write_reg_bit_field_regfield,
8205 (void *)&cmd_write_reg_bit_field_port_id,
8206 (void *)&cmd_write_reg_bit_field_reg_off,
8207 (void *)&cmd_write_reg_bit_field_bit1_pos,
8208 (void *)&cmd_write_reg_bit_field_bit2_pos,
8209 (void *)&cmd_write_reg_bit_field_value,
8214 /* *** WRITE PORT REGISTER BIT *** */
8215 struct cmd_write_reg_bit_result {
8216 cmdline_fixed_string_t write;
8217 cmdline_fixed_string_t regbit;
8225 cmd_write_reg_bit_parsed(void *parsed_result,
8226 __rte_unused struct cmdline *cl,
8227 __rte_unused void *data)
8229 struct cmd_write_reg_bit_result *res = parsed_result;
8230 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
8233 cmdline_parse_token_string_t cmd_write_reg_bit_write =
8234 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
8236 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
8237 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
8239 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
8240 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT16);
8241 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
8242 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
8243 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
8244 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
8245 cmdline_parse_token_num_t cmd_write_reg_bit_value =
8246 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
8248 cmdline_parse_inst_t cmd_write_reg_bit = {
8249 .f = cmd_write_reg_bit_parsed,
8251 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
8254 (void *)&cmd_write_reg_bit_write,
8255 (void *)&cmd_write_reg_bit_regbit,
8256 (void *)&cmd_write_reg_bit_port_id,
8257 (void *)&cmd_write_reg_bit_reg_off,
8258 (void *)&cmd_write_reg_bit_bit_pos,
8259 (void *)&cmd_write_reg_bit_value,
8264 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
8265 struct cmd_read_rxd_txd_result {
8266 cmdline_fixed_string_t read;
8267 cmdline_fixed_string_t rxd_txd;
8274 cmd_read_rxd_txd_parsed(void *parsed_result,
8275 __rte_unused struct cmdline *cl,
8276 __rte_unused void *data)
8278 struct cmd_read_rxd_txd_result *res = parsed_result;
8280 if (!strcmp(res->rxd_txd, "rxd"))
8281 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
8282 else if (!strcmp(res->rxd_txd, "txd"))
8283 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
8286 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
8287 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
8288 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
8289 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
8291 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
8292 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT16);
8293 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
8294 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
8295 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
8296 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
8298 cmdline_parse_inst_t cmd_read_rxd_txd = {
8299 .f = cmd_read_rxd_txd_parsed,
8301 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
8303 (void *)&cmd_read_rxd_txd_read,
8304 (void *)&cmd_read_rxd_txd_rxd_txd,
8305 (void *)&cmd_read_rxd_txd_port_id,
8306 (void *)&cmd_read_rxd_txd_queue_id,
8307 (void *)&cmd_read_rxd_txd_desc_id,
8313 struct cmd_quit_result {
8314 cmdline_fixed_string_t quit;
8317 static void cmd_quit_parsed(__rte_unused void *parsed_result,
8319 __rte_unused void *data)
8324 cmdline_parse_token_string_t cmd_quit_quit =
8325 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
8327 cmdline_parse_inst_t cmd_quit = {
8328 .f = cmd_quit_parsed,
8330 .help_str = "quit: Exit application",
8332 (void *)&cmd_quit_quit,
8337 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
8338 struct cmd_mac_addr_result {
8339 cmdline_fixed_string_t mac_addr_cmd;
8340 cmdline_fixed_string_t what;
8342 struct rte_ether_addr address;
8345 static void cmd_mac_addr_parsed(void *parsed_result,
8346 __rte_unused struct cmdline *cl,
8347 __rte_unused void *data)
8349 struct cmd_mac_addr_result *res = parsed_result;
8352 if (strcmp(res->what, "add") == 0)
8353 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
8354 else if (strcmp(res->what, "set") == 0)
8355 ret = rte_eth_dev_default_mac_addr_set(res->port_num,
8358 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
8360 /* check the return value and print it if is < 0 */
8362 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
8366 cmdline_parse_token_string_t cmd_mac_addr_cmd =
8367 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
8369 cmdline_parse_token_string_t cmd_mac_addr_what =
8370 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
8372 cmdline_parse_token_num_t cmd_mac_addr_portnum =
8373 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num,
8375 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
8376 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
8378 cmdline_parse_inst_t cmd_mac_addr = {
8379 .f = cmd_mac_addr_parsed,
8381 .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
8382 "Add/Remove/Set MAC address on port_id",
8384 (void *)&cmd_mac_addr_cmd,
8385 (void *)&cmd_mac_addr_what,
8386 (void *)&cmd_mac_addr_portnum,
8387 (void *)&cmd_mac_addr_addr,
8392 /* *** SET THE PEER ADDRESS FOR CERTAIN PORT *** */
8393 struct cmd_eth_peer_result {
8394 cmdline_fixed_string_t set;
8395 cmdline_fixed_string_t eth_peer;
8397 cmdline_fixed_string_t peer_addr;
8400 static void cmd_set_eth_peer_parsed(void *parsed_result,
8401 __rte_unused struct cmdline *cl,
8402 __rte_unused void *data)
8404 struct cmd_eth_peer_result *res = parsed_result;
8406 if (test_done == 0) {
8407 printf("Please stop forwarding first\n");
8410 if (!strcmp(res->eth_peer, "eth-peer")) {
8411 set_fwd_eth_peer(res->port_id, res->peer_addr);
8415 cmdline_parse_token_string_t cmd_eth_peer_set =
8416 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, set, "set");
8417 cmdline_parse_token_string_t cmd_eth_peer =
8418 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, eth_peer, "eth-peer");
8419 cmdline_parse_token_num_t cmd_eth_peer_port_id =
8420 TOKEN_NUM_INITIALIZER(struct cmd_eth_peer_result, port_id, UINT16);
8421 cmdline_parse_token_string_t cmd_eth_peer_addr =
8422 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, peer_addr, NULL);
8424 cmdline_parse_inst_t cmd_set_fwd_eth_peer = {
8425 .f = cmd_set_eth_peer_parsed,
8427 .help_str = "set eth-peer <port_id> <peer_mac>",
8429 (void *)&cmd_eth_peer_set,
8430 (void *)&cmd_eth_peer,
8431 (void *)&cmd_eth_peer_port_id,
8432 (void *)&cmd_eth_peer_addr,
8437 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
8438 struct cmd_set_qmap_result {
8439 cmdline_fixed_string_t set;
8440 cmdline_fixed_string_t qmap;
8441 cmdline_fixed_string_t what;
8448 cmd_set_qmap_parsed(void *parsed_result,
8449 __rte_unused struct cmdline *cl,
8450 __rte_unused void *data)
8452 struct cmd_set_qmap_result *res = parsed_result;
8453 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
8455 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
8458 cmdline_parse_token_string_t cmd_setqmap_set =
8459 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8461 cmdline_parse_token_string_t cmd_setqmap_qmap =
8462 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8464 cmdline_parse_token_string_t cmd_setqmap_what =
8465 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8467 cmdline_parse_token_num_t cmd_setqmap_portid =
8468 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8470 cmdline_parse_token_num_t cmd_setqmap_queueid =
8471 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8473 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
8474 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8477 cmdline_parse_inst_t cmd_set_qmap = {
8478 .f = cmd_set_qmap_parsed,
8480 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
8481 "Set statistics mapping value on tx|rx queue_id of port_id",
8483 (void *)&cmd_setqmap_set,
8484 (void *)&cmd_setqmap_qmap,
8485 (void *)&cmd_setqmap_what,
8486 (void *)&cmd_setqmap_portid,
8487 (void *)&cmd_setqmap_queueid,
8488 (void *)&cmd_setqmap_mapvalue,
8493 /* *** SET OPTION TO HIDE ZERO VALUES FOR XSTATS DISPLAY *** */
8494 struct cmd_set_xstats_hide_zero_result {
8495 cmdline_fixed_string_t keyword;
8496 cmdline_fixed_string_t name;
8497 cmdline_fixed_string_t on_off;
8501 cmd_set_xstats_hide_zero_parsed(void *parsed_result,
8502 __rte_unused struct cmdline *cl,
8503 __rte_unused void *data)
8505 struct cmd_set_xstats_hide_zero_result *res;
8506 uint16_t on_off = 0;
8508 res = parsed_result;
8509 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8510 set_xstats_hide_zero(on_off);
8513 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_keyword =
8514 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8516 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_name =
8517 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8518 name, "xstats-hide-zero");
8519 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_on_off =
8520 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8523 cmdline_parse_inst_t cmd_set_xstats_hide_zero = {
8524 .f = cmd_set_xstats_hide_zero_parsed,
8526 .help_str = "set xstats-hide-zero on|off",
8528 (void *)&cmd_set_xstats_hide_zero_keyword,
8529 (void *)&cmd_set_xstats_hide_zero_name,
8530 (void *)&cmd_set_xstats_hide_zero_on_off,
8535 /* *** SET OPTION TO ENABLE MEASUREMENT OF CPU CYCLES *** */
8536 struct cmd_set_record_core_cycles_result {
8537 cmdline_fixed_string_t keyword;
8538 cmdline_fixed_string_t name;
8539 cmdline_fixed_string_t on_off;
8543 cmd_set_record_core_cycles_parsed(void *parsed_result,
8544 __rte_unused struct cmdline *cl,
8545 __rte_unused void *data)
8547 struct cmd_set_record_core_cycles_result *res;
8548 uint16_t on_off = 0;
8550 res = parsed_result;
8551 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8552 set_record_core_cycles(on_off);
8555 cmdline_parse_token_string_t cmd_set_record_core_cycles_keyword =
8556 TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
8558 cmdline_parse_token_string_t cmd_set_record_core_cycles_name =
8559 TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
8560 name, "record-core-cycles");
8561 cmdline_parse_token_string_t cmd_set_record_core_cycles_on_off =
8562 TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
8565 cmdline_parse_inst_t cmd_set_record_core_cycles = {
8566 .f = cmd_set_record_core_cycles_parsed,
8568 .help_str = "set record-core-cycles on|off",
8570 (void *)&cmd_set_record_core_cycles_keyword,
8571 (void *)&cmd_set_record_core_cycles_name,
8572 (void *)&cmd_set_record_core_cycles_on_off,
8577 /* *** SET OPTION TO ENABLE DISPLAY OF RX AND TX BURSTS *** */
8578 struct cmd_set_record_burst_stats_result {
8579 cmdline_fixed_string_t keyword;
8580 cmdline_fixed_string_t name;
8581 cmdline_fixed_string_t on_off;
8585 cmd_set_record_burst_stats_parsed(void *parsed_result,
8586 __rte_unused struct cmdline *cl,
8587 __rte_unused void *data)
8589 struct cmd_set_record_burst_stats_result *res;
8590 uint16_t on_off = 0;
8592 res = parsed_result;
8593 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8594 set_record_burst_stats(on_off);
8597 cmdline_parse_token_string_t cmd_set_record_burst_stats_keyword =
8598 TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
8600 cmdline_parse_token_string_t cmd_set_record_burst_stats_name =
8601 TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
8602 name, "record-burst-stats");
8603 cmdline_parse_token_string_t cmd_set_record_burst_stats_on_off =
8604 TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
8607 cmdline_parse_inst_t cmd_set_record_burst_stats = {
8608 .f = cmd_set_record_burst_stats_parsed,
8610 .help_str = "set record-burst-stats on|off",
8612 (void *)&cmd_set_record_burst_stats_keyword,
8613 (void *)&cmd_set_record_burst_stats_name,
8614 (void *)&cmd_set_record_burst_stats_on_off,
8619 /* *** CONFIGURE UNICAST HASH TABLE *** */
8620 struct cmd_set_uc_hash_table {
8621 cmdline_fixed_string_t set;
8622 cmdline_fixed_string_t port;
8624 cmdline_fixed_string_t what;
8625 struct rte_ether_addr address;
8626 cmdline_fixed_string_t mode;
8630 cmd_set_uc_hash_parsed(void *parsed_result,
8631 __rte_unused struct cmdline *cl,
8632 __rte_unused void *data)
8635 struct cmd_set_uc_hash_table *res = parsed_result;
8637 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8639 if (strcmp(res->what, "uta") == 0)
8640 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
8641 &res->address,(uint8_t)is_on);
8643 printf("bad unicast hash table parameter, return code = %d \n", ret);
8647 cmdline_parse_token_string_t cmd_set_uc_hash_set =
8648 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8650 cmdline_parse_token_string_t cmd_set_uc_hash_port =
8651 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8653 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
8654 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
8656 cmdline_parse_token_string_t cmd_set_uc_hash_what =
8657 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8659 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
8660 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
8662 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
8663 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8666 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
8667 .f = cmd_set_uc_hash_parsed,
8669 .help_str = "set port <port_id> uta <mac_addr> on|off)",
8671 (void *)&cmd_set_uc_hash_set,
8672 (void *)&cmd_set_uc_hash_port,
8673 (void *)&cmd_set_uc_hash_portid,
8674 (void *)&cmd_set_uc_hash_what,
8675 (void *)&cmd_set_uc_hash_mac,
8676 (void *)&cmd_set_uc_hash_mode,
8681 struct cmd_set_uc_all_hash_table {
8682 cmdline_fixed_string_t set;
8683 cmdline_fixed_string_t port;
8685 cmdline_fixed_string_t what;
8686 cmdline_fixed_string_t value;
8687 cmdline_fixed_string_t mode;
8691 cmd_set_uc_all_hash_parsed(void *parsed_result,
8692 __rte_unused struct cmdline *cl,
8693 __rte_unused void *data)
8696 struct cmd_set_uc_all_hash_table *res = parsed_result;
8698 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8700 if ((strcmp(res->what, "uta") == 0) &&
8701 (strcmp(res->value, "all") == 0))
8702 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
8704 printf("bad unicast hash table parameter,"
8705 "return code = %d \n", ret);
8708 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
8709 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8711 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
8712 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8714 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
8715 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
8717 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
8718 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8720 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
8721 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8723 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
8724 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8727 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
8728 .f = cmd_set_uc_all_hash_parsed,
8730 .help_str = "set port <port_id> uta all on|off",
8732 (void *)&cmd_set_uc_all_hash_set,
8733 (void *)&cmd_set_uc_all_hash_port,
8734 (void *)&cmd_set_uc_all_hash_portid,
8735 (void *)&cmd_set_uc_all_hash_what,
8736 (void *)&cmd_set_uc_all_hash_value,
8737 (void *)&cmd_set_uc_all_hash_mode,
8742 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
8743 struct cmd_set_vf_traffic {
8744 cmdline_fixed_string_t set;
8745 cmdline_fixed_string_t port;
8747 cmdline_fixed_string_t vf;
8749 cmdline_fixed_string_t what;
8750 cmdline_fixed_string_t mode;
8754 cmd_set_vf_traffic_parsed(void *parsed_result,
8755 __rte_unused struct cmdline *cl,
8756 __rte_unused void *data)
8758 struct cmd_set_vf_traffic *res = parsed_result;
8759 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
8760 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8762 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
8765 cmdline_parse_token_string_t cmd_setvf_traffic_set =
8766 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8768 cmdline_parse_token_string_t cmd_setvf_traffic_port =
8769 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8771 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
8772 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8774 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
8775 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8777 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
8778 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8780 cmdline_parse_token_string_t cmd_setvf_traffic_what =
8781 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8783 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
8784 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8787 cmdline_parse_inst_t cmd_set_vf_traffic = {
8788 .f = cmd_set_vf_traffic_parsed,
8790 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
8792 (void *)&cmd_setvf_traffic_set,
8793 (void *)&cmd_setvf_traffic_port,
8794 (void *)&cmd_setvf_traffic_portid,
8795 (void *)&cmd_setvf_traffic_vf,
8796 (void *)&cmd_setvf_traffic_vfid,
8797 (void *)&cmd_setvf_traffic_what,
8798 (void *)&cmd_setvf_traffic_mode,
8803 /* *** CONFIGURE VF RECEIVE MODE *** */
8804 struct cmd_set_vf_rxmode {
8805 cmdline_fixed_string_t set;
8806 cmdline_fixed_string_t port;
8808 cmdline_fixed_string_t vf;
8810 cmdline_fixed_string_t what;
8811 cmdline_fixed_string_t mode;
8812 cmdline_fixed_string_t on;
8816 cmd_set_vf_rxmode_parsed(void *parsed_result,
8817 __rte_unused struct cmdline *cl,
8818 __rte_unused void *data)
8821 uint16_t vf_rxmode = 0;
8822 struct cmd_set_vf_rxmode *res = parsed_result;
8824 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
8825 if (!strcmp(res->what,"rxmode")) {
8826 if (!strcmp(res->mode, "AUPE"))
8827 vf_rxmode |= ETH_VMDQ_ACCEPT_UNTAG;
8828 else if (!strcmp(res->mode, "ROPE"))
8829 vf_rxmode |= ETH_VMDQ_ACCEPT_HASH_UC;
8830 else if (!strcmp(res->mode, "BAM"))
8831 vf_rxmode |= ETH_VMDQ_ACCEPT_BROADCAST;
8832 else if (!strncmp(res->mode, "MPE",3))
8833 vf_rxmode |= ETH_VMDQ_ACCEPT_MULTICAST;
8836 RTE_SET_USED(is_on);
8838 #ifdef RTE_NET_IXGBE
8839 if (ret == -ENOTSUP)
8840 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id,
8841 vf_rxmode, (uint8_t)is_on);
8844 if (ret == -ENOTSUP)
8845 ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id,
8846 vf_rxmode, (uint8_t)is_on);
8849 printf("bad VF receive mode parameter, return code = %d \n",
8853 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
8854 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8856 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
8857 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8859 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
8860 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8862 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
8863 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8865 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
8866 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8868 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
8869 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8871 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
8872 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8873 mode, "AUPE#ROPE#BAM#MPE");
8874 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
8875 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8878 cmdline_parse_inst_t cmd_set_vf_rxmode = {
8879 .f = cmd_set_vf_rxmode_parsed,
8881 .help_str = "set port <port_id> vf <vf_id> rxmode "
8882 "AUPE|ROPE|BAM|MPE on|off",
8884 (void *)&cmd_set_vf_rxmode_set,
8885 (void *)&cmd_set_vf_rxmode_port,
8886 (void *)&cmd_set_vf_rxmode_portid,
8887 (void *)&cmd_set_vf_rxmode_vf,
8888 (void *)&cmd_set_vf_rxmode_vfid,
8889 (void *)&cmd_set_vf_rxmode_what,
8890 (void *)&cmd_set_vf_rxmode_mode,
8891 (void *)&cmd_set_vf_rxmode_on,
8896 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
8897 struct cmd_vf_mac_addr_result {
8898 cmdline_fixed_string_t mac_addr_cmd;
8899 cmdline_fixed_string_t what;
8900 cmdline_fixed_string_t port;
8902 cmdline_fixed_string_t vf;
8904 struct rte_ether_addr address;
8907 static void cmd_vf_mac_addr_parsed(void *parsed_result,
8908 __rte_unused struct cmdline *cl,
8909 __rte_unused void *data)
8911 struct cmd_vf_mac_addr_result *res = parsed_result;
8914 if (strcmp(res->what, "add") != 0)
8918 if (ret == -ENOTSUP)
8919 ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num,
8923 if (ret == -ENOTSUP)
8924 ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address,
8929 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
8933 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
8934 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8935 mac_addr_cmd,"mac_addr");
8936 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
8937 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8939 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
8940 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8942 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
8943 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8945 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
8946 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8948 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
8949 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8951 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
8952 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
8955 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
8956 .f = cmd_vf_mac_addr_parsed,
8958 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
8959 "Add MAC address filtering for a VF on port_id",
8961 (void *)&cmd_vf_mac_addr_cmd,
8962 (void *)&cmd_vf_mac_addr_what,
8963 (void *)&cmd_vf_mac_addr_port,
8964 (void *)&cmd_vf_mac_addr_portnum,
8965 (void *)&cmd_vf_mac_addr_vf,
8966 (void *)&cmd_vf_mac_addr_vfnum,
8967 (void *)&cmd_vf_mac_addr_addr,
8972 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
8973 struct cmd_vf_rx_vlan_filter {
8974 cmdline_fixed_string_t rx_vlan;
8975 cmdline_fixed_string_t what;
8977 cmdline_fixed_string_t port;
8979 cmdline_fixed_string_t vf;
8984 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
8985 __rte_unused struct cmdline *cl,
8986 __rte_unused void *data)
8988 struct cmd_vf_rx_vlan_filter *res = parsed_result;
8991 __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
8993 #ifdef RTE_NET_IXGBE
8994 if (ret == -ENOTSUP)
8995 ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
8996 res->vlan_id, res->vf_mask, is_add);
8999 if (ret == -ENOTSUP)
9000 ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
9001 res->vlan_id, res->vf_mask, is_add);
9004 if (ret == -ENOTSUP)
9005 ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id,
9006 res->vlan_id, res->vf_mask, is_add);
9013 printf("invalid vlan_id %d or vf_mask %"PRIu64"\n",
9014 res->vlan_id, res->vf_mask);
9017 printf("invalid port_id %d\n", res->port_id);
9020 printf("function not implemented or supported\n");
9023 printf("programming error: (%s)\n", strerror(-ret));
9027 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
9028 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9029 rx_vlan, "rx_vlan");
9030 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
9031 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9033 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
9034 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9036 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
9037 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9039 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
9040 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9042 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
9043 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9045 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
9046 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9049 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
9050 .f = cmd_vf_rx_vlan_filter_parsed,
9052 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
9053 "(vf_mask = hexadecimal VF mask)",
9055 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
9056 (void *)&cmd_vf_rx_vlan_filter_what,
9057 (void *)&cmd_vf_rx_vlan_filter_vlanid,
9058 (void *)&cmd_vf_rx_vlan_filter_port,
9059 (void *)&cmd_vf_rx_vlan_filter_portid,
9060 (void *)&cmd_vf_rx_vlan_filter_vf,
9061 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
9066 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
9067 struct cmd_queue_rate_limit_result {
9068 cmdline_fixed_string_t set;
9069 cmdline_fixed_string_t port;
9071 cmdline_fixed_string_t queue;
9073 cmdline_fixed_string_t rate;
9077 static void cmd_queue_rate_limit_parsed(void *parsed_result,
9078 __rte_unused struct cmdline *cl,
9079 __rte_unused void *data)
9081 struct cmd_queue_rate_limit_result *res = parsed_result;
9084 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
9085 && (strcmp(res->queue, "queue") == 0)
9086 && (strcmp(res->rate, "rate") == 0))
9087 ret = set_queue_rate_limit(res->port_num, res->queue_num,
9090 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
9094 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
9095 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9097 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
9098 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9100 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
9101 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
9103 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
9104 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9106 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
9107 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
9109 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
9110 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9112 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
9113 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
9116 cmdline_parse_inst_t cmd_queue_rate_limit = {
9117 .f = cmd_queue_rate_limit_parsed,
9119 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
9120 "Set rate limit for a queue on port_id",
9122 (void *)&cmd_queue_rate_limit_set,
9123 (void *)&cmd_queue_rate_limit_port,
9124 (void *)&cmd_queue_rate_limit_portnum,
9125 (void *)&cmd_queue_rate_limit_queue,
9126 (void *)&cmd_queue_rate_limit_queuenum,
9127 (void *)&cmd_queue_rate_limit_rate,
9128 (void *)&cmd_queue_rate_limit_ratenum,
9133 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
9134 struct cmd_vf_rate_limit_result {
9135 cmdline_fixed_string_t set;
9136 cmdline_fixed_string_t port;
9138 cmdline_fixed_string_t vf;
9140 cmdline_fixed_string_t rate;
9142 cmdline_fixed_string_t q_msk;
9146 static void cmd_vf_rate_limit_parsed(void *parsed_result,
9147 __rte_unused struct cmdline *cl,
9148 __rte_unused void *data)
9150 struct cmd_vf_rate_limit_result *res = parsed_result;
9153 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
9154 && (strcmp(res->vf, "vf") == 0)
9155 && (strcmp(res->rate, "rate") == 0)
9156 && (strcmp(res->q_msk, "queue_mask") == 0))
9157 ret = set_vf_rate_limit(res->port_num, res->vf_num,
9158 res->rate_num, res->q_msk_val);
9160 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
9164 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
9165 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9167 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
9168 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9170 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
9171 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9173 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
9174 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9176 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
9177 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9179 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
9180 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9182 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
9183 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9185 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
9186 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9187 q_msk, "queue_mask");
9188 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
9189 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9192 cmdline_parse_inst_t cmd_vf_rate_limit = {
9193 .f = cmd_vf_rate_limit_parsed,
9195 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
9196 "queue_mask <queue_mask_value>: "
9197 "Set rate limit for queues of VF on port_id",
9199 (void *)&cmd_vf_rate_limit_set,
9200 (void *)&cmd_vf_rate_limit_port,
9201 (void *)&cmd_vf_rate_limit_portnum,
9202 (void *)&cmd_vf_rate_limit_vf,
9203 (void *)&cmd_vf_rate_limit_vfnum,
9204 (void *)&cmd_vf_rate_limit_rate,
9205 (void *)&cmd_vf_rate_limit_ratenum,
9206 (void *)&cmd_vf_rate_limit_q_msk,
9207 (void *)&cmd_vf_rate_limit_q_msk_val,
9212 /* *** ADD TUNNEL FILTER OF A PORT *** */
9213 struct cmd_tunnel_filter_result {
9214 cmdline_fixed_string_t cmd;
9215 cmdline_fixed_string_t what;
9217 struct rte_ether_addr outer_mac;
9218 struct rte_ether_addr inner_mac;
9219 cmdline_ipaddr_t ip_value;
9220 uint16_t inner_vlan;
9221 cmdline_fixed_string_t tunnel_type;
9222 cmdline_fixed_string_t filter_type;
9228 cmd_tunnel_filter_parsed(void *parsed_result,
9229 __rte_unused struct cmdline *cl,
9230 __rte_unused void *data)
9232 struct cmd_tunnel_filter_result *res = parsed_result;
9233 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
9236 memset(&tunnel_filter_conf, 0, sizeof(tunnel_filter_conf));
9238 rte_ether_addr_copy(&res->outer_mac, &tunnel_filter_conf.outer_mac);
9239 rte_ether_addr_copy(&res->inner_mac, &tunnel_filter_conf.inner_mac);
9240 tunnel_filter_conf.inner_vlan = res->inner_vlan;
9242 if (res->ip_value.family == AF_INET) {
9243 tunnel_filter_conf.ip_addr.ipv4_addr =
9244 res->ip_value.addr.ipv4.s_addr;
9245 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
9247 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
9248 &(res->ip_value.addr.ipv6),
9249 sizeof(struct in6_addr));
9250 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
9253 if (!strcmp(res->filter_type, "imac-ivlan"))
9254 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
9255 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
9256 tunnel_filter_conf.filter_type =
9257 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
9258 else if (!strcmp(res->filter_type, "imac-tenid"))
9259 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
9260 else if (!strcmp(res->filter_type, "imac"))
9261 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
9262 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
9263 tunnel_filter_conf.filter_type =
9264 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
9265 else if (!strcmp(res->filter_type, "oip"))
9266 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_OIP;
9267 else if (!strcmp(res->filter_type, "iip"))
9268 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IIP;
9270 printf("The filter type is not supported");
9274 if (!strcmp(res->tunnel_type, "vxlan"))
9275 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
9276 else if (!strcmp(res->tunnel_type, "vxlan-gpe"))
9277 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN_GPE;
9278 else if (!strcmp(res->tunnel_type, "nvgre"))
9279 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE;
9280 else if (!strcmp(res->tunnel_type, "ipingre"))
9281 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_IP_IN_GRE;
9283 printf("The tunnel type %s not supported.\n", res->tunnel_type);
9287 tunnel_filter_conf.tenant_id = res->tenant_id;
9288 tunnel_filter_conf.queue_id = res->queue_num;
9289 if (!strcmp(res->what, "add"))
9290 ret = rte_eth_dev_filter_ctrl(res->port_id,
9291 RTE_ETH_FILTER_TUNNEL,
9293 &tunnel_filter_conf);
9295 ret = rte_eth_dev_filter_ctrl(res->port_id,
9296 RTE_ETH_FILTER_TUNNEL,
9297 RTE_ETH_FILTER_DELETE,
9298 &tunnel_filter_conf);
9300 printf("cmd_tunnel_filter_parsed error: (%s)\n",
9304 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
9305 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
9306 cmd, "tunnel_filter");
9307 cmdline_parse_token_string_t cmd_tunnel_filter_what =
9308 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
9310 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
9311 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
9313 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
9314 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
9316 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
9317 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
9319 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
9320 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
9321 inner_vlan, UINT16);
9322 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
9323 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
9325 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
9326 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
9327 tunnel_type, "vxlan#nvgre#ipingre#vxlan-gpe");
9329 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
9330 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
9331 filter_type, "oip#iip#imac-ivlan#imac-ivlan-tenid#imac-tenid#"
9332 "imac#omac-imac-tenid");
9333 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
9334 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
9336 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
9337 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
9340 cmdline_parse_inst_t cmd_tunnel_filter = {
9341 .f = cmd_tunnel_filter_parsed,
9343 .help_str = "tunnel_filter add|rm <port_id> <outer_mac> <inner_mac> "
9344 "<ip> <inner_vlan> vxlan|nvgre|ipingre oip|iip|imac-ivlan|"
9345 "imac-ivlan-tenid|imac-tenid|imac|omac-imac-tenid <tenant_id> "
9346 "<queue_id>: Add/Rm tunnel filter of a port",
9348 (void *)&cmd_tunnel_filter_cmd,
9349 (void *)&cmd_tunnel_filter_what,
9350 (void *)&cmd_tunnel_filter_port_id,
9351 (void *)&cmd_tunnel_filter_outer_mac,
9352 (void *)&cmd_tunnel_filter_inner_mac,
9353 (void *)&cmd_tunnel_filter_ip_value,
9354 (void *)&cmd_tunnel_filter_innner_vlan,
9355 (void *)&cmd_tunnel_filter_tunnel_type,
9356 (void *)&cmd_tunnel_filter_filter_type,
9357 (void *)&cmd_tunnel_filter_tenant_id,
9358 (void *)&cmd_tunnel_filter_queue_num,
9363 /* *** CONFIGURE TUNNEL UDP PORT *** */
9364 struct cmd_tunnel_udp_config {
9365 cmdline_fixed_string_t cmd;
9366 cmdline_fixed_string_t what;
9372 cmd_tunnel_udp_config_parsed(void *parsed_result,
9373 __rte_unused struct cmdline *cl,
9374 __rte_unused void *data)
9376 struct cmd_tunnel_udp_config *res = parsed_result;
9377 struct rte_eth_udp_tunnel tunnel_udp;
9380 tunnel_udp.udp_port = res->udp_port;
9382 if (!strcmp(res->cmd, "rx_vxlan_port"))
9383 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
9385 if (!strcmp(res->what, "add"))
9386 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9389 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9393 printf("udp tunneling add error: (%s)\n", strerror(-ret));
9396 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
9397 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9398 cmd, "rx_vxlan_port");
9399 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
9400 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9402 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
9403 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9405 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
9406 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9409 cmdline_parse_inst_t cmd_tunnel_udp_config = {
9410 .f = cmd_tunnel_udp_config_parsed,
9412 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
9413 "Add/Remove a tunneling UDP port filter",
9415 (void *)&cmd_tunnel_udp_config_cmd,
9416 (void *)&cmd_tunnel_udp_config_what,
9417 (void *)&cmd_tunnel_udp_config_udp_port,
9418 (void *)&cmd_tunnel_udp_config_port_id,
9423 struct cmd_config_tunnel_udp_port {
9424 cmdline_fixed_string_t port;
9425 cmdline_fixed_string_t config;
9427 cmdline_fixed_string_t udp_tunnel_port;
9428 cmdline_fixed_string_t action;
9429 cmdline_fixed_string_t tunnel_type;
9434 cmd_cfg_tunnel_udp_port_parsed(void *parsed_result,
9435 __rte_unused struct cmdline *cl,
9436 __rte_unused void *data)
9438 struct cmd_config_tunnel_udp_port *res = parsed_result;
9439 struct rte_eth_udp_tunnel tunnel_udp;
9442 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9445 tunnel_udp.udp_port = res->udp_port;
9447 if (!strcmp(res->tunnel_type, "vxlan")) {
9448 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
9449 } else if (!strcmp(res->tunnel_type, "geneve")) {
9450 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_GENEVE;
9451 } else if (!strcmp(res->tunnel_type, "vxlan-gpe")) {
9452 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN_GPE;
9454 printf("Invalid tunnel type\n");
9458 if (!strcmp(res->action, "add"))
9459 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9462 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9466 printf("udp tunneling port add error: (%s)\n", strerror(-ret));
9469 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_port =
9470 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, port,
9472 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_config =
9473 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, config,
9475 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_port_id =
9476 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, port_id,
9478 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_port =
9479 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port,
9482 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_action =
9483 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, action,
9485 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_type =
9486 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, tunnel_type,
9487 "vxlan#geneve#vxlan-gpe");
9488 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_value =
9489 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, udp_port,
9492 cmdline_parse_inst_t cmd_cfg_tunnel_udp_port = {
9493 .f = cmd_cfg_tunnel_udp_port_parsed,
9495 .help_str = "port config <port_id> udp_tunnel_port add|rm vxlan|geneve|vxlan-gpe <udp_port>",
9497 (void *)&cmd_config_tunnel_udp_port_port,
9498 (void *)&cmd_config_tunnel_udp_port_config,
9499 (void *)&cmd_config_tunnel_udp_port_port_id,
9500 (void *)&cmd_config_tunnel_udp_port_tunnel_port,
9501 (void *)&cmd_config_tunnel_udp_port_action,
9502 (void *)&cmd_config_tunnel_udp_port_tunnel_type,
9503 (void *)&cmd_config_tunnel_udp_port_value,
9508 /* *** GLOBAL CONFIG *** */
9509 struct cmd_global_config_result {
9510 cmdline_fixed_string_t cmd;
9512 cmdline_fixed_string_t cfg_type;
9517 cmd_global_config_parsed(void *parsed_result,
9518 __rte_unused struct cmdline *cl,
9519 __rte_unused void *data)
9521 struct cmd_global_config_result *res = parsed_result;
9522 struct rte_eth_global_cfg conf;
9525 memset(&conf, 0, sizeof(conf));
9526 conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN;
9527 conf.cfg.gre_key_len = res->len;
9528 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE,
9529 RTE_ETH_FILTER_SET, &conf);
9531 if (ret == -ENOTSUP)
9532 ret = rte_pmd_i40e_set_gre_key_len(res->port_id, res->len);
9535 printf("Global config error\n");
9538 cmdline_parse_token_string_t cmd_global_config_cmd =
9539 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd,
9541 cmdline_parse_token_num_t cmd_global_config_port_id =
9542 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id,
9544 cmdline_parse_token_string_t cmd_global_config_type =
9545 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result,
9546 cfg_type, "gre-key-len");
9547 cmdline_parse_token_num_t cmd_global_config_gre_key_len =
9548 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result,
9551 cmdline_parse_inst_t cmd_global_config = {
9552 .f = cmd_global_config_parsed,
9553 .data = (void *)NULL,
9554 .help_str = "global_config <port_id> gre-key-len <key_len>",
9556 (void *)&cmd_global_config_cmd,
9557 (void *)&cmd_global_config_port_id,
9558 (void *)&cmd_global_config_type,
9559 (void *)&cmd_global_config_gre_key_len,
9564 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
9565 struct cmd_set_mirror_mask_result {
9566 cmdline_fixed_string_t set;
9567 cmdline_fixed_string_t port;
9569 cmdline_fixed_string_t mirror;
9571 cmdline_fixed_string_t what;
9572 cmdline_fixed_string_t value;
9573 cmdline_fixed_string_t dstpool;
9575 cmdline_fixed_string_t on;
9578 cmdline_parse_token_string_t cmd_mirror_mask_set =
9579 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9581 cmdline_parse_token_string_t cmd_mirror_mask_port =
9582 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9584 cmdline_parse_token_num_t cmd_mirror_mask_portid =
9585 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9587 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
9588 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9589 mirror, "mirror-rule");
9590 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
9591 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9593 cmdline_parse_token_string_t cmd_mirror_mask_what =
9594 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9595 what, "pool-mirror-up#pool-mirror-down"
9597 cmdline_parse_token_string_t cmd_mirror_mask_value =
9598 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9600 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
9601 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9602 dstpool, "dst-pool");
9603 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
9604 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9606 cmdline_parse_token_string_t cmd_mirror_mask_on =
9607 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9611 cmd_set_mirror_mask_parsed(void *parsed_result,
9612 __rte_unused struct cmdline *cl,
9613 __rte_unused void *data)
9616 struct cmd_set_mirror_mask_result *res = parsed_result;
9617 struct rte_eth_mirror_conf mr_conf;
9619 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
9621 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
9623 mr_conf.dst_pool = res->dstpool_id;
9625 if (!strcmp(res->what, "pool-mirror-up")) {
9626 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
9627 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
9628 } else if (!strcmp(res->what, "pool-mirror-down")) {
9629 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
9630 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
9631 } else if (!strcmp(res->what, "vlan-mirror")) {
9632 mr_conf.rule_type = ETH_MIRROR_VLAN;
9633 nb_item = parse_item_list(res->value, "vlan",
9634 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
9638 for (i = 0; i < nb_item; i++) {
9639 if (vlan_list[i] > RTE_ETHER_MAX_VLAN_ID) {
9640 printf("Invalid vlan_id: must be < 4096\n");
9644 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
9645 mr_conf.vlan.vlan_mask |= 1ULL << i;
9649 if (!strcmp(res->on, "on"))
9650 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9653 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9656 printf("mirror rule add error: (%s)\n", strerror(-ret));
9659 cmdline_parse_inst_t cmd_set_mirror_mask = {
9660 .f = cmd_set_mirror_mask_parsed,
9662 .help_str = "set port <port_id> mirror-rule <rule_id> "
9663 "pool-mirror-up|pool-mirror-down|vlan-mirror "
9664 "<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off",
9666 (void *)&cmd_mirror_mask_set,
9667 (void *)&cmd_mirror_mask_port,
9668 (void *)&cmd_mirror_mask_portid,
9669 (void *)&cmd_mirror_mask_mirror,
9670 (void *)&cmd_mirror_mask_ruleid,
9671 (void *)&cmd_mirror_mask_what,
9672 (void *)&cmd_mirror_mask_value,
9673 (void *)&cmd_mirror_mask_dstpool,
9674 (void *)&cmd_mirror_mask_poolid,
9675 (void *)&cmd_mirror_mask_on,
9680 /* *** CONFIGURE VM MIRROR UPLINK/DOWNLINK RULE *** */
9681 struct cmd_set_mirror_link_result {
9682 cmdline_fixed_string_t set;
9683 cmdline_fixed_string_t port;
9685 cmdline_fixed_string_t mirror;
9687 cmdline_fixed_string_t what;
9688 cmdline_fixed_string_t dstpool;
9690 cmdline_fixed_string_t on;
9693 cmdline_parse_token_string_t cmd_mirror_link_set =
9694 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9696 cmdline_parse_token_string_t cmd_mirror_link_port =
9697 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9699 cmdline_parse_token_num_t cmd_mirror_link_portid =
9700 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9702 cmdline_parse_token_string_t cmd_mirror_link_mirror =
9703 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9704 mirror, "mirror-rule");
9705 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
9706 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9708 cmdline_parse_token_string_t cmd_mirror_link_what =
9709 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9710 what, "uplink-mirror#downlink-mirror");
9711 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
9712 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9713 dstpool, "dst-pool");
9714 cmdline_parse_token_num_t cmd_mirror_link_poolid =
9715 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9717 cmdline_parse_token_string_t cmd_mirror_link_on =
9718 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9722 cmd_set_mirror_link_parsed(void *parsed_result,
9723 __rte_unused struct cmdline *cl,
9724 __rte_unused void *data)
9727 struct cmd_set_mirror_link_result *res = parsed_result;
9728 struct rte_eth_mirror_conf mr_conf;
9730 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
9731 if (!strcmp(res->what, "uplink-mirror"))
9732 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
9734 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
9736 mr_conf.dst_pool = res->dstpool_id;
9738 if (!strcmp(res->on, "on"))
9739 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9742 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9745 /* check the return value and print it if is < 0 */
9747 printf("mirror rule add error: (%s)\n", strerror(-ret));
9751 cmdline_parse_inst_t cmd_set_mirror_link = {
9752 .f = cmd_set_mirror_link_parsed,
9754 .help_str = "set port <port_id> mirror-rule <rule_id> "
9755 "uplink-mirror|downlink-mirror dst-pool <pool_id> on|off",
9757 (void *)&cmd_mirror_link_set,
9758 (void *)&cmd_mirror_link_port,
9759 (void *)&cmd_mirror_link_portid,
9760 (void *)&cmd_mirror_link_mirror,
9761 (void *)&cmd_mirror_link_ruleid,
9762 (void *)&cmd_mirror_link_what,
9763 (void *)&cmd_mirror_link_dstpool,
9764 (void *)&cmd_mirror_link_poolid,
9765 (void *)&cmd_mirror_link_on,
9770 /* *** RESET VM MIRROR RULE *** */
9771 struct cmd_rm_mirror_rule_result {
9772 cmdline_fixed_string_t reset;
9773 cmdline_fixed_string_t port;
9775 cmdline_fixed_string_t mirror;
9779 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
9780 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9782 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
9783 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9785 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
9786 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9788 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
9789 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9790 mirror, "mirror-rule");
9791 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
9792 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9796 cmd_reset_mirror_rule_parsed(void *parsed_result,
9797 __rte_unused struct cmdline *cl,
9798 __rte_unused void *data)
9801 struct cmd_set_mirror_link_result *res = parsed_result;
9803 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
9805 printf("mirror rule remove error: (%s)\n", strerror(-ret));
9808 cmdline_parse_inst_t cmd_reset_mirror_rule = {
9809 .f = cmd_reset_mirror_rule_parsed,
9811 .help_str = "reset port <port_id> mirror-rule <rule_id>",
9813 (void *)&cmd_rm_mirror_rule_reset,
9814 (void *)&cmd_rm_mirror_rule_port,
9815 (void *)&cmd_rm_mirror_rule_portid,
9816 (void *)&cmd_rm_mirror_rule_mirror,
9817 (void *)&cmd_rm_mirror_rule_ruleid,
9822 /* ******************************************************************************** */
9824 struct cmd_dump_result {
9825 cmdline_fixed_string_t dump;
9829 dump_struct_sizes(void)
9831 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
9832 DUMP_SIZE(struct rte_mbuf);
9833 DUMP_SIZE(struct rte_mempool);
9834 DUMP_SIZE(struct rte_ring);
9839 /* Dump the socket memory statistics on console */
9841 dump_socket_mem(FILE *f)
9843 struct rte_malloc_socket_stats socket_stats;
9848 unsigned int n_alloc = 0;
9849 unsigned int n_free = 0;
9850 static size_t last_allocs;
9851 static size_t last_total;
9854 for (i = 0; i < RTE_MAX_NUMA_NODES; i++) {
9855 if (rte_malloc_get_socket_stats(i, &socket_stats) ||
9856 !socket_stats.heap_totalsz_bytes)
9858 total += socket_stats.heap_totalsz_bytes;
9859 alloc += socket_stats.heap_allocsz_bytes;
9860 free += socket_stats.heap_freesz_bytes;
9861 n_alloc += socket_stats.alloc_count;
9862 n_free += socket_stats.free_count;
9864 "Socket %u: size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n",
9866 (double)socket_stats.heap_totalsz_bytes / (1024 * 1024),
9867 (double)socket_stats.heap_allocsz_bytes / (1024 * 1024),
9868 (double)socket_stats.heap_allocsz_bytes * 100 /
9869 (double)socket_stats.heap_totalsz_bytes,
9870 (double)socket_stats.heap_freesz_bytes / (1024 * 1024),
9871 socket_stats.alloc_count,
9872 socket_stats.free_count);
9875 "Total : size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n",
9876 (double)total / (1024 * 1024), (double)alloc / (1024 * 1024),
9877 (double)alloc * 100 / (double)total,
9878 (double)free / (1024 * 1024),
9881 fprintf(stdout, "Memory total change: %.6lf(M), allocation change: %.6lf(M)\n",
9882 ((double)total - (double)last_total) / (1024 * 1024),
9883 (double)(alloc - (double)last_allocs) / 1024 / 1024);
9884 last_allocs = alloc;
9888 static void cmd_dump_parsed(void *parsed_result,
9889 __rte_unused struct cmdline *cl,
9890 __rte_unused void *data)
9892 struct cmd_dump_result *res = parsed_result;
9894 if (!strcmp(res->dump, "dump_physmem"))
9895 rte_dump_physmem_layout(stdout);
9896 else if (!strcmp(res->dump, "dump_socket_mem"))
9897 dump_socket_mem(stdout);
9898 else if (!strcmp(res->dump, "dump_memzone"))
9899 rte_memzone_dump(stdout);
9900 else if (!strcmp(res->dump, "dump_struct_sizes"))
9901 dump_struct_sizes();
9902 else if (!strcmp(res->dump, "dump_ring"))
9903 rte_ring_list_dump(stdout);
9904 else if (!strcmp(res->dump, "dump_mempool"))
9905 rte_mempool_list_dump(stdout);
9906 else if (!strcmp(res->dump, "dump_devargs"))
9907 rte_devargs_dump(stdout);
9908 else if (!strcmp(res->dump, "dump_log_types"))
9909 rte_log_dump(stdout);
9912 cmdline_parse_token_string_t cmd_dump_dump =
9913 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
9917 "dump_struct_sizes#"
9923 cmdline_parse_inst_t cmd_dump = {
9924 .f = cmd_dump_parsed, /* function to call */
9925 .data = NULL, /* 2nd arg of func */
9926 .help_str = "Dump status",
9927 .tokens = { /* token list, NULL terminated */
9928 (void *)&cmd_dump_dump,
9933 /* ******************************************************************************** */
9935 struct cmd_dump_one_result {
9936 cmdline_fixed_string_t dump;
9937 cmdline_fixed_string_t name;
9940 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
9941 __rte_unused void *data)
9943 struct cmd_dump_one_result *res = parsed_result;
9945 if (!strcmp(res->dump, "dump_ring")) {
9947 r = rte_ring_lookup(res->name);
9949 cmdline_printf(cl, "Cannot find ring\n");
9952 rte_ring_dump(stdout, r);
9953 } else if (!strcmp(res->dump, "dump_mempool")) {
9954 struct rte_mempool *mp;
9955 mp = rte_mempool_lookup(res->name);
9957 cmdline_printf(cl, "Cannot find mempool\n");
9960 rte_mempool_dump(stdout, mp);
9964 cmdline_parse_token_string_t cmd_dump_one_dump =
9965 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
9966 "dump_ring#dump_mempool");
9968 cmdline_parse_token_string_t cmd_dump_one_name =
9969 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
9971 cmdline_parse_inst_t cmd_dump_one = {
9972 .f = cmd_dump_one_parsed, /* function to call */
9973 .data = NULL, /* 2nd arg of func */
9974 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
9975 .tokens = { /* token list, NULL terminated */
9976 (void *)&cmd_dump_one_dump,
9977 (void *)&cmd_dump_one_name,
9982 /* *** queue region set *** */
9983 struct cmd_queue_region_result {
9984 cmdline_fixed_string_t set;
9985 cmdline_fixed_string_t port;
9987 cmdline_fixed_string_t cmd;
9988 cmdline_fixed_string_t region;
9990 cmdline_fixed_string_t queue_start_index;
9992 cmdline_fixed_string_t queue_num;
9993 uint8_t queue_num_value;
9997 cmd_queue_region_parsed(void *parsed_result,
9998 __rte_unused struct cmdline *cl,
9999 __rte_unused void *data)
10001 struct cmd_queue_region_result *res = parsed_result;
10002 int ret = -ENOTSUP;
10003 #ifdef RTE_NET_I40E
10004 struct rte_pmd_i40e_queue_region_conf region_conf;
10005 enum rte_pmd_i40e_queue_region_op op_type;
10008 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10011 #ifdef RTE_NET_I40E
10012 memset(®ion_conf, 0, sizeof(region_conf));
10013 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_SET;
10014 region_conf.region_id = res->region_id;
10015 region_conf.queue_num = res->queue_num_value;
10016 region_conf.queue_start_index = res->queue_id;
10018 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10019 op_type, ®ion_conf);
10026 printf("function not implemented or supported\n");
10029 printf("queue region config error: (%s)\n", strerror(-ret));
10033 cmdline_parse_token_string_t cmd_queue_region_set =
10034 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
10036 cmdline_parse_token_string_t cmd_queue_region_port =
10037 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, port, "port");
10038 cmdline_parse_token_num_t cmd_queue_region_port_id =
10039 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
10041 cmdline_parse_token_string_t cmd_queue_region_cmd =
10042 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
10043 cmd, "queue-region");
10044 cmdline_parse_token_string_t cmd_queue_region_id =
10045 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
10046 region, "region_id");
10047 cmdline_parse_token_num_t cmd_queue_region_index =
10048 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
10050 cmdline_parse_token_string_t cmd_queue_region_queue_start_index =
10051 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
10052 queue_start_index, "queue_start_index");
10053 cmdline_parse_token_num_t cmd_queue_region_queue_id =
10054 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
10056 cmdline_parse_token_string_t cmd_queue_region_queue_num =
10057 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
10058 queue_num, "queue_num");
10059 cmdline_parse_token_num_t cmd_queue_region_queue_num_value =
10060 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
10061 queue_num_value, UINT8);
10063 cmdline_parse_inst_t cmd_queue_region = {
10064 .f = cmd_queue_region_parsed,
10066 .help_str = "set port <port_id> queue-region region_id <value> "
10067 "queue_start_index <value> queue_num <value>: Set a queue region",
10069 (void *)&cmd_queue_region_set,
10070 (void *)&cmd_queue_region_port,
10071 (void *)&cmd_queue_region_port_id,
10072 (void *)&cmd_queue_region_cmd,
10073 (void *)&cmd_queue_region_id,
10074 (void *)&cmd_queue_region_index,
10075 (void *)&cmd_queue_region_queue_start_index,
10076 (void *)&cmd_queue_region_queue_id,
10077 (void *)&cmd_queue_region_queue_num,
10078 (void *)&cmd_queue_region_queue_num_value,
10083 /* *** queue region and flowtype set *** */
10084 struct cmd_region_flowtype_result {
10085 cmdline_fixed_string_t set;
10086 cmdline_fixed_string_t port;
10088 cmdline_fixed_string_t cmd;
10089 cmdline_fixed_string_t region;
10091 cmdline_fixed_string_t flowtype;
10092 uint8_t flowtype_id;
10096 cmd_region_flowtype_parsed(void *parsed_result,
10097 __rte_unused struct cmdline *cl,
10098 __rte_unused void *data)
10100 struct cmd_region_flowtype_result *res = parsed_result;
10101 int ret = -ENOTSUP;
10102 #ifdef RTE_NET_I40E
10103 struct rte_pmd_i40e_queue_region_conf region_conf;
10104 enum rte_pmd_i40e_queue_region_op op_type;
10107 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10110 #ifdef RTE_NET_I40E
10111 memset(®ion_conf, 0, sizeof(region_conf));
10113 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_FLOWTYPE_SET;
10114 region_conf.region_id = res->region_id;
10115 region_conf.hw_flowtype = res->flowtype_id;
10117 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10118 op_type, ®ion_conf);
10125 printf("function not implemented or supported\n");
10128 printf("region flowtype config error: (%s)\n", strerror(-ret));
10132 cmdline_parse_token_string_t cmd_region_flowtype_set =
10133 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10135 cmdline_parse_token_string_t cmd_region_flowtype_port =
10136 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10138 cmdline_parse_token_num_t cmd_region_flowtype_port_index =
10139 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
10141 cmdline_parse_token_string_t cmd_region_flowtype_cmd =
10142 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10143 cmd, "queue-region");
10144 cmdline_parse_token_string_t cmd_region_flowtype_index =
10145 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10146 region, "region_id");
10147 cmdline_parse_token_num_t cmd_region_flowtype_id =
10148 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
10150 cmdline_parse_token_string_t cmd_region_flowtype_flow_index =
10151 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10152 flowtype, "flowtype");
10153 cmdline_parse_token_num_t cmd_region_flowtype_flow_id =
10154 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
10155 flowtype_id, UINT8);
10156 cmdline_parse_inst_t cmd_region_flowtype = {
10157 .f = cmd_region_flowtype_parsed,
10159 .help_str = "set port <port_id> queue-region region_id <value> "
10160 "flowtype <value>: Set a flowtype region index",
10162 (void *)&cmd_region_flowtype_set,
10163 (void *)&cmd_region_flowtype_port,
10164 (void *)&cmd_region_flowtype_port_index,
10165 (void *)&cmd_region_flowtype_cmd,
10166 (void *)&cmd_region_flowtype_index,
10167 (void *)&cmd_region_flowtype_id,
10168 (void *)&cmd_region_flowtype_flow_index,
10169 (void *)&cmd_region_flowtype_flow_id,
10174 /* *** User Priority (UP) to queue region (region_id) set *** */
10175 struct cmd_user_priority_region_result {
10176 cmdline_fixed_string_t set;
10177 cmdline_fixed_string_t port;
10179 cmdline_fixed_string_t cmd;
10180 cmdline_fixed_string_t user_priority;
10181 uint8_t user_priority_id;
10182 cmdline_fixed_string_t region;
10187 cmd_user_priority_region_parsed(void *parsed_result,
10188 __rte_unused struct cmdline *cl,
10189 __rte_unused void *data)
10191 struct cmd_user_priority_region_result *res = parsed_result;
10192 int ret = -ENOTSUP;
10193 #ifdef RTE_NET_I40E
10194 struct rte_pmd_i40e_queue_region_conf region_conf;
10195 enum rte_pmd_i40e_queue_region_op op_type;
10198 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10201 #ifdef RTE_NET_I40E
10202 memset(®ion_conf, 0, sizeof(region_conf));
10203 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_USER_PRIORITY_SET;
10204 region_conf.user_priority = res->user_priority_id;
10205 region_conf.region_id = res->region_id;
10207 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10208 op_type, ®ion_conf);
10215 printf("function not implemented or supported\n");
10218 printf("user_priority region config error: (%s)\n",
10223 cmdline_parse_token_string_t cmd_user_priority_region_set =
10224 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10226 cmdline_parse_token_string_t cmd_user_priority_region_port =
10227 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10229 cmdline_parse_token_num_t cmd_user_priority_region_port_index =
10230 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10232 cmdline_parse_token_string_t cmd_user_priority_region_cmd =
10233 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10234 cmd, "queue-region");
10235 cmdline_parse_token_string_t cmd_user_priority_region_UP =
10236 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10237 user_priority, "UP");
10238 cmdline_parse_token_num_t cmd_user_priority_region_UP_id =
10239 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10240 user_priority_id, UINT8);
10241 cmdline_parse_token_string_t cmd_user_priority_region_region =
10242 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10243 region, "region_id");
10244 cmdline_parse_token_num_t cmd_user_priority_region_region_id =
10245 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10248 cmdline_parse_inst_t cmd_user_priority_region = {
10249 .f = cmd_user_priority_region_parsed,
10251 .help_str = "set port <port_id> queue-region UP <value> "
10252 "region_id <value>: Set the mapping of User Priority (UP) "
10253 "to queue region (region_id) ",
10255 (void *)&cmd_user_priority_region_set,
10256 (void *)&cmd_user_priority_region_port,
10257 (void *)&cmd_user_priority_region_port_index,
10258 (void *)&cmd_user_priority_region_cmd,
10259 (void *)&cmd_user_priority_region_UP,
10260 (void *)&cmd_user_priority_region_UP_id,
10261 (void *)&cmd_user_priority_region_region,
10262 (void *)&cmd_user_priority_region_region_id,
10267 /* *** flush all queue region related configuration *** */
10268 struct cmd_flush_queue_region_result {
10269 cmdline_fixed_string_t set;
10270 cmdline_fixed_string_t port;
10272 cmdline_fixed_string_t cmd;
10273 cmdline_fixed_string_t flush;
10274 cmdline_fixed_string_t what;
10278 cmd_flush_queue_region_parsed(void *parsed_result,
10279 __rte_unused struct cmdline *cl,
10280 __rte_unused void *data)
10282 struct cmd_flush_queue_region_result *res = parsed_result;
10283 int ret = -ENOTSUP;
10284 #ifdef RTE_NET_I40E
10285 struct rte_pmd_i40e_queue_region_conf region_conf;
10286 enum rte_pmd_i40e_queue_region_op op_type;
10289 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10292 #ifdef RTE_NET_I40E
10293 memset(®ion_conf, 0, sizeof(region_conf));
10295 if (strcmp(res->what, "on") == 0)
10296 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_ON;
10298 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_OFF;
10300 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10301 op_type, ®ion_conf);
10308 printf("function not implemented or supported\n");
10311 printf("queue region config flush error: (%s)\n",
10316 cmdline_parse_token_string_t cmd_flush_queue_region_set =
10317 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10319 cmdline_parse_token_string_t cmd_flush_queue_region_port =
10320 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10322 cmdline_parse_token_num_t cmd_flush_queue_region_port_index =
10323 TOKEN_NUM_INITIALIZER(struct cmd_flush_queue_region_result,
10325 cmdline_parse_token_string_t cmd_flush_queue_region_cmd =
10326 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10327 cmd, "queue-region");
10328 cmdline_parse_token_string_t cmd_flush_queue_region_flush =
10329 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10331 cmdline_parse_token_string_t cmd_flush_queue_region_what =
10332 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10335 cmdline_parse_inst_t cmd_flush_queue_region = {
10336 .f = cmd_flush_queue_region_parsed,
10338 .help_str = "set port <port_id> queue-region flush on|off"
10339 ": flush all queue region related configuration",
10341 (void *)&cmd_flush_queue_region_set,
10342 (void *)&cmd_flush_queue_region_port,
10343 (void *)&cmd_flush_queue_region_port_index,
10344 (void *)&cmd_flush_queue_region_cmd,
10345 (void *)&cmd_flush_queue_region_flush,
10346 (void *)&cmd_flush_queue_region_what,
10351 /* *** get all queue region related configuration info *** */
10352 struct cmd_show_queue_region_info {
10353 cmdline_fixed_string_t show;
10354 cmdline_fixed_string_t port;
10356 cmdline_fixed_string_t cmd;
10360 cmd_show_queue_region_info_parsed(void *parsed_result,
10361 __rte_unused struct cmdline *cl,
10362 __rte_unused void *data)
10364 struct cmd_show_queue_region_info *res = parsed_result;
10365 int ret = -ENOTSUP;
10366 #ifdef RTE_NET_I40E
10367 struct rte_pmd_i40e_queue_regions rte_pmd_regions;
10368 enum rte_pmd_i40e_queue_region_op op_type;
10371 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10374 #ifdef RTE_NET_I40E
10375 memset(&rte_pmd_regions, 0, sizeof(rte_pmd_regions));
10377 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_INFO_GET;
10379 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10380 op_type, &rte_pmd_regions);
10382 port_queue_region_info_display(res->port_id, &rte_pmd_regions);
10389 printf("function not implemented or supported\n");
10392 printf("queue region config info show error: (%s)\n",
10397 cmdline_parse_token_string_t cmd_show_queue_region_info_get =
10398 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10400 cmdline_parse_token_string_t cmd_show_queue_region_info_port =
10401 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10403 cmdline_parse_token_num_t cmd_show_queue_region_info_port_index =
10404 TOKEN_NUM_INITIALIZER(struct cmd_show_queue_region_info,
10406 cmdline_parse_token_string_t cmd_show_queue_region_info_cmd =
10407 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10408 cmd, "queue-region");
10410 cmdline_parse_inst_t cmd_show_queue_region_info_all = {
10411 .f = cmd_show_queue_region_info_parsed,
10413 .help_str = "show port <port_id> queue-region"
10414 ": show all queue region related configuration info",
10416 (void *)&cmd_show_queue_region_info_get,
10417 (void *)&cmd_show_queue_region_info_port,
10418 (void *)&cmd_show_queue_region_info_port_index,
10419 (void *)&cmd_show_queue_region_info_cmd,
10424 /* *** ADD/REMOVE A 2tuple FILTER *** */
10425 struct cmd_2tuple_filter_result {
10426 cmdline_fixed_string_t filter;
10428 cmdline_fixed_string_t ops;
10429 cmdline_fixed_string_t dst_port;
10430 uint16_t dst_port_value;
10431 cmdline_fixed_string_t protocol;
10432 uint8_t protocol_value;
10433 cmdline_fixed_string_t mask;
10434 uint8_t mask_value;
10435 cmdline_fixed_string_t tcp_flags;
10436 uint8_t tcp_flags_value;
10437 cmdline_fixed_string_t priority;
10438 uint8_t priority_value;
10439 cmdline_fixed_string_t queue;
10444 cmd_2tuple_filter_parsed(void *parsed_result,
10445 __rte_unused struct cmdline *cl,
10446 __rte_unused void *data)
10448 struct rte_eth_ntuple_filter filter;
10449 struct cmd_2tuple_filter_result *res = parsed_result;
10452 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
10454 printf("ntuple filter is not supported on port %u.\n",
10459 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
10461 filter.flags = RTE_2TUPLE_FLAGS;
10462 filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
10463 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
10464 filter.proto = res->protocol_value;
10465 filter.priority = res->priority_value;
10466 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
10467 printf("nonzero tcp_flags is only meaningful"
10468 " when protocol is TCP.\n");
10471 if (res->tcp_flags_value > RTE_NTUPLE_TCP_FLAGS_MASK) {
10472 printf("invalid TCP flags.\n");
10476 if (res->tcp_flags_value != 0) {
10477 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
10478 filter.tcp_flags = res->tcp_flags_value;
10481 /* need convert to big endian. */
10482 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
10483 filter.queue = res->queue_id;
10485 if (!strcmp(res->ops, "add"))
10486 ret = rte_eth_dev_filter_ctrl(res->port_id,
10487 RTE_ETH_FILTER_NTUPLE,
10488 RTE_ETH_FILTER_ADD,
10491 ret = rte_eth_dev_filter_ctrl(res->port_id,
10492 RTE_ETH_FILTER_NTUPLE,
10493 RTE_ETH_FILTER_DELETE,
10496 printf("2tuple filter programming error: (%s)\n",
10501 cmdline_parse_token_string_t cmd_2tuple_filter_filter =
10502 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10503 filter, "2tuple_filter");
10504 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
10505 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10507 cmdline_parse_token_string_t cmd_2tuple_filter_ops =
10508 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10510 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
10511 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10512 dst_port, "dst_port");
10513 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
10514 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10515 dst_port_value, UINT16);
10516 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
10517 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10518 protocol, "protocol");
10519 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
10520 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10521 protocol_value, UINT8);
10522 cmdline_parse_token_string_t cmd_2tuple_filter_mask =
10523 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10525 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value =
10526 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10528 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags =
10529 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10530 tcp_flags, "tcp_flags");
10531 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value =
10532 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10533 tcp_flags_value, UINT8);
10534 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
10535 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10536 priority, "priority");
10537 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
10538 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10539 priority_value, UINT8);
10540 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
10541 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10543 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
10544 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10547 cmdline_parse_inst_t cmd_2tuple_filter = {
10548 .f = cmd_2tuple_filter_parsed,
10550 .help_str = "2tuple_filter <port_id> add|del dst_port <value> protocol "
10551 "<value> mask <value> tcp_flags <value> priority <value> queue "
10552 "<queue_id>: Add a 2tuple filter",
10554 (void *)&cmd_2tuple_filter_filter,
10555 (void *)&cmd_2tuple_filter_port_id,
10556 (void *)&cmd_2tuple_filter_ops,
10557 (void *)&cmd_2tuple_filter_dst_port,
10558 (void *)&cmd_2tuple_filter_dst_port_value,
10559 (void *)&cmd_2tuple_filter_protocol,
10560 (void *)&cmd_2tuple_filter_protocol_value,
10561 (void *)&cmd_2tuple_filter_mask,
10562 (void *)&cmd_2tuple_filter_mask_value,
10563 (void *)&cmd_2tuple_filter_tcp_flags,
10564 (void *)&cmd_2tuple_filter_tcp_flags_value,
10565 (void *)&cmd_2tuple_filter_priority,
10566 (void *)&cmd_2tuple_filter_priority_value,
10567 (void *)&cmd_2tuple_filter_queue,
10568 (void *)&cmd_2tuple_filter_queue_id,
10573 /* *** ADD/REMOVE A 5tuple FILTER *** */
10574 struct cmd_5tuple_filter_result {
10575 cmdline_fixed_string_t filter;
10577 cmdline_fixed_string_t ops;
10578 cmdline_fixed_string_t dst_ip;
10579 cmdline_ipaddr_t dst_ip_value;
10580 cmdline_fixed_string_t src_ip;
10581 cmdline_ipaddr_t src_ip_value;
10582 cmdline_fixed_string_t dst_port;
10583 uint16_t dst_port_value;
10584 cmdline_fixed_string_t src_port;
10585 uint16_t src_port_value;
10586 cmdline_fixed_string_t protocol;
10587 uint8_t protocol_value;
10588 cmdline_fixed_string_t mask;
10589 uint8_t mask_value;
10590 cmdline_fixed_string_t tcp_flags;
10591 uint8_t tcp_flags_value;
10592 cmdline_fixed_string_t priority;
10593 uint8_t priority_value;
10594 cmdline_fixed_string_t queue;
10599 cmd_5tuple_filter_parsed(void *parsed_result,
10600 __rte_unused struct cmdline *cl,
10601 __rte_unused void *data)
10603 struct rte_eth_ntuple_filter filter;
10604 struct cmd_5tuple_filter_result *res = parsed_result;
10607 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
10609 printf("ntuple filter is not supported on port %u.\n",
10614 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
10616 filter.flags = RTE_5TUPLE_FLAGS;
10617 filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0;
10618 filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0;
10619 filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0;
10620 filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
10621 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
10622 filter.proto = res->protocol_value;
10623 filter.priority = res->priority_value;
10624 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
10625 printf("nonzero tcp_flags is only meaningful"
10626 " when protocol is TCP.\n");
10629 if (res->tcp_flags_value > RTE_NTUPLE_TCP_FLAGS_MASK) {
10630 printf("invalid TCP flags.\n");
10634 if (res->tcp_flags_value != 0) {
10635 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
10636 filter.tcp_flags = res->tcp_flags_value;
10639 if (res->dst_ip_value.family == AF_INET)
10640 /* no need to convert, already big endian. */
10641 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
10643 if (filter.dst_ip_mask == 0) {
10644 printf("can not support ipv6 involved compare.\n");
10650 if (res->src_ip_value.family == AF_INET)
10651 /* no need to convert, already big endian. */
10652 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
10654 if (filter.src_ip_mask == 0) {
10655 printf("can not support ipv6 involved compare.\n");
10660 /* need convert to big endian. */
10661 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
10662 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
10663 filter.queue = res->queue_id;
10665 if (!strcmp(res->ops, "add"))
10666 ret = rte_eth_dev_filter_ctrl(res->port_id,
10667 RTE_ETH_FILTER_NTUPLE,
10668 RTE_ETH_FILTER_ADD,
10671 ret = rte_eth_dev_filter_ctrl(res->port_id,
10672 RTE_ETH_FILTER_NTUPLE,
10673 RTE_ETH_FILTER_DELETE,
10676 printf("5tuple filter programming error: (%s)\n",
10680 cmdline_parse_token_string_t cmd_5tuple_filter_filter =
10681 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10682 filter, "5tuple_filter");
10683 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
10684 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10686 cmdline_parse_token_string_t cmd_5tuple_filter_ops =
10687 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10689 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
10690 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10692 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
10693 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
10695 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
10696 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10698 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
10699 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
10701 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
10702 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10703 dst_port, "dst_port");
10704 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
10705 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10706 dst_port_value, UINT16);
10707 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
10708 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10709 src_port, "src_port");
10710 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
10711 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10712 src_port_value, UINT16);
10713 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
10714 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10715 protocol, "protocol");
10716 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
10717 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10718 protocol_value, UINT8);
10719 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
10720 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10722 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
10723 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10725 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags =
10726 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10727 tcp_flags, "tcp_flags");
10728 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value =
10729 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10730 tcp_flags_value, UINT8);
10731 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
10732 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10733 priority, "priority");
10734 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
10735 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10736 priority_value, UINT8);
10737 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
10738 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10740 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
10741 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10744 cmdline_parse_inst_t cmd_5tuple_filter = {
10745 .f = cmd_5tuple_filter_parsed,
10747 .help_str = "5tuple_filter <port_id> add|del dst_ip <value> "
10748 "src_ip <value> dst_port <value> src_port <value> "
10749 "protocol <value> mask <value> tcp_flags <value> "
10750 "priority <value> queue <queue_id>: Add/Del a 5tuple filter",
10752 (void *)&cmd_5tuple_filter_filter,
10753 (void *)&cmd_5tuple_filter_port_id,
10754 (void *)&cmd_5tuple_filter_ops,
10755 (void *)&cmd_5tuple_filter_dst_ip,
10756 (void *)&cmd_5tuple_filter_dst_ip_value,
10757 (void *)&cmd_5tuple_filter_src_ip,
10758 (void *)&cmd_5tuple_filter_src_ip_value,
10759 (void *)&cmd_5tuple_filter_dst_port,
10760 (void *)&cmd_5tuple_filter_dst_port_value,
10761 (void *)&cmd_5tuple_filter_src_port,
10762 (void *)&cmd_5tuple_filter_src_port_value,
10763 (void *)&cmd_5tuple_filter_protocol,
10764 (void *)&cmd_5tuple_filter_protocol_value,
10765 (void *)&cmd_5tuple_filter_mask,
10766 (void *)&cmd_5tuple_filter_mask_value,
10767 (void *)&cmd_5tuple_filter_tcp_flags,
10768 (void *)&cmd_5tuple_filter_tcp_flags_value,
10769 (void *)&cmd_5tuple_filter_priority,
10770 (void *)&cmd_5tuple_filter_priority_value,
10771 (void *)&cmd_5tuple_filter_queue,
10772 (void *)&cmd_5tuple_filter_queue_id,
10777 /* *** Filters Control *** */
10779 /* *** deal with flow director filter *** */
10780 struct cmd_flow_director_result {
10781 cmdline_fixed_string_t flow_director_filter;
10783 cmdline_fixed_string_t mode;
10784 cmdline_fixed_string_t mode_value;
10785 cmdline_fixed_string_t ops;
10786 cmdline_fixed_string_t flow;
10787 cmdline_fixed_string_t flow_type;
10788 cmdline_fixed_string_t ether;
10789 uint16_t ether_type;
10790 cmdline_fixed_string_t src;
10791 cmdline_ipaddr_t ip_src;
10793 cmdline_fixed_string_t dst;
10794 cmdline_ipaddr_t ip_dst;
10796 cmdline_fixed_string_t verify_tag;
10797 uint32_t verify_tag_value;
10798 cmdline_fixed_string_t tos;
10800 cmdline_fixed_string_t proto;
10801 uint8_t proto_value;
10802 cmdline_fixed_string_t ttl;
10804 cmdline_fixed_string_t vlan;
10805 uint16_t vlan_value;
10806 cmdline_fixed_string_t flexbytes;
10807 cmdline_fixed_string_t flexbytes_value;
10808 cmdline_fixed_string_t pf_vf;
10809 cmdline_fixed_string_t drop;
10810 cmdline_fixed_string_t queue;
10812 cmdline_fixed_string_t fd_id;
10813 uint32_t fd_id_value;
10814 cmdline_fixed_string_t mac;
10815 struct rte_ether_addr mac_addr;
10816 cmdline_fixed_string_t tunnel;
10817 cmdline_fixed_string_t tunnel_type;
10818 cmdline_fixed_string_t tunnel_id;
10819 uint32_t tunnel_id_value;
10820 cmdline_fixed_string_t packet;
10825 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
10828 const char *p, *p0 = q_arg;
10830 unsigned long int_fld;
10831 char *str_fld[max_num];
10836 p = strchr(p0, '(');
10840 p0 = strchr(p, ')');
10845 if (size >= sizeof(s))
10848 snprintf(s, sizeof(s), "%.*s", size, p);
10849 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
10850 if (ret < 0 || ret > max_num)
10852 for (i = 0; i < ret; i++) {
10854 int_fld = strtoul(str_fld[i], &end, 0);
10855 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
10857 flexbytes[i] = (uint8_t)int_fld;
10863 str2flowtype(char *string)
10866 static const struct {
10869 } flowtype_str[] = {
10870 {"raw", RTE_ETH_FLOW_RAW},
10871 {"ipv4", RTE_ETH_FLOW_IPV4},
10872 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
10873 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
10874 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
10875 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
10876 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
10877 {"ipv6", RTE_ETH_FLOW_IPV6},
10878 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
10879 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
10880 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
10881 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
10882 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
10883 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
10886 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
10887 if (!strcmp(flowtype_str[i].str, string))
10888 return flowtype_str[i].type;
10891 if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64)
10892 return (uint16_t)atoi(string);
10894 return RTE_ETH_FLOW_UNKNOWN;
10897 static enum rte_eth_fdir_tunnel_type
10898 str2fdir_tunneltype(char *string)
10902 static const struct {
10904 enum rte_eth_fdir_tunnel_type type;
10905 } tunneltype_str[] = {
10906 {"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE},
10907 {"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN},
10910 for (i = 0; i < RTE_DIM(tunneltype_str); i++) {
10911 if (!strcmp(tunneltype_str[i].str, string))
10912 return tunneltype_str[i].type;
10914 return RTE_FDIR_TUNNEL_TYPE_UNKNOWN;
10917 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
10919 if ((ip_addr).family == AF_INET) \
10920 (ip) = (ip_addr).addr.ipv4.s_addr; \
10922 printf("invalid parameter.\n"); \
10927 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
10929 if ((ip_addr).family == AF_INET6) \
10930 rte_memcpy(&(ip), \
10931 &((ip_addr).addr.ipv6), \
10932 sizeof(struct in6_addr)); \
10934 printf("invalid parameter.\n"); \
10940 cmd_flow_director_filter_parsed(void *parsed_result,
10941 __rte_unused struct cmdline *cl,
10942 __rte_unused void *data)
10944 struct cmd_flow_director_result *res = parsed_result;
10945 struct rte_eth_fdir_filter entry;
10946 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
10948 unsigned long vf_id;
10951 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
10953 printf("flow director is not supported on port %u.\n",
10957 memset(flexbytes, 0, sizeof(flexbytes));
10958 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
10960 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
10961 if (strcmp(res->mode_value, "MAC-VLAN")) {
10962 printf("Please set mode to MAC-VLAN.\n");
10965 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
10966 if (strcmp(res->mode_value, "Tunnel")) {
10967 printf("Please set mode to Tunnel.\n");
10971 if (!strcmp(res->mode_value, "raw")) {
10972 #ifdef RTE_NET_I40E
10973 struct rte_pmd_i40e_flow_type_mapping
10974 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
10975 struct rte_pmd_i40e_pkt_template_conf conf;
10976 uint16_t flow_type = str2flowtype(res->flow_type);
10977 uint16_t i, port = res->port_id;
10980 memset(&conf, 0, sizeof(conf));
10982 if (flow_type == RTE_ETH_FLOW_UNKNOWN) {
10983 printf("Invalid flow type specified.\n");
10986 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id,
10990 if (mapping[flow_type].pctype == 0ULL) {
10991 printf("Invalid flow type specified.\n");
10994 for (i = 0; i < RTE_PMD_I40E_PCTYPE_MAX; i++) {
10995 if (mapping[flow_type].pctype & (1ULL << i)) {
10996 conf.input.pctype = i;
11001 conf.input.packet = open_file(res->filepath,
11002 &conf.input.length);
11003 if (!conf.input.packet)
11005 if (!strcmp(res->drop, "drop"))
11006 conf.action.behavior =
11007 RTE_PMD_I40E_PKT_TEMPLATE_REJECT;
11009 conf.action.behavior =
11010 RTE_PMD_I40E_PKT_TEMPLATE_ACCEPT;
11011 conf.action.report_status =
11012 RTE_PMD_I40E_PKT_TEMPLATE_REPORT_ID;
11013 conf.action.rx_queue = res->queue_id;
11014 conf.soft_id = res->fd_id_value;
11015 add = strcmp(res->ops, "del") ? 1 : 0;
11016 ret = rte_pmd_i40e_flow_add_del_packet_template(port,
11020 printf("flow director config error: (%s)\n",
11022 close_file(conf.input.packet);
11025 } else if (strcmp(res->mode_value, "IP")) {
11026 printf("Please set mode to IP or raw.\n");
11029 entry.input.flow_type = str2flowtype(res->flow_type);
11032 ret = parse_flexbytes(res->flexbytes_value,
11034 RTE_ETH_FDIR_MAX_FLEXLEN);
11036 printf("error: Cannot parse flexbytes input.\n");
11040 switch (entry.input.flow_type) {
11041 case RTE_ETH_FLOW_FRAG_IPV4:
11042 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
11043 entry.input.flow.ip4_flow.proto = res->proto_value;
11045 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
11046 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
11047 IPV4_ADDR_TO_UINT(res->ip_dst,
11048 entry.input.flow.ip4_flow.dst_ip);
11049 IPV4_ADDR_TO_UINT(res->ip_src,
11050 entry.input.flow.ip4_flow.src_ip);
11051 entry.input.flow.ip4_flow.tos = res->tos_value;
11052 entry.input.flow.ip4_flow.ttl = res->ttl_value;
11053 /* need convert to big endian. */
11054 entry.input.flow.udp4_flow.dst_port =
11055 rte_cpu_to_be_16(res->port_dst);
11056 entry.input.flow.udp4_flow.src_port =
11057 rte_cpu_to_be_16(res->port_src);
11059 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
11060 IPV4_ADDR_TO_UINT(res->ip_dst,
11061 entry.input.flow.sctp4_flow.ip.dst_ip);
11062 IPV4_ADDR_TO_UINT(res->ip_src,
11063 entry.input.flow.sctp4_flow.ip.src_ip);
11064 entry.input.flow.ip4_flow.tos = res->tos_value;
11065 entry.input.flow.ip4_flow.ttl = res->ttl_value;
11066 /* need convert to big endian. */
11067 entry.input.flow.sctp4_flow.dst_port =
11068 rte_cpu_to_be_16(res->port_dst);
11069 entry.input.flow.sctp4_flow.src_port =
11070 rte_cpu_to_be_16(res->port_src);
11071 entry.input.flow.sctp4_flow.verify_tag =
11072 rte_cpu_to_be_32(res->verify_tag_value);
11074 case RTE_ETH_FLOW_FRAG_IPV6:
11075 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
11076 entry.input.flow.ipv6_flow.proto = res->proto_value;
11078 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
11079 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
11080 IPV6_ADDR_TO_ARRAY(res->ip_dst,
11081 entry.input.flow.ipv6_flow.dst_ip);
11082 IPV6_ADDR_TO_ARRAY(res->ip_src,
11083 entry.input.flow.ipv6_flow.src_ip);
11084 entry.input.flow.ipv6_flow.tc = res->tos_value;
11085 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
11086 /* need convert to big endian. */
11087 entry.input.flow.udp6_flow.dst_port =
11088 rte_cpu_to_be_16(res->port_dst);
11089 entry.input.flow.udp6_flow.src_port =
11090 rte_cpu_to_be_16(res->port_src);
11092 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
11093 IPV6_ADDR_TO_ARRAY(res->ip_dst,
11094 entry.input.flow.sctp6_flow.ip.dst_ip);
11095 IPV6_ADDR_TO_ARRAY(res->ip_src,
11096 entry.input.flow.sctp6_flow.ip.src_ip);
11097 entry.input.flow.ipv6_flow.tc = res->tos_value;
11098 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
11099 /* need convert to big endian. */
11100 entry.input.flow.sctp6_flow.dst_port =
11101 rte_cpu_to_be_16(res->port_dst);
11102 entry.input.flow.sctp6_flow.src_port =
11103 rte_cpu_to_be_16(res->port_src);
11104 entry.input.flow.sctp6_flow.verify_tag =
11105 rte_cpu_to_be_32(res->verify_tag_value);
11107 case RTE_ETH_FLOW_L2_PAYLOAD:
11108 entry.input.flow.l2_flow.ether_type =
11109 rte_cpu_to_be_16(res->ether_type);
11115 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN)
11116 rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr,
11118 sizeof(struct rte_ether_addr));
11120 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
11121 rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr,
11123 sizeof(struct rte_ether_addr));
11124 entry.input.flow.tunnel_flow.tunnel_type =
11125 str2fdir_tunneltype(res->tunnel_type);
11126 entry.input.flow.tunnel_flow.tunnel_id =
11127 rte_cpu_to_be_32(res->tunnel_id_value);
11130 rte_memcpy(entry.input.flow_ext.flexbytes,
11132 RTE_ETH_FDIR_MAX_FLEXLEN);
11134 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
11136 entry.action.flex_off = 0; /*use 0 by default */
11137 if (!strcmp(res->drop, "drop"))
11138 entry.action.behavior = RTE_ETH_FDIR_REJECT;
11140 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
11142 if (fdir_conf.mode != RTE_FDIR_MODE_PERFECT_MAC_VLAN &&
11143 fdir_conf.mode != RTE_FDIR_MODE_PERFECT_TUNNEL) {
11144 if (!strcmp(res->pf_vf, "pf"))
11145 entry.input.flow_ext.is_vf = 0;
11146 else if (!strncmp(res->pf_vf, "vf", 2)) {
11147 struct rte_eth_dev_info dev_info;
11149 ret = eth_dev_info_get_print_err(res->port_id,
11155 vf_id = strtoul(res->pf_vf + 2, &end, 10);
11156 if (errno != 0 || *end != '\0' ||
11157 vf_id >= dev_info.max_vfs) {
11158 printf("invalid parameter %s.\n", res->pf_vf);
11161 entry.input.flow_ext.is_vf = 1;
11162 entry.input.flow_ext.dst_id = (uint16_t)vf_id;
11164 printf("invalid parameter %s.\n", res->pf_vf);
11169 /* set to report FD ID by default */
11170 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
11171 entry.action.rx_queue = res->queue_id;
11172 entry.soft_id = res->fd_id_value;
11173 if (!strcmp(res->ops, "add"))
11174 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11175 RTE_ETH_FILTER_ADD, &entry);
11176 else if (!strcmp(res->ops, "del"))
11177 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11178 RTE_ETH_FILTER_DELETE, &entry);
11180 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11181 RTE_ETH_FILTER_UPDATE, &entry);
11183 printf("flow director programming error: (%s)\n",
11187 cmdline_parse_token_string_t cmd_flow_director_filter =
11188 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11189 flow_director_filter, "flow_director_filter");
11190 cmdline_parse_token_num_t cmd_flow_director_port_id =
11191 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11193 cmdline_parse_token_string_t cmd_flow_director_ops =
11194 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11195 ops, "add#del#update");
11196 cmdline_parse_token_string_t cmd_flow_director_flow =
11197 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11199 cmdline_parse_token_string_t cmd_flow_director_flow_type =
11200 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11202 cmdline_parse_token_string_t cmd_flow_director_ether =
11203 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11205 cmdline_parse_token_num_t cmd_flow_director_ether_type =
11206 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11207 ether_type, UINT16);
11208 cmdline_parse_token_string_t cmd_flow_director_src =
11209 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11211 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
11212 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
11214 cmdline_parse_token_num_t cmd_flow_director_port_src =
11215 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11217 cmdline_parse_token_string_t cmd_flow_director_dst =
11218 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11220 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
11221 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
11223 cmdline_parse_token_num_t cmd_flow_director_port_dst =
11224 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11226 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
11227 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11228 verify_tag, "verify_tag");
11229 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
11230 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11231 verify_tag_value, UINT32);
11232 cmdline_parse_token_string_t cmd_flow_director_tos =
11233 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11235 cmdline_parse_token_num_t cmd_flow_director_tos_value =
11236 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11238 cmdline_parse_token_string_t cmd_flow_director_proto =
11239 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11241 cmdline_parse_token_num_t cmd_flow_director_proto_value =
11242 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11243 proto_value, UINT8);
11244 cmdline_parse_token_string_t cmd_flow_director_ttl =
11245 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11247 cmdline_parse_token_num_t cmd_flow_director_ttl_value =
11248 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11250 cmdline_parse_token_string_t cmd_flow_director_vlan =
11251 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11253 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
11254 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11255 vlan_value, UINT16);
11256 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
11257 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11258 flexbytes, "flexbytes");
11259 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
11260 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11261 flexbytes_value, NULL);
11262 cmdline_parse_token_string_t cmd_flow_director_drop =
11263 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11265 cmdline_parse_token_string_t cmd_flow_director_pf_vf =
11266 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11268 cmdline_parse_token_string_t cmd_flow_director_queue =
11269 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11271 cmdline_parse_token_num_t cmd_flow_director_queue_id =
11272 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11274 cmdline_parse_token_string_t cmd_flow_director_fd_id =
11275 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11277 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
11278 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11279 fd_id_value, UINT32);
11281 cmdline_parse_token_string_t cmd_flow_director_mode =
11282 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11284 cmdline_parse_token_string_t cmd_flow_director_mode_ip =
11285 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11287 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan =
11288 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11289 mode_value, "MAC-VLAN");
11290 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel =
11291 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11292 mode_value, "Tunnel");
11293 cmdline_parse_token_string_t cmd_flow_director_mode_raw =
11294 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11295 mode_value, "raw");
11296 cmdline_parse_token_string_t cmd_flow_director_mac =
11297 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11299 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr =
11300 TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result,
11302 cmdline_parse_token_string_t cmd_flow_director_tunnel =
11303 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11305 cmdline_parse_token_string_t cmd_flow_director_tunnel_type =
11306 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11307 tunnel_type, "NVGRE#VxLAN");
11308 cmdline_parse_token_string_t cmd_flow_director_tunnel_id =
11309 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11310 tunnel_id, "tunnel-id");
11311 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value =
11312 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11313 tunnel_id_value, UINT32);
11314 cmdline_parse_token_string_t cmd_flow_director_packet =
11315 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11317 cmdline_parse_token_string_t cmd_flow_director_filepath =
11318 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11321 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
11322 .f = cmd_flow_director_filter_parsed,
11324 .help_str = "flow_director_filter <port_id> mode IP add|del|update flow"
11325 " ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
11326 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
11327 "l2_payload src <src_ip> dst <dst_ip> tos <tos_value> "
11328 "proto <proto_value> ttl <ttl_value> vlan <vlan_value> "
11329 "flexbytes <flexbyte_values> drop|fw <pf_vf> queue <queue_id> "
11330 "fd_id <fd_id_value>: "
11331 "Add or delete an ip flow director entry on NIC",
11333 (void *)&cmd_flow_director_filter,
11334 (void *)&cmd_flow_director_port_id,
11335 (void *)&cmd_flow_director_mode,
11336 (void *)&cmd_flow_director_mode_ip,
11337 (void *)&cmd_flow_director_ops,
11338 (void *)&cmd_flow_director_flow,
11339 (void *)&cmd_flow_director_flow_type,
11340 (void *)&cmd_flow_director_src,
11341 (void *)&cmd_flow_director_ip_src,
11342 (void *)&cmd_flow_director_dst,
11343 (void *)&cmd_flow_director_ip_dst,
11344 (void *)&cmd_flow_director_tos,
11345 (void *)&cmd_flow_director_tos_value,
11346 (void *)&cmd_flow_director_proto,
11347 (void *)&cmd_flow_director_proto_value,
11348 (void *)&cmd_flow_director_ttl,
11349 (void *)&cmd_flow_director_ttl_value,
11350 (void *)&cmd_flow_director_vlan,
11351 (void *)&cmd_flow_director_vlan_value,
11352 (void *)&cmd_flow_director_flexbytes,
11353 (void *)&cmd_flow_director_flexbytes_value,
11354 (void *)&cmd_flow_director_drop,
11355 (void *)&cmd_flow_director_pf_vf,
11356 (void *)&cmd_flow_director_queue,
11357 (void *)&cmd_flow_director_queue_id,
11358 (void *)&cmd_flow_director_fd_id,
11359 (void *)&cmd_flow_director_fd_id_value,
11364 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
11365 .f = cmd_flow_director_filter_parsed,
11367 .help_str = "flow_director_filter ... : Add or delete an udp/tcp flow "
11368 "director entry on NIC",
11370 (void *)&cmd_flow_director_filter,
11371 (void *)&cmd_flow_director_port_id,
11372 (void *)&cmd_flow_director_mode,
11373 (void *)&cmd_flow_director_mode_ip,
11374 (void *)&cmd_flow_director_ops,
11375 (void *)&cmd_flow_director_flow,
11376 (void *)&cmd_flow_director_flow_type,
11377 (void *)&cmd_flow_director_src,
11378 (void *)&cmd_flow_director_ip_src,
11379 (void *)&cmd_flow_director_port_src,
11380 (void *)&cmd_flow_director_dst,
11381 (void *)&cmd_flow_director_ip_dst,
11382 (void *)&cmd_flow_director_port_dst,
11383 (void *)&cmd_flow_director_tos,
11384 (void *)&cmd_flow_director_tos_value,
11385 (void *)&cmd_flow_director_ttl,
11386 (void *)&cmd_flow_director_ttl_value,
11387 (void *)&cmd_flow_director_vlan,
11388 (void *)&cmd_flow_director_vlan_value,
11389 (void *)&cmd_flow_director_flexbytes,
11390 (void *)&cmd_flow_director_flexbytes_value,
11391 (void *)&cmd_flow_director_drop,
11392 (void *)&cmd_flow_director_pf_vf,
11393 (void *)&cmd_flow_director_queue,
11394 (void *)&cmd_flow_director_queue_id,
11395 (void *)&cmd_flow_director_fd_id,
11396 (void *)&cmd_flow_director_fd_id_value,
11401 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
11402 .f = cmd_flow_director_filter_parsed,
11404 .help_str = "flow_director_filter ... : Add or delete a sctp flow "
11405 "director entry on NIC",
11407 (void *)&cmd_flow_director_filter,
11408 (void *)&cmd_flow_director_port_id,
11409 (void *)&cmd_flow_director_mode,
11410 (void *)&cmd_flow_director_mode_ip,
11411 (void *)&cmd_flow_director_ops,
11412 (void *)&cmd_flow_director_flow,
11413 (void *)&cmd_flow_director_flow_type,
11414 (void *)&cmd_flow_director_src,
11415 (void *)&cmd_flow_director_ip_src,
11416 (void *)&cmd_flow_director_port_src,
11417 (void *)&cmd_flow_director_dst,
11418 (void *)&cmd_flow_director_ip_dst,
11419 (void *)&cmd_flow_director_port_dst,
11420 (void *)&cmd_flow_director_verify_tag,
11421 (void *)&cmd_flow_director_verify_tag_value,
11422 (void *)&cmd_flow_director_tos,
11423 (void *)&cmd_flow_director_tos_value,
11424 (void *)&cmd_flow_director_ttl,
11425 (void *)&cmd_flow_director_ttl_value,
11426 (void *)&cmd_flow_director_vlan,
11427 (void *)&cmd_flow_director_vlan_value,
11428 (void *)&cmd_flow_director_flexbytes,
11429 (void *)&cmd_flow_director_flexbytes_value,
11430 (void *)&cmd_flow_director_drop,
11431 (void *)&cmd_flow_director_pf_vf,
11432 (void *)&cmd_flow_director_queue,
11433 (void *)&cmd_flow_director_queue_id,
11434 (void *)&cmd_flow_director_fd_id,
11435 (void *)&cmd_flow_director_fd_id_value,
11440 cmdline_parse_inst_t cmd_add_del_l2_flow_director = {
11441 .f = cmd_flow_director_filter_parsed,
11443 .help_str = "flow_director_filter ... : Add or delete a L2 flow "
11444 "director entry on NIC",
11446 (void *)&cmd_flow_director_filter,
11447 (void *)&cmd_flow_director_port_id,
11448 (void *)&cmd_flow_director_mode,
11449 (void *)&cmd_flow_director_mode_ip,
11450 (void *)&cmd_flow_director_ops,
11451 (void *)&cmd_flow_director_flow,
11452 (void *)&cmd_flow_director_flow_type,
11453 (void *)&cmd_flow_director_ether,
11454 (void *)&cmd_flow_director_ether_type,
11455 (void *)&cmd_flow_director_flexbytes,
11456 (void *)&cmd_flow_director_flexbytes_value,
11457 (void *)&cmd_flow_director_drop,
11458 (void *)&cmd_flow_director_pf_vf,
11459 (void *)&cmd_flow_director_queue,
11460 (void *)&cmd_flow_director_queue_id,
11461 (void *)&cmd_flow_director_fd_id,
11462 (void *)&cmd_flow_director_fd_id_value,
11467 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = {
11468 .f = cmd_flow_director_filter_parsed,
11470 .help_str = "flow_director_filter ... : Add or delete a MAC VLAN flow "
11471 "director entry on NIC",
11473 (void *)&cmd_flow_director_filter,
11474 (void *)&cmd_flow_director_port_id,
11475 (void *)&cmd_flow_director_mode,
11476 (void *)&cmd_flow_director_mode_mac_vlan,
11477 (void *)&cmd_flow_director_ops,
11478 (void *)&cmd_flow_director_mac,
11479 (void *)&cmd_flow_director_mac_addr,
11480 (void *)&cmd_flow_director_vlan,
11481 (void *)&cmd_flow_director_vlan_value,
11482 (void *)&cmd_flow_director_flexbytes,
11483 (void *)&cmd_flow_director_flexbytes_value,
11484 (void *)&cmd_flow_director_drop,
11485 (void *)&cmd_flow_director_queue,
11486 (void *)&cmd_flow_director_queue_id,
11487 (void *)&cmd_flow_director_fd_id,
11488 (void *)&cmd_flow_director_fd_id_value,
11493 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = {
11494 .f = cmd_flow_director_filter_parsed,
11496 .help_str = "flow_director_filter ... : Add or delete a tunnel flow "
11497 "director entry on NIC",
11499 (void *)&cmd_flow_director_filter,
11500 (void *)&cmd_flow_director_port_id,
11501 (void *)&cmd_flow_director_mode,
11502 (void *)&cmd_flow_director_mode_tunnel,
11503 (void *)&cmd_flow_director_ops,
11504 (void *)&cmd_flow_director_mac,
11505 (void *)&cmd_flow_director_mac_addr,
11506 (void *)&cmd_flow_director_vlan,
11507 (void *)&cmd_flow_director_vlan_value,
11508 (void *)&cmd_flow_director_tunnel,
11509 (void *)&cmd_flow_director_tunnel_type,
11510 (void *)&cmd_flow_director_tunnel_id,
11511 (void *)&cmd_flow_director_tunnel_id_value,
11512 (void *)&cmd_flow_director_flexbytes,
11513 (void *)&cmd_flow_director_flexbytes_value,
11514 (void *)&cmd_flow_director_drop,
11515 (void *)&cmd_flow_director_queue,
11516 (void *)&cmd_flow_director_queue_id,
11517 (void *)&cmd_flow_director_fd_id,
11518 (void *)&cmd_flow_director_fd_id_value,
11523 cmdline_parse_inst_t cmd_add_del_raw_flow_director = {
11524 .f = cmd_flow_director_filter_parsed,
11526 .help_str = "flow_director_filter ... : Add or delete a raw flow "
11527 "director entry on NIC",
11529 (void *)&cmd_flow_director_filter,
11530 (void *)&cmd_flow_director_port_id,
11531 (void *)&cmd_flow_director_mode,
11532 (void *)&cmd_flow_director_mode_raw,
11533 (void *)&cmd_flow_director_ops,
11534 (void *)&cmd_flow_director_flow,
11535 (void *)&cmd_flow_director_flow_type,
11536 (void *)&cmd_flow_director_drop,
11537 (void *)&cmd_flow_director_queue,
11538 (void *)&cmd_flow_director_queue_id,
11539 (void *)&cmd_flow_director_fd_id,
11540 (void *)&cmd_flow_director_fd_id_value,
11541 (void *)&cmd_flow_director_packet,
11542 (void *)&cmd_flow_director_filepath,
11547 struct cmd_flush_flow_director_result {
11548 cmdline_fixed_string_t flush_flow_director;
11552 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
11553 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
11554 flush_flow_director, "flush_flow_director");
11555 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
11556 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
11560 cmd_flush_flow_director_parsed(void *parsed_result,
11561 __rte_unused struct cmdline *cl,
11562 __rte_unused void *data)
11564 struct cmd_flow_director_result *res = parsed_result;
11567 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
11569 printf("flow director is not supported on port %u.\n",
11574 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11575 RTE_ETH_FILTER_FLUSH, NULL);
11577 printf("flow director table flushing error: (%s)\n",
11581 cmdline_parse_inst_t cmd_flush_flow_director = {
11582 .f = cmd_flush_flow_director_parsed,
11584 .help_str = "flush_flow_director <port_id>: "
11585 "Flush all flow director entries of a device on NIC",
11587 (void *)&cmd_flush_flow_director_flush,
11588 (void *)&cmd_flush_flow_director_port_id,
11593 /* *** deal with flow director mask *** */
11594 struct cmd_flow_director_mask_result {
11595 cmdline_fixed_string_t flow_director_mask;
11597 cmdline_fixed_string_t mode;
11598 cmdline_fixed_string_t mode_value;
11599 cmdline_fixed_string_t vlan;
11600 uint16_t vlan_mask;
11601 cmdline_fixed_string_t src_mask;
11602 cmdline_ipaddr_t ipv4_src;
11603 cmdline_ipaddr_t ipv6_src;
11605 cmdline_fixed_string_t dst_mask;
11606 cmdline_ipaddr_t ipv4_dst;
11607 cmdline_ipaddr_t ipv6_dst;
11609 cmdline_fixed_string_t mac;
11610 uint8_t mac_addr_byte_mask;
11611 cmdline_fixed_string_t tunnel_id;
11612 uint32_t tunnel_id_mask;
11613 cmdline_fixed_string_t tunnel_type;
11614 uint8_t tunnel_type_mask;
11618 cmd_flow_director_mask_parsed(void *parsed_result,
11619 __rte_unused struct cmdline *cl,
11620 __rte_unused void *data)
11622 struct cmd_flow_director_mask_result *res = parsed_result;
11623 struct rte_eth_fdir_masks *mask;
11624 struct rte_port *port;
11626 port = &ports[res->port_id];
11627 /** Check if the port is not started **/
11628 if (port->port_status != RTE_PORT_STOPPED) {
11629 printf("Please stop port %d first\n", res->port_id);
11633 mask = &port->dev_conf.fdir_conf.mask;
11635 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
11636 if (strcmp(res->mode_value, "MAC-VLAN")) {
11637 printf("Please set mode to MAC-VLAN.\n");
11641 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11642 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
11643 if (strcmp(res->mode_value, "Tunnel")) {
11644 printf("Please set mode to Tunnel.\n");
11648 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11649 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
11650 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
11651 mask->tunnel_type_mask = res->tunnel_type_mask;
11653 if (strcmp(res->mode_value, "IP")) {
11654 printf("Please set mode to IP.\n");
11658 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11659 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
11660 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
11661 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
11662 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
11663 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
11664 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
11667 cmd_reconfig_device_queue(res->port_id, 1, 1);
11670 cmdline_parse_token_string_t cmd_flow_director_mask =
11671 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11672 flow_director_mask, "flow_director_mask");
11673 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
11674 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11676 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
11677 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11679 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
11680 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11681 vlan_mask, UINT16);
11682 cmdline_parse_token_string_t cmd_flow_director_mask_src =
11683 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11684 src_mask, "src_mask");
11685 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
11686 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11688 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
11689 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11691 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
11692 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11694 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
11695 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11696 dst_mask, "dst_mask");
11697 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
11698 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11700 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
11701 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11703 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
11704 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11707 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
11708 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11710 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
11711 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11713 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
11714 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11715 mode_value, "MAC-VLAN");
11716 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
11717 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11718 mode_value, "Tunnel");
11719 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
11720 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11722 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
11723 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11724 mac_addr_byte_mask, UINT8);
11725 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
11726 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11727 tunnel_type, "tunnel-type");
11728 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
11729 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11730 tunnel_type_mask, UINT8);
11731 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
11732 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11733 tunnel_id, "tunnel-id");
11734 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
11735 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11736 tunnel_id_mask, UINT32);
11738 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
11739 .f = cmd_flow_director_mask_parsed,
11741 .help_str = "flow_director_mask ... : "
11742 "Set IP mode flow director's mask on NIC",
11744 (void *)&cmd_flow_director_mask,
11745 (void *)&cmd_flow_director_mask_port_id,
11746 (void *)&cmd_flow_director_mask_mode,
11747 (void *)&cmd_flow_director_mask_mode_ip,
11748 (void *)&cmd_flow_director_mask_vlan,
11749 (void *)&cmd_flow_director_mask_vlan_value,
11750 (void *)&cmd_flow_director_mask_src,
11751 (void *)&cmd_flow_director_mask_ipv4_src,
11752 (void *)&cmd_flow_director_mask_ipv6_src,
11753 (void *)&cmd_flow_director_mask_port_src,
11754 (void *)&cmd_flow_director_mask_dst,
11755 (void *)&cmd_flow_director_mask_ipv4_dst,
11756 (void *)&cmd_flow_director_mask_ipv6_dst,
11757 (void *)&cmd_flow_director_mask_port_dst,
11762 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
11763 .f = cmd_flow_director_mask_parsed,
11765 .help_str = "flow_director_mask ... : Set MAC VLAN mode "
11766 "flow director's mask on NIC",
11768 (void *)&cmd_flow_director_mask,
11769 (void *)&cmd_flow_director_mask_port_id,
11770 (void *)&cmd_flow_director_mask_mode,
11771 (void *)&cmd_flow_director_mask_mode_mac_vlan,
11772 (void *)&cmd_flow_director_mask_vlan,
11773 (void *)&cmd_flow_director_mask_vlan_value,
11778 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
11779 .f = cmd_flow_director_mask_parsed,
11781 .help_str = "flow_director_mask ... : Set tunnel mode "
11782 "flow director's mask on NIC",
11784 (void *)&cmd_flow_director_mask,
11785 (void *)&cmd_flow_director_mask_port_id,
11786 (void *)&cmd_flow_director_mask_mode,
11787 (void *)&cmd_flow_director_mask_mode_tunnel,
11788 (void *)&cmd_flow_director_mask_vlan,
11789 (void *)&cmd_flow_director_mask_vlan_value,
11790 (void *)&cmd_flow_director_mask_mac,
11791 (void *)&cmd_flow_director_mask_mac_value,
11792 (void *)&cmd_flow_director_mask_tunnel_type,
11793 (void *)&cmd_flow_director_mask_tunnel_type_value,
11794 (void *)&cmd_flow_director_mask_tunnel_id,
11795 (void *)&cmd_flow_director_mask_tunnel_id_value,
11800 /* *** deal with flow director mask on flexible payload *** */
11801 struct cmd_flow_director_flex_mask_result {
11802 cmdline_fixed_string_t flow_director_flexmask;
11804 cmdline_fixed_string_t flow;
11805 cmdline_fixed_string_t flow_type;
11806 cmdline_fixed_string_t mask;
11810 cmd_flow_director_flex_mask_parsed(void *parsed_result,
11811 __rte_unused struct cmdline *cl,
11812 __rte_unused void *data)
11814 struct cmd_flow_director_flex_mask_result *res = parsed_result;
11815 struct rte_eth_fdir_info fdir_info;
11816 struct rte_eth_fdir_flex_mask flex_mask;
11817 struct rte_port *port;
11818 uint64_t flow_type_mask;
11822 port = &ports[res->port_id];
11823 /** Check if the port is not started **/
11824 if (port->port_status != RTE_PORT_STOPPED) {
11825 printf("Please stop port %d first\n", res->port_id);
11829 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
11830 ret = parse_flexbytes(res->mask,
11832 RTE_ETH_FDIR_MAX_FLEXLEN);
11834 printf("error: Cannot parse mask input.\n");
11838 memset(&fdir_info, 0, sizeof(fdir_info));
11839 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11840 RTE_ETH_FILTER_INFO, &fdir_info);
11842 printf("Cannot get FDir filter info\n");
11846 if (!strcmp(res->flow_type, "none")) {
11847 /* means don't specify the flow type */
11848 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN;
11849 for (i = 0; i < RTE_ETH_FLOW_MAX; i++)
11850 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i],
11851 0, sizeof(struct rte_eth_fdir_flex_mask));
11852 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1;
11853 rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0],
11855 sizeof(struct rte_eth_fdir_flex_mask));
11856 cmd_reconfig_device_queue(res->port_id, 1, 1);
11859 flow_type_mask = fdir_info.flow_types_mask[0];
11860 if (!strcmp(res->flow_type, "all")) {
11861 if (!flow_type_mask) {
11862 printf("No flow type supported\n");
11865 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
11866 if (flow_type_mask & (1ULL << i)) {
11867 flex_mask.flow_type = i;
11868 fdir_set_flex_mask(res->port_id, &flex_mask);
11871 cmd_reconfig_device_queue(res->port_id, 1, 1);
11874 flex_mask.flow_type = str2flowtype(res->flow_type);
11875 if (!(flow_type_mask & (1ULL << flex_mask.flow_type))) {
11876 printf("Flow type %s not supported on port %d\n",
11877 res->flow_type, res->port_id);
11880 fdir_set_flex_mask(res->port_id, &flex_mask);
11881 cmd_reconfig_device_queue(res->port_id, 1, 1);
11884 cmdline_parse_token_string_t cmd_flow_director_flexmask =
11885 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11886 flow_director_flexmask,
11887 "flow_director_flex_mask");
11888 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
11889 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11891 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
11892 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11894 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
11895 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11896 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
11897 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all");
11898 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
11899 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11902 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
11903 .f = cmd_flow_director_flex_mask_parsed,
11905 .help_str = "flow_director_flex_mask ... : "
11906 "Set flow director's flex mask on NIC",
11908 (void *)&cmd_flow_director_flexmask,
11909 (void *)&cmd_flow_director_flexmask_port_id,
11910 (void *)&cmd_flow_director_flexmask_flow,
11911 (void *)&cmd_flow_director_flexmask_flow_type,
11912 (void *)&cmd_flow_director_flexmask_mask,
11917 /* *** deal with flow director flexible payload configuration *** */
11918 struct cmd_flow_director_flexpayload_result {
11919 cmdline_fixed_string_t flow_director_flexpayload;
11921 cmdline_fixed_string_t payload_layer;
11922 cmdline_fixed_string_t payload_cfg;
11926 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
11929 const char *p, *p0 = q_arg;
11931 unsigned long int_fld;
11932 char *str_fld[max_num];
11937 p = strchr(p0, '(');
11941 p0 = strchr(p, ')');
11946 if (size >= sizeof(s))
11949 snprintf(s, sizeof(s), "%.*s", size, p);
11950 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
11951 if (ret < 0 || ret > max_num)
11953 for (i = 0; i < ret; i++) {
11955 int_fld = strtoul(str_fld[i], &end, 0);
11956 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
11958 offsets[i] = (uint16_t)int_fld;
11964 cmd_flow_director_flxpld_parsed(void *parsed_result,
11965 __rte_unused struct cmdline *cl,
11966 __rte_unused void *data)
11968 struct cmd_flow_director_flexpayload_result *res = parsed_result;
11969 struct rte_eth_flex_payload_cfg flex_cfg;
11970 struct rte_port *port;
11973 port = &ports[res->port_id];
11974 /** Check if the port is not started **/
11975 if (port->port_status != RTE_PORT_STOPPED) {
11976 printf("Please stop port %d first\n", res->port_id);
11980 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
11982 if (!strcmp(res->payload_layer, "raw"))
11983 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
11984 else if (!strcmp(res->payload_layer, "l2"))
11985 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
11986 else if (!strcmp(res->payload_layer, "l3"))
11987 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
11988 else if (!strcmp(res->payload_layer, "l4"))
11989 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
11991 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
11992 RTE_ETH_FDIR_MAX_FLEXLEN);
11994 printf("error: Cannot parse flex payload input.\n");
11998 fdir_set_flex_payload(res->port_id, &flex_cfg);
11999 cmd_reconfig_device_queue(res->port_id, 1, 1);
12002 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
12003 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
12004 flow_director_flexpayload,
12005 "flow_director_flex_payload");
12006 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
12007 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
12009 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
12010 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
12011 payload_layer, "raw#l2#l3#l4");
12012 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
12013 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
12014 payload_cfg, NULL);
12016 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
12017 .f = cmd_flow_director_flxpld_parsed,
12019 .help_str = "flow_director_flexpayload ... : "
12020 "Set flow director's flex payload on NIC",
12022 (void *)&cmd_flow_director_flexpayload,
12023 (void *)&cmd_flow_director_flexpayload_port_id,
12024 (void *)&cmd_flow_director_flexpayload_payload_layer,
12025 (void *)&cmd_flow_director_flexpayload_payload_cfg,
12030 /* Generic flow interface command. */
12031 extern cmdline_parse_inst_t cmd_flow;
12033 /* *** Classification Filters Control *** */
12034 /* *** Get symmetric hash enable per port *** */
12035 struct cmd_get_sym_hash_ena_per_port_result {
12036 cmdline_fixed_string_t get_sym_hash_ena_per_port;
12041 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
12042 __rte_unused struct cmdline *cl,
12043 __rte_unused void *data)
12045 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
12046 struct rte_eth_hash_filter_info info;
12049 if (rte_eth_dev_filter_supported(res->port_id,
12050 RTE_ETH_FILTER_HASH) < 0) {
12051 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
12056 memset(&info, 0, sizeof(info));
12057 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
12058 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12059 RTE_ETH_FILTER_GET, &info);
12062 printf("Cannot get symmetric hash enable per port "
12063 "on port %u\n", res->port_id);
12067 printf("Symmetric hash is %s on port %u\n", info.info.enable ?
12068 "enabled" : "disabled", res->port_id);
12071 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
12072 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
12073 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
12074 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
12075 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
12078 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
12079 .f = cmd_get_sym_hash_per_port_parsed,
12081 .help_str = "get_sym_hash_ena_per_port <port_id>",
12083 (void *)&cmd_get_sym_hash_ena_per_port_all,
12084 (void *)&cmd_get_sym_hash_ena_per_port_port_id,
12089 /* *** Set symmetric hash enable per port *** */
12090 struct cmd_set_sym_hash_ena_per_port_result {
12091 cmdline_fixed_string_t set_sym_hash_ena_per_port;
12092 cmdline_fixed_string_t enable;
12097 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
12098 __rte_unused struct cmdline *cl,
12099 __rte_unused void *data)
12101 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
12102 struct rte_eth_hash_filter_info info;
12105 if (rte_eth_dev_filter_supported(res->port_id,
12106 RTE_ETH_FILTER_HASH) < 0) {
12107 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
12112 memset(&info, 0, sizeof(info));
12113 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
12114 if (!strcmp(res->enable, "enable"))
12115 info.info.enable = 1;
12116 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12117 RTE_ETH_FILTER_SET, &info);
12119 printf("Cannot set symmetric hash enable per port on "
12120 "port %u\n", res->port_id);
12123 printf("Symmetric hash has been set to %s on port %u\n",
12124 res->enable, res->port_id);
12127 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
12128 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
12129 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
12130 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
12131 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
12133 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
12134 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
12135 enable, "enable#disable");
12137 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
12138 .f = cmd_set_sym_hash_per_port_parsed,
12140 .help_str = "set_sym_hash_ena_per_port <port_id> enable|disable",
12142 (void *)&cmd_set_sym_hash_ena_per_port_all,
12143 (void *)&cmd_set_sym_hash_ena_per_port_port_id,
12144 (void *)&cmd_set_sym_hash_ena_per_port_enable,
12149 /* Get global config of hash function */
12150 struct cmd_get_hash_global_config_result {
12151 cmdline_fixed_string_t get_hash_global_config;
12156 flowtype_to_str(uint16_t ftype)
12162 } ftype_table[] = {
12163 {"ipv4", RTE_ETH_FLOW_IPV4},
12164 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
12165 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
12166 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
12167 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
12168 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
12169 {"ipv6", RTE_ETH_FLOW_IPV6},
12170 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
12171 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
12172 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
12173 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
12174 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
12175 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
12176 {"port", RTE_ETH_FLOW_PORT},
12177 {"vxlan", RTE_ETH_FLOW_VXLAN},
12178 {"geneve", RTE_ETH_FLOW_GENEVE},
12179 {"nvgre", RTE_ETH_FLOW_NVGRE},
12180 {"vxlan-gpe", RTE_ETH_FLOW_VXLAN_GPE},
12183 for (i = 0; i < RTE_DIM(ftype_table); i++) {
12184 if (ftype_table[i].ftype == ftype)
12185 return ftype_table[i].str;
12192 cmd_get_hash_global_config_parsed(void *parsed_result,
12193 __rte_unused struct cmdline *cl,
12194 __rte_unused void *data)
12196 struct cmd_get_hash_global_config_result *res = parsed_result;
12197 struct rte_eth_hash_filter_info info;
12198 uint32_t idx, offset;
12203 if (rte_eth_dev_filter_supported(res->port_id,
12204 RTE_ETH_FILTER_HASH) < 0) {
12205 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
12210 memset(&info, 0, sizeof(info));
12211 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
12212 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12213 RTE_ETH_FILTER_GET, &info);
12215 printf("Cannot get hash global configurations by port %d\n",
12220 switch (info.info.global_conf.hash_func) {
12221 case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
12222 printf("Hash function is Toeplitz\n");
12224 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
12225 printf("Hash function is Simple XOR\n");
12227 case RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ:
12228 printf("Hash function is Symmetric Toeplitz\n");
12231 printf("Unknown hash function\n");
12235 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) {
12236 idx = i / UINT64_BIT;
12237 offset = i % UINT64_BIT;
12238 if (!(info.info.global_conf.valid_bit_mask[idx] &
12241 str = flowtype_to_str(i);
12244 printf("Symmetric hash is %s globally for flow type %s "
12246 ((info.info.global_conf.sym_hash_enable_mask[idx] &
12247 (1ULL << offset)) ? "enabled" : "disabled"), str,
12252 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
12253 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
12254 get_hash_global_config, "get_hash_global_config");
12255 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
12256 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
12259 cmdline_parse_inst_t cmd_get_hash_global_config = {
12260 .f = cmd_get_hash_global_config_parsed,
12262 .help_str = "get_hash_global_config <port_id>",
12264 (void *)&cmd_get_hash_global_config_all,
12265 (void *)&cmd_get_hash_global_config_port_id,
12270 /* Set global config of hash function */
12271 struct cmd_set_hash_global_config_result {
12272 cmdline_fixed_string_t set_hash_global_config;
12274 cmdline_fixed_string_t hash_func;
12275 cmdline_fixed_string_t flow_type;
12276 cmdline_fixed_string_t enable;
12280 cmd_set_hash_global_config_parsed(void *parsed_result,
12281 __rte_unused struct cmdline *cl,
12282 __rte_unused void *data)
12284 struct cmd_set_hash_global_config_result *res = parsed_result;
12285 struct rte_eth_hash_filter_info info;
12286 uint32_t ftype, idx, offset;
12289 if (rte_eth_dev_filter_supported(res->port_id,
12290 RTE_ETH_FILTER_HASH) < 0) {
12291 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
12295 memset(&info, 0, sizeof(info));
12296 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
12297 if (!strcmp(res->hash_func, "toeplitz"))
12298 info.info.global_conf.hash_func =
12299 RTE_ETH_HASH_FUNCTION_TOEPLITZ;
12300 else if (!strcmp(res->hash_func, "simple_xor"))
12301 info.info.global_conf.hash_func =
12302 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
12303 else if (!strcmp(res->hash_func, "symmetric_toeplitz"))
12304 info.info.global_conf.hash_func =
12305 RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ;
12306 else if (!strcmp(res->hash_func, "default"))
12307 info.info.global_conf.hash_func =
12308 RTE_ETH_HASH_FUNCTION_DEFAULT;
12310 ftype = str2flowtype(res->flow_type);
12311 idx = ftype / UINT64_BIT;
12312 offset = ftype % UINT64_BIT;
12313 info.info.global_conf.valid_bit_mask[idx] |= (1ULL << offset);
12314 if (!strcmp(res->enable, "enable"))
12315 info.info.global_conf.sym_hash_enable_mask[idx] |=
12317 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12318 RTE_ETH_FILTER_SET, &info);
12320 printf("Cannot set global hash configurations by port %d\n",
12323 printf("Global hash configurations have been set "
12324 "successfully by port %d\n", res->port_id);
12327 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
12328 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12329 set_hash_global_config, "set_hash_global_config");
12330 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
12331 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
12333 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
12334 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12335 hash_func, "toeplitz#simple_xor#symmetric_toeplitz#default");
12336 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
12337 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12339 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
12340 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
12341 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
12342 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12343 enable, "enable#disable");
12345 cmdline_parse_inst_t cmd_set_hash_global_config = {
12346 .f = cmd_set_hash_global_config_parsed,
12348 .help_str = "set_hash_global_config <port_id> "
12349 "toeplitz|simple_xor|symmetric_toeplitz|default "
12350 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12351 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
12352 "l2_payload enable|disable",
12354 (void *)&cmd_set_hash_global_config_all,
12355 (void *)&cmd_set_hash_global_config_port_id,
12356 (void *)&cmd_set_hash_global_config_hash_func,
12357 (void *)&cmd_set_hash_global_config_flow_type,
12358 (void *)&cmd_set_hash_global_config_enable,
12363 /* Set hash input set */
12364 struct cmd_set_hash_input_set_result {
12365 cmdline_fixed_string_t set_hash_input_set;
12367 cmdline_fixed_string_t flow_type;
12368 cmdline_fixed_string_t inset_field;
12369 cmdline_fixed_string_t select;
12372 static enum rte_eth_input_set_field
12373 str2inset(char *string)
12377 static const struct {
12379 enum rte_eth_input_set_field inset;
12380 } inset_table[] = {
12381 {"ethertype", RTE_ETH_INPUT_SET_L2_ETHERTYPE},
12382 {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN},
12383 {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN},
12384 {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4},
12385 {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4},
12386 {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS},
12387 {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO},
12388 {"ipv4-ttl", RTE_ETH_INPUT_SET_L3_IP4_TTL},
12389 {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6},
12390 {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6},
12391 {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC},
12392 {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER},
12393 {"ipv6-hop-limits", RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS},
12394 {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT},
12395 {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT},
12396 {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT},
12397 {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT},
12398 {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT},
12399 {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT},
12400 {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG},
12401 {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY},
12402 {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY},
12403 {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD},
12404 {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD},
12405 {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD},
12406 {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD},
12407 {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD},
12408 {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD},
12409 {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD},
12410 {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD},
12411 {"none", RTE_ETH_INPUT_SET_NONE},
12414 for (i = 0; i < RTE_DIM(inset_table); i++) {
12415 if (!strcmp(string, inset_table[i].str))
12416 return inset_table[i].inset;
12419 return RTE_ETH_INPUT_SET_UNKNOWN;
12423 cmd_set_hash_input_set_parsed(void *parsed_result,
12424 __rte_unused struct cmdline *cl,
12425 __rte_unused void *data)
12427 struct cmd_set_hash_input_set_result *res = parsed_result;
12428 struct rte_eth_hash_filter_info info;
12430 memset(&info, 0, sizeof(info));
12431 info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT;
12432 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
12433 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
12434 info.info.input_set_conf.inset_size = 1;
12435 if (!strcmp(res->select, "select"))
12436 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
12437 else if (!strcmp(res->select, "add"))
12438 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
12439 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12440 RTE_ETH_FILTER_SET, &info);
12443 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd =
12444 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12445 set_hash_input_set, "set_hash_input_set");
12446 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id =
12447 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result,
12449 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type =
12450 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12452 cmdline_parse_token_string_t cmd_set_hash_input_set_field =
12453 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12455 "ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
12456 "ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#"
12457 "udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#"
12458 "sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#"
12459 "fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#"
12461 cmdline_parse_token_string_t cmd_set_hash_input_set_select =
12462 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12463 select, "select#add");
12465 cmdline_parse_inst_t cmd_set_hash_input_set = {
12466 .f = cmd_set_hash_input_set_parsed,
12468 .help_str = "set_hash_input_set <port_id> "
12469 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12470 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload|<flowtype_id> "
12471 "ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|"
12472 "ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|"
12473 "tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|"
12474 "gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
12475 "fld-7th|fld-8th|none select|add",
12477 (void *)&cmd_set_hash_input_set_cmd,
12478 (void *)&cmd_set_hash_input_set_port_id,
12479 (void *)&cmd_set_hash_input_set_flow_type,
12480 (void *)&cmd_set_hash_input_set_field,
12481 (void *)&cmd_set_hash_input_set_select,
12486 /* Set flow director input set */
12487 struct cmd_set_fdir_input_set_result {
12488 cmdline_fixed_string_t set_fdir_input_set;
12490 cmdline_fixed_string_t flow_type;
12491 cmdline_fixed_string_t inset_field;
12492 cmdline_fixed_string_t select;
12496 cmd_set_fdir_input_set_parsed(void *parsed_result,
12497 __rte_unused struct cmdline *cl,
12498 __rte_unused void *data)
12500 struct cmd_set_fdir_input_set_result *res = parsed_result;
12501 struct rte_eth_fdir_filter_info info;
12503 memset(&info, 0, sizeof(info));
12504 info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT;
12505 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
12506 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
12507 info.info.input_set_conf.inset_size = 1;
12508 if (!strcmp(res->select, "select"))
12509 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
12510 else if (!strcmp(res->select, "add"))
12511 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
12512 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
12513 RTE_ETH_FILTER_SET, &info);
12516 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd =
12517 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12518 set_fdir_input_set, "set_fdir_input_set");
12519 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id =
12520 TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result,
12522 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type =
12523 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12525 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
12526 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
12527 cmdline_parse_token_string_t cmd_set_fdir_input_set_field =
12528 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12530 "ivlan#ethertype#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
12531 "ipv4-tos#ipv4-proto#ipv4-ttl#ipv6-tc#ipv6-next-header#"
12532 "ipv6-hop-limits#udp-src-port#udp-dst-port#"
12533 "tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#"
12534 "sctp-veri-tag#none");
12535 cmdline_parse_token_string_t cmd_set_fdir_input_set_select =
12536 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12537 select, "select#add");
12539 cmdline_parse_inst_t cmd_set_fdir_input_set = {
12540 .f = cmd_set_fdir_input_set_parsed,
12542 .help_str = "set_fdir_input_set <port_id> "
12543 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12544 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
12545 "ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|"
12546 "ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|ipv6-next-header|"
12547 "ipv6-hop-limits|udp-src-port|udp-dst-port|"
12548 "tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|"
12549 "sctp-veri-tag|none select|add",
12551 (void *)&cmd_set_fdir_input_set_cmd,
12552 (void *)&cmd_set_fdir_input_set_port_id,
12553 (void *)&cmd_set_fdir_input_set_flow_type,
12554 (void *)&cmd_set_fdir_input_set_field,
12555 (void *)&cmd_set_fdir_input_set_select,
12560 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
12561 struct cmd_mcast_addr_result {
12562 cmdline_fixed_string_t mcast_addr_cmd;
12563 cmdline_fixed_string_t what;
12565 struct rte_ether_addr mc_addr;
12568 static void cmd_mcast_addr_parsed(void *parsed_result,
12569 __rte_unused struct cmdline *cl,
12570 __rte_unused void *data)
12572 struct cmd_mcast_addr_result *res = parsed_result;
12574 if (!rte_is_multicast_ether_addr(&res->mc_addr)) {
12575 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
12576 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
12577 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
12578 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
12581 if (strcmp(res->what, "add") == 0)
12582 mcast_addr_add(res->port_num, &res->mc_addr);
12584 mcast_addr_remove(res->port_num, &res->mc_addr);
12587 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
12588 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
12589 mcast_addr_cmd, "mcast_addr");
12590 cmdline_parse_token_string_t cmd_mcast_addr_what =
12591 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
12593 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
12594 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT16);
12595 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
12596 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
12598 cmdline_parse_inst_t cmd_mcast_addr = {
12599 .f = cmd_mcast_addr_parsed,
12601 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
12602 "Add/Remove multicast MAC address on port_id",
12604 (void *)&cmd_mcast_addr_cmd,
12605 (void *)&cmd_mcast_addr_what,
12606 (void *)&cmd_mcast_addr_portnum,
12607 (void *)&cmd_mcast_addr_addr,
12612 /* l2 tunnel config
12613 * only support E-tag now.
12616 /* Ether type config */
12617 struct cmd_config_l2_tunnel_eth_type_result {
12618 cmdline_fixed_string_t port;
12619 cmdline_fixed_string_t config;
12620 cmdline_fixed_string_t all;
12622 cmdline_fixed_string_t l2_tunnel;
12623 cmdline_fixed_string_t l2_tunnel_type;
12624 cmdline_fixed_string_t eth_type;
12625 uint16_t eth_type_val;
12628 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port =
12629 TOKEN_STRING_INITIALIZER
12630 (struct cmd_config_l2_tunnel_eth_type_result,
12632 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config =
12633 TOKEN_STRING_INITIALIZER
12634 (struct cmd_config_l2_tunnel_eth_type_result,
12636 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str =
12637 TOKEN_STRING_INITIALIZER
12638 (struct cmd_config_l2_tunnel_eth_type_result,
12640 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id =
12641 TOKEN_NUM_INITIALIZER
12642 (struct cmd_config_l2_tunnel_eth_type_result,
12644 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel =
12645 TOKEN_STRING_INITIALIZER
12646 (struct cmd_config_l2_tunnel_eth_type_result,
12647 l2_tunnel, "l2-tunnel");
12648 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type =
12649 TOKEN_STRING_INITIALIZER
12650 (struct cmd_config_l2_tunnel_eth_type_result,
12651 l2_tunnel_type, "E-tag");
12652 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type =
12653 TOKEN_STRING_INITIALIZER
12654 (struct cmd_config_l2_tunnel_eth_type_result,
12655 eth_type, "ether-type");
12656 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val =
12657 TOKEN_NUM_INITIALIZER
12658 (struct cmd_config_l2_tunnel_eth_type_result,
12659 eth_type_val, UINT16);
12661 static enum rte_eth_tunnel_type
12662 str2fdir_l2_tunnel_type(char *string)
12666 static const struct {
12668 enum rte_eth_tunnel_type type;
12669 } l2_tunnel_type_str[] = {
12670 {"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG},
12673 for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) {
12674 if (!strcmp(l2_tunnel_type_str[i].str, string))
12675 return l2_tunnel_type_str[i].type;
12677 return RTE_TUNNEL_TYPE_NONE;
12680 /* ether type config for all ports */
12682 cmd_config_l2_tunnel_eth_type_all_parsed
12683 (void *parsed_result,
12684 __rte_unused struct cmdline *cl,
12685 __rte_unused void *data)
12687 struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result;
12688 struct rte_eth_l2_tunnel_conf entry;
12691 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12692 entry.ether_type = res->eth_type_val;
12694 RTE_ETH_FOREACH_DEV(pid) {
12695 rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry);
12699 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = {
12700 .f = cmd_config_l2_tunnel_eth_type_all_parsed,
12702 .help_str = "port config all l2-tunnel E-tag ether-type <value>",
12704 (void *)&cmd_config_l2_tunnel_eth_type_port,
12705 (void *)&cmd_config_l2_tunnel_eth_type_config,
12706 (void *)&cmd_config_l2_tunnel_eth_type_all_str,
12707 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
12708 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
12709 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
12710 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
12715 /* ether type config for a specific port */
12717 cmd_config_l2_tunnel_eth_type_specific_parsed(
12718 void *parsed_result,
12719 __rte_unused struct cmdline *cl,
12720 __rte_unused void *data)
12722 struct cmd_config_l2_tunnel_eth_type_result *res =
12724 struct rte_eth_l2_tunnel_conf entry;
12726 if (port_id_is_invalid(res->id, ENABLED_WARN))
12729 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12730 entry.ether_type = res->eth_type_val;
12732 rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry);
12735 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = {
12736 .f = cmd_config_l2_tunnel_eth_type_specific_parsed,
12738 .help_str = "port config <port_id> l2-tunnel E-tag ether-type <value>",
12740 (void *)&cmd_config_l2_tunnel_eth_type_port,
12741 (void *)&cmd_config_l2_tunnel_eth_type_config,
12742 (void *)&cmd_config_l2_tunnel_eth_type_id,
12743 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
12744 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
12745 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
12746 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
12751 /* Enable/disable l2 tunnel */
12752 struct cmd_config_l2_tunnel_en_dis_result {
12753 cmdline_fixed_string_t port;
12754 cmdline_fixed_string_t config;
12755 cmdline_fixed_string_t all;
12757 cmdline_fixed_string_t l2_tunnel;
12758 cmdline_fixed_string_t l2_tunnel_type;
12759 cmdline_fixed_string_t en_dis;
12762 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port =
12763 TOKEN_STRING_INITIALIZER
12764 (struct cmd_config_l2_tunnel_en_dis_result,
12766 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config =
12767 TOKEN_STRING_INITIALIZER
12768 (struct cmd_config_l2_tunnel_en_dis_result,
12770 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str =
12771 TOKEN_STRING_INITIALIZER
12772 (struct cmd_config_l2_tunnel_en_dis_result,
12774 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id =
12775 TOKEN_NUM_INITIALIZER
12776 (struct cmd_config_l2_tunnel_en_dis_result,
12778 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel =
12779 TOKEN_STRING_INITIALIZER
12780 (struct cmd_config_l2_tunnel_en_dis_result,
12781 l2_tunnel, "l2-tunnel");
12782 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type =
12783 TOKEN_STRING_INITIALIZER
12784 (struct cmd_config_l2_tunnel_en_dis_result,
12785 l2_tunnel_type, "E-tag");
12786 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis =
12787 TOKEN_STRING_INITIALIZER
12788 (struct cmd_config_l2_tunnel_en_dis_result,
12789 en_dis, "enable#disable");
12791 /* enable/disable l2 tunnel for all ports */
12793 cmd_config_l2_tunnel_en_dis_all_parsed(
12794 void *parsed_result,
12795 __rte_unused struct cmdline *cl,
12796 __rte_unused void *data)
12798 struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result;
12799 struct rte_eth_l2_tunnel_conf entry;
12803 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12805 if (!strcmp("enable", res->en_dis))
12810 RTE_ETH_FOREACH_DEV(pid) {
12811 rte_eth_dev_l2_tunnel_offload_set(pid,
12813 ETH_L2_TUNNEL_ENABLE_MASK,
12818 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = {
12819 .f = cmd_config_l2_tunnel_en_dis_all_parsed,
12821 .help_str = "port config all l2-tunnel E-tag enable|disable",
12823 (void *)&cmd_config_l2_tunnel_en_dis_port,
12824 (void *)&cmd_config_l2_tunnel_en_dis_config,
12825 (void *)&cmd_config_l2_tunnel_en_dis_all_str,
12826 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
12827 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
12828 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
12833 /* enable/disable l2 tunnel for a port */
12835 cmd_config_l2_tunnel_en_dis_specific_parsed(
12836 void *parsed_result,
12837 __rte_unused struct cmdline *cl,
12838 __rte_unused void *data)
12840 struct cmd_config_l2_tunnel_en_dis_result *res =
12842 struct rte_eth_l2_tunnel_conf entry;
12844 if (port_id_is_invalid(res->id, ENABLED_WARN))
12847 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12849 if (!strcmp("enable", res->en_dis))
12850 rte_eth_dev_l2_tunnel_offload_set(res->id,
12852 ETH_L2_TUNNEL_ENABLE_MASK,
12855 rte_eth_dev_l2_tunnel_offload_set(res->id,
12857 ETH_L2_TUNNEL_ENABLE_MASK,
12861 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = {
12862 .f = cmd_config_l2_tunnel_en_dis_specific_parsed,
12864 .help_str = "port config <port_id> l2-tunnel E-tag enable|disable",
12866 (void *)&cmd_config_l2_tunnel_en_dis_port,
12867 (void *)&cmd_config_l2_tunnel_en_dis_config,
12868 (void *)&cmd_config_l2_tunnel_en_dis_id,
12869 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
12870 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
12871 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
12876 /* E-tag configuration */
12878 /* Common result structure for all E-tag configuration */
12879 struct cmd_config_e_tag_result {
12880 cmdline_fixed_string_t e_tag;
12881 cmdline_fixed_string_t set;
12882 cmdline_fixed_string_t insertion;
12883 cmdline_fixed_string_t stripping;
12884 cmdline_fixed_string_t forwarding;
12885 cmdline_fixed_string_t filter;
12886 cmdline_fixed_string_t add;
12887 cmdline_fixed_string_t del;
12888 cmdline_fixed_string_t on;
12889 cmdline_fixed_string_t off;
12890 cmdline_fixed_string_t on_off;
12891 cmdline_fixed_string_t port_tag_id;
12892 uint32_t port_tag_id_val;
12893 cmdline_fixed_string_t e_tag_id;
12894 uint16_t e_tag_id_val;
12895 cmdline_fixed_string_t dst_pool;
12896 uint8_t dst_pool_val;
12897 cmdline_fixed_string_t port;
12899 cmdline_fixed_string_t vf;
12903 /* Common CLI fields for all E-tag configuration */
12904 cmdline_parse_token_string_t cmd_config_e_tag_e_tag =
12905 TOKEN_STRING_INITIALIZER
12906 (struct cmd_config_e_tag_result,
12908 cmdline_parse_token_string_t cmd_config_e_tag_set =
12909 TOKEN_STRING_INITIALIZER
12910 (struct cmd_config_e_tag_result,
12912 cmdline_parse_token_string_t cmd_config_e_tag_insertion =
12913 TOKEN_STRING_INITIALIZER
12914 (struct cmd_config_e_tag_result,
12915 insertion, "insertion");
12916 cmdline_parse_token_string_t cmd_config_e_tag_stripping =
12917 TOKEN_STRING_INITIALIZER
12918 (struct cmd_config_e_tag_result,
12919 stripping, "stripping");
12920 cmdline_parse_token_string_t cmd_config_e_tag_forwarding =
12921 TOKEN_STRING_INITIALIZER
12922 (struct cmd_config_e_tag_result,
12923 forwarding, "forwarding");
12924 cmdline_parse_token_string_t cmd_config_e_tag_filter =
12925 TOKEN_STRING_INITIALIZER
12926 (struct cmd_config_e_tag_result,
12928 cmdline_parse_token_string_t cmd_config_e_tag_add =
12929 TOKEN_STRING_INITIALIZER
12930 (struct cmd_config_e_tag_result,
12932 cmdline_parse_token_string_t cmd_config_e_tag_del =
12933 TOKEN_STRING_INITIALIZER
12934 (struct cmd_config_e_tag_result,
12936 cmdline_parse_token_string_t cmd_config_e_tag_on =
12937 TOKEN_STRING_INITIALIZER
12938 (struct cmd_config_e_tag_result,
12940 cmdline_parse_token_string_t cmd_config_e_tag_off =
12941 TOKEN_STRING_INITIALIZER
12942 (struct cmd_config_e_tag_result,
12944 cmdline_parse_token_string_t cmd_config_e_tag_on_off =
12945 TOKEN_STRING_INITIALIZER
12946 (struct cmd_config_e_tag_result,
12948 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id =
12949 TOKEN_STRING_INITIALIZER
12950 (struct cmd_config_e_tag_result,
12951 port_tag_id, "port-tag-id");
12952 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val =
12953 TOKEN_NUM_INITIALIZER
12954 (struct cmd_config_e_tag_result,
12955 port_tag_id_val, UINT32);
12956 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id =
12957 TOKEN_STRING_INITIALIZER
12958 (struct cmd_config_e_tag_result,
12959 e_tag_id, "e-tag-id");
12960 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val =
12961 TOKEN_NUM_INITIALIZER
12962 (struct cmd_config_e_tag_result,
12963 e_tag_id_val, UINT16);
12964 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool =
12965 TOKEN_STRING_INITIALIZER
12966 (struct cmd_config_e_tag_result,
12967 dst_pool, "dst-pool");
12968 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val =
12969 TOKEN_NUM_INITIALIZER
12970 (struct cmd_config_e_tag_result,
12971 dst_pool_val, UINT8);
12972 cmdline_parse_token_string_t cmd_config_e_tag_port =
12973 TOKEN_STRING_INITIALIZER
12974 (struct cmd_config_e_tag_result,
12976 cmdline_parse_token_num_t cmd_config_e_tag_port_id =
12977 TOKEN_NUM_INITIALIZER
12978 (struct cmd_config_e_tag_result,
12980 cmdline_parse_token_string_t cmd_config_e_tag_vf =
12981 TOKEN_STRING_INITIALIZER
12982 (struct cmd_config_e_tag_result,
12984 cmdline_parse_token_num_t cmd_config_e_tag_vf_id =
12985 TOKEN_NUM_INITIALIZER
12986 (struct cmd_config_e_tag_result,
12989 /* E-tag insertion configuration */
12991 cmd_config_e_tag_insertion_en_parsed(
12992 void *parsed_result,
12993 __rte_unused struct cmdline *cl,
12994 __rte_unused void *data)
12996 struct cmd_config_e_tag_result *res =
12998 struct rte_eth_l2_tunnel_conf entry;
13000 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13003 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13004 entry.tunnel_id = res->port_tag_id_val;
13005 entry.vf_id = res->vf_id;
13006 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
13008 ETH_L2_TUNNEL_INSERTION_MASK,
13013 cmd_config_e_tag_insertion_dis_parsed(
13014 void *parsed_result,
13015 __rte_unused struct cmdline *cl,
13016 __rte_unused void *data)
13018 struct cmd_config_e_tag_result *res =
13020 struct rte_eth_l2_tunnel_conf entry;
13022 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13025 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13026 entry.vf_id = res->vf_id;
13028 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
13030 ETH_L2_TUNNEL_INSERTION_MASK,
13034 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = {
13035 .f = cmd_config_e_tag_insertion_en_parsed,
13037 .help_str = "E-tag ... : E-tag insertion enable",
13039 (void *)&cmd_config_e_tag_e_tag,
13040 (void *)&cmd_config_e_tag_set,
13041 (void *)&cmd_config_e_tag_insertion,
13042 (void *)&cmd_config_e_tag_on,
13043 (void *)&cmd_config_e_tag_port_tag_id,
13044 (void *)&cmd_config_e_tag_port_tag_id_val,
13045 (void *)&cmd_config_e_tag_port,
13046 (void *)&cmd_config_e_tag_port_id,
13047 (void *)&cmd_config_e_tag_vf,
13048 (void *)&cmd_config_e_tag_vf_id,
13053 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = {
13054 .f = cmd_config_e_tag_insertion_dis_parsed,
13056 .help_str = "E-tag ... : E-tag insertion disable",
13058 (void *)&cmd_config_e_tag_e_tag,
13059 (void *)&cmd_config_e_tag_set,
13060 (void *)&cmd_config_e_tag_insertion,
13061 (void *)&cmd_config_e_tag_off,
13062 (void *)&cmd_config_e_tag_port,
13063 (void *)&cmd_config_e_tag_port_id,
13064 (void *)&cmd_config_e_tag_vf,
13065 (void *)&cmd_config_e_tag_vf_id,
13070 /* E-tag stripping configuration */
13072 cmd_config_e_tag_stripping_parsed(
13073 void *parsed_result,
13074 __rte_unused struct cmdline *cl,
13075 __rte_unused void *data)
13077 struct cmd_config_e_tag_result *res =
13079 struct rte_eth_l2_tunnel_conf entry;
13081 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13084 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13086 if (!strcmp(res->on_off, "on"))
13087 rte_eth_dev_l2_tunnel_offload_set
13090 ETH_L2_TUNNEL_STRIPPING_MASK,
13093 rte_eth_dev_l2_tunnel_offload_set
13096 ETH_L2_TUNNEL_STRIPPING_MASK,
13100 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = {
13101 .f = cmd_config_e_tag_stripping_parsed,
13103 .help_str = "E-tag ... : E-tag stripping enable/disable",
13105 (void *)&cmd_config_e_tag_e_tag,
13106 (void *)&cmd_config_e_tag_set,
13107 (void *)&cmd_config_e_tag_stripping,
13108 (void *)&cmd_config_e_tag_on_off,
13109 (void *)&cmd_config_e_tag_port,
13110 (void *)&cmd_config_e_tag_port_id,
13115 /* E-tag forwarding configuration */
13117 cmd_config_e_tag_forwarding_parsed(
13118 void *parsed_result,
13119 __rte_unused struct cmdline *cl,
13120 __rte_unused void *data)
13122 struct cmd_config_e_tag_result *res = parsed_result;
13123 struct rte_eth_l2_tunnel_conf entry;
13125 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13128 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13130 if (!strcmp(res->on_off, "on"))
13131 rte_eth_dev_l2_tunnel_offload_set
13134 ETH_L2_TUNNEL_FORWARDING_MASK,
13137 rte_eth_dev_l2_tunnel_offload_set
13140 ETH_L2_TUNNEL_FORWARDING_MASK,
13144 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = {
13145 .f = cmd_config_e_tag_forwarding_parsed,
13147 .help_str = "E-tag ... : E-tag forwarding enable/disable",
13149 (void *)&cmd_config_e_tag_e_tag,
13150 (void *)&cmd_config_e_tag_set,
13151 (void *)&cmd_config_e_tag_forwarding,
13152 (void *)&cmd_config_e_tag_on_off,
13153 (void *)&cmd_config_e_tag_port,
13154 (void *)&cmd_config_e_tag_port_id,
13159 /* E-tag filter configuration */
13161 cmd_config_e_tag_filter_add_parsed(
13162 void *parsed_result,
13163 __rte_unused struct cmdline *cl,
13164 __rte_unused void *data)
13166 struct cmd_config_e_tag_result *res = parsed_result;
13167 struct rte_eth_l2_tunnel_conf entry;
13170 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13173 if (res->e_tag_id_val > 0x3fff) {
13174 printf("e-tag-id must be equal or less than 0x3fff.\n");
13178 ret = rte_eth_dev_filter_supported(res->port_id,
13179 RTE_ETH_FILTER_L2_TUNNEL);
13181 printf("E-tag filter is not supported on port %u.\n",
13186 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13187 entry.tunnel_id = res->e_tag_id_val;
13188 entry.pool = res->dst_pool_val;
13190 ret = rte_eth_dev_filter_ctrl(res->port_id,
13191 RTE_ETH_FILTER_L2_TUNNEL,
13192 RTE_ETH_FILTER_ADD,
13195 printf("E-tag filter programming error: (%s)\n",
13199 cmdline_parse_inst_t cmd_config_e_tag_filter_add = {
13200 .f = cmd_config_e_tag_filter_add_parsed,
13202 .help_str = "E-tag ... : E-tag filter add",
13204 (void *)&cmd_config_e_tag_e_tag,
13205 (void *)&cmd_config_e_tag_set,
13206 (void *)&cmd_config_e_tag_filter,
13207 (void *)&cmd_config_e_tag_add,
13208 (void *)&cmd_config_e_tag_e_tag_id,
13209 (void *)&cmd_config_e_tag_e_tag_id_val,
13210 (void *)&cmd_config_e_tag_dst_pool,
13211 (void *)&cmd_config_e_tag_dst_pool_val,
13212 (void *)&cmd_config_e_tag_port,
13213 (void *)&cmd_config_e_tag_port_id,
13219 cmd_config_e_tag_filter_del_parsed(
13220 void *parsed_result,
13221 __rte_unused struct cmdline *cl,
13222 __rte_unused void *data)
13224 struct cmd_config_e_tag_result *res = parsed_result;
13225 struct rte_eth_l2_tunnel_conf entry;
13228 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13231 if (res->e_tag_id_val > 0x3fff) {
13232 printf("e-tag-id must be less than 0x3fff.\n");
13236 ret = rte_eth_dev_filter_supported(res->port_id,
13237 RTE_ETH_FILTER_L2_TUNNEL);
13239 printf("E-tag filter is not supported on port %u.\n",
13244 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13245 entry.tunnel_id = res->e_tag_id_val;
13247 ret = rte_eth_dev_filter_ctrl(res->port_id,
13248 RTE_ETH_FILTER_L2_TUNNEL,
13249 RTE_ETH_FILTER_DELETE,
13252 printf("E-tag filter programming error: (%s)\n",
13256 cmdline_parse_inst_t cmd_config_e_tag_filter_del = {
13257 .f = cmd_config_e_tag_filter_del_parsed,
13259 .help_str = "E-tag ... : E-tag filter delete",
13261 (void *)&cmd_config_e_tag_e_tag,
13262 (void *)&cmd_config_e_tag_set,
13263 (void *)&cmd_config_e_tag_filter,
13264 (void *)&cmd_config_e_tag_del,
13265 (void *)&cmd_config_e_tag_e_tag_id,
13266 (void *)&cmd_config_e_tag_e_tag_id_val,
13267 (void *)&cmd_config_e_tag_port,
13268 (void *)&cmd_config_e_tag_port_id,
13273 /* vf vlan anti spoof configuration */
13275 /* Common result structure for vf vlan anti spoof */
13276 struct cmd_vf_vlan_anti_spoof_result {
13277 cmdline_fixed_string_t set;
13278 cmdline_fixed_string_t vf;
13279 cmdline_fixed_string_t vlan;
13280 cmdline_fixed_string_t antispoof;
13283 cmdline_fixed_string_t on_off;
13286 /* Common CLI fields for vf vlan anti spoof enable disable */
13287 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
13288 TOKEN_STRING_INITIALIZER
13289 (struct cmd_vf_vlan_anti_spoof_result,
13291 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
13292 TOKEN_STRING_INITIALIZER
13293 (struct cmd_vf_vlan_anti_spoof_result,
13295 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
13296 TOKEN_STRING_INITIALIZER
13297 (struct cmd_vf_vlan_anti_spoof_result,
13299 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
13300 TOKEN_STRING_INITIALIZER
13301 (struct cmd_vf_vlan_anti_spoof_result,
13302 antispoof, "antispoof");
13303 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
13304 TOKEN_NUM_INITIALIZER
13305 (struct cmd_vf_vlan_anti_spoof_result,
13307 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
13308 TOKEN_NUM_INITIALIZER
13309 (struct cmd_vf_vlan_anti_spoof_result,
13311 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
13312 TOKEN_STRING_INITIALIZER
13313 (struct cmd_vf_vlan_anti_spoof_result,
13317 cmd_set_vf_vlan_anti_spoof_parsed(
13318 void *parsed_result,
13319 __rte_unused struct cmdline *cl,
13320 __rte_unused void *data)
13322 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
13323 int ret = -ENOTSUP;
13325 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13327 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13330 #ifdef RTE_NET_IXGBE
13331 if (ret == -ENOTSUP)
13332 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
13333 res->vf_id, is_on);
13335 #ifdef RTE_NET_I40E
13336 if (ret == -ENOTSUP)
13337 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
13338 res->vf_id, is_on);
13340 #ifdef RTE_NET_BNXT
13341 if (ret == -ENOTSUP)
13342 ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
13343 res->vf_id, is_on);
13350 printf("invalid vf_id %d\n", res->vf_id);
13353 printf("invalid port_id %d\n", res->port_id);
13356 printf("function not implemented\n");
13359 printf("programming error: (%s)\n", strerror(-ret));
13363 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
13364 .f = cmd_set_vf_vlan_anti_spoof_parsed,
13366 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
13368 (void *)&cmd_vf_vlan_anti_spoof_set,
13369 (void *)&cmd_vf_vlan_anti_spoof_vf,
13370 (void *)&cmd_vf_vlan_anti_spoof_vlan,
13371 (void *)&cmd_vf_vlan_anti_spoof_antispoof,
13372 (void *)&cmd_vf_vlan_anti_spoof_port_id,
13373 (void *)&cmd_vf_vlan_anti_spoof_vf_id,
13374 (void *)&cmd_vf_vlan_anti_spoof_on_off,
13379 /* vf mac anti spoof configuration */
13381 /* Common result structure for vf mac anti spoof */
13382 struct cmd_vf_mac_anti_spoof_result {
13383 cmdline_fixed_string_t set;
13384 cmdline_fixed_string_t vf;
13385 cmdline_fixed_string_t mac;
13386 cmdline_fixed_string_t antispoof;
13389 cmdline_fixed_string_t on_off;
13392 /* Common CLI fields for vf mac anti spoof enable disable */
13393 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
13394 TOKEN_STRING_INITIALIZER
13395 (struct cmd_vf_mac_anti_spoof_result,
13397 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
13398 TOKEN_STRING_INITIALIZER
13399 (struct cmd_vf_mac_anti_spoof_result,
13401 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
13402 TOKEN_STRING_INITIALIZER
13403 (struct cmd_vf_mac_anti_spoof_result,
13405 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
13406 TOKEN_STRING_INITIALIZER
13407 (struct cmd_vf_mac_anti_spoof_result,
13408 antispoof, "antispoof");
13409 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
13410 TOKEN_NUM_INITIALIZER
13411 (struct cmd_vf_mac_anti_spoof_result,
13413 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
13414 TOKEN_NUM_INITIALIZER
13415 (struct cmd_vf_mac_anti_spoof_result,
13417 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
13418 TOKEN_STRING_INITIALIZER
13419 (struct cmd_vf_mac_anti_spoof_result,
13423 cmd_set_vf_mac_anti_spoof_parsed(
13424 void *parsed_result,
13425 __rte_unused struct cmdline *cl,
13426 __rte_unused void *data)
13428 struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
13429 int ret = -ENOTSUP;
13431 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13433 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13436 #ifdef RTE_NET_IXGBE
13437 if (ret == -ENOTSUP)
13438 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
13439 res->vf_id, is_on);
13441 #ifdef RTE_NET_I40E
13442 if (ret == -ENOTSUP)
13443 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
13444 res->vf_id, is_on);
13446 #ifdef RTE_NET_BNXT
13447 if (ret == -ENOTSUP)
13448 ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
13449 res->vf_id, is_on);
13456 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13459 printf("invalid port_id %d\n", res->port_id);
13462 printf("function not implemented\n");
13465 printf("programming error: (%s)\n", strerror(-ret));
13469 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
13470 .f = cmd_set_vf_mac_anti_spoof_parsed,
13472 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
13474 (void *)&cmd_vf_mac_anti_spoof_set,
13475 (void *)&cmd_vf_mac_anti_spoof_vf,
13476 (void *)&cmd_vf_mac_anti_spoof_mac,
13477 (void *)&cmd_vf_mac_anti_spoof_antispoof,
13478 (void *)&cmd_vf_mac_anti_spoof_port_id,
13479 (void *)&cmd_vf_mac_anti_spoof_vf_id,
13480 (void *)&cmd_vf_mac_anti_spoof_on_off,
13485 /* vf vlan strip queue configuration */
13487 /* Common result structure for vf mac anti spoof */
13488 struct cmd_vf_vlan_stripq_result {
13489 cmdline_fixed_string_t set;
13490 cmdline_fixed_string_t vf;
13491 cmdline_fixed_string_t vlan;
13492 cmdline_fixed_string_t stripq;
13495 cmdline_fixed_string_t on_off;
13498 /* Common CLI fields for vf vlan strip enable disable */
13499 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
13500 TOKEN_STRING_INITIALIZER
13501 (struct cmd_vf_vlan_stripq_result,
13503 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
13504 TOKEN_STRING_INITIALIZER
13505 (struct cmd_vf_vlan_stripq_result,
13507 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
13508 TOKEN_STRING_INITIALIZER
13509 (struct cmd_vf_vlan_stripq_result,
13511 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
13512 TOKEN_STRING_INITIALIZER
13513 (struct cmd_vf_vlan_stripq_result,
13515 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
13516 TOKEN_NUM_INITIALIZER
13517 (struct cmd_vf_vlan_stripq_result,
13519 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
13520 TOKEN_NUM_INITIALIZER
13521 (struct cmd_vf_vlan_stripq_result,
13523 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
13524 TOKEN_STRING_INITIALIZER
13525 (struct cmd_vf_vlan_stripq_result,
13529 cmd_set_vf_vlan_stripq_parsed(
13530 void *parsed_result,
13531 __rte_unused struct cmdline *cl,
13532 __rte_unused void *data)
13534 struct cmd_vf_vlan_stripq_result *res = parsed_result;
13535 int ret = -ENOTSUP;
13537 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13539 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13542 #ifdef RTE_NET_IXGBE
13543 if (ret == -ENOTSUP)
13544 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
13545 res->vf_id, is_on);
13547 #ifdef RTE_NET_I40E
13548 if (ret == -ENOTSUP)
13549 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
13550 res->vf_id, is_on);
13552 #ifdef RTE_NET_BNXT
13553 if (ret == -ENOTSUP)
13554 ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
13555 res->vf_id, is_on);
13562 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13565 printf("invalid port_id %d\n", res->port_id);
13568 printf("function not implemented\n");
13571 printf("programming error: (%s)\n", strerror(-ret));
13575 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
13576 .f = cmd_set_vf_vlan_stripq_parsed,
13578 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
13580 (void *)&cmd_vf_vlan_stripq_set,
13581 (void *)&cmd_vf_vlan_stripq_vf,
13582 (void *)&cmd_vf_vlan_stripq_vlan,
13583 (void *)&cmd_vf_vlan_stripq_stripq,
13584 (void *)&cmd_vf_vlan_stripq_port_id,
13585 (void *)&cmd_vf_vlan_stripq_vf_id,
13586 (void *)&cmd_vf_vlan_stripq_on_off,
13591 /* vf vlan insert configuration */
13593 /* Common result structure for vf vlan insert */
13594 struct cmd_vf_vlan_insert_result {
13595 cmdline_fixed_string_t set;
13596 cmdline_fixed_string_t vf;
13597 cmdline_fixed_string_t vlan;
13598 cmdline_fixed_string_t insert;
13604 /* Common CLI fields for vf vlan insert enable disable */
13605 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
13606 TOKEN_STRING_INITIALIZER
13607 (struct cmd_vf_vlan_insert_result,
13609 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
13610 TOKEN_STRING_INITIALIZER
13611 (struct cmd_vf_vlan_insert_result,
13613 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
13614 TOKEN_STRING_INITIALIZER
13615 (struct cmd_vf_vlan_insert_result,
13617 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
13618 TOKEN_STRING_INITIALIZER
13619 (struct cmd_vf_vlan_insert_result,
13621 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
13622 TOKEN_NUM_INITIALIZER
13623 (struct cmd_vf_vlan_insert_result,
13625 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
13626 TOKEN_NUM_INITIALIZER
13627 (struct cmd_vf_vlan_insert_result,
13629 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
13630 TOKEN_NUM_INITIALIZER
13631 (struct cmd_vf_vlan_insert_result,
13635 cmd_set_vf_vlan_insert_parsed(
13636 void *parsed_result,
13637 __rte_unused struct cmdline *cl,
13638 __rte_unused void *data)
13640 struct cmd_vf_vlan_insert_result *res = parsed_result;
13641 int ret = -ENOTSUP;
13643 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13646 #ifdef RTE_NET_IXGBE
13647 if (ret == -ENOTSUP)
13648 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
13651 #ifdef RTE_NET_I40E
13652 if (ret == -ENOTSUP)
13653 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
13656 #ifdef RTE_NET_BNXT
13657 if (ret == -ENOTSUP)
13658 ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
13666 printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id);
13669 printf("invalid port_id %d\n", res->port_id);
13672 printf("function not implemented\n");
13675 printf("programming error: (%s)\n", strerror(-ret));
13679 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
13680 .f = cmd_set_vf_vlan_insert_parsed,
13682 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
13684 (void *)&cmd_vf_vlan_insert_set,
13685 (void *)&cmd_vf_vlan_insert_vf,
13686 (void *)&cmd_vf_vlan_insert_vlan,
13687 (void *)&cmd_vf_vlan_insert_insert,
13688 (void *)&cmd_vf_vlan_insert_port_id,
13689 (void *)&cmd_vf_vlan_insert_vf_id,
13690 (void *)&cmd_vf_vlan_insert_vlan_id,
13695 /* tx loopback configuration */
13697 /* Common result structure for tx loopback */
13698 struct cmd_tx_loopback_result {
13699 cmdline_fixed_string_t set;
13700 cmdline_fixed_string_t tx;
13701 cmdline_fixed_string_t loopback;
13703 cmdline_fixed_string_t on_off;
13706 /* Common CLI fields for tx loopback enable disable */
13707 cmdline_parse_token_string_t cmd_tx_loopback_set =
13708 TOKEN_STRING_INITIALIZER
13709 (struct cmd_tx_loopback_result,
13711 cmdline_parse_token_string_t cmd_tx_loopback_tx =
13712 TOKEN_STRING_INITIALIZER
13713 (struct cmd_tx_loopback_result,
13715 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
13716 TOKEN_STRING_INITIALIZER
13717 (struct cmd_tx_loopback_result,
13718 loopback, "loopback");
13719 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
13720 TOKEN_NUM_INITIALIZER
13721 (struct cmd_tx_loopback_result,
13723 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
13724 TOKEN_STRING_INITIALIZER
13725 (struct cmd_tx_loopback_result,
13729 cmd_set_tx_loopback_parsed(
13730 void *parsed_result,
13731 __rte_unused struct cmdline *cl,
13732 __rte_unused void *data)
13734 struct cmd_tx_loopback_result *res = parsed_result;
13735 int ret = -ENOTSUP;
13737 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13739 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13742 #ifdef RTE_NET_IXGBE
13743 if (ret == -ENOTSUP)
13744 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
13746 #ifdef RTE_NET_I40E
13747 if (ret == -ENOTSUP)
13748 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
13750 #ifdef RTE_NET_BNXT
13751 if (ret == -ENOTSUP)
13752 ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
13754 #if defined RTE_BUS_DPAA && defined RTE_NET_DPAA
13755 if (ret == -ENOTSUP)
13756 ret = rte_pmd_dpaa_set_tx_loopback(res->port_id, is_on);
13763 printf("invalid is_on %d\n", is_on);
13766 printf("invalid port_id %d\n", res->port_id);
13769 printf("function not implemented\n");
13772 printf("programming error: (%s)\n", strerror(-ret));
13776 cmdline_parse_inst_t cmd_set_tx_loopback = {
13777 .f = cmd_set_tx_loopback_parsed,
13779 .help_str = "set tx loopback <port_id> on|off",
13781 (void *)&cmd_tx_loopback_set,
13782 (void *)&cmd_tx_loopback_tx,
13783 (void *)&cmd_tx_loopback_loopback,
13784 (void *)&cmd_tx_loopback_port_id,
13785 (void *)&cmd_tx_loopback_on_off,
13790 /* all queues drop enable configuration */
13792 /* Common result structure for all queues drop enable */
13793 struct cmd_all_queues_drop_en_result {
13794 cmdline_fixed_string_t set;
13795 cmdline_fixed_string_t all;
13796 cmdline_fixed_string_t queues;
13797 cmdline_fixed_string_t drop;
13799 cmdline_fixed_string_t on_off;
13802 /* Common CLI fields for tx loopback enable disable */
13803 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
13804 TOKEN_STRING_INITIALIZER
13805 (struct cmd_all_queues_drop_en_result,
13807 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
13808 TOKEN_STRING_INITIALIZER
13809 (struct cmd_all_queues_drop_en_result,
13811 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
13812 TOKEN_STRING_INITIALIZER
13813 (struct cmd_all_queues_drop_en_result,
13815 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
13816 TOKEN_STRING_INITIALIZER
13817 (struct cmd_all_queues_drop_en_result,
13819 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
13820 TOKEN_NUM_INITIALIZER
13821 (struct cmd_all_queues_drop_en_result,
13823 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
13824 TOKEN_STRING_INITIALIZER
13825 (struct cmd_all_queues_drop_en_result,
13829 cmd_set_all_queues_drop_en_parsed(
13830 void *parsed_result,
13831 __rte_unused struct cmdline *cl,
13832 __rte_unused void *data)
13834 struct cmd_all_queues_drop_en_result *res = parsed_result;
13835 int ret = -ENOTSUP;
13836 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13838 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13841 #ifdef RTE_NET_IXGBE
13842 if (ret == -ENOTSUP)
13843 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
13845 #ifdef RTE_NET_BNXT
13846 if (ret == -ENOTSUP)
13847 ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
13853 printf("invalid is_on %d\n", is_on);
13856 printf("invalid port_id %d\n", res->port_id);
13859 printf("function not implemented\n");
13862 printf("programming error: (%s)\n", strerror(-ret));
13866 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
13867 .f = cmd_set_all_queues_drop_en_parsed,
13869 .help_str = "set all queues drop <port_id> on|off",
13871 (void *)&cmd_all_queues_drop_en_set,
13872 (void *)&cmd_all_queues_drop_en_all,
13873 (void *)&cmd_all_queues_drop_en_queues,
13874 (void *)&cmd_all_queues_drop_en_drop,
13875 (void *)&cmd_all_queues_drop_en_port_id,
13876 (void *)&cmd_all_queues_drop_en_on_off,
13881 /* vf split drop enable configuration */
13883 /* Common result structure for vf split drop enable */
13884 struct cmd_vf_split_drop_en_result {
13885 cmdline_fixed_string_t set;
13886 cmdline_fixed_string_t vf;
13887 cmdline_fixed_string_t split;
13888 cmdline_fixed_string_t drop;
13891 cmdline_fixed_string_t on_off;
13894 /* Common CLI fields for vf split drop enable disable */
13895 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
13896 TOKEN_STRING_INITIALIZER
13897 (struct cmd_vf_split_drop_en_result,
13899 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
13900 TOKEN_STRING_INITIALIZER
13901 (struct cmd_vf_split_drop_en_result,
13903 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
13904 TOKEN_STRING_INITIALIZER
13905 (struct cmd_vf_split_drop_en_result,
13907 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
13908 TOKEN_STRING_INITIALIZER
13909 (struct cmd_vf_split_drop_en_result,
13911 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
13912 TOKEN_NUM_INITIALIZER
13913 (struct cmd_vf_split_drop_en_result,
13915 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
13916 TOKEN_NUM_INITIALIZER
13917 (struct cmd_vf_split_drop_en_result,
13919 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
13920 TOKEN_STRING_INITIALIZER
13921 (struct cmd_vf_split_drop_en_result,
13925 cmd_set_vf_split_drop_en_parsed(
13926 void *parsed_result,
13927 __rte_unused struct cmdline *cl,
13928 __rte_unused void *data)
13930 struct cmd_vf_split_drop_en_result *res = parsed_result;
13931 int ret = -ENOTSUP;
13932 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13934 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13937 #ifdef RTE_NET_IXGBE
13938 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
13945 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13948 printf("invalid port_id %d\n", res->port_id);
13951 printf("not supported on port %d\n", res->port_id);
13954 printf("programming error: (%s)\n", strerror(-ret));
13958 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
13959 .f = cmd_set_vf_split_drop_en_parsed,
13961 .help_str = "set vf split drop <port_id> <vf_id> on|off",
13963 (void *)&cmd_vf_split_drop_en_set,
13964 (void *)&cmd_vf_split_drop_en_vf,
13965 (void *)&cmd_vf_split_drop_en_split,
13966 (void *)&cmd_vf_split_drop_en_drop,
13967 (void *)&cmd_vf_split_drop_en_port_id,
13968 (void *)&cmd_vf_split_drop_en_vf_id,
13969 (void *)&cmd_vf_split_drop_en_on_off,
13974 /* vf mac address configuration */
13976 /* Common result structure for vf mac address */
13977 struct cmd_set_vf_mac_addr_result {
13978 cmdline_fixed_string_t set;
13979 cmdline_fixed_string_t vf;
13980 cmdline_fixed_string_t mac;
13981 cmdline_fixed_string_t addr;
13984 struct rte_ether_addr mac_addr;
13988 /* Common CLI fields for vf split drop enable disable */
13989 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
13990 TOKEN_STRING_INITIALIZER
13991 (struct cmd_set_vf_mac_addr_result,
13993 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
13994 TOKEN_STRING_INITIALIZER
13995 (struct cmd_set_vf_mac_addr_result,
13997 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
13998 TOKEN_STRING_INITIALIZER
13999 (struct cmd_set_vf_mac_addr_result,
14001 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
14002 TOKEN_STRING_INITIALIZER
14003 (struct cmd_set_vf_mac_addr_result,
14005 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
14006 TOKEN_NUM_INITIALIZER
14007 (struct cmd_set_vf_mac_addr_result,
14009 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
14010 TOKEN_NUM_INITIALIZER
14011 (struct cmd_set_vf_mac_addr_result,
14013 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
14014 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
14018 cmd_set_vf_mac_addr_parsed(
14019 void *parsed_result,
14020 __rte_unused struct cmdline *cl,
14021 __rte_unused void *data)
14023 struct cmd_set_vf_mac_addr_result *res = parsed_result;
14024 int ret = -ENOTSUP;
14026 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14029 #ifdef RTE_NET_IXGBE
14030 if (ret == -ENOTSUP)
14031 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
14034 #ifdef RTE_NET_I40E
14035 if (ret == -ENOTSUP)
14036 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
14039 #ifdef RTE_NET_BNXT
14040 if (ret == -ENOTSUP)
14041 ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
14049 printf("invalid vf_id %d or mac_addr\n", res->vf_id);
14052 printf("invalid port_id %d\n", res->port_id);
14055 printf("function not implemented\n");
14058 printf("programming error: (%s)\n", strerror(-ret));
14062 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
14063 .f = cmd_set_vf_mac_addr_parsed,
14065 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
14067 (void *)&cmd_set_vf_mac_addr_set,
14068 (void *)&cmd_set_vf_mac_addr_vf,
14069 (void *)&cmd_set_vf_mac_addr_mac,
14070 (void *)&cmd_set_vf_mac_addr_addr,
14071 (void *)&cmd_set_vf_mac_addr_port_id,
14072 (void *)&cmd_set_vf_mac_addr_vf_id,
14073 (void *)&cmd_set_vf_mac_addr_mac_addr,
14078 /* MACsec configuration */
14080 /* Common result structure for MACsec offload enable */
14081 struct cmd_macsec_offload_on_result {
14082 cmdline_fixed_string_t set;
14083 cmdline_fixed_string_t macsec;
14084 cmdline_fixed_string_t offload;
14086 cmdline_fixed_string_t on;
14087 cmdline_fixed_string_t encrypt;
14088 cmdline_fixed_string_t en_on_off;
14089 cmdline_fixed_string_t replay_protect;
14090 cmdline_fixed_string_t rp_on_off;
14093 /* Common CLI fields for MACsec offload disable */
14094 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
14095 TOKEN_STRING_INITIALIZER
14096 (struct cmd_macsec_offload_on_result,
14098 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
14099 TOKEN_STRING_INITIALIZER
14100 (struct cmd_macsec_offload_on_result,
14102 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
14103 TOKEN_STRING_INITIALIZER
14104 (struct cmd_macsec_offload_on_result,
14105 offload, "offload");
14106 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
14107 TOKEN_NUM_INITIALIZER
14108 (struct cmd_macsec_offload_on_result,
14110 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
14111 TOKEN_STRING_INITIALIZER
14112 (struct cmd_macsec_offload_on_result,
14114 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
14115 TOKEN_STRING_INITIALIZER
14116 (struct cmd_macsec_offload_on_result,
14117 encrypt, "encrypt");
14118 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
14119 TOKEN_STRING_INITIALIZER
14120 (struct cmd_macsec_offload_on_result,
14121 en_on_off, "on#off");
14122 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
14123 TOKEN_STRING_INITIALIZER
14124 (struct cmd_macsec_offload_on_result,
14125 replay_protect, "replay-protect");
14126 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
14127 TOKEN_STRING_INITIALIZER
14128 (struct cmd_macsec_offload_on_result,
14129 rp_on_off, "on#off");
14132 cmd_set_macsec_offload_on_parsed(
14133 void *parsed_result,
14134 __rte_unused struct cmdline *cl,
14135 __rte_unused void *data)
14137 struct cmd_macsec_offload_on_result *res = parsed_result;
14138 int ret = -ENOTSUP;
14139 portid_t port_id = res->port_id;
14140 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
14141 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
14142 struct rte_eth_dev_info dev_info;
14144 if (port_id_is_invalid(port_id, ENABLED_WARN))
14146 if (!port_is_stopped(port_id)) {
14147 printf("Please stop port %d first\n", port_id);
14151 ret = eth_dev_info_get_print_err(port_id, &dev_info);
14155 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
14156 #ifdef RTE_NET_IXGBE
14157 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
14165 ports[port_id].dev_conf.txmode.offloads |=
14166 DEV_TX_OFFLOAD_MACSEC_INSERT;
14167 cmd_reconfig_device_queue(port_id, 1, 1);
14170 printf("invalid port_id %d\n", port_id);
14173 printf("not supported on port %d\n", port_id);
14176 printf("programming error: (%s)\n", strerror(-ret));
14180 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
14181 .f = cmd_set_macsec_offload_on_parsed,
14183 .help_str = "set macsec offload <port_id> on "
14184 "encrypt on|off replay-protect on|off",
14186 (void *)&cmd_macsec_offload_on_set,
14187 (void *)&cmd_macsec_offload_on_macsec,
14188 (void *)&cmd_macsec_offload_on_offload,
14189 (void *)&cmd_macsec_offload_on_port_id,
14190 (void *)&cmd_macsec_offload_on_on,
14191 (void *)&cmd_macsec_offload_on_encrypt,
14192 (void *)&cmd_macsec_offload_on_en_on_off,
14193 (void *)&cmd_macsec_offload_on_replay_protect,
14194 (void *)&cmd_macsec_offload_on_rp_on_off,
14199 /* Common result structure for MACsec offload disable */
14200 struct cmd_macsec_offload_off_result {
14201 cmdline_fixed_string_t set;
14202 cmdline_fixed_string_t macsec;
14203 cmdline_fixed_string_t offload;
14205 cmdline_fixed_string_t off;
14208 /* Common CLI fields for MACsec offload disable */
14209 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
14210 TOKEN_STRING_INITIALIZER
14211 (struct cmd_macsec_offload_off_result,
14213 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
14214 TOKEN_STRING_INITIALIZER
14215 (struct cmd_macsec_offload_off_result,
14217 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
14218 TOKEN_STRING_INITIALIZER
14219 (struct cmd_macsec_offload_off_result,
14220 offload, "offload");
14221 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
14222 TOKEN_NUM_INITIALIZER
14223 (struct cmd_macsec_offload_off_result,
14225 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
14226 TOKEN_STRING_INITIALIZER
14227 (struct cmd_macsec_offload_off_result,
14231 cmd_set_macsec_offload_off_parsed(
14232 void *parsed_result,
14233 __rte_unused struct cmdline *cl,
14234 __rte_unused void *data)
14236 struct cmd_macsec_offload_off_result *res = parsed_result;
14237 int ret = -ENOTSUP;
14238 struct rte_eth_dev_info dev_info;
14239 portid_t port_id = res->port_id;
14241 if (port_id_is_invalid(port_id, ENABLED_WARN))
14243 if (!port_is_stopped(port_id)) {
14244 printf("Please stop port %d first\n", port_id);
14248 ret = eth_dev_info_get_print_err(port_id, &dev_info);
14252 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
14253 #ifdef RTE_NET_IXGBE
14254 ret = rte_pmd_ixgbe_macsec_disable(port_id);
14259 ports[port_id].dev_conf.txmode.offloads &=
14260 ~DEV_TX_OFFLOAD_MACSEC_INSERT;
14261 cmd_reconfig_device_queue(port_id, 1, 1);
14264 printf("invalid port_id %d\n", port_id);
14267 printf("not supported on port %d\n", port_id);
14270 printf("programming error: (%s)\n", strerror(-ret));
14274 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
14275 .f = cmd_set_macsec_offload_off_parsed,
14277 .help_str = "set macsec offload <port_id> off",
14279 (void *)&cmd_macsec_offload_off_set,
14280 (void *)&cmd_macsec_offload_off_macsec,
14281 (void *)&cmd_macsec_offload_off_offload,
14282 (void *)&cmd_macsec_offload_off_port_id,
14283 (void *)&cmd_macsec_offload_off_off,
14288 /* Common result structure for MACsec secure connection configure */
14289 struct cmd_macsec_sc_result {
14290 cmdline_fixed_string_t set;
14291 cmdline_fixed_string_t macsec;
14292 cmdline_fixed_string_t sc;
14293 cmdline_fixed_string_t tx_rx;
14295 struct rte_ether_addr mac;
14299 /* Common CLI fields for MACsec secure connection configure */
14300 cmdline_parse_token_string_t cmd_macsec_sc_set =
14301 TOKEN_STRING_INITIALIZER
14302 (struct cmd_macsec_sc_result,
14304 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
14305 TOKEN_STRING_INITIALIZER
14306 (struct cmd_macsec_sc_result,
14308 cmdline_parse_token_string_t cmd_macsec_sc_sc =
14309 TOKEN_STRING_INITIALIZER
14310 (struct cmd_macsec_sc_result,
14312 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
14313 TOKEN_STRING_INITIALIZER
14314 (struct cmd_macsec_sc_result,
14316 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
14317 TOKEN_NUM_INITIALIZER
14318 (struct cmd_macsec_sc_result,
14320 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
14321 TOKEN_ETHERADDR_INITIALIZER
14322 (struct cmd_macsec_sc_result,
14324 cmdline_parse_token_num_t cmd_macsec_sc_pi =
14325 TOKEN_NUM_INITIALIZER
14326 (struct cmd_macsec_sc_result,
14330 cmd_set_macsec_sc_parsed(
14331 void *parsed_result,
14332 __rte_unused struct cmdline *cl,
14333 __rte_unused void *data)
14335 struct cmd_macsec_sc_result *res = parsed_result;
14336 int ret = -ENOTSUP;
14337 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
14339 #ifdef RTE_NET_IXGBE
14341 rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
14342 res->mac.addr_bytes) :
14343 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
14344 res->mac.addr_bytes, res->pi);
14346 RTE_SET_USED(is_tx);
14352 printf("invalid port_id %d\n", res->port_id);
14355 printf("not supported on port %d\n", res->port_id);
14358 printf("programming error: (%s)\n", strerror(-ret));
14362 cmdline_parse_inst_t cmd_set_macsec_sc = {
14363 .f = cmd_set_macsec_sc_parsed,
14365 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
14367 (void *)&cmd_macsec_sc_set,
14368 (void *)&cmd_macsec_sc_macsec,
14369 (void *)&cmd_macsec_sc_sc,
14370 (void *)&cmd_macsec_sc_tx_rx,
14371 (void *)&cmd_macsec_sc_port_id,
14372 (void *)&cmd_macsec_sc_mac,
14373 (void *)&cmd_macsec_sc_pi,
14378 /* Common result structure for MACsec secure connection configure */
14379 struct cmd_macsec_sa_result {
14380 cmdline_fixed_string_t set;
14381 cmdline_fixed_string_t macsec;
14382 cmdline_fixed_string_t sa;
14383 cmdline_fixed_string_t tx_rx;
14388 cmdline_fixed_string_t key;
14391 /* Common CLI fields for MACsec secure connection configure */
14392 cmdline_parse_token_string_t cmd_macsec_sa_set =
14393 TOKEN_STRING_INITIALIZER
14394 (struct cmd_macsec_sa_result,
14396 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
14397 TOKEN_STRING_INITIALIZER
14398 (struct cmd_macsec_sa_result,
14400 cmdline_parse_token_string_t cmd_macsec_sa_sa =
14401 TOKEN_STRING_INITIALIZER
14402 (struct cmd_macsec_sa_result,
14404 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
14405 TOKEN_STRING_INITIALIZER
14406 (struct cmd_macsec_sa_result,
14408 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
14409 TOKEN_NUM_INITIALIZER
14410 (struct cmd_macsec_sa_result,
14412 cmdline_parse_token_num_t cmd_macsec_sa_idx =
14413 TOKEN_NUM_INITIALIZER
14414 (struct cmd_macsec_sa_result,
14416 cmdline_parse_token_num_t cmd_macsec_sa_an =
14417 TOKEN_NUM_INITIALIZER
14418 (struct cmd_macsec_sa_result,
14420 cmdline_parse_token_num_t cmd_macsec_sa_pn =
14421 TOKEN_NUM_INITIALIZER
14422 (struct cmd_macsec_sa_result,
14424 cmdline_parse_token_string_t cmd_macsec_sa_key =
14425 TOKEN_STRING_INITIALIZER
14426 (struct cmd_macsec_sa_result,
14430 cmd_set_macsec_sa_parsed(
14431 void *parsed_result,
14432 __rte_unused struct cmdline *cl,
14433 __rte_unused void *data)
14435 struct cmd_macsec_sa_result *res = parsed_result;
14436 int ret = -ENOTSUP;
14437 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
14438 uint8_t key[16] = { 0 };
14444 key_len = strlen(res->key) / 2;
14448 for (i = 0; i < key_len; i++) {
14449 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
14452 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
14455 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
14458 #ifdef RTE_NET_IXGBE
14460 rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
14461 res->idx, res->an, res->pn, key) :
14462 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
14463 res->idx, res->an, res->pn, key);
14465 RTE_SET_USED(is_tx);
14472 printf("invalid idx %d or an %d\n", res->idx, res->an);
14475 printf("invalid port_id %d\n", res->port_id);
14478 printf("not supported on port %d\n", res->port_id);
14481 printf("programming error: (%s)\n", strerror(-ret));
14485 cmdline_parse_inst_t cmd_set_macsec_sa = {
14486 .f = cmd_set_macsec_sa_parsed,
14488 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
14490 (void *)&cmd_macsec_sa_set,
14491 (void *)&cmd_macsec_sa_macsec,
14492 (void *)&cmd_macsec_sa_sa,
14493 (void *)&cmd_macsec_sa_tx_rx,
14494 (void *)&cmd_macsec_sa_port_id,
14495 (void *)&cmd_macsec_sa_idx,
14496 (void *)&cmd_macsec_sa_an,
14497 (void *)&cmd_macsec_sa_pn,
14498 (void *)&cmd_macsec_sa_key,
14503 /* VF unicast promiscuous mode configuration */
14505 /* Common result structure for VF unicast promiscuous mode */
14506 struct cmd_vf_promisc_result {
14507 cmdline_fixed_string_t set;
14508 cmdline_fixed_string_t vf;
14509 cmdline_fixed_string_t promisc;
14512 cmdline_fixed_string_t on_off;
14515 /* Common CLI fields for VF unicast promiscuous mode enable disable */
14516 cmdline_parse_token_string_t cmd_vf_promisc_set =
14517 TOKEN_STRING_INITIALIZER
14518 (struct cmd_vf_promisc_result,
14520 cmdline_parse_token_string_t cmd_vf_promisc_vf =
14521 TOKEN_STRING_INITIALIZER
14522 (struct cmd_vf_promisc_result,
14524 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
14525 TOKEN_STRING_INITIALIZER
14526 (struct cmd_vf_promisc_result,
14527 promisc, "promisc");
14528 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
14529 TOKEN_NUM_INITIALIZER
14530 (struct cmd_vf_promisc_result,
14532 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
14533 TOKEN_NUM_INITIALIZER
14534 (struct cmd_vf_promisc_result,
14536 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
14537 TOKEN_STRING_INITIALIZER
14538 (struct cmd_vf_promisc_result,
14542 cmd_set_vf_promisc_parsed(
14543 void *parsed_result,
14544 __rte_unused struct cmdline *cl,
14545 __rte_unused void *data)
14547 struct cmd_vf_promisc_result *res = parsed_result;
14548 int ret = -ENOTSUP;
14550 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14552 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14555 #ifdef RTE_NET_I40E
14556 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
14557 res->vf_id, is_on);
14564 printf("invalid vf_id %d\n", res->vf_id);
14567 printf("invalid port_id %d\n", res->port_id);
14570 printf("function not implemented\n");
14573 printf("programming error: (%s)\n", strerror(-ret));
14577 cmdline_parse_inst_t cmd_set_vf_promisc = {
14578 .f = cmd_set_vf_promisc_parsed,
14580 .help_str = "set vf promisc <port_id> <vf_id> on|off: "
14581 "Set unicast promiscuous mode for a VF from the PF",
14583 (void *)&cmd_vf_promisc_set,
14584 (void *)&cmd_vf_promisc_vf,
14585 (void *)&cmd_vf_promisc_promisc,
14586 (void *)&cmd_vf_promisc_port_id,
14587 (void *)&cmd_vf_promisc_vf_id,
14588 (void *)&cmd_vf_promisc_on_off,
14593 /* VF multicast promiscuous mode configuration */
14595 /* Common result structure for VF multicast promiscuous mode */
14596 struct cmd_vf_allmulti_result {
14597 cmdline_fixed_string_t set;
14598 cmdline_fixed_string_t vf;
14599 cmdline_fixed_string_t allmulti;
14602 cmdline_fixed_string_t on_off;
14605 /* Common CLI fields for VF multicast promiscuous mode enable disable */
14606 cmdline_parse_token_string_t cmd_vf_allmulti_set =
14607 TOKEN_STRING_INITIALIZER
14608 (struct cmd_vf_allmulti_result,
14610 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
14611 TOKEN_STRING_INITIALIZER
14612 (struct cmd_vf_allmulti_result,
14614 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
14615 TOKEN_STRING_INITIALIZER
14616 (struct cmd_vf_allmulti_result,
14617 allmulti, "allmulti");
14618 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
14619 TOKEN_NUM_INITIALIZER
14620 (struct cmd_vf_allmulti_result,
14622 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
14623 TOKEN_NUM_INITIALIZER
14624 (struct cmd_vf_allmulti_result,
14626 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
14627 TOKEN_STRING_INITIALIZER
14628 (struct cmd_vf_allmulti_result,
14632 cmd_set_vf_allmulti_parsed(
14633 void *parsed_result,
14634 __rte_unused struct cmdline *cl,
14635 __rte_unused void *data)
14637 struct cmd_vf_allmulti_result *res = parsed_result;
14638 int ret = -ENOTSUP;
14640 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14642 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14645 #ifdef RTE_NET_I40E
14646 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
14647 res->vf_id, is_on);
14654 printf("invalid vf_id %d\n", res->vf_id);
14657 printf("invalid port_id %d\n", res->port_id);
14660 printf("function not implemented\n");
14663 printf("programming error: (%s)\n", strerror(-ret));
14667 cmdline_parse_inst_t cmd_set_vf_allmulti = {
14668 .f = cmd_set_vf_allmulti_parsed,
14670 .help_str = "set vf allmulti <port_id> <vf_id> on|off: "
14671 "Set multicast promiscuous mode for a VF from the PF",
14673 (void *)&cmd_vf_allmulti_set,
14674 (void *)&cmd_vf_allmulti_vf,
14675 (void *)&cmd_vf_allmulti_allmulti,
14676 (void *)&cmd_vf_allmulti_port_id,
14677 (void *)&cmd_vf_allmulti_vf_id,
14678 (void *)&cmd_vf_allmulti_on_off,
14683 /* vf broadcast mode configuration */
14685 /* Common result structure for vf broadcast */
14686 struct cmd_set_vf_broadcast_result {
14687 cmdline_fixed_string_t set;
14688 cmdline_fixed_string_t vf;
14689 cmdline_fixed_string_t broadcast;
14692 cmdline_fixed_string_t on_off;
14695 /* Common CLI fields for vf broadcast enable disable */
14696 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
14697 TOKEN_STRING_INITIALIZER
14698 (struct cmd_set_vf_broadcast_result,
14700 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
14701 TOKEN_STRING_INITIALIZER
14702 (struct cmd_set_vf_broadcast_result,
14704 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
14705 TOKEN_STRING_INITIALIZER
14706 (struct cmd_set_vf_broadcast_result,
14707 broadcast, "broadcast");
14708 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
14709 TOKEN_NUM_INITIALIZER
14710 (struct cmd_set_vf_broadcast_result,
14712 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
14713 TOKEN_NUM_INITIALIZER
14714 (struct cmd_set_vf_broadcast_result,
14716 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
14717 TOKEN_STRING_INITIALIZER
14718 (struct cmd_set_vf_broadcast_result,
14722 cmd_set_vf_broadcast_parsed(
14723 void *parsed_result,
14724 __rte_unused struct cmdline *cl,
14725 __rte_unused void *data)
14727 struct cmd_set_vf_broadcast_result *res = parsed_result;
14728 int ret = -ENOTSUP;
14730 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14732 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14735 #ifdef RTE_NET_I40E
14736 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
14737 res->vf_id, is_on);
14744 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
14747 printf("invalid port_id %d\n", res->port_id);
14750 printf("function not implemented\n");
14753 printf("programming error: (%s)\n", strerror(-ret));
14757 cmdline_parse_inst_t cmd_set_vf_broadcast = {
14758 .f = cmd_set_vf_broadcast_parsed,
14760 .help_str = "set vf broadcast <port_id> <vf_id> on|off",
14762 (void *)&cmd_set_vf_broadcast_set,
14763 (void *)&cmd_set_vf_broadcast_vf,
14764 (void *)&cmd_set_vf_broadcast_broadcast,
14765 (void *)&cmd_set_vf_broadcast_port_id,
14766 (void *)&cmd_set_vf_broadcast_vf_id,
14767 (void *)&cmd_set_vf_broadcast_on_off,
14772 /* vf vlan tag configuration */
14774 /* Common result structure for vf vlan tag */
14775 struct cmd_set_vf_vlan_tag_result {
14776 cmdline_fixed_string_t set;
14777 cmdline_fixed_string_t vf;
14778 cmdline_fixed_string_t vlan;
14779 cmdline_fixed_string_t tag;
14782 cmdline_fixed_string_t on_off;
14785 /* Common CLI fields for vf vlan tag enable disable */
14786 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
14787 TOKEN_STRING_INITIALIZER
14788 (struct cmd_set_vf_vlan_tag_result,
14790 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
14791 TOKEN_STRING_INITIALIZER
14792 (struct cmd_set_vf_vlan_tag_result,
14794 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
14795 TOKEN_STRING_INITIALIZER
14796 (struct cmd_set_vf_vlan_tag_result,
14798 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
14799 TOKEN_STRING_INITIALIZER
14800 (struct cmd_set_vf_vlan_tag_result,
14802 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
14803 TOKEN_NUM_INITIALIZER
14804 (struct cmd_set_vf_vlan_tag_result,
14806 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
14807 TOKEN_NUM_INITIALIZER
14808 (struct cmd_set_vf_vlan_tag_result,
14810 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
14811 TOKEN_STRING_INITIALIZER
14812 (struct cmd_set_vf_vlan_tag_result,
14816 cmd_set_vf_vlan_tag_parsed(
14817 void *parsed_result,
14818 __rte_unused struct cmdline *cl,
14819 __rte_unused void *data)
14821 struct cmd_set_vf_vlan_tag_result *res = parsed_result;
14822 int ret = -ENOTSUP;
14824 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14826 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14829 #ifdef RTE_NET_I40E
14830 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
14831 res->vf_id, is_on);
14838 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
14841 printf("invalid port_id %d\n", res->port_id);
14844 printf("function not implemented\n");
14847 printf("programming error: (%s)\n", strerror(-ret));
14851 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
14852 .f = cmd_set_vf_vlan_tag_parsed,
14854 .help_str = "set vf vlan tag <port_id> <vf_id> on|off",
14856 (void *)&cmd_set_vf_vlan_tag_set,
14857 (void *)&cmd_set_vf_vlan_tag_vf,
14858 (void *)&cmd_set_vf_vlan_tag_vlan,
14859 (void *)&cmd_set_vf_vlan_tag_tag,
14860 (void *)&cmd_set_vf_vlan_tag_port_id,
14861 (void *)&cmd_set_vf_vlan_tag_vf_id,
14862 (void *)&cmd_set_vf_vlan_tag_on_off,
14867 /* Common definition of VF and TC TX bandwidth configuration */
14868 struct cmd_vf_tc_bw_result {
14869 cmdline_fixed_string_t set;
14870 cmdline_fixed_string_t vf;
14871 cmdline_fixed_string_t tc;
14872 cmdline_fixed_string_t tx;
14873 cmdline_fixed_string_t min_bw;
14874 cmdline_fixed_string_t max_bw;
14875 cmdline_fixed_string_t strict_link_prio;
14880 cmdline_fixed_string_t bw_list;
14884 cmdline_parse_token_string_t cmd_vf_tc_bw_set =
14885 TOKEN_STRING_INITIALIZER
14886 (struct cmd_vf_tc_bw_result,
14888 cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
14889 TOKEN_STRING_INITIALIZER
14890 (struct cmd_vf_tc_bw_result,
14892 cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
14893 TOKEN_STRING_INITIALIZER
14894 (struct cmd_vf_tc_bw_result,
14896 cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
14897 TOKEN_STRING_INITIALIZER
14898 (struct cmd_vf_tc_bw_result,
14900 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio =
14901 TOKEN_STRING_INITIALIZER
14902 (struct cmd_vf_tc_bw_result,
14903 strict_link_prio, "strict-link-priority");
14904 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw =
14905 TOKEN_STRING_INITIALIZER
14906 (struct cmd_vf_tc_bw_result,
14907 min_bw, "min-bandwidth");
14908 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
14909 TOKEN_STRING_INITIALIZER
14910 (struct cmd_vf_tc_bw_result,
14911 max_bw, "max-bandwidth");
14912 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
14913 TOKEN_NUM_INITIALIZER
14914 (struct cmd_vf_tc_bw_result,
14916 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
14917 TOKEN_NUM_INITIALIZER
14918 (struct cmd_vf_tc_bw_result,
14920 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no =
14921 TOKEN_NUM_INITIALIZER
14922 (struct cmd_vf_tc_bw_result,
14924 cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
14925 TOKEN_NUM_INITIALIZER
14926 (struct cmd_vf_tc_bw_result,
14928 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
14929 TOKEN_STRING_INITIALIZER
14930 (struct cmd_vf_tc_bw_result,
14932 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map =
14933 TOKEN_NUM_INITIALIZER
14934 (struct cmd_vf_tc_bw_result,
14937 /* VF max bandwidth setting */
14939 cmd_vf_max_bw_parsed(
14940 void *parsed_result,
14941 __rte_unused struct cmdline *cl,
14942 __rte_unused void *data)
14944 struct cmd_vf_tc_bw_result *res = parsed_result;
14945 int ret = -ENOTSUP;
14947 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14950 #ifdef RTE_NET_I40E
14951 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id,
14952 res->vf_id, res->bw);
14959 printf("invalid vf_id %d or bandwidth %d\n",
14960 res->vf_id, res->bw);
14963 printf("invalid port_id %d\n", res->port_id);
14966 printf("function not implemented\n");
14969 printf("programming error: (%s)\n", strerror(-ret));
14973 cmdline_parse_inst_t cmd_vf_max_bw = {
14974 .f = cmd_vf_max_bw_parsed,
14976 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
14978 (void *)&cmd_vf_tc_bw_set,
14979 (void *)&cmd_vf_tc_bw_vf,
14980 (void *)&cmd_vf_tc_bw_tx,
14981 (void *)&cmd_vf_tc_bw_max_bw,
14982 (void *)&cmd_vf_tc_bw_port_id,
14983 (void *)&cmd_vf_tc_bw_vf_id,
14984 (void *)&cmd_vf_tc_bw_bw,
14990 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
14995 const char *p, *p0 = str;
15002 p = strchr(p0, '(');
15004 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
15008 p0 = strchr(p, ')');
15010 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
15014 if (size >= sizeof(s)) {
15015 printf("The string size exceeds the internal buffer size\n");
15018 snprintf(s, sizeof(s), "%.*s", size, p);
15019 ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
15021 printf("Failed to get the bandwidth list. ");
15025 for (i = 0; i < ret; i++)
15026 bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
15031 /* TC min bandwidth setting */
15033 cmd_vf_tc_min_bw_parsed(
15034 void *parsed_result,
15035 __rte_unused struct cmdline *cl,
15036 __rte_unused void *data)
15038 struct cmd_vf_tc_bw_result *res = parsed_result;
15041 int ret = -ENOTSUP;
15043 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15046 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
15050 #ifdef RTE_NET_I40E
15051 ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
15059 printf("invalid vf_id %d or bandwidth\n", res->vf_id);
15062 printf("invalid port_id %d\n", res->port_id);
15065 printf("function not implemented\n");
15068 printf("programming error: (%s)\n", strerror(-ret));
15072 cmdline_parse_inst_t cmd_vf_tc_min_bw = {
15073 .f = cmd_vf_tc_min_bw_parsed,
15075 .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
15076 " <bw1, bw2, ...>",
15078 (void *)&cmd_vf_tc_bw_set,
15079 (void *)&cmd_vf_tc_bw_vf,
15080 (void *)&cmd_vf_tc_bw_tc,
15081 (void *)&cmd_vf_tc_bw_tx,
15082 (void *)&cmd_vf_tc_bw_min_bw,
15083 (void *)&cmd_vf_tc_bw_port_id,
15084 (void *)&cmd_vf_tc_bw_vf_id,
15085 (void *)&cmd_vf_tc_bw_bw_list,
15091 cmd_tc_min_bw_parsed(
15092 void *parsed_result,
15093 __rte_unused struct cmdline *cl,
15094 __rte_unused void *data)
15096 struct cmd_vf_tc_bw_result *res = parsed_result;
15097 struct rte_port *port;
15100 int ret = -ENOTSUP;
15102 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15105 port = &ports[res->port_id];
15106 /** Check if the port is not started **/
15107 if (port->port_status != RTE_PORT_STOPPED) {
15108 printf("Please stop port %d first\n", res->port_id);
15112 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
15116 #ifdef RTE_NET_IXGBE
15117 ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw);
15124 printf("invalid bandwidth\n");
15127 printf("invalid port_id %d\n", res->port_id);
15130 printf("function not implemented\n");
15133 printf("programming error: (%s)\n", strerror(-ret));
15137 cmdline_parse_inst_t cmd_tc_min_bw = {
15138 .f = cmd_tc_min_bw_parsed,
15140 .help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>",
15142 (void *)&cmd_vf_tc_bw_set,
15143 (void *)&cmd_vf_tc_bw_tc,
15144 (void *)&cmd_vf_tc_bw_tx,
15145 (void *)&cmd_vf_tc_bw_min_bw,
15146 (void *)&cmd_vf_tc_bw_port_id,
15147 (void *)&cmd_vf_tc_bw_bw_list,
15152 /* TC max bandwidth setting */
15154 cmd_vf_tc_max_bw_parsed(
15155 void *parsed_result,
15156 __rte_unused struct cmdline *cl,
15157 __rte_unused void *data)
15159 struct cmd_vf_tc_bw_result *res = parsed_result;
15160 int ret = -ENOTSUP;
15162 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15165 #ifdef RTE_NET_I40E
15166 ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id,
15167 res->tc_no, res->bw);
15174 printf("invalid vf_id %d, tc_no %d or bandwidth %d\n",
15175 res->vf_id, res->tc_no, res->bw);
15178 printf("invalid port_id %d\n", res->port_id);
15181 printf("function not implemented\n");
15184 printf("programming error: (%s)\n", strerror(-ret));
15188 cmdline_parse_inst_t cmd_vf_tc_max_bw = {
15189 .f = cmd_vf_tc_max_bw_parsed,
15191 .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>"
15194 (void *)&cmd_vf_tc_bw_set,
15195 (void *)&cmd_vf_tc_bw_vf,
15196 (void *)&cmd_vf_tc_bw_tc,
15197 (void *)&cmd_vf_tc_bw_tx,
15198 (void *)&cmd_vf_tc_bw_max_bw,
15199 (void *)&cmd_vf_tc_bw_port_id,
15200 (void *)&cmd_vf_tc_bw_vf_id,
15201 (void *)&cmd_vf_tc_bw_tc_no,
15202 (void *)&cmd_vf_tc_bw_bw,
15207 /** Set VXLAN encapsulation details */
15208 struct cmd_set_vxlan_result {
15209 cmdline_fixed_string_t set;
15210 cmdline_fixed_string_t vxlan;
15211 cmdline_fixed_string_t pos_token;
15212 cmdline_fixed_string_t ip_version;
15213 uint32_t vlan_present:1;
15217 cmdline_ipaddr_t ip_src;
15218 cmdline_ipaddr_t ip_dst;
15222 struct rte_ether_addr eth_src;
15223 struct rte_ether_addr eth_dst;
15226 cmdline_parse_token_string_t cmd_set_vxlan_set =
15227 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, set, "set");
15228 cmdline_parse_token_string_t cmd_set_vxlan_vxlan =
15229 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan, "vxlan");
15230 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_tos_ttl =
15231 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
15233 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_with_vlan =
15234 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
15235 "vxlan-with-vlan");
15236 cmdline_parse_token_string_t cmd_set_vxlan_ip_version =
15237 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15239 cmdline_parse_token_string_t cmd_set_vxlan_ip_version_value =
15240 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, ip_version,
15242 cmdline_parse_token_string_t cmd_set_vxlan_vni =
15243 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15245 cmdline_parse_token_num_t cmd_set_vxlan_vni_value =
15246 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, vni, UINT32);
15247 cmdline_parse_token_string_t cmd_set_vxlan_udp_src =
15248 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15250 cmdline_parse_token_num_t cmd_set_vxlan_udp_src_value =
15251 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_src, UINT16);
15252 cmdline_parse_token_string_t cmd_set_vxlan_udp_dst =
15253 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15255 cmdline_parse_token_num_t cmd_set_vxlan_udp_dst_value =
15256 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_dst, UINT16);
15257 cmdline_parse_token_string_t cmd_set_vxlan_ip_tos =
15258 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15260 cmdline_parse_token_num_t cmd_set_vxlan_ip_tos_value =
15261 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tos, UINT8);
15262 cmdline_parse_token_string_t cmd_set_vxlan_ip_ttl =
15263 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15265 cmdline_parse_token_num_t cmd_set_vxlan_ip_ttl_value =
15266 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, ttl, UINT8);
15267 cmdline_parse_token_string_t cmd_set_vxlan_ip_src =
15268 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15270 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_src_value =
15271 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_src);
15272 cmdline_parse_token_string_t cmd_set_vxlan_ip_dst =
15273 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15275 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_dst_value =
15276 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_dst);
15277 cmdline_parse_token_string_t cmd_set_vxlan_vlan =
15278 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15280 cmdline_parse_token_num_t cmd_set_vxlan_vlan_value =
15281 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tci, UINT16);
15282 cmdline_parse_token_string_t cmd_set_vxlan_eth_src =
15283 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15285 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_src_value =
15286 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_src);
15287 cmdline_parse_token_string_t cmd_set_vxlan_eth_dst =
15288 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15290 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_dst_value =
15291 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_dst);
15293 static void cmd_set_vxlan_parsed(void *parsed_result,
15294 __rte_unused struct cmdline *cl,
15295 __rte_unused void *data)
15297 struct cmd_set_vxlan_result *res = parsed_result;
15302 .vxlan_id = rte_cpu_to_be_32(res->vni) & RTE_BE32(0x00ffffff),
15305 vxlan_encap_conf.select_tos_ttl = 0;
15306 if (strcmp(res->vxlan, "vxlan") == 0)
15307 vxlan_encap_conf.select_vlan = 0;
15308 else if (strcmp(res->vxlan, "vxlan-with-vlan") == 0)
15309 vxlan_encap_conf.select_vlan = 1;
15310 else if (strcmp(res->vxlan, "vxlan-tos-ttl") == 0) {
15311 vxlan_encap_conf.select_vlan = 0;
15312 vxlan_encap_conf.select_tos_ttl = 1;
15314 if (strcmp(res->ip_version, "ipv4") == 0)
15315 vxlan_encap_conf.select_ipv4 = 1;
15316 else if (strcmp(res->ip_version, "ipv6") == 0)
15317 vxlan_encap_conf.select_ipv4 = 0;
15320 rte_memcpy(vxlan_encap_conf.vni, &id.vni[1], 3);
15321 vxlan_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
15322 vxlan_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
15323 vxlan_encap_conf.ip_tos = res->tos;
15324 vxlan_encap_conf.ip_ttl = res->ttl;
15325 if (vxlan_encap_conf.select_ipv4) {
15326 IPV4_ADDR_TO_UINT(res->ip_src, vxlan_encap_conf.ipv4_src);
15327 IPV4_ADDR_TO_UINT(res->ip_dst, vxlan_encap_conf.ipv4_dst);
15329 IPV6_ADDR_TO_ARRAY(res->ip_src, vxlan_encap_conf.ipv6_src);
15330 IPV6_ADDR_TO_ARRAY(res->ip_dst, vxlan_encap_conf.ipv6_dst);
15332 if (vxlan_encap_conf.select_vlan)
15333 vxlan_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15334 rte_memcpy(vxlan_encap_conf.eth_src, res->eth_src.addr_bytes,
15335 RTE_ETHER_ADDR_LEN);
15336 rte_memcpy(vxlan_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15337 RTE_ETHER_ADDR_LEN);
15340 cmdline_parse_inst_t cmd_set_vxlan = {
15341 .f = cmd_set_vxlan_parsed,
15343 .help_str = "set vxlan ip-version ipv4|ipv6 vni <vni> udp-src"
15344 " <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst <ip-dst>"
15345 " eth-src <eth-src> eth-dst <eth-dst>",
15347 (void *)&cmd_set_vxlan_set,
15348 (void *)&cmd_set_vxlan_vxlan,
15349 (void *)&cmd_set_vxlan_ip_version,
15350 (void *)&cmd_set_vxlan_ip_version_value,
15351 (void *)&cmd_set_vxlan_vni,
15352 (void *)&cmd_set_vxlan_vni_value,
15353 (void *)&cmd_set_vxlan_udp_src,
15354 (void *)&cmd_set_vxlan_udp_src_value,
15355 (void *)&cmd_set_vxlan_udp_dst,
15356 (void *)&cmd_set_vxlan_udp_dst_value,
15357 (void *)&cmd_set_vxlan_ip_src,
15358 (void *)&cmd_set_vxlan_ip_src_value,
15359 (void *)&cmd_set_vxlan_ip_dst,
15360 (void *)&cmd_set_vxlan_ip_dst_value,
15361 (void *)&cmd_set_vxlan_eth_src,
15362 (void *)&cmd_set_vxlan_eth_src_value,
15363 (void *)&cmd_set_vxlan_eth_dst,
15364 (void *)&cmd_set_vxlan_eth_dst_value,
15369 cmdline_parse_inst_t cmd_set_vxlan_tos_ttl = {
15370 .f = cmd_set_vxlan_parsed,
15372 .help_str = "set vxlan-tos-ttl ip-version ipv4|ipv6 vni <vni> udp-src"
15373 " <udp-src> udp-dst <udp-dst> ip-tos <ip-tos> ip-ttl <ip-ttl>"
15374 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
15375 " eth-dst <eth-dst>",
15377 (void *)&cmd_set_vxlan_set,
15378 (void *)&cmd_set_vxlan_vxlan_tos_ttl,
15379 (void *)&cmd_set_vxlan_ip_version,
15380 (void *)&cmd_set_vxlan_ip_version_value,
15381 (void *)&cmd_set_vxlan_vni,
15382 (void *)&cmd_set_vxlan_vni_value,
15383 (void *)&cmd_set_vxlan_udp_src,
15384 (void *)&cmd_set_vxlan_udp_src_value,
15385 (void *)&cmd_set_vxlan_udp_dst,
15386 (void *)&cmd_set_vxlan_udp_dst_value,
15387 (void *)&cmd_set_vxlan_ip_tos,
15388 (void *)&cmd_set_vxlan_ip_tos_value,
15389 (void *)&cmd_set_vxlan_ip_ttl,
15390 (void *)&cmd_set_vxlan_ip_ttl_value,
15391 (void *)&cmd_set_vxlan_ip_src,
15392 (void *)&cmd_set_vxlan_ip_src_value,
15393 (void *)&cmd_set_vxlan_ip_dst,
15394 (void *)&cmd_set_vxlan_ip_dst_value,
15395 (void *)&cmd_set_vxlan_eth_src,
15396 (void *)&cmd_set_vxlan_eth_src_value,
15397 (void *)&cmd_set_vxlan_eth_dst,
15398 (void *)&cmd_set_vxlan_eth_dst_value,
15403 cmdline_parse_inst_t cmd_set_vxlan_with_vlan = {
15404 .f = cmd_set_vxlan_parsed,
15406 .help_str = "set vxlan-with-vlan ip-version ipv4|ipv6 vni <vni>"
15407 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst"
15408 " <ip-dst> vlan-tci <vlan-tci> eth-src <eth-src> eth-dst"
15411 (void *)&cmd_set_vxlan_set,
15412 (void *)&cmd_set_vxlan_vxlan_with_vlan,
15413 (void *)&cmd_set_vxlan_ip_version,
15414 (void *)&cmd_set_vxlan_ip_version_value,
15415 (void *)&cmd_set_vxlan_vni,
15416 (void *)&cmd_set_vxlan_vni_value,
15417 (void *)&cmd_set_vxlan_udp_src,
15418 (void *)&cmd_set_vxlan_udp_src_value,
15419 (void *)&cmd_set_vxlan_udp_dst,
15420 (void *)&cmd_set_vxlan_udp_dst_value,
15421 (void *)&cmd_set_vxlan_ip_src,
15422 (void *)&cmd_set_vxlan_ip_src_value,
15423 (void *)&cmd_set_vxlan_ip_dst,
15424 (void *)&cmd_set_vxlan_ip_dst_value,
15425 (void *)&cmd_set_vxlan_vlan,
15426 (void *)&cmd_set_vxlan_vlan_value,
15427 (void *)&cmd_set_vxlan_eth_src,
15428 (void *)&cmd_set_vxlan_eth_src_value,
15429 (void *)&cmd_set_vxlan_eth_dst,
15430 (void *)&cmd_set_vxlan_eth_dst_value,
15435 /** Set NVGRE encapsulation details */
15436 struct cmd_set_nvgre_result {
15437 cmdline_fixed_string_t set;
15438 cmdline_fixed_string_t nvgre;
15439 cmdline_fixed_string_t pos_token;
15440 cmdline_fixed_string_t ip_version;
15442 cmdline_ipaddr_t ip_src;
15443 cmdline_ipaddr_t ip_dst;
15445 struct rte_ether_addr eth_src;
15446 struct rte_ether_addr eth_dst;
15449 cmdline_parse_token_string_t cmd_set_nvgre_set =
15450 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, set, "set");
15451 cmdline_parse_token_string_t cmd_set_nvgre_nvgre =
15452 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre, "nvgre");
15453 cmdline_parse_token_string_t cmd_set_nvgre_nvgre_with_vlan =
15454 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre,
15455 "nvgre-with-vlan");
15456 cmdline_parse_token_string_t cmd_set_nvgre_ip_version =
15457 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15459 cmdline_parse_token_string_t cmd_set_nvgre_ip_version_value =
15460 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, ip_version,
15462 cmdline_parse_token_string_t cmd_set_nvgre_tni =
15463 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15465 cmdline_parse_token_num_t cmd_set_nvgre_tni_value =
15466 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tni, UINT32);
15467 cmdline_parse_token_string_t cmd_set_nvgre_ip_src =
15468 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15470 cmdline_parse_token_num_t cmd_set_nvgre_ip_src_value =
15471 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_src);
15472 cmdline_parse_token_string_t cmd_set_nvgre_ip_dst =
15473 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15475 cmdline_parse_token_ipaddr_t cmd_set_nvgre_ip_dst_value =
15476 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_dst);
15477 cmdline_parse_token_string_t cmd_set_nvgre_vlan =
15478 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15480 cmdline_parse_token_num_t cmd_set_nvgre_vlan_value =
15481 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tci, UINT16);
15482 cmdline_parse_token_string_t cmd_set_nvgre_eth_src =
15483 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15485 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_src_value =
15486 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_src);
15487 cmdline_parse_token_string_t cmd_set_nvgre_eth_dst =
15488 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15490 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_dst_value =
15491 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_dst);
15493 static void cmd_set_nvgre_parsed(void *parsed_result,
15494 __rte_unused struct cmdline *cl,
15495 __rte_unused void *data)
15497 struct cmd_set_nvgre_result *res = parsed_result;
15499 uint32_t nvgre_tni;
15502 .nvgre_tni = rte_cpu_to_be_32(res->tni) & RTE_BE32(0x00ffffff),
15505 if (strcmp(res->nvgre, "nvgre") == 0)
15506 nvgre_encap_conf.select_vlan = 0;
15507 else if (strcmp(res->nvgre, "nvgre-with-vlan") == 0)
15508 nvgre_encap_conf.select_vlan = 1;
15509 if (strcmp(res->ip_version, "ipv4") == 0)
15510 nvgre_encap_conf.select_ipv4 = 1;
15511 else if (strcmp(res->ip_version, "ipv6") == 0)
15512 nvgre_encap_conf.select_ipv4 = 0;
15515 rte_memcpy(nvgre_encap_conf.tni, &id.tni[1], 3);
15516 if (nvgre_encap_conf.select_ipv4) {
15517 IPV4_ADDR_TO_UINT(res->ip_src, nvgre_encap_conf.ipv4_src);
15518 IPV4_ADDR_TO_UINT(res->ip_dst, nvgre_encap_conf.ipv4_dst);
15520 IPV6_ADDR_TO_ARRAY(res->ip_src, nvgre_encap_conf.ipv6_src);
15521 IPV6_ADDR_TO_ARRAY(res->ip_dst, nvgre_encap_conf.ipv6_dst);
15523 if (nvgre_encap_conf.select_vlan)
15524 nvgre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15525 rte_memcpy(nvgre_encap_conf.eth_src, res->eth_src.addr_bytes,
15526 RTE_ETHER_ADDR_LEN);
15527 rte_memcpy(nvgre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15528 RTE_ETHER_ADDR_LEN);
15531 cmdline_parse_inst_t cmd_set_nvgre = {
15532 .f = cmd_set_nvgre_parsed,
15534 .help_str = "set nvgre ip-version <ipv4|ipv6> tni <tni> ip-src"
15535 " <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
15536 " eth-dst <eth-dst>",
15538 (void *)&cmd_set_nvgre_set,
15539 (void *)&cmd_set_nvgre_nvgre,
15540 (void *)&cmd_set_nvgre_ip_version,
15541 (void *)&cmd_set_nvgre_ip_version_value,
15542 (void *)&cmd_set_nvgre_tni,
15543 (void *)&cmd_set_nvgre_tni_value,
15544 (void *)&cmd_set_nvgre_ip_src,
15545 (void *)&cmd_set_nvgre_ip_src_value,
15546 (void *)&cmd_set_nvgre_ip_dst,
15547 (void *)&cmd_set_nvgre_ip_dst_value,
15548 (void *)&cmd_set_nvgre_eth_src,
15549 (void *)&cmd_set_nvgre_eth_src_value,
15550 (void *)&cmd_set_nvgre_eth_dst,
15551 (void *)&cmd_set_nvgre_eth_dst_value,
15556 cmdline_parse_inst_t cmd_set_nvgre_with_vlan = {
15557 .f = cmd_set_nvgre_parsed,
15559 .help_str = "set nvgre-with-vlan ip-version <ipv4|ipv6> tni <tni>"
15560 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
15561 " eth-src <eth-src> eth-dst <eth-dst>",
15563 (void *)&cmd_set_nvgre_set,
15564 (void *)&cmd_set_nvgre_nvgre_with_vlan,
15565 (void *)&cmd_set_nvgre_ip_version,
15566 (void *)&cmd_set_nvgre_ip_version_value,
15567 (void *)&cmd_set_nvgre_tni,
15568 (void *)&cmd_set_nvgre_tni_value,
15569 (void *)&cmd_set_nvgre_ip_src,
15570 (void *)&cmd_set_nvgre_ip_src_value,
15571 (void *)&cmd_set_nvgre_ip_dst,
15572 (void *)&cmd_set_nvgre_ip_dst_value,
15573 (void *)&cmd_set_nvgre_vlan,
15574 (void *)&cmd_set_nvgre_vlan_value,
15575 (void *)&cmd_set_nvgre_eth_src,
15576 (void *)&cmd_set_nvgre_eth_src_value,
15577 (void *)&cmd_set_nvgre_eth_dst,
15578 (void *)&cmd_set_nvgre_eth_dst_value,
15583 /** Set L2 encapsulation details */
15584 struct cmd_set_l2_encap_result {
15585 cmdline_fixed_string_t set;
15586 cmdline_fixed_string_t l2_encap;
15587 cmdline_fixed_string_t pos_token;
15588 cmdline_fixed_string_t ip_version;
15589 uint32_t vlan_present:1;
15591 struct rte_ether_addr eth_src;
15592 struct rte_ether_addr eth_dst;
15595 cmdline_parse_token_string_t cmd_set_l2_encap_set =
15596 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, set, "set");
15597 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap =
15598 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap, "l2_encap");
15599 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap_with_vlan =
15600 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap,
15601 "l2_encap-with-vlan");
15602 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version =
15603 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15605 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version_value =
15606 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, ip_version,
15608 cmdline_parse_token_string_t cmd_set_l2_encap_vlan =
15609 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15611 cmdline_parse_token_num_t cmd_set_l2_encap_vlan_value =
15612 TOKEN_NUM_INITIALIZER(struct cmd_set_l2_encap_result, tci, UINT16);
15613 cmdline_parse_token_string_t cmd_set_l2_encap_eth_src =
15614 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15616 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_src_value =
15617 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_src);
15618 cmdline_parse_token_string_t cmd_set_l2_encap_eth_dst =
15619 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15621 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_dst_value =
15622 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_dst);
15624 static void cmd_set_l2_encap_parsed(void *parsed_result,
15625 __rte_unused struct cmdline *cl,
15626 __rte_unused void *data)
15628 struct cmd_set_l2_encap_result *res = parsed_result;
15630 if (strcmp(res->l2_encap, "l2_encap") == 0)
15631 l2_encap_conf.select_vlan = 0;
15632 else if (strcmp(res->l2_encap, "l2_encap-with-vlan") == 0)
15633 l2_encap_conf.select_vlan = 1;
15634 if (strcmp(res->ip_version, "ipv4") == 0)
15635 l2_encap_conf.select_ipv4 = 1;
15636 else if (strcmp(res->ip_version, "ipv6") == 0)
15637 l2_encap_conf.select_ipv4 = 0;
15640 if (l2_encap_conf.select_vlan)
15641 l2_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15642 rte_memcpy(l2_encap_conf.eth_src, res->eth_src.addr_bytes,
15643 RTE_ETHER_ADDR_LEN);
15644 rte_memcpy(l2_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15645 RTE_ETHER_ADDR_LEN);
15648 cmdline_parse_inst_t cmd_set_l2_encap = {
15649 .f = cmd_set_l2_encap_parsed,
15651 .help_str = "set l2_encap ip-version ipv4|ipv6"
15652 " eth-src <eth-src> eth-dst <eth-dst>",
15654 (void *)&cmd_set_l2_encap_set,
15655 (void *)&cmd_set_l2_encap_l2_encap,
15656 (void *)&cmd_set_l2_encap_ip_version,
15657 (void *)&cmd_set_l2_encap_ip_version_value,
15658 (void *)&cmd_set_l2_encap_eth_src,
15659 (void *)&cmd_set_l2_encap_eth_src_value,
15660 (void *)&cmd_set_l2_encap_eth_dst,
15661 (void *)&cmd_set_l2_encap_eth_dst_value,
15666 cmdline_parse_inst_t cmd_set_l2_encap_with_vlan = {
15667 .f = cmd_set_l2_encap_parsed,
15669 .help_str = "set l2_encap-with-vlan ip-version ipv4|ipv6"
15670 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
15672 (void *)&cmd_set_l2_encap_set,
15673 (void *)&cmd_set_l2_encap_l2_encap_with_vlan,
15674 (void *)&cmd_set_l2_encap_ip_version,
15675 (void *)&cmd_set_l2_encap_ip_version_value,
15676 (void *)&cmd_set_l2_encap_vlan,
15677 (void *)&cmd_set_l2_encap_vlan_value,
15678 (void *)&cmd_set_l2_encap_eth_src,
15679 (void *)&cmd_set_l2_encap_eth_src_value,
15680 (void *)&cmd_set_l2_encap_eth_dst,
15681 (void *)&cmd_set_l2_encap_eth_dst_value,
15686 /** Set L2 decapsulation details */
15687 struct cmd_set_l2_decap_result {
15688 cmdline_fixed_string_t set;
15689 cmdline_fixed_string_t l2_decap;
15690 cmdline_fixed_string_t pos_token;
15691 uint32_t vlan_present:1;
15694 cmdline_parse_token_string_t cmd_set_l2_decap_set =
15695 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, set, "set");
15696 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap =
15697 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
15699 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap_with_vlan =
15700 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
15701 "l2_decap-with-vlan");
15703 static void cmd_set_l2_decap_parsed(void *parsed_result,
15704 __rte_unused struct cmdline *cl,
15705 __rte_unused void *data)
15707 struct cmd_set_l2_decap_result *res = parsed_result;
15709 if (strcmp(res->l2_decap, "l2_decap") == 0)
15710 l2_decap_conf.select_vlan = 0;
15711 else if (strcmp(res->l2_decap, "l2_decap-with-vlan") == 0)
15712 l2_decap_conf.select_vlan = 1;
15715 cmdline_parse_inst_t cmd_set_l2_decap = {
15716 .f = cmd_set_l2_decap_parsed,
15718 .help_str = "set l2_decap",
15720 (void *)&cmd_set_l2_decap_set,
15721 (void *)&cmd_set_l2_decap_l2_decap,
15726 cmdline_parse_inst_t cmd_set_l2_decap_with_vlan = {
15727 .f = cmd_set_l2_decap_parsed,
15729 .help_str = "set l2_decap-with-vlan",
15731 (void *)&cmd_set_l2_decap_set,
15732 (void *)&cmd_set_l2_decap_l2_decap_with_vlan,
15737 /** Set MPLSoGRE encapsulation details */
15738 struct cmd_set_mplsogre_encap_result {
15739 cmdline_fixed_string_t set;
15740 cmdline_fixed_string_t mplsogre;
15741 cmdline_fixed_string_t pos_token;
15742 cmdline_fixed_string_t ip_version;
15743 uint32_t vlan_present:1;
15745 cmdline_ipaddr_t ip_src;
15746 cmdline_ipaddr_t ip_dst;
15748 struct rte_ether_addr eth_src;
15749 struct rte_ether_addr eth_dst;
15752 cmdline_parse_token_string_t cmd_set_mplsogre_encap_set =
15753 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, set,
15755 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap =
15756 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, mplsogre,
15758 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap_with_vlan =
15759 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15760 mplsogre, "mplsogre_encap-with-vlan");
15761 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version =
15762 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15763 pos_token, "ip-version");
15764 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version_value =
15765 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15766 ip_version, "ipv4#ipv6");
15767 cmdline_parse_token_string_t cmd_set_mplsogre_encap_label =
15768 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15769 pos_token, "label");
15770 cmdline_parse_token_num_t cmd_set_mplsogre_encap_label_value =
15771 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, label,
15773 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_src =
15774 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15775 pos_token, "ip-src");
15776 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_src_value =
15777 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_src);
15778 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_dst =
15779 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15780 pos_token, "ip-dst");
15781 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_dst_value =
15782 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_dst);
15783 cmdline_parse_token_string_t cmd_set_mplsogre_encap_vlan =
15784 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15785 pos_token, "vlan-tci");
15786 cmdline_parse_token_num_t cmd_set_mplsogre_encap_vlan_value =
15787 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, tci,
15789 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_src =
15790 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15791 pos_token, "eth-src");
15792 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_src_value =
15793 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15795 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_dst =
15796 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15797 pos_token, "eth-dst");
15798 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_dst_value =
15799 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15802 static void cmd_set_mplsogre_encap_parsed(void *parsed_result,
15803 __rte_unused struct cmdline *cl,
15804 __rte_unused void *data)
15806 struct cmd_set_mplsogre_encap_result *res = parsed_result;
15808 uint32_t mplsogre_label;
15811 .mplsogre_label = rte_cpu_to_be_32(res->label<<12),
15814 if (strcmp(res->mplsogre, "mplsogre_encap") == 0)
15815 mplsogre_encap_conf.select_vlan = 0;
15816 else if (strcmp(res->mplsogre, "mplsogre_encap-with-vlan") == 0)
15817 mplsogre_encap_conf.select_vlan = 1;
15818 if (strcmp(res->ip_version, "ipv4") == 0)
15819 mplsogre_encap_conf.select_ipv4 = 1;
15820 else if (strcmp(res->ip_version, "ipv6") == 0)
15821 mplsogre_encap_conf.select_ipv4 = 0;
15824 rte_memcpy(mplsogre_encap_conf.label, &id.label, 3);
15825 if (mplsogre_encap_conf.select_ipv4) {
15826 IPV4_ADDR_TO_UINT(res->ip_src, mplsogre_encap_conf.ipv4_src);
15827 IPV4_ADDR_TO_UINT(res->ip_dst, mplsogre_encap_conf.ipv4_dst);
15829 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsogre_encap_conf.ipv6_src);
15830 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsogre_encap_conf.ipv6_dst);
15832 if (mplsogre_encap_conf.select_vlan)
15833 mplsogre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15834 rte_memcpy(mplsogre_encap_conf.eth_src, res->eth_src.addr_bytes,
15835 RTE_ETHER_ADDR_LEN);
15836 rte_memcpy(mplsogre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15837 RTE_ETHER_ADDR_LEN);
15840 cmdline_parse_inst_t cmd_set_mplsogre_encap = {
15841 .f = cmd_set_mplsogre_encap_parsed,
15843 .help_str = "set mplsogre_encap ip-version ipv4|ipv6 label <label>"
15844 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
15845 " eth-dst <eth-dst>",
15847 (void *)&cmd_set_mplsogre_encap_set,
15848 (void *)&cmd_set_mplsogre_encap_mplsogre_encap,
15849 (void *)&cmd_set_mplsogre_encap_ip_version,
15850 (void *)&cmd_set_mplsogre_encap_ip_version_value,
15851 (void *)&cmd_set_mplsogre_encap_label,
15852 (void *)&cmd_set_mplsogre_encap_label_value,
15853 (void *)&cmd_set_mplsogre_encap_ip_src,
15854 (void *)&cmd_set_mplsogre_encap_ip_src_value,
15855 (void *)&cmd_set_mplsogre_encap_ip_dst,
15856 (void *)&cmd_set_mplsogre_encap_ip_dst_value,
15857 (void *)&cmd_set_mplsogre_encap_eth_src,
15858 (void *)&cmd_set_mplsogre_encap_eth_src_value,
15859 (void *)&cmd_set_mplsogre_encap_eth_dst,
15860 (void *)&cmd_set_mplsogre_encap_eth_dst_value,
15865 cmdline_parse_inst_t cmd_set_mplsogre_encap_with_vlan = {
15866 .f = cmd_set_mplsogre_encap_parsed,
15868 .help_str = "set mplsogre_encap-with-vlan ip-version ipv4|ipv6"
15869 " label <label> ip-src <ip-src> ip-dst <ip-dst>"
15870 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
15872 (void *)&cmd_set_mplsogre_encap_set,
15873 (void *)&cmd_set_mplsogre_encap_mplsogre_encap_with_vlan,
15874 (void *)&cmd_set_mplsogre_encap_ip_version,
15875 (void *)&cmd_set_mplsogre_encap_ip_version_value,
15876 (void *)&cmd_set_mplsogre_encap_label,
15877 (void *)&cmd_set_mplsogre_encap_label_value,
15878 (void *)&cmd_set_mplsogre_encap_ip_src,
15879 (void *)&cmd_set_mplsogre_encap_ip_src_value,
15880 (void *)&cmd_set_mplsogre_encap_ip_dst,
15881 (void *)&cmd_set_mplsogre_encap_ip_dst_value,
15882 (void *)&cmd_set_mplsogre_encap_vlan,
15883 (void *)&cmd_set_mplsogre_encap_vlan_value,
15884 (void *)&cmd_set_mplsogre_encap_eth_src,
15885 (void *)&cmd_set_mplsogre_encap_eth_src_value,
15886 (void *)&cmd_set_mplsogre_encap_eth_dst,
15887 (void *)&cmd_set_mplsogre_encap_eth_dst_value,
15892 /** Set MPLSoGRE decapsulation details */
15893 struct cmd_set_mplsogre_decap_result {
15894 cmdline_fixed_string_t set;
15895 cmdline_fixed_string_t mplsogre;
15896 cmdline_fixed_string_t pos_token;
15897 cmdline_fixed_string_t ip_version;
15898 uint32_t vlan_present:1;
15901 cmdline_parse_token_string_t cmd_set_mplsogre_decap_set =
15902 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, set,
15904 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap =
15905 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, mplsogre,
15907 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap_with_vlan =
15908 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
15909 mplsogre, "mplsogre_decap-with-vlan");
15910 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version =
15911 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
15912 pos_token, "ip-version");
15913 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version_value =
15914 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
15915 ip_version, "ipv4#ipv6");
15917 static void cmd_set_mplsogre_decap_parsed(void *parsed_result,
15918 __rte_unused struct cmdline *cl,
15919 __rte_unused void *data)
15921 struct cmd_set_mplsogre_decap_result *res = parsed_result;
15923 if (strcmp(res->mplsogre, "mplsogre_decap") == 0)
15924 mplsogre_decap_conf.select_vlan = 0;
15925 else if (strcmp(res->mplsogre, "mplsogre_decap-with-vlan") == 0)
15926 mplsogre_decap_conf.select_vlan = 1;
15927 if (strcmp(res->ip_version, "ipv4") == 0)
15928 mplsogre_decap_conf.select_ipv4 = 1;
15929 else if (strcmp(res->ip_version, "ipv6") == 0)
15930 mplsogre_decap_conf.select_ipv4 = 0;
15933 cmdline_parse_inst_t cmd_set_mplsogre_decap = {
15934 .f = cmd_set_mplsogre_decap_parsed,
15936 .help_str = "set mplsogre_decap ip-version ipv4|ipv6",
15938 (void *)&cmd_set_mplsogre_decap_set,
15939 (void *)&cmd_set_mplsogre_decap_mplsogre_decap,
15940 (void *)&cmd_set_mplsogre_decap_ip_version,
15941 (void *)&cmd_set_mplsogre_decap_ip_version_value,
15946 cmdline_parse_inst_t cmd_set_mplsogre_decap_with_vlan = {
15947 .f = cmd_set_mplsogre_decap_parsed,
15949 .help_str = "set mplsogre_decap-with-vlan ip-version ipv4|ipv6",
15951 (void *)&cmd_set_mplsogre_decap_set,
15952 (void *)&cmd_set_mplsogre_decap_mplsogre_decap_with_vlan,
15953 (void *)&cmd_set_mplsogre_decap_ip_version,
15954 (void *)&cmd_set_mplsogre_decap_ip_version_value,
15959 /** Set MPLSoUDP encapsulation details */
15960 struct cmd_set_mplsoudp_encap_result {
15961 cmdline_fixed_string_t set;
15962 cmdline_fixed_string_t mplsoudp;
15963 cmdline_fixed_string_t pos_token;
15964 cmdline_fixed_string_t ip_version;
15965 uint32_t vlan_present:1;
15969 cmdline_ipaddr_t ip_src;
15970 cmdline_ipaddr_t ip_dst;
15972 struct rte_ether_addr eth_src;
15973 struct rte_ether_addr eth_dst;
15976 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_set =
15977 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, set,
15979 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap =
15980 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, mplsoudp,
15982 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan =
15983 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15984 mplsoudp, "mplsoudp_encap-with-vlan");
15985 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version =
15986 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15987 pos_token, "ip-version");
15988 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version_value =
15989 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15990 ip_version, "ipv4#ipv6");
15991 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_label =
15992 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15993 pos_token, "label");
15994 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_label_value =
15995 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, label,
15997 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_src =
15998 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15999 pos_token, "udp-src");
16000 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_src_value =
16001 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_src,
16003 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_dst =
16004 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16005 pos_token, "udp-dst");
16006 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_dst_value =
16007 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_dst,
16009 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_src =
16010 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16011 pos_token, "ip-src");
16012 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_src_value =
16013 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_src);
16014 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_dst =
16015 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16016 pos_token, "ip-dst");
16017 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_dst_value =
16018 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_dst);
16019 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_vlan =
16020 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16021 pos_token, "vlan-tci");
16022 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_vlan_value =
16023 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, tci,
16025 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_src =
16026 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16027 pos_token, "eth-src");
16028 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_src_value =
16029 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16031 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_dst =
16032 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16033 pos_token, "eth-dst");
16034 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_dst_value =
16035 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16038 static void cmd_set_mplsoudp_encap_parsed(void *parsed_result,
16039 __rte_unused struct cmdline *cl,
16040 __rte_unused void *data)
16042 struct cmd_set_mplsoudp_encap_result *res = parsed_result;
16044 uint32_t mplsoudp_label;
16047 .mplsoudp_label = rte_cpu_to_be_32(res->label<<12),
16050 if (strcmp(res->mplsoudp, "mplsoudp_encap") == 0)
16051 mplsoudp_encap_conf.select_vlan = 0;
16052 else if (strcmp(res->mplsoudp, "mplsoudp_encap-with-vlan") == 0)
16053 mplsoudp_encap_conf.select_vlan = 1;
16054 if (strcmp(res->ip_version, "ipv4") == 0)
16055 mplsoudp_encap_conf.select_ipv4 = 1;
16056 else if (strcmp(res->ip_version, "ipv6") == 0)
16057 mplsoudp_encap_conf.select_ipv4 = 0;
16060 rte_memcpy(mplsoudp_encap_conf.label, &id.label, 3);
16061 mplsoudp_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
16062 mplsoudp_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
16063 if (mplsoudp_encap_conf.select_ipv4) {
16064 IPV4_ADDR_TO_UINT(res->ip_src, mplsoudp_encap_conf.ipv4_src);
16065 IPV4_ADDR_TO_UINT(res->ip_dst, mplsoudp_encap_conf.ipv4_dst);
16067 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsoudp_encap_conf.ipv6_src);
16068 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsoudp_encap_conf.ipv6_dst);
16070 if (mplsoudp_encap_conf.select_vlan)
16071 mplsoudp_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
16072 rte_memcpy(mplsoudp_encap_conf.eth_src, res->eth_src.addr_bytes,
16073 RTE_ETHER_ADDR_LEN);
16074 rte_memcpy(mplsoudp_encap_conf.eth_dst, res->eth_dst.addr_bytes,
16075 RTE_ETHER_ADDR_LEN);
16078 cmdline_parse_inst_t cmd_set_mplsoudp_encap = {
16079 .f = cmd_set_mplsoudp_encap_parsed,
16081 .help_str = "set mplsoudp_encap ip-version ipv4|ipv6 label <label>"
16082 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src>"
16083 " ip-dst <ip-dst> eth-src <eth-src> eth-dst <eth-dst>",
16085 (void *)&cmd_set_mplsoudp_encap_set,
16086 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap,
16087 (void *)&cmd_set_mplsoudp_encap_ip_version,
16088 (void *)&cmd_set_mplsoudp_encap_ip_version_value,
16089 (void *)&cmd_set_mplsoudp_encap_label,
16090 (void *)&cmd_set_mplsoudp_encap_label_value,
16091 (void *)&cmd_set_mplsoudp_encap_udp_src,
16092 (void *)&cmd_set_mplsoudp_encap_udp_src_value,
16093 (void *)&cmd_set_mplsoudp_encap_udp_dst,
16094 (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
16095 (void *)&cmd_set_mplsoudp_encap_ip_src,
16096 (void *)&cmd_set_mplsoudp_encap_ip_src_value,
16097 (void *)&cmd_set_mplsoudp_encap_ip_dst,
16098 (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
16099 (void *)&cmd_set_mplsoudp_encap_eth_src,
16100 (void *)&cmd_set_mplsoudp_encap_eth_src_value,
16101 (void *)&cmd_set_mplsoudp_encap_eth_dst,
16102 (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
16107 cmdline_parse_inst_t cmd_set_mplsoudp_encap_with_vlan = {
16108 .f = cmd_set_mplsoudp_encap_parsed,
16110 .help_str = "set mplsoudp_encap-with-vlan ip-version ipv4|ipv6"
16111 " label <label> udp-src <udp-src> udp-dst <udp-dst>"
16112 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
16113 " eth-src <eth-src> eth-dst <eth-dst>",
16115 (void *)&cmd_set_mplsoudp_encap_set,
16116 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan,
16117 (void *)&cmd_set_mplsoudp_encap_ip_version,
16118 (void *)&cmd_set_mplsoudp_encap_ip_version_value,
16119 (void *)&cmd_set_mplsoudp_encap_label,
16120 (void *)&cmd_set_mplsoudp_encap_label_value,
16121 (void *)&cmd_set_mplsoudp_encap_udp_src,
16122 (void *)&cmd_set_mplsoudp_encap_udp_src_value,
16123 (void *)&cmd_set_mplsoudp_encap_udp_dst,
16124 (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
16125 (void *)&cmd_set_mplsoudp_encap_ip_src,
16126 (void *)&cmd_set_mplsoudp_encap_ip_src_value,
16127 (void *)&cmd_set_mplsoudp_encap_ip_dst,
16128 (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
16129 (void *)&cmd_set_mplsoudp_encap_vlan,
16130 (void *)&cmd_set_mplsoudp_encap_vlan_value,
16131 (void *)&cmd_set_mplsoudp_encap_eth_src,
16132 (void *)&cmd_set_mplsoudp_encap_eth_src_value,
16133 (void *)&cmd_set_mplsoudp_encap_eth_dst,
16134 (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
16139 /** Set MPLSoUDP decapsulation details */
16140 struct cmd_set_mplsoudp_decap_result {
16141 cmdline_fixed_string_t set;
16142 cmdline_fixed_string_t mplsoudp;
16143 cmdline_fixed_string_t pos_token;
16144 cmdline_fixed_string_t ip_version;
16145 uint32_t vlan_present:1;
16148 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_set =
16149 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, set,
16151 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap =
16152 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, mplsoudp,
16154 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan =
16155 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
16156 mplsoudp, "mplsoudp_decap-with-vlan");
16157 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version =
16158 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
16159 pos_token, "ip-version");
16160 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version_value =
16161 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
16162 ip_version, "ipv4#ipv6");
16164 static void cmd_set_mplsoudp_decap_parsed(void *parsed_result,
16165 __rte_unused struct cmdline *cl,
16166 __rte_unused void *data)
16168 struct cmd_set_mplsoudp_decap_result *res = parsed_result;
16170 if (strcmp(res->mplsoudp, "mplsoudp_decap") == 0)
16171 mplsoudp_decap_conf.select_vlan = 0;
16172 else if (strcmp(res->mplsoudp, "mplsoudp_decap-with-vlan") == 0)
16173 mplsoudp_decap_conf.select_vlan = 1;
16174 if (strcmp(res->ip_version, "ipv4") == 0)
16175 mplsoudp_decap_conf.select_ipv4 = 1;
16176 else if (strcmp(res->ip_version, "ipv6") == 0)
16177 mplsoudp_decap_conf.select_ipv4 = 0;
16180 cmdline_parse_inst_t cmd_set_mplsoudp_decap = {
16181 .f = cmd_set_mplsoudp_decap_parsed,
16183 .help_str = "set mplsoudp_decap ip-version ipv4|ipv6",
16185 (void *)&cmd_set_mplsoudp_decap_set,
16186 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap,
16187 (void *)&cmd_set_mplsoudp_decap_ip_version,
16188 (void *)&cmd_set_mplsoudp_decap_ip_version_value,
16193 cmdline_parse_inst_t cmd_set_mplsoudp_decap_with_vlan = {
16194 .f = cmd_set_mplsoudp_decap_parsed,
16196 .help_str = "set mplsoudp_decap-with-vlan ip-version ipv4|ipv6",
16198 (void *)&cmd_set_mplsoudp_decap_set,
16199 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan,
16200 (void *)&cmd_set_mplsoudp_decap_ip_version,
16201 (void *)&cmd_set_mplsoudp_decap_ip_version_value,
16206 /* Strict link priority scheduling mode setting */
16208 cmd_strict_link_prio_parsed(
16209 void *parsed_result,
16210 __rte_unused struct cmdline *cl,
16211 __rte_unused void *data)
16213 struct cmd_vf_tc_bw_result *res = parsed_result;
16214 int ret = -ENOTSUP;
16216 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16219 #ifdef RTE_NET_I40E
16220 ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map);
16227 printf("invalid tc_bitmap 0x%x\n", res->tc_map);
16230 printf("invalid port_id %d\n", res->port_id);
16233 printf("function not implemented\n");
16236 printf("programming error: (%s)\n", strerror(-ret));
16240 cmdline_parse_inst_t cmd_strict_link_prio = {
16241 .f = cmd_strict_link_prio_parsed,
16243 .help_str = "set tx strict-link-priority <port_id> <tc_bitmap>",
16245 (void *)&cmd_vf_tc_bw_set,
16246 (void *)&cmd_vf_tc_bw_tx,
16247 (void *)&cmd_vf_tc_bw_strict_link_prio,
16248 (void *)&cmd_vf_tc_bw_port_id,
16249 (void *)&cmd_vf_tc_bw_tc_map,
16254 /* Load dynamic device personalization*/
16255 struct cmd_ddp_add_result {
16256 cmdline_fixed_string_t ddp;
16257 cmdline_fixed_string_t add;
16262 cmdline_parse_token_string_t cmd_ddp_add_ddp =
16263 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp");
16264 cmdline_parse_token_string_t cmd_ddp_add_add =
16265 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add");
16266 cmdline_parse_token_num_t cmd_ddp_add_port_id =
16267 TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id, UINT16);
16268 cmdline_parse_token_string_t cmd_ddp_add_filepath =
16269 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL);
16272 cmd_ddp_add_parsed(
16273 void *parsed_result,
16274 __rte_unused struct cmdline *cl,
16275 __rte_unused void *data)
16277 struct cmd_ddp_add_result *res = parsed_result;
16283 int ret = -ENOTSUP;
16285 if (!all_ports_stopped()) {
16286 printf("Please stop all ports first\n");
16290 filepath = strdup(res->filepath);
16291 if (filepath == NULL) {
16292 printf("Failed to allocate memory\n");
16295 file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ',');
16297 buff = open_file(file_fld[0], &size);
16299 free((void *)filepath);
16303 #ifdef RTE_NET_I40E
16304 if (ret == -ENOTSUP)
16305 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
16307 RTE_PMD_I40E_PKG_OP_WR_ADD);
16310 if (ret == -EEXIST)
16311 printf("Profile has already existed.\n");
16313 printf("Failed to load profile.\n");
16314 else if (file_num == 2)
16315 save_file(file_fld[1], buff, size);
16318 free((void *)filepath);
16321 cmdline_parse_inst_t cmd_ddp_add = {
16322 .f = cmd_ddp_add_parsed,
16324 .help_str = "ddp add <port_id> <profile_path[,backup_profile_path]>",
16326 (void *)&cmd_ddp_add_ddp,
16327 (void *)&cmd_ddp_add_add,
16328 (void *)&cmd_ddp_add_port_id,
16329 (void *)&cmd_ddp_add_filepath,
16334 /* Delete dynamic device personalization*/
16335 struct cmd_ddp_del_result {
16336 cmdline_fixed_string_t ddp;
16337 cmdline_fixed_string_t del;
16342 cmdline_parse_token_string_t cmd_ddp_del_ddp =
16343 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp");
16344 cmdline_parse_token_string_t cmd_ddp_del_del =
16345 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del");
16346 cmdline_parse_token_num_t cmd_ddp_del_port_id =
16347 TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, UINT16);
16348 cmdline_parse_token_string_t cmd_ddp_del_filepath =
16349 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL);
16352 cmd_ddp_del_parsed(
16353 void *parsed_result,
16354 __rte_unused struct cmdline *cl,
16355 __rte_unused void *data)
16357 struct cmd_ddp_del_result *res = parsed_result;
16360 int ret = -ENOTSUP;
16362 if (!all_ports_stopped()) {
16363 printf("Please stop all ports first\n");
16367 buff = open_file(res->filepath, &size);
16371 #ifdef RTE_NET_I40E
16372 if (ret == -ENOTSUP)
16373 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
16375 RTE_PMD_I40E_PKG_OP_WR_DEL);
16378 if (ret == -EACCES)
16379 printf("Profile does not exist.\n");
16381 printf("Failed to delete profile.\n");
16386 cmdline_parse_inst_t cmd_ddp_del = {
16387 .f = cmd_ddp_del_parsed,
16389 .help_str = "ddp del <port_id> <backup_profile_path>",
16391 (void *)&cmd_ddp_del_ddp,
16392 (void *)&cmd_ddp_del_del,
16393 (void *)&cmd_ddp_del_port_id,
16394 (void *)&cmd_ddp_del_filepath,
16399 /* Get dynamic device personalization profile info */
16400 struct cmd_ddp_info_result {
16401 cmdline_fixed_string_t ddp;
16402 cmdline_fixed_string_t get;
16403 cmdline_fixed_string_t info;
16407 cmdline_parse_token_string_t cmd_ddp_info_ddp =
16408 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp");
16409 cmdline_parse_token_string_t cmd_ddp_info_get =
16410 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get");
16411 cmdline_parse_token_string_t cmd_ddp_info_info =
16412 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info");
16413 cmdline_parse_token_string_t cmd_ddp_info_filepath =
16414 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL);
16417 cmd_ddp_info_parsed(
16418 void *parsed_result,
16419 __rte_unused struct cmdline *cl,
16420 __rte_unused void *data)
16422 struct cmd_ddp_info_result *res = parsed_result;
16425 int ret = -ENOTSUP;
16426 #ifdef RTE_NET_I40E
16429 uint32_t buff_size = 0;
16430 struct rte_pmd_i40e_profile_info info;
16431 uint32_t dev_num = 0;
16432 struct rte_pmd_i40e_ddp_device_id *devs;
16433 uint32_t proto_num = 0;
16434 struct rte_pmd_i40e_proto_info *proto = NULL;
16435 uint32_t pctype_num = 0;
16436 struct rte_pmd_i40e_ptype_info *pctype;
16437 uint32_t ptype_num = 0;
16438 struct rte_pmd_i40e_ptype_info *ptype;
16443 pkg = open_file(res->filepath, &pkg_size);
16447 #ifdef RTE_NET_I40E
16448 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16449 (uint8_t *)&info, sizeof(info),
16450 RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER);
16452 printf("Global Track id: 0x%x\n", info.track_id);
16453 printf("Global Version: %d.%d.%d.%d\n",
16454 info.version.major,
16455 info.version.minor,
16456 info.version.update,
16457 info.version.draft);
16458 printf("Global Package name: %s\n\n", info.name);
16461 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16462 (uint8_t *)&info, sizeof(info),
16463 RTE_PMD_I40E_PKG_INFO_HEADER);
16465 printf("i40e Profile Track id: 0x%x\n", info.track_id);
16466 printf("i40e Profile Version: %d.%d.%d.%d\n",
16467 info.version.major,
16468 info.version.minor,
16469 info.version.update,
16470 info.version.draft);
16471 printf("i40e Profile name: %s\n\n", info.name);
16474 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16475 (uint8_t *)&buff_size, sizeof(buff_size),
16476 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE);
16477 if (!ret && buff_size) {
16478 buff = (uint8_t *)malloc(buff_size);
16480 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16482 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES);
16484 printf("Package Notes:\n%s\n\n", buff);
16489 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16490 (uint8_t *)&dev_num, sizeof(dev_num),
16491 RTE_PMD_I40E_PKG_INFO_DEVID_NUM);
16492 if (!ret && dev_num) {
16493 buff_size = dev_num * sizeof(struct rte_pmd_i40e_ddp_device_id);
16494 devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(buff_size);
16496 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16497 (uint8_t *)devs, buff_size,
16498 RTE_PMD_I40E_PKG_INFO_DEVID_LIST);
16500 printf("List of supported devices:\n");
16501 for (i = 0; i < dev_num; i++) {
16502 printf(" %04X:%04X %04X:%04X\n",
16503 devs[i].vendor_dev_id >> 16,
16504 devs[i].vendor_dev_id & 0xFFFF,
16505 devs[i].sub_vendor_dev_id >> 16,
16506 devs[i].sub_vendor_dev_id & 0xFFFF);
16514 /* get information about protocols and packet types */
16515 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16516 (uint8_t *)&proto_num, sizeof(proto_num),
16517 RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM);
16518 if (ret || !proto_num)
16519 goto no_print_return;
16521 buff_size = proto_num * sizeof(struct rte_pmd_i40e_proto_info);
16522 proto = (struct rte_pmd_i40e_proto_info *)malloc(buff_size);
16524 goto no_print_return;
16526 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)proto,
16528 RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST);
16530 printf("List of used protocols:\n");
16531 for (i = 0; i < proto_num; i++)
16532 printf(" %2u: %s\n", proto[i].proto_id,
16536 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16537 (uint8_t *)&pctype_num, sizeof(pctype_num),
16538 RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM);
16539 if (ret || !pctype_num)
16540 goto no_print_pctypes;
16542 buff_size = pctype_num * sizeof(struct rte_pmd_i40e_ptype_info);
16543 pctype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
16545 goto no_print_pctypes;
16547 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)pctype,
16549 RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST);
16552 goto no_print_pctypes;
16555 printf("List of defined packet classification types:\n");
16556 for (i = 0; i < pctype_num; i++) {
16557 printf(" %2u:", pctype[i].ptype_id);
16558 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
16559 proto_id = pctype[i].protocols[j];
16560 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
16561 for (n = 0; n < proto_num; n++) {
16562 if (proto[n].proto_id == proto_id) {
16563 printf(" %s", proto[n].name);
16576 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)&ptype_num,
16578 RTE_PMD_I40E_PKG_INFO_PTYPE_NUM);
16579 if (ret || !ptype_num)
16580 goto no_print_return;
16582 buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_info);
16583 ptype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
16585 goto no_print_return;
16587 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)ptype,
16589 RTE_PMD_I40E_PKG_INFO_PTYPE_LIST);
16592 goto no_print_return;
16594 printf("List of defined packet types:\n");
16595 for (i = 0; i < ptype_num; i++) {
16596 printf(" %2u:", ptype[i].ptype_id);
16597 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
16598 proto_id = ptype[i].protocols[j];
16599 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
16600 for (n = 0; n < proto_num; n++) {
16601 if (proto[n].proto_id == proto_id) {
16602 printf(" %s", proto[n].name);
16618 if (ret == -ENOTSUP)
16619 printf("Function not supported in PMD driver\n");
16623 cmdline_parse_inst_t cmd_ddp_get_info = {
16624 .f = cmd_ddp_info_parsed,
16626 .help_str = "ddp get info <profile_path>",
16628 (void *)&cmd_ddp_info_ddp,
16629 (void *)&cmd_ddp_info_get,
16630 (void *)&cmd_ddp_info_info,
16631 (void *)&cmd_ddp_info_filepath,
16636 /* Get dynamic device personalization profile info list*/
16637 #define PROFILE_INFO_SIZE 48
16638 #define MAX_PROFILE_NUM 16
16640 struct cmd_ddp_get_list_result {
16641 cmdline_fixed_string_t ddp;
16642 cmdline_fixed_string_t get;
16643 cmdline_fixed_string_t list;
16647 cmdline_parse_token_string_t cmd_ddp_get_list_ddp =
16648 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp");
16649 cmdline_parse_token_string_t cmd_ddp_get_list_get =
16650 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get");
16651 cmdline_parse_token_string_t cmd_ddp_get_list_list =
16652 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list");
16653 cmdline_parse_token_num_t cmd_ddp_get_list_port_id =
16654 TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id, UINT16);
16657 cmd_ddp_get_list_parsed(
16658 __rte_unused void *parsed_result,
16659 __rte_unused struct cmdline *cl,
16660 __rte_unused void *data)
16662 #ifdef RTE_NET_I40E
16663 struct cmd_ddp_get_list_result *res = parsed_result;
16664 struct rte_pmd_i40e_profile_list *p_list;
16665 struct rte_pmd_i40e_profile_info *p_info;
16670 int ret = -ENOTSUP;
16672 #ifdef RTE_NET_I40E
16673 size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4;
16674 p_list = (struct rte_pmd_i40e_profile_list *)malloc(size);
16676 printf("%s: Failed to malloc buffer\n", __func__);
16680 if (ret == -ENOTSUP)
16681 ret = rte_pmd_i40e_get_ddp_list(res->port_id,
16682 (uint8_t *)p_list, size);
16685 p_num = p_list->p_count;
16686 printf("Profile number is: %d\n\n", p_num);
16688 for (i = 0; i < p_num; i++) {
16689 p_info = &p_list->p_info[i];
16690 printf("Profile %d:\n", i);
16691 printf("Track id: 0x%x\n", p_info->track_id);
16692 printf("Version: %d.%d.%d.%d\n",
16693 p_info->version.major,
16694 p_info->version.minor,
16695 p_info->version.update,
16696 p_info->version.draft);
16697 printf("Profile name: %s\n\n", p_info->name);
16705 printf("Failed to get ddp list\n");
16708 cmdline_parse_inst_t cmd_ddp_get_list = {
16709 .f = cmd_ddp_get_list_parsed,
16711 .help_str = "ddp get list <port_id>",
16713 (void *)&cmd_ddp_get_list_ddp,
16714 (void *)&cmd_ddp_get_list_get,
16715 (void *)&cmd_ddp_get_list_list,
16716 (void *)&cmd_ddp_get_list_port_id,
16721 /* Configure input set */
16722 struct cmd_cfg_input_set_result {
16723 cmdline_fixed_string_t port;
16724 cmdline_fixed_string_t cfg;
16726 cmdline_fixed_string_t pctype;
16728 cmdline_fixed_string_t inset_type;
16729 cmdline_fixed_string_t opt;
16730 cmdline_fixed_string_t field;
16735 cmd_cfg_input_set_parsed(
16736 __rte_unused void *parsed_result,
16737 __rte_unused struct cmdline *cl,
16738 __rte_unused void *data)
16740 #ifdef RTE_NET_I40E
16741 struct cmd_cfg_input_set_result *res = parsed_result;
16742 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
16743 struct rte_pmd_i40e_inset inset;
16745 int ret = -ENOTSUP;
16747 if (!all_ports_stopped()) {
16748 printf("Please stop all ports first\n");
16752 #ifdef RTE_NET_I40E
16753 if (!strcmp(res->inset_type, "hash_inset"))
16754 inset_type = INSET_HASH;
16755 else if (!strcmp(res->inset_type, "fdir_inset"))
16756 inset_type = INSET_FDIR;
16757 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
16758 inset_type = INSET_FDIR_FLX;
16759 ret = rte_pmd_i40e_inset_get(res->port_id, res->pctype_id,
16760 &inset, inset_type);
16762 printf("Failed to get input set.\n");
16766 if (!strcmp(res->opt, "get")) {
16767 ret = rte_pmd_i40e_inset_field_get(inset.inset,
16770 printf("Field index %d is enabled.\n", res->field_idx);
16772 printf("Field index %d is disabled.\n", res->field_idx);
16774 } else if (!strcmp(res->opt, "set"))
16775 ret = rte_pmd_i40e_inset_field_set(&inset.inset,
16777 else if (!strcmp(res->opt, "clear"))
16778 ret = rte_pmd_i40e_inset_field_clear(&inset.inset,
16781 printf("Failed to configure input set field.\n");
16785 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
16786 &inset, inset_type);
16788 printf("Failed to set input set.\n");
16793 if (ret == -ENOTSUP)
16794 printf("Function not supported\n");
16797 cmdline_parse_token_string_t cmd_cfg_input_set_port =
16798 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16800 cmdline_parse_token_string_t cmd_cfg_input_set_cfg =
16801 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16803 cmdline_parse_token_num_t cmd_cfg_input_set_port_id =
16804 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
16806 cmdline_parse_token_string_t cmd_cfg_input_set_pctype =
16807 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16809 cmdline_parse_token_num_t cmd_cfg_input_set_pctype_id =
16810 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
16812 cmdline_parse_token_string_t cmd_cfg_input_set_inset_type =
16813 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16815 "hash_inset#fdir_inset#fdir_flx_inset");
16816 cmdline_parse_token_string_t cmd_cfg_input_set_opt =
16817 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16818 opt, "get#set#clear");
16819 cmdline_parse_token_string_t cmd_cfg_input_set_field =
16820 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16822 cmdline_parse_token_num_t cmd_cfg_input_set_field_idx =
16823 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
16826 cmdline_parse_inst_t cmd_cfg_input_set = {
16827 .f = cmd_cfg_input_set_parsed,
16829 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
16830 "fdir_inset|fdir_flx_inset get|set|clear field <field_idx>",
16832 (void *)&cmd_cfg_input_set_port,
16833 (void *)&cmd_cfg_input_set_cfg,
16834 (void *)&cmd_cfg_input_set_port_id,
16835 (void *)&cmd_cfg_input_set_pctype,
16836 (void *)&cmd_cfg_input_set_pctype_id,
16837 (void *)&cmd_cfg_input_set_inset_type,
16838 (void *)&cmd_cfg_input_set_opt,
16839 (void *)&cmd_cfg_input_set_field,
16840 (void *)&cmd_cfg_input_set_field_idx,
16845 /* Clear input set */
16846 struct cmd_clear_input_set_result {
16847 cmdline_fixed_string_t port;
16848 cmdline_fixed_string_t cfg;
16850 cmdline_fixed_string_t pctype;
16852 cmdline_fixed_string_t inset_type;
16853 cmdline_fixed_string_t clear;
16854 cmdline_fixed_string_t all;
16858 cmd_clear_input_set_parsed(
16859 __rte_unused void *parsed_result,
16860 __rte_unused struct cmdline *cl,
16861 __rte_unused void *data)
16863 #ifdef RTE_NET_I40E
16864 struct cmd_clear_input_set_result *res = parsed_result;
16865 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
16866 struct rte_pmd_i40e_inset inset;
16868 int ret = -ENOTSUP;
16870 if (!all_ports_stopped()) {
16871 printf("Please stop all ports first\n");
16875 #ifdef RTE_NET_I40E
16876 if (!strcmp(res->inset_type, "hash_inset"))
16877 inset_type = INSET_HASH;
16878 else if (!strcmp(res->inset_type, "fdir_inset"))
16879 inset_type = INSET_FDIR;
16880 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
16881 inset_type = INSET_FDIR_FLX;
16883 memset(&inset, 0, sizeof(inset));
16885 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
16886 &inset, inset_type);
16888 printf("Failed to clear input set.\n");
16894 if (ret == -ENOTSUP)
16895 printf("Function not supported\n");
16898 cmdline_parse_token_string_t cmd_clear_input_set_port =
16899 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
16901 cmdline_parse_token_string_t cmd_clear_input_set_cfg =
16902 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
16904 cmdline_parse_token_num_t cmd_clear_input_set_port_id =
16905 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
16907 cmdline_parse_token_string_t cmd_clear_input_set_pctype =
16908 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
16910 cmdline_parse_token_num_t cmd_clear_input_set_pctype_id =
16911 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
16913 cmdline_parse_token_string_t cmd_clear_input_set_inset_type =
16914 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
16916 "hash_inset#fdir_inset#fdir_flx_inset");
16917 cmdline_parse_token_string_t cmd_clear_input_set_clear =
16918 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
16920 cmdline_parse_token_string_t cmd_clear_input_set_all =
16921 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
16924 cmdline_parse_inst_t cmd_clear_input_set = {
16925 .f = cmd_clear_input_set_parsed,
16927 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
16928 "fdir_inset|fdir_flx_inset clear all",
16930 (void *)&cmd_clear_input_set_port,
16931 (void *)&cmd_clear_input_set_cfg,
16932 (void *)&cmd_clear_input_set_port_id,
16933 (void *)&cmd_clear_input_set_pctype,
16934 (void *)&cmd_clear_input_set_pctype_id,
16935 (void *)&cmd_clear_input_set_inset_type,
16936 (void *)&cmd_clear_input_set_clear,
16937 (void *)&cmd_clear_input_set_all,
16942 /* show vf stats */
16944 /* Common result structure for show vf stats */
16945 struct cmd_show_vf_stats_result {
16946 cmdline_fixed_string_t show;
16947 cmdline_fixed_string_t vf;
16948 cmdline_fixed_string_t stats;
16953 /* Common CLI fields show vf stats*/
16954 cmdline_parse_token_string_t cmd_show_vf_stats_show =
16955 TOKEN_STRING_INITIALIZER
16956 (struct cmd_show_vf_stats_result,
16958 cmdline_parse_token_string_t cmd_show_vf_stats_vf =
16959 TOKEN_STRING_INITIALIZER
16960 (struct cmd_show_vf_stats_result,
16962 cmdline_parse_token_string_t cmd_show_vf_stats_stats =
16963 TOKEN_STRING_INITIALIZER
16964 (struct cmd_show_vf_stats_result,
16966 cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
16967 TOKEN_NUM_INITIALIZER
16968 (struct cmd_show_vf_stats_result,
16970 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
16971 TOKEN_NUM_INITIALIZER
16972 (struct cmd_show_vf_stats_result,
16976 cmd_show_vf_stats_parsed(
16977 void *parsed_result,
16978 __rte_unused struct cmdline *cl,
16979 __rte_unused void *data)
16981 struct cmd_show_vf_stats_result *res = parsed_result;
16982 struct rte_eth_stats stats;
16983 int ret = -ENOTSUP;
16984 static const char *nic_stats_border = "########################";
16986 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16989 memset(&stats, 0, sizeof(stats));
16991 #ifdef RTE_NET_I40E
16992 if (ret == -ENOTSUP)
16993 ret = rte_pmd_i40e_get_vf_stats(res->port_id,
16997 #ifdef RTE_NET_BNXT
16998 if (ret == -ENOTSUP)
16999 ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
17008 printf("invalid vf_id %d\n", res->vf_id);
17011 printf("invalid port_id %d\n", res->port_id);
17014 printf("function not implemented\n");
17017 printf("programming error: (%s)\n", strerror(-ret));
17020 printf("\n %s NIC statistics for port %-2d vf %-2d %s\n",
17021 nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
17023 printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: "
17025 stats.ipackets, stats.imissed, stats.ibytes);
17026 printf(" RX-errors: %-"PRIu64"\n", stats.ierrors);
17027 printf(" RX-nombuf: %-10"PRIu64"\n",
17029 printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: "
17031 stats.opackets, stats.oerrors, stats.obytes);
17033 printf(" %s############################%s\n",
17034 nic_stats_border, nic_stats_border);
17037 cmdline_parse_inst_t cmd_show_vf_stats = {
17038 .f = cmd_show_vf_stats_parsed,
17040 .help_str = "show vf stats <port_id> <vf_id>",
17042 (void *)&cmd_show_vf_stats_show,
17043 (void *)&cmd_show_vf_stats_vf,
17044 (void *)&cmd_show_vf_stats_stats,
17045 (void *)&cmd_show_vf_stats_port_id,
17046 (void *)&cmd_show_vf_stats_vf_id,
17051 /* clear vf stats */
17053 /* Common result structure for clear vf stats */
17054 struct cmd_clear_vf_stats_result {
17055 cmdline_fixed_string_t clear;
17056 cmdline_fixed_string_t vf;
17057 cmdline_fixed_string_t stats;
17062 /* Common CLI fields clear vf stats*/
17063 cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
17064 TOKEN_STRING_INITIALIZER
17065 (struct cmd_clear_vf_stats_result,
17067 cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
17068 TOKEN_STRING_INITIALIZER
17069 (struct cmd_clear_vf_stats_result,
17071 cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
17072 TOKEN_STRING_INITIALIZER
17073 (struct cmd_clear_vf_stats_result,
17075 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
17076 TOKEN_NUM_INITIALIZER
17077 (struct cmd_clear_vf_stats_result,
17079 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
17080 TOKEN_NUM_INITIALIZER
17081 (struct cmd_clear_vf_stats_result,
17085 cmd_clear_vf_stats_parsed(
17086 void *parsed_result,
17087 __rte_unused struct cmdline *cl,
17088 __rte_unused void *data)
17090 struct cmd_clear_vf_stats_result *res = parsed_result;
17091 int ret = -ENOTSUP;
17093 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17096 #ifdef RTE_NET_I40E
17097 if (ret == -ENOTSUP)
17098 ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
17101 #ifdef RTE_NET_BNXT
17102 if (ret == -ENOTSUP)
17103 ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
17111 printf("invalid vf_id %d\n", res->vf_id);
17114 printf("invalid port_id %d\n", res->port_id);
17117 printf("function not implemented\n");
17120 printf("programming error: (%s)\n", strerror(-ret));
17124 cmdline_parse_inst_t cmd_clear_vf_stats = {
17125 .f = cmd_clear_vf_stats_parsed,
17127 .help_str = "clear vf stats <port_id> <vf_id>",
17129 (void *)&cmd_clear_vf_stats_clear,
17130 (void *)&cmd_clear_vf_stats_vf,
17131 (void *)&cmd_clear_vf_stats_stats,
17132 (void *)&cmd_clear_vf_stats_port_id,
17133 (void *)&cmd_clear_vf_stats_vf_id,
17138 /* port config pctype mapping reset */
17140 /* Common result structure for port config pctype mapping reset */
17141 struct cmd_pctype_mapping_reset_result {
17142 cmdline_fixed_string_t port;
17143 cmdline_fixed_string_t config;
17145 cmdline_fixed_string_t pctype;
17146 cmdline_fixed_string_t mapping;
17147 cmdline_fixed_string_t reset;
17150 /* Common CLI fields for port config pctype mapping reset*/
17151 cmdline_parse_token_string_t cmd_pctype_mapping_reset_port =
17152 TOKEN_STRING_INITIALIZER
17153 (struct cmd_pctype_mapping_reset_result,
17155 cmdline_parse_token_string_t cmd_pctype_mapping_reset_config =
17156 TOKEN_STRING_INITIALIZER
17157 (struct cmd_pctype_mapping_reset_result,
17159 cmdline_parse_token_num_t cmd_pctype_mapping_reset_port_id =
17160 TOKEN_NUM_INITIALIZER
17161 (struct cmd_pctype_mapping_reset_result,
17163 cmdline_parse_token_string_t cmd_pctype_mapping_reset_pctype =
17164 TOKEN_STRING_INITIALIZER
17165 (struct cmd_pctype_mapping_reset_result,
17167 cmdline_parse_token_string_t cmd_pctype_mapping_reset_mapping =
17168 TOKEN_STRING_INITIALIZER
17169 (struct cmd_pctype_mapping_reset_result,
17170 mapping, "mapping");
17171 cmdline_parse_token_string_t cmd_pctype_mapping_reset_reset =
17172 TOKEN_STRING_INITIALIZER
17173 (struct cmd_pctype_mapping_reset_result,
17177 cmd_pctype_mapping_reset_parsed(
17178 void *parsed_result,
17179 __rte_unused struct cmdline *cl,
17180 __rte_unused void *data)
17182 struct cmd_pctype_mapping_reset_result *res = parsed_result;
17183 int ret = -ENOTSUP;
17185 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17188 #ifdef RTE_NET_I40E
17189 ret = rte_pmd_i40e_flow_type_mapping_reset(res->port_id);
17196 printf("invalid port_id %d\n", res->port_id);
17199 printf("function not implemented\n");
17202 printf("programming error: (%s)\n", strerror(-ret));
17206 cmdline_parse_inst_t cmd_pctype_mapping_reset = {
17207 .f = cmd_pctype_mapping_reset_parsed,
17209 .help_str = "port config <port_id> pctype mapping reset",
17211 (void *)&cmd_pctype_mapping_reset_port,
17212 (void *)&cmd_pctype_mapping_reset_config,
17213 (void *)&cmd_pctype_mapping_reset_port_id,
17214 (void *)&cmd_pctype_mapping_reset_pctype,
17215 (void *)&cmd_pctype_mapping_reset_mapping,
17216 (void *)&cmd_pctype_mapping_reset_reset,
17221 /* show port pctype mapping */
17223 /* Common result structure for show port pctype mapping */
17224 struct cmd_pctype_mapping_get_result {
17225 cmdline_fixed_string_t show;
17226 cmdline_fixed_string_t port;
17228 cmdline_fixed_string_t pctype;
17229 cmdline_fixed_string_t mapping;
17232 /* Common CLI fields for pctype mapping get */
17233 cmdline_parse_token_string_t cmd_pctype_mapping_get_show =
17234 TOKEN_STRING_INITIALIZER
17235 (struct cmd_pctype_mapping_get_result,
17237 cmdline_parse_token_string_t cmd_pctype_mapping_get_port =
17238 TOKEN_STRING_INITIALIZER
17239 (struct cmd_pctype_mapping_get_result,
17241 cmdline_parse_token_num_t cmd_pctype_mapping_get_port_id =
17242 TOKEN_NUM_INITIALIZER
17243 (struct cmd_pctype_mapping_get_result,
17245 cmdline_parse_token_string_t cmd_pctype_mapping_get_pctype =
17246 TOKEN_STRING_INITIALIZER
17247 (struct cmd_pctype_mapping_get_result,
17249 cmdline_parse_token_string_t cmd_pctype_mapping_get_mapping =
17250 TOKEN_STRING_INITIALIZER
17251 (struct cmd_pctype_mapping_get_result,
17252 mapping, "mapping");
17255 cmd_pctype_mapping_get_parsed(
17256 void *parsed_result,
17257 __rte_unused struct cmdline *cl,
17258 __rte_unused void *data)
17260 struct cmd_pctype_mapping_get_result *res = parsed_result;
17261 int ret = -ENOTSUP;
17262 #ifdef RTE_NET_I40E
17263 struct rte_pmd_i40e_flow_type_mapping
17264 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
17265 int i, j, first_pctype;
17268 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17271 #ifdef RTE_NET_I40E
17272 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, mapping);
17279 printf("invalid port_id %d\n", res->port_id);
17282 printf("function not implemented\n");
17285 printf("programming error: (%s)\n", strerror(-ret));
17289 #ifdef RTE_NET_I40E
17290 for (i = 0; i < RTE_PMD_I40E_FLOW_TYPE_MAX; i++) {
17291 if (mapping[i].pctype != 0ULL) {
17294 printf("pctype: ");
17295 for (j = 0; j < RTE_PMD_I40E_PCTYPE_MAX; j++) {
17296 if (mapping[i].pctype & (1ULL << j)) {
17297 printf(first_pctype ?
17298 "%02d" : ",%02d", j);
17302 printf(" -> flowtype: %02d\n", mapping[i].flow_type);
17308 cmdline_parse_inst_t cmd_pctype_mapping_get = {
17309 .f = cmd_pctype_mapping_get_parsed,
17311 .help_str = "show port <port_id> pctype mapping",
17313 (void *)&cmd_pctype_mapping_get_show,
17314 (void *)&cmd_pctype_mapping_get_port,
17315 (void *)&cmd_pctype_mapping_get_port_id,
17316 (void *)&cmd_pctype_mapping_get_pctype,
17317 (void *)&cmd_pctype_mapping_get_mapping,
17322 /* port config pctype mapping update */
17324 /* Common result structure for port config pctype mapping update */
17325 struct cmd_pctype_mapping_update_result {
17326 cmdline_fixed_string_t port;
17327 cmdline_fixed_string_t config;
17329 cmdline_fixed_string_t pctype;
17330 cmdline_fixed_string_t mapping;
17331 cmdline_fixed_string_t update;
17332 cmdline_fixed_string_t pctype_list;
17333 uint16_t flow_type;
17336 /* Common CLI fields for pctype mapping update*/
17337 cmdline_parse_token_string_t cmd_pctype_mapping_update_port =
17338 TOKEN_STRING_INITIALIZER
17339 (struct cmd_pctype_mapping_update_result,
17341 cmdline_parse_token_string_t cmd_pctype_mapping_update_config =
17342 TOKEN_STRING_INITIALIZER
17343 (struct cmd_pctype_mapping_update_result,
17345 cmdline_parse_token_num_t cmd_pctype_mapping_update_port_id =
17346 TOKEN_NUM_INITIALIZER
17347 (struct cmd_pctype_mapping_update_result,
17349 cmdline_parse_token_string_t cmd_pctype_mapping_update_pctype =
17350 TOKEN_STRING_INITIALIZER
17351 (struct cmd_pctype_mapping_update_result,
17353 cmdline_parse_token_string_t cmd_pctype_mapping_update_mapping =
17354 TOKEN_STRING_INITIALIZER
17355 (struct cmd_pctype_mapping_update_result,
17356 mapping, "mapping");
17357 cmdline_parse_token_string_t cmd_pctype_mapping_update_update =
17358 TOKEN_STRING_INITIALIZER
17359 (struct cmd_pctype_mapping_update_result,
17361 cmdline_parse_token_string_t cmd_pctype_mapping_update_pc_type =
17362 TOKEN_STRING_INITIALIZER
17363 (struct cmd_pctype_mapping_update_result,
17364 pctype_list, NULL);
17365 cmdline_parse_token_num_t cmd_pctype_mapping_update_flow_type =
17366 TOKEN_NUM_INITIALIZER
17367 (struct cmd_pctype_mapping_update_result,
17368 flow_type, UINT16);
17371 cmd_pctype_mapping_update_parsed(
17372 void *parsed_result,
17373 __rte_unused struct cmdline *cl,
17374 __rte_unused void *data)
17376 struct cmd_pctype_mapping_update_result *res = parsed_result;
17377 int ret = -ENOTSUP;
17378 #ifdef RTE_NET_I40E
17379 struct rte_pmd_i40e_flow_type_mapping mapping;
17381 unsigned int nb_item;
17382 unsigned int pctype_list[RTE_PMD_I40E_PCTYPE_MAX];
17385 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17388 #ifdef RTE_NET_I40E
17389 nb_item = parse_item_list(res->pctype_list, "pctypes",
17390 RTE_PMD_I40E_PCTYPE_MAX, pctype_list, 1);
17391 mapping.flow_type = res->flow_type;
17392 for (i = 0, mapping.pctype = 0ULL; i < nb_item; i++)
17393 mapping.pctype |= (1ULL << pctype_list[i]);
17394 ret = rte_pmd_i40e_flow_type_mapping_update(res->port_id,
17404 printf("invalid pctype or flow type\n");
17407 printf("invalid port_id %d\n", res->port_id);
17410 printf("function not implemented\n");
17413 printf("programming error: (%s)\n", strerror(-ret));
17417 cmdline_parse_inst_t cmd_pctype_mapping_update = {
17418 .f = cmd_pctype_mapping_update_parsed,
17420 .help_str = "port config <port_id> pctype mapping update"
17421 " <pctype_id_0,[pctype_id_1]*> <flowtype_id>",
17423 (void *)&cmd_pctype_mapping_update_port,
17424 (void *)&cmd_pctype_mapping_update_config,
17425 (void *)&cmd_pctype_mapping_update_port_id,
17426 (void *)&cmd_pctype_mapping_update_pctype,
17427 (void *)&cmd_pctype_mapping_update_mapping,
17428 (void *)&cmd_pctype_mapping_update_update,
17429 (void *)&cmd_pctype_mapping_update_pc_type,
17430 (void *)&cmd_pctype_mapping_update_flow_type,
17435 /* ptype mapping get */
17437 /* Common result structure for ptype mapping get */
17438 struct cmd_ptype_mapping_get_result {
17439 cmdline_fixed_string_t ptype;
17440 cmdline_fixed_string_t mapping;
17441 cmdline_fixed_string_t get;
17443 uint8_t valid_only;
17446 /* Common CLI fields for ptype mapping get */
17447 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype =
17448 TOKEN_STRING_INITIALIZER
17449 (struct cmd_ptype_mapping_get_result,
17451 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping =
17452 TOKEN_STRING_INITIALIZER
17453 (struct cmd_ptype_mapping_get_result,
17454 mapping, "mapping");
17455 cmdline_parse_token_string_t cmd_ptype_mapping_get_get =
17456 TOKEN_STRING_INITIALIZER
17457 (struct cmd_ptype_mapping_get_result,
17459 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id =
17460 TOKEN_NUM_INITIALIZER
17461 (struct cmd_ptype_mapping_get_result,
17463 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only =
17464 TOKEN_NUM_INITIALIZER
17465 (struct cmd_ptype_mapping_get_result,
17466 valid_only, UINT8);
17469 cmd_ptype_mapping_get_parsed(
17470 void *parsed_result,
17471 __rte_unused struct cmdline *cl,
17472 __rte_unused void *data)
17474 struct cmd_ptype_mapping_get_result *res = parsed_result;
17475 int ret = -ENOTSUP;
17476 #ifdef RTE_NET_I40E
17477 int max_ptype_num = 256;
17478 struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num];
17483 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17486 #ifdef RTE_NET_I40E
17487 ret = rte_pmd_i40e_ptype_mapping_get(res->port_id,
17498 printf("invalid port_id %d\n", res->port_id);
17501 printf("function not implemented\n");
17504 printf("programming error: (%s)\n", strerror(-ret));
17507 #ifdef RTE_NET_I40E
17509 for (i = 0; i < count; i++)
17510 printf("%3d\t0x%08x\n",
17511 mapping[i].hw_ptype, mapping[i].sw_ptype);
17516 cmdline_parse_inst_t cmd_ptype_mapping_get = {
17517 .f = cmd_ptype_mapping_get_parsed,
17519 .help_str = "ptype mapping get <port_id> <valid_only>",
17521 (void *)&cmd_ptype_mapping_get_ptype,
17522 (void *)&cmd_ptype_mapping_get_mapping,
17523 (void *)&cmd_ptype_mapping_get_get,
17524 (void *)&cmd_ptype_mapping_get_port_id,
17525 (void *)&cmd_ptype_mapping_get_valid_only,
17530 /* ptype mapping replace */
17532 /* Common result structure for ptype mapping replace */
17533 struct cmd_ptype_mapping_replace_result {
17534 cmdline_fixed_string_t ptype;
17535 cmdline_fixed_string_t mapping;
17536 cmdline_fixed_string_t replace;
17543 /* Common CLI fields for ptype mapping replace */
17544 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype =
17545 TOKEN_STRING_INITIALIZER
17546 (struct cmd_ptype_mapping_replace_result,
17548 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping =
17549 TOKEN_STRING_INITIALIZER
17550 (struct cmd_ptype_mapping_replace_result,
17551 mapping, "mapping");
17552 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace =
17553 TOKEN_STRING_INITIALIZER
17554 (struct cmd_ptype_mapping_replace_result,
17555 replace, "replace");
17556 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id =
17557 TOKEN_NUM_INITIALIZER
17558 (struct cmd_ptype_mapping_replace_result,
17560 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target =
17561 TOKEN_NUM_INITIALIZER
17562 (struct cmd_ptype_mapping_replace_result,
17564 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask =
17565 TOKEN_NUM_INITIALIZER
17566 (struct cmd_ptype_mapping_replace_result,
17568 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type =
17569 TOKEN_NUM_INITIALIZER
17570 (struct cmd_ptype_mapping_replace_result,
17574 cmd_ptype_mapping_replace_parsed(
17575 void *parsed_result,
17576 __rte_unused struct cmdline *cl,
17577 __rte_unused void *data)
17579 struct cmd_ptype_mapping_replace_result *res = parsed_result;
17580 int ret = -ENOTSUP;
17582 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17585 #ifdef RTE_NET_I40E
17586 ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id,
17596 printf("invalid ptype 0x%8x or 0x%8x\n",
17597 res->target, res->pkt_type);
17600 printf("invalid port_id %d\n", res->port_id);
17603 printf("function not implemented\n");
17606 printf("programming error: (%s)\n", strerror(-ret));
17610 cmdline_parse_inst_t cmd_ptype_mapping_replace = {
17611 .f = cmd_ptype_mapping_replace_parsed,
17614 "ptype mapping replace <port_id> <target> <mask> <pkt_type>",
17616 (void *)&cmd_ptype_mapping_replace_ptype,
17617 (void *)&cmd_ptype_mapping_replace_mapping,
17618 (void *)&cmd_ptype_mapping_replace_replace,
17619 (void *)&cmd_ptype_mapping_replace_port_id,
17620 (void *)&cmd_ptype_mapping_replace_target,
17621 (void *)&cmd_ptype_mapping_replace_mask,
17622 (void *)&cmd_ptype_mapping_replace_pkt_type,
17627 /* ptype mapping reset */
17629 /* Common result structure for ptype mapping reset */
17630 struct cmd_ptype_mapping_reset_result {
17631 cmdline_fixed_string_t ptype;
17632 cmdline_fixed_string_t mapping;
17633 cmdline_fixed_string_t reset;
17637 /* Common CLI fields for ptype mapping reset*/
17638 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype =
17639 TOKEN_STRING_INITIALIZER
17640 (struct cmd_ptype_mapping_reset_result,
17642 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping =
17643 TOKEN_STRING_INITIALIZER
17644 (struct cmd_ptype_mapping_reset_result,
17645 mapping, "mapping");
17646 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset =
17647 TOKEN_STRING_INITIALIZER
17648 (struct cmd_ptype_mapping_reset_result,
17650 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id =
17651 TOKEN_NUM_INITIALIZER
17652 (struct cmd_ptype_mapping_reset_result,
17656 cmd_ptype_mapping_reset_parsed(
17657 void *parsed_result,
17658 __rte_unused struct cmdline *cl,
17659 __rte_unused void *data)
17661 struct cmd_ptype_mapping_reset_result *res = parsed_result;
17662 int ret = -ENOTSUP;
17664 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17667 #ifdef RTE_NET_I40E
17668 ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id);
17675 printf("invalid port_id %d\n", res->port_id);
17678 printf("function not implemented\n");
17681 printf("programming error: (%s)\n", strerror(-ret));
17685 cmdline_parse_inst_t cmd_ptype_mapping_reset = {
17686 .f = cmd_ptype_mapping_reset_parsed,
17688 .help_str = "ptype mapping reset <port_id>",
17690 (void *)&cmd_ptype_mapping_reset_ptype,
17691 (void *)&cmd_ptype_mapping_reset_mapping,
17692 (void *)&cmd_ptype_mapping_reset_reset,
17693 (void *)&cmd_ptype_mapping_reset_port_id,
17698 /* ptype mapping update */
17700 /* Common result structure for ptype mapping update */
17701 struct cmd_ptype_mapping_update_result {
17702 cmdline_fixed_string_t ptype;
17703 cmdline_fixed_string_t mapping;
17704 cmdline_fixed_string_t reset;
17710 /* Common CLI fields for ptype mapping update*/
17711 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype =
17712 TOKEN_STRING_INITIALIZER
17713 (struct cmd_ptype_mapping_update_result,
17715 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping =
17716 TOKEN_STRING_INITIALIZER
17717 (struct cmd_ptype_mapping_update_result,
17718 mapping, "mapping");
17719 cmdline_parse_token_string_t cmd_ptype_mapping_update_update =
17720 TOKEN_STRING_INITIALIZER
17721 (struct cmd_ptype_mapping_update_result,
17723 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id =
17724 TOKEN_NUM_INITIALIZER
17725 (struct cmd_ptype_mapping_update_result,
17727 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype =
17728 TOKEN_NUM_INITIALIZER
17729 (struct cmd_ptype_mapping_update_result,
17731 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype =
17732 TOKEN_NUM_INITIALIZER
17733 (struct cmd_ptype_mapping_update_result,
17737 cmd_ptype_mapping_update_parsed(
17738 void *parsed_result,
17739 __rte_unused struct cmdline *cl,
17740 __rte_unused void *data)
17742 struct cmd_ptype_mapping_update_result *res = parsed_result;
17743 int ret = -ENOTSUP;
17744 #ifdef RTE_NET_I40E
17745 struct rte_pmd_i40e_ptype_mapping mapping;
17747 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17750 #ifdef RTE_NET_I40E
17751 mapping.hw_ptype = res->hw_ptype;
17752 mapping.sw_ptype = res->sw_ptype;
17753 ret = rte_pmd_i40e_ptype_mapping_update(res->port_id,
17763 printf("invalid ptype 0x%8x\n", res->sw_ptype);
17766 printf("invalid port_id %d\n", res->port_id);
17769 printf("function not implemented\n");
17772 printf("programming error: (%s)\n", strerror(-ret));
17776 cmdline_parse_inst_t cmd_ptype_mapping_update = {
17777 .f = cmd_ptype_mapping_update_parsed,
17779 .help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>",
17781 (void *)&cmd_ptype_mapping_update_ptype,
17782 (void *)&cmd_ptype_mapping_update_mapping,
17783 (void *)&cmd_ptype_mapping_update_update,
17784 (void *)&cmd_ptype_mapping_update_port_id,
17785 (void *)&cmd_ptype_mapping_update_hw_ptype,
17786 (void *)&cmd_ptype_mapping_update_sw_ptype,
17791 /* Common result structure for file commands */
17792 struct cmd_cmdfile_result {
17793 cmdline_fixed_string_t load;
17794 cmdline_fixed_string_t filename;
17797 /* Common CLI fields for file commands */
17798 cmdline_parse_token_string_t cmd_load_cmdfile =
17799 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
17800 cmdline_parse_token_string_t cmd_load_cmdfile_filename =
17801 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
17804 cmd_load_from_file_parsed(
17805 void *parsed_result,
17806 __rte_unused struct cmdline *cl,
17807 __rte_unused void *data)
17809 struct cmd_cmdfile_result *res = parsed_result;
17811 cmdline_read_from_file(res->filename);
17814 cmdline_parse_inst_t cmd_load_from_file = {
17815 .f = cmd_load_from_file_parsed,
17817 .help_str = "load <filename>",
17819 (void *)&cmd_load_cmdfile,
17820 (void *)&cmd_load_cmdfile_filename,
17825 /* Get Rx offloads capabilities */
17826 struct cmd_rx_offload_get_capa_result {
17827 cmdline_fixed_string_t show;
17828 cmdline_fixed_string_t port;
17830 cmdline_fixed_string_t rx_offload;
17831 cmdline_fixed_string_t capabilities;
17834 cmdline_parse_token_string_t cmd_rx_offload_get_capa_show =
17835 TOKEN_STRING_INITIALIZER
17836 (struct cmd_rx_offload_get_capa_result,
17838 cmdline_parse_token_string_t cmd_rx_offload_get_capa_port =
17839 TOKEN_STRING_INITIALIZER
17840 (struct cmd_rx_offload_get_capa_result,
17842 cmdline_parse_token_num_t cmd_rx_offload_get_capa_port_id =
17843 TOKEN_NUM_INITIALIZER
17844 (struct cmd_rx_offload_get_capa_result,
17846 cmdline_parse_token_string_t cmd_rx_offload_get_capa_rx_offload =
17847 TOKEN_STRING_INITIALIZER
17848 (struct cmd_rx_offload_get_capa_result,
17849 rx_offload, "rx_offload");
17850 cmdline_parse_token_string_t cmd_rx_offload_get_capa_capabilities =
17851 TOKEN_STRING_INITIALIZER
17852 (struct cmd_rx_offload_get_capa_result,
17853 capabilities, "capabilities");
17856 print_rx_offloads(uint64_t offloads)
17858 uint64_t single_offload;
17866 begin = __builtin_ctzll(offloads);
17867 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
17869 single_offload = 1ULL << begin;
17870 for (bit = begin; bit < end; bit++) {
17871 if (offloads & single_offload)
17873 rte_eth_dev_rx_offload_name(single_offload));
17874 single_offload <<= 1;
17879 cmd_rx_offload_get_capa_parsed(
17880 void *parsed_result,
17881 __rte_unused struct cmdline *cl,
17882 __rte_unused void *data)
17884 struct cmd_rx_offload_get_capa_result *res = parsed_result;
17885 struct rte_eth_dev_info dev_info;
17886 portid_t port_id = res->port_id;
17887 uint64_t queue_offloads;
17888 uint64_t port_offloads;
17891 ret = eth_dev_info_get_print_err(port_id, &dev_info);
17895 queue_offloads = dev_info.rx_queue_offload_capa;
17896 port_offloads = dev_info.rx_offload_capa ^ queue_offloads;
17898 printf("Rx Offloading Capabilities of port %d :\n", port_id);
17899 printf(" Per Queue :");
17900 print_rx_offloads(queue_offloads);
17903 printf(" Per Port :");
17904 print_rx_offloads(port_offloads);
17908 cmdline_parse_inst_t cmd_rx_offload_get_capa = {
17909 .f = cmd_rx_offload_get_capa_parsed,
17911 .help_str = "show port <port_id> rx_offload capabilities",
17913 (void *)&cmd_rx_offload_get_capa_show,
17914 (void *)&cmd_rx_offload_get_capa_port,
17915 (void *)&cmd_rx_offload_get_capa_port_id,
17916 (void *)&cmd_rx_offload_get_capa_rx_offload,
17917 (void *)&cmd_rx_offload_get_capa_capabilities,
17922 /* Get Rx offloads configuration */
17923 struct cmd_rx_offload_get_configuration_result {
17924 cmdline_fixed_string_t show;
17925 cmdline_fixed_string_t port;
17927 cmdline_fixed_string_t rx_offload;
17928 cmdline_fixed_string_t configuration;
17931 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_show =
17932 TOKEN_STRING_INITIALIZER
17933 (struct cmd_rx_offload_get_configuration_result,
17935 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_port =
17936 TOKEN_STRING_INITIALIZER
17937 (struct cmd_rx_offload_get_configuration_result,
17939 cmdline_parse_token_num_t cmd_rx_offload_get_configuration_port_id =
17940 TOKEN_NUM_INITIALIZER
17941 (struct cmd_rx_offload_get_configuration_result,
17943 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_rx_offload =
17944 TOKEN_STRING_INITIALIZER
17945 (struct cmd_rx_offload_get_configuration_result,
17946 rx_offload, "rx_offload");
17947 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_configuration =
17948 TOKEN_STRING_INITIALIZER
17949 (struct cmd_rx_offload_get_configuration_result,
17950 configuration, "configuration");
17953 cmd_rx_offload_get_configuration_parsed(
17954 void *parsed_result,
17955 __rte_unused struct cmdline *cl,
17956 __rte_unused void *data)
17958 struct cmd_rx_offload_get_configuration_result *res = parsed_result;
17959 struct rte_eth_dev_info dev_info;
17960 portid_t port_id = res->port_id;
17961 struct rte_port *port = &ports[port_id];
17962 uint64_t port_offloads;
17963 uint64_t queue_offloads;
17964 uint16_t nb_rx_queues;
17968 printf("Rx Offloading Configuration of port %d :\n", port_id);
17970 port_offloads = port->dev_conf.rxmode.offloads;
17972 print_rx_offloads(port_offloads);
17975 ret = eth_dev_info_get_print_err(port_id, &dev_info);
17979 nb_rx_queues = dev_info.nb_rx_queues;
17980 for (q = 0; q < nb_rx_queues; q++) {
17981 queue_offloads = port->rx_conf[q].offloads;
17982 printf(" Queue[%2d] :", q);
17983 print_rx_offloads(queue_offloads);
17989 cmdline_parse_inst_t cmd_rx_offload_get_configuration = {
17990 .f = cmd_rx_offload_get_configuration_parsed,
17992 .help_str = "show port <port_id> rx_offload configuration",
17994 (void *)&cmd_rx_offload_get_configuration_show,
17995 (void *)&cmd_rx_offload_get_configuration_port,
17996 (void *)&cmd_rx_offload_get_configuration_port_id,
17997 (void *)&cmd_rx_offload_get_configuration_rx_offload,
17998 (void *)&cmd_rx_offload_get_configuration_configuration,
18003 /* Enable/Disable a per port offloading */
18004 struct cmd_config_per_port_rx_offload_result {
18005 cmdline_fixed_string_t port;
18006 cmdline_fixed_string_t config;
18008 cmdline_fixed_string_t rx_offload;
18009 cmdline_fixed_string_t offload;
18010 cmdline_fixed_string_t on_off;
18013 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_port =
18014 TOKEN_STRING_INITIALIZER
18015 (struct cmd_config_per_port_rx_offload_result,
18017 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_config =
18018 TOKEN_STRING_INITIALIZER
18019 (struct cmd_config_per_port_rx_offload_result,
18021 cmdline_parse_token_num_t cmd_config_per_port_rx_offload_result_port_id =
18022 TOKEN_NUM_INITIALIZER
18023 (struct cmd_config_per_port_rx_offload_result,
18025 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_rx_offload =
18026 TOKEN_STRING_INITIALIZER
18027 (struct cmd_config_per_port_rx_offload_result,
18028 rx_offload, "rx_offload");
18029 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_offload =
18030 TOKEN_STRING_INITIALIZER
18031 (struct cmd_config_per_port_rx_offload_result,
18032 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
18033 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
18034 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
18035 "scatter#buffer_split#timestamp#security#"
18036 "keep_crc#rss_hash");
18037 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_on_off =
18038 TOKEN_STRING_INITIALIZER
18039 (struct cmd_config_per_port_rx_offload_result,
18043 search_rx_offload(const char *name)
18045 uint64_t single_offload;
18046 const char *single_name;
18050 single_offload = 1;
18051 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
18052 single_name = rte_eth_dev_rx_offload_name(single_offload);
18053 if (!strcasecmp(single_name, name)) {
18057 single_offload <<= 1;
18061 return single_offload;
18067 cmd_config_per_port_rx_offload_parsed(void *parsed_result,
18068 __rte_unused struct cmdline *cl,
18069 __rte_unused void *data)
18071 struct cmd_config_per_port_rx_offload_result *res = parsed_result;
18072 portid_t port_id = res->port_id;
18073 struct rte_eth_dev_info dev_info;
18074 struct rte_port *port = &ports[port_id];
18075 uint64_t single_offload;
18076 uint16_t nb_rx_queues;
18080 if (port->port_status != RTE_PORT_STOPPED) {
18081 printf("Error: Can't config offload when Port %d "
18082 "is not stopped\n", port_id);
18086 single_offload = search_rx_offload(res->offload);
18087 if (single_offload == 0) {
18088 printf("Unknown offload name: %s\n", res->offload);
18092 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18096 nb_rx_queues = dev_info.nb_rx_queues;
18097 if (!strcmp(res->on_off, "on")) {
18098 port->dev_conf.rxmode.offloads |= single_offload;
18099 for (q = 0; q < nb_rx_queues; q++)
18100 port->rx_conf[q].offloads |= single_offload;
18102 port->dev_conf.rxmode.offloads &= ~single_offload;
18103 for (q = 0; q < nb_rx_queues; q++)
18104 port->rx_conf[q].offloads &= ~single_offload;
18107 cmd_reconfig_device_queue(port_id, 1, 1);
18110 cmdline_parse_inst_t cmd_config_per_port_rx_offload = {
18111 .f = cmd_config_per_port_rx_offload_parsed,
18113 .help_str = "port config <port_id> rx_offload vlan_strip|ipv4_cksum|"
18114 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
18115 "macsec_strip|header_split|vlan_filter|vlan_extend|"
18116 "jumbo_frame|scatter|buffer_split|timestamp|security|"
18117 "keep_crc|rss_hash on|off",
18119 (void *)&cmd_config_per_port_rx_offload_result_port,
18120 (void *)&cmd_config_per_port_rx_offload_result_config,
18121 (void *)&cmd_config_per_port_rx_offload_result_port_id,
18122 (void *)&cmd_config_per_port_rx_offload_result_rx_offload,
18123 (void *)&cmd_config_per_port_rx_offload_result_offload,
18124 (void *)&cmd_config_per_port_rx_offload_result_on_off,
18129 /* Enable/Disable a per queue offloading */
18130 struct cmd_config_per_queue_rx_offload_result {
18131 cmdline_fixed_string_t port;
18133 cmdline_fixed_string_t rxq;
18135 cmdline_fixed_string_t rx_offload;
18136 cmdline_fixed_string_t offload;
18137 cmdline_fixed_string_t on_off;
18140 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_port =
18141 TOKEN_STRING_INITIALIZER
18142 (struct cmd_config_per_queue_rx_offload_result,
18144 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_port_id =
18145 TOKEN_NUM_INITIALIZER
18146 (struct cmd_config_per_queue_rx_offload_result,
18148 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxq =
18149 TOKEN_STRING_INITIALIZER
18150 (struct cmd_config_per_queue_rx_offload_result,
18152 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_queue_id =
18153 TOKEN_NUM_INITIALIZER
18154 (struct cmd_config_per_queue_rx_offload_result,
18156 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxoffload =
18157 TOKEN_STRING_INITIALIZER
18158 (struct cmd_config_per_queue_rx_offload_result,
18159 rx_offload, "rx_offload");
18160 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_offload =
18161 TOKEN_STRING_INITIALIZER
18162 (struct cmd_config_per_queue_rx_offload_result,
18163 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
18164 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
18165 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
18166 "scatter#buffer_split#timestamp#security#keep_crc");
18167 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_on_off =
18168 TOKEN_STRING_INITIALIZER
18169 (struct cmd_config_per_queue_rx_offload_result,
18173 cmd_config_per_queue_rx_offload_parsed(void *parsed_result,
18174 __rte_unused struct cmdline *cl,
18175 __rte_unused void *data)
18177 struct cmd_config_per_queue_rx_offload_result *res = parsed_result;
18178 struct rte_eth_dev_info dev_info;
18179 portid_t port_id = res->port_id;
18180 uint16_t queue_id = res->queue_id;
18181 struct rte_port *port = &ports[port_id];
18182 uint64_t single_offload;
18185 if (port->port_status != RTE_PORT_STOPPED) {
18186 printf("Error: Can't config offload when Port %d "
18187 "is not stopped\n", port_id);
18191 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18195 if (queue_id >= dev_info.nb_rx_queues) {
18196 printf("Error: input queue_id should be 0 ... "
18197 "%d\n", dev_info.nb_rx_queues - 1);
18201 single_offload = search_rx_offload(res->offload);
18202 if (single_offload == 0) {
18203 printf("Unknown offload name: %s\n", res->offload);
18207 if (!strcmp(res->on_off, "on"))
18208 port->rx_conf[queue_id].offloads |= single_offload;
18210 port->rx_conf[queue_id].offloads &= ~single_offload;
18212 cmd_reconfig_device_queue(port_id, 1, 1);
18215 cmdline_parse_inst_t cmd_config_per_queue_rx_offload = {
18216 .f = cmd_config_per_queue_rx_offload_parsed,
18218 .help_str = "port <port_id> rxq <queue_id> rx_offload "
18219 "vlan_strip|ipv4_cksum|"
18220 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
18221 "macsec_strip|header_split|vlan_filter|vlan_extend|"
18222 "jumbo_frame|scatter|buffer_split|timestamp|security|"
18225 (void *)&cmd_config_per_queue_rx_offload_result_port,
18226 (void *)&cmd_config_per_queue_rx_offload_result_port_id,
18227 (void *)&cmd_config_per_queue_rx_offload_result_rxq,
18228 (void *)&cmd_config_per_queue_rx_offload_result_queue_id,
18229 (void *)&cmd_config_per_queue_rx_offload_result_rxoffload,
18230 (void *)&cmd_config_per_queue_rx_offload_result_offload,
18231 (void *)&cmd_config_per_queue_rx_offload_result_on_off,
18236 /* Get Tx offloads capabilities */
18237 struct cmd_tx_offload_get_capa_result {
18238 cmdline_fixed_string_t show;
18239 cmdline_fixed_string_t port;
18241 cmdline_fixed_string_t tx_offload;
18242 cmdline_fixed_string_t capabilities;
18245 cmdline_parse_token_string_t cmd_tx_offload_get_capa_show =
18246 TOKEN_STRING_INITIALIZER
18247 (struct cmd_tx_offload_get_capa_result,
18249 cmdline_parse_token_string_t cmd_tx_offload_get_capa_port =
18250 TOKEN_STRING_INITIALIZER
18251 (struct cmd_tx_offload_get_capa_result,
18253 cmdline_parse_token_num_t cmd_tx_offload_get_capa_port_id =
18254 TOKEN_NUM_INITIALIZER
18255 (struct cmd_tx_offload_get_capa_result,
18257 cmdline_parse_token_string_t cmd_tx_offload_get_capa_tx_offload =
18258 TOKEN_STRING_INITIALIZER
18259 (struct cmd_tx_offload_get_capa_result,
18260 tx_offload, "tx_offload");
18261 cmdline_parse_token_string_t cmd_tx_offload_get_capa_capabilities =
18262 TOKEN_STRING_INITIALIZER
18263 (struct cmd_tx_offload_get_capa_result,
18264 capabilities, "capabilities");
18267 print_tx_offloads(uint64_t offloads)
18269 uint64_t single_offload;
18277 begin = __builtin_ctzll(offloads);
18278 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
18280 single_offload = 1ULL << begin;
18281 for (bit = begin; bit < end; bit++) {
18282 if (offloads & single_offload)
18284 rte_eth_dev_tx_offload_name(single_offload));
18285 single_offload <<= 1;
18290 cmd_tx_offload_get_capa_parsed(
18291 void *parsed_result,
18292 __rte_unused struct cmdline *cl,
18293 __rte_unused void *data)
18295 struct cmd_tx_offload_get_capa_result *res = parsed_result;
18296 struct rte_eth_dev_info dev_info;
18297 portid_t port_id = res->port_id;
18298 uint64_t queue_offloads;
18299 uint64_t port_offloads;
18302 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18306 queue_offloads = dev_info.tx_queue_offload_capa;
18307 port_offloads = dev_info.tx_offload_capa ^ queue_offloads;
18309 printf("Tx Offloading Capabilities of port %d :\n", port_id);
18310 printf(" Per Queue :");
18311 print_tx_offloads(queue_offloads);
18314 printf(" Per Port :");
18315 print_tx_offloads(port_offloads);
18319 cmdline_parse_inst_t cmd_tx_offload_get_capa = {
18320 .f = cmd_tx_offload_get_capa_parsed,
18322 .help_str = "show port <port_id> tx_offload capabilities",
18324 (void *)&cmd_tx_offload_get_capa_show,
18325 (void *)&cmd_tx_offload_get_capa_port,
18326 (void *)&cmd_tx_offload_get_capa_port_id,
18327 (void *)&cmd_tx_offload_get_capa_tx_offload,
18328 (void *)&cmd_tx_offload_get_capa_capabilities,
18333 /* Get Tx offloads configuration */
18334 struct cmd_tx_offload_get_configuration_result {
18335 cmdline_fixed_string_t show;
18336 cmdline_fixed_string_t port;
18338 cmdline_fixed_string_t tx_offload;
18339 cmdline_fixed_string_t configuration;
18342 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_show =
18343 TOKEN_STRING_INITIALIZER
18344 (struct cmd_tx_offload_get_configuration_result,
18346 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_port =
18347 TOKEN_STRING_INITIALIZER
18348 (struct cmd_tx_offload_get_configuration_result,
18350 cmdline_parse_token_num_t cmd_tx_offload_get_configuration_port_id =
18351 TOKEN_NUM_INITIALIZER
18352 (struct cmd_tx_offload_get_configuration_result,
18354 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_tx_offload =
18355 TOKEN_STRING_INITIALIZER
18356 (struct cmd_tx_offload_get_configuration_result,
18357 tx_offload, "tx_offload");
18358 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_configuration =
18359 TOKEN_STRING_INITIALIZER
18360 (struct cmd_tx_offload_get_configuration_result,
18361 configuration, "configuration");
18364 cmd_tx_offload_get_configuration_parsed(
18365 void *parsed_result,
18366 __rte_unused struct cmdline *cl,
18367 __rte_unused void *data)
18369 struct cmd_tx_offload_get_configuration_result *res = parsed_result;
18370 struct rte_eth_dev_info dev_info;
18371 portid_t port_id = res->port_id;
18372 struct rte_port *port = &ports[port_id];
18373 uint64_t port_offloads;
18374 uint64_t queue_offloads;
18375 uint16_t nb_tx_queues;
18379 printf("Tx Offloading Configuration of port %d :\n", port_id);
18381 port_offloads = port->dev_conf.txmode.offloads;
18383 print_tx_offloads(port_offloads);
18386 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18390 nb_tx_queues = dev_info.nb_tx_queues;
18391 for (q = 0; q < nb_tx_queues; q++) {
18392 queue_offloads = port->tx_conf[q].offloads;
18393 printf(" Queue[%2d] :", q);
18394 print_tx_offloads(queue_offloads);
18400 cmdline_parse_inst_t cmd_tx_offload_get_configuration = {
18401 .f = cmd_tx_offload_get_configuration_parsed,
18403 .help_str = "show port <port_id> tx_offload configuration",
18405 (void *)&cmd_tx_offload_get_configuration_show,
18406 (void *)&cmd_tx_offload_get_configuration_port,
18407 (void *)&cmd_tx_offload_get_configuration_port_id,
18408 (void *)&cmd_tx_offload_get_configuration_tx_offload,
18409 (void *)&cmd_tx_offload_get_configuration_configuration,
18414 /* Enable/Disable a per port offloading */
18415 struct cmd_config_per_port_tx_offload_result {
18416 cmdline_fixed_string_t port;
18417 cmdline_fixed_string_t config;
18419 cmdline_fixed_string_t tx_offload;
18420 cmdline_fixed_string_t offload;
18421 cmdline_fixed_string_t on_off;
18424 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_port =
18425 TOKEN_STRING_INITIALIZER
18426 (struct cmd_config_per_port_tx_offload_result,
18428 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_config =
18429 TOKEN_STRING_INITIALIZER
18430 (struct cmd_config_per_port_tx_offload_result,
18432 cmdline_parse_token_num_t cmd_config_per_port_tx_offload_result_port_id =
18433 TOKEN_NUM_INITIALIZER
18434 (struct cmd_config_per_port_tx_offload_result,
18436 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_tx_offload =
18437 TOKEN_STRING_INITIALIZER
18438 (struct cmd_config_per_port_tx_offload_result,
18439 tx_offload, "tx_offload");
18440 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_offload =
18441 TOKEN_STRING_INITIALIZER
18442 (struct cmd_config_per_port_tx_offload_result,
18443 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
18444 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
18445 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
18446 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
18447 "mt_lockfree#multi_segs#mbuf_fast_free#security#"
18448 "send_on_timestamp");
18449 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_on_off =
18450 TOKEN_STRING_INITIALIZER
18451 (struct cmd_config_per_port_tx_offload_result,
18455 search_tx_offload(const char *name)
18457 uint64_t single_offload;
18458 const char *single_name;
18462 single_offload = 1;
18463 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
18464 single_name = rte_eth_dev_tx_offload_name(single_offload);
18465 if (single_name == NULL)
18467 if (!strcasecmp(single_name, name)) {
18470 } else if (!strcasecmp(single_name, "UNKNOWN"))
18472 single_offload <<= 1;
18476 return single_offload;
18482 cmd_config_per_port_tx_offload_parsed(void *parsed_result,
18483 __rte_unused struct cmdline *cl,
18484 __rte_unused void *data)
18486 struct cmd_config_per_port_tx_offload_result *res = parsed_result;
18487 portid_t port_id = res->port_id;
18488 struct rte_eth_dev_info dev_info;
18489 struct rte_port *port = &ports[port_id];
18490 uint64_t single_offload;
18491 uint16_t nb_tx_queues;
18495 if (port->port_status != RTE_PORT_STOPPED) {
18496 printf("Error: Can't config offload when Port %d "
18497 "is not stopped\n", port_id);
18501 single_offload = search_tx_offload(res->offload);
18502 if (single_offload == 0) {
18503 printf("Unknown offload name: %s\n", res->offload);
18507 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18511 nb_tx_queues = dev_info.nb_tx_queues;
18512 if (!strcmp(res->on_off, "on")) {
18513 port->dev_conf.txmode.offloads |= single_offload;
18514 for (q = 0; q < nb_tx_queues; q++)
18515 port->tx_conf[q].offloads |= single_offload;
18517 port->dev_conf.txmode.offloads &= ~single_offload;
18518 for (q = 0; q < nb_tx_queues; q++)
18519 port->tx_conf[q].offloads &= ~single_offload;
18522 cmd_reconfig_device_queue(port_id, 1, 1);
18525 cmdline_parse_inst_t cmd_config_per_port_tx_offload = {
18526 .f = cmd_config_per_port_tx_offload_parsed,
18528 .help_str = "port config <port_id> tx_offload "
18529 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
18530 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
18531 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
18532 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
18533 "mt_lockfree|multi_segs|mbuf_fast_free|security|"
18534 "send_on_timestamp on|off",
18536 (void *)&cmd_config_per_port_tx_offload_result_port,
18537 (void *)&cmd_config_per_port_tx_offload_result_config,
18538 (void *)&cmd_config_per_port_tx_offload_result_port_id,
18539 (void *)&cmd_config_per_port_tx_offload_result_tx_offload,
18540 (void *)&cmd_config_per_port_tx_offload_result_offload,
18541 (void *)&cmd_config_per_port_tx_offload_result_on_off,
18546 /* Enable/Disable a per queue offloading */
18547 struct cmd_config_per_queue_tx_offload_result {
18548 cmdline_fixed_string_t port;
18550 cmdline_fixed_string_t txq;
18552 cmdline_fixed_string_t tx_offload;
18553 cmdline_fixed_string_t offload;
18554 cmdline_fixed_string_t on_off;
18557 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_port =
18558 TOKEN_STRING_INITIALIZER
18559 (struct cmd_config_per_queue_tx_offload_result,
18561 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_port_id =
18562 TOKEN_NUM_INITIALIZER
18563 (struct cmd_config_per_queue_tx_offload_result,
18565 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txq =
18566 TOKEN_STRING_INITIALIZER
18567 (struct cmd_config_per_queue_tx_offload_result,
18569 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_queue_id =
18570 TOKEN_NUM_INITIALIZER
18571 (struct cmd_config_per_queue_tx_offload_result,
18573 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txoffload =
18574 TOKEN_STRING_INITIALIZER
18575 (struct cmd_config_per_queue_tx_offload_result,
18576 tx_offload, "tx_offload");
18577 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_offload =
18578 TOKEN_STRING_INITIALIZER
18579 (struct cmd_config_per_queue_tx_offload_result,
18580 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
18581 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
18582 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
18583 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
18584 "mt_lockfree#multi_segs#mbuf_fast_free#security");
18585 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_on_off =
18586 TOKEN_STRING_INITIALIZER
18587 (struct cmd_config_per_queue_tx_offload_result,
18591 cmd_config_per_queue_tx_offload_parsed(void *parsed_result,
18592 __rte_unused struct cmdline *cl,
18593 __rte_unused void *data)
18595 struct cmd_config_per_queue_tx_offload_result *res = parsed_result;
18596 struct rte_eth_dev_info dev_info;
18597 portid_t port_id = res->port_id;
18598 uint16_t queue_id = res->queue_id;
18599 struct rte_port *port = &ports[port_id];
18600 uint64_t single_offload;
18603 if (port->port_status != RTE_PORT_STOPPED) {
18604 printf("Error: Can't config offload when Port %d "
18605 "is not stopped\n", port_id);
18609 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18613 if (queue_id >= dev_info.nb_tx_queues) {
18614 printf("Error: input queue_id should be 0 ... "
18615 "%d\n", dev_info.nb_tx_queues - 1);
18619 single_offload = search_tx_offload(res->offload);
18620 if (single_offload == 0) {
18621 printf("Unknown offload name: %s\n", res->offload);
18625 if (!strcmp(res->on_off, "on"))
18626 port->tx_conf[queue_id].offloads |= single_offload;
18628 port->tx_conf[queue_id].offloads &= ~single_offload;
18630 cmd_reconfig_device_queue(port_id, 1, 1);
18633 cmdline_parse_inst_t cmd_config_per_queue_tx_offload = {
18634 .f = cmd_config_per_queue_tx_offload_parsed,
18636 .help_str = "port <port_id> txq <queue_id> tx_offload "
18637 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
18638 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
18639 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
18640 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
18641 "mt_lockfree|multi_segs|mbuf_fast_free|security "
18644 (void *)&cmd_config_per_queue_tx_offload_result_port,
18645 (void *)&cmd_config_per_queue_tx_offload_result_port_id,
18646 (void *)&cmd_config_per_queue_tx_offload_result_txq,
18647 (void *)&cmd_config_per_queue_tx_offload_result_queue_id,
18648 (void *)&cmd_config_per_queue_tx_offload_result_txoffload,
18649 (void *)&cmd_config_per_queue_tx_offload_result_offload,
18650 (void *)&cmd_config_per_queue_tx_offload_result_on_off,
18655 /* *** configure tx_metadata for specific port *** */
18656 struct cmd_config_tx_metadata_specific_result {
18657 cmdline_fixed_string_t port;
18658 cmdline_fixed_string_t keyword;
18660 cmdline_fixed_string_t item;
18665 cmd_config_tx_metadata_specific_parsed(void *parsed_result,
18666 __rte_unused struct cmdline *cl,
18667 __rte_unused void *data)
18669 struct cmd_config_tx_metadata_specific_result *res = parsed_result;
18671 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
18673 ports[res->port_id].tx_metadata = res->value;
18674 /* Add/remove callback to insert valid metadata in every Tx packet. */
18675 if (ports[res->port_id].tx_metadata)
18676 add_tx_md_callback(res->port_id);
18678 remove_tx_md_callback(res->port_id);
18679 rte_flow_dynf_metadata_register();
18682 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_port =
18683 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18685 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_keyword =
18686 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18687 keyword, "config");
18688 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_id =
18689 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18691 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_item =
18692 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18693 item, "tx_metadata");
18694 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_value =
18695 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18698 cmdline_parse_inst_t cmd_config_tx_metadata_specific = {
18699 .f = cmd_config_tx_metadata_specific_parsed,
18701 .help_str = "port config <port_id> tx_metadata <value>",
18703 (void *)&cmd_config_tx_metadata_specific_port,
18704 (void *)&cmd_config_tx_metadata_specific_keyword,
18705 (void *)&cmd_config_tx_metadata_specific_id,
18706 (void *)&cmd_config_tx_metadata_specific_item,
18707 (void *)&cmd_config_tx_metadata_specific_value,
18712 /* *** set dynf *** */
18713 struct cmd_config_tx_dynf_specific_result {
18714 cmdline_fixed_string_t port;
18715 cmdline_fixed_string_t keyword;
18717 cmdline_fixed_string_t item;
18718 cmdline_fixed_string_t name;
18719 cmdline_fixed_string_t value;
18723 cmd_config_dynf_specific_parsed(void *parsed_result,
18724 __rte_unused struct cmdline *cl,
18725 __rte_unused void *data)
18727 struct cmd_config_tx_dynf_specific_result *res = parsed_result;
18728 struct rte_mbuf_dynflag desc_flag;
18730 uint64_t old_port_flags;
18732 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
18734 flag = rte_mbuf_dynflag_lookup(res->name, NULL);
18736 if (strlcpy(desc_flag.name, res->name,
18737 RTE_MBUF_DYN_NAMESIZE) >= RTE_MBUF_DYN_NAMESIZE) {
18738 printf("Flag name too long\n");
18741 desc_flag.flags = 0;
18742 flag = rte_mbuf_dynflag_register(&desc_flag);
18744 printf("Can't register flag\n");
18747 strcpy(dynf_names[flag], desc_flag.name);
18749 old_port_flags = ports[res->port_id].mbuf_dynf;
18750 if (!strcmp(res->value, "set")) {
18751 ports[res->port_id].mbuf_dynf |= 1UL << flag;
18752 if (old_port_flags == 0)
18753 add_tx_dynf_callback(res->port_id);
18755 ports[res->port_id].mbuf_dynf &= ~(1UL << flag);
18756 if (ports[res->port_id].mbuf_dynf == 0)
18757 remove_tx_dynf_callback(res->port_id);
18761 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_port =
18762 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
18764 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_keyword =
18765 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
18766 keyword, "config");
18767 cmdline_parse_token_num_t cmd_config_tx_dynf_specific_port_id =
18768 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
18770 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_item =
18771 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
18773 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_name =
18774 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
18776 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_value =
18777 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
18778 value, "set#clear");
18780 cmdline_parse_inst_t cmd_config_tx_dynf_specific = {
18781 .f = cmd_config_dynf_specific_parsed,
18783 .help_str = "port config <port id> dynf <name> set|clear",
18785 (void *)&cmd_config_tx_dynf_specific_port,
18786 (void *)&cmd_config_tx_dynf_specific_keyword,
18787 (void *)&cmd_config_tx_dynf_specific_port_id,
18788 (void *)&cmd_config_tx_dynf_specific_item,
18789 (void *)&cmd_config_tx_dynf_specific_name,
18790 (void *)&cmd_config_tx_dynf_specific_value,
18795 /* *** display tx_metadata per port configuration *** */
18796 struct cmd_show_tx_metadata_result {
18797 cmdline_fixed_string_t cmd_show;
18798 cmdline_fixed_string_t cmd_port;
18799 cmdline_fixed_string_t cmd_keyword;
18804 cmd_show_tx_metadata_parsed(void *parsed_result,
18805 __rte_unused struct cmdline *cl,
18806 __rte_unused void *data)
18808 struct cmd_show_tx_metadata_result *res = parsed_result;
18810 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
18811 printf("invalid port id %u\n", res->cmd_pid);
18814 if (!strcmp(res->cmd_keyword, "tx_metadata")) {
18815 printf("Port %u tx_metadata: %u\n", res->cmd_pid,
18816 ports[res->cmd_pid].tx_metadata);
18820 cmdline_parse_token_string_t cmd_show_tx_metadata_show =
18821 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
18823 cmdline_parse_token_string_t cmd_show_tx_metadata_port =
18824 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
18826 cmdline_parse_token_num_t cmd_show_tx_metadata_pid =
18827 TOKEN_NUM_INITIALIZER(struct cmd_show_tx_metadata_result,
18829 cmdline_parse_token_string_t cmd_show_tx_metadata_keyword =
18830 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
18831 cmd_keyword, "tx_metadata");
18833 cmdline_parse_inst_t cmd_show_tx_metadata = {
18834 .f = cmd_show_tx_metadata_parsed,
18836 .help_str = "show port <port_id> tx_metadata",
18838 (void *)&cmd_show_tx_metadata_show,
18839 (void *)&cmd_show_tx_metadata_port,
18840 (void *)&cmd_show_tx_metadata_pid,
18841 (void *)&cmd_show_tx_metadata_keyword,
18846 /* *** show fec capability per port configuration *** */
18847 struct cmd_show_fec_capability_result {
18848 cmdline_fixed_string_t cmd_show;
18849 cmdline_fixed_string_t cmd_port;
18850 cmdline_fixed_string_t cmd_fec;
18851 cmdline_fixed_string_t cmd_keyword;
18856 cmd_show_fec_capability_parsed(void *parsed_result,
18857 __rte_unused struct cmdline *cl,
18858 __rte_unused void *data)
18860 #define FEC_CAP_NUM 2
18861 struct cmd_show_fec_capability_result *res = parsed_result;
18862 struct rte_eth_fec_capa speed_fec_capa[FEC_CAP_NUM];
18863 unsigned int num = FEC_CAP_NUM;
18864 unsigned int ret_num;
18867 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
18868 printf("Invalid port id %u\n", res->cmd_pid);
18872 ret = rte_eth_fec_get_capability(res->cmd_pid, speed_fec_capa, num);
18873 if (ret == -ENOTSUP) {
18874 printf("Function not implemented\n");
18876 } else if (ret < 0) {
18877 printf("Get FEC capability failed\n");
18881 ret_num = (unsigned int)ret;
18882 show_fec_capability(ret_num, speed_fec_capa);
18885 cmdline_parse_token_string_t cmd_show_fec_capability_show =
18886 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
18888 cmdline_parse_token_string_t cmd_show_fec_capability_port =
18889 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
18891 cmdline_parse_token_num_t cmd_show_fec_capability_pid =
18892 TOKEN_NUM_INITIALIZER(struct cmd_show_fec_capability_result,
18894 cmdline_parse_token_string_t cmd_show_fec_capability_fec =
18895 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
18897 cmdline_parse_token_string_t cmd_show_fec_capability_keyword =
18898 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
18899 cmd_keyword, "capabilities");
18901 cmdline_parse_inst_t cmd_show_capability = {
18902 .f = cmd_show_fec_capability_parsed,
18904 .help_str = "show port <port_id> fec capabilities",
18906 (void *)&cmd_show_fec_capability_show,
18907 (void *)&cmd_show_fec_capability_port,
18908 (void *)&cmd_show_fec_capability_pid,
18909 (void *)&cmd_show_fec_capability_fec,
18910 (void *)&cmd_show_fec_capability_keyword,
18915 /* *** show fec mode per port configuration *** */
18916 struct cmd_show_fec_metadata_result {
18917 cmdline_fixed_string_t cmd_show;
18918 cmdline_fixed_string_t cmd_port;
18919 cmdline_fixed_string_t cmd_keyword;
18924 cmd_show_fec_mode_parsed(void *parsed_result,
18925 __rte_unused struct cmdline *cl,
18926 __rte_unused void *data)
18928 #define FEC_NAME_SIZE 16
18929 struct cmd_show_fec_metadata_result *res = parsed_result;
18931 char buf[FEC_NAME_SIZE];
18934 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
18935 printf("Invalid port id %u\n", res->cmd_pid);
18938 ret = rte_eth_fec_get(res->cmd_pid, &mode);
18939 if (ret == -ENOTSUP) {
18940 printf("Function not implemented\n");
18942 } else if (ret < 0) {
18943 printf("Get FEC mode failed\n");
18948 case RTE_ETH_FEC_MODE_CAPA_MASK(NOFEC):
18949 strlcpy(buf, "off", sizeof(buf));
18951 case RTE_ETH_FEC_MODE_CAPA_MASK(AUTO):
18952 strlcpy(buf, "auto", sizeof(buf));
18954 case RTE_ETH_FEC_MODE_CAPA_MASK(BASER):
18955 strlcpy(buf, "baser", sizeof(buf));
18957 case RTE_ETH_FEC_MODE_CAPA_MASK(RS):
18958 strlcpy(buf, "rs", sizeof(buf));
18964 printf("%s\n", buf);
18967 cmdline_parse_token_string_t cmd_show_fec_mode_show =
18968 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
18970 cmdline_parse_token_string_t cmd_show_fec_mode_port =
18971 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
18973 cmdline_parse_token_num_t cmd_show_fec_mode_pid =
18974 TOKEN_NUM_INITIALIZER(struct cmd_show_fec_metadata_result,
18976 cmdline_parse_token_string_t cmd_show_fec_mode_keyword =
18977 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
18978 cmd_keyword, "fec_mode");
18980 cmdline_parse_inst_t cmd_show_fec_mode = {
18981 .f = cmd_show_fec_mode_parsed,
18983 .help_str = "show port <port_id> fec_mode",
18985 (void *)&cmd_show_fec_mode_show,
18986 (void *)&cmd_show_fec_mode_port,
18987 (void *)&cmd_show_fec_mode_pid,
18988 (void *)&cmd_show_fec_mode_keyword,
18993 /* *** set fec mode per port configuration *** */
18994 struct cmd_set_port_fec_mode {
18995 cmdline_fixed_string_t set;
18996 cmdline_fixed_string_t port;
18998 cmdline_fixed_string_t fec_mode;
18999 cmdline_fixed_string_t fec_value;
19002 /* Common CLI fields for set fec mode */
19003 cmdline_parse_token_string_t cmd_set_port_fec_mode_set =
19004 TOKEN_STRING_INITIALIZER
19005 (struct cmd_set_port_fec_mode,
19007 cmdline_parse_token_string_t cmd_set_port_fec_mode_port =
19008 TOKEN_STRING_INITIALIZER
19009 (struct cmd_set_port_fec_mode,
19011 cmdline_parse_token_num_t cmd_set_port_fec_mode_port_id =
19012 TOKEN_NUM_INITIALIZER
19013 (struct cmd_set_port_fec_mode,
19015 cmdline_parse_token_string_t cmd_set_port_fec_mode_str =
19016 TOKEN_STRING_INITIALIZER
19017 (struct cmd_set_port_fec_mode,
19018 fec_mode, "fec_mode");
19019 cmdline_parse_token_string_t cmd_set_port_fec_mode_value =
19020 TOKEN_STRING_INITIALIZER
19021 (struct cmd_set_port_fec_mode,
19025 cmd_set_port_fec_mode_parsed(
19026 void *parsed_result,
19027 __rte_unused struct cmdline *cl,
19028 __rte_unused void *data)
19030 struct cmd_set_port_fec_mode *res = parsed_result;
19031 uint16_t port_id = res->port_id;
19035 ret = parse_fec_mode(res->fec_value, &mode);
19037 printf("Unknown fec mode: %s for Port %d\n", res->fec_value,
19042 ret = rte_eth_fec_set(port_id, mode);
19043 if (ret == -ENOTSUP) {
19044 printf("Function not implemented\n");
19046 } else if (ret < 0) {
19047 printf("Set FEC mode failed\n");
19052 cmdline_parse_inst_t cmd_set_fec_mode = {
19053 .f = cmd_set_port_fec_mode_parsed,
19055 .help_str = "set port <port_id> fec_mode auto|off|rs|baser",
19057 (void *)&cmd_set_port_fec_mode_set,
19058 (void *)&cmd_set_port_fec_mode_port,
19059 (void *)&cmd_set_port_fec_mode_port_id,
19060 (void *)&cmd_set_port_fec_mode_str,
19061 (void *)&cmd_set_port_fec_mode_value,
19066 /* show port supported ptypes */
19068 /* Common result structure for show port ptypes */
19069 struct cmd_show_port_supported_ptypes_result {
19070 cmdline_fixed_string_t show;
19071 cmdline_fixed_string_t port;
19073 cmdline_fixed_string_t ptypes;
19076 /* Common CLI fields for show port ptypes */
19077 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_show =
19078 TOKEN_STRING_INITIALIZER
19079 (struct cmd_show_port_supported_ptypes_result,
19081 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_port =
19082 TOKEN_STRING_INITIALIZER
19083 (struct cmd_show_port_supported_ptypes_result,
19085 cmdline_parse_token_num_t cmd_show_port_supported_ptypes_port_id =
19086 TOKEN_NUM_INITIALIZER
19087 (struct cmd_show_port_supported_ptypes_result,
19089 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_ptypes =
19090 TOKEN_STRING_INITIALIZER
19091 (struct cmd_show_port_supported_ptypes_result,
19095 cmd_show_port_supported_ptypes_parsed(
19096 void *parsed_result,
19097 __rte_unused struct cmdline *cl,
19098 __rte_unused void *data)
19100 #define RSVD_PTYPE_MASK 0xf0000000
19101 #define MAX_PTYPES_PER_LAYER 16
19102 #define LTYPE_NAMESIZE 32
19103 #define PTYPE_NAMESIZE 256
19104 struct cmd_show_port_supported_ptypes_result *res = parsed_result;
19105 char buf[PTYPE_NAMESIZE], ltype[LTYPE_NAMESIZE];
19106 uint32_t ptype_mask = RTE_PTYPE_L2_MASK;
19107 uint32_t ptypes[MAX_PTYPES_PER_LAYER];
19108 uint16_t port_id = res->port_id;
19111 ret = rte_eth_dev_get_supported_ptypes(port_id, ptype_mask, NULL, 0);
19115 while (ptype_mask != RSVD_PTYPE_MASK) {
19117 switch (ptype_mask) {
19118 case RTE_PTYPE_L2_MASK:
19119 strlcpy(ltype, "L2", sizeof(ltype));
19121 case RTE_PTYPE_L3_MASK:
19122 strlcpy(ltype, "L3", sizeof(ltype));
19124 case RTE_PTYPE_L4_MASK:
19125 strlcpy(ltype, "L4", sizeof(ltype));
19127 case RTE_PTYPE_TUNNEL_MASK:
19128 strlcpy(ltype, "Tunnel", sizeof(ltype));
19130 case RTE_PTYPE_INNER_L2_MASK:
19131 strlcpy(ltype, "Inner L2", sizeof(ltype));
19133 case RTE_PTYPE_INNER_L3_MASK:
19134 strlcpy(ltype, "Inner L3", sizeof(ltype));
19136 case RTE_PTYPE_INNER_L4_MASK:
19137 strlcpy(ltype, "Inner L4", sizeof(ltype));
19143 ret = rte_eth_dev_get_supported_ptypes(res->port_id,
19144 ptype_mask, ptypes,
19145 MAX_PTYPES_PER_LAYER);
19148 printf("Supported %s ptypes:\n", ltype);
19150 printf("%s ptypes unsupported\n", ltype);
19152 for (i = 0; i < ret; ++i) {
19153 rte_get_ptype_name(ptypes[i], buf, sizeof(buf));
19154 printf("%s\n", buf);
19161 cmdline_parse_inst_t cmd_show_port_supported_ptypes = {
19162 .f = cmd_show_port_supported_ptypes_parsed,
19164 .help_str = "show port <port_id> ptypes",
19166 (void *)&cmd_show_port_supported_ptypes_show,
19167 (void *)&cmd_show_port_supported_ptypes_port,
19168 (void *)&cmd_show_port_supported_ptypes_port_id,
19169 (void *)&cmd_show_port_supported_ptypes_ptypes,
19174 /* *** display rx/tx descriptor status *** */
19175 struct cmd_show_rx_tx_desc_status_result {
19176 cmdline_fixed_string_t cmd_show;
19177 cmdline_fixed_string_t cmd_port;
19178 cmdline_fixed_string_t cmd_keyword;
19179 cmdline_fixed_string_t cmd_desc;
19180 cmdline_fixed_string_t cmd_status;
19187 cmd_show_rx_tx_desc_status_parsed(void *parsed_result,
19188 __rte_unused struct cmdline *cl,
19189 __rte_unused void *data)
19191 struct cmd_show_rx_tx_desc_status_result *res = parsed_result;
19194 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
19195 printf("invalid port id %u\n", res->cmd_pid);
19199 if (!strcmp(res->cmd_keyword, "rxq")) {
19200 rc = rte_eth_rx_descriptor_status(res->cmd_pid, res->cmd_qid,
19203 printf("Invalid queueid = %d\n", res->cmd_qid);
19206 if (rc == RTE_ETH_RX_DESC_AVAIL)
19207 printf("Desc status = AVAILABLE\n");
19208 else if (rc == RTE_ETH_RX_DESC_DONE)
19209 printf("Desc status = DONE\n");
19211 printf("Desc status = UNAVAILABLE\n");
19212 } else if (!strcmp(res->cmd_keyword, "txq")) {
19213 rc = rte_eth_tx_descriptor_status(res->cmd_pid, res->cmd_qid,
19216 printf("Invalid queueid = %d\n", res->cmd_qid);
19219 if (rc == RTE_ETH_TX_DESC_FULL)
19220 printf("Desc status = FULL\n");
19221 else if (rc == RTE_ETH_TX_DESC_DONE)
19222 printf("Desc status = DONE\n");
19224 printf("Desc status = UNAVAILABLE\n");
19228 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_show =
19229 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19231 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_port =
19232 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19234 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_pid =
19235 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19237 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_keyword =
19238 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19239 cmd_keyword, "rxq#txq");
19240 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_qid =
19241 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19243 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_desc =
19244 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19246 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_did =
19247 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19249 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_status =
19250 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19251 cmd_status, "status");
19252 cmdline_parse_inst_t cmd_show_rx_tx_desc_status = {
19253 .f = cmd_show_rx_tx_desc_status_parsed,
19255 .help_str = "show port <port_id> rxq|txq <queue_id> desc <desc_id> "
19258 (void *)&cmd_show_rx_tx_desc_status_show,
19259 (void *)&cmd_show_rx_tx_desc_status_port,
19260 (void *)&cmd_show_rx_tx_desc_status_pid,
19261 (void *)&cmd_show_rx_tx_desc_status_keyword,
19262 (void *)&cmd_show_rx_tx_desc_status_qid,
19263 (void *)&cmd_show_rx_tx_desc_status_desc,
19264 (void *)&cmd_show_rx_tx_desc_status_did,
19265 (void *)&cmd_show_rx_tx_desc_status_status,
19270 /* Common result structure for set port ptypes */
19271 struct cmd_set_port_ptypes_result {
19272 cmdline_fixed_string_t set;
19273 cmdline_fixed_string_t port;
19275 cmdline_fixed_string_t ptype_mask;
19279 /* Common CLI fields for set port ptypes */
19280 cmdline_parse_token_string_t cmd_set_port_ptypes_set =
19281 TOKEN_STRING_INITIALIZER
19282 (struct cmd_set_port_ptypes_result,
19284 cmdline_parse_token_string_t cmd_set_port_ptypes_port =
19285 TOKEN_STRING_INITIALIZER
19286 (struct cmd_set_port_ptypes_result,
19288 cmdline_parse_token_num_t cmd_set_port_ptypes_port_id =
19289 TOKEN_NUM_INITIALIZER
19290 (struct cmd_set_port_ptypes_result,
19292 cmdline_parse_token_string_t cmd_set_port_ptypes_mask_str =
19293 TOKEN_STRING_INITIALIZER
19294 (struct cmd_set_port_ptypes_result,
19295 ptype_mask, "ptype_mask");
19296 cmdline_parse_token_num_t cmd_set_port_ptypes_mask_u32 =
19297 TOKEN_NUM_INITIALIZER
19298 (struct cmd_set_port_ptypes_result,
19302 cmd_set_port_ptypes_parsed(
19303 void *parsed_result,
19304 __rte_unused struct cmdline *cl,
19305 __rte_unused void *data)
19307 struct cmd_set_port_ptypes_result *res = parsed_result;
19308 #define PTYPE_NAMESIZE 256
19309 char ptype_name[PTYPE_NAMESIZE];
19310 uint16_t port_id = res->port_id;
19311 uint32_t ptype_mask = res->mask;
19314 ret = rte_eth_dev_get_supported_ptypes(port_id, RTE_PTYPE_ALL_MASK,
19317 printf("Port %d doesn't support any ptypes.\n", port_id);
19321 uint32_t ptypes[ret];
19323 ret = rte_eth_dev_set_ptypes(port_id, ptype_mask, ptypes, ret);
19325 printf("Unable to set requested ptypes for Port %d\n", port_id);
19329 printf("Successfully set following ptypes for Port %d\n", port_id);
19330 for (i = 0; i < ret && ptypes[i] != RTE_PTYPE_UNKNOWN; i++) {
19331 rte_get_ptype_name(ptypes[i], ptype_name, sizeof(ptype_name));
19332 printf("%s\n", ptype_name);
19335 clear_ptypes = false;
19338 cmdline_parse_inst_t cmd_set_port_ptypes = {
19339 .f = cmd_set_port_ptypes_parsed,
19341 .help_str = "set port <port_id> ptype_mask <mask>",
19343 (void *)&cmd_set_port_ptypes_set,
19344 (void *)&cmd_set_port_ptypes_port,
19345 (void *)&cmd_set_port_ptypes_port_id,
19346 (void *)&cmd_set_port_ptypes_mask_str,
19347 (void *)&cmd_set_port_ptypes_mask_u32,
19352 /* *** display mac addresses added to a port *** */
19353 struct cmd_showport_macs_result {
19354 cmdline_fixed_string_t cmd_show;
19355 cmdline_fixed_string_t cmd_port;
19356 cmdline_fixed_string_t cmd_keyword;
19361 cmd_showport_macs_parsed(void *parsed_result,
19362 __rte_unused struct cmdline *cl,
19363 __rte_unused void *data)
19365 struct cmd_showport_macs_result *res = parsed_result;
19367 if (port_id_is_invalid(res->cmd_pid, ENABLED_WARN))
19370 if (!strcmp(res->cmd_keyword, "macs"))
19371 show_macs(res->cmd_pid);
19372 else if (!strcmp(res->cmd_keyword, "mcast_macs"))
19373 show_mcast_macs(res->cmd_pid);
19376 cmdline_parse_token_string_t cmd_showport_macs_show =
19377 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
19379 cmdline_parse_token_string_t cmd_showport_macs_port =
19380 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
19382 cmdline_parse_token_num_t cmd_showport_macs_pid =
19383 TOKEN_NUM_INITIALIZER(struct cmd_showport_macs_result,
19385 cmdline_parse_token_string_t cmd_showport_macs_keyword =
19386 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
19387 cmd_keyword, "macs#mcast_macs");
19389 cmdline_parse_inst_t cmd_showport_macs = {
19390 .f = cmd_showport_macs_parsed,
19392 .help_str = "show port <port_id> macs|mcast_macs",
19394 (void *)&cmd_showport_macs_show,
19395 (void *)&cmd_showport_macs_port,
19396 (void *)&cmd_showport_macs_pid,
19397 (void *)&cmd_showport_macs_keyword,
19402 /* ******************************************************************************** */
19404 /* list of instructions */
19405 cmdline_parse_ctx_t main_ctx[] = {
19406 (cmdline_parse_inst_t *)&cmd_help_brief,
19407 (cmdline_parse_inst_t *)&cmd_help_long,
19408 (cmdline_parse_inst_t *)&cmd_quit,
19409 (cmdline_parse_inst_t *)&cmd_load_from_file,
19410 (cmdline_parse_inst_t *)&cmd_showport,
19411 (cmdline_parse_inst_t *)&cmd_showqueue,
19412 (cmdline_parse_inst_t *)&cmd_showeeprom,
19413 (cmdline_parse_inst_t *)&cmd_showportall,
19414 (cmdline_parse_inst_t *)&cmd_showdevice,
19415 (cmdline_parse_inst_t *)&cmd_showcfg,
19416 (cmdline_parse_inst_t *)&cmd_showfwdall,
19417 (cmdline_parse_inst_t *)&cmd_start,
19418 (cmdline_parse_inst_t *)&cmd_start_tx_first,
19419 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
19420 (cmdline_parse_inst_t *)&cmd_set_link_up,
19421 (cmdline_parse_inst_t *)&cmd_set_link_down,
19422 (cmdline_parse_inst_t *)&cmd_reset,
19423 (cmdline_parse_inst_t *)&cmd_set_numbers,
19424 (cmdline_parse_inst_t *)&cmd_set_log,
19425 (cmdline_parse_inst_t *)&cmd_set_rxoffs,
19426 (cmdline_parse_inst_t *)&cmd_set_rxpkts,
19427 (cmdline_parse_inst_t *)&cmd_set_txpkts,
19428 (cmdline_parse_inst_t *)&cmd_set_txsplit,
19429 (cmdline_parse_inst_t *)&cmd_set_txtimes,
19430 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
19431 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
19432 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
19433 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
19434 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
19435 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
19436 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
19437 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
19438 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
19439 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
19440 (cmdline_parse_inst_t *)&cmd_set_link_check,
19441 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
19442 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
19443 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
19444 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
19445 #ifdef RTE_NET_BOND
19446 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
19447 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
19448 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
19449 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
19450 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
19451 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
19452 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
19453 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
19454 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
19455 (cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues,
19456 (cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy,
19458 (cmdline_parse_inst_t *)&cmd_vlan_offload,
19459 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
19460 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
19461 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
19462 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
19463 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
19464 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
19465 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
19466 (cmdline_parse_inst_t *)&cmd_csum_set,
19467 (cmdline_parse_inst_t *)&cmd_csum_show,
19468 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
19469 (cmdline_parse_inst_t *)&cmd_tso_set,
19470 (cmdline_parse_inst_t *)&cmd_tso_show,
19471 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
19472 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
19473 (cmdline_parse_inst_t *)&cmd_gro_enable,
19474 (cmdline_parse_inst_t *)&cmd_gro_flush,
19475 (cmdline_parse_inst_t *)&cmd_gro_show,
19476 (cmdline_parse_inst_t *)&cmd_gso_enable,
19477 (cmdline_parse_inst_t *)&cmd_gso_size,
19478 (cmdline_parse_inst_t *)&cmd_gso_show,
19479 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
19480 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
19481 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
19482 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
19483 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
19484 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
19485 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
19486 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
19487 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
19488 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
19489 (cmdline_parse_inst_t *)&cmd_config_dcb,
19490 (cmdline_parse_inst_t *)&cmd_read_reg,
19491 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
19492 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
19493 (cmdline_parse_inst_t *)&cmd_write_reg,
19494 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
19495 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
19496 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
19497 (cmdline_parse_inst_t *)&cmd_stop,
19498 (cmdline_parse_inst_t *)&cmd_mac_addr,
19499 (cmdline_parse_inst_t *)&cmd_set_fwd_eth_peer,
19500 (cmdline_parse_inst_t *)&cmd_set_qmap,
19501 (cmdline_parse_inst_t *)&cmd_set_xstats_hide_zero,
19502 (cmdline_parse_inst_t *)&cmd_set_record_core_cycles,
19503 (cmdline_parse_inst_t *)&cmd_set_record_burst_stats,
19504 (cmdline_parse_inst_t *)&cmd_operate_port,
19505 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
19506 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
19507 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
19508 (cmdline_parse_inst_t *)&cmd_operate_detach_device,
19509 (cmdline_parse_inst_t *)&cmd_set_port_setup_on,
19510 (cmdline_parse_inst_t *)&cmd_config_speed_all,
19511 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
19512 (cmdline_parse_inst_t *)&cmd_config_loopback_all,
19513 (cmdline_parse_inst_t *)&cmd_config_loopback_specific,
19514 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
19515 (cmdline_parse_inst_t *)&cmd_config_mtu,
19516 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
19517 (cmdline_parse_inst_t *)&cmd_config_max_lro_pkt_size,
19518 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
19519 (cmdline_parse_inst_t *)&cmd_config_rss,
19520 (cmdline_parse_inst_t *)&cmd_config_rxtx_ring_size,
19521 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
19522 (cmdline_parse_inst_t *)&cmd_config_deferred_start_rxtx_queue,
19523 (cmdline_parse_inst_t *)&cmd_setup_rxtx_queue,
19524 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
19525 (cmdline_parse_inst_t *)&cmd_showport_reta,
19526 (cmdline_parse_inst_t *)&cmd_showport_macs,
19527 (cmdline_parse_inst_t *)&cmd_config_burst,
19528 (cmdline_parse_inst_t *)&cmd_config_thresh,
19529 (cmdline_parse_inst_t *)&cmd_config_threshold,
19530 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
19531 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
19532 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
19533 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
19534 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
19535 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
19536 (cmdline_parse_inst_t *)&cmd_global_config,
19537 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
19538 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
19539 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
19540 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
19541 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
19542 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
19543 (cmdline_parse_inst_t *)&cmd_dump,
19544 (cmdline_parse_inst_t *)&cmd_dump_one,
19545 (cmdline_parse_inst_t *)&cmd_2tuple_filter,
19546 (cmdline_parse_inst_t *)&cmd_5tuple_filter,
19547 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
19548 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
19549 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
19550 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director,
19551 (cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director,
19552 (cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director,
19553 (cmdline_parse_inst_t *)&cmd_add_del_raw_flow_director,
19554 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
19555 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
19556 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
19557 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
19558 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
19559 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
19560 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
19561 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
19562 (cmdline_parse_inst_t *)&cmd_get_hash_global_config,
19563 (cmdline_parse_inst_t *)&cmd_set_hash_global_config,
19564 (cmdline_parse_inst_t *)&cmd_set_hash_input_set,
19565 (cmdline_parse_inst_t *)&cmd_set_fdir_input_set,
19566 (cmdline_parse_inst_t *)&cmd_flow,
19567 (cmdline_parse_inst_t *)&cmd_show_port_meter_cap,
19568 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm,
19569 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm,
19570 (cmdline_parse_inst_t *)&cmd_del_port_meter_profile,
19571 (cmdline_parse_inst_t *)&cmd_create_port_meter,
19572 (cmdline_parse_inst_t *)&cmd_enable_port_meter,
19573 (cmdline_parse_inst_t *)&cmd_disable_port_meter,
19574 (cmdline_parse_inst_t *)&cmd_del_port_meter,
19575 (cmdline_parse_inst_t *)&cmd_set_port_meter_profile,
19576 (cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table,
19577 (cmdline_parse_inst_t *)&cmd_set_port_meter_policer_action,
19578 (cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask,
19579 (cmdline_parse_inst_t *)&cmd_show_port_meter_stats,
19580 (cmdline_parse_inst_t *)&cmd_mcast_addr,
19581 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all,
19582 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific,
19583 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all,
19584 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific,
19585 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_en,
19586 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_dis,
19587 (cmdline_parse_inst_t *)&cmd_config_e_tag_stripping_en_dis,
19588 (cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis,
19589 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_add,
19590 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_del,
19591 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
19592 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
19593 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
19594 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
19595 (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
19596 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
19597 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
19598 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
19599 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
19600 (cmdline_parse_inst_t *)&cmd_set_macsec_sc,
19601 (cmdline_parse_inst_t *)&cmd_set_macsec_sa,
19602 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
19603 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
19604 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
19605 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
19606 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
19607 (cmdline_parse_inst_t *)&cmd_set_vf_promisc,
19608 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
19609 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
19610 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
19611 (cmdline_parse_inst_t *)&cmd_vf_max_bw,
19612 (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
19613 (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
19614 (cmdline_parse_inst_t *)&cmd_strict_link_prio,
19615 (cmdline_parse_inst_t *)&cmd_tc_min_bw,
19616 (cmdline_parse_inst_t *)&cmd_set_vxlan,
19617 (cmdline_parse_inst_t *)&cmd_set_vxlan_tos_ttl,
19618 (cmdline_parse_inst_t *)&cmd_set_vxlan_with_vlan,
19619 (cmdline_parse_inst_t *)&cmd_set_nvgre,
19620 (cmdline_parse_inst_t *)&cmd_set_nvgre_with_vlan,
19621 (cmdline_parse_inst_t *)&cmd_set_l2_encap,
19622 (cmdline_parse_inst_t *)&cmd_set_l2_encap_with_vlan,
19623 (cmdline_parse_inst_t *)&cmd_set_l2_decap,
19624 (cmdline_parse_inst_t *)&cmd_set_l2_decap_with_vlan,
19625 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap,
19626 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap_with_vlan,
19627 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap,
19628 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap_with_vlan,
19629 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap,
19630 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap_with_vlan,
19631 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap,
19632 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap_with_vlan,
19633 (cmdline_parse_inst_t *)&cmd_ddp_add,
19634 (cmdline_parse_inst_t *)&cmd_ddp_del,
19635 (cmdline_parse_inst_t *)&cmd_ddp_get_list,
19636 (cmdline_parse_inst_t *)&cmd_ddp_get_info,
19637 (cmdline_parse_inst_t *)&cmd_cfg_input_set,
19638 (cmdline_parse_inst_t *)&cmd_clear_input_set,
19639 (cmdline_parse_inst_t *)&cmd_show_vf_stats,
19640 (cmdline_parse_inst_t *)&cmd_clear_vf_stats,
19641 (cmdline_parse_inst_t *)&cmd_show_port_supported_ptypes,
19642 (cmdline_parse_inst_t *)&cmd_set_port_ptypes,
19643 (cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
19644 (cmdline_parse_inst_t *)&cmd_ptype_mapping_replace,
19645 (cmdline_parse_inst_t *)&cmd_ptype_mapping_reset,
19646 (cmdline_parse_inst_t *)&cmd_ptype_mapping_update,
19648 (cmdline_parse_inst_t *)&cmd_pctype_mapping_get,
19649 (cmdline_parse_inst_t *)&cmd_pctype_mapping_reset,
19650 (cmdline_parse_inst_t *)&cmd_pctype_mapping_update,
19651 (cmdline_parse_inst_t *)&cmd_queue_region,
19652 (cmdline_parse_inst_t *)&cmd_region_flowtype,
19653 (cmdline_parse_inst_t *)&cmd_user_priority_region,
19654 (cmdline_parse_inst_t *)&cmd_flush_queue_region,
19655 (cmdline_parse_inst_t *)&cmd_show_queue_region_info_all,
19656 (cmdline_parse_inst_t *)&cmd_show_port_tm_cap,
19657 (cmdline_parse_inst_t *)&cmd_show_port_tm_level_cap,
19658 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_cap,
19659 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_type,
19660 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_stats,
19661 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shaper_profile,
19662 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shaper_profile,
19663 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shared_shaper,
19664 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shared_shaper,
19665 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_wred_profile,
19666 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_wred_profile,
19667 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_shaper_profile,
19668 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node,
19669 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node_pmode,
19670 (cmdline_parse_inst_t *)&cmd_add_port_tm_leaf_node,
19671 (cmdline_parse_inst_t *)&cmd_del_port_tm_node,
19672 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_parent,
19673 (cmdline_parse_inst_t *)&cmd_suspend_port_tm_node,
19674 (cmdline_parse_inst_t *)&cmd_resume_port_tm_node,
19675 (cmdline_parse_inst_t *)&cmd_port_tm_hierarchy_commit,
19676 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_ecn,
19677 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_dscp,
19678 (cmdline_parse_inst_t *)&cmd_port_tm_mark_vlan_dei,
19679 (cmdline_parse_inst_t *)&cmd_cfg_tunnel_udp_port,
19680 (cmdline_parse_inst_t *)&cmd_rx_offload_get_capa,
19681 (cmdline_parse_inst_t *)&cmd_rx_offload_get_configuration,
19682 (cmdline_parse_inst_t *)&cmd_config_per_port_rx_offload,
19683 (cmdline_parse_inst_t *)&cmd_config_per_queue_rx_offload,
19684 (cmdline_parse_inst_t *)&cmd_tx_offload_get_capa,
19685 (cmdline_parse_inst_t *)&cmd_tx_offload_get_configuration,
19686 (cmdline_parse_inst_t *)&cmd_config_per_port_tx_offload,
19687 (cmdline_parse_inst_t *)&cmd_config_per_queue_tx_offload,
19689 (cmdline_parse_inst_t *)&cmd_operate_bpf_ld_parse,
19690 (cmdline_parse_inst_t *)&cmd_operate_bpf_unld_parse,
19692 (cmdline_parse_inst_t *)&cmd_config_tx_metadata_specific,
19693 (cmdline_parse_inst_t *)&cmd_show_tx_metadata,
19694 (cmdline_parse_inst_t *)&cmd_show_rx_tx_desc_status,
19695 (cmdline_parse_inst_t *)&cmd_set_raw,
19696 (cmdline_parse_inst_t *)&cmd_show_set_raw,
19697 (cmdline_parse_inst_t *)&cmd_show_set_raw_all,
19698 (cmdline_parse_inst_t *)&cmd_config_tx_dynf_specific,
19699 (cmdline_parse_inst_t *)&cmd_show_fec_mode,
19700 (cmdline_parse_inst_t *)&cmd_set_fec_mode,
19701 (cmdline_parse_inst_t *)&cmd_show_capability,
19705 /* read cmdline commands from file */
19707 cmdline_read_from_file(const char *filename)
19709 struct cmdline *cl;
19711 cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
19713 printf("Failed to create file based cmdline context: %s\n",
19718 cmdline_interact(cl);
19723 printf("Read CLI commands from %s\n", filename);
19726 /* prompt function, called from main on MAIN lcore */
19730 /* initialize non-constant commands */
19731 cmd_set_fwd_mode_init();
19732 cmd_set_fwd_retry_mode_init();
19734 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
19735 if (testpmd_cl == NULL)
19737 cmdline_interact(testpmd_cl);
19738 cmdline_stdin_exit(testpmd_cl);
19744 if (testpmd_cl != NULL)
19745 cmdline_quit(testpmd_cl);
19749 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
19751 if (id == (portid_t)RTE_PORT_ALL) {
19754 RTE_ETH_FOREACH_DEV(pid) {
19755 /* check if need_reconfig has been set to 1 */
19756 if (ports[pid].need_reconfig == 0)
19757 ports[pid].need_reconfig = dev;
19758 /* check if need_reconfig_queues has been set to 1 */
19759 if (ports[pid].need_reconfig_queues == 0)
19760 ports[pid].need_reconfig_queues = queue;
19762 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
19763 /* check if need_reconfig has been set to 1 */
19764 if (ports[id].need_reconfig == 0)
19765 ports[id].need_reconfig = dev;
19766 /* check if need_reconfig_queues has been set to 1 */
19767 if (ports[id].need_reconfig_queues == 0)
19768 ports[id].need_reconfig_queues = queue;