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 "ethertype_filter (port_id) (add|del)"
980 " (mac_addr|mac_ignr) (mac_address) ethertype"
981 " (ether_type) (drop|fwd) queue (queue_id)\n"
982 " Add/Del an ethertype filter.\n\n"
984 "2tuple_filter (port_id) (add|del)"
985 " dst_port (dst_port_value) protocol (protocol_value)"
986 " mask (mask_value) tcp_flags (tcp_flags_value)"
987 " priority (prio_value) queue (queue_id)\n"
988 " Add/Del a 2tuple filter.\n\n"
990 "5tuple_filter (port_id) (add|del)"
991 " dst_ip (dst_address) src_ip (src_address)"
992 " dst_port (dst_port_value) src_port (src_port_value)"
993 " protocol (protocol_value)"
994 " mask (mask_value) tcp_flags (tcp_flags_value)"
995 " priority (prio_value) queue (queue_id)\n"
996 " Add/Del a 5tuple filter.\n\n"
998 "syn_filter (port_id) (add|del) priority (high|low) queue (queue_id)"
999 " Add/Del syn filter.\n\n"
1001 "flex_filter (port_id) (add|del) len (len_value)"
1002 " bytes (bytes_value) mask (mask_value)"
1003 " priority (prio_value) queue (queue_id)\n"
1004 " Add/Del a flex filter.\n\n"
1006 "flow_director_filter (port_id) mode IP (add|del|update)"
1007 " flow (ipv4-other|ipv4-frag|ipv6-other|ipv6-frag)"
1008 " src (src_ip_address) dst (dst_ip_address)"
1009 " tos (tos_value) proto (proto_value) ttl (ttl_value)"
1010 " vlan (vlan_value) flexbytes (flexbytes_value)"
1011 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
1012 " fd_id (fd_id_value)\n"
1013 " Add/Del an IP type flow director filter.\n\n"
1015 "flow_director_filter (port_id) mode IP (add|del|update)"
1016 " flow (ipv4-tcp|ipv4-udp|ipv6-tcp|ipv6-udp)"
1017 " src (src_ip_address) (src_port)"
1018 " dst (dst_ip_address) (dst_port)"
1019 " tos (tos_value) ttl (ttl_value)"
1020 " vlan (vlan_value) flexbytes (flexbytes_value)"
1021 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
1022 " fd_id (fd_id_value)\n"
1023 " Add/Del an UDP/TCP type flow director filter.\n\n"
1025 "flow_director_filter (port_id) mode IP (add|del|update)"
1026 " flow (ipv4-sctp|ipv6-sctp)"
1027 " src (src_ip_address) (src_port)"
1028 " dst (dst_ip_address) (dst_port)"
1029 " tag (verification_tag) "
1030 " tos (tos_value) ttl (ttl_value)"
1031 " vlan (vlan_value)"
1032 " flexbytes (flexbytes_value) (drop|fwd)"
1033 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
1034 " Add/Del a SCTP type flow director filter.\n\n"
1036 "flow_director_filter (port_id) mode IP (add|del|update)"
1037 " flow l2_payload ether (ethertype)"
1038 " flexbytes (flexbytes_value) (drop|fwd)"
1039 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
1040 " Add/Del a l2 payload type flow director filter.\n\n"
1042 "flow_director_filter (port_id) mode MAC-VLAN (add|del|update)"
1043 " mac (mac_address) vlan (vlan_value)"
1044 " flexbytes (flexbytes_value) (drop|fwd)"
1045 " queue (queue_id) fd_id (fd_id_value)\n"
1046 " Add/Del a MAC-VLAN flow director filter.\n\n"
1048 "flow_director_filter (port_id) mode Tunnel (add|del|update)"
1049 " mac (mac_address) vlan (vlan_value)"
1050 " tunnel (NVGRE|VxLAN) tunnel-id (tunnel_id_value)"
1051 " flexbytes (flexbytes_value) (drop|fwd)"
1052 " queue (queue_id) fd_id (fd_id_value)\n"
1053 " Add/Del a Tunnel flow director filter.\n\n"
1055 "flow_director_filter (port_id) mode raw (add|del|update)"
1056 " flow (flow_id) (drop|fwd) queue (queue_id)"
1057 " fd_id (fd_id_value) packet (packet file name)\n"
1058 " Add/Del a raw type flow director filter.\n\n"
1060 "flush_flow_director (port_id)\n"
1061 " Flush all flow director entries of a device.\n\n"
1063 "flow_director_mask (port_id) mode IP vlan (vlan_value)"
1064 " src_mask (ipv4_src) (ipv6_src) (src_port)"
1065 " dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n"
1066 " Set flow director IP mask.\n\n"
1068 "flow_director_mask (port_id) mode MAC-VLAN"
1069 " vlan (vlan_value)\n"
1070 " Set flow director MAC-VLAN mask.\n\n"
1072 "flow_director_mask (port_id) mode Tunnel"
1073 " vlan (vlan_value) mac (mac_value)"
1074 " tunnel-type (tunnel_type_value)"
1075 " tunnel-id (tunnel_id_value)\n"
1076 " Set flow director Tunnel mask.\n\n"
1078 "flow_director_flex_mask (port_id)"
1079 " flow (none|ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
1080 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|l2_payload|all)"
1082 " Configure mask of flex payload.\n\n"
1084 "flow_director_flex_payload (port_id)"
1085 " (raw|l2|l3|l4) (config)\n"
1086 " Configure flex payload selection.\n\n"
1088 "get_sym_hash_ena_per_port (port_id)\n"
1089 " get symmetric hash enable configuration per port.\n\n"
1091 "set_sym_hash_ena_per_port (port_id) (enable|disable)\n"
1092 " set symmetric hash enable configuration per port"
1093 " to enable or disable.\n\n"
1095 "get_hash_global_config (port_id)\n"
1096 " Get the global configurations of hash filters.\n\n"
1098 "set_hash_global_config (port_id) (toeplitz|simple_xor|symmetric_toeplitz|default)"
1099 " (ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
1100 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload)"
1101 " (enable|disable)\n"
1102 " Set the global configurations of hash filters.\n\n"
1104 "set_hash_input_set (port_id) (ipv4|ipv4-frag|"
1105 "ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
1106 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1107 "l2_payload|<flowtype_id>) (ovlan|ivlan|src-ipv4|dst-ipv4|"
1108 "src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|ipv6-tc|"
1109 "ipv6-next-header|udp-src-port|udp-dst-port|"
1110 "tcp-src-port|tcp-dst-port|sctp-src-port|"
1111 "sctp-dst-port|sctp-veri-tag|udp-key|gre-key|fld-1st|"
1112 "fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|fld-7th|"
1113 "fld-8th|none) (select|add)\n"
1114 " Set the input set for hash.\n\n"
1116 "set_fdir_input_set (port_id) "
1117 "(ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
1118 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1119 "l2_payload) (ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|"
1120 "dst-ipv6|ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|"
1121 "ipv6-next-header|ipv6-hop-limits|udp-src-port|"
1122 "udp-dst-port|tcp-src-port|tcp-dst-port|"
1123 "sctp-src-port|sctp-dst-port|sctp-veri-tag|none)"
1125 " Set the input set for FDir.\n\n"
1127 "flow validate {port_id}"
1128 " [group {group_id}] [priority {level}]"
1129 " [ingress] [egress]"
1130 " pattern {item} [/ {item} [...]] / end"
1131 " actions {action} [/ {action} [...]] / end\n"
1132 " Check whether a flow rule can be created.\n\n"
1134 "flow create {port_id}"
1135 " [group {group_id}] [priority {level}]"
1136 " [ingress] [egress]"
1137 " pattern {item} [/ {item} [...]] / end"
1138 " actions {action} [/ {action} [...]] / end\n"
1139 " Create a flow rule.\n\n"
1141 "flow destroy {port_id} rule {rule_id} [...]\n"
1142 " Destroy specific flow rules.\n\n"
1144 "flow flush {port_id}\n"
1145 " Destroy all flow rules.\n\n"
1147 "flow query {port_id} {rule_id} {action}\n"
1148 " Query an existing flow rule.\n\n"
1150 "flow list {port_id} [group {group_id}] [...]\n"
1151 " List existing flow rules sorted by priority,"
1152 " filtered by group identifiers.\n\n"
1154 "flow isolate {port_id} {boolean}\n"
1155 " Restrict ingress traffic to the defined"
1158 "flow aged {port_id} [destroy]\n"
1159 " List and destroy aged flows"
1162 "flow shared_action {port_id} create"
1163 " [action_id {shared_action_id}]"
1164 " [ingress] [egress]"
1165 " action {action} / end\n"
1166 " Create shared action.\n\n"
1168 "flow shared_action {port_id} update"
1169 " {shared_action_id} action {action} / end\n"
1170 " Update shared action.\n\n"
1172 "flow shared_action {port_id} destroy"
1173 " action_id {shared_action_id} [...]\n"
1174 " Destroy specific shared actions.\n\n"
1176 "flow shared_action {port_id} query"
1177 " {shared_action_id}\n"
1178 " Query an existing shared action.\n\n"
1180 "set vxlan ip-version (ipv4|ipv6) vni (vni) udp-src"
1181 " (udp-src) udp-dst (udp-dst) ip-src (ip-src) ip-dst"
1182 " (ip-dst) eth-src (eth-src) eth-dst (eth-dst)\n"
1183 " Configure the VXLAN encapsulation for flows.\n\n"
1185 "set vxlan-with-vlan ip-version (ipv4|ipv6) vni (vni)"
1186 " udp-src (udp-src) udp-dst (udp-dst) ip-src (ip-src)"
1187 " ip-dst (ip-dst) vlan-tci (vlan-tci) eth-src (eth-src)"
1188 " eth-dst (eth-dst)\n"
1189 " Configure the VXLAN encapsulation for flows.\n\n"
1191 "set vxlan-tos-ttl ip-version (ipv4|ipv6) vni (vni) udp-src"
1192 " (udp-src) udp-dst (udp-dst) ip-tos (ip-tos) ip-ttl (ip-ttl)"
1193 " ip-src (ip-src) ip-dst (ip-dst) eth-src (eth-src)"
1194 " eth-dst (eth-dst)\n"
1195 " Configure the VXLAN encapsulation for flows.\n\n"
1197 "set nvgre ip-version (ipv4|ipv6) tni (tni) ip-src"
1198 " (ip-src) ip-dst (ip-dst) eth-src (eth-src) eth-dst"
1200 " Configure the NVGRE encapsulation for flows.\n\n"
1202 "set nvgre-with-vlan ip-version (ipv4|ipv6) tni (tni)"
1203 " ip-src (ip-src) ip-dst (ip-dst) vlan-tci (vlan-tci)"
1204 " eth-src (eth-src) eth-dst (eth-dst)\n"
1205 " Configure the NVGRE encapsulation for flows.\n\n"
1207 "set raw_encap {flow items}\n"
1208 " Configure the encapsulation with raw data.\n\n"
1210 "set raw_decap {flow items}\n"
1211 " Configure the decapsulation with raw data.\n\n"
1216 if (show_all || !strcmp(res->section, "traffic_management")) {
1220 "Traffic Management:\n"
1222 "show port tm cap (port_id)\n"
1223 " Display the port TM capability.\n\n"
1225 "show port tm level cap (port_id) (level_id)\n"
1226 " Display the port TM hierarchical level capability.\n\n"
1228 "show port tm node cap (port_id) (node_id)\n"
1229 " Display the port TM node capability.\n\n"
1231 "show port tm node type (port_id) (node_id)\n"
1232 " Display the port TM node type.\n\n"
1234 "show port tm node stats (port_id) (node_id) (clear)\n"
1235 " Display the port TM node stats.\n\n"
1237 "add port tm node shaper profile (port_id) (shaper_profile_id)"
1238 " (cmit_tb_rate) (cmit_tb_size) (peak_tb_rate) (peak_tb_size)"
1239 " (packet_length_adjust) (packet_mode)\n"
1240 " Add port tm node private shaper profile.\n\n"
1242 "del port tm node shaper profile (port_id) (shaper_profile_id)\n"
1243 " Delete port tm node private shaper profile.\n\n"
1245 "add port tm node shared shaper (port_id) (shared_shaper_id)"
1246 " (shaper_profile_id)\n"
1247 " Add/update port tm node shared shaper.\n\n"
1249 "del port tm node shared shaper (port_id) (shared_shaper_id)\n"
1250 " Delete port tm node shared shaper.\n\n"
1252 "set port tm node shaper profile (port_id) (node_id)"
1253 " (shaper_profile_id)\n"
1254 " Set port tm node shaper profile.\n\n"
1256 "add port tm node wred profile (port_id) (wred_profile_id)"
1257 " (color_g) (min_th_g) (max_th_g) (maxp_inv_g) (wq_log2_g)"
1258 " (color_y) (min_th_y) (max_th_y) (maxp_inv_y) (wq_log2_y)"
1259 " (color_r) (min_th_r) (max_th_r) (maxp_inv_r) (wq_log2_r)\n"
1260 " Add port tm node wred profile.\n\n"
1262 "del port tm node wred profile (port_id) (wred_profile_id)\n"
1263 " Delete port tm node wred profile.\n\n"
1265 "add port tm nonleaf node (port_id) (node_id) (parent_node_id)"
1266 " (priority) (weight) (level_id) (shaper_profile_id)"
1267 " (n_sp_priorities) (stats_mask) (n_shared_shapers)"
1268 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1269 " Add port tm nonleaf node.\n\n"
1271 "add port tm nonleaf node pktmode (port_id) (node_id) (parent_node_id)"
1272 " (priority) (weight) (level_id) (shaper_profile_id)"
1273 " (n_sp_priorities) (stats_mask) (n_shared_shapers)"
1274 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1275 " Add port tm nonleaf node with pkt mode enabled.\n\n"
1277 "add port tm leaf node (port_id) (node_id) (parent_node_id)"
1278 " (priority) (weight) (level_id) (shaper_profile_id)"
1279 " (cman_mode) (wred_profile_id) (stats_mask) (n_shared_shapers)"
1280 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1281 " Add port tm leaf node.\n\n"
1283 "del port tm node (port_id) (node_id)\n"
1284 " Delete port tm node.\n\n"
1286 "set port tm node parent (port_id) (node_id) (parent_node_id)"
1287 " (priority) (weight)\n"
1288 " Set port tm node parent.\n\n"
1290 "suspend port tm node (port_id) (node_id)"
1291 " Suspend tm node.\n\n"
1293 "resume port tm node (port_id) (node_id)"
1294 " Resume tm node.\n\n"
1296 "port tm hierarchy commit (port_id) (clean_on_fail)\n"
1297 " Commit tm hierarchy.\n\n"
1299 "set port tm mark ip_ecn (port) (green) (yellow)"
1301 " Enables/Disables the traffic management marking"
1302 " for IP ECN (Explicit Congestion Notification)"
1303 " packets on a given port\n\n"
1305 "set port tm mark ip_dscp (port) (green) (yellow)"
1307 " Enables/Disables the traffic management marking"
1308 " on the port for IP dscp packets\n\n"
1310 "set port tm mark vlan_dei (port) (green) (yellow)"
1312 " Enables/Disables the traffic management marking"
1313 " on the port for VLAN packets with DEI enabled\n\n"
1317 if (show_all || !strcmp(res->section, "devices")) {
1321 "Device Operations:\n"
1323 "device detach (identifier)\n"
1324 " Detach device by identifier.\n\n"
1330 cmdline_parse_token_string_t cmd_help_long_help =
1331 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
1333 cmdline_parse_token_string_t cmd_help_long_section =
1334 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
1335 "all#control#display#config#"
1336 "ports#registers#filters#traffic_management#devices");
1338 cmdline_parse_inst_t cmd_help_long = {
1339 .f = cmd_help_long_parsed,
1341 .help_str = "help all|control|display|config|ports|register|"
1342 "filters|traffic_management|devices: "
1345 (void *)&cmd_help_long_help,
1346 (void *)&cmd_help_long_section,
1352 /* *** start/stop/close all ports *** */
1353 struct cmd_operate_port_result {
1354 cmdline_fixed_string_t keyword;
1355 cmdline_fixed_string_t name;
1356 cmdline_fixed_string_t value;
1359 static void cmd_operate_port_parsed(void *parsed_result,
1360 __rte_unused struct cmdline *cl,
1361 __rte_unused void *data)
1363 struct cmd_operate_port_result *res = parsed_result;
1365 if (!strcmp(res->name, "start"))
1366 start_port(RTE_PORT_ALL);
1367 else if (!strcmp(res->name, "stop"))
1368 stop_port(RTE_PORT_ALL);
1369 else if (!strcmp(res->name, "close"))
1370 close_port(RTE_PORT_ALL);
1371 else if (!strcmp(res->name, "reset"))
1372 reset_port(RTE_PORT_ALL);
1374 printf("Unknown parameter\n");
1377 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
1378 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
1380 cmdline_parse_token_string_t cmd_operate_port_all_port =
1381 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
1382 "start#stop#close#reset");
1383 cmdline_parse_token_string_t cmd_operate_port_all_all =
1384 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
1386 cmdline_parse_inst_t cmd_operate_port = {
1387 .f = cmd_operate_port_parsed,
1389 .help_str = "port start|stop|close all: Start/Stop/Close/Reset all ports",
1391 (void *)&cmd_operate_port_all_cmd,
1392 (void *)&cmd_operate_port_all_port,
1393 (void *)&cmd_operate_port_all_all,
1398 /* *** start/stop/close specific port *** */
1399 struct cmd_operate_specific_port_result {
1400 cmdline_fixed_string_t keyword;
1401 cmdline_fixed_string_t name;
1405 static void cmd_operate_specific_port_parsed(void *parsed_result,
1406 __rte_unused struct cmdline *cl,
1407 __rte_unused void *data)
1409 struct cmd_operate_specific_port_result *res = parsed_result;
1411 if (!strcmp(res->name, "start"))
1412 start_port(res->value);
1413 else if (!strcmp(res->name, "stop"))
1414 stop_port(res->value);
1415 else if (!strcmp(res->name, "close"))
1416 close_port(res->value);
1417 else if (!strcmp(res->name, "reset"))
1418 reset_port(res->value);
1420 printf("Unknown parameter\n");
1423 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
1424 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1426 cmdline_parse_token_string_t cmd_operate_specific_port_port =
1427 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1428 name, "start#stop#close#reset");
1429 cmdline_parse_token_num_t cmd_operate_specific_port_id =
1430 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
1433 cmdline_parse_inst_t cmd_operate_specific_port = {
1434 .f = cmd_operate_specific_port_parsed,
1436 .help_str = "port start|stop|close <port_id>: Start/Stop/Close/Reset port_id",
1438 (void *)&cmd_operate_specific_port_cmd,
1439 (void *)&cmd_operate_specific_port_port,
1440 (void *)&cmd_operate_specific_port_id,
1445 /* *** enable port setup (after attach) via iterator or event *** */
1446 struct cmd_set_port_setup_on_result {
1447 cmdline_fixed_string_t set;
1448 cmdline_fixed_string_t port;
1449 cmdline_fixed_string_t setup;
1450 cmdline_fixed_string_t on;
1451 cmdline_fixed_string_t mode;
1454 static void cmd_set_port_setup_on_parsed(void *parsed_result,
1455 __rte_unused struct cmdline *cl,
1456 __rte_unused void *data)
1458 struct cmd_set_port_setup_on_result *res = parsed_result;
1460 if (strcmp(res->mode, "event") == 0)
1461 setup_on_probe_event = true;
1462 else if (strcmp(res->mode, "iterator") == 0)
1463 setup_on_probe_event = false;
1465 printf("Unknown mode\n");
1468 cmdline_parse_token_string_t cmd_set_port_setup_on_set =
1469 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1471 cmdline_parse_token_string_t cmd_set_port_setup_on_port =
1472 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1474 cmdline_parse_token_string_t cmd_set_port_setup_on_setup =
1475 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1477 cmdline_parse_token_string_t cmd_set_port_setup_on_on =
1478 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1480 cmdline_parse_token_string_t cmd_set_port_setup_on_mode =
1481 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1482 mode, "iterator#event");
1484 cmdline_parse_inst_t cmd_set_port_setup_on = {
1485 .f = cmd_set_port_setup_on_parsed,
1487 .help_str = "set port setup on iterator|event",
1489 (void *)&cmd_set_port_setup_on_set,
1490 (void *)&cmd_set_port_setup_on_port,
1491 (void *)&cmd_set_port_setup_on_setup,
1492 (void *)&cmd_set_port_setup_on_on,
1493 (void *)&cmd_set_port_setup_on_mode,
1498 /* *** attach a specified port *** */
1499 struct cmd_operate_attach_port_result {
1500 cmdline_fixed_string_t port;
1501 cmdline_fixed_string_t keyword;
1502 cmdline_multi_string_t identifier;
1505 static void cmd_operate_attach_port_parsed(void *parsed_result,
1506 __rte_unused struct cmdline *cl,
1507 __rte_unused void *data)
1509 struct cmd_operate_attach_port_result *res = parsed_result;
1511 if (!strcmp(res->keyword, "attach"))
1512 attach_port(res->identifier);
1514 printf("Unknown parameter\n");
1517 cmdline_parse_token_string_t cmd_operate_attach_port_port =
1518 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1520 cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
1521 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1523 cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
1524 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1525 identifier, TOKEN_STRING_MULTI);
1527 cmdline_parse_inst_t cmd_operate_attach_port = {
1528 .f = cmd_operate_attach_port_parsed,
1530 .help_str = "port attach <identifier>: "
1531 "(identifier: pci address or virtual dev name)",
1533 (void *)&cmd_operate_attach_port_port,
1534 (void *)&cmd_operate_attach_port_keyword,
1535 (void *)&cmd_operate_attach_port_identifier,
1540 /* *** detach a specified port *** */
1541 struct cmd_operate_detach_port_result {
1542 cmdline_fixed_string_t port;
1543 cmdline_fixed_string_t keyword;
1547 static void cmd_operate_detach_port_parsed(void *parsed_result,
1548 __rte_unused struct cmdline *cl,
1549 __rte_unused void *data)
1551 struct cmd_operate_detach_port_result *res = parsed_result;
1553 if (!strcmp(res->keyword, "detach")) {
1554 RTE_ETH_VALID_PORTID_OR_RET(res->port_id);
1555 detach_port_device(res->port_id);
1557 printf("Unknown parameter\n");
1561 cmdline_parse_token_string_t cmd_operate_detach_port_port =
1562 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1564 cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
1565 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1567 cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
1568 TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
1571 cmdline_parse_inst_t cmd_operate_detach_port = {
1572 .f = cmd_operate_detach_port_parsed,
1574 .help_str = "port detach <port_id>",
1576 (void *)&cmd_operate_detach_port_port,
1577 (void *)&cmd_operate_detach_port_keyword,
1578 (void *)&cmd_operate_detach_port_port_id,
1583 /* *** detach device by identifier *** */
1584 struct cmd_operate_detach_device_result {
1585 cmdline_fixed_string_t device;
1586 cmdline_fixed_string_t keyword;
1587 cmdline_fixed_string_t identifier;
1590 static void cmd_operate_detach_device_parsed(void *parsed_result,
1591 __rte_unused struct cmdline *cl,
1592 __rte_unused void *data)
1594 struct cmd_operate_detach_device_result *res = parsed_result;
1596 if (!strcmp(res->keyword, "detach"))
1597 detach_devargs(res->identifier);
1599 printf("Unknown parameter\n");
1602 cmdline_parse_token_string_t cmd_operate_detach_device_device =
1603 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1605 cmdline_parse_token_string_t cmd_operate_detach_device_keyword =
1606 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1608 cmdline_parse_token_string_t cmd_operate_detach_device_identifier =
1609 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1612 cmdline_parse_inst_t cmd_operate_detach_device = {
1613 .f = cmd_operate_detach_device_parsed,
1615 .help_str = "device detach <identifier>:"
1616 "(identifier: pci address or virtual dev name)",
1618 (void *)&cmd_operate_detach_device_device,
1619 (void *)&cmd_operate_detach_device_keyword,
1620 (void *)&cmd_operate_detach_device_identifier,
1624 /* *** configure speed for all ports *** */
1625 struct cmd_config_speed_all {
1626 cmdline_fixed_string_t port;
1627 cmdline_fixed_string_t keyword;
1628 cmdline_fixed_string_t all;
1629 cmdline_fixed_string_t item1;
1630 cmdline_fixed_string_t item2;
1631 cmdline_fixed_string_t value1;
1632 cmdline_fixed_string_t value2;
1636 parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed)
1641 if (!strcmp(duplexstr, "half")) {
1642 duplex = ETH_LINK_HALF_DUPLEX;
1643 } else if (!strcmp(duplexstr, "full")) {
1644 duplex = ETH_LINK_FULL_DUPLEX;
1645 } else if (!strcmp(duplexstr, "auto")) {
1646 duplex = ETH_LINK_FULL_DUPLEX;
1648 printf("Unknown duplex parameter\n");
1652 if (!strcmp(speedstr, "10")) {
1653 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1654 ETH_LINK_SPEED_10M_HD : ETH_LINK_SPEED_10M;
1655 } else if (!strcmp(speedstr, "100")) {
1656 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1657 ETH_LINK_SPEED_100M_HD : ETH_LINK_SPEED_100M;
1659 if (duplex != ETH_LINK_FULL_DUPLEX) {
1660 printf("Invalid speed/duplex parameters\n");
1663 if (!strcmp(speedstr, "1000")) {
1664 *speed = ETH_LINK_SPEED_1G;
1665 } else if (!strcmp(speedstr, "10000")) {
1666 *speed = ETH_LINK_SPEED_10G;
1667 } else if (!strcmp(speedstr, "25000")) {
1668 *speed = ETH_LINK_SPEED_25G;
1669 } else if (!strcmp(speedstr, "40000")) {
1670 *speed = ETH_LINK_SPEED_40G;
1671 } else if (!strcmp(speedstr, "50000")) {
1672 *speed = ETH_LINK_SPEED_50G;
1673 } else if (!strcmp(speedstr, "100000")) {
1674 *speed = ETH_LINK_SPEED_100G;
1675 } else if (!strcmp(speedstr, "200000")) {
1676 *speed = ETH_LINK_SPEED_200G;
1677 } else if (!strcmp(speedstr, "auto")) {
1678 *speed = ETH_LINK_SPEED_AUTONEG;
1680 printf("Unknown speed parameter\n");
1689 cmd_config_speed_all_parsed(void *parsed_result,
1690 __rte_unused struct cmdline *cl,
1691 __rte_unused void *data)
1693 struct cmd_config_speed_all *res = parsed_result;
1694 uint32_t link_speed;
1697 if (!all_ports_stopped()) {
1698 printf("Please stop all ports first\n");
1702 if (parse_and_check_speed_duplex(res->value1, res->value2,
1706 RTE_ETH_FOREACH_DEV(pid) {
1707 ports[pid].dev_conf.link_speeds = link_speed;
1710 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1713 cmdline_parse_token_string_t cmd_config_speed_all_port =
1714 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1715 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1716 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1718 cmdline_parse_token_string_t cmd_config_speed_all_all =
1719 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1720 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1721 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1722 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1723 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1724 "10#100#1000#10000#25000#40000#50000#100000#200000#auto");
1725 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1726 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1727 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1728 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1731 cmdline_parse_inst_t cmd_config_speed_all = {
1732 .f = cmd_config_speed_all_parsed,
1734 .help_str = "port config all speed "
1735 "10|100|1000|10000|25000|40000|50000|100000|200000|auto duplex "
1738 (void *)&cmd_config_speed_all_port,
1739 (void *)&cmd_config_speed_all_keyword,
1740 (void *)&cmd_config_speed_all_all,
1741 (void *)&cmd_config_speed_all_item1,
1742 (void *)&cmd_config_speed_all_value1,
1743 (void *)&cmd_config_speed_all_item2,
1744 (void *)&cmd_config_speed_all_value2,
1749 /* *** configure speed for specific port *** */
1750 struct cmd_config_speed_specific {
1751 cmdline_fixed_string_t port;
1752 cmdline_fixed_string_t keyword;
1754 cmdline_fixed_string_t item1;
1755 cmdline_fixed_string_t item2;
1756 cmdline_fixed_string_t value1;
1757 cmdline_fixed_string_t value2;
1761 cmd_config_speed_specific_parsed(void *parsed_result,
1762 __rte_unused struct cmdline *cl,
1763 __rte_unused void *data)
1765 struct cmd_config_speed_specific *res = parsed_result;
1766 uint32_t link_speed;
1768 if (!all_ports_stopped()) {
1769 printf("Please stop all ports first\n");
1773 if (port_id_is_invalid(res->id, ENABLED_WARN))
1776 if (parse_and_check_speed_duplex(res->value1, res->value2,
1780 ports[res->id].dev_conf.link_speeds = link_speed;
1782 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1786 cmdline_parse_token_string_t cmd_config_speed_specific_port =
1787 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1789 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1790 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1792 cmdline_parse_token_num_t cmd_config_speed_specific_id =
1793 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT16);
1794 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1795 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1797 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1798 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1799 "10#100#1000#10000#25000#40000#50000#100000#200000#auto");
1800 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1801 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1803 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1804 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1807 cmdline_parse_inst_t cmd_config_speed_specific = {
1808 .f = cmd_config_speed_specific_parsed,
1810 .help_str = "port config <port_id> speed "
1811 "10|100|1000|10000|25000|40000|50000|100000|200000|auto duplex "
1814 (void *)&cmd_config_speed_specific_port,
1815 (void *)&cmd_config_speed_specific_keyword,
1816 (void *)&cmd_config_speed_specific_id,
1817 (void *)&cmd_config_speed_specific_item1,
1818 (void *)&cmd_config_speed_specific_value1,
1819 (void *)&cmd_config_speed_specific_item2,
1820 (void *)&cmd_config_speed_specific_value2,
1825 /* *** configure loopback for all ports *** */
1826 struct cmd_config_loopback_all {
1827 cmdline_fixed_string_t port;
1828 cmdline_fixed_string_t keyword;
1829 cmdline_fixed_string_t all;
1830 cmdline_fixed_string_t item;
1835 cmd_config_loopback_all_parsed(void *parsed_result,
1836 __rte_unused struct cmdline *cl,
1837 __rte_unused void *data)
1839 struct cmd_config_loopback_all *res = parsed_result;
1842 if (!all_ports_stopped()) {
1843 printf("Please stop all ports first\n");
1847 RTE_ETH_FOREACH_DEV(pid) {
1848 ports[pid].dev_conf.lpbk_mode = res->mode;
1851 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1854 cmdline_parse_token_string_t cmd_config_loopback_all_port =
1855 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, port, "port");
1856 cmdline_parse_token_string_t cmd_config_loopback_all_keyword =
1857 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, keyword,
1859 cmdline_parse_token_string_t cmd_config_loopback_all_all =
1860 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, all, "all");
1861 cmdline_parse_token_string_t cmd_config_loopback_all_item =
1862 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, item,
1864 cmdline_parse_token_num_t cmd_config_loopback_all_mode =
1865 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_all, mode, UINT32);
1867 cmdline_parse_inst_t cmd_config_loopback_all = {
1868 .f = cmd_config_loopback_all_parsed,
1870 .help_str = "port config all loopback <mode>",
1872 (void *)&cmd_config_loopback_all_port,
1873 (void *)&cmd_config_loopback_all_keyword,
1874 (void *)&cmd_config_loopback_all_all,
1875 (void *)&cmd_config_loopback_all_item,
1876 (void *)&cmd_config_loopback_all_mode,
1881 /* *** configure loopback for specific port *** */
1882 struct cmd_config_loopback_specific {
1883 cmdline_fixed_string_t port;
1884 cmdline_fixed_string_t keyword;
1886 cmdline_fixed_string_t item;
1891 cmd_config_loopback_specific_parsed(void *parsed_result,
1892 __rte_unused struct cmdline *cl,
1893 __rte_unused void *data)
1895 struct cmd_config_loopback_specific *res = parsed_result;
1897 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
1900 if (!port_is_stopped(res->port_id)) {
1901 printf("Please stop port %u first\n", res->port_id);
1905 ports[res->port_id].dev_conf.lpbk_mode = res->mode;
1907 cmd_reconfig_device_queue(res->port_id, 1, 1);
1911 cmdline_parse_token_string_t cmd_config_loopback_specific_port =
1912 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, port,
1914 cmdline_parse_token_string_t cmd_config_loopback_specific_keyword =
1915 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, keyword,
1917 cmdline_parse_token_num_t cmd_config_loopback_specific_id =
1918 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, port_id,
1920 cmdline_parse_token_string_t cmd_config_loopback_specific_item =
1921 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, item,
1923 cmdline_parse_token_num_t cmd_config_loopback_specific_mode =
1924 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, mode,
1927 cmdline_parse_inst_t cmd_config_loopback_specific = {
1928 .f = cmd_config_loopback_specific_parsed,
1930 .help_str = "port config <port_id> loopback <mode>",
1932 (void *)&cmd_config_loopback_specific_port,
1933 (void *)&cmd_config_loopback_specific_keyword,
1934 (void *)&cmd_config_loopback_specific_id,
1935 (void *)&cmd_config_loopback_specific_item,
1936 (void *)&cmd_config_loopback_specific_mode,
1941 /* *** configure txq/rxq, txd/rxd *** */
1942 struct cmd_config_rx_tx {
1943 cmdline_fixed_string_t port;
1944 cmdline_fixed_string_t keyword;
1945 cmdline_fixed_string_t all;
1946 cmdline_fixed_string_t name;
1951 cmd_config_rx_tx_parsed(void *parsed_result,
1952 __rte_unused struct cmdline *cl,
1953 __rte_unused void *data)
1955 struct cmd_config_rx_tx *res = parsed_result;
1957 if (!all_ports_stopped()) {
1958 printf("Please stop all ports first\n");
1961 if (!strcmp(res->name, "rxq")) {
1962 if (!res->value && !nb_txq) {
1963 printf("Warning: Either rx or tx queues should be non zero\n");
1966 if (check_nb_rxq(res->value) != 0)
1968 nb_rxq = res->value;
1970 else if (!strcmp(res->name, "txq")) {
1971 if (!res->value && !nb_rxq) {
1972 printf("Warning: Either rx or tx queues should be non zero\n");
1975 if (check_nb_txq(res->value) != 0)
1977 nb_txq = res->value;
1979 else if (!strcmp(res->name, "rxd")) {
1980 if (check_nb_rxd(res->value) != 0)
1982 nb_rxd = res->value;
1983 } else if (!strcmp(res->name, "txd")) {
1984 if (check_nb_txd(res->value) != 0)
1987 nb_txd = res->value;
1989 printf("Unknown parameter\n");
1997 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2000 cmdline_parse_token_string_t cmd_config_rx_tx_port =
2001 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
2002 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
2003 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
2004 cmdline_parse_token_string_t cmd_config_rx_tx_all =
2005 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
2006 cmdline_parse_token_string_t cmd_config_rx_tx_name =
2007 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
2009 cmdline_parse_token_num_t cmd_config_rx_tx_value =
2010 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
2012 cmdline_parse_inst_t cmd_config_rx_tx = {
2013 .f = cmd_config_rx_tx_parsed,
2015 .help_str = "port config all rxq|txq|rxd|txd <value>",
2017 (void *)&cmd_config_rx_tx_port,
2018 (void *)&cmd_config_rx_tx_keyword,
2019 (void *)&cmd_config_rx_tx_all,
2020 (void *)&cmd_config_rx_tx_name,
2021 (void *)&cmd_config_rx_tx_value,
2026 /* *** config max packet length *** */
2027 struct cmd_config_max_pkt_len_result {
2028 cmdline_fixed_string_t port;
2029 cmdline_fixed_string_t keyword;
2030 cmdline_fixed_string_t all;
2031 cmdline_fixed_string_t name;
2036 cmd_config_max_pkt_len_parsed(void *parsed_result,
2037 __rte_unused struct cmdline *cl,
2038 __rte_unused void *data)
2040 struct cmd_config_max_pkt_len_result *res = parsed_result;
2043 if (!all_ports_stopped()) {
2044 printf("Please stop all ports first\n");
2048 RTE_ETH_FOREACH_DEV(pid) {
2049 struct rte_port *port = &ports[pid];
2050 uint64_t rx_offloads = port->dev_conf.rxmode.offloads;
2052 if (!strcmp(res->name, "max-pkt-len")) {
2053 if (res->value < RTE_ETHER_MIN_LEN) {
2054 printf("max-pkt-len can not be less than %d\n",
2058 if (res->value == port->dev_conf.rxmode.max_rx_pkt_len)
2061 port->dev_conf.rxmode.max_rx_pkt_len = res->value;
2062 if (res->value > RTE_ETHER_MAX_LEN)
2063 rx_offloads |= DEV_RX_OFFLOAD_JUMBO_FRAME;
2065 rx_offloads &= ~DEV_RX_OFFLOAD_JUMBO_FRAME;
2066 port->dev_conf.rxmode.offloads = rx_offloads;
2068 printf("Unknown parameter\n");
2075 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2078 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
2079 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
2081 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
2082 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
2084 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
2085 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
2087 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
2088 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
2090 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
2091 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
2094 cmdline_parse_inst_t cmd_config_max_pkt_len = {
2095 .f = cmd_config_max_pkt_len_parsed,
2097 .help_str = "port config all max-pkt-len <value>",
2099 (void *)&cmd_config_max_pkt_len_port,
2100 (void *)&cmd_config_max_pkt_len_keyword,
2101 (void *)&cmd_config_max_pkt_len_all,
2102 (void *)&cmd_config_max_pkt_len_name,
2103 (void *)&cmd_config_max_pkt_len_value,
2108 /* *** config max LRO aggregated packet size *** */
2109 struct cmd_config_max_lro_pkt_size_result {
2110 cmdline_fixed_string_t port;
2111 cmdline_fixed_string_t keyword;
2112 cmdline_fixed_string_t all;
2113 cmdline_fixed_string_t name;
2118 cmd_config_max_lro_pkt_size_parsed(void *parsed_result,
2119 __rte_unused struct cmdline *cl,
2120 __rte_unused void *data)
2122 struct cmd_config_max_lro_pkt_size_result *res = parsed_result;
2125 if (!all_ports_stopped()) {
2126 printf("Please stop all ports first\n");
2130 RTE_ETH_FOREACH_DEV(pid) {
2131 struct rte_port *port = &ports[pid];
2133 if (!strcmp(res->name, "max-lro-pkt-size")) {
2135 port->dev_conf.rxmode.max_lro_pkt_size)
2138 port->dev_conf.rxmode.max_lro_pkt_size = res->value;
2140 printf("Unknown parameter\n");
2147 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2150 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_port =
2151 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2153 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_keyword =
2154 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2156 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_all =
2157 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2159 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_name =
2160 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2161 name, "max-lro-pkt-size");
2162 cmdline_parse_token_num_t cmd_config_max_lro_pkt_size_value =
2163 TOKEN_NUM_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2166 cmdline_parse_inst_t cmd_config_max_lro_pkt_size = {
2167 .f = cmd_config_max_lro_pkt_size_parsed,
2169 .help_str = "port config all max-lro-pkt-size <value>",
2171 (void *)&cmd_config_max_lro_pkt_size_port,
2172 (void *)&cmd_config_max_lro_pkt_size_keyword,
2173 (void *)&cmd_config_max_lro_pkt_size_all,
2174 (void *)&cmd_config_max_lro_pkt_size_name,
2175 (void *)&cmd_config_max_lro_pkt_size_value,
2180 /* *** configure port MTU *** */
2181 struct cmd_config_mtu_result {
2182 cmdline_fixed_string_t port;
2183 cmdline_fixed_string_t keyword;
2184 cmdline_fixed_string_t mtu;
2190 cmd_config_mtu_parsed(void *parsed_result,
2191 __rte_unused struct cmdline *cl,
2192 __rte_unused void *data)
2194 struct cmd_config_mtu_result *res = parsed_result;
2196 if (res->value < RTE_ETHER_MIN_LEN) {
2197 printf("mtu cannot be less than %d\n", RTE_ETHER_MIN_LEN);
2200 port_mtu_set(res->port_id, res->value);
2203 cmdline_parse_token_string_t cmd_config_mtu_port =
2204 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
2206 cmdline_parse_token_string_t cmd_config_mtu_keyword =
2207 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2209 cmdline_parse_token_string_t cmd_config_mtu_mtu =
2210 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2212 cmdline_parse_token_num_t cmd_config_mtu_port_id =
2213 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT16);
2214 cmdline_parse_token_num_t cmd_config_mtu_value =
2215 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
2217 cmdline_parse_inst_t cmd_config_mtu = {
2218 .f = cmd_config_mtu_parsed,
2220 .help_str = "port config mtu <port_id> <value>",
2222 (void *)&cmd_config_mtu_port,
2223 (void *)&cmd_config_mtu_keyword,
2224 (void *)&cmd_config_mtu_mtu,
2225 (void *)&cmd_config_mtu_port_id,
2226 (void *)&cmd_config_mtu_value,
2231 /* *** configure rx mode *** */
2232 struct cmd_config_rx_mode_flag {
2233 cmdline_fixed_string_t port;
2234 cmdline_fixed_string_t keyword;
2235 cmdline_fixed_string_t all;
2236 cmdline_fixed_string_t name;
2237 cmdline_fixed_string_t value;
2241 cmd_config_rx_mode_flag_parsed(void *parsed_result,
2242 __rte_unused struct cmdline *cl,
2243 __rte_unused void *data)
2245 struct cmd_config_rx_mode_flag *res = parsed_result;
2247 if (!all_ports_stopped()) {
2248 printf("Please stop all ports first\n");
2252 if (!strcmp(res->name, "drop-en")) {
2253 if (!strcmp(res->value, "on"))
2255 else if (!strcmp(res->value, "off"))
2258 printf("Unknown parameter\n");
2262 printf("Unknown parameter\n");
2268 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2271 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
2272 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
2273 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
2274 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
2276 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
2277 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
2278 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
2279 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
2281 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
2282 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
2285 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
2286 .f = cmd_config_rx_mode_flag_parsed,
2288 .help_str = "port config all drop-en on|off",
2290 (void *)&cmd_config_rx_mode_flag_port,
2291 (void *)&cmd_config_rx_mode_flag_keyword,
2292 (void *)&cmd_config_rx_mode_flag_all,
2293 (void *)&cmd_config_rx_mode_flag_name,
2294 (void *)&cmd_config_rx_mode_flag_value,
2299 /* *** configure rss *** */
2300 struct cmd_config_rss {
2301 cmdline_fixed_string_t port;
2302 cmdline_fixed_string_t keyword;
2303 cmdline_fixed_string_t all;
2304 cmdline_fixed_string_t name;
2305 cmdline_fixed_string_t value;
2309 cmd_config_rss_parsed(void *parsed_result,
2310 __rte_unused struct cmdline *cl,
2311 __rte_unused void *data)
2313 struct cmd_config_rss *res = parsed_result;
2314 struct rte_eth_rss_conf rss_conf = { .rss_key_len = 0, };
2315 struct rte_eth_dev_info dev_info = { .flow_type_rss_offloads = 0, };
2316 int use_default = 0;
2317 int all_updated = 1;
2322 if (!strcmp(res->value, "all"))
2323 rss_conf.rss_hf = ETH_RSS_ETH | ETH_RSS_VLAN | ETH_RSS_IP |
2324 ETH_RSS_TCP | ETH_RSS_UDP | ETH_RSS_SCTP |
2325 ETH_RSS_L2_PAYLOAD | ETH_RSS_L2TPV3 | ETH_RSS_ESP |
2326 ETH_RSS_AH | ETH_RSS_PFCP | ETH_RSS_GTPU;
2327 else if (!strcmp(res->value, "eth"))
2328 rss_conf.rss_hf = ETH_RSS_ETH;
2329 else if (!strcmp(res->value, "vlan"))
2330 rss_conf.rss_hf = ETH_RSS_VLAN;
2331 else if (!strcmp(res->value, "ip"))
2332 rss_conf.rss_hf = ETH_RSS_IP;
2333 else if (!strcmp(res->value, "udp"))
2334 rss_conf.rss_hf = ETH_RSS_UDP;
2335 else if (!strcmp(res->value, "tcp"))
2336 rss_conf.rss_hf = ETH_RSS_TCP;
2337 else if (!strcmp(res->value, "sctp"))
2338 rss_conf.rss_hf = ETH_RSS_SCTP;
2339 else if (!strcmp(res->value, "ether"))
2340 rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD;
2341 else if (!strcmp(res->value, "port"))
2342 rss_conf.rss_hf = ETH_RSS_PORT;
2343 else if (!strcmp(res->value, "vxlan"))
2344 rss_conf.rss_hf = ETH_RSS_VXLAN;
2345 else if (!strcmp(res->value, "geneve"))
2346 rss_conf.rss_hf = ETH_RSS_GENEVE;
2347 else if (!strcmp(res->value, "nvgre"))
2348 rss_conf.rss_hf = ETH_RSS_NVGRE;
2349 else if (!strcmp(res->value, "l3-pre32"))
2350 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE32;
2351 else if (!strcmp(res->value, "l3-pre40"))
2352 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE40;
2353 else if (!strcmp(res->value, "l3-pre48"))
2354 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE48;
2355 else if (!strcmp(res->value, "l3-pre56"))
2356 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE56;
2357 else if (!strcmp(res->value, "l3-pre64"))
2358 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE64;
2359 else if (!strcmp(res->value, "l3-pre96"))
2360 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE96;
2361 else if (!strcmp(res->value, "l3-src-only"))
2362 rss_conf.rss_hf = ETH_RSS_L3_SRC_ONLY;
2363 else if (!strcmp(res->value, "l3-dst-only"))
2364 rss_conf.rss_hf = ETH_RSS_L3_DST_ONLY;
2365 else if (!strcmp(res->value, "l4-src-only"))
2366 rss_conf.rss_hf = ETH_RSS_L4_SRC_ONLY;
2367 else if (!strcmp(res->value, "l4-dst-only"))
2368 rss_conf.rss_hf = ETH_RSS_L4_DST_ONLY;
2369 else if (!strcmp(res->value, "l2-src-only"))
2370 rss_conf.rss_hf = ETH_RSS_L2_SRC_ONLY;
2371 else if (!strcmp(res->value, "l2-dst-only"))
2372 rss_conf.rss_hf = ETH_RSS_L2_DST_ONLY;
2373 else if (!strcmp(res->value, "l2tpv3"))
2374 rss_conf.rss_hf = ETH_RSS_L2TPV3;
2375 else if (!strcmp(res->value, "esp"))
2376 rss_conf.rss_hf = ETH_RSS_ESP;
2377 else if (!strcmp(res->value, "ah"))
2378 rss_conf.rss_hf = ETH_RSS_AH;
2379 else if (!strcmp(res->value, "pfcp"))
2380 rss_conf.rss_hf = ETH_RSS_PFCP;
2381 else if (!strcmp(res->value, "pppoe"))
2382 rss_conf.rss_hf = ETH_RSS_PPPOE;
2383 else if (!strcmp(res->value, "gtpu"))
2384 rss_conf.rss_hf = ETH_RSS_GTPU;
2385 else if (!strcmp(res->value, "none"))
2386 rss_conf.rss_hf = 0;
2387 else if (!strcmp(res->value, "level-default")) {
2388 rss_hf &= (~ETH_RSS_LEVEL_MASK);
2389 rss_conf.rss_hf = (rss_hf | ETH_RSS_LEVEL_PMD_DEFAULT);
2390 } else if (!strcmp(res->value, "level-outer")) {
2391 rss_hf &= (~ETH_RSS_LEVEL_MASK);
2392 rss_conf.rss_hf = (rss_hf | ETH_RSS_LEVEL_OUTERMOST);
2393 } else if (!strcmp(res->value, "level-inner")) {
2394 rss_hf &= (~ETH_RSS_LEVEL_MASK);
2395 rss_conf.rss_hf = (rss_hf | ETH_RSS_LEVEL_INNERMOST);
2396 } else if (!strcmp(res->value, "default"))
2398 else if (isdigit(res->value[0]) && atoi(res->value) > 0 &&
2399 atoi(res->value) < 64)
2400 rss_conf.rss_hf = 1ULL << atoi(res->value);
2402 printf("Unknown parameter\n");
2405 rss_conf.rss_key = NULL;
2406 /* Update global configuration for RSS types. */
2407 RTE_ETH_FOREACH_DEV(i) {
2408 struct rte_eth_rss_conf local_rss_conf;
2410 ret = eth_dev_info_get_print_err(i, &dev_info);
2415 rss_conf.rss_hf = dev_info.flow_type_rss_offloads;
2417 local_rss_conf = rss_conf;
2418 local_rss_conf.rss_hf = rss_conf.rss_hf &
2419 dev_info.flow_type_rss_offloads;
2420 if (local_rss_conf.rss_hf != rss_conf.rss_hf) {
2421 printf("Port %u modified RSS hash function based on hardware support,"
2422 "requested:%#"PRIx64" configured:%#"PRIx64"\n",
2423 i, rss_conf.rss_hf, local_rss_conf.rss_hf);
2425 diag = rte_eth_dev_rss_hash_update(i, &local_rss_conf);
2428 printf("Configuration of RSS hash at ethernet port %d "
2429 "failed with error (%d): %s.\n",
2430 i, -diag, strerror(-diag));
2433 if (all_updated && !use_default) {
2434 rss_hf = rss_conf.rss_hf;
2435 printf("rss_hf %#"PRIx64"\n", rss_hf);
2439 cmdline_parse_token_string_t cmd_config_rss_port =
2440 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
2441 cmdline_parse_token_string_t cmd_config_rss_keyword =
2442 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
2443 cmdline_parse_token_string_t cmd_config_rss_all =
2444 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
2445 cmdline_parse_token_string_t cmd_config_rss_name =
2446 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
2447 cmdline_parse_token_string_t cmd_config_rss_value =
2448 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, NULL);
2450 cmdline_parse_inst_t cmd_config_rss = {
2451 .f = cmd_config_rss_parsed,
2453 .help_str = "port config all rss "
2454 "all|default|eth|vlan|ip|tcp|udp|sctp|ether|port|vxlan|geneve|"
2455 "nvgre|vxlan-gpe|l2tpv3|esp|ah|pfcp|none|level-default|"
2456 "level-outer|level-inner|<flowtype_id>",
2458 (void *)&cmd_config_rss_port,
2459 (void *)&cmd_config_rss_keyword,
2460 (void *)&cmd_config_rss_all,
2461 (void *)&cmd_config_rss_name,
2462 (void *)&cmd_config_rss_value,
2467 /* *** configure rss hash key *** */
2468 struct cmd_config_rss_hash_key {
2469 cmdline_fixed_string_t port;
2470 cmdline_fixed_string_t config;
2472 cmdline_fixed_string_t rss_hash_key;
2473 cmdline_fixed_string_t rss_type;
2474 cmdline_fixed_string_t key;
2478 hexa_digit_to_value(char hexa_digit)
2480 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
2481 return (uint8_t) (hexa_digit - '0');
2482 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
2483 return (uint8_t) ((hexa_digit - 'a') + 10);
2484 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
2485 return (uint8_t) ((hexa_digit - 'A') + 10);
2486 /* Invalid hexa digit */
2491 parse_and_check_key_hexa_digit(char *key, int idx)
2495 hexa_v = hexa_digit_to_value(key[idx]);
2497 printf("invalid key: character %c at position %d is not a "
2498 "valid hexa digit\n", key[idx], idx);
2503 cmd_config_rss_hash_key_parsed(void *parsed_result,
2504 __rte_unused struct cmdline *cl,
2505 __rte_unused void *data)
2507 struct cmd_config_rss_hash_key *res = parsed_result;
2508 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
2512 struct rte_eth_dev_info dev_info;
2513 uint8_t hash_key_size;
2517 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
2521 if (dev_info.hash_key_size > 0 &&
2522 dev_info.hash_key_size <= sizeof(hash_key))
2523 hash_key_size = dev_info.hash_key_size;
2525 printf("dev_info did not provide a valid hash key size\n");
2528 /* Check the length of the RSS hash key */
2529 key_len = strlen(res->key);
2530 if (key_len != (hash_key_size * 2)) {
2531 printf("key length: %d invalid - key must be a string of %d"
2532 " hexa-decimal numbers\n",
2533 (int) key_len, hash_key_size * 2);
2536 /* Translate RSS hash key into binary representation */
2537 for (i = 0; i < hash_key_size; i++) {
2538 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
2541 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
2544 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
2546 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
2550 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
2551 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
2552 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
2553 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
2555 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
2556 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT16);
2557 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
2558 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
2559 rss_hash_key, "rss-hash-key");
2560 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
2561 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
2562 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2563 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2564 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2565 "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 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
2570 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
2572 cmdline_parse_inst_t cmd_config_rss_hash_key = {
2573 .f = cmd_config_rss_hash_key_parsed,
2575 .help_str = "port config <port_id> rss-hash-key "
2576 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2577 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2578 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex|"
2579 "l3-src-only|l3-dst-only|l4-src-only|l4-dst-only|"
2580 "l2-src-only|l2-dst-only|s-vlan|c-vlan|"
2581 "l2tpv3|esp|ah|pfcp|pppoe|gtpu "
2582 "<string of hex digits (variable length, NIC dependent)>",
2584 (void *)&cmd_config_rss_hash_key_port,
2585 (void *)&cmd_config_rss_hash_key_config,
2586 (void *)&cmd_config_rss_hash_key_port_id,
2587 (void *)&cmd_config_rss_hash_key_rss_hash_key,
2588 (void *)&cmd_config_rss_hash_key_rss_type,
2589 (void *)&cmd_config_rss_hash_key_value,
2594 /* *** configure port rxq/txq ring size *** */
2595 struct cmd_config_rxtx_ring_size {
2596 cmdline_fixed_string_t port;
2597 cmdline_fixed_string_t config;
2599 cmdline_fixed_string_t rxtxq;
2601 cmdline_fixed_string_t rsize;
2606 cmd_config_rxtx_ring_size_parsed(void *parsed_result,
2607 __rte_unused struct cmdline *cl,
2608 __rte_unused void *data)
2610 struct cmd_config_rxtx_ring_size *res = parsed_result;
2611 struct rte_port *port;
2614 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2617 if (res->portid == (portid_t)RTE_PORT_ALL) {
2618 printf("Invalid port id\n");
2622 port = &ports[res->portid];
2624 if (!strcmp(res->rxtxq, "rxq"))
2626 else if (!strcmp(res->rxtxq, "txq"))
2629 printf("Unknown parameter\n");
2633 if (isrx && rx_queue_id_is_invalid(res->qid))
2635 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2638 if (isrx && res->size != 0 && res->size <= rx_free_thresh) {
2639 printf("Invalid rx ring_size, must > rx_free_thresh: %d\n",
2645 port->nb_rx_desc[res->qid] = res->size;
2647 port->nb_tx_desc[res->qid] = res->size;
2649 cmd_reconfig_device_queue(res->portid, 0, 1);
2652 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_port =
2653 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2655 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_config =
2656 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2658 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_portid =
2659 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2661 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rxtxq =
2662 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2664 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_qid =
2665 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2667 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rsize =
2668 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2669 rsize, "ring_size");
2670 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_size =
2671 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2674 cmdline_parse_inst_t cmd_config_rxtx_ring_size = {
2675 .f = cmd_config_rxtx_ring_size_parsed,
2677 .help_str = "port config <port_id> rxq|txq <queue_id> ring_size <value>",
2679 (void *)&cmd_config_rxtx_ring_size_port,
2680 (void *)&cmd_config_rxtx_ring_size_config,
2681 (void *)&cmd_config_rxtx_ring_size_portid,
2682 (void *)&cmd_config_rxtx_ring_size_rxtxq,
2683 (void *)&cmd_config_rxtx_ring_size_qid,
2684 (void *)&cmd_config_rxtx_ring_size_rsize,
2685 (void *)&cmd_config_rxtx_ring_size_size,
2690 /* *** configure port rxq/txq start/stop *** */
2691 struct cmd_config_rxtx_queue {
2692 cmdline_fixed_string_t port;
2694 cmdline_fixed_string_t rxtxq;
2696 cmdline_fixed_string_t opname;
2700 cmd_config_rxtx_queue_parsed(void *parsed_result,
2701 __rte_unused struct cmdline *cl,
2702 __rte_unused void *data)
2704 struct cmd_config_rxtx_queue *res = parsed_result;
2709 if (test_done == 0) {
2710 printf("Please stop forwarding first\n");
2714 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2717 if (port_is_started(res->portid) != 1) {
2718 printf("Please start port %u first\n", res->portid);
2722 if (!strcmp(res->rxtxq, "rxq"))
2724 else if (!strcmp(res->rxtxq, "txq"))
2727 printf("Unknown parameter\n");
2731 if (isrx && rx_queue_id_is_invalid(res->qid))
2733 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2736 if (!strcmp(res->opname, "start"))
2738 else if (!strcmp(res->opname, "stop"))
2741 printf("Unknown parameter\n");
2745 if (isstart && isrx)
2746 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
2747 else if (!isstart && isrx)
2748 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
2749 else if (isstart && !isrx)
2750 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
2752 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
2754 if (ret == -ENOTSUP)
2755 printf("Function not supported in PMD driver\n");
2758 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
2759 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
2760 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
2761 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT16);
2762 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
2763 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
2764 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
2765 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
2766 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
2767 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
2770 cmdline_parse_inst_t cmd_config_rxtx_queue = {
2771 .f = cmd_config_rxtx_queue_parsed,
2773 .help_str = "port <port_id> rxq|txq <queue_id> start|stop",
2775 (void *)&cmd_config_rxtx_queue_port,
2776 (void *)&cmd_config_rxtx_queue_portid,
2777 (void *)&cmd_config_rxtx_queue_rxtxq,
2778 (void *)&cmd_config_rxtx_queue_qid,
2779 (void *)&cmd_config_rxtx_queue_opname,
2784 /* *** configure port rxq/txq deferred start on/off *** */
2785 struct cmd_config_deferred_start_rxtx_queue {
2786 cmdline_fixed_string_t port;
2788 cmdline_fixed_string_t rxtxq;
2790 cmdline_fixed_string_t opname;
2791 cmdline_fixed_string_t state;
2795 cmd_config_deferred_start_rxtx_queue_parsed(void *parsed_result,
2796 __rte_unused struct cmdline *cl,
2797 __rte_unused void *data)
2799 struct cmd_config_deferred_start_rxtx_queue *res = parsed_result;
2800 struct rte_port *port;
2803 uint8_t needreconfig = 0;
2805 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
2808 if (port_is_started(res->port_id) != 0) {
2809 printf("Please stop port %u first\n", res->port_id);
2813 port = &ports[res->port_id];
2815 isrx = !strcmp(res->rxtxq, "rxq");
2817 if (isrx && rx_queue_id_is_invalid(res->qid))
2819 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2822 ison = !strcmp(res->state, "on");
2824 if (isrx && port->rx_conf[res->qid].rx_deferred_start != ison) {
2825 port->rx_conf[res->qid].rx_deferred_start = ison;
2827 } else if (!isrx && port->tx_conf[res->qid].tx_deferred_start != ison) {
2828 port->tx_conf[res->qid].tx_deferred_start = ison;
2833 cmd_reconfig_device_queue(res->port_id, 0, 1);
2836 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_port =
2837 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2839 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_port_id =
2840 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2842 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_rxtxq =
2843 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2845 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_qid =
2846 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2848 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_opname =
2849 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2850 opname, "deferred_start");
2851 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_state =
2852 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2855 cmdline_parse_inst_t cmd_config_deferred_start_rxtx_queue = {
2856 .f = cmd_config_deferred_start_rxtx_queue_parsed,
2858 .help_str = "port <port_id> rxq|txq <queue_id> deferred_start on|off",
2860 (void *)&cmd_config_deferred_start_rxtx_queue_port,
2861 (void *)&cmd_config_deferred_start_rxtx_queue_port_id,
2862 (void *)&cmd_config_deferred_start_rxtx_queue_rxtxq,
2863 (void *)&cmd_config_deferred_start_rxtx_queue_qid,
2864 (void *)&cmd_config_deferred_start_rxtx_queue_opname,
2865 (void *)&cmd_config_deferred_start_rxtx_queue_state,
2870 /* *** configure port rxq/txq setup *** */
2871 struct cmd_setup_rxtx_queue {
2872 cmdline_fixed_string_t port;
2874 cmdline_fixed_string_t rxtxq;
2876 cmdline_fixed_string_t setup;
2879 /* Common CLI fields for queue setup */
2880 cmdline_parse_token_string_t cmd_setup_rxtx_queue_port =
2881 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, port, "port");
2882 cmdline_parse_token_num_t cmd_setup_rxtx_queue_portid =
2883 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, portid, UINT16);
2884 cmdline_parse_token_string_t cmd_setup_rxtx_queue_rxtxq =
2885 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, rxtxq, "rxq#txq");
2886 cmdline_parse_token_num_t cmd_setup_rxtx_queue_qid =
2887 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, qid, UINT16);
2888 cmdline_parse_token_string_t cmd_setup_rxtx_queue_setup =
2889 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, setup, "setup");
2892 cmd_setup_rxtx_queue_parsed(
2893 void *parsed_result,
2894 __rte_unused struct cmdline *cl,
2895 __rte_unused void *data)
2897 struct cmd_setup_rxtx_queue *res = parsed_result;
2898 struct rte_port *port;
2899 struct rte_mempool *mp;
2900 unsigned int socket_id;
2904 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2907 if (res->portid == (portid_t)RTE_PORT_ALL) {
2908 printf("Invalid port id\n");
2912 if (!strcmp(res->rxtxq, "rxq"))
2914 else if (!strcmp(res->rxtxq, "txq"))
2917 printf("Unknown parameter\n");
2921 if (isrx && rx_queue_id_is_invalid(res->qid)) {
2922 printf("Invalid rx queue\n");
2924 } else if (!isrx && tx_queue_id_is_invalid(res->qid)) {
2925 printf("Invalid tx queue\n");
2929 port = &ports[res->portid];
2931 socket_id = rxring_numa[res->portid];
2932 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2933 socket_id = port->socket_id;
2935 mp = mbuf_pool_find(socket_id, 0);
2937 printf("Failed to setup RX queue: "
2938 "No mempool allocation"
2939 " on the socket %d\n",
2940 rxring_numa[res->portid]);
2943 ret = rx_queue_setup(res->portid,
2945 port->nb_rx_desc[res->qid],
2947 &port->rx_conf[res->qid],
2950 printf("Failed to setup RX queue\n");
2952 socket_id = txring_numa[res->portid];
2953 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2954 socket_id = port->socket_id;
2956 ret = rte_eth_tx_queue_setup(res->portid,
2958 port->nb_tx_desc[res->qid],
2960 &port->tx_conf[res->qid]);
2962 printf("Failed to setup TX queue\n");
2966 cmdline_parse_inst_t cmd_setup_rxtx_queue = {
2967 .f = cmd_setup_rxtx_queue_parsed,
2969 .help_str = "port <port_id> rxq|txq <queue_idx> setup",
2971 (void *)&cmd_setup_rxtx_queue_port,
2972 (void *)&cmd_setup_rxtx_queue_portid,
2973 (void *)&cmd_setup_rxtx_queue_rxtxq,
2974 (void *)&cmd_setup_rxtx_queue_qid,
2975 (void *)&cmd_setup_rxtx_queue_setup,
2981 /* *** Configure RSS RETA *** */
2982 struct cmd_config_rss_reta {
2983 cmdline_fixed_string_t port;
2984 cmdline_fixed_string_t keyword;
2986 cmdline_fixed_string_t name;
2987 cmdline_fixed_string_t list_name;
2988 cmdline_fixed_string_t list_of_items;
2992 parse_reta_config(const char *str,
2993 struct rte_eth_rss_reta_entry64 *reta_conf,
2994 uint16_t nb_entries)
2998 uint16_t hash_index, idx, shift;
3001 const char *p, *p0 = str;
3008 unsigned long int_fld[_NUM_FLD];
3009 char *str_fld[_NUM_FLD];
3011 while ((p = strchr(p0,'(')) != NULL) {
3013 if((p0 = strchr(p,')')) == NULL)
3017 if(size >= sizeof(s))
3020 snprintf(s, sizeof(s), "%.*s", size, p);
3021 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
3023 for (i = 0; i < _NUM_FLD; i++) {
3025 int_fld[i] = strtoul(str_fld[i], &end, 0);
3026 if (errno != 0 || end == str_fld[i] ||
3031 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
3032 nb_queue = (uint16_t)int_fld[FLD_QUEUE];
3034 if (hash_index >= nb_entries) {
3035 printf("Invalid RETA hash index=%d\n", hash_index);
3039 idx = hash_index / RTE_RETA_GROUP_SIZE;
3040 shift = hash_index % RTE_RETA_GROUP_SIZE;
3041 reta_conf[idx].mask |= (1ULL << shift);
3042 reta_conf[idx].reta[shift] = nb_queue;
3049 cmd_set_rss_reta_parsed(void *parsed_result,
3050 __rte_unused struct cmdline *cl,
3051 __rte_unused void *data)
3054 struct rte_eth_dev_info dev_info;
3055 struct rte_eth_rss_reta_entry64 reta_conf[8];
3056 struct cmd_config_rss_reta *res = parsed_result;
3058 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
3062 if (dev_info.reta_size == 0) {
3063 printf("Redirection table size is 0 which is "
3064 "invalid for RSS\n");
3067 printf("The reta size of port %d is %u\n",
3068 res->port_id, dev_info.reta_size);
3069 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
3070 printf("Currently do not support more than %u entries of "
3071 "redirection table\n", ETH_RSS_RETA_SIZE_512);
3075 memset(reta_conf, 0, sizeof(reta_conf));
3076 if (!strcmp(res->list_name, "reta")) {
3077 if (parse_reta_config(res->list_of_items, reta_conf,
3078 dev_info.reta_size)) {
3079 printf("Invalid RSS Redirection Table "
3080 "config entered\n");
3083 ret = rte_eth_dev_rss_reta_update(res->port_id,
3084 reta_conf, dev_info.reta_size);
3086 printf("Bad redirection table parameter, "
3087 "return code = %d \n", ret);
3091 cmdline_parse_token_string_t cmd_config_rss_reta_port =
3092 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
3093 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
3094 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
3095 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
3096 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT16);
3097 cmdline_parse_token_string_t cmd_config_rss_reta_name =
3098 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
3099 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
3100 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
3101 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
3102 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
3104 cmdline_parse_inst_t cmd_config_rss_reta = {
3105 .f = cmd_set_rss_reta_parsed,
3107 .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
3109 (void *)&cmd_config_rss_reta_port,
3110 (void *)&cmd_config_rss_reta_keyword,
3111 (void *)&cmd_config_rss_reta_port_id,
3112 (void *)&cmd_config_rss_reta_name,
3113 (void *)&cmd_config_rss_reta_list_name,
3114 (void *)&cmd_config_rss_reta_list_of_items,
3119 /* *** SHOW PORT RETA INFO *** */
3120 struct cmd_showport_reta {
3121 cmdline_fixed_string_t show;
3122 cmdline_fixed_string_t port;
3124 cmdline_fixed_string_t rss;
3125 cmdline_fixed_string_t reta;
3127 cmdline_fixed_string_t list_of_items;
3131 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
3132 uint16_t nb_entries,
3136 const char *p, *p0 = str;
3141 uint16_t num = (nb_entries + RTE_RETA_GROUP_SIZE - 1) /
3142 RTE_RETA_GROUP_SIZE;
3145 p = strchr(p0, '(');
3149 p0 = strchr(p, ')');
3153 if (size >= sizeof(s)) {
3154 printf("The string size exceeds the internal buffer size\n");
3157 snprintf(s, sizeof(s), "%.*s", size, p);
3158 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
3159 if (ret <= 0 || ret != num) {
3160 printf("The bits of masks do not match the number of "
3161 "reta entries: %u\n", num);
3164 for (i = 0; i < ret; i++)
3165 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
3171 cmd_showport_reta_parsed(void *parsed_result,
3172 __rte_unused struct cmdline *cl,
3173 __rte_unused void *data)
3175 struct cmd_showport_reta *res = parsed_result;
3176 struct rte_eth_rss_reta_entry64 reta_conf[8];
3177 struct rte_eth_dev_info dev_info;
3178 uint16_t max_reta_size;
3181 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
3185 max_reta_size = RTE_MIN(dev_info.reta_size, ETH_RSS_RETA_SIZE_512);
3186 if (res->size == 0 || res->size > max_reta_size) {
3187 printf("Invalid redirection table size: %u (1-%u)\n",
3188 res->size, max_reta_size);
3192 memset(reta_conf, 0, sizeof(reta_conf));
3193 if (showport_parse_reta_config(reta_conf, res->size,
3194 res->list_of_items) < 0) {
3195 printf("Invalid string: %s for reta masks\n",
3196 res->list_of_items);
3199 port_rss_reta_info(res->port_id, reta_conf, res->size);
3202 cmdline_parse_token_string_t cmd_showport_reta_show =
3203 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
3204 cmdline_parse_token_string_t cmd_showport_reta_port =
3205 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
3206 cmdline_parse_token_num_t cmd_showport_reta_port_id =
3207 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT16);
3208 cmdline_parse_token_string_t cmd_showport_reta_rss =
3209 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
3210 cmdline_parse_token_string_t cmd_showport_reta_reta =
3211 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
3212 cmdline_parse_token_num_t cmd_showport_reta_size =
3213 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16);
3214 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
3215 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
3216 list_of_items, NULL);
3218 cmdline_parse_inst_t cmd_showport_reta = {
3219 .f = cmd_showport_reta_parsed,
3221 .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
3223 (void *)&cmd_showport_reta_show,
3224 (void *)&cmd_showport_reta_port,
3225 (void *)&cmd_showport_reta_port_id,
3226 (void *)&cmd_showport_reta_rss,
3227 (void *)&cmd_showport_reta_reta,
3228 (void *)&cmd_showport_reta_size,
3229 (void *)&cmd_showport_reta_list_of_items,
3234 /* *** Show RSS hash configuration *** */
3235 struct cmd_showport_rss_hash {
3236 cmdline_fixed_string_t show;
3237 cmdline_fixed_string_t port;
3239 cmdline_fixed_string_t rss_hash;
3240 cmdline_fixed_string_t rss_type;
3241 cmdline_fixed_string_t key; /* optional argument */
3244 static void cmd_showport_rss_hash_parsed(void *parsed_result,
3245 __rte_unused struct cmdline *cl,
3248 struct cmd_showport_rss_hash *res = parsed_result;
3250 port_rss_hash_conf_show(res->port_id, show_rss_key != NULL);
3253 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
3254 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
3255 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
3256 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
3257 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
3258 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT16);
3259 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
3260 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
3262 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
3263 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
3265 cmdline_parse_inst_t cmd_showport_rss_hash = {
3266 .f = cmd_showport_rss_hash_parsed,
3268 .help_str = "show port <port_id> rss-hash",
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,
3278 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
3279 .f = cmd_showport_rss_hash_parsed,
3281 .help_str = "show port <port_id> rss-hash key",
3283 (void *)&cmd_showport_rss_hash_show,
3284 (void *)&cmd_showport_rss_hash_port,
3285 (void *)&cmd_showport_rss_hash_port_id,
3286 (void *)&cmd_showport_rss_hash_rss_hash,
3287 (void *)&cmd_showport_rss_hash_rss_key,
3292 /* *** Configure DCB *** */
3293 struct cmd_config_dcb {
3294 cmdline_fixed_string_t port;
3295 cmdline_fixed_string_t config;
3297 cmdline_fixed_string_t dcb;
3298 cmdline_fixed_string_t vt;
3299 cmdline_fixed_string_t vt_en;
3301 cmdline_fixed_string_t pfc;
3302 cmdline_fixed_string_t pfc_en;
3306 cmd_config_dcb_parsed(void *parsed_result,
3307 __rte_unused struct cmdline *cl,
3308 __rte_unused void *data)
3310 struct cmd_config_dcb *res = parsed_result;
3311 portid_t port_id = res->port_id;
3312 struct rte_port *port;
3316 port = &ports[port_id];
3317 /** Check if the port is not started **/
3318 if (port->port_status != RTE_PORT_STOPPED) {
3319 printf("Please stop port %d first\n", port_id);
3323 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
3324 printf("The invalid number of traffic class,"
3325 " only 4 or 8 allowed.\n");
3329 if (nb_fwd_lcores < res->num_tcs) {
3330 printf("nb_cores shouldn't be less than number of TCs.\n");
3333 if (!strncmp(res->pfc_en, "on", 2))
3338 /* DCB in VT mode */
3339 if (!strncmp(res->vt_en, "on", 2))
3340 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
3341 (enum rte_eth_nb_tcs)res->num_tcs,
3344 ret = init_port_dcb_config(port_id, DCB_ENABLED,
3345 (enum rte_eth_nb_tcs)res->num_tcs,
3350 printf("Cannot initialize network ports.\n");
3354 cmd_reconfig_device_queue(port_id, 1, 1);
3357 cmdline_parse_token_string_t cmd_config_dcb_port =
3358 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
3359 cmdline_parse_token_string_t cmd_config_dcb_config =
3360 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
3361 cmdline_parse_token_num_t cmd_config_dcb_port_id =
3362 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT16);
3363 cmdline_parse_token_string_t cmd_config_dcb_dcb =
3364 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
3365 cmdline_parse_token_string_t cmd_config_dcb_vt =
3366 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
3367 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
3368 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
3369 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
3370 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
3371 cmdline_parse_token_string_t cmd_config_dcb_pfc=
3372 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
3373 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
3374 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
3376 cmdline_parse_inst_t cmd_config_dcb = {
3377 .f = cmd_config_dcb_parsed,
3379 .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
3381 (void *)&cmd_config_dcb_port,
3382 (void *)&cmd_config_dcb_config,
3383 (void *)&cmd_config_dcb_port_id,
3384 (void *)&cmd_config_dcb_dcb,
3385 (void *)&cmd_config_dcb_vt,
3386 (void *)&cmd_config_dcb_vt_en,
3387 (void *)&cmd_config_dcb_num_tcs,
3388 (void *)&cmd_config_dcb_pfc,
3389 (void *)&cmd_config_dcb_pfc_en,
3394 /* *** configure number of packets per burst *** */
3395 struct cmd_config_burst {
3396 cmdline_fixed_string_t port;
3397 cmdline_fixed_string_t keyword;
3398 cmdline_fixed_string_t all;
3399 cmdline_fixed_string_t name;
3404 cmd_config_burst_parsed(void *parsed_result,
3405 __rte_unused struct cmdline *cl,
3406 __rte_unused void *data)
3408 struct cmd_config_burst *res = parsed_result;
3409 struct rte_eth_dev_info dev_info;
3410 uint16_t rec_nb_pkts;
3413 if (!all_ports_stopped()) {
3414 printf("Please stop all ports first\n");
3418 if (!strcmp(res->name, "burst")) {
3419 if (res->value == 0) {
3420 /* If user gives a value of zero, query the PMD for
3421 * its recommended Rx burst size. Testpmd uses a single
3422 * size for all ports, so assume all ports are the same
3423 * NIC model and use the values from Port 0.
3425 ret = eth_dev_info_get_print_err(0, &dev_info);
3429 rec_nb_pkts = dev_info.default_rxportconf.burst_size;
3431 if (rec_nb_pkts == 0) {
3432 printf("PMD does not recommend a burst size.\n"
3433 "User provided value must be between"
3434 " 1 and %d\n", MAX_PKT_BURST);
3436 } else if (rec_nb_pkts > MAX_PKT_BURST) {
3437 printf("PMD recommended burst size of %d"
3438 " exceeds maximum value of %d\n",
3439 rec_nb_pkts, MAX_PKT_BURST);
3442 printf("Using PMD-provided burst value of %d\n",
3444 nb_pkt_per_burst = rec_nb_pkts;
3445 } else if (res->value > MAX_PKT_BURST) {
3446 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
3449 nb_pkt_per_burst = res->value;
3451 printf("Unknown parameter\n");
3457 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3460 cmdline_parse_token_string_t cmd_config_burst_port =
3461 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
3462 cmdline_parse_token_string_t cmd_config_burst_keyword =
3463 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
3464 cmdline_parse_token_string_t cmd_config_burst_all =
3465 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
3466 cmdline_parse_token_string_t cmd_config_burst_name =
3467 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
3468 cmdline_parse_token_num_t cmd_config_burst_value =
3469 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
3471 cmdline_parse_inst_t cmd_config_burst = {
3472 .f = cmd_config_burst_parsed,
3474 .help_str = "port config all burst <value>",
3476 (void *)&cmd_config_burst_port,
3477 (void *)&cmd_config_burst_keyword,
3478 (void *)&cmd_config_burst_all,
3479 (void *)&cmd_config_burst_name,
3480 (void *)&cmd_config_burst_value,
3485 /* *** configure rx/tx queues *** */
3486 struct cmd_config_thresh {
3487 cmdline_fixed_string_t port;
3488 cmdline_fixed_string_t keyword;
3489 cmdline_fixed_string_t all;
3490 cmdline_fixed_string_t name;
3495 cmd_config_thresh_parsed(void *parsed_result,
3496 __rte_unused struct cmdline *cl,
3497 __rte_unused void *data)
3499 struct cmd_config_thresh *res = parsed_result;
3501 if (!all_ports_stopped()) {
3502 printf("Please stop all ports first\n");
3506 if (!strcmp(res->name, "txpt"))
3507 tx_pthresh = res->value;
3508 else if(!strcmp(res->name, "txht"))
3509 tx_hthresh = res->value;
3510 else if(!strcmp(res->name, "txwt"))
3511 tx_wthresh = res->value;
3512 else if(!strcmp(res->name, "rxpt"))
3513 rx_pthresh = res->value;
3514 else if(!strcmp(res->name, "rxht"))
3515 rx_hthresh = res->value;
3516 else if(!strcmp(res->name, "rxwt"))
3517 rx_wthresh = res->value;
3519 printf("Unknown parameter\n");
3525 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3528 cmdline_parse_token_string_t cmd_config_thresh_port =
3529 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
3530 cmdline_parse_token_string_t cmd_config_thresh_keyword =
3531 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
3532 cmdline_parse_token_string_t cmd_config_thresh_all =
3533 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
3534 cmdline_parse_token_string_t cmd_config_thresh_name =
3535 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
3536 "txpt#txht#txwt#rxpt#rxht#rxwt");
3537 cmdline_parse_token_num_t cmd_config_thresh_value =
3538 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
3540 cmdline_parse_inst_t cmd_config_thresh = {
3541 .f = cmd_config_thresh_parsed,
3543 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
3545 (void *)&cmd_config_thresh_port,
3546 (void *)&cmd_config_thresh_keyword,
3547 (void *)&cmd_config_thresh_all,
3548 (void *)&cmd_config_thresh_name,
3549 (void *)&cmd_config_thresh_value,
3554 /* *** configure free/rs threshold *** */
3555 struct cmd_config_threshold {
3556 cmdline_fixed_string_t port;
3557 cmdline_fixed_string_t keyword;
3558 cmdline_fixed_string_t all;
3559 cmdline_fixed_string_t name;
3564 cmd_config_threshold_parsed(void *parsed_result,
3565 __rte_unused struct cmdline *cl,
3566 __rte_unused void *data)
3568 struct cmd_config_threshold *res = parsed_result;
3570 if (!all_ports_stopped()) {
3571 printf("Please stop all ports first\n");
3575 if (!strcmp(res->name, "txfreet"))
3576 tx_free_thresh = res->value;
3577 else if (!strcmp(res->name, "txrst"))
3578 tx_rs_thresh = res->value;
3579 else if (!strcmp(res->name, "rxfreet"))
3580 rx_free_thresh = res->value;
3582 printf("Unknown parameter\n");
3588 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3591 cmdline_parse_token_string_t cmd_config_threshold_port =
3592 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
3593 cmdline_parse_token_string_t cmd_config_threshold_keyword =
3594 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
3596 cmdline_parse_token_string_t cmd_config_threshold_all =
3597 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
3598 cmdline_parse_token_string_t cmd_config_threshold_name =
3599 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
3600 "txfreet#txrst#rxfreet");
3601 cmdline_parse_token_num_t cmd_config_threshold_value =
3602 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
3604 cmdline_parse_inst_t cmd_config_threshold = {
3605 .f = cmd_config_threshold_parsed,
3607 .help_str = "port config all txfreet|txrst|rxfreet <value>",
3609 (void *)&cmd_config_threshold_port,
3610 (void *)&cmd_config_threshold_keyword,
3611 (void *)&cmd_config_threshold_all,
3612 (void *)&cmd_config_threshold_name,
3613 (void *)&cmd_config_threshold_value,
3619 struct cmd_stop_result {
3620 cmdline_fixed_string_t stop;
3623 static void cmd_stop_parsed(__rte_unused void *parsed_result,
3624 __rte_unused struct cmdline *cl,
3625 __rte_unused void *data)
3627 stop_packet_forwarding();
3630 cmdline_parse_token_string_t cmd_stop_stop =
3631 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
3633 cmdline_parse_inst_t cmd_stop = {
3634 .f = cmd_stop_parsed,
3636 .help_str = "stop: Stop packet forwarding",
3638 (void *)&cmd_stop_stop,
3643 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
3646 parse_item_list(char* str, const char* item_name, unsigned int max_items,
3647 unsigned int *parsed_items, int check_unique_values)
3649 unsigned int nb_item;
3657 * First parse all items in the list and store their value.
3662 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
3664 if ((c >= '0') && (c <= '9')) {
3665 value = (unsigned int) (value * 10 + (c - '0'));
3670 printf("character %c is not a decimal digit\n", c);
3674 printf("No valid value before comma\n");
3677 if (nb_item < max_items) {
3678 parsed_items[nb_item] = value;
3684 if (nb_item >= max_items) {
3685 printf("Number of %s = %u > %u (maximum items)\n",
3686 item_name, nb_item + 1, max_items);
3689 parsed_items[nb_item++] = value;
3690 if (! check_unique_values)
3694 * Then, check that all values in the list are differents.
3695 * No optimization here...
3697 for (i = 0; i < nb_item; i++) {
3698 for (j = i + 1; j < nb_item; j++) {
3699 if (parsed_items[j] == parsed_items[i]) {
3700 printf("duplicated %s %u at index %u and %u\n",
3701 item_name, parsed_items[i], i, j);
3709 struct cmd_set_list_result {
3710 cmdline_fixed_string_t cmd_keyword;
3711 cmdline_fixed_string_t list_name;
3712 cmdline_fixed_string_t list_of_items;
3715 static void cmd_set_list_parsed(void *parsed_result,
3716 __rte_unused struct cmdline *cl,
3717 __rte_unused void *data)
3719 struct cmd_set_list_result *res;
3721 unsigned int lcorelist[RTE_MAX_LCORE];
3722 unsigned int portlist[RTE_MAX_ETHPORTS];
3724 unsigned int nb_item;
3726 if (test_done == 0) {
3727 printf("Please stop forwarding first\n");
3731 res = parsed_result;
3732 if (!strcmp(res->list_name, "corelist")) {
3733 nb_item = parse_item_list(res->list_of_items, "core",
3735 parsed_items.lcorelist, 1);
3737 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
3742 if (!strcmp(res->list_name, "portlist")) {
3743 nb_item = parse_item_list(res->list_of_items, "port",
3745 parsed_items.portlist, 1);
3747 set_fwd_ports_list(parsed_items.portlist, nb_item);
3753 cmdline_parse_token_string_t cmd_set_list_keyword =
3754 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
3756 cmdline_parse_token_string_t cmd_set_list_name =
3757 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
3758 "corelist#portlist");
3759 cmdline_parse_token_string_t cmd_set_list_of_items =
3760 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
3763 cmdline_parse_inst_t cmd_set_fwd_list = {
3764 .f = cmd_set_list_parsed,
3766 .help_str = "set corelist|portlist <list0[,list1]*>",
3768 (void *)&cmd_set_list_keyword,
3769 (void *)&cmd_set_list_name,
3770 (void *)&cmd_set_list_of_items,
3775 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
3777 struct cmd_setmask_result {
3778 cmdline_fixed_string_t set;
3779 cmdline_fixed_string_t mask;
3783 static void cmd_set_mask_parsed(void *parsed_result,
3784 __rte_unused struct cmdline *cl,
3785 __rte_unused void *data)
3787 struct cmd_setmask_result *res = parsed_result;
3789 if (test_done == 0) {
3790 printf("Please stop forwarding first\n");
3793 if (!strcmp(res->mask, "coremask")) {
3794 set_fwd_lcores_mask(res->hexavalue);
3796 } else if (!strcmp(res->mask, "portmask")) {
3797 set_fwd_ports_mask(res->hexavalue);
3802 cmdline_parse_token_string_t cmd_setmask_set =
3803 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
3804 cmdline_parse_token_string_t cmd_setmask_mask =
3805 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
3806 "coremask#portmask");
3807 cmdline_parse_token_num_t cmd_setmask_value =
3808 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
3810 cmdline_parse_inst_t cmd_set_fwd_mask = {
3811 .f = cmd_set_mask_parsed,
3813 .help_str = "set coremask|portmask <hexadecimal value>",
3815 (void *)&cmd_setmask_set,
3816 (void *)&cmd_setmask_mask,
3817 (void *)&cmd_setmask_value,
3823 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
3825 struct cmd_set_result {
3826 cmdline_fixed_string_t set;
3827 cmdline_fixed_string_t what;
3831 static void cmd_set_parsed(void *parsed_result,
3832 __rte_unused struct cmdline *cl,
3833 __rte_unused void *data)
3835 struct cmd_set_result *res = parsed_result;
3836 if (!strcmp(res->what, "nbport")) {
3837 set_fwd_ports_number(res->value);
3839 } else if (!strcmp(res->what, "nbcore")) {
3840 set_fwd_lcores_number(res->value);
3842 } else if (!strcmp(res->what, "burst"))
3843 set_nb_pkt_per_burst(res->value);
3844 else if (!strcmp(res->what, "verbose"))
3845 set_verbose_level(res->value);
3848 cmdline_parse_token_string_t cmd_set_set =
3849 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
3850 cmdline_parse_token_string_t cmd_set_what =
3851 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
3852 "nbport#nbcore#burst#verbose");
3853 cmdline_parse_token_num_t cmd_set_value =
3854 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
3856 cmdline_parse_inst_t cmd_set_numbers = {
3857 .f = cmd_set_parsed,
3859 .help_str = "set nbport|nbcore|burst|verbose <value>",
3861 (void *)&cmd_set_set,
3862 (void *)&cmd_set_what,
3863 (void *)&cmd_set_value,
3868 /* *** SET LOG LEVEL CONFIGURATION *** */
3870 struct cmd_set_log_result {
3871 cmdline_fixed_string_t set;
3872 cmdline_fixed_string_t log;
3873 cmdline_fixed_string_t type;
3878 cmd_set_log_parsed(void *parsed_result,
3879 __rte_unused struct cmdline *cl,
3880 __rte_unused void *data)
3882 struct cmd_set_log_result *res;
3885 res = parsed_result;
3886 if (!strcmp(res->type, "global"))
3887 rte_log_set_global_level(res->level);
3889 ret = rte_log_set_level_regexp(res->type, res->level);
3891 printf("Unable to set log level\n");
3895 cmdline_parse_token_string_t cmd_set_log_set =
3896 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, set, "set");
3897 cmdline_parse_token_string_t cmd_set_log_log =
3898 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, log, "log");
3899 cmdline_parse_token_string_t cmd_set_log_type =
3900 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, type, NULL);
3901 cmdline_parse_token_num_t cmd_set_log_level =
3902 TOKEN_NUM_INITIALIZER(struct cmd_set_log_result, level, UINT32);
3904 cmdline_parse_inst_t cmd_set_log = {
3905 .f = cmd_set_log_parsed,
3907 .help_str = "set log global|<type> <level>",
3909 (void *)&cmd_set_log_set,
3910 (void *)&cmd_set_log_log,
3911 (void *)&cmd_set_log_type,
3912 (void *)&cmd_set_log_level,
3917 /* *** SET SEGMENT OFFSETS OF RX PACKETS SPLIT *** */
3919 struct cmd_set_rxoffs_result {
3920 cmdline_fixed_string_t cmd_keyword;
3921 cmdline_fixed_string_t rxoffs;
3922 cmdline_fixed_string_t seg_offsets;
3926 cmd_set_rxoffs_parsed(void *parsed_result,
3927 __rte_unused struct cmdline *cl,
3928 __rte_unused void *data)
3930 struct cmd_set_rxoffs_result *res;
3931 unsigned int seg_offsets[MAX_SEGS_BUFFER_SPLIT];
3932 unsigned int nb_segs;
3934 res = parsed_result;
3935 nb_segs = parse_item_list(res->seg_offsets, "segment offsets",
3936 MAX_SEGS_BUFFER_SPLIT, seg_offsets, 0);
3938 set_rx_pkt_offsets(seg_offsets, nb_segs);
3941 cmdline_parse_token_string_t cmd_set_rxoffs_keyword =
3942 TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
3943 cmd_keyword, "set");
3944 cmdline_parse_token_string_t cmd_set_rxoffs_name =
3945 TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
3947 cmdline_parse_token_string_t cmd_set_rxoffs_offsets =
3948 TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
3951 cmdline_parse_inst_t cmd_set_rxoffs = {
3952 .f = cmd_set_rxoffs_parsed,
3954 .help_str = "set rxoffs <len0[,len1]*>",
3956 (void *)&cmd_set_rxoffs_keyword,
3957 (void *)&cmd_set_rxoffs_name,
3958 (void *)&cmd_set_rxoffs_offsets,
3963 /* *** SET SEGMENT LENGTHS OF RX PACKETS SPLIT *** */
3965 struct cmd_set_rxpkts_result {
3966 cmdline_fixed_string_t cmd_keyword;
3967 cmdline_fixed_string_t rxpkts;
3968 cmdline_fixed_string_t seg_lengths;
3972 cmd_set_rxpkts_parsed(void *parsed_result,
3973 __rte_unused struct cmdline *cl,
3974 __rte_unused void *data)
3976 struct cmd_set_rxpkts_result *res;
3977 unsigned int seg_lengths[MAX_SEGS_BUFFER_SPLIT];
3978 unsigned int nb_segs;
3980 res = parsed_result;
3981 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
3982 MAX_SEGS_BUFFER_SPLIT, seg_lengths, 0);
3984 set_rx_pkt_segments(seg_lengths, nb_segs);
3987 cmdline_parse_token_string_t cmd_set_rxpkts_keyword =
3988 TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
3989 cmd_keyword, "set");
3990 cmdline_parse_token_string_t cmd_set_rxpkts_name =
3991 TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
3993 cmdline_parse_token_string_t cmd_set_rxpkts_lengths =
3994 TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
3997 cmdline_parse_inst_t cmd_set_rxpkts = {
3998 .f = cmd_set_rxpkts_parsed,
4000 .help_str = "set rxpkts <len0[,len1]*>",
4002 (void *)&cmd_set_rxpkts_keyword,
4003 (void *)&cmd_set_rxpkts_name,
4004 (void *)&cmd_set_rxpkts_lengths,
4009 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
4011 struct cmd_set_txpkts_result {
4012 cmdline_fixed_string_t cmd_keyword;
4013 cmdline_fixed_string_t txpkts;
4014 cmdline_fixed_string_t seg_lengths;
4018 cmd_set_txpkts_parsed(void *parsed_result,
4019 __rte_unused struct cmdline *cl,
4020 __rte_unused void *data)
4022 struct cmd_set_txpkts_result *res;
4023 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
4024 unsigned int nb_segs;
4026 res = parsed_result;
4027 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
4028 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
4030 set_tx_pkt_segments(seg_lengths, nb_segs);
4033 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
4034 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
4035 cmd_keyword, "set");
4036 cmdline_parse_token_string_t cmd_set_txpkts_name =
4037 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
4039 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
4040 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
4043 cmdline_parse_inst_t cmd_set_txpkts = {
4044 .f = cmd_set_txpkts_parsed,
4046 .help_str = "set txpkts <len0[,len1]*>",
4048 (void *)&cmd_set_txpkts_keyword,
4049 (void *)&cmd_set_txpkts_name,
4050 (void *)&cmd_set_txpkts_lengths,
4055 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
4057 struct cmd_set_txsplit_result {
4058 cmdline_fixed_string_t cmd_keyword;
4059 cmdline_fixed_string_t txsplit;
4060 cmdline_fixed_string_t mode;
4064 cmd_set_txsplit_parsed(void *parsed_result,
4065 __rte_unused struct cmdline *cl,
4066 __rte_unused void *data)
4068 struct cmd_set_txsplit_result *res;
4070 res = parsed_result;
4071 set_tx_pkt_split(res->mode);
4074 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
4075 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
4076 cmd_keyword, "set");
4077 cmdline_parse_token_string_t cmd_set_txsplit_name =
4078 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
4079 txsplit, "txsplit");
4080 cmdline_parse_token_string_t cmd_set_txsplit_mode =
4081 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
4084 cmdline_parse_inst_t cmd_set_txsplit = {
4085 .f = cmd_set_txsplit_parsed,
4087 .help_str = "set txsplit on|off|rand",
4089 (void *)&cmd_set_txsplit_keyword,
4090 (void *)&cmd_set_txsplit_name,
4091 (void *)&cmd_set_txsplit_mode,
4096 /* *** SET TIMES FOR TXONLY PACKETS SCHEDULING ON TIMESTAMPS *** */
4098 struct cmd_set_txtimes_result {
4099 cmdline_fixed_string_t cmd_keyword;
4100 cmdline_fixed_string_t txtimes;
4101 cmdline_fixed_string_t tx_times;
4105 cmd_set_txtimes_parsed(void *parsed_result,
4106 __rte_unused struct cmdline *cl,
4107 __rte_unused void *data)
4109 struct cmd_set_txtimes_result *res;
4110 unsigned int tx_times[2] = {0, 0};
4111 unsigned int n_times;
4113 res = parsed_result;
4114 n_times = parse_item_list(res->tx_times, "tx times",
4117 set_tx_pkt_times(tx_times);
4120 cmdline_parse_token_string_t cmd_set_txtimes_keyword =
4121 TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
4122 cmd_keyword, "set");
4123 cmdline_parse_token_string_t cmd_set_txtimes_name =
4124 TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
4125 txtimes, "txtimes");
4126 cmdline_parse_token_string_t cmd_set_txtimes_value =
4127 TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
4130 cmdline_parse_inst_t cmd_set_txtimes = {
4131 .f = cmd_set_txtimes_parsed,
4133 .help_str = "set txtimes <inter_burst>,<intra_burst>",
4135 (void *)&cmd_set_txtimes_keyword,
4136 (void *)&cmd_set_txtimes_name,
4137 (void *)&cmd_set_txtimes_value,
4142 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
4143 struct cmd_rx_vlan_filter_all_result {
4144 cmdline_fixed_string_t rx_vlan;
4145 cmdline_fixed_string_t what;
4146 cmdline_fixed_string_t all;
4151 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
4152 __rte_unused struct cmdline *cl,
4153 __rte_unused void *data)
4155 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
4157 if (!strcmp(res->what, "add"))
4158 rx_vlan_all_filter_set(res->port_id, 1);
4160 rx_vlan_all_filter_set(res->port_id, 0);
4163 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
4164 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4165 rx_vlan, "rx_vlan");
4166 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
4167 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4169 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
4170 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4172 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
4173 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4176 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
4177 .f = cmd_rx_vlan_filter_all_parsed,
4179 .help_str = "rx_vlan add|rm all <port_id>: "
4180 "Add/Remove all identifiers to/from the set of VLAN "
4181 "identifiers filtered by a port",
4183 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
4184 (void *)&cmd_rx_vlan_filter_all_what,
4185 (void *)&cmd_rx_vlan_filter_all_all,
4186 (void *)&cmd_rx_vlan_filter_all_portid,
4191 /* *** VLAN OFFLOAD SET ON A PORT *** */
4192 struct cmd_vlan_offload_result {
4193 cmdline_fixed_string_t vlan;
4194 cmdline_fixed_string_t set;
4195 cmdline_fixed_string_t vlan_type;
4196 cmdline_fixed_string_t what;
4197 cmdline_fixed_string_t on;
4198 cmdline_fixed_string_t port_id;
4202 cmd_vlan_offload_parsed(void *parsed_result,
4203 __rte_unused struct cmdline *cl,
4204 __rte_unused void *data)
4207 struct cmd_vlan_offload_result *res = parsed_result;
4210 portid_t port_id = 0;
4214 len = strnlen(str, STR_TOKEN_SIZE);
4216 /* Get port_id first */
4224 tmp = strtoul(str, NULL, 0);
4225 /* If port_id greater that what portid_t can represent, return */
4226 if(tmp >= RTE_MAX_ETHPORTS)
4228 port_id = (portid_t)tmp;
4230 if (!strcmp(res->on, "on"))
4235 if (!strcmp(res->what, "strip"))
4236 rx_vlan_strip_set(port_id, on);
4237 else if(!strcmp(res->what, "stripq")){
4238 uint16_t queue_id = 0;
4240 /* No queue_id, return */
4242 printf("must specify (port,queue_id)\n");
4245 tmp = strtoul(str + i + 1, NULL, 0);
4246 /* If queue_id greater that what 16-bits can represent, return */
4250 queue_id = (uint16_t)tmp;
4251 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
4253 else if (!strcmp(res->what, "filter"))
4254 rx_vlan_filter_set(port_id, on);
4255 else if (!strcmp(res->what, "qinq_strip"))
4256 rx_vlan_qinq_strip_set(port_id, on);
4258 vlan_extend_set(port_id, on);
4263 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
4264 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4266 cmdline_parse_token_string_t cmd_vlan_offload_set =
4267 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4269 cmdline_parse_token_string_t cmd_vlan_offload_what =
4270 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4271 what, "strip#filter#qinq_strip#extend#stripq");
4272 cmdline_parse_token_string_t cmd_vlan_offload_on =
4273 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4275 cmdline_parse_token_string_t cmd_vlan_offload_portid =
4276 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4279 cmdline_parse_inst_t cmd_vlan_offload = {
4280 .f = cmd_vlan_offload_parsed,
4282 .help_str = "vlan set strip|filter|qinq_strip|extend|stripq on|off "
4283 "<port_id[,queue_id]>: "
4284 "Strip/Filter/QinQ for rx side Extend for both rx/tx sides",
4286 (void *)&cmd_vlan_offload_vlan,
4287 (void *)&cmd_vlan_offload_set,
4288 (void *)&cmd_vlan_offload_what,
4289 (void *)&cmd_vlan_offload_on,
4290 (void *)&cmd_vlan_offload_portid,
4295 /* *** VLAN TPID SET ON A PORT *** */
4296 struct cmd_vlan_tpid_result {
4297 cmdline_fixed_string_t vlan;
4298 cmdline_fixed_string_t set;
4299 cmdline_fixed_string_t vlan_type;
4300 cmdline_fixed_string_t what;
4306 cmd_vlan_tpid_parsed(void *parsed_result,
4307 __rte_unused struct cmdline *cl,
4308 __rte_unused void *data)
4310 struct cmd_vlan_tpid_result *res = parsed_result;
4311 enum rte_vlan_type vlan_type;
4313 if (!strcmp(res->vlan_type, "inner"))
4314 vlan_type = ETH_VLAN_TYPE_INNER;
4315 else if (!strcmp(res->vlan_type, "outer"))
4316 vlan_type = ETH_VLAN_TYPE_OUTER;
4318 printf("Unknown vlan type\n");
4321 vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
4324 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
4325 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4327 cmdline_parse_token_string_t cmd_vlan_tpid_set =
4328 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4330 cmdline_parse_token_string_t cmd_vlan_type =
4331 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4332 vlan_type, "inner#outer");
4333 cmdline_parse_token_string_t cmd_vlan_tpid_what =
4334 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4336 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
4337 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4339 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
4340 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4343 cmdline_parse_inst_t cmd_vlan_tpid = {
4344 .f = cmd_vlan_tpid_parsed,
4346 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
4347 "Set the VLAN Ether type",
4349 (void *)&cmd_vlan_tpid_vlan,
4350 (void *)&cmd_vlan_tpid_set,
4351 (void *)&cmd_vlan_type,
4352 (void *)&cmd_vlan_tpid_what,
4353 (void *)&cmd_vlan_tpid_tpid,
4354 (void *)&cmd_vlan_tpid_portid,
4359 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
4360 struct cmd_rx_vlan_filter_result {
4361 cmdline_fixed_string_t rx_vlan;
4362 cmdline_fixed_string_t what;
4368 cmd_rx_vlan_filter_parsed(void *parsed_result,
4369 __rte_unused struct cmdline *cl,
4370 __rte_unused void *data)
4372 struct cmd_rx_vlan_filter_result *res = parsed_result;
4374 if (!strcmp(res->what, "add"))
4375 rx_vft_set(res->port_id, res->vlan_id, 1);
4377 rx_vft_set(res->port_id, res->vlan_id, 0);
4380 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
4381 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4382 rx_vlan, "rx_vlan");
4383 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
4384 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4386 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
4387 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4389 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
4390 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4393 cmdline_parse_inst_t cmd_rx_vlan_filter = {
4394 .f = cmd_rx_vlan_filter_parsed,
4396 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
4397 "Add/Remove a VLAN identifier to/from the set of VLAN "
4398 "identifiers filtered by a port",
4400 (void *)&cmd_rx_vlan_filter_rx_vlan,
4401 (void *)&cmd_rx_vlan_filter_what,
4402 (void *)&cmd_rx_vlan_filter_vlanid,
4403 (void *)&cmd_rx_vlan_filter_portid,
4408 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4409 struct cmd_tx_vlan_set_result {
4410 cmdline_fixed_string_t tx_vlan;
4411 cmdline_fixed_string_t set;
4417 cmd_tx_vlan_set_parsed(void *parsed_result,
4418 __rte_unused struct cmdline *cl,
4419 __rte_unused void *data)
4421 struct cmd_tx_vlan_set_result *res = parsed_result;
4423 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4426 if (!port_is_stopped(res->port_id)) {
4427 printf("Please stop port %d first\n", res->port_id);
4431 tx_vlan_set(res->port_id, res->vlan_id);
4433 cmd_reconfig_device_queue(res->port_id, 1, 1);
4436 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
4437 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4438 tx_vlan, "tx_vlan");
4439 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
4440 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4442 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
4443 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4445 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
4446 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4449 cmdline_parse_inst_t cmd_tx_vlan_set = {
4450 .f = cmd_tx_vlan_set_parsed,
4452 .help_str = "tx_vlan set <port_id> <vlan_id>: "
4453 "Enable hardware insertion of a single VLAN header "
4454 "with a given TAG Identifier in packets sent on a port",
4456 (void *)&cmd_tx_vlan_set_tx_vlan,
4457 (void *)&cmd_tx_vlan_set_set,
4458 (void *)&cmd_tx_vlan_set_portid,
4459 (void *)&cmd_tx_vlan_set_vlanid,
4464 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
4465 struct cmd_tx_vlan_set_qinq_result {
4466 cmdline_fixed_string_t tx_vlan;
4467 cmdline_fixed_string_t set;
4470 uint16_t vlan_id_outer;
4474 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
4475 __rte_unused struct cmdline *cl,
4476 __rte_unused void *data)
4478 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
4480 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4483 if (!port_is_stopped(res->port_id)) {
4484 printf("Please stop port %d first\n", res->port_id);
4488 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
4490 cmd_reconfig_device_queue(res->port_id, 1, 1);
4493 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
4494 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4495 tx_vlan, "tx_vlan");
4496 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
4497 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4499 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
4500 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4502 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
4503 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4505 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
4506 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4507 vlan_id_outer, UINT16);
4509 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
4510 .f = cmd_tx_vlan_set_qinq_parsed,
4512 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
4513 "Enable hardware insertion of double VLAN header "
4514 "with given TAG Identifiers in packets sent on a port",
4516 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
4517 (void *)&cmd_tx_vlan_set_qinq_set,
4518 (void *)&cmd_tx_vlan_set_qinq_portid,
4519 (void *)&cmd_tx_vlan_set_qinq_vlanid,
4520 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
4525 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
4526 struct cmd_tx_vlan_set_pvid_result {
4527 cmdline_fixed_string_t tx_vlan;
4528 cmdline_fixed_string_t set;
4529 cmdline_fixed_string_t pvid;
4532 cmdline_fixed_string_t mode;
4536 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
4537 __rte_unused struct cmdline *cl,
4538 __rte_unused void *data)
4540 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
4542 if (strcmp(res->mode, "on") == 0)
4543 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
4545 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
4548 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
4549 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4550 tx_vlan, "tx_vlan");
4551 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
4552 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4554 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
4555 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4557 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
4558 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4560 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
4561 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4563 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
4564 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4567 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
4568 .f = cmd_tx_vlan_set_pvid_parsed,
4570 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
4572 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
4573 (void *)&cmd_tx_vlan_set_pvid_set,
4574 (void *)&cmd_tx_vlan_set_pvid_pvid,
4575 (void *)&cmd_tx_vlan_set_pvid_port_id,
4576 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
4577 (void *)&cmd_tx_vlan_set_pvid_mode,
4582 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4583 struct cmd_tx_vlan_reset_result {
4584 cmdline_fixed_string_t tx_vlan;
4585 cmdline_fixed_string_t reset;
4590 cmd_tx_vlan_reset_parsed(void *parsed_result,
4591 __rte_unused struct cmdline *cl,
4592 __rte_unused void *data)
4594 struct cmd_tx_vlan_reset_result *res = parsed_result;
4596 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4599 if (!port_is_stopped(res->port_id)) {
4600 printf("Please stop port %d first\n", res->port_id);
4604 tx_vlan_reset(res->port_id);
4606 cmd_reconfig_device_queue(res->port_id, 1, 1);
4609 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
4610 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4611 tx_vlan, "tx_vlan");
4612 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
4613 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4615 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
4616 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
4619 cmdline_parse_inst_t cmd_tx_vlan_reset = {
4620 .f = cmd_tx_vlan_reset_parsed,
4622 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
4623 "VLAN header in packets sent on a port",
4625 (void *)&cmd_tx_vlan_reset_tx_vlan,
4626 (void *)&cmd_tx_vlan_reset_reset,
4627 (void *)&cmd_tx_vlan_reset_portid,
4633 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
4634 struct cmd_csum_result {
4635 cmdline_fixed_string_t csum;
4636 cmdline_fixed_string_t mode;
4637 cmdline_fixed_string_t proto;
4638 cmdline_fixed_string_t hwsw;
4643 csum_show(int port_id)
4645 struct rte_eth_dev_info dev_info;
4646 uint64_t tx_offloads;
4649 tx_offloads = ports[port_id].dev_conf.txmode.offloads;
4650 printf("Parse tunnel is %s\n",
4651 (ports[port_id].parse_tunnel) ? "on" : "off");
4652 printf("IP checksum offload is %s\n",
4653 (tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) ? "hw" : "sw");
4654 printf("UDP checksum offload is %s\n",
4655 (tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
4656 printf("TCP checksum offload is %s\n",
4657 (tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
4658 printf("SCTP checksum offload is %s\n",
4659 (tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
4660 printf("Outer-Ip checksum offload is %s\n",
4661 (tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) ? "hw" : "sw");
4662 printf("Outer-Udp checksum offload is %s\n",
4663 (tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) ? "hw" : "sw");
4665 /* display warnings if configuration is not supported by the NIC */
4666 ret = eth_dev_info_get_print_err(port_id, &dev_info);
4670 if ((tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) &&
4671 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
4672 printf("Warning: hardware IP checksum enabled but not "
4673 "supported by port %d\n", port_id);
4675 if ((tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) &&
4676 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
4677 printf("Warning: hardware UDP checksum enabled but not "
4678 "supported by port %d\n", port_id);
4680 if ((tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) &&
4681 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
4682 printf("Warning: hardware TCP checksum enabled but not "
4683 "supported by port %d\n", port_id);
4685 if ((tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) &&
4686 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
4687 printf("Warning: hardware SCTP checksum enabled but not "
4688 "supported by port %d\n", port_id);
4690 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) &&
4691 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
4692 printf("Warning: hardware outer IP checksum enabled but not "
4693 "supported by port %d\n", port_id);
4695 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) &&
4696 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)
4698 printf("Warning: hardware outer UDP checksum enabled but not "
4699 "supported by port %d\n", port_id);
4704 cmd_config_queue_tx_offloads(struct rte_port *port)
4708 /* Apply queue tx offloads configuration */
4709 for (k = 0; k < port->dev_info.max_rx_queues; k++)
4710 port->tx_conf[k].offloads =
4711 port->dev_conf.txmode.offloads;
4715 cmd_csum_parsed(void *parsed_result,
4716 __rte_unused struct cmdline *cl,
4717 __rte_unused void *data)
4719 struct cmd_csum_result *res = parsed_result;
4721 uint64_t csum_offloads = 0;
4722 struct rte_eth_dev_info dev_info;
4725 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
4726 printf("invalid port %d\n", res->port_id);
4729 if (!port_is_stopped(res->port_id)) {
4730 printf("Please stop port %d first\n", res->port_id);
4734 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4738 if (!strcmp(res->mode, "set")) {
4740 if (!strcmp(res->hwsw, "hw"))
4743 if (!strcmp(res->proto, "ip")) {
4744 if (hw == 0 || (dev_info.tx_offload_capa &
4745 DEV_TX_OFFLOAD_IPV4_CKSUM)) {
4746 csum_offloads |= DEV_TX_OFFLOAD_IPV4_CKSUM;
4748 printf("IP checksum offload is not supported "
4749 "by port %u\n", res->port_id);
4751 } else if (!strcmp(res->proto, "udp")) {
4752 if (hw == 0 || (dev_info.tx_offload_capa &
4753 DEV_TX_OFFLOAD_UDP_CKSUM)) {
4754 csum_offloads |= DEV_TX_OFFLOAD_UDP_CKSUM;
4756 printf("UDP checksum offload is not supported "
4757 "by port %u\n", res->port_id);
4759 } else if (!strcmp(res->proto, "tcp")) {
4760 if (hw == 0 || (dev_info.tx_offload_capa &
4761 DEV_TX_OFFLOAD_TCP_CKSUM)) {
4762 csum_offloads |= DEV_TX_OFFLOAD_TCP_CKSUM;
4764 printf("TCP checksum offload is not supported "
4765 "by port %u\n", res->port_id);
4767 } else if (!strcmp(res->proto, "sctp")) {
4768 if (hw == 0 || (dev_info.tx_offload_capa &
4769 DEV_TX_OFFLOAD_SCTP_CKSUM)) {
4770 csum_offloads |= DEV_TX_OFFLOAD_SCTP_CKSUM;
4772 printf("SCTP checksum offload is not supported "
4773 "by port %u\n", res->port_id);
4775 } else if (!strcmp(res->proto, "outer-ip")) {
4776 if (hw == 0 || (dev_info.tx_offload_capa &
4777 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM)) {
4779 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM;
4781 printf("Outer IP checksum offload is not "
4782 "supported by port %u\n", res->port_id);
4784 } else if (!strcmp(res->proto, "outer-udp")) {
4785 if (hw == 0 || (dev_info.tx_offload_capa &
4786 DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)) {
4788 DEV_TX_OFFLOAD_OUTER_UDP_CKSUM;
4790 printf("Outer UDP checksum offload is not "
4791 "supported by port %u\n", res->port_id);
4796 ports[res->port_id].dev_conf.txmode.offloads |=
4799 ports[res->port_id].dev_conf.txmode.offloads &=
4802 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4804 csum_show(res->port_id);
4806 cmd_reconfig_device_queue(res->port_id, 1, 1);
4809 cmdline_parse_token_string_t cmd_csum_csum =
4810 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4812 cmdline_parse_token_string_t cmd_csum_mode =
4813 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4815 cmdline_parse_token_string_t cmd_csum_proto =
4816 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4817 proto, "ip#tcp#udp#sctp#outer-ip#outer-udp");
4818 cmdline_parse_token_string_t cmd_csum_hwsw =
4819 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4821 cmdline_parse_token_num_t cmd_csum_portid =
4822 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
4825 cmdline_parse_inst_t cmd_csum_set = {
4826 .f = cmd_csum_parsed,
4828 .help_str = "csum set ip|tcp|udp|sctp|outer-ip|outer-udp hw|sw <port_id>: "
4829 "Enable/Disable hardware calculation of L3/L4 checksum when "
4830 "using csum forward engine",
4832 (void *)&cmd_csum_csum,
4833 (void *)&cmd_csum_mode,
4834 (void *)&cmd_csum_proto,
4835 (void *)&cmd_csum_hwsw,
4836 (void *)&cmd_csum_portid,
4841 cmdline_parse_token_string_t cmd_csum_mode_show =
4842 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4845 cmdline_parse_inst_t cmd_csum_show = {
4846 .f = cmd_csum_parsed,
4848 .help_str = "csum show <port_id>: Show checksum offload configuration",
4850 (void *)&cmd_csum_csum,
4851 (void *)&cmd_csum_mode_show,
4852 (void *)&cmd_csum_portid,
4857 /* Enable/disable tunnel parsing */
4858 struct cmd_csum_tunnel_result {
4859 cmdline_fixed_string_t csum;
4860 cmdline_fixed_string_t parse;
4861 cmdline_fixed_string_t onoff;
4866 cmd_csum_tunnel_parsed(void *parsed_result,
4867 __rte_unused struct cmdline *cl,
4868 __rte_unused void *data)
4870 struct cmd_csum_tunnel_result *res = parsed_result;
4872 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4875 if (!strcmp(res->onoff, "on"))
4876 ports[res->port_id].parse_tunnel = 1;
4878 ports[res->port_id].parse_tunnel = 0;
4880 csum_show(res->port_id);
4883 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
4884 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4886 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
4887 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4888 parse, "parse-tunnel");
4889 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
4890 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4892 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
4893 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
4896 cmdline_parse_inst_t cmd_csum_tunnel = {
4897 .f = cmd_csum_tunnel_parsed,
4899 .help_str = "csum parse-tunnel on|off <port_id>: "
4900 "Enable/Disable parsing of tunnels for csum engine",
4902 (void *)&cmd_csum_tunnel_csum,
4903 (void *)&cmd_csum_tunnel_parse,
4904 (void *)&cmd_csum_tunnel_onoff,
4905 (void *)&cmd_csum_tunnel_portid,
4910 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
4911 struct cmd_tso_set_result {
4912 cmdline_fixed_string_t tso;
4913 cmdline_fixed_string_t mode;
4919 cmd_tso_set_parsed(void *parsed_result,
4920 __rte_unused struct cmdline *cl,
4921 __rte_unused void *data)
4923 struct cmd_tso_set_result *res = parsed_result;
4924 struct rte_eth_dev_info dev_info;
4927 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4929 if (!port_is_stopped(res->port_id)) {
4930 printf("Please stop port %d first\n", res->port_id);
4934 if (!strcmp(res->mode, "set"))
4935 ports[res->port_id].tso_segsz = res->tso_segsz;
4937 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4941 if ((ports[res->port_id].tso_segsz != 0) &&
4942 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4943 printf("Error: TSO is not supported by port %d\n",
4948 if (ports[res->port_id].tso_segsz == 0) {
4949 ports[res->port_id].dev_conf.txmode.offloads &=
4950 ~DEV_TX_OFFLOAD_TCP_TSO;
4951 printf("TSO for non-tunneled packets is disabled\n");
4953 ports[res->port_id].dev_conf.txmode.offloads |=
4954 DEV_TX_OFFLOAD_TCP_TSO;
4955 printf("TSO segment size for non-tunneled packets is %d\n",
4956 ports[res->port_id].tso_segsz);
4958 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4960 /* display warnings if configuration is not supported by the NIC */
4961 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4965 if ((ports[res->port_id].tso_segsz != 0) &&
4966 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4967 printf("Warning: TSO enabled but not "
4968 "supported by port %d\n", res->port_id);
4971 cmd_reconfig_device_queue(res->port_id, 1, 1);
4974 cmdline_parse_token_string_t cmd_tso_set_tso =
4975 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4977 cmdline_parse_token_string_t cmd_tso_set_mode =
4978 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4980 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
4981 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4983 cmdline_parse_token_num_t cmd_tso_set_portid =
4984 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4987 cmdline_parse_inst_t cmd_tso_set = {
4988 .f = cmd_tso_set_parsed,
4990 .help_str = "tso set <tso_segsz> <port_id>: "
4991 "Set TSO segment size of non-tunneled packets for csum engine "
4994 (void *)&cmd_tso_set_tso,
4995 (void *)&cmd_tso_set_mode,
4996 (void *)&cmd_tso_set_tso_segsz,
4997 (void *)&cmd_tso_set_portid,
5002 cmdline_parse_token_string_t cmd_tso_show_mode =
5003 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
5007 cmdline_parse_inst_t cmd_tso_show = {
5008 .f = cmd_tso_set_parsed,
5010 .help_str = "tso show <port_id>: "
5011 "Show TSO segment size of non-tunneled packets for csum engine",
5013 (void *)&cmd_tso_set_tso,
5014 (void *)&cmd_tso_show_mode,
5015 (void *)&cmd_tso_set_portid,
5020 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
5021 struct cmd_tunnel_tso_set_result {
5022 cmdline_fixed_string_t tso;
5023 cmdline_fixed_string_t mode;
5028 static struct rte_eth_dev_info
5029 check_tunnel_tso_nic_support(portid_t port_id)
5031 struct rte_eth_dev_info dev_info;
5033 if (eth_dev_info_get_print_err(port_id, &dev_info) != 0)
5036 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO))
5037 printf("Warning: VXLAN TUNNEL TSO not supported therefore "
5038 "not enabled for port %d\n", port_id);
5039 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO))
5040 printf("Warning: GRE TUNNEL TSO not supported therefore "
5041 "not enabled for port %d\n", port_id);
5042 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO))
5043 printf("Warning: IPIP TUNNEL TSO not supported therefore "
5044 "not enabled for port %d\n", port_id);
5045 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
5046 printf("Warning: GENEVE TUNNEL TSO not supported therefore "
5047 "not enabled for port %d\n", port_id);
5048 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IP_TNL_TSO))
5049 printf("Warning: IP TUNNEL TSO not supported therefore "
5050 "not enabled for port %d\n", port_id);
5051 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_TNL_TSO))
5052 printf("Warning: UDP TUNNEL TSO not supported therefore "
5053 "not enabled for port %d\n", port_id);
5058 cmd_tunnel_tso_set_parsed(void *parsed_result,
5059 __rte_unused struct cmdline *cl,
5060 __rte_unused void *data)
5062 struct cmd_tunnel_tso_set_result *res = parsed_result;
5063 struct rte_eth_dev_info dev_info;
5065 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
5067 if (!port_is_stopped(res->port_id)) {
5068 printf("Please stop port %d first\n", res->port_id);
5072 if (!strcmp(res->mode, "set"))
5073 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
5075 dev_info = check_tunnel_tso_nic_support(res->port_id);
5076 if (ports[res->port_id].tunnel_tso_segsz == 0) {
5077 ports[res->port_id].dev_conf.txmode.offloads &=
5078 ~(DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
5079 DEV_TX_OFFLOAD_GRE_TNL_TSO |
5080 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
5081 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
5082 DEV_TX_OFFLOAD_IP_TNL_TSO |
5083 DEV_TX_OFFLOAD_UDP_TNL_TSO);
5084 printf("TSO for tunneled packets is disabled\n");
5086 uint64_t tso_offloads = (DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
5087 DEV_TX_OFFLOAD_GRE_TNL_TSO |
5088 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
5089 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
5090 DEV_TX_OFFLOAD_IP_TNL_TSO |
5091 DEV_TX_OFFLOAD_UDP_TNL_TSO);
5093 ports[res->port_id].dev_conf.txmode.offloads |=
5094 (tso_offloads & dev_info.tx_offload_capa);
5095 printf("TSO segment size for tunneled packets is %d\n",
5096 ports[res->port_id].tunnel_tso_segsz);
5098 /* Below conditions are needed to make it work:
5099 * (1) tunnel TSO is supported by the NIC;
5100 * (2) "csum parse_tunnel" must be set so that tunneled pkts
5102 * (3) for tunneled pkts with outer L3 of IPv4,
5103 * "csum set outer-ip" must be set to hw, because after tso,
5104 * total_len of outer IP header is changed, and the checksum
5105 * of outer IP header calculated by sw should be wrong; that
5106 * is not necessary for IPv6 tunneled pkts because there's no
5107 * checksum in IP header anymore.
5110 if (!ports[res->port_id].parse_tunnel)
5111 printf("Warning: csum parse_tunnel must be set "
5112 "so that tunneled packets are recognized\n");
5113 if (!(ports[res->port_id].dev_conf.txmode.offloads &
5114 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM))
5115 printf("Warning: csum set outer-ip must be set to hw "
5116 "if outer L3 is IPv4; not necessary for IPv6\n");
5119 cmd_config_queue_tx_offloads(&ports[res->port_id]);
5120 cmd_reconfig_device_queue(res->port_id, 1, 1);
5123 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
5124 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
5126 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
5127 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
5129 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
5130 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
5132 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
5133 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
5136 cmdline_parse_inst_t cmd_tunnel_tso_set = {
5137 .f = cmd_tunnel_tso_set_parsed,
5139 .help_str = "tunnel_tso set <tso_segsz> <port_id>: "
5140 "Set TSO segment size of tunneled packets for csum engine "
5143 (void *)&cmd_tunnel_tso_set_tso,
5144 (void *)&cmd_tunnel_tso_set_mode,
5145 (void *)&cmd_tunnel_tso_set_tso_segsz,
5146 (void *)&cmd_tunnel_tso_set_portid,
5151 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
5152 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
5156 cmdline_parse_inst_t cmd_tunnel_tso_show = {
5157 .f = cmd_tunnel_tso_set_parsed,
5159 .help_str = "tunnel_tso show <port_id> "
5160 "Show TSO segment size of tunneled packets for csum engine",
5162 (void *)&cmd_tunnel_tso_set_tso,
5163 (void *)&cmd_tunnel_tso_show_mode,
5164 (void *)&cmd_tunnel_tso_set_portid,
5169 /* *** SET GRO FOR A PORT *** */
5170 struct cmd_gro_enable_result {
5171 cmdline_fixed_string_t cmd_set;
5172 cmdline_fixed_string_t cmd_port;
5173 cmdline_fixed_string_t cmd_keyword;
5174 cmdline_fixed_string_t cmd_onoff;
5179 cmd_gro_enable_parsed(void *parsed_result,
5180 __rte_unused struct cmdline *cl,
5181 __rte_unused void *data)
5183 struct cmd_gro_enable_result *res;
5185 res = parsed_result;
5186 if (!strcmp(res->cmd_keyword, "gro"))
5187 setup_gro(res->cmd_onoff, res->cmd_pid);
5190 cmdline_parse_token_string_t cmd_gro_enable_set =
5191 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5193 cmdline_parse_token_string_t cmd_gro_enable_port =
5194 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5195 cmd_keyword, "port");
5196 cmdline_parse_token_num_t cmd_gro_enable_pid =
5197 TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result,
5199 cmdline_parse_token_string_t cmd_gro_enable_keyword =
5200 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5201 cmd_keyword, "gro");
5202 cmdline_parse_token_string_t cmd_gro_enable_onoff =
5203 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5204 cmd_onoff, "on#off");
5206 cmdline_parse_inst_t cmd_gro_enable = {
5207 .f = cmd_gro_enable_parsed,
5209 .help_str = "set port <port_id> gro on|off",
5211 (void *)&cmd_gro_enable_set,
5212 (void *)&cmd_gro_enable_port,
5213 (void *)&cmd_gro_enable_pid,
5214 (void *)&cmd_gro_enable_keyword,
5215 (void *)&cmd_gro_enable_onoff,
5220 /* *** DISPLAY GRO CONFIGURATION *** */
5221 struct cmd_gro_show_result {
5222 cmdline_fixed_string_t cmd_show;
5223 cmdline_fixed_string_t cmd_port;
5224 cmdline_fixed_string_t cmd_keyword;
5229 cmd_gro_show_parsed(void *parsed_result,
5230 __rte_unused struct cmdline *cl,
5231 __rte_unused void *data)
5233 struct cmd_gro_show_result *res;
5235 res = parsed_result;
5236 if (!strcmp(res->cmd_keyword, "gro"))
5237 show_gro(res->cmd_pid);
5240 cmdline_parse_token_string_t cmd_gro_show_show =
5241 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5243 cmdline_parse_token_string_t cmd_gro_show_port =
5244 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5246 cmdline_parse_token_num_t cmd_gro_show_pid =
5247 TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result,
5249 cmdline_parse_token_string_t cmd_gro_show_keyword =
5250 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5251 cmd_keyword, "gro");
5253 cmdline_parse_inst_t cmd_gro_show = {
5254 .f = cmd_gro_show_parsed,
5256 .help_str = "show port <port_id> gro",
5258 (void *)&cmd_gro_show_show,
5259 (void *)&cmd_gro_show_port,
5260 (void *)&cmd_gro_show_pid,
5261 (void *)&cmd_gro_show_keyword,
5266 /* *** SET FLUSH CYCLES FOR GRO *** */
5267 struct cmd_gro_flush_result {
5268 cmdline_fixed_string_t cmd_set;
5269 cmdline_fixed_string_t cmd_keyword;
5270 cmdline_fixed_string_t cmd_flush;
5275 cmd_gro_flush_parsed(void *parsed_result,
5276 __rte_unused struct cmdline *cl,
5277 __rte_unused void *data)
5279 struct cmd_gro_flush_result *res;
5281 res = parsed_result;
5282 if ((!strcmp(res->cmd_keyword, "gro")) &&
5283 (!strcmp(res->cmd_flush, "flush")))
5284 setup_gro_flush_cycles(res->cmd_cycles);
5287 cmdline_parse_token_string_t cmd_gro_flush_set =
5288 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5290 cmdline_parse_token_string_t cmd_gro_flush_keyword =
5291 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5292 cmd_keyword, "gro");
5293 cmdline_parse_token_string_t cmd_gro_flush_flush =
5294 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5295 cmd_flush, "flush");
5296 cmdline_parse_token_num_t cmd_gro_flush_cycles =
5297 TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result,
5300 cmdline_parse_inst_t cmd_gro_flush = {
5301 .f = cmd_gro_flush_parsed,
5303 .help_str = "set gro flush <cycles>",
5305 (void *)&cmd_gro_flush_set,
5306 (void *)&cmd_gro_flush_keyword,
5307 (void *)&cmd_gro_flush_flush,
5308 (void *)&cmd_gro_flush_cycles,
5313 /* *** ENABLE/DISABLE GSO *** */
5314 struct cmd_gso_enable_result {
5315 cmdline_fixed_string_t cmd_set;
5316 cmdline_fixed_string_t cmd_port;
5317 cmdline_fixed_string_t cmd_keyword;
5318 cmdline_fixed_string_t cmd_mode;
5323 cmd_gso_enable_parsed(void *parsed_result,
5324 __rte_unused struct cmdline *cl,
5325 __rte_unused void *data)
5327 struct cmd_gso_enable_result *res;
5329 res = parsed_result;
5330 if (!strcmp(res->cmd_keyword, "gso"))
5331 setup_gso(res->cmd_mode, res->cmd_pid);
5334 cmdline_parse_token_string_t cmd_gso_enable_set =
5335 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5337 cmdline_parse_token_string_t cmd_gso_enable_port =
5338 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5340 cmdline_parse_token_string_t cmd_gso_enable_keyword =
5341 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5342 cmd_keyword, "gso");
5343 cmdline_parse_token_string_t cmd_gso_enable_mode =
5344 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5345 cmd_mode, "on#off");
5346 cmdline_parse_token_num_t cmd_gso_enable_pid =
5347 TOKEN_NUM_INITIALIZER(struct cmd_gso_enable_result,
5350 cmdline_parse_inst_t cmd_gso_enable = {
5351 .f = cmd_gso_enable_parsed,
5353 .help_str = "set port <port_id> gso on|off",
5355 (void *)&cmd_gso_enable_set,
5356 (void *)&cmd_gso_enable_port,
5357 (void *)&cmd_gso_enable_pid,
5358 (void *)&cmd_gso_enable_keyword,
5359 (void *)&cmd_gso_enable_mode,
5364 /* *** SET MAX PACKET LENGTH FOR GSO SEGMENTS *** */
5365 struct cmd_gso_size_result {
5366 cmdline_fixed_string_t cmd_set;
5367 cmdline_fixed_string_t cmd_keyword;
5368 cmdline_fixed_string_t cmd_segsz;
5373 cmd_gso_size_parsed(void *parsed_result,
5374 __rte_unused struct cmdline *cl,
5375 __rte_unused void *data)
5377 struct cmd_gso_size_result *res = parsed_result;
5379 if (test_done == 0) {
5380 printf("Before setting GSO segsz, please first"
5381 " stop forwarding\n");
5385 if (!strcmp(res->cmd_keyword, "gso") &&
5386 !strcmp(res->cmd_segsz, "segsz")) {
5387 if (res->cmd_size < RTE_GSO_SEG_SIZE_MIN)
5388 printf("gso_size should be larger than %zu."
5389 " Please input a legal value\n",
5390 RTE_GSO_SEG_SIZE_MIN);
5392 gso_max_segment_size = res->cmd_size;
5396 cmdline_parse_token_string_t cmd_gso_size_set =
5397 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5399 cmdline_parse_token_string_t cmd_gso_size_keyword =
5400 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5401 cmd_keyword, "gso");
5402 cmdline_parse_token_string_t cmd_gso_size_segsz =
5403 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5404 cmd_segsz, "segsz");
5405 cmdline_parse_token_num_t cmd_gso_size_size =
5406 TOKEN_NUM_INITIALIZER(struct cmd_gso_size_result,
5409 cmdline_parse_inst_t cmd_gso_size = {
5410 .f = cmd_gso_size_parsed,
5412 .help_str = "set gso segsz <length>",
5414 (void *)&cmd_gso_size_set,
5415 (void *)&cmd_gso_size_keyword,
5416 (void *)&cmd_gso_size_segsz,
5417 (void *)&cmd_gso_size_size,
5422 /* *** SHOW GSO CONFIGURATION *** */
5423 struct cmd_gso_show_result {
5424 cmdline_fixed_string_t cmd_show;
5425 cmdline_fixed_string_t cmd_port;
5426 cmdline_fixed_string_t cmd_keyword;
5431 cmd_gso_show_parsed(void *parsed_result,
5432 __rte_unused struct cmdline *cl,
5433 __rte_unused void *data)
5435 struct cmd_gso_show_result *res = parsed_result;
5437 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
5438 printf("invalid port id %u\n", res->cmd_pid);
5441 if (!strcmp(res->cmd_keyword, "gso")) {
5442 if (gso_ports[res->cmd_pid].enable) {
5443 printf("Max GSO'd packet size: %uB\n"
5444 "Supported GSO types: TCP/IPv4, "
5445 "UDP/IPv4, VxLAN with inner "
5446 "TCP/IPv4 packet, GRE with inner "
5447 "TCP/IPv4 packet\n",
5448 gso_max_segment_size);
5450 printf("GSO is not enabled on Port %u\n", res->cmd_pid);
5454 cmdline_parse_token_string_t cmd_gso_show_show =
5455 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5457 cmdline_parse_token_string_t cmd_gso_show_port =
5458 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5460 cmdline_parse_token_string_t cmd_gso_show_keyword =
5461 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5462 cmd_keyword, "gso");
5463 cmdline_parse_token_num_t cmd_gso_show_pid =
5464 TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result,
5467 cmdline_parse_inst_t cmd_gso_show = {
5468 .f = cmd_gso_show_parsed,
5470 .help_str = "show port <port_id> gso",
5472 (void *)&cmd_gso_show_show,
5473 (void *)&cmd_gso_show_port,
5474 (void *)&cmd_gso_show_pid,
5475 (void *)&cmd_gso_show_keyword,
5480 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
5481 struct cmd_set_flush_rx {
5482 cmdline_fixed_string_t set;
5483 cmdline_fixed_string_t flush_rx;
5484 cmdline_fixed_string_t mode;
5488 cmd_set_flush_rx_parsed(void *parsed_result,
5489 __rte_unused struct cmdline *cl,
5490 __rte_unused void *data)
5492 struct cmd_set_flush_rx *res = parsed_result;
5493 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5496 cmdline_parse_token_string_t cmd_setflushrx_set =
5497 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5499 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
5500 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5501 flush_rx, "flush_rx");
5502 cmdline_parse_token_string_t cmd_setflushrx_mode =
5503 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5507 cmdline_parse_inst_t cmd_set_flush_rx = {
5508 .f = cmd_set_flush_rx_parsed,
5509 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
5512 (void *)&cmd_setflushrx_set,
5513 (void *)&cmd_setflushrx_flush_rx,
5514 (void *)&cmd_setflushrx_mode,
5519 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
5520 struct cmd_set_link_check {
5521 cmdline_fixed_string_t set;
5522 cmdline_fixed_string_t link_check;
5523 cmdline_fixed_string_t mode;
5527 cmd_set_link_check_parsed(void *parsed_result,
5528 __rte_unused struct cmdline *cl,
5529 __rte_unused void *data)
5531 struct cmd_set_link_check *res = parsed_result;
5532 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5535 cmdline_parse_token_string_t cmd_setlinkcheck_set =
5536 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5538 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
5539 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5540 link_check, "link_check");
5541 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
5542 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5546 cmdline_parse_inst_t cmd_set_link_check = {
5547 .f = cmd_set_link_check_parsed,
5548 .help_str = "set link_check on|off: Enable/Disable link status check "
5549 "when starting/stopping a port",
5552 (void *)&cmd_setlinkcheck_set,
5553 (void *)&cmd_setlinkcheck_link_check,
5554 (void *)&cmd_setlinkcheck_mode,
5559 /* *** SET NIC BYPASS MODE *** */
5560 struct cmd_set_bypass_mode_result {
5561 cmdline_fixed_string_t set;
5562 cmdline_fixed_string_t bypass;
5563 cmdline_fixed_string_t mode;
5564 cmdline_fixed_string_t value;
5569 cmd_set_bypass_mode_parsed(void *parsed_result,
5570 __rte_unused struct cmdline *cl,
5571 __rte_unused void *data)
5573 struct cmd_set_bypass_mode_result *res = parsed_result;
5574 portid_t port_id = res->port_id;
5575 int32_t rc = -EINVAL;
5577 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5578 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5580 if (!strcmp(res->value, "bypass"))
5581 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5582 else if (!strcmp(res->value, "isolate"))
5583 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5585 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5587 /* Set the bypass mode for the relevant port. */
5588 rc = rte_pmd_ixgbe_bypass_state_set(port_id, &bypass_mode);
5591 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
5594 cmdline_parse_token_string_t cmd_setbypass_mode_set =
5595 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5597 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
5598 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5600 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
5601 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5603 cmdline_parse_token_string_t cmd_setbypass_mode_value =
5604 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5605 value, "normal#bypass#isolate");
5606 cmdline_parse_token_num_t cmd_setbypass_mode_port =
5607 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
5610 cmdline_parse_inst_t cmd_set_bypass_mode = {
5611 .f = cmd_set_bypass_mode_parsed,
5612 .help_str = "set bypass mode normal|bypass|isolate <port_id>: "
5613 "Set the NIC bypass mode for port_id",
5616 (void *)&cmd_setbypass_mode_set,
5617 (void *)&cmd_setbypass_mode_bypass,
5618 (void *)&cmd_setbypass_mode_mode,
5619 (void *)&cmd_setbypass_mode_value,
5620 (void *)&cmd_setbypass_mode_port,
5625 /* *** SET NIC BYPASS EVENT *** */
5626 struct cmd_set_bypass_event_result {
5627 cmdline_fixed_string_t set;
5628 cmdline_fixed_string_t bypass;
5629 cmdline_fixed_string_t event;
5630 cmdline_fixed_string_t event_value;
5631 cmdline_fixed_string_t mode;
5632 cmdline_fixed_string_t mode_value;
5637 cmd_set_bypass_event_parsed(void *parsed_result,
5638 __rte_unused struct cmdline *cl,
5639 __rte_unused void *data)
5641 int32_t rc = -EINVAL;
5642 struct cmd_set_bypass_event_result *res = parsed_result;
5643 portid_t port_id = res->port_id;
5645 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5646 uint32_t bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5647 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5649 if (!strcmp(res->event_value, "timeout"))
5650 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT;
5651 else if (!strcmp(res->event_value, "os_on"))
5652 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_ON;
5653 else if (!strcmp(res->event_value, "os_off"))
5654 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_OFF;
5655 else if (!strcmp(res->event_value, "power_on"))
5656 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_ON;
5657 else if (!strcmp(res->event_value, "power_off"))
5658 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_OFF;
5660 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5662 if (!strcmp(res->mode_value, "bypass"))
5663 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5664 else if (!strcmp(res->mode_value, "isolate"))
5665 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5667 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5669 /* Set the watchdog timeout. */
5670 if (bypass_event == RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT) {
5673 if (RTE_PMD_IXGBE_BYPASS_TMT_VALID(bypass_timeout)) {
5674 rc = rte_pmd_ixgbe_bypass_wd_timeout_store(port_id,
5678 printf("Failed to set timeout value %u "
5679 "for port %d, errto code: %d.\n",
5680 bypass_timeout, port_id, rc);
5684 /* Set the bypass event to transition to bypass mode. */
5685 rc = rte_pmd_ixgbe_bypass_event_store(port_id, bypass_event,
5690 printf("\t Failed to set bypass event for port = %d.\n",
5694 cmdline_parse_token_string_t cmd_setbypass_event_set =
5695 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5697 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
5698 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5700 cmdline_parse_token_string_t cmd_setbypass_event_event =
5701 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5703 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
5704 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5705 event_value, "none#timeout#os_off#os_on#power_on#power_off");
5706 cmdline_parse_token_string_t cmd_setbypass_event_mode =
5707 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5709 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
5710 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5711 mode_value, "normal#bypass#isolate");
5712 cmdline_parse_token_num_t cmd_setbypass_event_port =
5713 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
5716 cmdline_parse_inst_t cmd_set_bypass_event = {
5717 .f = cmd_set_bypass_event_parsed,
5718 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
5719 "power_off mode normal|bypass|isolate <port_id>: "
5720 "Set the NIC bypass event mode for port_id",
5723 (void *)&cmd_setbypass_event_set,
5724 (void *)&cmd_setbypass_event_bypass,
5725 (void *)&cmd_setbypass_event_event,
5726 (void *)&cmd_setbypass_event_event_value,
5727 (void *)&cmd_setbypass_event_mode,
5728 (void *)&cmd_setbypass_event_mode_value,
5729 (void *)&cmd_setbypass_event_port,
5735 /* *** SET NIC BYPASS TIMEOUT *** */
5736 struct cmd_set_bypass_timeout_result {
5737 cmdline_fixed_string_t set;
5738 cmdline_fixed_string_t bypass;
5739 cmdline_fixed_string_t timeout;
5740 cmdline_fixed_string_t value;
5744 cmd_set_bypass_timeout_parsed(void *parsed_result,
5745 __rte_unused struct cmdline *cl,
5746 __rte_unused void *data)
5748 __rte_unused struct cmd_set_bypass_timeout_result *res = parsed_result;
5750 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5751 if (!strcmp(res->value, "1.5"))
5752 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_1_5_SEC;
5753 else if (!strcmp(res->value, "2"))
5754 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_2_SEC;
5755 else if (!strcmp(res->value, "3"))
5756 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_3_SEC;
5757 else if (!strcmp(res->value, "4"))
5758 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_4_SEC;
5759 else if (!strcmp(res->value, "8"))
5760 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_8_SEC;
5761 else if (!strcmp(res->value, "16"))
5762 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_16_SEC;
5763 else if (!strcmp(res->value, "32"))
5764 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_32_SEC;
5766 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5770 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
5771 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5773 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
5774 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5776 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
5777 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5778 timeout, "timeout");
5779 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
5780 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5781 value, "0#1.5#2#3#4#8#16#32");
5783 cmdline_parse_inst_t cmd_set_bypass_timeout = {
5784 .f = cmd_set_bypass_timeout_parsed,
5785 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
5786 "Set the NIC bypass watchdog timeout in seconds",
5789 (void *)&cmd_setbypass_timeout_set,
5790 (void *)&cmd_setbypass_timeout_bypass,
5791 (void *)&cmd_setbypass_timeout_timeout,
5792 (void *)&cmd_setbypass_timeout_value,
5797 /* *** SHOW NIC BYPASS MODE *** */
5798 struct cmd_show_bypass_config_result {
5799 cmdline_fixed_string_t show;
5800 cmdline_fixed_string_t bypass;
5801 cmdline_fixed_string_t config;
5806 cmd_show_bypass_config_parsed(void *parsed_result,
5807 __rte_unused struct cmdline *cl,
5808 __rte_unused void *data)
5810 struct cmd_show_bypass_config_result *res = parsed_result;
5811 portid_t port_id = res->port_id;
5813 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5814 uint32_t event_mode;
5815 uint32_t bypass_mode;
5816 uint32_t timeout = bypass_timeout;
5819 static const char * const timeouts[RTE_PMD_IXGBE_BYPASS_TMT_NUM] =
5820 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
5821 static const char * const modes[RTE_PMD_IXGBE_BYPASS_MODE_NUM] =
5822 {"UNKNOWN", "normal", "bypass", "isolate"};
5823 static const char * const events[RTE_PMD_IXGBE_BYPASS_EVENT_NUM] = {
5831 /* Display the bypass mode.*/
5832 if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) != 0) {
5833 printf("\tFailed to get bypass mode for port = %d\n", port_id);
5837 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(bypass_mode))
5838 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5840 printf("\tbypass mode = %s\n", modes[bypass_mode]);
5843 /* Display the bypass timeout.*/
5844 if (!RTE_PMD_IXGBE_BYPASS_TMT_VALID(timeout))
5845 timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5847 printf("\tbypass timeout = %s\n", timeouts[timeout]);
5849 /* Display the bypass events and associated modes. */
5850 for (i = RTE_PMD_IXGBE_BYPASS_EVENT_START; i < RTE_DIM(events); i++) {
5852 if (rte_pmd_ixgbe_bypass_event_show(port_id, i, &event_mode)) {
5853 printf("\tFailed to get bypass mode for event = %s\n",
5856 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(event_mode))
5857 event_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5859 printf("\tbypass event: %-16s = %s\n", events[i],
5865 printf("\tFailed to get bypass configuration for port = %d\n",
5869 cmdline_parse_token_string_t cmd_showbypass_config_show =
5870 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5872 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
5873 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5875 cmdline_parse_token_string_t cmd_showbypass_config_config =
5876 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5878 cmdline_parse_token_num_t cmd_showbypass_config_port =
5879 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
5882 cmdline_parse_inst_t cmd_show_bypass_config = {
5883 .f = cmd_show_bypass_config_parsed,
5884 .help_str = "show bypass config <port_id>: "
5885 "Show the NIC bypass config for port_id",
5888 (void *)&cmd_showbypass_config_show,
5889 (void *)&cmd_showbypass_config_bypass,
5890 (void *)&cmd_showbypass_config_config,
5891 (void *)&cmd_showbypass_config_port,
5897 /* *** SET BONDING MODE *** */
5898 struct cmd_set_bonding_mode_result {
5899 cmdline_fixed_string_t set;
5900 cmdline_fixed_string_t bonding;
5901 cmdline_fixed_string_t mode;
5906 static void cmd_set_bonding_mode_parsed(void *parsed_result,
5907 __rte_unused struct cmdline *cl,
5908 __rte_unused void *data)
5910 struct cmd_set_bonding_mode_result *res = parsed_result;
5911 portid_t port_id = res->port_id;
5913 /* Set the bonding mode for the relevant port. */
5914 if (0 != rte_eth_bond_mode_set(port_id, res->value))
5915 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
5918 cmdline_parse_token_string_t cmd_setbonding_mode_set =
5919 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5921 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
5922 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5923 bonding, "bonding");
5924 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
5925 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5927 cmdline_parse_token_num_t cmd_setbonding_mode_value =
5928 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5930 cmdline_parse_token_num_t cmd_setbonding_mode_port =
5931 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5934 cmdline_parse_inst_t cmd_set_bonding_mode = {
5935 .f = cmd_set_bonding_mode_parsed,
5936 .help_str = "set bonding mode <mode_value> <port_id>: "
5937 "Set the bonding mode for port_id",
5940 (void *) &cmd_setbonding_mode_set,
5941 (void *) &cmd_setbonding_mode_bonding,
5942 (void *) &cmd_setbonding_mode_mode,
5943 (void *) &cmd_setbonding_mode_value,
5944 (void *) &cmd_setbonding_mode_port,
5949 /* *** SET BONDING SLOW_QUEUE SW/HW *** */
5950 struct cmd_set_bonding_lacp_dedicated_queues_result {
5951 cmdline_fixed_string_t set;
5952 cmdline_fixed_string_t bonding;
5953 cmdline_fixed_string_t lacp;
5954 cmdline_fixed_string_t dedicated_queues;
5956 cmdline_fixed_string_t mode;
5959 static void cmd_set_bonding_lacp_dedicated_queues_parsed(void *parsed_result,
5960 __rte_unused struct cmdline *cl,
5961 __rte_unused void *data)
5963 struct cmd_set_bonding_lacp_dedicated_queues_result *res = parsed_result;
5964 portid_t port_id = res->port_id;
5965 struct rte_port *port;
5967 port = &ports[port_id];
5969 /** Check if the port is not started **/
5970 if (port->port_status != RTE_PORT_STOPPED) {
5971 printf("Please stop port %d first\n", port_id);
5975 if (!strcmp(res->mode, "enable")) {
5976 if (rte_eth_bond_8023ad_dedicated_queues_enable(port_id) == 0)
5977 printf("Dedicate queues for LACP control packets"
5980 printf("Enabling dedicate queues for LACP control "
5981 "packets on port %d failed\n", port_id);
5982 } else if (!strcmp(res->mode, "disable")) {
5983 if (rte_eth_bond_8023ad_dedicated_queues_disable(port_id) == 0)
5984 printf("Dedicated queues for LACP control packets "
5987 printf("Disabling dedicated queues for LACP control "
5988 "traffic on port %d failed\n", port_id);
5992 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_set =
5993 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5995 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_bonding =
5996 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5997 bonding, "bonding");
5998 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_lacp =
5999 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
6001 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_dedicated_queues =
6002 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
6003 dedicated_queues, "dedicated_queues");
6004 cmdline_parse_token_num_t cmd_setbonding_lacp_dedicated_queues_port_id =
6005 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
6007 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_mode =
6008 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
6009 mode, "enable#disable");
6011 cmdline_parse_inst_t cmd_set_lacp_dedicated_queues = {
6012 .f = cmd_set_bonding_lacp_dedicated_queues_parsed,
6013 .help_str = "set bonding lacp dedicated_queues <port_id> "
6015 "Enable/disable dedicated queues for LACP control traffic for port_id",
6018 (void *)&cmd_setbonding_lacp_dedicated_queues_set,
6019 (void *)&cmd_setbonding_lacp_dedicated_queues_bonding,
6020 (void *)&cmd_setbonding_lacp_dedicated_queues_lacp,
6021 (void *)&cmd_setbonding_lacp_dedicated_queues_dedicated_queues,
6022 (void *)&cmd_setbonding_lacp_dedicated_queues_port_id,
6023 (void *)&cmd_setbonding_lacp_dedicated_queues_mode,
6028 /* *** SET BALANCE XMIT POLICY *** */
6029 struct cmd_set_bonding_balance_xmit_policy_result {
6030 cmdline_fixed_string_t set;
6031 cmdline_fixed_string_t bonding;
6032 cmdline_fixed_string_t balance_xmit_policy;
6034 cmdline_fixed_string_t policy;
6037 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
6038 __rte_unused struct cmdline *cl,
6039 __rte_unused void *data)
6041 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
6042 portid_t port_id = res->port_id;
6045 if (!strcmp(res->policy, "l2")) {
6046 policy = BALANCE_XMIT_POLICY_LAYER2;
6047 } else if (!strcmp(res->policy, "l23")) {
6048 policy = BALANCE_XMIT_POLICY_LAYER23;
6049 } else if (!strcmp(res->policy, "l34")) {
6050 policy = BALANCE_XMIT_POLICY_LAYER34;
6052 printf("\t Invalid xmit policy selection");
6056 /* Set the bonding mode for the relevant port. */
6057 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
6058 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
6063 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
6064 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6066 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
6067 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6068 bonding, "bonding");
6069 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
6070 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6071 balance_xmit_policy, "balance_xmit_policy");
6072 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
6073 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6075 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
6076 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6077 policy, "l2#l23#l34");
6079 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
6080 .f = cmd_set_bonding_balance_xmit_policy_parsed,
6081 .help_str = "set bonding balance_xmit_policy <port_id> "
6083 "Set the bonding balance_xmit_policy for port_id",
6086 (void *)&cmd_setbonding_balance_xmit_policy_set,
6087 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
6088 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
6089 (void *)&cmd_setbonding_balance_xmit_policy_port,
6090 (void *)&cmd_setbonding_balance_xmit_policy_policy,
6095 /* *** SHOW NIC BONDING CONFIGURATION *** */
6096 struct cmd_show_bonding_config_result {
6097 cmdline_fixed_string_t show;
6098 cmdline_fixed_string_t bonding;
6099 cmdline_fixed_string_t config;
6103 static void cmd_show_bonding_config_parsed(void *parsed_result,
6104 __rte_unused struct cmdline *cl,
6105 __rte_unused void *data)
6107 struct cmd_show_bonding_config_result *res = parsed_result;
6108 int bonding_mode, agg_mode;
6109 portid_t slaves[RTE_MAX_ETHPORTS];
6110 int num_slaves, num_active_slaves;
6113 portid_t port_id = res->port_id;
6115 /* Display the bonding mode.*/
6116 bonding_mode = rte_eth_bond_mode_get(port_id);
6117 if (bonding_mode < 0) {
6118 printf("\tFailed to get bonding mode for port = %d\n", port_id);
6121 printf("\tBonding mode: %d\n", bonding_mode);
6123 if (bonding_mode == BONDING_MODE_BALANCE) {
6124 int balance_xmit_policy;
6126 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
6127 if (balance_xmit_policy < 0) {
6128 printf("\tFailed to get balance xmit policy for port = %d\n",
6132 printf("\tBalance Xmit Policy: ");
6134 switch (balance_xmit_policy) {
6135 case BALANCE_XMIT_POLICY_LAYER2:
6136 printf("BALANCE_XMIT_POLICY_LAYER2");
6138 case BALANCE_XMIT_POLICY_LAYER23:
6139 printf("BALANCE_XMIT_POLICY_LAYER23");
6141 case BALANCE_XMIT_POLICY_LAYER34:
6142 printf("BALANCE_XMIT_POLICY_LAYER34");
6149 if (bonding_mode == BONDING_MODE_8023AD) {
6150 agg_mode = rte_eth_bond_8023ad_agg_selection_get(port_id);
6151 printf("\tIEEE802.3AD Aggregator Mode: ");
6154 printf("bandwidth");
6166 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
6168 if (num_slaves < 0) {
6169 printf("\tFailed to get slave list for port = %d\n", port_id);
6172 if (num_slaves > 0) {
6173 printf("\tSlaves (%d): [", num_slaves);
6174 for (i = 0; i < num_slaves - 1; i++)
6175 printf("%d ", slaves[i]);
6177 printf("%d]\n", slaves[num_slaves - 1]);
6179 printf("\tSlaves: []\n");
6183 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
6186 if (num_active_slaves < 0) {
6187 printf("\tFailed to get active slave list for port = %d\n", port_id);
6190 if (num_active_slaves > 0) {
6191 printf("\tActive Slaves (%d): [", num_active_slaves);
6192 for (i = 0; i < num_active_slaves - 1; i++)
6193 printf("%d ", slaves[i]);
6195 printf("%d]\n", slaves[num_active_slaves - 1]);
6198 printf("\tActive Slaves: []\n");
6202 primary_id = rte_eth_bond_primary_get(port_id);
6203 if (primary_id < 0) {
6204 printf("\tFailed to get primary slave for port = %d\n", port_id);
6207 printf("\tPrimary: [%d]\n", primary_id);
6211 cmdline_parse_token_string_t cmd_showbonding_config_show =
6212 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6214 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
6215 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6216 bonding, "bonding");
6217 cmdline_parse_token_string_t cmd_showbonding_config_config =
6218 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6220 cmdline_parse_token_num_t cmd_showbonding_config_port =
6221 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
6224 cmdline_parse_inst_t cmd_show_bonding_config = {
6225 .f = cmd_show_bonding_config_parsed,
6226 .help_str = "show bonding config <port_id>: "
6227 "Show the bonding config for port_id",
6230 (void *)&cmd_showbonding_config_show,
6231 (void *)&cmd_showbonding_config_bonding,
6232 (void *)&cmd_showbonding_config_config,
6233 (void *)&cmd_showbonding_config_port,
6238 /* *** SET BONDING PRIMARY *** */
6239 struct cmd_set_bonding_primary_result {
6240 cmdline_fixed_string_t set;
6241 cmdline_fixed_string_t bonding;
6242 cmdline_fixed_string_t primary;
6247 static void cmd_set_bonding_primary_parsed(void *parsed_result,
6248 __rte_unused struct cmdline *cl,
6249 __rte_unused void *data)
6251 struct cmd_set_bonding_primary_result *res = parsed_result;
6252 portid_t master_port_id = res->port_id;
6253 portid_t slave_port_id = res->slave_id;
6255 /* Set the primary slave for a bonded device. */
6256 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
6257 printf("\t Failed to set primary slave for port = %d.\n",
6264 cmdline_parse_token_string_t cmd_setbonding_primary_set =
6265 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6267 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
6268 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6269 bonding, "bonding");
6270 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
6271 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6272 primary, "primary");
6273 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
6274 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
6276 cmdline_parse_token_num_t cmd_setbonding_primary_port =
6277 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
6280 cmdline_parse_inst_t cmd_set_bonding_primary = {
6281 .f = cmd_set_bonding_primary_parsed,
6282 .help_str = "set bonding primary <slave_id> <port_id>: "
6283 "Set the primary slave for port_id",
6286 (void *)&cmd_setbonding_primary_set,
6287 (void *)&cmd_setbonding_primary_bonding,
6288 (void *)&cmd_setbonding_primary_primary,
6289 (void *)&cmd_setbonding_primary_slave,
6290 (void *)&cmd_setbonding_primary_port,
6295 /* *** ADD SLAVE *** */
6296 struct cmd_add_bonding_slave_result {
6297 cmdline_fixed_string_t add;
6298 cmdline_fixed_string_t bonding;
6299 cmdline_fixed_string_t slave;
6304 static void cmd_add_bonding_slave_parsed(void *parsed_result,
6305 __rte_unused struct cmdline *cl,
6306 __rte_unused void *data)
6308 struct cmd_add_bonding_slave_result *res = parsed_result;
6309 portid_t master_port_id = res->port_id;
6310 portid_t slave_port_id = res->slave_id;
6312 /* add the slave for a bonded device. */
6313 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
6314 printf("\t Failed to add slave %d to master port = %d.\n",
6315 slave_port_id, master_port_id);
6319 set_port_slave_flag(slave_port_id);
6322 cmdline_parse_token_string_t cmd_addbonding_slave_add =
6323 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6325 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
6326 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6327 bonding, "bonding");
6328 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
6329 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6331 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
6332 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
6334 cmdline_parse_token_num_t cmd_addbonding_slave_port =
6335 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
6338 cmdline_parse_inst_t cmd_add_bonding_slave = {
6339 .f = cmd_add_bonding_slave_parsed,
6340 .help_str = "add bonding slave <slave_id> <port_id>: "
6341 "Add a slave device to a bonded device",
6344 (void *)&cmd_addbonding_slave_add,
6345 (void *)&cmd_addbonding_slave_bonding,
6346 (void *)&cmd_addbonding_slave_slave,
6347 (void *)&cmd_addbonding_slave_slaveid,
6348 (void *)&cmd_addbonding_slave_port,
6353 /* *** REMOVE SLAVE *** */
6354 struct cmd_remove_bonding_slave_result {
6355 cmdline_fixed_string_t remove;
6356 cmdline_fixed_string_t bonding;
6357 cmdline_fixed_string_t slave;
6362 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
6363 __rte_unused struct cmdline *cl,
6364 __rte_unused void *data)
6366 struct cmd_remove_bonding_slave_result *res = parsed_result;
6367 portid_t master_port_id = res->port_id;
6368 portid_t slave_port_id = res->slave_id;
6370 /* remove the slave from a bonded device. */
6371 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
6372 printf("\t Failed to remove slave %d from master port = %d.\n",
6373 slave_port_id, master_port_id);
6377 clear_port_slave_flag(slave_port_id);
6380 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
6381 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6383 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
6384 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6385 bonding, "bonding");
6386 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
6387 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6389 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
6390 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6392 cmdline_parse_token_num_t cmd_removebonding_slave_port =
6393 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6396 cmdline_parse_inst_t cmd_remove_bonding_slave = {
6397 .f = cmd_remove_bonding_slave_parsed,
6398 .help_str = "remove bonding slave <slave_id> <port_id>: "
6399 "Remove a slave device from a bonded device",
6402 (void *)&cmd_removebonding_slave_remove,
6403 (void *)&cmd_removebonding_slave_bonding,
6404 (void *)&cmd_removebonding_slave_slave,
6405 (void *)&cmd_removebonding_slave_slaveid,
6406 (void *)&cmd_removebonding_slave_port,
6411 /* *** CREATE BONDED DEVICE *** */
6412 struct cmd_create_bonded_device_result {
6413 cmdline_fixed_string_t create;
6414 cmdline_fixed_string_t bonded;
6415 cmdline_fixed_string_t device;
6420 static int bond_dev_num = 0;
6422 static void cmd_create_bonded_device_parsed(void *parsed_result,
6423 __rte_unused struct cmdline *cl,
6424 __rte_unused void *data)
6426 struct cmd_create_bonded_device_result *res = parsed_result;
6427 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
6431 if (test_done == 0) {
6432 printf("Please stop forwarding first\n");
6436 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bonding_testpmd_%d",
6439 /* Create a new bonded device. */
6440 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
6442 printf("\t Failed to create bonded device.\n");
6445 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
6448 /* Update number of ports */
6449 nb_ports = rte_eth_dev_count_avail();
6450 reconfig(port_id, res->socket);
6451 ret = rte_eth_promiscuous_enable(port_id);
6453 printf("Failed to enable promiscuous mode for port %u: %s - ignore\n",
6454 port_id, rte_strerror(-ret));
6456 ports[port_id].need_setup = 0;
6457 ports[port_id].port_status = RTE_PORT_STOPPED;
6462 cmdline_parse_token_string_t cmd_createbonded_device_create =
6463 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6465 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
6466 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6468 cmdline_parse_token_string_t cmd_createbonded_device_device =
6469 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6471 cmdline_parse_token_num_t cmd_createbonded_device_mode =
6472 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6474 cmdline_parse_token_num_t cmd_createbonded_device_socket =
6475 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6478 cmdline_parse_inst_t cmd_create_bonded_device = {
6479 .f = cmd_create_bonded_device_parsed,
6480 .help_str = "create bonded device <mode> <socket>: "
6481 "Create a new bonded device with specific bonding mode and socket",
6484 (void *)&cmd_createbonded_device_create,
6485 (void *)&cmd_createbonded_device_bonded,
6486 (void *)&cmd_createbonded_device_device,
6487 (void *)&cmd_createbonded_device_mode,
6488 (void *)&cmd_createbonded_device_socket,
6493 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
6494 struct cmd_set_bond_mac_addr_result {
6495 cmdline_fixed_string_t set;
6496 cmdline_fixed_string_t bonding;
6497 cmdline_fixed_string_t mac_addr;
6499 struct rte_ether_addr address;
6502 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
6503 __rte_unused struct cmdline *cl,
6504 __rte_unused void *data)
6506 struct cmd_set_bond_mac_addr_result *res = parsed_result;
6509 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
6512 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
6514 /* check the return value and print it if is < 0 */
6516 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
6519 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
6520 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
6521 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
6522 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
6524 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
6525 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
6527 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
6528 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result,
6530 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
6531 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
6533 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
6534 .f = cmd_set_bond_mac_addr_parsed,
6536 .help_str = "set bonding mac_addr <port_id> <mac_addr>",
6538 (void *)&cmd_set_bond_mac_addr_set,
6539 (void *)&cmd_set_bond_mac_addr_bonding,
6540 (void *)&cmd_set_bond_mac_addr_mac,
6541 (void *)&cmd_set_bond_mac_addr_portnum,
6542 (void *)&cmd_set_bond_mac_addr_addr,
6548 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
6549 struct cmd_set_bond_mon_period_result {
6550 cmdline_fixed_string_t set;
6551 cmdline_fixed_string_t bonding;
6552 cmdline_fixed_string_t mon_period;
6557 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
6558 __rte_unused struct cmdline *cl,
6559 __rte_unused void *data)
6561 struct cmd_set_bond_mon_period_result *res = parsed_result;
6564 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
6566 /* check the return value and print it if is < 0 */
6568 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
6571 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
6572 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6574 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
6575 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6576 bonding, "bonding");
6577 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
6578 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6579 mon_period, "mon_period");
6580 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
6581 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6583 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
6584 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6587 cmdline_parse_inst_t cmd_set_bond_mon_period = {
6588 .f = cmd_set_bond_mon_period_parsed,
6590 .help_str = "set bonding mon_period <port_id> <period_ms>",
6592 (void *)&cmd_set_bond_mon_period_set,
6593 (void *)&cmd_set_bond_mon_period_bonding,
6594 (void *)&cmd_set_bond_mon_period_mon_period,
6595 (void *)&cmd_set_bond_mon_period_portnum,
6596 (void *)&cmd_set_bond_mon_period_period_ms,
6603 struct cmd_set_bonding_agg_mode_policy_result {
6604 cmdline_fixed_string_t set;
6605 cmdline_fixed_string_t bonding;
6606 cmdline_fixed_string_t agg_mode;
6608 cmdline_fixed_string_t policy;
6613 cmd_set_bonding_agg_mode(void *parsed_result,
6614 __rte_unused struct cmdline *cl,
6615 __rte_unused void *data)
6617 struct cmd_set_bonding_agg_mode_policy_result *res = parsed_result;
6618 uint8_t policy = AGG_BANDWIDTH;
6620 if (!strcmp(res->policy, "bandwidth"))
6621 policy = AGG_BANDWIDTH;
6622 else if (!strcmp(res->policy, "stable"))
6623 policy = AGG_STABLE;
6624 else if (!strcmp(res->policy, "count"))
6627 rte_eth_bond_8023ad_agg_selection_set(res->port_num, policy);
6631 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_set =
6632 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6634 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_bonding =
6635 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6636 bonding, "bonding");
6638 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_agg_mode =
6639 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6640 agg_mode, "agg_mode");
6642 cmdline_parse_token_num_t cmd_set_bonding_agg_mode_portnum =
6643 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6646 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_policy_string =
6647 TOKEN_STRING_INITIALIZER(
6648 struct cmd_set_bonding_balance_xmit_policy_result,
6649 policy, "stable#bandwidth#count");
6651 cmdline_parse_inst_t cmd_set_bonding_agg_mode_policy = {
6652 .f = cmd_set_bonding_agg_mode,
6654 .help_str = "set bonding mode IEEE802.3AD aggregator policy <port_id> <agg_name>",
6656 (void *)&cmd_set_bonding_agg_mode_set,
6657 (void *)&cmd_set_bonding_agg_mode_bonding,
6658 (void *)&cmd_set_bonding_agg_mode_agg_mode,
6659 (void *)&cmd_set_bonding_agg_mode_portnum,
6660 (void *)&cmd_set_bonding_agg_mode_policy_string,
6666 #endif /* RTE_NET_BOND */
6668 /* *** SET FORWARDING MODE *** */
6669 struct cmd_set_fwd_mode_result {
6670 cmdline_fixed_string_t set;
6671 cmdline_fixed_string_t fwd;
6672 cmdline_fixed_string_t mode;
6675 static void cmd_set_fwd_mode_parsed(void *parsed_result,
6676 __rte_unused struct cmdline *cl,
6677 __rte_unused void *data)
6679 struct cmd_set_fwd_mode_result *res = parsed_result;
6682 set_pkt_forwarding_mode(res->mode);
6685 cmdline_parse_token_string_t cmd_setfwd_set =
6686 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
6687 cmdline_parse_token_string_t cmd_setfwd_fwd =
6688 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
6689 cmdline_parse_token_string_t cmd_setfwd_mode =
6690 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
6691 "" /* defined at init */);
6693 cmdline_parse_inst_t cmd_set_fwd_mode = {
6694 .f = cmd_set_fwd_mode_parsed,
6696 .help_str = NULL, /* defined at init */
6698 (void *)&cmd_setfwd_set,
6699 (void *)&cmd_setfwd_fwd,
6700 (void *)&cmd_setfwd_mode,
6705 static void cmd_set_fwd_mode_init(void)
6708 static char token[128];
6709 static char help[256];
6710 cmdline_parse_token_string_t *token_struct;
6712 modes = list_pkt_forwarding_modes();
6713 snprintf(help, sizeof(help), "set fwd %s: "
6714 "Set packet forwarding mode", modes);
6715 cmd_set_fwd_mode.help_str = help;
6717 /* string token separator is # */
6718 for (c = token; *modes != '\0'; modes++)
6723 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
6724 token_struct->string_data.str = token;
6727 /* *** SET RETRY FORWARDING MODE *** */
6728 struct cmd_set_fwd_retry_mode_result {
6729 cmdline_fixed_string_t set;
6730 cmdline_fixed_string_t fwd;
6731 cmdline_fixed_string_t mode;
6732 cmdline_fixed_string_t retry;
6735 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
6736 __rte_unused struct cmdline *cl,
6737 __rte_unused void *data)
6739 struct cmd_set_fwd_retry_mode_result *res = parsed_result;
6742 set_pkt_forwarding_mode(res->mode);
6745 cmdline_parse_token_string_t cmd_setfwd_retry_set =
6746 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6748 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
6749 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6751 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
6752 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6754 "" /* defined at init */);
6755 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
6756 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6759 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
6760 .f = cmd_set_fwd_retry_mode_parsed,
6762 .help_str = NULL, /* defined at init */
6764 (void *)&cmd_setfwd_retry_set,
6765 (void *)&cmd_setfwd_retry_fwd,
6766 (void *)&cmd_setfwd_retry_mode,
6767 (void *)&cmd_setfwd_retry_retry,
6772 static void cmd_set_fwd_retry_mode_init(void)
6775 static char token[128];
6776 static char help[256];
6777 cmdline_parse_token_string_t *token_struct;
6779 modes = list_pkt_forwarding_retry_modes();
6780 snprintf(help, sizeof(help), "set fwd %s retry: "
6781 "Set packet forwarding mode with retry", modes);
6782 cmd_set_fwd_retry_mode.help_str = help;
6784 /* string token separator is # */
6785 for (c = token; *modes != '\0'; modes++)
6790 token_struct = (cmdline_parse_token_string_t *)
6791 cmd_set_fwd_retry_mode.tokens[2];
6792 token_struct->string_data.str = token;
6795 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
6796 struct cmd_set_burst_tx_retry_result {
6797 cmdline_fixed_string_t set;
6798 cmdline_fixed_string_t burst;
6799 cmdline_fixed_string_t tx;
6800 cmdline_fixed_string_t delay;
6802 cmdline_fixed_string_t retry;
6806 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
6807 __rte_unused struct cmdline *cl,
6808 __rte_unused void *data)
6810 struct cmd_set_burst_tx_retry_result *res = parsed_result;
6812 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
6813 && !strcmp(res->tx, "tx")) {
6814 if (!strcmp(res->delay, "delay"))
6815 burst_tx_delay_time = res->time;
6816 if (!strcmp(res->retry, "retry"))
6817 burst_tx_retry_num = res->retry_num;
6822 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
6823 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
6824 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
6825 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
6827 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
6828 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
6829 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
6830 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
6831 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
6832 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
6833 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
6834 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
6835 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
6836 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
6838 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
6839 .f = cmd_set_burst_tx_retry_parsed,
6840 .help_str = "set burst tx delay <delay_usec> retry <num_retry>",
6842 (void *)&cmd_set_burst_tx_retry_set,
6843 (void *)&cmd_set_burst_tx_retry_burst,
6844 (void *)&cmd_set_burst_tx_retry_tx,
6845 (void *)&cmd_set_burst_tx_retry_delay,
6846 (void *)&cmd_set_burst_tx_retry_time,
6847 (void *)&cmd_set_burst_tx_retry_retry,
6848 (void *)&cmd_set_burst_tx_retry_retry_num,
6853 /* *** SET PROMISC MODE *** */
6854 struct cmd_set_promisc_mode_result {
6855 cmdline_fixed_string_t set;
6856 cmdline_fixed_string_t promisc;
6857 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6858 uint16_t port_num; /* valid if "allports" argument == 0 */
6859 cmdline_fixed_string_t mode;
6862 static void cmd_set_promisc_mode_parsed(void *parsed_result,
6863 __rte_unused struct cmdline *cl,
6866 struct cmd_set_promisc_mode_result *res = parsed_result;
6870 if (!strcmp(res->mode, "on"))
6877 RTE_ETH_FOREACH_DEV(i)
6878 eth_set_promisc_mode(i, enable);
6880 eth_set_promisc_mode(res->port_num, enable);
6884 cmdline_parse_token_string_t cmd_setpromisc_set =
6885 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
6886 cmdline_parse_token_string_t cmd_setpromisc_promisc =
6887 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
6889 cmdline_parse_token_string_t cmd_setpromisc_portall =
6890 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
6892 cmdline_parse_token_num_t cmd_setpromisc_portnum =
6893 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
6895 cmdline_parse_token_string_t cmd_setpromisc_mode =
6896 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
6899 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
6900 .f = cmd_set_promisc_mode_parsed,
6902 .help_str = "set promisc all on|off: Set promisc mode for all ports",
6904 (void *)&cmd_setpromisc_set,
6905 (void *)&cmd_setpromisc_promisc,
6906 (void *)&cmd_setpromisc_portall,
6907 (void *)&cmd_setpromisc_mode,
6912 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
6913 .f = cmd_set_promisc_mode_parsed,
6915 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
6917 (void *)&cmd_setpromisc_set,
6918 (void *)&cmd_setpromisc_promisc,
6919 (void *)&cmd_setpromisc_portnum,
6920 (void *)&cmd_setpromisc_mode,
6925 /* *** SET ALLMULTI MODE *** */
6926 struct cmd_set_allmulti_mode_result {
6927 cmdline_fixed_string_t set;
6928 cmdline_fixed_string_t allmulti;
6929 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6930 uint16_t port_num; /* valid if "allports" argument == 0 */
6931 cmdline_fixed_string_t mode;
6934 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
6935 __rte_unused struct cmdline *cl,
6938 struct cmd_set_allmulti_mode_result *res = parsed_result;
6942 if (!strcmp(res->mode, "on"))
6949 RTE_ETH_FOREACH_DEV(i) {
6950 eth_set_allmulticast_mode(i, enable);
6954 eth_set_allmulticast_mode(res->port_num, enable);
6958 cmdline_parse_token_string_t cmd_setallmulti_set =
6959 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
6960 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
6961 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
6963 cmdline_parse_token_string_t cmd_setallmulti_portall =
6964 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
6966 cmdline_parse_token_num_t cmd_setallmulti_portnum =
6967 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
6969 cmdline_parse_token_string_t cmd_setallmulti_mode =
6970 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
6973 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
6974 .f = cmd_set_allmulti_mode_parsed,
6976 .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
6978 (void *)&cmd_setallmulti_set,
6979 (void *)&cmd_setallmulti_allmulti,
6980 (void *)&cmd_setallmulti_portall,
6981 (void *)&cmd_setallmulti_mode,
6986 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
6987 .f = cmd_set_allmulti_mode_parsed,
6989 .help_str = "set allmulti <port_id> on|off: "
6990 "Set allmulti mode on port_id",
6992 (void *)&cmd_setallmulti_set,
6993 (void *)&cmd_setallmulti_allmulti,
6994 (void *)&cmd_setallmulti_portnum,
6995 (void *)&cmd_setallmulti_mode,
7000 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
7001 struct cmd_link_flow_ctrl_set_result {
7002 cmdline_fixed_string_t set;
7003 cmdline_fixed_string_t flow_ctrl;
7004 cmdline_fixed_string_t rx;
7005 cmdline_fixed_string_t rx_lfc_mode;
7006 cmdline_fixed_string_t tx;
7007 cmdline_fixed_string_t tx_lfc_mode;
7008 cmdline_fixed_string_t mac_ctrl_frame_fwd;
7009 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
7010 cmdline_fixed_string_t autoneg_str;
7011 cmdline_fixed_string_t autoneg;
7012 cmdline_fixed_string_t hw_str;
7013 uint32_t high_water;
7014 cmdline_fixed_string_t lw_str;
7016 cmdline_fixed_string_t pt_str;
7017 uint16_t pause_time;
7018 cmdline_fixed_string_t xon_str;
7023 cmdline_parse_token_string_t cmd_lfc_set_set =
7024 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7026 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
7027 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7028 flow_ctrl, "flow_ctrl");
7029 cmdline_parse_token_string_t cmd_lfc_set_rx =
7030 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7032 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
7033 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7034 rx_lfc_mode, "on#off");
7035 cmdline_parse_token_string_t cmd_lfc_set_tx =
7036 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7038 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
7039 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7040 tx_lfc_mode, "on#off");
7041 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
7042 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7043 hw_str, "high_water");
7044 cmdline_parse_token_num_t cmd_lfc_set_high_water =
7045 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7046 high_water, UINT32);
7047 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
7048 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7049 lw_str, "low_water");
7050 cmdline_parse_token_num_t cmd_lfc_set_low_water =
7051 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7053 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
7054 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7055 pt_str, "pause_time");
7056 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
7057 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7058 pause_time, UINT16);
7059 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
7060 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7061 xon_str, "send_xon");
7062 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
7063 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7065 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
7066 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7067 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
7068 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
7069 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7070 mac_ctrl_frame_fwd_mode, "on#off");
7071 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
7072 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7073 autoneg_str, "autoneg");
7074 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
7075 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7077 cmdline_parse_token_num_t cmd_lfc_set_portid =
7078 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7081 /* forward declaration */
7083 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
7086 cmdline_parse_inst_t cmd_link_flow_control_set = {
7087 .f = cmd_link_flow_ctrl_set_parsed,
7089 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
7090 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
7091 "autoneg on|off <port_id>: Configure the Ethernet flow control",
7093 (void *)&cmd_lfc_set_set,
7094 (void *)&cmd_lfc_set_flow_ctrl,
7095 (void *)&cmd_lfc_set_rx,
7096 (void *)&cmd_lfc_set_rx_mode,
7097 (void *)&cmd_lfc_set_tx,
7098 (void *)&cmd_lfc_set_tx_mode,
7099 (void *)&cmd_lfc_set_high_water,
7100 (void *)&cmd_lfc_set_low_water,
7101 (void *)&cmd_lfc_set_pause_time,
7102 (void *)&cmd_lfc_set_send_xon,
7103 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
7104 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
7105 (void *)&cmd_lfc_set_autoneg_str,
7106 (void *)&cmd_lfc_set_autoneg,
7107 (void *)&cmd_lfc_set_portid,
7112 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
7113 .f = cmd_link_flow_ctrl_set_parsed,
7114 .data = (void *)&cmd_link_flow_control_set_rx,
7115 .help_str = "set flow_ctrl rx on|off <port_id>: "
7116 "Change rx flow control parameter",
7118 (void *)&cmd_lfc_set_set,
7119 (void *)&cmd_lfc_set_flow_ctrl,
7120 (void *)&cmd_lfc_set_rx,
7121 (void *)&cmd_lfc_set_rx_mode,
7122 (void *)&cmd_lfc_set_portid,
7127 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
7128 .f = cmd_link_flow_ctrl_set_parsed,
7129 .data = (void *)&cmd_link_flow_control_set_tx,
7130 .help_str = "set flow_ctrl tx on|off <port_id>: "
7131 "Change tx flow control parameter",
7133 (void *)&cmd_lfc_set_set,
7134 (void *)&cmd_lfc_set_flow_ctrl,
7135 (void *)&cmd_lfc_set_tx,
7136 (void *)&cmd_lfc_set_tx_mode,
7137 (void *)&cmd_lfc_set_portid,
7142 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
7143 .f = cmd_link_flow_ctrl_set_parsed,
7144 .data = (void *)&cmd_link_flow_control_set_hw,
7145 .help_str = "set flow_ctrl high_water <value> <port_id>: "
7146 "Change high water flow control parameter",
7148 (void *)&cmd_lfc_set_set,
7149 (void *)&cmd_lfc_set_flow_ctrl,
7150 (void *)&cmd_lfc_set_high_water_str,
7151 (void *)&cmd_lfc_set_high_water,
7152 (void *)&cmd_lfc_set_portid,
7157 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
7158 .f = cmd_link_flow_ctrl_set_parsed,
7159 .data = (void *)&cmd_link_flow_control_set_lw,
7160 .help_str = "set flow_ctrl low_water <value> <port_id>: "
7161 "Change low water flow control parameter",
7163 (void *)&cmd_lfc_set_set,
7164 (void *)&cmd_lfc_set_flow_ctrl,
7165 (void *)&cmd_lfc_set_low_water_str,
7166 (void *)&cmd_lfc_set_low_water,
7167 (void *)&cmd_lfc_set_portid,
7172 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
7173 .f = cmd_link_flow_ctrl_set_parsed,
7174 .data = (void *)&cmd_link_flow_control_set_pt,
7175 .help_str = "set flow_ctrl pause_time <value> <port_id>: "
7176 "Change pause time flow control parameter",
7178 (void *)&cmd_lfc_set_set,
7179 (void *)&cmd_lfc_set_flow_ctrl,
7180 (void *)&cmd_lfc_set_pause_time_str,
7181 (void *)&cmd_lfc_set_pause_time,
7182 (void *)&cmd_lfc_set_portid,
7187 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
7188 .f = cmd_link_flow_ctrl_set_parsed,
7189 .data = (void *)&cmd_link_flow_control_set_xon,
7190 .help_str = "set flow_ctrl send_xon <value> <port_id>: "
7191 "Change send_xon flow control parameter",
7193 (void *)&cmd_lfc_set_set,
7194 (void *)&cmd_lfc_set_flow_ctrl,
7195 (void *)&cmd_lfc_set_send_xon_str,
7196 (void *)&cmd_lfc_set_send_xon,
7197 (void *)&cmd_lfc_set_portid,
7202 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
7203 .f = cmd_link_flow_ctrl_set_parsed,
7204 .data = (void *)&cmd_link_flow_control_set_macfwd,
7205 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
7206 "Change mac ctrl fwd flow control parameter",
7208 (void *)&cmd_lfc_set_set,
7209 (void *)&cmd_lfc_set_flow_ctrl,
7210 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
7211 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
7212 (void *)&cmd_lfc_set_portid,
7217 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
7218 .f = cmd_link_flow_ctrl_set_parsed,
7219 .data = (void *)&cmd_link_flow_control_set_autoneg,
7220 .help_str = "set flow_ctrl autoneg on|off <port_id>: "
7221 "Change autoneg flow control parameter",
7223 (void *)&cmd_lfc_set_set,
7224 (void *)&cmd_lfc_set_flow_ctrl,
7225 (void *)&cmd_lfc_set_autoneg_str,
7226 (void *)&cmd_lfc_set_autoneg,
7227 (void *)&cmd_lfc_set_portid,
7233 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
7234 __rte_unused struct cmdline *cl,
7237 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
7238 cmdline_parse_inst_t *cmd = data;
7239 struct rte_eth_fc_conf fc_conf;
7245 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
7246 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
7247 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
7248 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
7250 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
7251 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
7254 /* Partial command line, retrieve current configuration */
7256 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
7258 printf("cannot get current flow ctrl parameters, return"
7259 "code = %d\n", ret);
7263 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
7264 (fc_conf.mode == RTE_FC_FULL))
7266 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
7267 (fc_conf.mode == RTE_FC_FULL))
7271 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
7272 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
7274 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
7275 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
7277 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
7279 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
7280 fc_conf.high_water = res->high_water;
7282 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
7283 fc_conf.low_water = res->low_water;
7285 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
7286 fc_conf.pause_time = res->pause_time;
7288 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
7289 fc_conf.send_xon = res->send_xon;
7291 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
7292 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
7293 fc_conf.mac_ctrl_frame_fwd = 1;
7295 fc_conf.mac_ctrl_frame_fwd = 0;
7298 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
7299 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
7301 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
7303 printf("bad flow contrl parameter, return code = %d \n", ret);
7306 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
7307 struct cmd_priority_flow_ctrl_set_result {
7308 cmdline_fixed_string_t set;
7309 cmdline_fixed_string_t pfc_ctrl;
7310 cmdline_fixed_string_t rx;
7311 cmdline_fixed_string_t rx_pfc_mode;
7312 cmdline_fixed_string_t tx;
7313 cmdline_fixed_string_t tx_pfc_mode;
7314 uint32_t high_water;
7316 uint16_t pause_time;
7322 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
7323 __rte_unused struct cmdline *cl,
7324 __rte_unused void *data)
7326 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
7327 struct rte_eth_pfc_conf pfc_conf;
7328 int rx_fc_enable, tx_fc_enable;
7332 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
7333 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
7334 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
7335 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
7337 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
7338 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
7341 memset(&pfc_conf, 0, sizeof(struct rte_eth_pfc_conf));
7342 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
7343 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
7344 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
7345 pfc_conf.fc.high_water = res->high_water;
7346 pfc_conf.fc.low_water = res->low_water;
7347 pfc_conf.fc.pause_time = res->pause_time;
7348 pfc_conf.priority = res->priority;
7350 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
7352 printf("bad priority flow contrl parameter, return code = %d \n", ret);
7355 cmdline_parse_token_string_t cmd_pfc_set_set =
7356 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7358 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
7359 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7360 pfc_ctrl, "pfc_ctrl");
7361 cmdline_parse_token_string_t cmd_pfc_set_rx =
7362 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7364 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
7365 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7366 rx_pfc_mode, "on#off");
7367 cmdline_parse_token_string_t cmd_pfc_set_tx =
7368 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7370 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
7371 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7372 tx_pfc_mode, "on#off");
7373 cmdline_parse_token_num_t cmd_pfc_set_high_water =
7374 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7375 high_water, UINT32);
7376 cmdline_parse_token_num_t cmd_pfc_set_low_water =
7377 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7379 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
7380 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7381 pause_time, UINT16);
7382 cmdline_parse_token_num_t cmd_pfc_set_priority =
7383 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7385 cmdline_parse_token_num_t cmd_pfc_set_portid =
7386 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7389 cmdline_parse_inst_t cmd_priority_flow_control_set = {
7390 .f = cmd_priority_flow_ctrl_set_parsed,
7392 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
7393 "<pause_time> <priority> <port_id>: "
7394 "Configure the Ethernet priority flow control",
7396 (void *)&cmd_pfc_set_set,
7397 (void *)&cmd_pfc_set_flow_ctrl,
7398 (void *)&cmd_pfc_set_rx,
7399 (void *)&cmd_pfc_set_rx_mode,
7400 (void *)&cmd_pfc_set_tx,
7401 (void *)&cmd_pfc_set_tx_mode,
7402 (void *)&cmd_pfc_set_high_water,
7403 (void *)&cmd_pfc_set_low_water,
7404 (void *)&cmd_pfc_set_pause_time,
7405 (void *)&cmd_pfc_set_priority,
7406 (void *)&cmd_pfc_set_portid,
7411 /* *** RESET CONFIGURATION *** */
7412 struct cmd_reset_result {
7413 cmdline_fixed_string_t reset;
7414 cmdline_fixed_string_t def;
7417 static void cmd_reset_parsed(__rte_unused void *parsed_result,
7419 __rte_unused void *data)
7421 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
7422 set_def_fwd_config();
7425 cmdline_parse_token_string_t cmd_reset_set =
7426 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
7427 cmdline_parse_token_string_t cmd_reset_def =
7428 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
7431 cmdline_parse_inst_t cmd_reset = {
7432 .f = cmd_reset_parsed,
7434 .help_str = "set default: Reset default forwarding configuration",
7436 (void *)&cmd_reset_set,
7437 (void *)&cmd_reset_def,
7442 /* *** START FORWARDING *** */
7443 struct cmd_start_result {
7444 cmdline_fixed_string_t start;
7447 cmdline_parse_token_string_t cmd_start_start =
7448 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
7450 static void cmd_start_parsed(__rte_unused void *parsed_result,
7451 __rte_unused struct cmdline *cl,
7452 __rte_unused void *data)
7454 start_packet_forwarding(0);
7457 cmdline_parse_inst_t cmd_start = {
7458 .f = cmd_start_parsed,
7460 .help_str = "start: Start packet forwarding",
7462 (void *)&cmd_start_start,
7467 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
7468 struct cmd_start_tx_first_result {
7469 cmdline_fixed_string_t start;
7470 cmdline_fixed_string_t tx_first;
7474 cmd_start_tx_first_parsed(__rte_unused void *parsed_result,
7475 __rte_unused struct cmdline *cl,
7476 __rte_unused void *data)
7478 start_packet_forwarding(1);
7481 cmdline_parse_token_string_t cmd_start_tx_first_start =
7482 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
7484 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
7485 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
7486 tx_first, "tx_first");
7488 cmdline_parse_inst_t cmd_start_tx_first = {
7489 .f = cmd_start_tx_first_parsed,
7491 .help_str = "start tx_first: Start packet forwarding, "
7492 "after sending 1 burst of packets",
7494 (void *)&cmd_start_tx_first_start,
7495 (void *)&cmd_start_tx_first_tx_first,
7500 /* *** START FORWARDING WITH N TX BURST FIRST *** */
7501 struct cmd_start_tx_first_n_result {
7502 cmdline_fixed_string_t start;
7503 cmdline_fixed_string_t tx_first;
7508 cmd_start_tx_first_n_parsed(void *parsed_result,
7509 __rte_unused struct cmdline *cl,
7510 __rte_unused void *data)
7512 struct cmd_start_tx_first_n_result *res = parsed_result;
7514 start_packet_forwarding(res->tx_num);
7517 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
7518 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7520 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
7521 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7522 tx_first, "tx_first");
7523 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
7524 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
7527 cmdline_parse_inst_t cmd_start_tx_first_n = {
7528 .f = cmd_start_tx_first_n_parsed,
7530 .help_str = "start tx_first <num>: "
7531 "packet forwarding, after sending <num> bursts of packets",
7533 (void *)&cmd_start_tx_first_n_start,
7534 (void *)&cmd_start_tx_first_n_tx_first,
7535 (void *)&cmd_start_tx_first_n_tx_num,
7540 /* *** SET LINK UP *** */
7541 struct cmd_set_link_up_result {
7542 cmdline_fixed_string_t set;
7543 cmdline_fixed_string_t link_up;
7544 cmdline_fixed_string_t port;
7548 cmdline_parse_token_string_t cmd_set_link_up_set =
7549 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
7550 cmdline_parse_token_string_t cmd_set_link_up_link_up =
7551 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
7553 cmdline_parse_token_string_t cmd_set_link_up_port =
7554 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
7555 cmdline_parse_token_num_t cmd_set_link_up_port_id =
7556 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT16);
7558 static void cmd_set_link_up_parsed(__rte_unused void *parsed_result,
7559 __rte_unused struct cmdline *cl,
7560 __rte_unused void *data)
7562 struct cmd_set_link_up_result *res = parsed_result;
7563 dev_set_link_up(res->port_id);
7566 cmdline_parse_inst_t cmd_set_link_up = {
7567 .f = cmd_set_link_up_parsed,
7569 .help_str = "set link-up port <port id>",
7571 (void *)&cmd_set_link_up_set,
7572 (void *)&cmd_set_link_up_link_up,
7573 (void *)&cmd_set_link_up_port,
7574 (void *)&cmd_set_link_up_port_id,
7579 /* *** SET LINK DOWN *** */
7580 struct cmd_set_link_down_result {
7581 cmdline_fixed_string_t set;
7582 cmdline_fixed_string_t link_down;
7583 cmdline_fixed_string_t port;
7587 cmdline_parse_token_string_t cmd_set_link_down_set =
7588 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
7589 cmdline_parse_token_string_t cmd_set_link_down_link_down =
7590 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
7592 cmdline_parse_token_string_t cmd_set_link_down_port =
7593 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
7594 cmdline_parse_token_num_t cmd_set_link_down_port_id =
7595 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT16);
7597 static void cmd_set_link_down_parsed(
7598 __rte_unused void *parsed_result,
7599 __rte_unused struct cmdline *cl,
7600 __rte_unused void *data)
7602 struct cmd_set_link_down_result *res = parsed_result;
7603 dev_set_link_down(res->port_id);
7606 cmdline_parse_inst_t cmd_set_link_down = {
7607 .f = cmd_set_link_down_parsed,
7609 .help_str = "set link-down port <port id>",
7611 (void *)&cmd_set_link_down_set,
7612 (void *)&cmd_set_link_down_link_down,
7613 (void *)&cmd_set_link_down_port,
7614 (void *)&cmd_set_link_down_port_id,
7619 /* *** SHOW CFG *** */
7620 struct cmd_showcfg_result {
7621 cmdline_fixed_string_t show;
7622 cmdline_fixed_string_t cfg;
7623 cmdline_fixed_string_t what;
7626 static void cmd_showcfg_parsed(void *parsed_result,
7627 __rte_unused struct cmdline *cl,
7628 __rte_unused void *data)
7630 struct cmd_showcfg_result *res = parsed_result;
7631 if (!strcmp(res->what, "rxtx"))
7632 rxtx_config_display();
7633 else if (!strcmp(res->what, "cores"))
7634 fwd_lcores_config_display();
7635 else if (!strcmp(res->what, "fwd"))
7636 pkt_fwd_config_display(&cur_fwd_config);
7637 else if (!strcmp(res->what, "rxoffs"))
7638 show_rx_pkt_offsets();
7639 else if (!strcmp(res->what, "rxpkts"))
7640 show_rx_pkt_segments();
7641 else if (!strcmp(res->what, "txpkts"))
7642 show_tx_pkt_segments();
7643 else if (!strcmp(res->what, "txtimes"))
7644 show_tx_pkt_times();
7647 cmdline_parse_token_string_t cmd_showcfg_show =
7648 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
7649 cmdline_parse_token_string_t cmd_showcfg_port =
7650 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
7651 cmdline_parse_token_string_t cmd_showcfg_what =
7652 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
7653 "rxtx#cores#fwd#rxoffs#rxpkts#txpkts#txtimes");
7655 cmdline_parse_inst_t cmd_showcfg = {
7656 .f = cmd_showcfg_parsed,
7658 .help_str = "show config rxtx|cores|fwd|rxoffs|rxpkts|txpkts|txtimes",
7660 (void *)&cmd_showcfg_show,
7661 (void *)&cmd_showcfg_port,
7662 (void *)&cmd_showcfg_what,
7667 /* *** SHOW ALL PORT INFO *** */
7668 struct cmd_showportall_result {
7669 cmdline_fixed_string_t show;
7670 cmdline_fixed_string_t port;
7671 cmdline_fixed_string_t what;
7672 cmdline_fixed_string_t all;
7675 static void cmd_showportall_parsed(void *parsed_result,
7676 __rte_unused struct cmdline *cl,
7677 __rte_unused void *data)
7681 struct cmd_showportall_result *res = parsed_result;
7682 if (!strcmp(res->show, "clear")) {
7683 if (!strcmp(res->what, "stats"))
7684 RTE_ETH_FOREACH_DEV(i)
7686 else if (!strcmp(res->what, "xstats"))
7687 RTE_ETH_FOREACH_DEV(i)
7688 nic_xstats_clear(i);
7689 } else if (!strcmp(res->what, "info"))
7690 RTE_ETH_FOREACH_DEV(i)
7691 port_infos_display(i);
7692 else if (!strcmp(res->what, "summary")) {
7693 port_summary_header_display();
7694 RTE_ETH_FOREACH_DEV(i)
7695 port_summary_display(i);
7697 else if (!strcmp(res->what, "stats"))
7698 RTE_ETH_FOREACH_DEV(i)
7699 nic_stats_display(i);
7700 else if (!strcmp(res->what, "xstats"))
7701 RTE_ETH_FOREACH_DEV(i)
7702 nic_xstats_display(i);
7703 else if (!strcmp(res->what, "fdir"))
7704 RTE_ETH_FOREACH_DEV(i)
7706 else if (!strcmp(res->what, "stat_qmap"))
7707 RTE_ETH_FOREACH_DEV(i)
7708 nic_stats_mapping_display(i);
7709 else if (!strcmp(res->what, "dcb_tc"))
7710 RTE_ETH_FOREACH_DEV(i)
7711 port_dcb_info_display(i);
7712 else if (!strcmp(res->what, "cap"))
7713 RTE_ETH_FOREACH_DEV(i)
7714 port_offload_cap_display(i);
7717 cmdline_parse_token_string_t cmd_showportall_show =
7718 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
7720 cmdline_parse_token_string_t cmd_showportall_port =
7721 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
7722 cmdline_parse_token_string_t cmd_showportall_what =
7723 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
7724 "info#summary#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
7725 cmdline_parse_token_string_t cmd_showportall_all =
7726 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
7727 cmdline_parse_inst_t cmd_showportall = {
7728 .f = cmd_showportall_parsed,
7730 .help_str = "show|clear port "
7731 "info|summary|stats|xstats|fdir|stat_qmap|dcb_tc|cap all",
7733 (void *)&cmd_showportall_show,
7734 (void *)&cmd_showportall_port,
7735 (void *)&cmd_showportall_what,
7736 (void *)&cmd_showportall_all,
7741 /* *** SHOW PORT INFO *** */
7742 struct cmd_showport_result {
7743 cmdline_fixed_string_t show;
7744 cmdline_fixed_string_t port;
7745 cmdline_fixed_string_t what;
7749 static void cmd_showport_parsed(void *parsed_result,
7750 __rte_unused struct cmdline *cl,
7751 __rte_unused void *data)
7753 struct cmd_showport_result *res = parsed_result;
7754 if (!strcmp(res->show, "clear")) {
7755 if (!strcmp(res->what, "stats"))
7756 nic_stats_clear(res->portnum);
7757 else if (!strcmp(res->what, "xstats"))
7758 nic_xstats_clear(res->portnum);
7759 } else if (!strcmp(res->what, "info"))
7760 port_infos_display(res->portnum);
7761 else if (!strcmp(res->what, "summary")) {
7762 port_summary_header_display();
7763 port_summary_display(res->portnum);
7765 else if (!strcmp(res->what, "stats"))
7766 nic_stats_display(res->portnum);
7767 else if (!strcmp(res->what, "xstats"))
7768 nic_xstats_display(res->portnum);
7769 else if (!strcmp(res->what, "fdir"))
7770 fdir_get_infos(res->portnum);
7771 else if (!strcmp(res->what, "stat_qmap"))
7772 nic_stats_mapping_display(res->portnum);
7773 else if (!strcmp(res->what, "dcb_tc"))
7774 port_dcb_info_display(res->portnum);
7775 else if (!strcmp(res->what, "cap"))
7776 port_offload_cap_display(res->portnum);
7779 cmdline_parse_token_string_t cmd_showport_show =
7780 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
7782 cmdline_parse_token_string_t cmd_showport_port =
7783 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
7784 cmdline_parse_token_string_t cmd_showport_what =
7785 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
7786 "info#summary#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
7787 cmdline_parse_token_num_t cmd_showport_portnum =
7788 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT16);
7790 cmdline_parse_inst_t cmd_showport = {
7791 .f = cmd_showport_parsed,
7793 .help_str = "show|clear port "
7794 "info|summary|stats|xstats|fdir|stat_qmap|dcb_tc|cap "
7797 (void *)&cmd_showport_show,
7798 (void *)&cmd_showport_port,
7799 (void *)&cmd_showport_what,
7800 (void *)&cmd_showport_portnum,
7805 /* *** SHOW DEVICE INFO *** */
7806 struct cmd_showdevice_result {
7807 cmdline_fixed_string_t show;
7808 cmdline_fixed_string_t device;
7809 cmdline_fixed_string_t what;
7810 cmdline_fixed_string_t identifier;
7813 static void cmd_showdevice_parsed(void *parsed_result,
7814 __rte_unused struct cmdline *cl,
7815 __rte_unused void *data)
7817 struct cmd_showdevice_result *res = parsed_result;
7818 if (!strcmp(res->what, "info")) {
7819 if (!strcmp(res->identifier, "all"))
7820 device_infos_display(NULL);
7822 device_infos_display(res->identifier);
7826 cmdline_parse_token_string_t cmd_showdevice_show =
7827 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, show,
7829 cmdline_parse_token_string_t cmd_showdevice_device =
7830 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, device, "device");
7831 cmdline_parse_token_string_t cmd_showdevice_what =
7832 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, what,
7834 cmdline_parse_token_string_t cmd_showdevice_identifier =
7835 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result,
7838 cmdline_parse_inst_t cmd_showdevice = {
7839 .f = cmd_showdevice_parsed,
7841 .help_str = "show device info <identifier>|all",
7843 (void *)&cmd_showdevice_show,
7844 (void *)&cmd_showdevice_device,
7845 (void *)&cmd_showdevice_what,
7846 (void *)&cmd_showdevice_identifier,
7851 /* *** SHOW MODULE EEPROM/EEPROM port INFO *** */
7852 struct cmd_showeeprom_result {
7853 cmdline_fixed_string_t show;
7854 cmdline_fixed_string_t port;
7856 cmdline_fixed_string_t type;
7859 static void cmd_showeeprom_parsed(void *parsed_result,
7860 __rte_unused struct cmdline *cl,
7861 __rte_unused void *data)
7863 struct cmd_showeeprom_result *res = parsed_result;
7865 if (!strcmp(res->type, "eeprom"))
7866 port_eeprom_display(res->portnum);
7867 else if (!strcmp(res->type, "module_eeprom"))
7868 port_module_eeprom_display(res->portnum);
7870 printf("Unknown argument\n");
7873 cmdline_parse_token_string_t cmd_showeeprom_show =
7874 TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, show, "show");
7875 cmdline_parse_token_string_t cmd_showeeprom_port =
7876 TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, port, "port");
7877 cmdline_parse_token_num_t cmd_showeeprom_portnum =
7878 TOKEN_NUM_INITIALIZER(struct cmd_showeeprom_result, portnum, UINT16);
7879 cmdline_parse_token_string_t cmd_showeeprom_type =
7880 TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, type, "module_eeprom#eeprom");
7882 cmdline_parse_inst_t cmd_showeeprom = {
7883 .f = cmd_showeeprom_parsed,
7885 .help_str = "show port <port_id> module_eeprom|eeprom",
7887 (void *)&cmd_showeeprom_show,
7888 (void *)&cmd_showeeprom_port,
7889 (void *)&cmd_showeeprom_portnum,
7890 (void *)&cmd_showeeprom_type,
7895 /* *** SHOW QUEUE INFO *** */
7896 struct cmd_showqueue_result {
7897 cmdline_fixed_string_t show;
7898 cmdline_fixed_string_t type;
7899 cmdline_fixed_string_t what;
7905 cmd_showqueue_parsed(void *parsed_result,
7906 __rte_unused struct cmdline *cl,
7907 __rte_unused void *data)
7909 struct cmd_showqueue_result *res = parsed_result;
7911 if (!strcmp(res->type, "rxq"))
7912 rx_queue_infos_display(res->portnum, res->queuenum);
7913 else if (!strcmp(res->type, "txq"))
7914 tx_queue_infos_display(res->portnum, res->queuenum);
7917 cmdline_parse_token_string_t cmd_showqueue_show =
7918 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
7919 cmdline_parse_token_string_t cmd_showqueue_type =
7920 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
7921 cmdline_parse_token_string_t cmd_showqueue_what =
7922 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
7923 cmdline_parse_token_num_t cmd_showqueue_portnum =
7924 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, UINT16);
7925 cmdline_parse_token_num_t cmd_showqueue_queuenum =
7926 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, UINT16);
7928 cmdline_parse_inst_t cmd_showqueue = {
7929 .f = cmd_showqueue_parsed,
7931 .help_str = "show rxq|txq info <port_id> <queue_id>",
7933 (void *)&cmd_showqueue_show,
7934 (void *)&cmd_showqueue_type,
7935 (void *)&cmd_showqueue_what,
7936 (void *)&cmd_showqueue_portnum,
7937 (void *)&cmd_showqueue_queuenum,
7942 /* show/clear fwd engine statistics */
7944 cmdline_fixed_string_t action;
7945 cmdline_fixed_string_t fwd;
7946 cmdline_fixed_string_t stats;
7947 cmdline_fixed_string_t all;
7950 cmdline_parse_token_string_t cmd_fwd_action =
7951 TOKEN_STRING_INITIALIZER(struct fwd_result, action, "show#clear");
7952 cmdline_parse_token_string_t cmd_fwd_fwd =
7953 TOKEN_STRING_INITIALIZER(struct fwd_result, fwd, "fwd");
7954 cmdline_parse_token_string_t cmd_fwd_stats =
7955 TOKEN_STRING_INITIALIZER(struct fwd_result, stats, "stats");
7956 cmdline_parse_token_string_t cmd_fwd_all =
7957 TOKEN_STRING_INITIALIZER(struct fwd_result, all, "all");
7960 cmd_showfwdall_parsed(void *parsed_result,
7961 __rte_unused struct cmdline *cl,
7962 __rte_unused void *data)
7964 struct fwd_result *res = parsed_result;
7966 if (!strcmp(res->action, "show"))
7967 fwd_stats_display();
7972 static cmdline_parse_inst_t cmd_showfwdall = {
7973 .f = cmd_showfwdall_parsed,
7975 .help_str = "show|clear fwd stats all",
7977 (void *)&cmd_fwd_action,
7978 (void *)&cmd_fwd_fwd,
7979 (void *)&cmd_fwd_stats,
7980 (void *)&cmd_fwd_all,
7985 /* *** READ PORT REGISTER *** */
7986 struct cmd_read_reg_result {
7987 cmdline_fixed_string_t read;
7988 cmdline_fixed_string_t reg;
7994 cmd_read_reg_parsed(void *parsed_result,
7995 __rte_unused struct cmdline *cl,
7996 __rte_unused void *data)
7998 struct cmd_read_reg_result *res = parsed_result;
7999 port_reg_display(res->port_id, res->reg_off);
8002 cmdline_parse_token_string_t cmd_read_reg_read =
8003 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
8004 cmdline_parse_token_string_t cmd_read_reg_reg =
8005 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
8006 cmdline_parse_token_num_t cmd_read_reg_port_id =
8007 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT16);
8008 cmdline_parse_token_num_t cmd_read_reg_reg_off =
8009 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
8011 cmdline_parse_inst_t cmd_read_reg = {
8012 .f = cmd_read_reg_parsed,
8014 .help_str = "read reg <port_id> <reg_off>",
8016 (void *)&cmd_read_reg_read,
8017 (void *)&cmd_read_reg_reg,
8018 (void *)&cmd_read_reg_port_id,
8019 (void *)&cmd_read_reg_reg_off,
8024 /* *** READ PORT REGISTER BIT FIELD *** */
8025 struct cmd_read_reg_bit_field_result {
8026 cmdline_fixed_string_t read;
8027 cmdline_fixed_string_t regfield;
8035 cmd_read_reg_bit_field_parsed(void *parsed_result,
8036 __rte_unused struct cmdline *cl,
8037 __rte_unused void *data)
8039 struct cmd_read_reg_bit_field_result *res = parsed_result;
8040 port_reg_bit_field_display(res->port_id, res->reg_off,
8041 res->bit1_pos, res->bit2_pos);
8044 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
8045 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
8047 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
8048 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
8049 regfield, "regfield");
8050 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
8051 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
8053 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
8054 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
8056 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
8057 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
8059 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
8060 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
8063 cmdline_parse_inst_t cmd_read_reg_bit_field = {
8064 .f = cmd_read_reg_bit_field_parsed,
8066 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
8067 "Read register bit field between bit_x and bit_y included",
8069 (void *)&cmd_read_reg_bit_field_read,
8070 (void *)&cmd_read_reg_bit_field_regfield,
8071 (void *)&cmd_read_reg_bit_field_port_id,
8072 (void *)&cmd_read_reg_bit_field_reg_off,
8073 (void *)&cmd_read_reg_bit_field_bit1_pos,
8074 (void *)&cmd_read_reg_bit_field_bit2_pos,
8079 /* *** READ PORT REGISTER BIT *** */
8080 struct cmd_read_reg_bit_result {
8081 cmdline_fixed_string_t read;
8082 cmdline_fixed_string_t regbit;
8089 cmd_read_reg_bit_parsed(void *parsed_result,
8090 __rte_unused struct cmdline *cl,
8091 __rte_unused void *data)
8093 struct cmd_read_reg_bit_result *res = parsed_result;
8094 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
8097 cmdline_parse_token_string_t cmd_read_reg_bit_read =
8098 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
8099 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
8100 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
8102 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
8103 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT16);
8104 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
8105 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
8106 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
8107 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
8109 cmdline_parse_inst_t cmd_read_reg_bit = {
8110 .f = cmd_read_reg_bit_parsed,
8112 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
8114 (void *)&cmd_read_reg_bit_read,
8115 (void *)&cmd_read_reg_bit_regbit,
8116 (void *)&cmd_read_reg_bit_port_id,
8117 (void *)&cmd_read_reg_bit_reg_off,
8118 (void *)&cmd_read_reg_bit_bit_pos,
8123 /* *** WRITE PORT REGISTER *** */
8124 struct cmd_write_reg_result {
8125 cmdline_fixed_string_t write;
8126 cmdline_fixed_string_t reg;
8133 cmd_write_reg_parsed(void *parsed_result,
8134 __rte_unused struct cmdline *cl,
8135 __rte_unused void *data)
8137 struct cmd_write_reg_result *res = parsed_result;
8138 port_reg_set(res->port_id, res->reg_off, res->value);
8141 cmdline_parse_token_string_t cmd_write_reg_write =
8142 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
8143 cmdline_parse_token_string_t cmd_write_reg_reg =
8144 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
8145 cmdline_parse_token_num_t cmd_write_reg_port_id =
8146 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT16);
8147 cmdline_parse_token_num_t cmd_write_reg_reg_off =
8148 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
8149 cmdline_parse_token_num_t cmd_write_reg_value =
8150 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
8152 cmdline_parse_inst_t cmd_write_reg = {
8153 .f = cmd_write_reg_parsed,
8155 .help_str = "write reg <port_id> <reg_off> <reg_value>",
8157 (void *)&cmd_write_reg_write,
8158 (void *)&cmd_write_reg_reg,
8159 (void *)&cmd_write_reg_port_id,
8160 (void *)&cmd_write_reg_reg_off,
8161 (void *)&cmd_write_reg_value,
8166 /* *** WRITE PORT REGISTER BIT FIELD *** */
8167 struct cmd_write_reg_bit_field_result {
8168 cmdline_fixed_string_t write;
8169 cmdline_fixed_string_t regfield;
8178 cmd_write_reg_bit_field_parsed(void *parsed_result,
8179 __rte_unused struct cmdline *cl,
8180 __rte_unused void *data)
8182 struct cmd_write_reg_bit_field_result *res = parsed_result;
8183 port_reg_bit_field_set(res->port_id, res->reg_off,
8184 res->bit1_pos, res->bit2_pos, res->value);
8187 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
8188 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
8190 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
8191 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
8192 regfield, "regfield");
8193 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
8194 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
8196 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
8197 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
8199 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
8200 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
8202 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
8203 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
8205 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
8206 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
8209 cmdline_parse_inst_t cmd_write_reg_bit_field = {
8210 .f = cmd_write_reg_bit_field_parsed,
8212 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
8214 "Set register bit field between bit_x and bit_y included",
8216 (void *)&cmd_write_reg_bit_field_write,
8217 (void *)&cmd_write_reg_bit_field_regfield,
8218 (void *)&cmd_write_reg_bit_field_port_id,
8219 (void *)&cmd_write_reg_bit_field_reg_off,
8220 (void *)&cmd_write_reg_bit_field_bit1_pos,
8221 (void *)&cmd_write_reg_bit_field_bit2_pos,
8222 (void *)&cmd_write_reg_bit_field_value,
8227 /* *** WRITE PORT REGISTER BIT *** */
8228 struct cmd_write_reg_bit_result {
8229 cmdline_fixed_string_t write;
8230 cmdline_fixed_string_t regbit;
8238 cmd_write_reg_bit_parsed(void *parsed_result,
8239 __rte_unused struct cmdline *cl,
8240 __rte_unused void *data)
8242 struct cmd_write_reg_bit_result *res = parsed_result;
8243 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
8246 cmdline_parse_token_string_t cmd_write_reg_bit_write =
8247 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
8249 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
8250 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
8252 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
8253 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT16);
8254 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
8255 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
8256 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
8257 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
8258 cmdline_parse_token_num_t cmd_write_reg_bit_value =
8259 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
8261 cmdline_parse_inst_t cmd_write_reg_bit = {
8262 .f = cmd_write_reg_bit_parsed,
8264 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
8267 (void *)&cmd_write_reg_bit_write,
8268 (void *)&cmd_write_reg_bit_regbit,
8269 (void *)&cmd_write_reg_bit_port_id,
8270 (void *)&cmd_write_reg_bit_reg_off,
8271 (void *)&cmd_write_reg_bit_bit_pos,
8272 (void *)&cmd_write_reg_bit_value,
8277 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
8278 struct cmd_read_rxd_txd_result {
8279 cmdline_fixed_string_t read;
8280 cmdline_fixed_string_t rxd_txd;
8287 cmd_read_rxd_txd_parsed(void *parsed_result,
8288 __rte_unused struct cmdline *cl,
8289 __rte_unused void *data)
8291 struct cmd_read_rxd_txd_result *res = parsed_result;
8293 if (!strcmp(res->rxd_txd, "rxd"))
8294 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
8295 else if (!strcmp(res->rxd_txd, "txd"))
8296 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
8299 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
8300 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
8301 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
8302 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
8304 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
8305 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT16);
8306 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
8307 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
8308 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
8309 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
8311 cmdline_parse_inst_t cmd_read_rxd_txd = {
8312 .f = cmd_read_rxd_txd_parsed,
8314 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
8316 (void *)&cmd_read_rxd_txd_read,
8317 (void *)&cmd_read_rxd_txd_rxd_txd,
8318 (void *)&cmd_read_rxd_txd_port_id,
8319 (void *)&cmd_read_rxd_txd_queue_id,
8320 (void *)&cmd_read_rxd_txd_desc_id,
8326 struct cmd_quit_result {
8327 cmdline_fixed_string_t quit;
8330 static void cmd_quit_parsed(__rte_unused void *parsed_result,
8332 __rte_unused void *data)
8337 cmdline_parse_token_string_t cmd_quit_quit =
8338 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
8340 cmdline_parse_inst_t cmd_quit = {
8341 .f = cmd_quit_parsed,
8343 .help_str = "quit: Exit application",
8345 (void *)&cmd_quit_quit,
8350 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
8351 struct cmd_mac_addr_result {
8352 cmdline_fixed_string_t mac_addr_cmd;
8353 cmdline_fixed_string_t what;
8355 struct rte_ether_addr address;
8358 static void cmd_mac_addr_parsed(void *parsed_result,
8359 __rte_unused struct cmdline *cl,
8360 __rte_unused void *data)
8362 struct cmd_mac_addr_result *res = parsed_result;
8365 if (strcmp(res->what, "add") == 0)
8366 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
8367 else if (strcmp(res->what, "set") == 0)
8368 ret = rte_eth_dev_default_mac_addr_set(res->port_num,
8371 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
8373 /* check the return value and print it if is < 0 */
8375 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
8379 cmdline_parse_token_string_t cmd_mac_addr_cmd =
8380 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
8382 cmdline_parse_token_string_t cmd_mac_addr_what =
8383 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
8385 cmdline_parse_token_num_t cmd_mac_addr_portnum =
8386 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num,
8388 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
8389 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
8391 cmdline_parse_inst_t cmd_mac_addr = {
8392 .f = cmd_mac_addr_parsed,
8394 .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
8395 "Add/Remove/Set MAC address on port_id",
8397 (void *)&cmd_mac_addr_cmd,
8398 (void *)&cmd_mac_addr_what,
8399 (void *)&cmd_mac_addr_portnum,
8400 (void *)&cmd_mac_addr_addr,
8405 /* *** SET THE PEER ADDRESS FOR CERTAIN PORT *** */
8406 struct cmd_eth_peer_result {
8407 cmdline_fixed_string_t set;
8408 cmdline_fixed_string_t eth_peer;
8410 cmdline_fixed_string_t peer_addr;
8413 static void cmd_set_eth_peer_parsed(void *parsed_result,
8414 __rte_unused struct cmdline *cl,
8415 __rte_unused void *data)
8417 struct cmd_eth_peer_result *res = parsed_result;
8419 if (test_done == 0) {
8420 printf("Please stop forwarding first\n");
8423 if (!strcmp(res->eth_peer, "eth-peer")) {
8424 set_fwd_eth_peer(res->port_id, res->peer_addr);
8428 cmdline_parse_token_string_t cmd_eth_peer_set =
8429 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, set, "set");
8430 cmdline_parse_token_string_t cmd_eth_peer =
8431 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, eth_peer, "eth-peer");
8432 cmdline_parse_token_num_t cmd_eth_peer_port_id =
8433 TOKEN_NUM_INITIALIZER(struct cmd_eth_peer_result, port_id, UINT16);
8434 cmdline_parse_token_string_t cmd_eth_peer_addr =
8435 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, peer_addr, NULL);
8437 cmdline_parse_inst_t cmd_set_fwd_eth_peer = {
8438 .f = cmd_set_eth_peer_parsed,
8440 .help_str = "set eth-peer <port_id> <peer_mac>",
8442 (void *)&cmd_eth_peer_set,
8443 (void *)&cmd_eth_peer,
8444 (void *)&cmd_eth_peer_port_id,
8445 (void *)&cmd_eth_peer_addr,
8450 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
8451 struct cmd_set_qmap_result {
8452 cmdline_fixed_string_t set;
8453 cmdline_fixed_string_t qmap;
8454 cmdline_fixed_string_t what;
8461 cmd_set_qmap_parsed(void *parsed_result,
8462 __rte_unused struct cmdline *cl,
8463 __rte_unused void *data)
8465 struct cmd_set_qmap_result *res = parsed_result;
8466 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
8468 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
8471 cmdline_parse_token_string_t cmd_setqmap_set =
8472 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8474 cmdline_parse_token_string_t cmd_setqmap_qmap =
8475 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8477 cmdline_parse_token_string_t cmd_setqmap_what =
8478 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8480 cmdline_parse_token_num_t cmd_setqmap_portid =
8481 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8483 cmdline_parse_token_num_t cmd_setqmap_queueid =
8484 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8486 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
8487 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8490 cmdline_parse_inst_t cmd_set_qmap = {
8491 .f = cmd_set_qmap_parsed,
8493 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
8494 "Set statistics mapping value on tx|rx queue_id of port_id",
8496 (void *)&cmd_setqmap_set,
8497 (void *)&cmd_setqmap_qmap,
8498 (void *)&cmd_setqmap_what,
8499 (void *)&cmd_setqmap_portid,
8500 (void *)&cmd_setqmap_queueid,
8501 (void *)&cmd_setqmap_mapvalue,
8506 /* *** SET OPTION TO HIDE ZERO VALUES FOR XSTATS DISPLAY *** */
8507 struct cmd_set_xstats_hide_zero_result {
8508 cmdline_fixed_string_t keyword;
8509 cmdline_fixed_string_t name;
8510 cmdline_fixed_string_t on_off;
8514 cmd_set_xstats_hide_zero_parsed(void *parsed_result,
8515 __rte_unused struct cmdline *cl,
8516 __rte_unused void *data)
8518 struct cmd_set_xstats_hide_zero_result *res;
8519 uint16_t on_off = 0;
8521 res = parsed_result;
8522 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8523 set_xstats_hide_zero(on_off);
8526 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_keyword =
8527 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8529 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_name =
8530 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8531 name, "xstats-hide-zero");
8532 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_on_off =
8533 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8536 cmdline_parse_inst_t cmd_set_xstats_hide_zero = {
8537 .f = cmd_set_xstats_hide_zero_parsed,
8539 .help_str = "set xstats-hide-zero on|off",
8541 (void *)&cmd_set_xstats_hide_zero_keyword,
8542 (void *)&cmd_set_xstats_hide_zero_name,
8543 (void *)&cmd_set_xstats_hide_zero_on_off,
8548 /* *** SET OPTION TO ENABLE MEASUREMENT OF CPU CYCLES *** */
8549 struct cmd_set_record_core_cycles_result {
8550 cmdline_fixed_string_t keyword;
8551 cmdline_fixed_string_t name;
8552 cmdline_fixed_string_t on_off;
8556 cmd_set_record_core_cycles_parsed(void *parsed_result,
8557 __rte_unused struct cmdline *cl,
8558 __rte_unused void *data)
8560 struct cmd_set_record_core_cycles_result *res;
8561 uint16_t on_off = 0;
8563 res = parsed_result;
8564 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8565 set_record_core_cycles(on_off);
8568 cmdline_parse_token_string_t cmd_set_record_core_cycles_keyword =
8569 TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
8571 cmdline_parse_token_string_t cmd_set_record_core_cycles_name =
8572 TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
8573 name, "record-core-cycles");
8574 cmdline_parse_token_string_t cmd_set_record_core_cycles_on_off =
8575 TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
8578 cmdline_parse_inst_t cmd_set_record_core_cycles = {
8579 .f = cmd_set_record_core_cycles_parsed,
8581 .help_str = "set record-core-cycles on|off",
8583 (void *)&cmd_set_record_core_cycles_keyword,
8584 (void *)&cmd_set_record_core_cycles_name,
8585 (void *)&cmd_set_record_core_cycles_on_off,
8590 /* *** SET OPTION TO ENABLE DISPLAY OF RX AND TX BURSTS *** */
8591 struct cmd_set_record_burst_stats_result {
8592 cmdline_fixed_string_t keyword;
8593 cmdline_fixed_string_t name;
8594 cmdline_fixed_string_t on_off;
8598 cmd_set_record_burst_stats_parsed(void *parsed_result,
8599 __rte_unused struct cmdline *cl,
8600 __rte_unused void *data)
8602 struct cmd_set_record_burst_stats_result *res;
8603 uint16_t on_off = 0;
8605 res = parsed_result;
8606 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8607 set_record_burst_stats(on_off);
8610 cmdline_parse_token_string_t cmd_set_record_burst_stats_keyword =
8611 TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
8613 cmdline_parse_token_string_t cmd_set_record_burst_stats_name =
8614 TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
8615 name, "record-burst-stats");
8616 cmdline_parse_token_string_t cmd_set_record_burst_stats_on_off =
8617 TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
8620 cmdline_parse_inst_t cmd_set_record_burst_stats = {
8621 .f = cmd_set_record_burst_stats_parsed,
8623 .help_str = "set record-burst-stats on|off",
8625 (void *)&cmd_set_record_burst_stats_keyword,
8626 (void *)&cmd_set_record_burst_stats_name,
8627 (void *)&cmd_set_record_burst_stats_on_off,
8632 /* *** CONFIGURE UNICAST HASH TABLE *** */
8633 struct cmd_set_uc_hash_table {
8634 cmdline_fixed_string_t set;
8635 cmdline_fixed_string_t port;
8637 cmdline_fixed_string_t what;
8638 struct rte_ether_addr address;
8639 cmdline_fixed_string_t mode;
8643 cmd_set_uc_hash_parsed(void *parsed_result,
8644 __rte_unused struct cmdline *cl,
8645 __rte_unused void *data)
8648 struct cmd_set_uc_hash_table *res = parsed_result;
8650 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8652 if (strcmp(res->what, "uta") == 0)
8653 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
8654 &res->address,(uint8_t)is_on);
8656 printf("bad unicast hash table parameter, return code = %d \n", ret);
8660 cmdline_parse_token_string_t cmd_set_uc_hash_set =
8661 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8663 cmdline_parse_token_string_t cmd_set_uc_hash_port =
8664 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8666 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
8667 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
8669 cmdline_parse_token_string_t cmd_set_uc_hash_what =
8670 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8672 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
8673 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
8675 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
8676 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8679 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
8680 .f = cmd_set_uc_hash_parsed,
8682 .help_str = "set port <port_id> uta <mac_addr> on|off)",
8684 (void *)&cmd_set_uc_hash_set,
8685 (void *)&cmd_set_uc_hash_port,
8686 (void *)&cmd_set_uc_hash_portid,
8687 (void *)&cmd_set_uc_hash_what,
8688 (void *)&cmd_set_uc_hash_mac,
8689 (void *)&cmd_set_uc_hash_mode,
8694 struct cmd_set_uc_all_hash_table {
8695 cmdline_fixed_string_t set;
8696 cmdline_fixed_string_t port;
8698 cmdline_fixed_string_t what;
8699 cmdline_fixed_string_t value;
8700 cmdline_fixed_string_t mode;
8704 cmd_set_uc_all_hash_parsed(void *parsed_result,
8705 __rte_unused struct cmdline *cl,
8706 __rte_unused void *data)
8709 struct cmd_set_uc_all_hash_table *res = parsed_result;
8711 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8713 if ((strcmp(res->what, "uta") == 0) &&
8714 (strcmp(res->value, "all") == 0))
8715 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
8717 printf("bad unicast hash table parameter,"
8718 "return code = %d \n", ret);
8721 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
8722 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8724 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
8725 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8727 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
8728 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
8730 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
8731 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8733 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
8734 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8736 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
8737 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8740 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
8741 .f = cmd_set_uc_all_hash_parsed,
8743 .help_str = "set port <port_id> uta all on|off",
8745 (void *)&cmd_set_uc_all_hash_set,
8746 (void *)&cmd_set_uc_all_hash_port,
8747 (void *)&cmd_set_uc_all_hash_portid,
8748 (void *)&cmd_set_uc_all_hash_what,
8749 (void *)&cmd_set_uc_all_hash_value,
8750 (void *)&cmd_set_uc_all_hash_mode,
8755 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
8756 struct cmd_set_vf_traffic {
8757 cmdline_fixed_string_t set;
8758 cmdline_fixed_string_t port;
8760 cmdline_fixed_string_t vf;
8762 cmdline_fixed_string_t what;
8763 cmdline_fixed_string_t mode;
8767 cmd_set_vf_traffic_parsed(void *parsed_result,
8768 __rte_unused struct cmdline *cl,
8769 __rte_unused void *data)
8771 struct cmd_set_vf_traffic *res = parsed_result;
8772 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
8773 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8775 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
8778 cmdline_parse_token_string_t cmd_setvf_traffic_set =
8779 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8781 cmdline_parse_token_string_t cmd_setvf_traffic_port =
8782 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8784 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
8785 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8787 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
8788 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8790 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
8791 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8793 cmdline_parse_token_string_t cmd_setvf_traffic_what =
8794 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8796 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
8797 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8800 cmdline_parse_inst_t cmd_set_vf_traffic = {
8801 .f = cmd_set_vf_traffic_parsed,
8803 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
8805 (void *)&cmd_setvf_traffic_set,
8806 (void *)&cmd_setvf_traffic_port,
8807 (void *)&cmd_setvf_traffic_portid,
8808 (void *)&cmd_setvf_traffic_vf,
8809 (void *)&cmd_setvf_traffic_vfid,
8810 (void *)&cmd_setvf_traffic_what,
8811 (void *)&cmd_setvf_traffic_mode,
8816 /* *** CONFIGURE VF RECEIVE MODE *** */
8817 struct cmd_set_vf_rxmode {
8818 cmdline_fixed_string_t set;
8819 cmdline_fixed_string_t port;
8821 cmdline_fixed_string_t vf;
8823 cmdline_fixed_string_t what;
8824 cmdline_fixed_string_t mode;
8825 cmdline_fixed_string_t on;
8829 cmd_set_vf_rxmode_parsed(void *parsed_result,
8830 __rte_unused struct cmdline *cl,
8831 __rte_unused void *data)
8834 uint16_t vf_rxmode = 0;
8835 struct cmd_set_vf_rxmode *res = parsed_result;
8837 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
8838 if (!strcmp(res->what,"rxmode")) {
8839 if (!strcmp(res->mode, "AUPE"))
8840 vf_rxmode |= ETH_VMDQ_ACCEPT_UNTAG;
8841 else if (!strcmp(res->mode, "ROPE"))
8842 vf_rxmode |= ETH_VMDQ_ACCEPT_HASH_UC;
8843 else if (!strcmp(res->mode, "BAM"))
8844 vf_rxmode |= ETH_VMDQ_ACCEPT_BROADCAST;
8845 else if (!strncmp(res->mode, "MPE",3))
8846 vf_rxmode |= ETH_VMDQ_ACCEPT_MULTICAST;
8849 RTE_SET_USED(is_on);
8851 #ifdef RTE_NET_IXGBE
8852 if (ret == -ENOTSUP)
8853 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id,
8854 vf_rxmode, (uint8_t)is_on);
8857 if (ret == -ENOTSUP)
8858 ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id,
8859 vf_rxmode, (uint8_t)is_on);
8862 printf("bad VF receive mode parameter, return code = %d \n",
8866 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
8867 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8869 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
8870 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8872 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
8873 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8875 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
8876 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8878 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
8879 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8881 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
8882 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8884 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
8885 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8886 mode, "AUPE#ROPE#BAM#MPE");
8887 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
8888 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8891 cmdline_parse_inst_t cmd_set_vf_rxmode = {
8892 .f = cmd_set_vf_rxmode_parsed,
8894 .help_str = "set port <port_id> vf <vf_id> rxmode "
8895 "AUPE|ROPE|BAM|MPE on|off",
8897 (void *)&cmd_set_vf_rxmode_set,
8898 (void *)&cmd_set_vf_rxmode_port,
8899 (void *)&cmd_set_vf_rxmode_portid,
8900 (void *)&cmd_set_vf_rxmode_vf,
8901 (void *)&cmd_set_vf_rxmode_vfid,
8902 (void *)&cmd_set_vf_rxmode_what,
8903 (void *)&cmd_set_vf_rxmode_mode,
8904 (void *)&cmd_set_vf_rxmode_on,
8909 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
8910 struct cmd_vf_mac_addr_result {
8911 cmdline_fixed_string_t mac_addr_cmd;
8912 cmdline_fixed_string_t what;
8913 cmdline_fixed_string_t port;
8915 cmdline_fixed_string_t vf;
8917 struct rte_ether_addr address;
8920 static void cmd_vf_mac_addr_parsed(void *parsed_result,
8921 __rte_unused struct cmdline *cl,
8922 __rte_unused void *data)
8924 struct cmd_vf_mac_addr_result *res = parsed_result;
8927 if (strcmp(res->what, "add") != 0)
8931 if (ret == -ENOTSUP)
8932 ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num,
8936 if (ret == -ENOTSUP)
8937 ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address,
8942 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
8946 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
8947 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8948 mac_addr_cmd,"mac_addr");
8949 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
8950 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8952 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
8953 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8955 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
8956 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8958 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
8959 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8961 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
8962 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8964 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
8965 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
8968 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
8969 .f = cmd_vf_mac_addr_parsed,
8971 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
8972 "Add MAC address filtering for a VF on port_id",
8974 (void *)&cmd_vf_mac_addr_cmd,
8975 (void *)&cmd_vf_mac_addr_what,
8976 (void *)&cmd_vf_mac_addr_port,
8977 (void *)&cmd_vf_mac_addr_portnum,
8978 (void *)&cmd_vf_mac_addr_vf,
8979 (void *)&cmd_vf_mac_addr_vfnum,
8980 (void *)&cmd_vf_mac_addr_addr,
8985 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
8986 struct cmd_vf_rx_vlan_filter {
8987 cmdline_fixed_string_t rx_vlan;
8988 cmdline_fixed_string_t what;
8990 cmdline_fixed_string_t port;
8992 cmdline_fixed_string_t vf;
8997 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
8998 __rte_unused struct cmdline *cl,
8999 __rte_unused void *data)
9001 struct cmd_vf_rx_vlan_filter *res = parsed_result;
9004 __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
9006 #ifdef RTE_NET_IXGBE
9007 if (ret == -ENOTSUP)
9008 ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
9009 res->vlan_id, res->vf_mask, is_add);
9012 if (ret == -ENOTSUP)
9013 ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
9014 res->vlan_id, res->vf_mask, is_add);
9017 if (ret == -ENOTSUP)
9018 ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id,
9019 res->vlan_id, res->vf_mask, is_add);
9026 printf("invalid vlan_id %d or vf_mask %"PRIu64"\n",
9027 res->vlan_id, res->vf_mask);
9030 printf("invalid port_id %d\n", res->port_id);
9033 printf("function not implemented or supported\n");
9036 printf("programming error: (%s)\n", strerror(-ret));
9040 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
9041 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9042 rx_vlan, "rx_vlan");
9043 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
9044 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9046 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
9047 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9049 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
9050 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9052 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
9053 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9055 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
9056 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9058 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
9059 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9062 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
9063 .f = cmd_vf_rx_vlan_filter_parsed,
9065 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
9066 "(vf_mask = hexadecimal VF mask)",
9068 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
9069 (void *)&cmd_vf_rx_vlan_filter_what,
9070 (void *)&cmd_vf_rx_vlan_filter_vlanid,
9071 (void *)&cmd_vf_rx_vlan_filter_port,
9072 (void *)&cmd_vf_rx_vlan_filter_portid,
9073 (void *)&cmd_vf_rx_vlan_filter_vf,
9074 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
9079 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
9080 struct cmd_queue_rate_limit_result {
9081 cmdline_fixed_string_t set;
9082 cmdline_fixed_string_t port;
9084 cmdline_fixed_string_t queue;
9086 cmdline_fixed_string_t rate;
9090 static void cmd_queue_rate_limit_parsed(void *parsed_result,
9091 __rte_unused struct cmdline *cl,
9092 __rte_unused void *data)
9094 struct cmd_queue_rate_limit_result *res = parsed_result;
9097 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
9098 && (strcmp(res->queue, "queue") == 0)
9099 && (strcmp(res->rate, "rate") == 0))
9100 ret = set_queue_rate_limit(res->port_num, res->queue_num,
9103 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
9107 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
9108 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9110 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
9111 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9113 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
9114 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
9116 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
9117 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9119 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
9120 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
9122 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
9123 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9125 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
9126 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
9129 cmdline_parse_inst_t cmd_queue_rate_limit = {
9130 .f = cmd_queue_rate_limit_parsed,
9132 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
9133 "Set rate limit for a queue on port_id",
9135 (void *)&cmd_queue_rate_limit_set,
9136 (void *)&cmd_queue_rate_limit_port,
9137 (void *)&cmd_queue_rate_limit_portnum,
9138 (void *)&cmd_queue_rate_limit_queue,
9139 (void *)&cmd_queue_rate_limit_queuenum,
9140 (void *)&cmd_queue_rate_limit_rate,
9141 (void *)&cmd_queue_rate_limit_ratenum,
9146 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
9147 struct cmd_vf_rate_limit_result {
9148 cmdline_fixed_string_t set;
9149 cmdline_fixed_string_t port;
9151 cmdline_fixed_string_t vf;
9153 cmdline_fixed_string_t rate;
9155 cmdline_fixed_string_t q_msk;
9159 static void cmd_vf_rate_limit_parsed(void *parsed_result,
9160 __rte_unused struct cmdline *cl,
9161 __rte_unused void *data)
9163 struct cmd_vf_rate_limit_result *res = parsed_result;
9166 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
9167 && (strcmp(res->vf, "vf") == 0)
9168 && (strcmp(res->rate, "rate") == 0)
9169 && (strcmp(res->q_msk, "queue_mask") == 0))
9170 ret = set_vf_rate_limit(res->port_num, res->vf_num,
9171 res->rate_num, res->q_msk_val);
9173 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
9177 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
9178 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9180 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
9181 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9183 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
9184 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9186 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
9187 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9189 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
9190 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9192 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
9193 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9195 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
9196 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9198 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
9199 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9200 q_msk, "queue_mask");
9201 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
9202 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9205 cmdline_parse_inst_t cmd_vf_rate_limit = {
9206 .f = cmd_vf_rate_limit_parsed,
9208 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
9209 "queue_mask <queue_mask_value>: "
9210 "Set rate limit for queues of VF on port_id",
9212 (void *)&cmd_vf_rate_limit_set,
9213 (void *)&cmd_vf_rate_limit_port,
9214 (void *)&cmd_vf_rate_limit_portnum,
9215 (void *)&cmd_vf_rate_limit_vf,
9216 (void *)&cmd_vf_rate_limit_vfnum,
9217 (void *)&cmd_vf_rate_limit_rate,
9218 (void *)&cmd_vf_rate_limit_ratenum,
9219 (void *)&cmd_vf_rate_limit_q_msk,
9220 (void *)&cmd_vf_rate_limit_q_msk_val,
9225 /* *** ADD TUNNEL FILTER OF A PORT *** */
9226 struct cmd_tunnel_filter_result {
9227 cmdline_fixed_string_t cmd;
9228 cmdline_fixed_string_t what;
9230 struct rte_ether_addr outer_mac;
9231 struct rte_ether_addr inner_mac;
9232 cmdline_ipaddr_t ip_value;
9233 uint16_t inner_vlan;
9234 cmdline_fixed_string_t tunnel_type;
9235 cmdline_fixed_string_t filter_type;
9241 cmd_tunnel_filter_parsed(void *parsed_result,
9242 __rte_unused struct cmdline *cl,
9243 __rte_unused void *data)
9245 struct cmd_tunnel_filter_result *res = parsed_result;
9246 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
9249 memset(&tunnel_filter_conf, 0, sizeof(tunnel_filter_conf));
9251 rte_ether_addr_copy(&res->outer_mac, &tunnel_filter_conf.outer_mac);
9252 rte_ether_addr_copy(&res->inner_mac, &tunnel_filter_conf.inner_mac);
9253 tunnel_filter_conf.inner_vlan = res->inner_vlan;
9255 if (res->ip_value.family == AF_INET) {
9256 tunnel_filter_conf.ip_addr.ipv4_addr =
9257 res->ip_value.addr.ipv4.s_addr;
9258 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
9260 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
9261 &(res->ip_value.addr.ipv6),
9262 sizeof(struct in6_addr));
9263 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
9266 if (!strcmp(res->filter_type, "imac-ivlan"))
9267 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
9268 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
9269 tunnel_filter_conf.filter_type =
9270 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
9271 else if (!strcmp(res->filter_type, "imac-tenid"))
9272 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
9273 else if (!strcmp(res->filter_type, "imac"))
9274 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
9275 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
9276 tunnel_filter_conf.filter_type =
9277 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
9278 else if (!strcmp(res->filter_type, "oip"))
9279 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_OIP;
9280 else if (!strcmp(res->filter_type, "iip"))
9281 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IIP;
9283 printf("The filter type is not supported");
9287 if (!strcmp(res->tunnel_type, "vxlan"))
9288 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
9289 else if (!strcmp(res->tunnel_type, "vxlan-gpe"))
9290 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN_GPE;
9291 else if (!strcmp(res->tunnel_type, "nvgre"))
9292 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE;
9293 else if (!strcmp(res->tunnel_type, "ipingre"))
9294 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_IP_IN_GRE;
9296 printf("The tunnel type %s not supported.\n", res->tunnel_type);
9300 tunnel_filter_conf.tenant_id = res->tenant_id;
9301 tunnel_filter_conf.queue_id = res->queue_num;
9302 if (!strcmp(res->what, "add"))
9303 ret = rte_eth_dev_filter_ctrl(res->port_id,
9304 RTE_ETH_FILTER_TUNNEL,
9306 &tunnel_filter_conf);
9308 ret = rte_eth_dev_filter_ctrl(res->port_id,
9309 RTE_ETH_FILTER_TUNNEL,
9310 RTE_ETH_FILTER_DELETE,
9311 &tunnel_filter_conf);
9313 printf("cmd_tunnel_filter_parsed error: (%s)\n",
9317 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
9318 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
9319 cmd, "tunnel_filter");
9320 cmdline_parse_token_string_t cmd_tunnel_filter_what =
9321 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
9323 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
9324 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
9326 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
9327 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
9329 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
9330 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
9332 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
9333 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
9334 inner_vlan, UINT16);
9335 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
9336 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
9338 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
9339 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
9340 tunnel_type, "vxlan#nvgre#ipingre#vxlan-gpe");
9342 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
9343 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
9344 filter_type, "oip#iip#imac-ivlan#imac-ivlan-tenid#imac-tenid#"
9345 "imac#omac-imac-tenid");
9346 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
9347 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
9349 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
9350 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
9353 cmdline_parse_inst_t cmd_tunnel_filter = {
9354 .f = cmd_tunnel_filter_parsed,
9356 .help_str = "tunnel_filter add|rm <port_id> <outer_mac> <inner_mac> "
9357 "<ip> <inner_vlan> vxlan|nvgre|ipingre oip|iip|imac-ivlan|"
9358 "imac-ivlan-tenid|imac-tenid|imac|omac-imac-tenid <tenant_id> "
9359 "<queue_id>: Add/Rm tunnel filter of a port",
9361 (void *)&cmd_tunnel_filter_cmd,
9362 (void *)&cmd_tunnel_filter_what,
9363 (void *)&cmd_tunnel_filter_port_id,
9364 (void *)&cmd_tunnel_filter_outer_mac,
9365 (void *)&cmd_tunnel_filter_inner_mac,
9366 (void *)&cmd_tunnel_filter_ip_value,
9367 (void *)&cmd_tunnel_filter_innner_vlan,
9368 (void *)&cmd_tunnel_filter_tunnel_type,
9369 (void *)&cmd_tunnel_filter_filter_type,
9370 (void *)&cmd_tunnel_filter_tenant_id,
9371 (void *)&cmd_tunnel_filter_queue_num,
9376 /* *** CONFIGURE TUNNEL UDP PORT *** */
9377 struct cmd_tunnel_udp_config {
9378 cmdline_fixed_string_t cmd;
9379 cmdline_fixed_string_t what;
9385 cmd_tunnel_udp_config_parsed(void *parsed_result,
9386 __rte_unused struct cmdline *cl,
9387 __rte_unused void *data)
9389 struct cmd_tunnel_udp_config *res = parsed_result;
9390 struct rte_eth_udp_tunnel tunnel_udp;
9393 tunnel_udp.udp_port = res->udp_port;
9395 if (!strcmp(res->cmd, "rx_vxlan_port"))
9396 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
9398 if (!strcmp(res->what, "add"))
9399 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9402 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9406 printf("udp tunneling add error: (%s)\n", strerror(-ret));
9409 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
9410 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9411 cmd, "rx_vxlan_port");
9412 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
9413 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9415 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
9416 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9418 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
9419 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9422 cmdline_parse_inst_t cmd_tunnel_udp_config = {
9423 .f = cmd_tunnel_udp_config_parsed,
9425 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
9426 "Add/Remove a tunneling UDP port filter",
9428 (void *)&cmd_tunnel_udp_config_cmd,
9429 (void *)&cmd_tunnel_udp_config_what,
9430 (void *)&cmd_tunnel_udp_config_udp_port,
9431 (void *)&cmd_tunnel_udp_config_port_id,
9436 struct cmd_config_tunnel_udp_port {
9437 cmdline_fixed_string_t port;
9438 cmdline_fixed_string_t config;
9440 cmdline_fixed_string_t udp_tunnel_port;
9441 cmdline_fixed_string_t action;
9442 cmdline_fixed_string_t tunnel_type;
9447 cmd_cfg_tunnel_udp_port_parsed(void *parsed_result,
9448 __rte_unused struct cmdline *cl,
9449 __rte_unused void *data)
9451 struct cmd_config_tunnel_udp_port *res = parsed_result;
9452 struct rte_eth_udp_tunnel tunnel_udp;
9455 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9458 tunnel_udp.udp_port = res->udp_port;
9460 if (!strcmp(res->tunnel_type, "vxlan")) {
9461 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
9462 } else if (!strcmp(res->tunnel_type, "geneve")) {
9463 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_GENEVE;
9464 } else if (!strcmp(res->tunnel_type, "vxlan-gpe")) {
9465 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN_GPE;
9467 printf("Invalid tunnel type\n");
9471 if (!strcmp(res->action, "add"))
9472 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9475 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9479 printf("udp tunneling port add error: (%s)\n", strerror(-ret));
9482 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_port =
9483 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, port,
9485 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_config =
9486 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, config,
9488 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_port_id =
9489 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, port_id,
9491 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_port =
9492 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port,
9495 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_action =
9496 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, action,
9498 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_type =
9499 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, tunnel_type,
9500 "vxlan#geneve#vxlan-gpe");
9501 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_value =
9502 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, udp_port,
9505 cmdline_parse_inst_t cmd_cfg_tunnel_udp_port = {
9506 .f = cmd_cfg_tunnel_udp_port_parsed,
9508 .help_str = "port config <port_id> udp_tunnel_port add|rm vxlan|geneve|vxlan-gpe <udp_port>",
9510 (void *)&cmd_config_tunnel_udp_port_port,
9511 (void *)&cmd_config_tunnel_udp_port_config,
9512 (void *)&cmd_config_tunnel_udp_port_port_id,
9513 (void *)&cmd_config_tunnel_udp_port_tunnel_port,
9514 (void *)&cmd_config_tunnel_udp_port_action,
9515 (void *)&cmd_config_tunnel_udp_port_tunnel_type,
9516 (void *)&cmd_config_tunnel_udp_port_value,
9521 /* *** GLOBAL CONFIG *** */
9522 struct cmd_global_config_result {
9523 cmdline_fixed_string_t cmd;
9525 cmdline_fixed_string_t cfg_type;
9530 cmd_global_config_parsed(void *parsed_result,
9531 __rte_unused struct cmdline *cl,
9532 __rte_unused void *data)
9534 struct cmd_global_config_result *res = parsed_result;
9535 struct rte_eth_global_cfg conf;
9538 memset(&conf, 0, sizeof(conf));
9539 conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN;
9540 conf.cfg.gre_key_len = res->len;
9541 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE,
9542 RTE_ETH_FILTER_SET, &conf);
9544 if (ret == -ENOTSUP)
9545 ret = rte_pmd_i40e_set_gre_key_len(res->port_id, res->len);
9548 printf("Global config error\n");
9551 cmdline_parse_token_string_t cmd_global_config_cmd =
9552 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd,
9554 cmdline_parse_token_num_t cmd_global_config_port_id =
9555 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id,
9557 cmdline_parse_token_string_t cmd_global_config_type =
9558 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result,
9559 cfg_type, "gre-key-len");
9560 cmdline_parse_token_num_t cmd_global_config_gre_key_len =
9561 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result,
9564 cmdline_parse_inst_t cmd_global_config = {
9565 .f = cmd_global_config_parsed,
9566 .data = (void *)NULL,
9567 .help_str = "global_config <port_id> gre-key-len <key_len>",
9569 (void *)&cmd_global_config_cmd,
9570 (void *)&cmd_global_config_port_id,
9571 (void *)&cmd_global_config_type,
9572 (void *)&cmd_global_config_gre_key_len,
9577 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
9578 struct cmd_set_mirror_mask_result {
9579 cmdline_fixed_string_t set;
9580 cmdline_fixed_string_t port;
9582 cmdline_fixed_string_t mirror;
9584 cmdline_fixed_string_t what;
9585 cmdline_fixed_string_t value;
9586 cmdline_fixed_string_t dstpool;
9588 cmdline_fixed_string_t on;
9591 cmdline_parse_token_string_t cmd_mirror_mask_set =
9592 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9594 cmdline_parse_token_string_t cmd_mirror_mask_port =
9595 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9597 cmdline_parse_token_num_t cmd_mirror_mask_portid =
9598 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9600 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
9601 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9602 mirror, "mirror-rule");
9603 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
9604 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9606 cmdline_parse_token_string_t cmd_mirror_mask_what =
9607 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9608 what, "pool-mirror-up#pool-mirror-down"
9610 cmdline_parse_token_string_t cmd_mirror_mask_value =
9611 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9613 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
9614 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9615 dstpool, "dst-pool");
9616 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
9617 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9619 cmdline_parse_token_string_t cmd_mirror_mask_on =
9620 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9624 cmd_set_mirror_mask_parsed(void *parsed_result,
9625 __rte_unused struct cmdline *cl,
9626 __rte_unused void *data)
9629 struct cmd_set_mirror_mask_result *res = parsed_result;
9630 struct rte_eth_mirror_conf mr_conf;
9632 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
9634 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
9636 mr_conf.dst_pool = res->dstpool_id;
9638 if (!strcmp(res->what, "pool-mirror-up")) {
9639 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
9640 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
9641 } else if (!strcmp(res->what, "pool-mirror-down")) {
9642 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
9643 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
9644 } else if (!strcmp(res->what, "vlan-mirror")) {
9645 mr_conf.rule_type = ETH_MIRROR_VLAN;
9646 nb_item = parse_item_list(res->value, "vlan",
9647 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
9651 for (i = 0; i < nb_item; i++) {
9652 if (vlan_list[i] > RTE_ETHER_MAX_VLAN_ID) {
9653 printf("Invalid vlan_id: must be < 4096\n");
9657 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
9658 mr_conf.vlan.vlan_mask |= 1ULL << i;
9662 if (!strcmp(res->on, "on"))
9663 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9666 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9669 printf("mirror rule add error: (%s)\n", strerror(-ret));
9672 cmdline_parse_inst_t cmd_set_mirror_mask = {
9673 .f = cmd_set_mirror_mask_parsed,
9675 .help_str = "set port <port_id> mirror-rule <rule_id> "
9676 "pool-mirror-up|pool-mirror-down|vlan-mirror "
9677 "<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off",
9679 (void *)&cmd_mirror_mask_set,
9680 (void *)&cmd_mirror_mask_port,
9681 (void *)&cmd_mirror_mask_portid,
9682 (void *)&cmd_mirror_mask_mirror,
9683 (void *)&cmd_mirror_mask_ruleid,
9684 (void *)&cmd_mirror_mask_what,
9685 (void *)&cmd_mirror_mask_value,
9686 (void *)&cmd_mirror_mask_dstpool,
9687 (void *)&cmd_mirror_mask_poolid,
9688 (void *)&cmd_mirror_mask_on,
9693 /* *** CONFIGURE VM MIRROR UPLINK/DOWNLINK RULE *** */
9694 struct cmd_set_mirror_link_result {
9695 cmdline_fixed_string_t set;
9696 cmdline_fixed_string_t port;
9698 cmdline_fixed_string_t mirror;
9700 cmdline_fixed_string_t what;
9701 cmdline_fixed_string_t dstpool;
9703 cmdline_fixed_string_t on;
9706 cmdline_parse_token_string_t cmd_mirror_link_set =
9707 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9709 cmdline_parse_token_string_t cmd_mirror_link_port =
9710 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9712 cmdline_parse_token_num_t cmd_mirror_link_portid =
9713 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9715 cmdline_parse_token_string_t cmd_mirror_link_mirror =
9716 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9717 mirror, "mirror-rule");
9718 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
9719 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9721 cmdline_parse_token_string_t cmd_mirror_link_what =
9722 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9723 what, "uplink-mirror#downlink-mirror");
9724 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
9725 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9726 dstpool, "dst-pool");
9727 cmdline_parse_token_num_t cmd_mirror_link_poolid =
9728 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9730 cmdline_parse_token_string_t cmd_mirror_link_on =
9731 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9735 cmd_set_mirror_link_parsed(void *parsed_result,
9736 __rte_unused struct cmdline *cl,
9737 __rte_unused void *data)
9740 struct cmd_set_mirror_link_result *res = parsed_result;
9741 struct rte_eth_mirror_conf mr_conf;
9743 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
9744 if (!strcmp(res->what, "uplink-mirror"))
9745 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
9747 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
9749 mr_conf.dst_pool = res->dstpool_id;
9751 if (!strcmp(res->on, "on"))
9752 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9755 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9758 /* check the return value and print it if is < 0 */
9760 printf("mirror rule add error: (%s)\n", strerror(-ret));
9764 cmdline_parse_inst_t cmd_set_mirror_link = {
9765 .f = cmd_set_mirror_link_parsed,
9767 .help_str = "set port <port_id> mirror-rule <rule_id> "
9768 "uplink-mirror|downlink-mirror dst-pool <pool_id> on|off",
9770 (void *)&cmd_mirror_link_set,
9771 (void *)&cmd_mirror_link_port,
9772 (void *)&cmd_mirror_link_portid,
9773 (void *)&cmd_mirror_link_mirror,
9774 (void *)&cmd_mirror_link_ruleid,
9775 (void *)&cmd_mirror_link_what,
9776 (void *)&cmd_mirror_link_dstpool,
9777 (void *)&cmd_mirror_link_poolid,
9778 (void *)&cmd_mirror_link_on,
9783 /* *** RESET VM MIRROR RULE *** */
9784 struct cmd_rm_mirror_rule_result {
9785 cmdline_fixed_string_t reset;
9786 cmdline_fixed_string_t port;
9788 cmdline_fixed_string_t mirror;
9792 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
9793 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9795 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
9796 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9798 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
9799 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9801 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
9802 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9803 mirror, "mirror-rule");
9804 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
9805 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9809 cmd_reset_mirror_rule_parsed(void *parsed_result,
9810 __rte_unused struct cmdline *cl,
9811 __rte_unused void *data)
9814 struct cmd_set_mirror_link_result *res = parsed_result;
9816 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
9818 printf("mirror rule remove error: (%s)\n", strerror(-ret));
9821 cmdline_parse_inst_t cmd_reset_mirror_rule = {
9822 .f = cmd_reset_mirror_rule_parsed,
9824 .help_str = "reset port <port_id> mirror-rule <rule_id>",
9826 (void *)&cmd_rm_mirror_rule_reset,
9827 (void *)&cmd_rm_mirror_rule_port,
9828 (void *)&cmd_rm_mirror_rule_portid,
9829 (void *)&cmd_rm_mirror_rule_mirror,
9830 (void *)&cmd_rm_mirror_rule_ruleid,
9835 /* ******************************************************************************** */
9837 struct cmd_dump_result {
9838 cmdline_fixed_string_t dump;
9842 dump_struct_sizes(void)
9844 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
9845 DUMP_SIZE(struct rte_mbuf);
9846 DUMP_SIZE(struct rte_mempool);
9847 DUMP_SIZE(struct rte_ring);
9852 /* Dump the socket memory statistics on console */
9854 dump_socket_mem(FILE *f)
9856 struct rte_malloc_socket_stats socket_stats;
9861 unsigned int n_alloc = 0;
9862 unsigned int n_free = 0;
9863 static size_t last_allocs;
9864 static size_t last_total;
9867 for (i = 0; i < RTE_MAX_NUMA_NODES; i++) {
9868 if (rte_malloc_get_socket_stats(i, &socket_stats) ||
9869 !socket_stats.heap_totalsz_bytes)
9871 total += socket_stats.heap_totalsz_bytes;
9872 alloc += socket_stats.heap_allocsz_bytes;
9873 free += socket_stats.heap_freesz_bytes;
9874 n_alloc += socket_stats.alloc_count;
9875 n_free += socket_stats.free_count;
9877 "Socket %u: size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n",
9879 (double)socket_stats.heap_totalsz_bytes / (1024 * 1024),
9880 (double)socket_stats.heap_allocsz_bytes / (1024 * 1024),
9881 (double)socket_stats.heap_allocsz_bytes * 100 /
9882 (double)socket_stats.heap_totalsz_bytes,
9883 (double)socket_stats.heap_freesz_bytes / (1024 * 1024),
9884 socket_stats.alloc_count,
9885 socket_stats.free_count);
9888 "Total : size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n",
9889 (double)total / (1024 * 1024), (double)alloc / (1024 * 1024),
9890 (double)alloc * 100 / (double)total,
9891 (double)free / (1024 * 1024),
9894 fprintf(stdout, "Memory total change: %.6lf(M), allocation change: %.6lf(M)\n",
9895 ((double)total - (double)last_total) / (1024 * 1024),
9896 (double)(alloc - (double)last_allocs) / 1024 / 1024);
9897 last_allocs = alloc;
9901 static void cmd_dump_parsed(void *parsed_result,
9902 __rte_unused struct cmdline *cl,
9903 __rte_unused void *data)
9905 struct cmd_dump_result *res = parsed_result;
9907 if (!strcmp(res->dump, "dump_physmem"))
9908 rte_dump_physmem_layout(stdout);
9909 else if (!strcmp(res->dump, "dump_socket_mem"))
9910 dump_socket_mem(stdout);
9911 else if (!strcmp(res->dump, "dump_memzone"))
9912 rte_memzone_dump(stdout);
9913 else if (!strcmp(res->dump, "dump_struct_sizes"))
9914 dump_struct_sizes();
9915 else if (!strcmp(res->dump, "dump_ring"))
9916 rte_ring_list_dump(stdout);
9917 else if (!strcmp(res->dump, "dump_mempool"))
9918 rte_mempool_list_dump(stdout);
9919 else if (!strcmp(res->dump, "dump_devargs"))
9920 rte_devargs_dump(stdout);
9921 else if (!strcmp(res->dump, "dump_log_types"))
9922 rte_log_dump(stdout);
9925 cmdline_parse_token_string_t cmd_dump_dump =
9926 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
9930 "dump_struct_sizes#"
9936 cmdline_parse_inst_t cmd_dump = {
9937 .f = cmd_dump_parsed, /* function to call */
9938 .data = NULL, /* 2nd arg of func */
9939 .help_str = "Dump status",
9940 .tokens = { /* token list, NULL terminated */
9941 (void *)&cmd_dump_dump,
9946 /* ******************************************************************************** */
9948 struct cmd_dump_one_result {
9949 cmdline_fixed_string_t dump;
9950 cmdline_fixed_string_t name;
9953 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
9954 __rte_unused void *data)
9956 struct cmd_dump_one_result *res = parsed_result;
9958 if (!strcmp(res->dump, "dump_ring")) {
9960 r = rte_ring_lookup(res->name);
9962 cmdline_printf(cl, "Cannot find ring\n");
9965 rte_ring_dump(stdout, r);
9966 } else if (!strcmp(res->dump, "dump_mempool")) {
9967 struct rte_mempool *mp;
9968 mp = rte_mempool_lookup(res->name);
9970 cmdline_printf(cl, "Cannot find mempool\n");
9973 rte_mempool_dump(stdout, mp);
9977 cmdline_parse_token_string_t cmd_dump_one_dump =
9978 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
9979 "dump_ring#dump_mempool");
9981 cmdline_parse_token_string_t cmd_dump_one_name =
9982 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
9984 cmdline_parse_inst_t cmd_dump_one = {
9985 .f = cmd_dump_one_parsed, /* function to call */
9986 .data = NULL, /* 2nd arg of func */
9987 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
9988 .tokens = { /* token list, NULL terminated */
9989 (void *)&cmd_dump_one_dump,
9990 (void *)&cmd_dump_one_name,
9995 /* *** Add/Del syn filter *** */
9996 struct cmd_syn_filter_result {
9997 cmdline_fixed_string_t filter;
9999 cmdline_fixed_string_t ops;
10000 cmdline_fixed_string_t priority;
10001 cmdline_fixed_string_t high;
10002 cmdline_fixed_string_t queue;
10007 cmd_syn_filter_parsed(void *parsed_result,
10008 __rte_unused struct cmdline *cl,
10009 __rte_unused void *data)
10011 struct cmd_syn_filter_result *res = parsed_result;
10012 struct rte_eth_syn_filter syn_filter;
10015 ret = rte_eth_dev_filter_supported(res->port_id,
10016 RTE_ETH_FILTER_SYN);
10018 printf("syn filter is not supported on port %u.\n",
10023 memset(&syn_filter, 0, sizeof(syn_filter));
10025 if (!strcmp(res->ops, "add")) {
10026 if (!strcmp(res->high, "high"))
10027 syn_filter.hig_pri = 1;
10029 syn_filter.hig_pri = 0;
10031 syn_filter.queue = res->queue_id;
10032 ret = rte_eth_dev_filter_ctrl(res->port_id,
10033 RTE_ETH_FILTER_SYN,
10034 RTE_ETH_FILTER_ADD,
10037 ret = rte_eth_dev_filter_ctrl(res->port_id,
10038 RTE_ETH_FILTER_SYN,
10039 RTE_ETH_FILTER_DELETE,
10043 printf("syn filter programming error: (%s)\n",
10047 cmdline_parse_token_string_t cmd_syn_filter_filter =
10048 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
10049 filter, "syn_filter");
10050 cmdline_parse_token_num_t cmd_syn_filter_port_id =
10051 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
10053 cmdline_parse_token_string_t cmd_syn_filter_ops =
10054 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
10056 cmdline_parse_token_string_t cmd_syn_filter_priority =
10057 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
10058 priority, "priority");
10059 cmdline_parse_token_string_t cmd_syn_filter_high =
10060 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
10062 cmdline_parse_token_string_t cmd_syn_filter_queue =
10063 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
10065 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
10066 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
10069 cmdline_parse_inst_t cmd_syn_filter = {
10070 .f = cmd_syn_filter_parsed,
10072 .help_str = "syn_filter <port_id> add|del priority high|low queue "
10073 "<queue_id>: Add/Delete syn filter",
10075 (void *)&cmd_syn_filter_filter,
10076 (void *)&cmd_syn_filter_port_id,
10077 (void *)&cmd_syn_filter_ops,
10078 (void *)&cmd_syn_filter_priority,
10079 (void *)&cmd_syn_filter_high,
10080 (void *)&cmd_syn_filter_queue,
10081 (void *)&cmd_syn_filter_queue_id,
10086 /* *** queue region set *** */
10087 struct cmd_queue_region_result {
10088 cmdline_fixed_string_t set;
10089 cmdline_fixed_string_t port;
10091 cmdline_fixed_string_t cmd;
10092 cmdline_fixed_string_t region;
10094 cmdline_fixed_string_t queue_start_index;
10096 cmdline_fixed_string_t queue_num;
10097 uint8_t queue_num_value;
10101 cmd_queue_region_parsed(void *parsed_result,
10102 __rte_unused struct cmdline *cl,
10103 __rte_unused void *data)
10105 struct cmd_queue_region_result *res = parsed_result;
10106 int ret = -ENOTSUP;
10107 #ifdef RTE_NET_I40E
10108 struct rte_pmd_i40e_queue_region_conf region_conf;
10109 enum rte_pmd_i40e_queue_region_op op_type;
10112 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10115 #ifdef RTE_NET_I40E
10116 memset(®ion_conf, 0, sizeof(region_conf));
10117 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_SET;
10118 region_conf.region_id = res->region_id;
10119 region_conf.queue_num = res->queue_num_value;
10120 region_conf.queue_start_index = res->queue_id;
10122 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10123 op_type, ®ion_conf);
10130 printf("function not implemented or supported\n");
10133 printf("queue region config error: (%s)\n", strerror(-ret));
10137 cmdline_parse_token_string_t cmd_queue_region_set =
10138 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
10140 cmdline_parse_token_string_t cmd_queue_region_port =
10141 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, port, "port");
10142 cmdline_parse_token_num_t cmd_queue_region_port_id =
10143 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
10145 cmdline_parse_token_string_t cmd_queue_region_cmd =
10146 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
10147 cmd, "queue-region");
10148 cmdline_parse_token_string_t cmd_queue_region_id =
10149 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
10150 region, "region_id");
10151 cmdline_parse_token_num_t cmd_queue_region_index =
10152 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
10154 cmdline_parse_token_string_t cmd_queue_region_queue_start_index =
10155 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
10156 queue_start_index, "queue_start_index");
10157 cmdline_parse_token_num_t cmd_queue_region_queue_id =
10158 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
10160 cmdline_parse_token_string_t cmd_queue_region_queue_num =
10161 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
10162 queue_num, "queue_num");
10163 cmdline_parse_token_num_t cmd_queue_region_queue_num_value =
10164 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
10165 queue_num_value, UINT8);
10167 cmdline_parse_inst_t cmd_queue_region = {
10168 .f = cmd_queue_region_parsed,
10170 .help_str = "set port <port_id> queue-region region_id <value> "
10171 "queue_start_index <value> queue_num <value>: Set a queue region",
10173 (void *)&cmd_queue_region_set,
10174 (void *)&cmd_queue_region_port,
10175 (void *)&cmd_queue_region_port_id,
10176 (void *)&cmd_queue_region_cmd,
10177 (void *)&cmd_queue_region_id,
10178 (void *)&cmd_queue_region_index,
10179 (void *)&cmd_queue_region_queue_start_index,
10180 (void *)&cmd_queue_region_queue_id,
10181 (void *)&cmd_queue_region_queue_num,
10182 (void *)&cmd_queue_region_queue_num_value,
10187 /* *** queue region and flowtype set *** */
10188 struct cmd_region_flowtype_result {
10189 cmdline_fixed_string_t set;
10190 cmdline_fixed_string_t port;
10192 cmdline_fixed_string_t cmd;
10193 cmdline_fixed_string_t region;
10195 cmdline_fixed_string_t flowtype;
10196 uint8_t flowtype_id;
10200 cmd_region_flowtype_parsed(void *parsed_result,
10201 __rte_unused struct cmdline *cl,
10202 __rte_unused void *data)
10204 struct cmd_region_flowtype_result *res = parsed_result;
10205 int ret = -ENOTSUP;
10206 #ifdef RTE_NET_I40E
10207 struct rte_pmd_i40e_queue_region_conf region_conf;
10208 enum rte_pmd_i40e_queue_region_op op_type;
10211 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10214 #ifdef RTE_NET_I40E
10215 memset(®ion_conf, 0, sizeof(region_conf));
10217 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_FLOWTYPE_SET;
10218 region_conf.region_id = res->region_id;
10219 region_conf.hw_flowtype = res->flowtype_id;
10221 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10222 op_type, ®ion_conf);
10229 printf("function not implemented or supported\n");
10232 printf("region flowtype config error: (%s)\n", strerror(-ret));
10236 cmdline_parse_token_string_t cmd_region_flowtype_set =
10237 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10239 cmdline_parse_token_string_t cmd_region_flowtype_port =
10240 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10242 cmdline_parse_token_num_t cmd_region_flowtype_port_index =
10243 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
10245 cmdline_parse_token_string_t cmd_region_flowtype_cmd =
10246 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10247 cmd, "queue-region");
10248 cmdline_parse_token_string_t cmd_region_flowtype_index =
10249 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10250 region, "region_id");
10251 cmdline_parse_token_num_t cmd_region_flowtype_id =
10252 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
10254 cmdline_parse_token_string_t cmd_region_flowtype_flow_index =
10255 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10256 flowtype, "flowtype");
10257 cmdline_parse_token_num_t cmd_region_flowtype_flow_id =
10258 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
10259 flowtype_id, UINT8);
10260 cmdline_parse_inst_t cmd_region_flowtype = {
10261 .f = cmd_region_flowtype_parsed,
10263 .help_str = "set port <port_id> queue-region region_id <value> "
10264 "flowtype <value>: Set a flowtype region index",
10266 (void *)&cmd_region_flowtype_set,
10267 (void *)&cmd_region_flowtype_port,
10268 (void *)&cmd_region_flowtype_port_index,
10269 (void *)&cmd_region_flowtype_cmd,
10270 (void *)&cmd_region_flowtype_index,
10271 (void *)&cmd_region_flowtype_id,
10272 (void *)&cmd_region_flowtype_flow_index,
10273 (void *)&cmd_region_flowtype_flow_id,
10278 /* *** User Priority (UP) to queue region (region_id) set *** */
10279 struct cmd_user_priority_region_result {
10280 cmdline_fixed_string_t set;
10281 cmdline_fixed_string_t port;
10283 cmdline_fixed_string_t cmd;
10284 cmdline_fixed_string_t user_priority;
10285 uint8_t user_priority_id;
10286 cmdline_fixed_string_t region;
10291 cmd_user_priority_region_parsed(void *parsed_result,
10292 __rte_unused struct cmdline *cl,
10293 __rte_unused void *data)
10295 struct cmd_user_priority_region_result *res = parsed_result;
10296 int ret = -ENOTSUP;
10297 #ifdef RTE_NET_I40E
10298 struct rte_pmd_i40e_queue_region_conf region_conf;
10299 enum rte_pmd_i40e_queue_region_op op_type;
10302 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10305 #ifdef RTE_NET_I40E
10306 memset(®ion_conf, 0, sizeof(region_conf));
10307 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_USER_PRIORITY_SET;
10308 region_conf.user_priority = res->user_priority_id;
10309 region_conf.region_id = res->region_id;
10311 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10312 op_type, ®ion_conf);
10319 printf("function not implemented or supported\n");
10322 printf("user_priority region config error: (%s)\n",
10327 cmdline_parse_token_string_t cmd_user_priority_region_set =
10328 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10330 cmdline_parse_token_string_t cmd_user_priority_region_port =
10331 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10333 cmdline_parse_token_num_t cmd_user_priority_region_port_index =
10334 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10336 cmdline_parse_token_string_t cmd_user_priority_region_cmd =
10337 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10338 cmd, "queue-region");
10339 cmdline_parse_token_string_t cmd_user_priority_region_UP =
10340 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10341 user_priority, "UP");
10342 cmdline_parse_token_num_t cmd_user_priority_region_UP_id =
10343 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10344 user_priority_id, UINT8);
10345 cmdline_parse_token_string_t cmd_user_priority_region_region =
10346 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10347 region, "region_id");
10348 cmdline_parse_token_num_t cmd_user_priority_region_region_id =
10349 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10352 cmdline_parse_inst_t cmd_user_priority_region = {
10353 .f = cmd_user_priority_region_parsed,
10355 .help_str = "set port <port_id> queue-region UP <value> "
10356 "region_id <value>: Set the mapping of User Priority (UP) "
10357 "to queue region (region_id) ",
10359 (void *)&cmd_user_priority_region_set,
10360 (void *)&cmd_user_priority_region_port,
10361 (void *)&cmd_user_priority_region_port_index,
10362 (void *)&cmd_user_priority_region_cmd,
10363 (void *)&cmd_user_priority_region_UP,
10364 (void *)&cmd_user_priority_region_UP_id,
10365 (void *)&cmd_user_priority_region_region,
10366 (void *)&cmd_user_priority_region_region_id,
10371 /* *** flush all queue region related configuration *** */
10372 struct cmd_flush_queue_region_result {
10373 cmdline_fixed_string_t set;
10374 cmdline_fixed_string_t port;
10376 cmdline_fixed_string_t cmd;
10377 cmdline_fixed_string_t flush;
10378 cmdline_fixed_string_t what;
10382 cmd_flush_queue_region_parsed(void *parsed_result,
10383 __rte_unused struct cmdline *cl,
10384 __rte_unused void *data)
10386 struct cmd_flush_queue_region_result *res = parsed_result;
10387 int ret = -ENOTSUP;
10388 #ifdef RTE_NET_I40E
10389 struct rte_pmd_i40e_queue_region_conf region_conf;
10390 enum rte_pmd_i40e_queue_region_op op_type;
10393 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10396 #ifdef RTE_NET_I40E
10397 memset(®ion_conf, 0, sizeof(region_conf));
10399 if (strcmp(res->what, "on") == 0)
10400 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_ON;
10402 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_OFF;
10404 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10405 op_type, ®ion_conf);
10412 printf("function not implemented or supported\n");
10415 printf("queue region config flush error: (%s)\n",
10420 cmdline_parse_token_string_t cmd_flush_queue_region_set =
10421 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10423 cmdline_parse_token_string_t cmd_flush_queue_region_port =
10424 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10426 cmdline_parse_token_num_t cmd_flush_queue_region_port_index =
10427 TOKEN_NUM_INITIALIZER(struct cmd_flush_queue_region_result,
10429 cmdline_parse_token_string_t cmd_flush_queue_region_cmd =
10430 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10431 cmd, "queue-region");
10432 cmdline_parse_token_string_t cmd_flush_queue_region_flush =
10433 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10435 cmdline_parse_token_string_t cmd_flush_queue_region_what =
10436 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10439 cmdline_parse_inst_t cmd_flush_queue_region = {
10440 .f = cmd_flush_queue_region_parsed,
10442 .help_str = "set port <port_id> queue-region flush on|off"
10443 ": flush all queue region related configuration",
10445 (void *)&cmd_flush_queue_region_set,
10446 (void *)&cmd_flush_queue_region_port,
10447 (void *)&cmd_flush_queue_region_port_index,
10448 (void *)&cmd_flush_queue_region_cmd,
10449 (void *)&cmd_flush_queue_region_flush,
10450 (void *)&cmd_flush_queue_region_what,
10455 /* *** get all queue region related configuration info *** */
10456 struct cmd_show_queue_region_info {
10457 cmdline_fixed_string_t show;
10458 cmdline_fixed_string_t port;
10460 cmdline_fixed_string_t cmd;
10464 cmd_show_queue_region_info_parsed(void *parsed_result,
10465 __rte_unused struct cmdline *cl,
10466 __rte_unused void *data)
10468 struct cmd_show_queue_region_info *res = parsed_result;
10469 int ret = -ENOTSUP;
10470 #ifdef RTE_NET_I40E
10471 struct rte_pmd_i40e_queue_regions rte_pmd_regions;
10472 enum rte_pmd_i40e_queue_region_op op_type;
10475 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10478 #ifdef RTE_NET_I40E
10479 memset(&rte_pmd_regions, 0, sizeof(rte_pmd_regions));
10481 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_INFO_GET;
10483 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10484 op_type, &rte_pmd_regions);
10486 port_queue_region_info_display(res->port_id, &rte_pmd_regions);
10493 printf("function not implemented or supported\n");
10496 printf("queue region config info show error: (%s)\n",
10501 cmdline_parse_token_string_t cmd_show_queue_region_info_get =
10502 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10504 cmdline_parse_token_string_t cmd_show_queue_region_info_port =
10505 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10507 cmdline_parse_token_num_t cmd_show_queue_region_info_port_index =
10508 TOKEN_NUM_INITIALIZER(struct cmd_show_queue_region_info,
10510 cmdline_parse_token_string_t cmd_show_queue_region_info_cmd =
10511 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10512 cmd, "queue-region");
10514 cmdline_parse_inst_t cmd_show_queue_region_info_all = {
10515 .f = cmd_show_queue_region_info_parsed,
10517 .help_str = "show port <port_id> queue-region"
10518 ": show all queue region related configuration info",
10520 (void *)&cmd_show_queue_region_info_get,
10521 (void *)&cmd_show_queue_region_info_port,
10522 (void *)&cmd_show_queue_region_info_port_index,
10523 (void *)&cmd_show_queue_region_info_cmd,
10528 /* *** ADD/REMOVE A 2tuple FILTER *** */
10529 struct cmd_2tuple_filter_result {
10530 cmdline_fixed_string_t filter;
10532 cmdline_fixed_string_t ops;
10533 cmdline_fixed_string_t dst_port;
10534 uint16_t dst_port_value;
10535 cmdline_fixed_string_t protocol;
10536 uint8_t protocol_value;
10537 cmdline_fixed_string_t mask;
10538 uint8_t mask_value;
10539 cmdline_fixed_string_t tcp_flags;
10540 uint8_t tcp_flags_value;
10541 cmdline_fixed_string_t priority;
10542 uint8_t priority_value;
10543 cmdline_fixed_string_t queue;
10548 cmd_2tuple_filter_parsed(void *parsed_result,
10549 __rte_unused struct cmdline *cl,
10550 __rte_unused void *data)
10552 struct rte_eth_ntuple_filter filter;
10553 struct cmd_2tuple_filter_result *res = parsed_result;
10556 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
10558 printf("ntuple filter is not supported on port %u.\n",
10563 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
10565 filter.flags = RTE_2TUPLE_FLAGS;
10566 filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
10567 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
10568 filter.proto = res->protocol_value;
10569 filter.priority = res->priority_value;
10570 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
10571 printf("nonzero tcp_flags is only meaningful"
10572 " when protocol is TCP.\n");
10575 if (res->tcp_flags_value > RTE_NTUPLE_TCP_FLAGS_MASK) {
10576 printf("invalid TCP flags.\n");
10580 if (res->tcp_flags_value != 0) {
10581 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
10582 filter.tcp_flags = res->tcp_flags_value;
10585 /* need convert to big endian. */
10586 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
10587 filter.queue = res->queue_id;
10589 if (!strcmp(res->ops, "add"))
10590 ret = rte_eth_dev_filter_ctrl(res->port_id,
10591 RTE_ETH_FILTER_NTUPLE,
10592 RTE_ETH_FILTER_ADD,
10595 ret = rte_eth_dev_filter_ctrl(res->port_id,
10596 RTE_ETH_FILTER_NTUPLE,
10597 RTE_ETH_FILTER_DELETE,
10600 printf("2tuple filter programming error: (%s)\n",
10605 cmdline_parse_token_string_t cmd_2tuple_filter_filter =
10606 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10607 filter, "2tuple_filter");
10608 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
10609 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10611 cmdline_parse_token_string_t cmd_2tuple_filter_ops =
10612 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10614 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
10615 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10616 dst_port, "dst_port");
10617 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
10618 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10619 dst_port_value, UINT16);
10620 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
10621 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10622 protocol, "protocol");
10623 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
10624 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10625 protocol_value, UINT8);
10626 cmdline_parse_token_string_t cmd_2tuple_filter_mask =
10627 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10629 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value =
10630 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10632 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags =
10633 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10634 tcp_flags, "tcp_flags");
10635 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value =
10636 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10637 tcp_flags_value, UINT8);
10638 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
10639 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10640 priority, "priority");
10641 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
10642 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10643 priority_value, UINT8);
10644 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
10645 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10647 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
10648 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10651 cmdline_parse_inst_t cmd_2tuple_filter = {
10652 .f = cmd_2tuple_filter_parsed,
10654 .help_str = "2tuple_filter <port_id> add|del dst_port <value> protocol "
10655 "<value> mask <value> tcp_flags <value> priority <value> queue "
10656 "<queue_id>: Add a 2tuple filter",
10658 (void *)&cmd_2tuple_filter_filter,
10659 (void *)&cmd_2tuple_filter_port_id,
10660 (void *)&cmd_2tuple_filter_ops,
10661 (void *)&cmd_2tuple_filter_dst_port,
10662 (void *)&cmd_2tuple_filter_dst_port_value,
10663 (void *)&cmd_2tuple_filter_protocol,
10664 (void *)&cmd_2tuple_filter_protocol_value,
10665 (void *)&cmd_2tuple_filter_mask,
10666 (void *)&cmd_2tuple_filter_mask_value,
10667 (void *)&cmd_2tuple_filter_tcp_flags,
10668 (void *)&cmd_2tuple_filter_tcp_flags_value,
10669 (void *)&cmd_2tuple_filter_priority,
10670 (void *)&cmd_2tuple_filter_priority_value,
10671 (void *)&cmd_2tuple_filter_queue,
10672 (void *)&cmd_2tuple_filter_queue_id,
10677 /* *** ADD/REMOVE A 5tuple FILTER *** */
10678 struct cmd_5tuple_filter_result {
10679 cmdline_fixed_string_t filter;
10681 cmdline_fixed_string_t ops;
10682 cmdline_fixed_string_t dst_ip;
10683 cmdline_ipaddr_t dst_ip_value;
10684 cmdline_fixed_string_t src_ip;
10685 cmdline_ipaddr_t src_ip_value;
10686 cmdline_fixed_string_t dst_port;
10687 uint16_t dst_port_value;
10688 cmdline_fixed_string_t src_port;
10689 uint16_t src_port_value;
10690 cmdline_fixed_string_t protocol;
10691 uint8_t protocol_value;
10692 cmdline_fixed_string_t mask;
10693 uint8_t mask_value;
10694 cmdline_fixed_string_t tcp_flags;
10695 uint8_t tcp_flags_value;
10696 cmdline_fixed_string_t priority;
10697 uint8_t priority_value;
10698 cmdline_fixed_string_t queue;
10703 cmd_5tuple_filter_parsed(void *parsed_result,
10704 __rte_unused struct cmdline *cl,
10705 __rte_unused void *data)
10707 struct rte_eth_ntuple_filter filter;
10708 struct cmd_5tuple_filter_result *res = parsed_result;
10711 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
10713 printf("ntuple filter is not supported on port %u.\n",
10718 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
10720 filter.flags = RTE_5TUPLE_FLAGS;
10721 filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0;
10722 filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0;
10723 filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0;
10724 filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
10725 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
10726 filter.proto = res->protocol_value;
10727 filter.priority = res->priority_value;
10728 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
10729 printf("nonzero tcp_flags is only meaningful"
10730 " when protocol is TCP.\n");
10733 if (res->tcp_flags_value > RTE_NTUPLE_TCP_FLAGS_MASK) {
10734 printf("invalid TCP flags.\n");
10738 if (res->tcp_flags_value != 0) {
10739 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
10740 filter.tcp_flags = res->tcp_flags_value;
10743 if (res->dst_ip_value.family == AF_INET)
10744 /* no need to convert, already big endian. */
10745 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
10747 if (filter.dst_ip_mask == 0) {
10748 printf("can not support ipv6 involved compare.\n");
10754 if (res->src_ip_value.family == AF_INET)
10755 /* no need to convert, already big endian. */
10756 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
10758 if (filter.src_ip_mask == 0) {
10759 printf("can not support ipv6 involved compare.\n");
10764 /* need convert to big endian. */
10765 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
10766 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
10767 filter.queue = res->queue_id;
10769 if (!strcmp(res->ops, "add"))
10770 ret = rte_eth_dev_filter_ctrl(res->port_id,
10771 RTE_ETH_FILTER_NTUPLE,
10772 RTE_ETH_FILTER_ADD,
10775 ret = rte_eth_dev_filter_ctrl(res->port_id,
10776 RTE_ETH_FILTER_NTUPLE,
10777 RTE_ETH_FILTER_DELETE,
10780 printf("5tuple filter programming error: (%s)\n",
10784 cmdline_parse_token_string_t cmd_5tuple_filter_filter =
10785 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10786 filter, "5tuple_filter");
10787 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
10788 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10790 cmdline_parse_token_string_t cmd_5tuple_filter_ops =
10791 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10793 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
10794 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10796 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
10797 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
10799 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
10800 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10802 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
10803 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
10805 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
10806 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10807 dst_port, "dst_port");
10808 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
10809 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10810 dst_port_value, UINT16);
10811 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
10812 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10813 src_port, "src_port");
10814 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
10815 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10816 src_port_value, UINT16);
10817 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
10818 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10819 protocol, "protocol");
10820 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
10821 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10822 protocol_value, UINT8);
10823 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
10824 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10826 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
10827 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10829 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags =
10830 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10831 tcp_flags, "tcp_flags");
10832 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value =
10833 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10834 tcp_flags_value, UINT8);
10835 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
10836 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10837 priority, "priority");
10838 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
10839 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10840 priority_value, UINT8);
10841 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
10842 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10844 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
10845 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10848 cmdline_parse_inst_t cmd_5tuple_filter = {
10849 .f = cmd_5tuple_filter_parsed,
10851 .help_str = "5tuple_filter <port_id> add|del dst_ip <value> "
10852 "src_ip <value> dst_port <value> src_port <value> "
10853 "protocol <value> mask <value> tcp_flags <value> "
10854 "priority <value> queue <queue_id>: Add/Del a 5tuple filter",
10856 (void *)&cmd_5tuple_filter_filter,
10857 (void *)&cmd_5tuple_filter_port_id,
10858 (void *)&cmd_5tuple_filter_ops,
10859 (void *)&cmd_5tuple_filter_dst_ip,
10860 (void *)&cmd_5tuple_filter_dst_ip_value,
10861 (void *)&cmd_5tuple_filter_src_ip,
10862 (void *)&cmd_5tuple_filter_src_ip_value,
10863 (void *)&cmd_5tuple_filter_dst_port,
10864 (void *)&cmd_5tuple_filter_dst_port_value,
10865 (void *)&cmd_5tuple_filter_src_port,
10866 (void *)&cmd_5tuple_filter_src_port_value,
10867 (void *)&cmd_5tuple_filter_protocol,
10868 (void *)&cmd_5tuple_filter_protocol_value,
10869 (void *)&cmd_5tuple_filter_mask,
10870 (void *)&cmd_5tuple_filter_mask_value,
10871 (void *)&cmd_5tuple_filter_tcp_flags,
10872 (void *)&cmd_5tuple_filter_tcp_flags_value,
10873 (void *)&cmd_5tuple_filter_priority,
10874 (void *)&cmd_5tuple_filter_priority_value,
10875 (void *)&cmd_5tuple_filter_queue,
10876 (void *)&cmd_5tuple_filter_queue_id,
10881 /* *** ADD/REMOVE A flex FILTER *** */
10882 struct cmd_flex_filter_result {
10883 cmdline_fixed_string_t filter;
10884 cmdline_fixed_string_t ops;
10886 cmdline_fixed_string_t len;
10888 cmdline_fixed_string_t bytes;
10889 cmdline_fixed_string_t bytes_value;
10890 cmdline_fixed_string_t mask;
10891 cmdline_fixed_string_t mask_value;
10892 cmdline_fixed_string_t priority;
10893 uint8_t priority_value;
10894 cmdline_fixed_string_t queue;
10898 static int xdigit2val(unsigned char c)
10903 else if (isupper(c))
10904 val = c - 'A' + 10;
10906 val = c - 'a' + 10;
10911 cmd_flex_filter_parsed(void *parsed_result,
10912 __rte_unused struct cmdline *cl,
10913 __rte_unused void *data)
10916 struct rte_eth_flex_filter filter;
10917 struct cmd_flex_filter_result *res = parsed_result;
10918 char *bytes_ptr, *mask_ptr;
10919 uint16_t len, i, j = 0;
10924 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) {
10925 printf("the len exceed the max length 128\n");
10928 memset(&filter, 0, sizeof(struct rte_eth_flex_filter));
10929 filter.len = res->len_value;
10930 filter.priority = res->priority_value;
10931 filter.queue = res->queue_id;
10932 bytes_ptr = res->bytes_value;
10933 mask_ptr = res->mask_value;
10935 /* translate bytes string to array. */
10936 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
10937 (bytes_ptr[1] == 'X')))
10939 len = strnlen(bytes_ptr, res->len_value * 2);
10940 if (len == 0 || (len % 8 != 0)) {
10941 printf("please check len and bytes input\n");
10944 for (i = 0; i < len; i++) {
10946 if (isxdigit(c) == 0) {
10947 /* invalid characters. */
10948 printf("invalid input\n");
10951 val = xdigit2val(c);
10954 filter.bytes[j] = byte;
10955 printf("bytes[%d]:%02x ", j, filter.bytes[j]);
10962 /* translate mask string to uint8_t array. */
10963 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
10964 (mask_ptr[1] == 'X')))
10966 len = strnlen(mask_ptr, (res->len_value + 3) / 4);
10968 printf("invalid input\n");
10973 for (i = 0; i < len; i++) {
10975 if (isxdigit(c) == 0) {
10976 /* invalid characters. */
10977 printf("invalid input\n");
10980 val = xdigit2val(c);
10983 filter.mask[j] = byte;
10984 printf("mask[%d]:%02x ", j, filter.mask[j]);
10992 if (!strcmp(res->ops, "add"))
10993 ret = rte_eth_dev_filter_ctrl(res->port_id,
10994 RTE_ETH_FILTER_FLEXIBLE,
10995 RTE_ETH_FILTER_ADD,
10998 ret = rte_eth_dev_filter_ctrl(res->port_id,
10999 RTE_ETH_FILTER_FLEXIBLE,
11000 RTE_ETH_FILTER_DELETE,
11004 printf("flex filter setting error: (%s)\n", strerror(-ret));
11007 cmdline_parse_token_string_t cmd_flex_filter_filter =
11008 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
11009 filter, "flex_filter");
11010 cmdline_parse_token_num_t cmd_flex_filter_port_id =
11011 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
11013 cmdline_parse_token_string_t cmd_flex_filter_ops =
11014 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
11016 cmdline_parse_token_string_t cmd_flex_filter_len =
11017 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
11019 cmdline_parse_token_num_t cmd_flex_filter_len_value =
11020 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
11022 cmdline_parse_token_string_t cmd_flex_filter_bytes =
11023 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
11025 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
11026 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
11027 bytes_value, NULL);
11028 cmdline_parse_token_string_t cmd_flex_filter_mask =
11029 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
11031 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
11032 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
11034 cmdline_parse_token_string_t cmd_flex_filter_priority =
11035 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
11036 priority, "priority");
11037 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
11038 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
11039 priority_value, UINT8);
11040 cmdline_parse_token_string_t cmd_flex_filter_queue =
11041 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
11043 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
11044 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
11046 cmdline_parse_inst_t cmd_flex_filter = {
11047 .f = cmd_flex_filter_parsed,
11049 .help_str = "flex_filter <port_id> add|del len <value> bytes "
11050 "<value> mask <value> priority <value> queue <queue_id>: "
11051 "Add/Del a flex filter",
11053 (void *)&cmd_flex_filter_filter,
11054 (void *)&cmd_flex_filter_port_id,
11055 (void *)&cmd_flex_filter_ops,
11056 (void *)&cmd_flex_filter_len,
11057 (void *)&cmd_flex_filter_len_value,
11058 (void *)&cmd_flex_filter_bytes,
11059 (void *)&cmd_flex_filter_bytes_value,
11060 (void *)&cmd_flex_filter_mask,
11061 (void *)&cmd_flex_filter_mask_value,
11062 (void *)&cmd_flex_filter_priority,
11063 (void *)&cmd_flex_filter_priority_value,
11064 (void *)&cmd_flex_filter_queue,
11065 (void *)&cmd_flex_filter_queue_id,
11070 /* *** Filters Control *** */
11072 /* *** deal with ethertype filter *** */
11073 struct cmd_ethertype_filter_result {
11074 cmdline_fixed_string_t filter;
11076 cmdline_fixed_string_t ops;
11077 cmdline_fixed_string_t mac;
11078 struct rte_ether_addr mac_addr;
11079 cmdline_fixed_string_t ethertype;
11080 uint16_t ethertype_value;
11081 cmdline_fixed_string_t drop;
11082 cmdline_fixed_string_t queue;
11086 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
11087 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
11088 filter, "ethertype_filter");
11089 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
11090 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
11092 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
11093 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
11095 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
11096 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
11097 mac, "mac_addr#mac_ignr");
11098 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
11099 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
11101 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
11102 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
11103 ethertype, "ethertype");
11104 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
11105 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
11106 ethertype_value, UINT16);
11107 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
11108 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
11110 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
11111 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
11113 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
11114 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
11118 cmd_ethertype_filter_parsed(void *parsed_result,
11119 __rte_unused struct cmdline *cl,
11120 __rte_unused void *data)
11122 struct cmd_ethertype_filter_result *res = parsed_result;
11123 struct rte_eth_ethertype_filter filter;
11126 ret = rte_eth_dev_filter_supported(res->port_id,
11127 RTE_ETH_FILTER_ETHERTYPE);
11129 printf("ethertype filter is not supported on port %u.\n",
11134 memset(&filter, 0, sizeof(filter));
11135 if (!strcmp(res->mac, "mac_addr")) {
11136 filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
11137 rte_memcpy(&filter.mac_addr, &res->mac_addr,
11138 sizeof(struct rte_ether_addr));
11140 if (!strcmp(res->drop, "drop"))
11141 filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
11142 filter.ether_type = res->ethertype_value;
11143 filter.queue = res->queue_id;
11145 if (!strcmp(res->ops, "add"))
11146 ret = rte_eth_dev_filter_ctrl(res->port_id,
11147 RTE_ETH_FILTER_ETHERTYPE,
11148 RTE_ETH_FILTER_ADD,
11151 ret = rte_eth_dev_filter_ctrl(res->port_id,
11152 RTE_ETH_FILTER_ETHERTYPE,
11153 RTE_ETH_FILTER_DELETE,
11156 printf("ethertype filter programming error: (%s)\n",
11160 cmdline_parse_inst_t cmd_ethertype_filter = {
11161 .f = cmd_ethertype_filter_parsed,
11163 .help_str = "ethertype_filter <port_id> add|del mac_addr|mac_ignr "
11164 "<mac_addr> ethertype <value> drop|fw queue <queue_id>: "
11165 "Add or delete an ethertype filter entry",
11167 (void *)&cmd_ethertype_filter_filter,
11168 (void *)&cmd_ethertype_filter_port_id,
11169 (void *)&cmd_ethertype_filter_ops,
11170 (void *)&cmd_ethertype_filter_mac,
11171 (void *)&cmd_ethertype_filter_mac_addr,
11172 (void *)&cmd_ethertype_filter_ethertype,
11173 (void *)&cmd_ethertype_filter_ethertype_value,
11174 (void *)&cmd_ethertype_filter_drop,
11175 (void *)&cmd_ethertype_filter_queue,
11176 (void *)&cmd_ethertype_filter_queue_id,
11181 /* *** deal with flow director filter *** */
11182 struct cmd_flow_director_result {
11183 cmdline_fixed_string_t flow_director_filter;
11185 cmdline_fixed_string_t mode;
11186 cmdline_fixed_string_t mode_value;
11187 cmdline_fixed_string_t ops;
11188 cmdline_fixed_string_t flow;
11189 cmdline_fixed_string_t flow_type;
11190 cmdline_fixed_string_t ether;
11191 uint16_t ether_type;
11192 cmdline_fixed_string_t src;
11193 cmdline_ipaddr_t ip_src;
11195 cmdline_fixed_string_t dst;
11196 cmdline_ipaddr_t ip_dst;
11198 cmdline_fixed_string_t verify_tag;
11199 uint32_t verify_tag_value;
11200 cmdline_fixed_string_t tos;
11202 cmdline_fixed_string_t proto;
11203 uint8_t proto_value;
11204 cmdline_fixed_string_t ttl;
11206 cmdline_fixed_string_t vlan;
11207 uint16_t vlan_value;
11208 cmdline_fixed_string_t flexbytes;
11209 cmdline_fixed_string_t flexbytes_value;
11210 cmdline_fixed_string_t pf_vf;
11211 cmdline_fixed_string_t drop;
11212 cmdline_fixed_string_t queue;
11214 cmdline_fixed_string_t fd_id;
11215 uint32_t fd_id_value;
11216 cmdline_fixed_string_t mac;
11217 struct rte_ether_addr mac_addr;
11218 cmdline_fixed_string_t tunnel;
11219 cmdline_fixed_string_t tunnel_type;
11220 cmdline_fixed_string_t tunnel_id;
11221 uint32_t tunnel_id_value;
11222 cmdline_fixed_string_t packet;
11227 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
11230 const char *p, *p0 = q_arg;
11232 unsigned long int_fld;
11233 char *str_fld[max_num];
11238 p = strchr(p0, '(');
11242 p0 = strchr(p, ')');
11247 if (size >= sizeof(s))
11250 snprintf(s, sizeof(s), "%.*s", size, p);
11251 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
11252 if (ret < 0 || ret > max_num)
11254 for (i = 0; i < ret; i++) {
11256 int_fld = strtoul(str_fld[i], &end, 0);
11257 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
11259 flexbytes[i] = (uint8_t)int_fld;
11265 str2flowtype(char *string)
11268 static const struct {
11271 } flowtype_str[] = {
11272 {"raw", RTE_ETH_FLOW_RAW},
11273 {"ipv4", RTE_ETH_FLOW_IPV4},
11274 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
11275 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
11276 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
11277 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
11278 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
11279 {"ipv6", RTE_ETH_FLOW_IPV6},
11280 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
11281 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
11282 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
11283 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
11284 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
11285 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
11288 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
11289 if (!strcmp(flowtype_str[i].str, string))
11290 return flowtype_str[i].type;
11293 if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64)
11294 return (uint16_t)atoi(string);
11296 return RTE_ETH_FLOW_UNKNOWN;
11299 static enum rte_eth_fdir_tunnel_type
11300 str2fdir_tunneltype(char *string)
11304 static const struct {
11306 enum rte_eth_fdir_tunnel_type type;
11307 } tunneltype_str[] = {
11308 {"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE},
11309 {"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN},
11312 for (i = 0; i < RTE_DIM(tunneltype_str); i++) {
11313 if (!strcmp(tunneltype_str[i].str, string))
11314 return tunneltype_str[i].type;
11316 return RTE_FDIR_TUNNEL_TYPE_UNKNOWN;
11319 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
11321 if ((ip_addr).family == AF_INET) \
11322 (ip) = (ip_addr).addr.ipv4.s_addr; \
11324 printf("invalid parameter.\n"); \
11329 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
11331 if ((ip_addr).family == AF_INET6) \
11332 rte_memcpy(&(ip), \
11333 &((ip_addr).addr.ipv6), \
11334 sizeof(struct in6_addr)); \
11336 printf("invalid parameter.\n"); \
11342 cmd_flow_director_filter_parsed(void *parsed_result,
11343 __rte_unused struct cmdline *cl,
11344 __rte_unused void *data)
11346 struct cmd_flow_director_result *res = parsed_result;
11347 struct rte_eth_fdir_filter entry;
11348 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
11350 unsigned long vf_id;
11353 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
11355 printf("flow director is not supported on port %u.\n",
11359 memset(flexbytes, 0, sizeof(flexbytes));
11360 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
11362 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
11363 if (strcmp(res->mode_value, "MAC-VLAN")) {
11364 printf("Please set mode to MAC-VLAN.\n");
11367 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
11368 if (strcmp(res->mode_value, "Tunnel")) {
11369 printf("Please set mode to Tunnel.\n");
11373 if (!strcmp(res->mode_value, "raw")) {
11374 #ifdef RTE_NET_I40E
11375 struct rte_pmd_i40e_flow_type_mapping
11376 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
11377 struct rte_pmd_i40e_pkt_template_conf conf;
11378 uint16_t flow_type = str2flowtype(res->flow_type);
11379 uint16_t i, port = res->port_id;
11382 memset(&conf, 0, sizeof(conf));
11384 if (flow_type == RTE_ETH_FLOW_UNKNOWN) {
11385 printf("Invalid flow type specified.\n");
11388 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id,
11392 if (mapping[flow_type].pctype == 0ULL) {
11393 printf("Invalid flow type specified.\n");
11396 for (i = 0; i < RTE_PMD_I40E_PCTYPE_MAX; i++) {
11397 if (mapping[flow_type].pctype & (1ULL << i)) {
11398 conf.input.pctype = i;
11403 conf.input.packet = open_file(res->filepath,
11404 &conf.input.length);
11405 if (!conf.input.packet)
11407 if (!strcmp(res->drop, "drop"))
11408 conf.action.behavior =
11409 RTE_PMD_I40E_PKT_TEMPLATE_REJECT;
11411 conf.action.behavior =
11412 RTE_PMD_I40E_PKT_TEMPLATE_ACCEPT;
11413 conf.action.report_status =
11414 RTE_PMD_I40E_PKT_TEMPLATE_REPORT_ID;
11415 conf.action.rx_queue = res->queue_id;
11416 conf.soft_id = res->fd_id_value;
11417 add = strcmp(res->ops, "del") ? 1 : 0;
11418 ret = rte_pmd_i40e_flow_add_del_packet_template(port,
11422 printf("flow director config error: (%s)\n",
11424 close_file(conf.input.packet);
11427 } else if (strcmp(res->mode_value, "IP")) {
11428 printf("Please set mode to IP or raw.\n");
11431 entry.input.flow_type = str2flowtype(res->flow_type);
11434 ret = parse_flexbytes(res->flexbytes_value,
11436 RTE_ETH_FDIR_MAX_FLEXLEN);
11438 printf("error: Cannot parse flexbytes input.\n");
11442 switch (entry.input.flow_type) {
11443 case RTE_ETH_FLOW_FRAG_IPV4:
11444 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
11445 entry.input.flow.ip4_flow.proto = res->proto_value;
11447 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
11448 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
11449 IPV4_ADDR_TO_UINT(res->ip_dst,
11450 entry.input.flow.ip4_flow.dst_ip);
11451 IPV4_ADDR_TO_UINT(res->ip_src,
11452 entry.input.flow.ip4_flow.src_ip);
11453 entry.input.flow.ip4_flow.tos = res->tos_value;
11454 entry.input.flow.ip4_flow.ttl = res->ttl_value;
11455 /* need convert to big endian. */
11456 entry.input.flow.udp4_flow.dst_port =
11457 rte_cpu_to_be_16(res->port_dst);
11458 entry.input.flow.udp4_flow.src_port =
11459 rte_cpu_to_be_16(res->port_src);
11461 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
11462 IPV4_ADDR_TO_UINT(res->ip_dst,
11463 entry.input.flow.sctp4_flow.ip.dst_ip);
11464 IPV4_ADDR_TO_UINT(res->ip_src,
11465 entry.input.flow.sctp4_flow.ip.src_ip);
11466 entry.input.flow.ip4_flow.tos = res->tos_value;
11467 entry.input.flow.ip4_flow.ttl = res->ttl_value;
11468 /* need convert to big endian. */
11469 entry.input.flow.sctp4_flow.dst_port =
11470 rte_cpu_to_be_16(res->port_dst);
11471 entry.input.flow.sctp4_flow.src_port =
11472 rte_cpu_to_be_16(res->port_src);
11473 entry.input.flow.sctp4_flow.verify_tag =
11474 rte_cpu_to_be_32(res->verify_tag_value);
11476 case RTE_ETH_FLOW_FRAG_IPV6:
11477 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
11478 entry.input.flow.ipv6_flow.proto = res->proto_value;
11480 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
11481 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
11482 IPV6_ADDR_TO_ARRAY(res->ip_dst,
11483 entry.input.flow.ipv6_flow.dst_ip);
11484 IPV6_ADDR_TO_ARRAY(res->ip_src,
11485 entry.input.flow.ipv6_flow.src_ip);
11486 entry.input.flow.ipv6_flow.tc = res->tos_value;
11487 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
11488 /* need convert to big endian. */
11489 entry.input.flow.udp6_flow.dst_port =
11490 rte_cpu_to_be_16(res->port_dst);
11491 entry.input.flow.udp6_flow.src_port =
11492 rte_cpu_to_be_16(res->port_src);
11494 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
11495 IPV6_ADDR_TO_ARRAY(res->ip_dst,
11496 entry.input.flow.sctp6_flow.ip.dst_ip);
11497 IPV6_ADDR_TO_ARRAY(res->ip_src,
11498 entry.input.flow.sctp6_flow.ip.src_ip);
11499 entry.input.flow.ipv6_flow.tc = res->tos_value;
11500 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
11501 /* need convert to big endian. */
11502 entry.input.flow.sctp6_flow.dst_port =
11503 rte_cpu_to_be_16(res->port_dst);
11504 entry.input.flow.sctp6_flow.src_port =
11505 rte_cpu_to_be_16(res->port_src);
11506 entry.input.flow.sctp6_flow.verify_tag =
11507 rte_cpu_to_be_32(res->verify_tag_value);
11509 case RTE_ETH_FLOW_L2_PAYLOAD:
11510 entry.input.flow.l2_flow.ether_type =
11511 rte_cpu_to_be_16(res->ether_type);
11517 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN)
11518 rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr,
11520 sizeof(struct rte_ether_addr));
11522 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
11523 rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr,
11525 sizeof(struct rte_ether_addr));
11526 entry.input.flow.tunnel_flow.tunnel_type =
11527 str2fdir_tunneltype(res->tunnel_type);
11528 entry.input.flow.tunnel_flow.tunnel_id =
11529 rte_cpu_to_be_32(res->tunnel_id_value);
11532 rte_memcpy(entry.input.flow_ext.flexbytes,
11534 RTE_ETH_FDIR_MAX_FLEXLEN);
11536 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
11538 entry.action.flex_off = 0; /*use 0 by default */
11539 if (!strcmp(res->drop, "drop"))
11540 entry.action.behavior = RTE_ETH_FDIR_REJECT;
11542 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
11544 if (fdir_conf.mode != RTE_FDIR_MODE_PERFECT_MAC_VLAN &&
11545 fdir_conf.mode != RTE_FDIR_MODE_PERFECT_TUNNEL) {
11546 if (!strcmp(res->pf_vf, "pf"))
11547 entry.input.flow_ext.is_vf = 0;
11548 else if (!strncmp(res->pf_vf, "vf", 2)) {
11549 struct rte_eth_dev_info dev_info;
11551 ret = eth_dev_info_get_print_err(res->port_id,
11557 vf_id = strtoul(res->pf_vf + 2, &end, 10);
11558 if (errno != 0 || *end != '\0' ||
11559 vf_id >= dev_info.max_vfs) {
11560 printf("invalid parameter %s.\n", res->pf_vf);
11563 entry.input.flow_ext.is_vf = 1;
11564 entry.input.flow_ext.dst_id = (uint16_t)vf_id;
11566 printf("invalid parameter %s.\n", res->pf_vf);
11571 /* set to report FD ID by default */
11572 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
11573 entry.action.rx_queue = res->queue_id;
11574 entry.soft_id = res->fd_id_value;
11575 if (!strcmp(res->ops, "add"))
11576 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11577 RTE_ETH_FILTER_ADD, &entry);
11578 else if (!strcmp(res->ops, "del"))
11579 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11580 RTE_ETH_FILTER_DELETE, &entry);
11582 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11583 RTE_ETH_FILTER_UPDATE, &entry);
11585 printf("flow director programming error: (%s)\n",
11589 cmdline_parse_token_string_t cmd_flow_director_filter =
11590 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11591 flow_director_filter, "flow_director_filter");
11592 cmdline_parse_token_num_t cmd_flow_director_port_id =
11593 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11595 cmdline_parse_token_string_t cmd_flow_director_ops =
11596 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11597 ops, "add#del#update");
11598 cmdline_parse_token_string_t cmd_flow_director_flow =
11599 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11601 cmdline_parse_token_string_t cmd_flow_director_flow_type =
11602 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11604 cmdline_parse_token_string_t cmd_flow_director_ether =
11605 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11607 cmdline_parse_token_num_t cmd_flow_director_ether_type =
11608 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11609 ether_type, UINT16);
11610 cmdline_parse_token_string_t cmd_flow_director_src =
11611 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11613 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
11614 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
11616 cmdline_parse_token_num_t cmd_flow_director_port_src =
11617 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11619 cmdline_parse_token_string_t cmd_flow_director_dst =
11620 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11622 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
11623 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
11625 cmdline_parse_token_num_t cmd_flow_director_port_dst =
11626 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11628 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
11629 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11630 verify_tag, "verify_tag");
11631 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
11632 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11633 verify_tag_value, UINT32);
11634 cmdline_parse_token_string_t cmd_flow_director_tos =
11635 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11637 cmdline_parse_token_num_t cmd_flow_director_tos_value =
11638 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11640 cmdline_parse_token_string_t cmd_flow_director_proto =
11641 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11643 cmdline_parse_token_num_t cmd_flow_director_proto_value =
11644 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11645 proto_value, UINT8);
11646 cmdline_parse_token_string_t cmd_flow_director_ttl =
11647 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11649 cmdline_parse_token_num_t cmd_flow_director_ttl_value =
11650 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11652 cmdline_parse_token_string_t cmd_flow_director_vlan =
11653 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11655 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
11656 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11657 vlan_value, UINT16);
11658 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
11659 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11660 flexbytes, "flexbytes");
11661 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
11662 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11663 flexbytes_value, NULL);
11664 cmdline_parse_token_string_t cmd_flow_director_drop =
11665 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11667 cmdline_parse_token_string_t cmd_flow_director_pf_vf =
11668 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11670 cmdline_parse_token_string_t cmd_flow_director_queue =
11671 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11673 cmdline_parse_token_num_t cmd_flow_director_queue_id =
11674 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11676 cmdline_parse_token_string_t cmd_flow_director_fd_id =
11677 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11679 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
11680 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11681 fd_id_value, UINT32);
11683 cmdline_parse_token_string_t cmd_flow_director_mode =
11684 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11686 cmdline_parse_token_string_t cmd_flow_director_mode_ip =
11687 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11689 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan =
11690 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11691 mode_value, "MAC-VLAN");
11692 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel =
11693 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11694 mode_value, "Tunnel");
11695 cmdline_parse_token_string_t cmd_flow_director_mode_raw =
11696 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11697 mode_value, "raw");
11698 cmdline_parse_token_string_t cmd_flow_director_mac =
11699 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11701 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr =
11702 TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result,
11704 cmdline_parse_token_string_t cmd_flow_director_tunnel =
11705 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11707 cmdline_parse_token_string_t cmd_flow_director_tunnel_type =
11708 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11709 tunnel_type, "NVGRE#VxLAN");
11710 cmdline_parse_token_string_t cmd_flow_director_tunnel_id =
11711 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11712 tunnel_id, "tunnel-id");
11713 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value =
11714 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11715 tunnel_id_value, UINT32);
11716 cmdline_parse_token_string_t cmd_flow_director_packet =
11717 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11719 cmdline_parse_token_string_t cmd_flow_director_filepath =
11720 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11723 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
11724 .f = cmd_flow_director_filter_parsed,
11726 .help_str = "flow_director_filter <port_id> mode IP add|del|update flow"
11727 " ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
11728 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
11729 "l2_payload src <src_ip> dst <dst_ip> tos <tos_value> "
11730 "proto <proto_value> ttl <ttl_value> vlan <vlan_value> "
11731 "flexbytes <flexbyte_values> drop|fw <pf_vf> queue <queue_id> "
11732 "fd_id <fd_id_value>: "
11733 "Add or delete an ip flow director entry on NIC",
11735 (void *)&cmd_flow_director_filter,
11736 (void *)&cmd_flow_director_port_id,
11737 (void *)&cmd_flow_director_mode,
11738 (void *)&cmd_flow_director_mode_ip,
11739 (void *)&cmd_flow_director_ops,
11740 (void *)&cmd_flow_director_flow,
11741 (void *)&cmd_flow_director_flow_type,
11742 (void *)&cmd_flow_director_src,
11743 (void *)&cmd_flow_director_ip_src,
11744 (void *)&cmd_flow_director_dst,
11745 (void *)&cmd_flow_director_ip_dst,
11746 (void *)&cmd_flow_director_tos,
11747 (void *)&cmd_flow_director_tos_value,
11748 (void *)&cmd_flow_director_proto,
11749 (void *)&cmd_flow_director_proto_value,
11750 (void *)&cmd_flow_director_ttl,
11751 (void *)&cmd_flow_director_ttl_value,
11752 (void *)&cmd_flow_director_vlan,
11753 (void *)&cmd_flow_director_vlan_value,
11754 (void *)&cmd_flow_director_flexbytes,
11755 (void *)&cmd_flow_director_flexbytes_value,
11756 (void *)&cmd_flow_director_drop,
11757 (void *)&cmd_flow_director_pf_vf,
11758 (void *)&cmd_flow_director_queue,
11759 (void *)&cmd_flow_director_queue_id,
11760 (void *)&cmd_flow_director_fd_id,
11761 (void *)&cmd_flow_director_fd_id_value,
11766 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
11767 .f = cmd_flow_director_filter_parsed,
11769 .help_str = "flow_director_filter ... : Add or delete an udp/tcp flow "
11770 "director entry on NIC",
11772 (void *)&cmd_flow_director_filter,
11773 (void *)&cmd_flow_director_port_id,
11774 (void *)&cmd_flow_director_mode,
11775 (void *)&cmd_flow_director_mode_ip,
11776 (void *)&cmd_flow_director_ops,
11777 (void *)&cmd_flow_director_flow,
11778 (void *)&cmd_flow_director_flow_type,
11779 (void *)&cmd_flow_director_src,
11780 (void *)&cmd_flow_director_ip_src,
11781 (void *)&cmd_flow_director_port_src,
11782 (void *)&cmd_flow_director_dst,
11783 (void *)&cmd_flow_director_ip_dst,
11784 (void *)&cmd_flow_director_port_dst,
11785 (void *)&cmd_flow_director_tos,
11786 (void *)&cmd_flow_director_tos_value,
11787 (void *)&cmd_flow_director_ttl,
11788 (void *)&cmd_flow_director_ttl_value,
11789 (void *)&cmd_flow_director_vlan,
11790 (void *)&cmd_flow_director_vlan_value,
11791 (void *)&cmd_flow_director_flexbytes,
11792 (void *)&cmd_flow_director_flexbytes_value,
11793 (void *)&cmd_flow_director_drop,
11794 (void *)&cmd_flow_director_pf_vf,
11795 (void *)&cmd_flow_director_queue,
11796 (void *)&cmd_flow_director_queue_id,
11797 (void *)&cmd_flow_director_fd_id,
11798 (void *)&cmd_flow_director_fd_id_value,
11803 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
11804 .f = cmd_flow_director_filter_parsed,
11806 .help_str = "flow_director_filter ... : Add or delete a sctp flow "
11807 "director entry on NIC",
11809 (void *)&cmd_flow_director_filter,
11810 (void *)&cmd_flow_director_port_id,
11811 (void *)&cmd_flow_director_mode,
11812 (void *)&cmd_flow_director_mode_ip,
11813 (void *)&cmd_flow_director_ops,
11814 (void *)&cmd_flow_director_flow,
11815 (void *)&cmd_flow_director_flow_type,
11816 (void *)&cmd_flow_director_src,
11817 (void *)&cmd_flow_director_ip_src,
11818 (void *)&cmd_flow_director_port_src,
11819 (void *)&cmd_flow_director_dst,
11820 (void *)&cmd_flow_director_ip_dst,
11821 (void *)&cmd_flow_director_port_dst,
11822 (void *)&cmd_flow_director_verify_tag,
11823 (void *)&cmd_flow_director_verify_tag_value,
11824 (void *)&cmd_flow_director_tos,
11825 (void *)&cmd_flow_director_tos_value,
11826 (void *)&cmd_flow_director_ttl,
11827 (void *)&cmd_flow_director_ttl_value,
11828 (void *)&cmd_flow_director_vlan,
11829 (void *)&cmd_flow_director_vlan_value,
11830 (void *)&cmd_flow_director_flexbytes,
11831 (void *)&cmd_flow_director_flexbytes_value,
11832 (void *)&cmd_flow_director_drop,
11833 (void *)&cmd_flow_director_pf_vf,
11834 (void *)&cmd_flow_director_queue,
11835 (void *)&cmd_flow_director_queue_id,
11836 (void *)&cmd_flow_director_fd_id,
11837 (void *)&cmd_flow_director_fd_id_value,
11842 cmdline_parse_inst_t cmd_add_del_l2_flow_director = {
11843 .f = cmd_flow_director_filter_parsed,
11845 .help_str = "flow_director_filter ... : Add or delete a L2 flow "
11846 "director entry on NIC",
11848 (void *)&cmd_flow_director_filter,
11849 (void *)&cmd_flow_director_port_id,
11850 (void *)&cmd_flow_director_mode,
11851 (void *)&cmd_flow_director_mode_ip,
11852 (void *)&cmd_flow_director_ops,
11853 (void *)&cmd_flow_director_flow,
11854 (void *)&cmd_flow_director_flow_type,
11855 (void *)&cmd_flow_director_ether,
11856 (void *)&cmd_flow_director_ether_type,
11857 (void *)&cmd_flow_director_flexbytes,
11858 (void *)&cmd_flow_director_flexbytes_value,
11859 (void *)&cmd_flow_director_drop,
11860 (void *)&cmd_flow_director_pf_vf,
11861 (void *)&cmd_flow_director_queue,
11862 (void *)&cmd_flow_director_queue_id,
11863 (void *)&cmd_flow_director_fd_id,
11864 (void *)&cmd_flow_director_fd_id_value,
11869 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = {
11870 .f = cmd_flow_director_filter_parsed,
11872 .help_str = "flow_director_filter ... : Add or delete a MAC VLAN flow "
11873 "director entry on NIC",
11875 (void *)&cmd_flow_director_filter,
11876 (void *)&cmd_flow_director_port_id,
11877 (void *)&cmd_flow_director_mode,
11878 (void *)&cmd_flow_director_mode_mac_vlan,
11879 (void *)&cmd_flow_director_ops,
11880 (void *)&cmd_flow_director_mac,
11881 (void *)&cmd_flow_director_mac_addr,
11882 (void *)&cmd_flow_director_vlan,
11883 (void *)&cmd_flow_director_vlan_value,
11884 (void *)&cmd_flow_director_flexbytes,
11885 (void *)&cmd_flow_director_flexbytes_value,
11886 (void *)&cmd_flow_director_drop,
11887 (void *)&cmd_flow_director_queue,
11888 (void *)&cmd_flow_director_queue_id,
11889 (void *)&cmd_flow_director_fd_id,
11890 (void *)&cmd_flow_director_fd_id_value,
11895 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = {
11896 .f = cmd_flow_director_filter_parsed,
11898 .help_str = "flow_director_filter ... : Add or delete a tunnel flow "
11899 "director entry on NIC",
11901 (void *)&cmd_flow_director_filter,
11902 (void *)&cmd_flow_director_port_id,
11903 (void *)&cmd_flow_director_mode,
11904 (void *)&cmd_flow_director_mode_tunnel,
11905 (void *)&cmd_flow_director_ops,
11906 (void *)&cmd_flow_director_mac,
11907 (void *)&cmd_flow_director_mac_addr,
11908 (void *)&cmd_flow_director_vlan,
11909 (void *)&cmd_flow_director_vlan_value,
11910 (void *)&cmd_flow_director_tunnel,
11911 (void *)&cmd_flow_director_tunnel_type,
11912 (void *)&cmd_flow_director_tunnel_id,
11913 (void *)&cmd_flow_director_tunnel_id_value,
11914 (void *)&cmd_flow_director_flexbytes,
11915 (void *)&cmd_flow_director_flexbytes_value,
11916 (void *)&cmd_flow_director_drop,
11917 (void *)&cmd_flow_director_queue,
11918 (void *)&cmd_flow_director_queue_id,
11919 (void *)&cmd_flow_director_fd_id,
11920 (void *)&cmd_flow_director_fd_id_value,
11925 cmdline_parse_inst_t cmd_add_del_raw_flow_director = {
11926 .f = cmd_flow_director_filter_parsed,
11928 .help_str = "flow_director_filter ... : Add or delete a raw flow "
11929 "director entry on NIC",
11931 (void *)&cmd_flow_director_filter,
11932 (void *)&cmd_flow_director_port_id,
11933 (void *)&cmd_flow_director_mode,
11934 (void *)&cmd_flow_director_mode_raw,
11935 (void *)&cmd_flow_director_ops,
11936 (void *)&cmd_flow_director_flow,
11937 (void *)&cmd_flow_director_flow_type,
11938 (void *)&cmd_flow_director_drop,
11939 (void *)&cmd_flow_director_queue,
11940 (void *)&cmd_flow_director_queue_id,
11941 (void *)&cmd_flow_director_fd_id,
11942 (void *)&cmd_flow_director_fd_id_value,
11943 (void *)&cmd_flow_director_packet,
11944 (void *)&cmd_flow_director_filepath,
11949 struct cmd_flush_flow_director_result {
11950 cmdline_fixed_string_t flush_flow_director;
11954 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
11955 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
11956 flush_flow_director, "flush_flow_director");
11957 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
11958 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
11962 cmd_flush_flow_director_parsed(void *parsed_result,
11963 __rte_unused struct cmdline *cl,
11964 __rte_unused void *data)
11966 struct cmd_flow_director_result *res = parsed_result;
11969 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
11971 printf("flow director is not supported on port %u.\n",
11976 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11977 RTE_ETH_FILTER_FLUSH, NULL);
11979 printf("flow director table flushing error: (%s)\n",
11983 cmdline_parse_inst_t cmd_flush_flow_director = {
11984 .f = cmd_flush_flow_director_parsed,
11986 .help_str = "flush_flow_director <port_id>: "
11987 "Flush all flow director entries of a device on NIC",
11989 (void *)&cmd_flush_flow_director_flush,
11990 (void *)&cmd_flush_flow_director_port_id,
11995 /* *** deal with flow director mask *** */
11996 struct cmd_flow_director_mask_result {
11997 cmdline_fixed_string_t flow_director_mask;
11999 cmdline_fixed_string_t mode;
12000 cmdline_fixed_string_t mode_value;
12001 cmdline_fixed_string_t vlan;
12002 uint16_t vlan_mask;
12003 cmdline_fixed_string_t src_mask;
12004 cmdline_ipaddr_t ipv4_src;
12005 cmdline_ipaddr_t ipv6_src;
12007 cmdline_fixed_string_t dst_mask;
12008 cmdline_ipaddr_t ipv4_dst;
12009 cmdline_ipaddr_t ipv6_dst;
12011 cmdline_fixed_string_t mac;
12012 uint8_t mac_addr_byte_mask;
12013 cmdline_fixed_string_t tunnel_id;
12014 uint32_t tunnel_id_mask;
12015 cmdline_fixed_string_t tunnel_type;
12016 uint8_t tunnel_type_mask;
12020 cmd_flow_director_mask_parsed(void *parsed_result,
12021 __rte_unused struct cmdline *cl,
12022 __rte_unused void *data)
12024 struct cmd_flow_director_mask_result *res = parsed_result;
12025 struct rte_eth_fdir_masks *mask;
12026 struct rte_port *port;
12028 port = &ports[res->port_id];
12029 /** Check if the port is not started **/
12030 if (port->port_status != RTE_PORT_STOPPED) {
12031 printf("Please stop port %d first\n", res->port_id);
12035 mask = &port->dev_conf.fdir_conf.mask;
12037 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
12038 if (strcmp(res->mode_value, "MAC-VLAN")) {
12039 printf("Please set mode to MAC-VLAN.\n");
12043 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
12044 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
12045 if (strcmp(res->mode_value, "Tunnel")) {
12046 printf("Please set mode to Tunnel.\n");
12050 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
12051 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
12052 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
12053 mask->tunnel_type_mask = res->tunnel_type_mask;
12055 if (strcmp(res->mode_value, "IP")) {
12056 printf("Please set mode to IP.\n");
12060 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
12061 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
12062 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
12063 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
12064 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
12065 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
12066 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
12069 cmd_reconfig_device_queue(res->port_id, 1, 1);
12072 cmdline_parse_token_string_t cmd_flow_director_mask =
12073 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
12074 flow_director_mask, "flow_director_mask");
12075 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
12076 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
12078 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
12079 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
12081 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
12082 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
12083 vlan_mask, UINT16);
12084 cmdline_parse_token_string_t cmd_flow_director_mask_src =
12085 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
12086 src_mask, "src_mask");
12087 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
12088 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
12090 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
12091 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
12093 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
12094 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
12096 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
12097 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
12098 dst_mask, "dst_mask");
12099 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
12100 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
12102 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
12103 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
12105 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
12106 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
12109 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
12110 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
12112 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
12113 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
12115 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
12116 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
12117 mode_value, "MAC-VLAN");
12118 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
12119 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
12120 mode_value, "Tunnel");
12121 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
12122 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
12124 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
12125 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
12126 mac_addr_byte_mask, UINT8);
12127 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
12128 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
12129 tunnel_type, "tunnel-type");
12130 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
12131 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
12132 tunnel_type_mask, UINT8);
12133 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
12134 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
12135 tunnel_id, "tunnel-id");
12136 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
12137 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
12138 tunnel_id_mask, UINT32);
12140 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
12141 .f = cmd_flow_director_mask_parsed,
12143 .help_str = "flow_director_mask ... : "
12144 "Set IP mode flow director's mask on NIC",
12146 (void *)&cmd_flow_director_mask,
12147 (void *)&cmd_flow_director_mask_port_id,
12148 (void *)&cmd_flow_director_mask_mode,
12149 (void *)&cmd_flow_director_mask_mode_ip,
12150 (void *)&cmd_flow_director_mask_vlan,
12151 (void *)&cmd_flow_director_mask_vlan_value,
12152 (void *)&cmd_flow_director_mask_src,
12153 (void *)&cmd_flow_director_mask_ipv4_src,
12154 (void *)&cmd_flow_director_mask_ipv6_src,
12155 (void *)&cmd_flow_director_mask_port_src,
12156 (void *)&cmd_flow_director_mask_dst,
12157 (void *)&cmd_flow_director_mask_ipv4_dst,
12158 (void *)&cmd_flow_director_mask_ipv6_dst,
12159 (void *)&cmd_flow_director_mask_port_dst,
12164 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
12165 .f = cmd_flow_director_mask_parsed,
12167 .help_str = "flow_director_mask ... : Set MAC VLAN mode "
12168 "flow director's mask on NIC",
12170 (void *)&cmd_flow_director_mask,
12171 (void *)&cmd_flow_director_mask_port_id,
12172 (void *)&cmd_flow_director_mask_mode,
12173 (void *)&cmd_flow_director_mask_mode_mac_vlan,
12174 (void *)&cmd_flow_director_mask_vlan,
12175 (void *)&cmd_flow_director_mask_vlan_value,
12180 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
12181 .f = cmd_flow_director_mask_parsed,
12183 .help_str = "flow_director_mask ... : Set tunnel mode "
12184 "flow director's mask on NIC",
12186 (void *)&cmd_flow_director_mask,
12187 (void *)&cmd_flow_director_mask_port_id,
12188 (void *)&cmd_flow_director_mask_mode,
12189 (void *)&cmd_flow_director_mask_mode_tunnel,
12190 (void *)&cmd_flow_director_mask_vlan,
12191 (void *)&cmd_flow_director_mask_vlan_value,
12192 (void *)&cmd_flow_director_mask_mac,
12193 (void *)&cmd_flow_director_mask_mac_value,
12194 (void *)&cmd_flow_director_mask_tunnel_type,
12195 (void *)&cmd_flow_director_mask_tunnel_type_value,
12196 (void *)&cmd_flow_director_mask_tunnel_id,
12197 (void *)&cmd_flow_director_mask_tunnel_id_value,
12202 /* *** deal with flow director mask on flexible payload *** */
12203 struct cmd_flow_director_flex_mask_result {
12204 cmdline_fixed_string_t flow_director_flexmask;
12206 cmdline_fixed_string_t flow;
12207 cmdline_fixed_string_t flow_type;
12208 cmdline_fixed_string_t mask;
12212 cmd_flow_director_flex_mask_parsed(void *parsed_result,
12213 __rte_unused struct cmdline *cl,
12214 __rte_unused void *data)
12216 struct cmd_flow_director_flex_mask_result *res = parsed_result;
12217 struct rte_eth_fdir_info fdir_info;
12218 struct rte_eth_fdir_flex_mask flex_mask;
12219 struct rte_port *port;
12220 uint64_t flow_type_mask;
12224 port = &ports[res->port_id];
12225 /** Check if the port is not started **/
12226 if (port->port_status != RTE_PORT_STOPPED) {
12227 printf("Please stop port %d first\n", res->port_id);
12231 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
12232 ret = parse_flexbytes(res->mask,
12234 RTE_ETH_FDIR_MAX_FLEXLEN);
12236 printf("error: Cannot parse mask input.\n");
12240 memset(&fdir_info, 0, sizeof(fdir_info));
12241 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
12242 RTE_ETH_FILTER_INFO, &fdir_info);
12244 printf("Cannot get FDir filter info\n");
12248 if (!strcmp(res->flow_type, "none")) {
12249 /* means don't specify the flow type */
12250 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN;
12251 for (i = 0; i < RTE_ETH_FLOW_MAX; i++)
12252 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i],
12253 0, sizeof(struct rte_eth_fdir_flex_mask));
12254 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1;
12255 rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0],
12257 sizeof(struct rte_eth_fdir_flex_mask));
12258 cmd_reconfig_device_queue(res->port_id, 1, 1);
12261 flow_type_mask = fdir_info.flow_types_mask[0];
12262 if (!strcmp(res->flow_type, "all")) {
12263 if (!flow_type_mask) {
12264 printf("No flow type supported\n");
12267 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
12268 if (flow_type_mask & (1ULL << i)) {
12269 flex_mask.flow_type = i;
12270 fdir_set_flex_mask(res->port_id, &flex_mask);
12273 cmd_reconfig_device_queue(res->port_id, 1, 1);
12276 flex_mask.flow_type = str2flowtype(res->flow_type);
12277 if (!(flow_type_mask & (1ULL << flex_mask.flow_type))) {
12278 printf("Flow type %s not supported on port %d\n",
12279 res->flow_type, res->port_id);
12282 fdir_set_flex_mask(res->port_id, &flex_mask);
12283 cmd_reconfig_device_queue(res->port_id, 1, 1);
12286 cmdline_parse_token_string_t cmd_flow_director_flexmask =
12287 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
12288 flow_director_flexmask,
12289 "flow_director_flex_mask");
12290 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
12291 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
12293 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
12294 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
12296 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
12297 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
12298 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
12299 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all");
12300 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
12301 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
12304 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
12305 .f = cmd_flow_director_flex_mask_parsed,
12307 .help_str = "flow_director_flex_mask ... : "
12308 "Set flow director's flex mask on NIC",
12310 (void *)&cmd_flow_director_flexmask,
12311 (void *)&cmd_flow_director_flexmask_port_id,
12312 (void *)&cmd_flow_director_flexmask_flow,
12313 (void *)&cmd_flow_director_flexmask_flow_type,
12314 (void *)&cmd_flow_director_flexmask_mask,
12319 /* *** deal with flow director flexible payload configuration *** */
12320 struct cmd_flow_director_flexpayload_result {
12321 cmdline_fixed_string_t flow_director_flexpayload;
12323 cmdline_fixed_string_t payload_layer;
12324 cmdline_fixed_string_t payload_cfg;
12328 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
12331 const char *p, *p0 = q_arg;
12333 unsigned long int_fld;
12334 char *str_fld[max_num];
12339 p = strchr(p0, '(');
12343 p0 = strchr(p, ')');
12348 if (size >= sizeof(s))
12351 snprintf(s, sizeof(s), "%.*s", size, p);
12352 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
12353 if (ret < 0 || ret > max_num)
12355 for (i = 0; i < ret; i++) {
12357 int_fld = strtoul(str_fld[i], &end, 0);
12358 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
12360 offsets[i] = (uint16_t)int_fld;
12366 cmd_flow_director_flxpld_parsed(void *parsed_result,
12367 __rte_unused struct cmdline *cl,
12368 __rte_unused void *data)
12370 struct cmd_flow_director_flexpayload_result *res = parsed_result;
12371 struct rte_eth_flex_payload_cfg flex_cfg;
12372 struct rte_port *port;
12375 port = &ports[res->port_id];
12376 /** Check if the port is not started **/
12377 if (port->port_status != RTE_PORT_STOPPED) {
12378 printf("Please stop port %d first\n", res->port_id);
12382 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
12384 if (!strcmp(res->payload_layer, "raw"))
12385 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
12386 else if (!strcmp(res->payload_layer, "l2"))
12387 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
12388 else if (!strcmp(res->payload_layer, "l3"))
12389 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
12390 else if (!strcmp(res->payload_layer, "l4"))
12391 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
12393 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
12394 RTE_ETH_FDIR_MAX_FLEXLEN);
12396 printf("error: Cannot parse flex payload input.\n");
12400 fdir_set_flex_payload(res->port_id, &flex_cfg);
12401 cmd_reconfig_device_queue(res->port_id, 1, 1);
12404 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
12405 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
12406 flow_director_flexpayload,
12407 "flow_director_flex_payload");
12408 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
12409 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
12411 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
12412 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
12413 payload_layer, "raw#l2#l3#l4");
12414 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
12415 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
12416 payload_cfg, NULL);
12418 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
12419 .f = cmd_flow_director_flxpld_parsed,
12421 .help_str = "flow_director_flexpayload ... : "
12422 "Set flow director's flex payload on NIC",
12424 (void *)&cmd_flow_director_flexpayload,
12425 (void *)&cmd_flow_director_flexpayload_port_id,
12426 (void *)&cmd_flow_director_flexpayload_payload_layer,
12427 (void *)&cmd_flow_director_flexpayload_payload_cfg,
12432 /* Generic flow interface command. */
12433 extern cmdline_parse_inst_t cmd_flow;
12435 /* *** Classification Filters Control *** */
12436 /* *** Get symmetric hash enable per port *** */
12437 struct cmd_get_sym_hash_ena_per_port_result {
12438 cmdline_fixed_string_t get_sym_hash_ena_per_port;
12443 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
12444 __rte_unused struct cmdline *cl,
12445 __rte_unused void *data)
12447 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
12448 struct rte_eth_hash_filter_info info;
12451 if (rte_eth_dev_filter_supported(res->port_id,
12452 RTE_ETH_FILTER_HASH) < 0) {
12453 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
12458 memset(&info, 0, sizeof(info));
12459 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
12460 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12461 RTE_ETH_FILTER_GET, &info);
12464 printf("Cannot get symmetric hash enable per port "
12465 "on port %u\n", res->port_id);
12469 printf("Symmetric hash is %s on port %u\n", info.info.enable ?
12470 "enabled" : "disabled", res->port_id);
12473 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
12474 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
12475 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
12476 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
12477 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
12480 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
12481 .f = cmd_get_sym_hash_per_port_parsed,
12483 .help_str = "get_sym_hash_ena_per_port <port_id>",
12485 (void *)&cmd_get_sym_hash_ena_per_port_all,
12486 (void *)&cmd_get_sym_hash_ena_per_port_port_id,
12491 /* *** Set symmetric hash enable per port *** */
12492 struct cmd_set_sym_hash_ena_per_port_result {
12493 cmdline_fixed_string_t set_sym_hash_ena_per_port;
12494 cmdline_fixed_string_t enable;
12499 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
12500 __rte_unused struct cmdline *cl,
12501 __rte_unused void *data)
12503 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
12504 struct rte_eth_hash_filter_info info;
12507 if (rte_eth_dev_filter_supported(res->port_id,
12508 RTE_ETH_FILTER_HASH) < 0) {
12509 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
12514 memset(&info, 0, sizeof(info));
12515 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
12516 if (!strcmp(res->enable, "enable"))
12517 info.info.enable = 1;
12518 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12519 RTE_ETH_FILTER_SET, &info);
12521 printf("Cannot set symmetric hash enable per port on "
12522 "port %u\n", res->port_id);
12525 printf("Symmetric hash has been set to %s on port %u\n",
12526 res->enable, res->port_id);
12529 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
12530 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
12531 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
12532 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
12533 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
12535 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
12536 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
12537 enable, "enable#disable");
12539 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
12540 .f = cmd_set_sym_hash_per_port_parsed,
12542 .help_str = "set_sym_hash_ena_per_port <port_id> enable|disable",
12544 (void *)&cmd_set_sym_hash_ena_per_port_all,
12545 (void *)&cmd_set_sym_hash_ena_per_port_port_id,
12546 (void *)&cmd_set_sym_hash_ena_per_port_enable,
12551 /* Get global config of hash function */
12552 struct cmd_get_hash_global_config_result {
12553 cmdline_fixed_string_t get_hash_global_config;
12558 flowtype_to_str(uint16_t ftype)
12564 } ftype_table[] = {
12565 {"ipv4", RTE_ETH_FLOW_IPV4},
12566 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
12567 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
12568 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
12569 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
12570 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
12571 {"ipv6", RTE_ETH_FLOW_IPV6},
12572 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
12573 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
12574 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
12575 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
12576 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
12577 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
12578 {"port", RTE_ETH_FLOW_PORT},
12579 {"vxlan", RTE_ETH_FLOW_VXLAN},
12580 {"geneve", RTE_ETH_FLOW_GENEVE},
12581 {"nvgre", RTE_ETH_FLOW_NVGRE},
12582 {"vxlan-gpe", RTE_ETH_FLOW_VXLAN_GPE},
12585 for (i = 0; i < RTE_DIM(ftype_table); i++) {
12586 if (ftype_table[i].ftype == ftype)
12587 return ftype_table[i].str;
12594 cmd_get_hash_global_config_parsed(void *parsed_result,
12595 __rte_unused struct cmdline *cl,
12596 __rte_unused void *data)
12598 struct cmd_get_hash_global_config_result *res = parsed_result;
12599 struct rte_eth_hash_filter_info info;
12600 uint32_t idx, offset;
12605 if (rte_eth_dev_filter_supported(res->port_id,
12606 RTE_ETH_FILTER_HASH) < 0) {
12607 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
12612 memset(&info, 0, sizeof(info));
12613 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
12614 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12615 RTE_ETH_FILTER_GET, &info);
12617 printf("Cannot get hash global configurations by port %d\n",
12622 switch (info.info.global_conf.hash_func) {
12623 case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
12624 printf("Hash function is Toeplitz\n");
12626 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
12627 printf("Hash function is Simple XOR\n");
12629 case RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ:
12630 printf("Hash function is Symmetric Toeplitz\n");
12633 printf("Unknown hash function\n");
12637 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) {
12638 idx = i / UINT64_BIT;
12639 offset = i % UINT64_BIT;
12640 if (!(info.info.global_conf.valid_bit_mask[idx] &
12643 str = flowtype_to_str(i);
12646 printf("Symmetric hash is %s globally for flow type %s "
12648 ((info.info.global_conf.sym_hash_enable_mask[idx] &
12649 (1ULL << offset)) ? "enabled" : "disabled"), str,
12654 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
12655 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
12656 get_hash_global_config, "get_hash_global_config");
12657 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
12658 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
12661 cmdline_parse_inst_t cmd_get_hash_global_config = {
12662 .f = cmd_get_hash_global_config_parsed,
12664 .help_str = "get_hash_global_config <port_id>",
12666 (void *)&cmd_get_hash_global_config_all,
12667 (void *)&cmd_get_hash_global_config_port_id,
12672 /* Set global config of hash function */
12673 struct cmd_set_hash_global_config_result {
12674 cmdline_fixed_string_t set_hash_global_config;
12676 cmdline_fixed_string_t hash_func;
12677 cmdline_fixed_string_t flow_type;
12678 cmdline_fixed_string_t enable;
12682 cmd_set_hash_global_config_parsed(void *parsed_result,
12683 __rte_unused struct cmdline *cl,
12684 __rte_unused void *data)
12686 struct cmd_set_hash_global_config_result *res = parsed_result;
12687 struct rte_eth_hash_filter_info info;
12688 uint32_t ftype, idx, offset;
12691 if (rte_eth_dev_filter_supported(res->port_id,
12692 RTE_ETH_FILTER_HASH) < 0) {
12693 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
12697 memset(&info, 0, sizeof(info));
12698 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
12699 if (!strcmp(res->hash_func, "toeplitz"))
12700 info.info.global_conf.hash_func =
12701 RTE_ETH_HASH_FUNCTION_TOEPLITZ;
12702 else if (!strcmp(res->hash_func, "simple_xor"))
12703 info.info.global_conf.hash_func =
12704 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
12705 else if (!strcmp(res->hash_func, "symmetric_toeplitz"))
12706 info.info.global_conf.hash_func =
12707 RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ;
12708 else if (!strcmp(res->hash_func, "default"))
12709 info.info.global_conf.hash_func =
12710 RTE_ETH_HASH_FUNCTION_DEFAULT;
12712 ftype = str2flowtype(res->flow_type);
12713 idx = ftype / UINT64_BIT;
12714 offset = ftype % UINT64_BIT;
12715 info.info.global_conf.valid_bit_mask[idx] |= (1ULL << offset);
12716 if (!strcmp(res->enable, "enable"))
12717 info.info.global_conf.sym_hash_enable_mask[idx] |=
12719 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12720 RTE_ETH_FILTER_SET, &info);
12722 printf("Cannot set global hash configurations by port %d\n",
12725 printf("Global hash configurations have been set "
12726 "successfully by port %d\n", res->port_id);
12729 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
12730 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12731 set_hash_global_config, "set_hash_global_config");
12732 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
12733 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
12735 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
12736 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12737 hash_func, "toeplitz#simple_xor#symmetric_toeplitz#default");
12738 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
12739 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12741 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
12742 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
12743 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
12744 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12745 enable, "enable#disable");
12747 cmdline_parse_inst_t cmd_set_hash_global_config = {
12748 .f = cmd_set_hash_global_config_parsed,
12750 .help_str = "set_hash_global_config <port_id> "
12751 "toeplitz|simple_xor|symmetric_toeplitz|default "
12752 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12753 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
12754 "l2_payload enable|disable",
12756 (void *)&cmd_set_hash_global_config_all,
12757 (void *)&cmd_set_hash_global_config_port_id,
12758 (void *)&cmd_set_hash_global_config_hash_func,
12759 (void *)&cmd_set_hash_global_config_flow_type,
12760 (void *)&cmd_set_hash_global_config_enable,
12765 /* Set hash input set */
12766 struct cmd_set_hash_input_set_result {
12767 cmdline_fixed_string_t set_hash_input_set;
12769 cmdline_fixed_string_t flow_type;
12770 cmdline_fixed_string_t inset_field;
12771 cmdline_fixed_string_t select;
12774 static enum rte_eth_input_set_field
12775 str2inset(char *string)
12779 static const struct {
12781 enum rte_eth_input_set_field inset;
12782 } inset_table[] = {
12783 {"ethertype", RTE_ETH_INPUT_SET_L2_ETHERTYPE},
12784 {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN},
12785 {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN},
12786 {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4},
12787 {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4},
12788 {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS},
12789 {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO},
12790 {"ipv4-ttl", RTE_ETH_INPUT_SET_L3_IP4_TTL},
12791 {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6},
12792 {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6},
12793 {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC},
12794 {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER},
12795 {"ipv6-hop-limits", RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS},
12796 {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT},
12797 {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT},
12798 {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT},
12799 {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT},
12800 {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT},
12801 {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT},
12802 {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG},
12803 {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY},
12804 {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY},
12805 {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD},
12806 {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD},
12807 {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD},
12808 {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD},
12809 {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD},
12810 {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD},
12811 {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD},
12812 {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD},
12813 {"none", RTE_ETH_INPUT_SET_NONE},
12816 for (i = 0; i < RTE_DIM(inset_table); i++) {
12817 if (!strcmp(string, inset_table[i].str))
12818 return inset_table[i].inset;
12821 return RTE_ETH_INPUT_SET_UNKNOWN;
12825 cmd_set_hash_input_set_parsed(void *parsed_result,
12826 __rte_unused struct cmdline *cl,
12827 __rte_unused void *data)
12829 struct cmd_set_hash_input_set_result *res = parsed_result;
12830 struct rte_eth_hash_filter_info info;
12832 memset(&info, 0, sizeof(info));
12833 info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT;
12834 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
12835 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
12836 info.info.input_set_conf.inset_size = 1;
12837 if (!strcmp(res->select, "select"))
12838 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
12839 else if (!strcmp(res->select, "add"))
12840 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
12841 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12842 RTE_ETH_FILTER_SET, &info);
12845 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd =
12846 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12847 set_hash_input_set, "set_hash_input_set");
12848 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id =
12849 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result,
12851 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type =
12852 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12854 cmdline_parse_token_string_t cmd_set_hash_input_set_field =
12855 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12857 "ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
12858 "ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#"
12859 "udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#"
12860 "sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#"
12861 "fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#"
12863 cmdline_parse_token_string_t cmd_set_hash_input_set_select =
12864 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12865 select, "select#add");
12867 cmdline_parse_inst_t cmd_set_hash_input_set = {
12868 .f = cmd_set_hash_input_set_parsed,
12870 .help_str = "set_hash_input_set <port_id> "
12871 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12872 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload|<flowtype_id> "
12873 "ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|"
12874 "ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|"
12875 "tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|"
12876 "gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
12877 "fld-7th|fld-8th|none select|add",
12879 (void *)&cmd_set_hash_input_set_cmd,
12880 (void *)&cmd_set_hash_input_set_port_id,
12881 (void *)&cmd_set_hash_input_set_flow_type,
12882 (void *)&cmd_set_hash_input_set_field,
12883 (void *)&cmd_set_hash_input_set_select,
12888 /* Set flow director input set */
12889 struct cmd_set_fdir_input_set_result {
12890 cmdline_fixed_string_t set_fdir_input_set;
12892 cmdline_fixed_string_t flow_type;
12893 cmdline_fixed_string_t inset_field;
12894 cmdline_fixed_string_t select;
12898 cmd_set_fdir_input_set_parsed(void *parsed_result,
12899 __rte_unused struct cmdline *cl,
12900 __rte_unused void *data)
12902 struct cmd_set_fdir_input_set_result *res = parsed_result;
12903 struct rte_eth_fdir_filter_info info;
12905 memset(&info, 0, sizeof(info));
12906 info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT;
12907 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
12908 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
12909 info.info.input_set_conf.inset_size = 1;
12910 if (!strcmp(res->select, "select"))
12911 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
12912 else if (!strcmp(res->select, "add"))
12913 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
12914 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
12915 RTE_ETH_FILTER_SET, &info);
12918 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd =
12919 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12920 set_fdir_input_set, "set_fdir_input_set");
12921 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id =
12922 TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result,
12924 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type =
12925 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12927 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
12928 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
12929 cmdline_parse_token_string_t cmd_set_fdir_input_set_field =
12930 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12932 "ivlan#ethertype#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
12933 "ipv4-tos#ipv4-proto#ipv4-ttl#ipv6-tc#ipv6-next-header#"
12934 "ipv6-hop-limits#udp-src-port#udp-dst-port#"
12935 "tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#"
12936 "sctp-veri-tag#none");
12937 cmdline_parse_token_string_t cmd_set_fdir_input_set_select =
12938 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12939 select, "select#add");
12941 cmdline_parse_inst_t cmd_set_fdir_input_set = {
12942 .f = cmd_set_fdir_input_set_parsed,
12944 .help_str = "set_fdir_input_set <port_id> "
12945 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12946 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
12947 "ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|"
12948 "ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|ipv6-next-header|"
12949 "ipv6-hop-limits|udp-src-port|udp-dst-port|"
12950 "tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|"
12951 "sctp-veri-tag|none select|add",
12953 (void *)&cmd_set_fdir_input_set_cmd,
12954 (void *)&cmd_set_fdir_input_set_port_id,
12955 (void *)&cmd_set_fdir_input_set_flow_type,
12956 (void *)&cmd_set_fdir_input_set_field,
12957 (void *)&cmd_set_fdir_input_set_select,
12962 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
12963 struct cmd_mcast_addr_result {
12964 cmdline_fixed_string_t mcast_addr_cmd;
12965 cmdline_fixed_string_t what;
12967 struct rte_ether_addr mc_addr;
12970 static void cmd_mcast_addr_parsed(void *parsed_result,
12971 __rte_unused struct cmdline *cl,
12972 __rte_unused void *data)
12974 struct cmd_mcast_addr_result *res = parsed_result;
12976 if (!rte_is_multicast_ether_addr(&res->mc_addr)) {
12977 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
12978 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
12979 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
12980 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
12983 if (strcmp(res->what, "add") == 0)
12984 mcast_addr_add(res->port_num, &res->mc_addr);
12986 mcast_addr_remove(res->port_num, &res->mc_addr);
12989 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
12990 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
12991 mcast_addr_cmd, "mcast_addr");
12992 cmdline_parse_token_string_t cmd_mcast_addr_what =
12993 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
12995 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
12996 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT16);
12997 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
12998 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
13000 cmdline_parse_inst_t cmd_mcast_addr = {
13001 .f = cmd_mcast_addr_parsed,
13003 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
13004 "Add/Remove multicast MAC address on port_id",
13006 (void *)&cmd_mcast_addr_cmd,
13007 (void *)&cmd_mcast_addr_what,
13008 (void *)&cmd_mcast_addr_portnum,
13009 (void *)&cmd_mcast_addr_addr,
13014 /* l2 tunnel config
13015 * only support E-tag now.
13018 /* Ether type config */
13019 struct cmd_config_l2_tunnel_eth_type_result {
13020 cmdline_fixed_string_t port;
13021 cmdline_fixed_string_t config;
13022 cmdline_fixed_string_t all;
13024 cmdline_fixed_string_t l2_tunnel;
13025 cmdline_fixed_string_t l2_tunnel_type;
13026 cmdline_fixed_string_t eth_type;
13027 uint16_t eth_type_val;
13030 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port =
13031 TOKEN_STRING_INITIALIZER
13032 (struct cmd_config_l2_tunnel_eth_type_result,
13034 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config =
13035 TOKEN_STRING_INITIALIZER
13036 (struct cmd_config_l2_tunnel_eth_type_result,
13038 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str =
13039 TOKEN_STRING_INITIALIZER
13040 (struct cmd_config_l2_tunnel_eth_type_result,
13042 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id =
13043 TOKEN_NUM_INITIALIZER
13044 (struct cmd_config_l2_tunnel_eth_type_result,
13046 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel =
13047 TOKEN_STRING_INITIALIZER
13048 (struct cmd_config_l2_tunnel_eth_type_result,
13049 l2_tunnel, "l2-tunnel");
13050 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type =
13051 TOKEN_STRING_INITIALIZER
13052 (struct cmd_config_l2_tunnel_eth_type_result,
13053 l2_tunnel_type, "E-tag");
13054 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type =
13055 TOKEN_STRING_INITIALIZER
13056 (struct cmd_config_l2_tunnel_eth_type_result,
13057 eth_type, "ether-type");
13058 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val =
13059 TOKEN_NUM_INITIALIZER
13060 (struct cmd_config_l2_tunnel_eth_type_result,
13061 eth_type_val, UINT16);
13063 static enum rte_eth_tunnel_type
13064 str2fdir_l2_tunnel_type(char *string)
13068 static const struct {
13070 enum rte_eth_tunnel_type type;
13071 } l2_tunnel_type_str[] = {
13072 {"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG},
13075 for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) {
13076 if (!strcmp(l2_tunnel_type_str[i].str, string))
13077 return l2_tunnel_type_str[i].type;
13079 return RTE_TUNNEL_TYPE_NONE;
13082 /* ether type config for all ports */
13084 cmd_config_l2_tunnel_eth_type_all_parsed
13085 (void *parsed_result,
13086 __rte_unused struct cmdline *cl,
13087 __rte_unused void *data)
13089 struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result;
13090 struct rte_eth_l2_tunnel_conf entry;
13093 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
13094 entry.ether_type = res->eth_type_val;
13096 RTE_ETH_FOREACH_DEV(pid) {
13097 rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry);
13101 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = {
13102 .f = cmd_config_l2_tunnel_eth_type_all_parsed,
13104 .help_str = "port config all l2-tunnel E-tag ether-type <value>",
13106 (void *)&cmd_config_l2_tunnel_eth_type_port,
13107 (void *)&cmd_config_l2_tunnel_eth_type_config,
13108 (void *)&cmd_config_l2_tunnel_eth_type_all_str,
13109 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
13110 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
13111 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
13112 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
13117 /* ether type config for a specific port */
13119 cmd_config_l2_tunnel_eth_type_specific_parsed(
13120 void *parsed_result,
13121 __rte_unused struct cmdline *cl,
13122 __rte_unused void *data)
13124 struct cmd_config_l2_tunnel_eth_type_result *res =
13126 struct rte_eth_l2_tunnel_conf entry;
13128 if (port_id_is_invalid(res->id, ENABLED_WARN))
13131 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
13132 entry.ether_type = res->eth_type_val;
13134 rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry);
13137 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = {
13138 .f = cmd_config_l2_tunnel_eth_type_specific_parsed,
13140 .help_str = "port config <port_id> l2-tunnel E-tag ether-type <value>",
13142 (void *)&cmd_config_l2_tunnel_eth_type_port,
13143 (void *)&cmd_config_l2_tunnel_eth_type_config,
13144 (void *)&cmd_config_l2_tunnel_eth_type_id,
13145 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
13146 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
13147 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
13148 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
13153 /* Enable/disable l2 tunnel */
13154 struct cmd_config_l2_tunnel_en_dis_result {
13155 cmdline_fixed_string_t port;
13156 cmdline_fixed_string_t config;
13157 cmdline_fixed_string_t all;
13159 cmdline_fixed_string_t l2_tunnel;
13160 cmdline_fixed_string_t l2_tunnel_type;
13161 cmdline_fixed_string_t en_dis;
13164 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port =
13165 TOKEN_STRING_INITIALIZER
13166 (struct cmd_config_l2_tunnel_en_dis_result,
13168 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config =
13169 TOKEN_STRING_INITIALIZER
13170 (struct cmd_config_l2_tunnel_en_dis_result,
13172 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str =
13173 TOKEN_STRING_INITIALIZER
13174 (struct cmd_config_l2_tunnel_en_dis_result,
13176 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id =
13177 TOKEN_NUM_INITIALIZER
13178 (struct cmd_config_l2_tunnel_en_dis_result,
13180 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel =
13181 TOKEN_STRING_INITIALIZER
13182 (struct cmd_config_l2_tunnel_en_dis_result,
13183 l2_tunnel, "l2-tunnel");
13184 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type =
13185 TOKEN_STRING_INITIALIZER
13186 (struct cmd_config_l2_tunnel_en_dis_result,
13187 l2_tunnel_type, "E-tag");
13188 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis =
13189 TOKEN_STRING_INITIALIZER
13190 (struct cmd_config_l2_tunnel_en_dis_result,
13191 en_dis, "enable#disable");
13193 /* enable/disable l2 tunnel for all ports */
13195 cmd_config_l2_tunnel_en_dis_all_parsed(
13196 void *parsed_result,
13197 __rte_unused struct cmdline *cl,
13198 __rte_unused void *data)
13200 struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result;
13201 struct rte_eth_l2_tunnel_conf entry;
13205 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
13207 if (!strcmp("enable", res->en_dis))
13212 RTE_ETH_FOREACH_DEV(pid) {
13213 rte_eth_dev_l2_tunnel_offload_set(pid,
13215 ETH_L2_TUNNEL_ENABLE_MASK,
13220 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = {
13221 .f = cmd_config_l2_tunnel_en_dis_all_parsed,
13223 .help_str = "port config all l2-tunnel E-tag enable|disable",
13225 (void *)&cmd_config_l2_tunnel_en_dis_port,
13226 (void *)&cmd_config_l2_tunnel_en_dis_config,
13227 (void *)&cmd_config_l2_tunnel_en_dis_all_str,
13228 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
13229 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
13230 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
13235 /* enable/disable l2 tunnel for a port */
13237 cmd_config_l2_tunnel_en_dis_specific_parsed(
13238 void *parsed_result,
13239 __rte_unused struct cmdline *cl,
13240 __rte_unused void *data)
13242 struct cmd_config_l2_tunnel_en_dis_result *res =
13244 struct rte_eth_l2_tunnel_conf entry;
13246 if (port_id_is_invalid(res->id, ENABLED_WARN))
13249 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
13251 if (!strcmp("enable", res->en_dis))
13252 rte_eth_dev_l2_tunnel_offload_set(res->id,
13254 ETH_L2_TUNNEL_ENABLE_MASK,
13257 rte_eth_dev_l2_tunnel_offload_set(res->id,
13259 ETH_L2_TUNNEL_ENABLE_MASK,
13263 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = {
13264 .f = cmd_config_l2_tunnel_en_dis_specific_parsed,
13266 .help_str = "port config <port_id> l2-tunnel E-tag enable|disable",
13268 (void *)&cmd_config_l2_tunnel_en_dis_port,
13269 (void *)&cmd_config_l2_tunnel_en_dis_config,
13270 (void *)&cmd_config_l2_tunnel_en_dis_id,
13271 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
13272 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
13273 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
13278 /* E-tag configuration */
13280 /* Common result structure for all E-tag configuration */
13281 struct cmd_config_e_tag_result {
13282 cmdline_fixed_string_t e_tag;
13283 cmdline_fixed_string_t set;
13284 cmdline_fixed_string_t insertion;
13285 cmdline_fixed_string_t stripping;
13286 cmdline_fixed_string_t forwarding;
13287 cmdline_fixed_string_t filter;
13288 cmdline_fixed_string_t add;
13289 cmdline_fixed_string_t del;
13290 cmdline_fixed_string_t on;
13291 cmdline_fixed_string_t off;
13292 cmdline_fixed_string_t on_off;
13293 cmdline_fixed_string_t port_tag_id;
13294 uint32_t port_tag_id_val;
13295 cmdline_fixed_string_t e_tag_id;
13296 uint16_t e_tag_id_val;
13297 cmdline_fixed_string_t dst_pool;
13298 uint8_t dst_pool_val;
13299 cmdline_fixed_string_t port;
13301 cmdline_fixed_string_t vf;
13305 /* Common CLI fields for all E-tag configuration */
13306 cmdline_parse_token_string_t cmd_config_e_tag_e_tag =
13307 TOKEN_STRING_INITIALIZER
13308 (struct cmd_config_e_tag_result,
13310 cmdline_parse_token_string_t cmd_config_e_tag_set =
13311 TOKEN_STRING_INITIALIZER
13312 (struct cmd_config_e_tag_result,
13314 cmdline_parse_token_string_t cmd_config_e_tag_insertion =
13315 TOKEN_STRING_INITIALIZER
13316 (struct cmd_config_e_tag_result,
13317 insertion, "insertion");
13318 cmdline_parse_token_string_t cmd_config_e_tag_stripping =
13319 TOKEN_STRING_INITIALIZER
13320 (struct cmd_config_e_tag_result,
13321 stripping, "stripping");
13322 cmdline_parse_token_string_t cmd_config_e_tag_forwarding =
13323 TOKEN_STRING_INITIALIZER
13324 (struct cmd_config_e_tag_result,
13325 forwarding, "forwarding");
13326 cmdline_parse_token_string_t cmd_config_e_tag_filter =
13327 TOKEN_STRING_INITIALIZER
13328 (struct cmd_config_e_tag_result,
13330 cmdline_parse_token_string_t cmd_config_e_tag_add =
13331 TOKEN_STRING_INITIALIZER
13332 (struct cmd_config_e_tag_result,
13334 cmdline_parse_token_string_t cmd_config_e_tag_del =
13335 TOKEN_STRING_INITIALIZER
13336 (struct cmd_config_e_tag_result,
13338 cmdline_parse_token_string_t cmd_config_e_tag_on =
13339 TOKEN_STRING_INITIALIZER
13340 (struct cmd_config_e_tag_result,
13342 cmdline_parse_token_string_t cmd_config_e_tag_off =
13343 TOKEN_STRING_INITIALIZER
13344 (struct cmd_config_e_tag_result,
13346 cmdline_parse_token_string_t cmd_config_e_tag_on_off =
13347 TOKEN_STRING_INITIALIZER
13348 (struct cmd_config_e_tag_result,
13350 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id =
13351 TOKEN_STRING_INITIALIZER
13352 (struct cmd_config_e_tag_result,
13353 port_tag_id, "port-tag-id");
13354 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val =
13355 TOKEN_NUM_INITIALIZER
13356 (struct cmd_config_e_tag_result,
13357 port_tag_id_val, UINT32);
13358 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id =
13359 TOKEN_STRING_INITIALIZER
13360 (struct cmd_config_e_tag_result,
13361 e_tag_id, "e-tag-id");
13362 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val =
13363 TOKEN_NUM_INITIALIZER
13364 (struct cmd_config_e_tag_result,
13365 e_tag_id_val, UINT16);
13366 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool =
13367 TOKEN_STRING_INITIALIZER
13368 (struct cmd_config_e_tag_result,
13369 dst_pool, "dst-pool");
13370 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val =
13371 TOKEN_NUM_INITIALIZER
13372 (struct cmd_config_e_tag_result,
13373 dst_pool_val, UINT8);
13374 cmdline_parse_token_string_t cmd_config_e_tag_port =
13375 TOKEN_STRING_INITIALIZER
13376 (struct cmd_config_e_tag_result,
13378 cmdline_parse_token_num_t cmd_config_e_tag_port_id =
13379 TOKEN_NUM_INITIALIZER
13380 (struct cmd_config_e_tag_result,
13382 cmdline_parse_token_string_t cmd_config_e_tag_vf =
13383 TOKEN_STRING_INITIALIZER
13384 (struct cmd_config_e_tag_result,
13386 cmdline_parse_token_num_t cmd_config_e_tag_vf_id =
13387 TOKEN_NUM_INITIALIZER
13388 (struct cmd_config_e_tag_result,
13391 /* E-tag insertion configuration */
13393 cmd_config_e_tag_insertion_en_parsed(
13394 void *parsed_result,
13395 __rte_unused struct cmdline *cl,
13396 __rte_unused void *data)
13398 struct cmd_config_e_tag_result *res =
13400 struct rte_eth_l2_tunnel_conf entry;
13402 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13405 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13406 entry.tunnel_id = res->port_tag_id_val;
13407 entry.vf_id = res->vf_id;
13408 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
13410 ETH_L2_TUNNEL_INSERTION_MASK,
13415 cmd_config_e_tag_insertion_dis_parsed(
13416 void *parsed_result,
13417 __rte_unused struct cmdline *cl,
13418 __rte_unused void *data)
13420 struct cmd_config_e_tag_result *res =
13422 struct rte_eth_l2_tunnel_conf entry;
13424 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13427 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13428 entry.vf_id = res->vf_id;
13430 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
13432 ETH_L2_TUNNEL_INSERTION_MASK,
13436 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = {
13437 .f = cmd_config_e_tag_insertion_en_parsed,
13439 .help_str = "E-tag ... : E-tag insertion enable",
13441 (void *)&cmd_config_e_tag_e_tag,
13442 (void *)&cmd_config_e_tag_set,
13443 (void *)&cmd_config_e_tag_insertion,
13444 (void *)&cmd_config_e_tag_on,
13445 (void *)&cmd_config_e_tag_port_tag_id,
13446 (void *)&cmd_config_e_tag_port_tag_id_val,
13447 (void *)&cmd_config_e_tag_port,
13448 (void *)&cmd_config_e_tag_port_id,
13449 (void *)&cmd_config_e_tag_vf,
13450 (void *)&cmd_config_e_tag_vf_id,
13455 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = {
13456 .f = cmd_config_e_tag_insertion_dis_parsed,
13458 .help_str = "E-tag ... : E-tag insertion disable",
13460 (void *)&cmd_config_e_tag_e_tag,
13461 (void *)&cmd_config_e_tag_set,
13462 (void *)&cmd_config_e_tag_insertion,
13463 (void *)&cmd_config_e_tag_off,
13464 (void *)&cmd_config_e_tag_port,
13465 (void *)&cmd_config_e_tag_port_id,
13466 (void *)&cmd_config_e_tag_vf,
13467 (void *)&cmd_config_e_tag_vf_id,
13472 /* E-tag stripping configuration */
13474 cmd_config_e_tag_stripping_parsed(
13475 void *parsed_result,
13476 __rte_unused struct cmdline *cl,
13477 __rte_unused void *data)
13479 struct cmd_config_e_tag_result *res =
13481 struct rte_eth_l2_tunnel_conf entry;
13483 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13486 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13488 if (!strcmp(res->on_off, "on"))
13489 rte_eth_dev_l2_tunnel_offload_set
13492 ETH_L2_TUNNEL_STRIPPING_MASK,
13495 rte_eth_dev_l2_tunnel_offload_set
13498 ETH_L2_TUNNEL_STRIPPING_MASK,
13502 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = {
13503 .f = cmd_config_e_tag_stripping_parsed,
13505 .help_str = "E-tag ... : E-tag stripping enable/disable",
13507 (void *)&cmd_config_e_tag_e_tag,
13508 (void *)&cmd_config_e_tag_set,
13509 (void *)&cmd_config_e_tag_stripping,
13510 (void *)&cmd_config_e_tag_on_off,
13511 (void *)&cmd_config_e_tag_port,
13512 (void *)&cmd_config_e_tag_port_id,
13517 /* E-tag forwarding configuration */
13519 cmd_config_e_tag_forwarding_parsed(
13520 void *parsed_result,
13521 __rte_unused struct cmdline *cl,
13522 __rte_unused void *data)
13524 struct cmd_config_e_tag_result *res = parsed_result;
13525 struct rte_eth_l2_tunnel_conf entry;
13527 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13530 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13532 if (!strcmp(res->on_off, "on"))
13533 rte_eth_dev_l2_tunnel_offload_set
13536 ETH_L2_TUNNEL_FORWARDING_MASK,
13539 rte_eth_dev_l2_tunnel_offload_set
13542 ETH_L2_TUNNEL_FORWARDING_MASK,
13546 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = {
13547 .f = cmd_config_e_tag_forwarding_parsed,
13549 .help_str = "E-tag ... : E-tag forwarding enable/disable",
13551 (void *)&cmd_config_e_tag_e_tag,
13552 (void *)&cmd_config_e_tag_set,
13553 (void *)&cmd_config_e_tag_forwarding,
13554 (void *)&cmd_config_e_tag_on_off,
13555 (void *)&cmd_config_e_tag_port,
13556 (void *)&cmd_config_e_tag_port_id,
13561 /* E-tag filter configuration */
13563 cmd_config_e_tag_filter_add_parsed(
13564 void *parsed_result,
13565 __rte_unused struct cmdline *cl,
13566 __rte_unused void *data)
13568 struct cmd_config_e_tag_result *res = parsed_result;
13569 struct rte_eth_l2_tunnel_conf entry;
13572 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13575 if (res->e_tag_id_val > 0x3fff) {
13576 printf("e-tag-id must be equal or less than 0x3fff.\n");
13580 ret = rte_eth_dev_filter_supported(res->port_id,
13581 RTE_ETH_FILTER_L2_TUNNEL);
13583 printf("E-tag filter is not supported on port %u.\n",
13588 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13589 entry.tunnel_id = res->e_tag_id_val;
13590 entry.pool = res->dst_pool_val;
13592 ret = rte_eth_dev_filter_ctrl(res->port_id,
13593 RTE_ETH_FILTER_L2_TUNNEL,
13594 RTE_ETH_FILTER_ADD,
13597 printf("E-tag filter programming error: (%s)\n",
13601 cmdline_parse_inst_t cmd_config_e_tag_filter_add = {
13602 .f = cmd_config_e_tag_filter_add_parsed,
13604 .help_str = "E-tag ... : E-tag filter add",
13606 (void *)&cmd_config_e_tag_e_tag,
13607 (void *)&cmd_config_e_tag_set,
13608 (void *)&cmd_config_e_tag_filter,
13609 (void *)&cmd_config_e_tag_add,
13610 (void *)&cmd_config_e_tag_e_tag_id,
13611 (void *)&cmd_config_e_tag_e_tag_id_val,
13612 (void *)&cmd_config_e_tag_dst_pool,
13613 (void *)&cmd_config_e_tag_dst_pool_val,
13614 (void *)&cmd_config_e_tag_port,
13615 (void *)&cmd_config_e_tag_port_id,
13621 cmd_config_e_tag_filter_del_parsed(
13622 void *parsed_result,
13623 __rte_unused struct cmdline *cl,
13624 __rte_unused void *data)
13626 struct cmd_config_e_tag_result *res = parsed_result;
13627 struct rte_eth_l2_tunnel_conf entry;
13630 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13633 if (res->e_tag_id_val > 0x3fff) {
13634 printf("e-tag-id must be less than 0x3fff.\n");
13638 ret = rte_eth_dev_filter_supported(res->port_id,
13639 RTE_ETH_FILTER_L2_TUNNEL);
13641 printf("E-tag filter is not supported on port %u.\n",
13646 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13647 entry.tunnel_id = res->e_tag_id_val;
13649 ret = rte_eth_dev_filter_ctrl(res->port_id,
13650 RTE_ETH_FILTER_L2_TUNNEL,
13651 RTE_ETH_FILTER_DELETE,
13654 printf("E-tag filter programming error: (%s)\n",
13658 cmdline_parse_inst_t cmd_config_e_tag_filter_del = {
13659 .f = cmd_config_e_tag_filter_del_parsed,
13661 .help_str = "E-tag ... : E-tag filter delete",
13663 (void *)&cmd_config_e_tag_e_tag,
13664 (void *)&cmd_config_e_tag_set,
13665 (void *)&cmd_config_e_tag_filter,
13666 (void *)&cmd_config_e_tag_del,
13667 (void *)&cmd_config_e_tag_e_tag_id,
13668 (void *)&cmd_config_e_tag_e_tag_id_val,
13669 (void *)&cmd_config_e_tag_port,
13670 (void *)&cmd_config_e_tag_port_id,
13675 /* vf vlan anti spoof configuration */
13677 /* Common result structure for vf vlan anti spoof */
13678 struct cmd_vf_vlan_anti_spoof_result {
13679 cmdline_fixed_string_t set;
13680 cmdline_fixed_string_t vf;
13681 cmdline_fixed_string_t vlan;
13682 cmdline_fixed_string_t antispoof;
13685 cmdline_fixed_string_t on_off;
13688 /* Common CLI fields for vf vlan anti spoof enable disable */
13689 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
13690 TOKEN_STRING_INITIALIZER
13691 (struct cmd_vf_vlan_anti_spoof_result,
13693 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
13694 TOKEN_STRING_INITIALIZER
13695 (struct cmd_vf_vlan_anti_spoof_result,
13697 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
13698 TOKEN_STRING_INITIALIZER
13699 (struct cmd_vf_vlan_anti_spoof_result,
13701 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
13702 TOKEN_STRING_INITIALIZER
13703 (struct cmd_vf_vlan_anti_spoof_result,
13704 antispoof, "antispoof");
13705 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
13706 TOKEN_NUM_INITIALIZER
13707 (struct cmd_vf_vlan_anti_spoof_result,
13709 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
13710 TOKEN_NUM_INITIALIZER
13711 (struct cmd_vf_vlan_anti_spoof_result,
13713 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
13714 TOKEN_STRING_INITIALIZER
13715 (struct cmd_vf_vlan_anti_spoof_result,
13719 cmd_set_vf_vlan_anti_spoof_parsed(
13720 void *parsed_result,
13721 __rte_unused struct cmdline *cl,
13722 __rte_unused void *data)
13724 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
13725 int ret = -ENOTSUP;
13727 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13729 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13732 #ifdef RTE_NET_IXGBE
13733 if (ret == -ENOTSUP)
13734 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
13735 res->vf_id, is_on);
13737 #ifdef RTE_NET_I40E
13738 if (ret == -ENOTSUP)
13739 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
13740 res->vf_id, is_on);
13742 #ifdef RTE_NET_BNXT
13743 if (ret == -ENOTSUP)
13744 ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
13745 res->vf_id, is_on);
13752 printf("invalid vf_id %d\n", res->vf_id);
13755 printf("invalid port_id %d\n", res->port_id);
13758 printf("function not implemented\n");
13761 printf("programming error: (%s)\n", strerror(-ret));
13765 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
13766 .f = cmd_set_vf_vlan_anti_spoof_parsed,
13768 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
13770 (void *)&cmd_vf_vlan_anti_spoof_set,
13771 (void *)&cmd_vf_vlan_anti_spoof_vf,
13772 (void *)&cmd_vf_vlan_anti_spoof_vlan,
13773 (void *)&cmd_vf_vlan_anti_spoof_antispoof,
13774 (void *)&cmd_vf_vlan_anti_spoof_port_id,
13775 (void *)&cmd_vf_vlan_anti_spoof_vf_id,
13776 (void *)&cmd_vf_vlan_anti_spoof_on_off,
13781 /* vf mac anti spoof configuration */
13783 /* Common result structure for vf mac anti spoof */
13784 struct cmd_vf_mac_anti_spoof_result {
13785 cmdline_fixed_string_t set;
13786 cmdline_fixed_string_t vf;
13787 cmdline_fixed_string_t mac;
13788 cmdline_fixed_string_t antispoof;
13791 cmdline_fixed_string_t on_off;
13794 /* Common CLI fields for vf mac anti spoof enable disable */
13795 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
13796 TOKEN_STRING_INITIALIZER
13797 (struct cmd_vf_mac_anti_spoof_result,
13799 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
13800 TOKEN_STRING_INITIALIZER
13801 (struct cmd_vf_mac_anti_spoof_result,
13803 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
13804 TOKEN_STRING_INITIALIZER
13805 (struct cmd_vf_mac_anti_spoof_result,
13807 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
13808 TOKEN_STRING_INITIALIZER
13809 (struct cmd_vf_mac_anti_spoof_result,
13810 antispoof, "antispoof");
13811 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
13812 TOKEN_NUM_INITIALIZER
13813 (struct cmd_vf_mac_anti_spoof_result,
13815 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
13816 TOKEN_NUM_INITIALIZER
13817 (struct cmd_vf_mac_anti_spoof_result,
13819 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
13820 TOKEN_STRING_INITIALIZER
13821 (struct cmd_vf_mac_anti_spoof_result,
13825 cmd_set_vf_mac_anti_spoof_parsed(
13826 void *parsed_result,
13827 __rte_unused struct cmdline *cl,
13828 __rte_unused void *data)
13830 struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
13831 int ret = -ENOTSUP;
13833 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13835 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13838 #ifdef RTE_NET_IXGBE
13839 if (ret == -ENOTSUP)
13840 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
13841 res->vf_id, is_on);
13843 #ifdef RTE_NET_I40E
13844 if (ret == -ENOTSUP)
13845 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
13846 res->vf_id, is_on);
13848 #ifdef RTE_NET_BNXT
13849 if (ret == -ENOTSUP)
13850 ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
13851 res->vf_id, is_on);
13858 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13861 printf("invalid port_id %d\n", res->port_id);
13864 printf("function not implemented\n");
13867 printf("programming error: (%s)\n", strerror(-ret));
13871 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
13872 .f = cmd_set_vf_mac_anti_spoof_parsed,
13874 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
13876 (void *)&cmd_vf_mac_anti_spoof_set,
13877 (void *)&cmd_vf_mac_anti_spoof_vf,
13878 (void *)&cmd_vf_mac_anti_spoof_mac,
13879 (void *)&cmd_vf_mac_anti_spoof_antispoof,
13880 (void *)&cmd_vf_mac_anti_spoof_port_id,
13881 (void *)&cmd_vf_mac_anti_spoof_vf_id,
13882 (void *)&cmd_vf_mac_anti_spoof_on_off,
13887 /* vf vlan strip queue configuration */
13889 /* Common result structure for vf mac anti spoof */
13890 struct cmd_vf_vlan_stripq_result {
13891 cmdline_fixed_string_t set;
13892 cmdline_fixed_string_t vf;
13893 cmdline_fixed_string_t vlan;
13894 cmdline_fixed_string_t stripq;
13897 cmdline_fixed_string_t on_off;
13900 /* Common CLI fields for vf vlan strip enable disable */
13901 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
13902 TOKEN_STRING_INITIALIZER
13903 (struct cmd_vf_vlan_stripq_result,
13905 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
13906 TOKEN_STRING_INITIALIZER
13907 (struct cmd_vf_vlan_stripq_result,
13909 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
13910 TOKEN_STRING_INITIALIZER
13911 (struct cmd_vf_vlan_stripq_result,
13913 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
13914 TOKEN_STRING_INITIALIZER
13915 (struct cmd_vf_vlan_stripq_result,
13917 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
13918 TOKEN_NUM_INITIALIZER
13919 (struct cmd_vf_vlan_stripq_result,
13921 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
13922 TOKEN_NUM_INITIALIZER
13923 (struct cmd_vf_vlan_stripq_result,
13925 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
13926 TOKEN_STRING_INITIALIZER
13927 (struct cmd_vf_vlan_stripq_result,
13931 cmd_set_vf_vlan_stripq_parsed(
13932 void *parsed_result,
13933 __rte_unused struct cmdline *cl,
13934 __rte_unused void *data)
13936 struct cmd_vf_vlan_stripq_result *res = parsed_result;
13937 int ret = -ENOTSUP;
13939 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13941 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13944 #ifdef RTE_NET_IXGBE
13945 if (ret == -ENOTSUP)
13946 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
13947 res->vf_id, is_on);
13949 #ifdef RTE_NET_I40E
13950 if (ret == -ENOTSUP)
13951 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
13952 res->vf_id, is_on);
13954 #ifdef RTE_NET_BNXT
13955 if (ret == -ENOTSUP)
13956 ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
13957 res->vf_id, is_on);
13964 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13967 printf("invalid port_id %d\n", res->port_id);
13970 printf("function not implemented\n");
13973 printf("programming error: (%s)\n", strerror(-ret));
13977 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
13978 .f = cmd_set_vf_vlan_stripq_parsed,
13980 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
13982 (void *)&cmd_vf_vlan_stripq_set,
13983 (void *)&cmd_vf_vlan_stripq_vf,
13984 (void *)&cmd_vf_vlan_stripq_vlan,
13985 (void *)&cmd_vf_vlan_stripq_stripq,
13986 (void *)&cmd_vf_vlan_stripq_port_id,
13987 (void *)&cmd_vf_vlan_stripq_vf_id,
13988 (void *)&cmd_vf_vlan_stripq_on_off,
13993 /* vf vlan insert configuration */
13995 /* Common result structure for vf vlan insert */
13996 struct cmd_vf_vlan_insert_result {
13997 cmdline_fixed_string_t set;
13998 cmdline_fixed_string_t vf;
13999 cmdline_fixed_string_t vlan;
14000 cmdline_fixed_string_t insert;
14006 /* Common CLI fields for vf vlan insert enable disable */
14007 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
14008 TOKEN_STRING_INITIALIZER
14009 (struct cmd_vf_vlan_insert_result,
14011 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
14012 TOKEN_STRING_INITIALIZER
14013 (struct cmd_vf_vlan_insert_result,
14015 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
14016 TOKEN_STRING_INITIALIZER
14017 (struct cmd_vf_vlan_insert_result,
14019 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
14020 TOKEN_STRING_INITIALIZER
14021 (struct cmd_vf_vlan_insert_result,
14023 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
14024 TOKEN_NUM_INITIALIZER
14025 (struct cmd_vf_vlan_insert_result,
14027 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
14028 TOKEN_NUM_INITIALIZER
14029 (struct cmd_vf_vlan_insert_result,
14031 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
14032 TOKEN_NUM_INITIALIZER
14033 (struct cmd_vf_vlan_insert_result,
14037 cmd_set_vf_vlan_insert_parsed(
14038 void *parsed_result,
14039 __rte_unused struct cmdline *cl,
14040 __rte_unused void *data)
14042 struct cmd_vf_vlan_insert_result *res = parsed_result;
14043 int ret = -ENOTSUP;
14045 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14048 #ifdef RTE_NET_IXGBE
14049 if (ret == -ENOTSUP)
14050 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
14053 #ifdef RTE_NET_I40E
14054 if (ret == -ENOTSUP)
14055 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
14058 #ifdef RTE_NET_BNXT
14059 if (ret == -ENOTSUP)
14060 ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
14068 printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id);
14071 printf("invalid port_id %d\n", res->port_id);
14074 printf("function not implemented\n");
14077 printf("programming error: (%s)\n", strerror(-ret));
14081 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
14082 .f = cmd_set_vf_vlan_insert_parsed,
14084 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
14086 (void *)&cmd_vf_vlan_insert_set,
14087 (void *)&cmd_vf_vlan_insert_vf,
14088 (void *)&cmd_vf_vlan_insert_vlan,
14089 (void *)&cmd_vf_vlan_insert_insert,
14090 (void *)&cmd_vf_vlan_insert_port_id,
14091 (void *)&cmd_vf_vlan_insert_vf_id,
14092 (void *)&cmd_vf_vlan_insert_vlan_id,
14097 /* tx loopback configuration */
14099 /* Common result structure for tx loopback */
14100 struct cmd_tx_loopback_result {
14101 cmdline_fixed_string_t set;
14102 cmdline_fixed_string_t tx;
14103 cmdline_fixed_string_t loopback;
14105 cmdline_fixed_string_t on_off;
14108 /* Common CLI fields for tx loopback enable disable */
14109 cmdline_parse_token_string_t cmd_tx_loopback_set =
14110 TOKEN_STRING_INITIALIZER
14111 (struct cmd_tx_loopback_result,
14113 cmdline_parse_token_string_t cmd_tx_loopback_tx =
14114 TOKEN_STRING_INITIALIZER
14115 (struct cmd_tx_loopback_result,
14117 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
14118 TOKEN_STRING_INITIALIZER
14119 (struct cmd_tx_loopback_result,
14120 loopback, "loopback");
14121 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
14122 TOKEN_NUM_INITIALIZER
14123 (struct cmd_tx_loopback_result,
14125 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
14126 TOKEN_STRING_INITIALIZER
14127 (struct cmd_tx_loopback_result,
14131 cmd_set_tx_loopback_parsed(
14132 void *parsed_result,
14133 __rte_unused struct cmdline *cl,
14134 __rte_unused void *data)
14136 struct cmd_tx_loopback_result *res = parsed_result;
14137 int ret = -ENOTSUP;
14139 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14141 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14144 #ifdef RTE_NET_IXGBE
14145 if (ret == -ENOTSUP)
14146 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
14148 #ifdef RTE_NET_I40E
14149 if (ret == -ENOTSUP)
14150 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
14152 #ifdef RTE_NET_BNXT
14153 if (ret == -ENOTSUP)
14154 ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
14156 #if defined RTE_BUS_DPAA && defined RTE_NET_DPAA
14157 if (ret == -ENOTSUP)
14158 ret = rte_pmd_dpaa_set_tx_loopback(res->port_id, is_on);
14165 printf("invalid is_on %d\n", is_on);
14168 printf("invalid port_id %d\n", res->port_id);
14171 printf("function not implemented\n");
14174 printf("programming error: (%s)\n", strerror(-ret));
14178 cmdline_parse_inst_t cmd_set_tx_loopback = {
14179 .f = cmd_set_tx_loopback_parsed,
14181 .help_str = "set tx loopback <port_id> on|off",
14183 (void *)&cmd_tx_loopback_set,
14184 (void *)&cmd_tx_loopback_tx,
14185 (void *)&cmd_tx_loopback_loopback,
14186 (void *)&cmd_tx_loopback_port_id,
14187 (void *)&cmd_tx_loopback_on_off,
14192 /* all queues drop enable configuration */
14194 /* Common result structure for all queues drop enable */
14195 struct cmd_all_queues_drop_en_result {
14196 cmdline_fixed_string_t set;
14197 cmdline_fixed_string_t all;
14198 cmdline_fixed_string_t queues;
14199 cmdline_fixed_string_t drop;
14201 cmdline_fixed_string_t on_off;
14204 /* Common CLI fields for tx loopback enable disable */
14205 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
14206 TOKEN_STRING_INITIALIZER
14207 (struct cmd_all_queues_drop_en_result,
14209 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
14210 TOKEN_STRING_INITIALIZER
14211 (struct cmd_all_queues_drop_en_result,
14213 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
14214 TOKEN_STRING_INITIALIZER
14215 (struct cmd_all_queues_drop_en_result,
14217 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
14218 TOKEN_STRING_INITIALIZER
14219 (struct cmd_all_queues_drop_en_result,
14221 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
14222 TOKEN_NUM_INITIALIZER
14223 (struct cmd_all_queues_drop_en_result,
14225 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
14226 TOKEN_STRING_INITIALIZER
14227 (struct cmd_all_queues_drop_en_result,
14231 cmd_set_all_queues_drop_en_parsed(
14232 void *parsed_result,
14233 __rte_unused struct cmdline *cl,
14234 __rte_unused void *data)
14236 struct cmd_all_queues_drop_en_result *res = parsed_result;
14237 int ret = -ENOTSUP;
14238 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14240 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14243 #ifdef RTE_NET_IXGBE
14244 if (ret == -ENOTSUP)
14245 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
14247 #ifdef RTE_NET_BNXT
14248 if (ret == -ENOTSUP)
14249 ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
14255 printf("invalid is_on %d\n", is_on);
14258 printf("invalid port_id %d\n", res->port_id);
14261 printf("function not implemented\n");
14264 printf("programming error: (%s)\n", strerror(-ret));
14268 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
14269 .f = cmd_set_all_queues_drop_en_parsed,
14271 .help_str = "set all queues drop <port_id> on|off",
14273 (void *)&cmd_all_queues_drop_en_set,
14274 (void *)&cmd_all_queues_drop_en_all,
14275 (void *)&cmd_all_queues_drop_en_queues,
14276 (void *)&cmd_all_queues_drop_en_drop,
14277 (void *)&cmd_all_queues_drop_en_port_id,
14278 (void *)&cmd_all_queues_drop_en_on_off,
14283 /* vf split drop enable configuration */
14285 /* Common result structure for vf split drop enable */
14286 struct cmd_vf_split_drop_en_result {
14287 cmdline_fixed_string_t set;
14288 cmdline_fixed_string_t vf;
14289 cmdline_fixed_string_t split;
14290 cmdline_fixed_string_t drop;
14293 cmdline_fixed_string_t on_off;
14296 /* Common CLI fields for vf split drop enable disable */
14297 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
14298 TOKEN_STRING_INITIALIZER
14299 (struct cmd_vf_split_drop_en_result,
14301 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
14302 TOKEN_STRING_INITIALIZER
14303 (struct cmd_vf_split_drop_en_result,
14305 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
14306 TOKEN_STRING_INITIALIZER
14307 (struct cmd_vf_split_drop_en_result,
14309 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
14310 TOKEN_STRING_INITIALIZER
14311 (struct cmd_vf_split_drop_en_result,
14313 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
14314 TOKEN_NUM_INITIALIZER
14315 (struct cmd_vf_split_drop_en_result,
14317 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
14318 TOKEN_NUM_INITIALIZER
14319 (struct cmd_vf_split_drop_en_result,
14321 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
14322 TOKEN_STRING_INITIALIZER
14323 (struct cmd_vf_split_drop_en_result,
14327 cmd_set_vf_split_drop_en_parsed(
14328 void *parsed_result,
14329 __rte_unused struct cmdline *cl,
14330 __rte_unused void *data)
14332 struct cmd_vf_split_drop_en_result *res = parsed_result;
14333 int ret = -ENOTSUP;
14334 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14336 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14339 #ifdef RTE_NET_IXGBE
14340 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
14347 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
14350 printf("invalid port_id %d\n", res->port_id);
14353 printf("not supported on port %d\n", res->port_id);
14356 printf("programming error: (%s)\n", strerror(-ret));
14360 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
14361 .f = cmd_set_vf_split_drop_en_parsed,
14363 .help_str = "set vf split drop <port_id> <vf_id> on|off",
14365 (void *)&cmd_vf_split_drop_en_set,
14366 (void *)&cmd_vf_split_drop_en_vf,
14367 (void *)&cmd_vf_split_drop_en_split,
14368 (void *)&cmd_vf_split_drop_en_drop,
14369 (void *)&cmd_vf_split_drop_en_port_id,
14370 (void *)&cmd_vf_split_drop_en_vf_id,
14371 (void *)&cmd_vf_split_drop_en_on_off,
14376 /* vf mac address configuration */
14378 /* Common result structure for vf mac address */
14379 struct cmd_set_vf_mac_addr_result {
14380 cmdline_fixed_string_t set;
14381 cmdline_fixed_string_t vf;
14382 cmdline_fixed_string_t mac;
14383 cmdline_fixed_string_t addr;
14386 struct rte_ether_addr mac_addr;
14390 /* Common CLI fields for vf split drop enable disable */
14391 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
14392 TOKEN_STRING_INITIALIZER
14393 (struct cmd_set_vf_mac_addr_result,
14395 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
14396 TOKEN_STRING_INITIALIZER
14397 (struct cmd_set_vf_mac_addr_result,
14399 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
14400 TOKEN_STRING_INITIALIZER
14401 (struct cmd_set_vf_mac_addr_result,
14403 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
14404 TOKEN_STRING_INITIALIZER
14405 (struct cmd_set_vf_mac_addr_result,
14407 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
14408 TOKEN_NUM_INITIALIZER
14409 (struct cmd_set_vf_mac_addr_result,
14411 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
14412 TOKEN_NUM_INITIALIZER
14413 (struct cmd_set_vf_mac_addr_result,
14415 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
14416 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
14420 cmd_set_vf_mac_addr_parsed(
14421 void *parsed_result,
14422 __rte_unused struct cmdline *cl,
14423 __rte_unused void *data)
14425 struct cmd_set_vf_mac_addr_result *res = parsed_result;
14426 int ret = -ENOTSUP;
14428 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14431 #ifdef RTE_NET_IXGBE
14432 if (ret == -ENOTSUP)
14433 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
14436 #ifdef RTE_NET_I40E
14437 if (ret == -ENOTSUP)
14438 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
14441 #ifdef RTE_NET_BNXT
14442 if (ret == -ENOTSUP)
14443 ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
14451 printf("invalid vf_id %d or mac_addr\n", res->vf_id);
14454 printf("invalid port_id %d\n", res->port_id);
14457 printf("function not implemented\n");
14460 printf("programming error: (%s)\n", strerror(-ret));
14464 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
14465 .f = cmd_set_vf_mac_addr_parsed,
14467 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
14469 (void *)&cmd_set_vf_mac_addr_set,
14470 (void *)&cmd_set_vf_mac_addr_vf,
14471 (void *)&cmd_set_vf_mac_addr_mac,
14472 (void *)&cmd_set_vf_mac_addr_addr,
14473 (void *)&cmd_set_vf_mac_addr_port_id,
14474 (void *)&cmd_set_vf_mac_addr_vf_id,
14475 (void *)&cmd_set_vf_mac_addr_mac_addr,
14480 /* MACsec configuration */
14482 /* Common result structure for MACsec offload enable */
14483 struct cmd_macsec_offload_on_result {
14484 cmdline_fixed_string_t set;
14485 cmdline_fixed_string_t macsec;
14486 cmdline_fixed_string_t offload;
14488 cmdline_fixed_string_t on;
14489 cmdline_fixed_string_t encrypt;
14490 cmdline_fixed_string_t en_on_off;
14491 cmdline_fixed_string_t replay_protect;
14492 cmdline_fixed_string_t rp_on_off;
14495 /* Common CLI fields for MACsec offload disable */
14496 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
14497 TOKEN_STRING_INITIALIZER
14498 (struct cmd_macsec_offload_on_result,
14500 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
14501 TOKEN_STRING_INITIALIZER
14502 (struct cmd_macsec_offload_on_result,
14504 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
14505 TOKEN_STRING_INITIALIZER
14506 (struct cmd_macsec_offload_on_result,
14507 offload, "offload");
14508 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
14509 TOKEN_NUM_INITIALIZER
14510 (struct cmd_macsec_offload_on_result,
14512 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
14513 TOKEN_STRING_INITIALIZER
14514 (struct cmd_macsec_offload_on_result,
14516 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
14517 TOKEN_STRING_INITIALIZER
14518 (struct cmd_macsec_offload_on_result,
14519 encrypt, "encrypt");
14520 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
14521 TOKEN_STRING_INITIALIZER
14522 (struct cmd_macsec_offload_on_result,
14523 en_on_off, "on#off");
14524 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
14525 TOKEN_STRING_INITIALIZER
14526 (struct cmd_macsec_offload_on_result,
14527 replay_protect, "replay-protect");
14528 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
14529 TOKEN_STRING_INITIALIZER
14530 (struct cmd_macsec_offload_on_result,
14531 rp_on_off, "on#off");
14534 cmd_set_macsec_offload_on_parsed(
14535 void *parsed_result,
14536 __rte_unused struct cmdline *cl,
14537 __rte_unused void *data)
14539 struct cmd_macsec_offload_on_result *res = parsed_result;
14540 int ret = -ENOTSUP;
14541 portid_t port_id = res->port_id;
14542 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
14543 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
14544 struct rte_eth_dev_info dev_info;
14546 if (port_id_is_invalid(port_id, ENABLED_WARN))
14548 if (!port_is_stopped(port_id)) {
14549 printf("Please stop port %d first\n", port_id);
14553 ret = eth_dev_info_get_print_err(port_id, &dev_info);
14557 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
14558 #ifdef RTE_NET_IXGBE
14559 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
14567 ports[port_id].dev_conf.txmode.offloads |=
14568 DEV_TX_OFFLOAD_MACSEC_INSERT;
14569 cmd_reconfig_device_queue(port_id, 1, 1);
14572 printf("invalid port_id %d\n", port_id);
14575 printf("not supported on port %d\n", port_id);
14578 printf("programming error: (%s)\n", strerror(-ret));
14582 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
14583 .f = cmd_set_macsec_offload_on_parsed,
14585 .help_str = "set macsec offload <port_id> on "
14586 "encrypt on|off replay-protect on|off",
14588 (void *)&cmd_macsec_offload_on_set,
14589 (void *)&cmd_macsec_offload_on_macsec,
14590 (void *)&cmd_macsec_offload_on_offload,
14591 (void *)&cmd_macsec_offload_on_port_id,
14592 (void *)&cmd_macsec_offload_on_on,
14593 (void *)&cmd_macsec_offload_on_encrypt,
14594 (void *)&cmd_macsec_offload_on_en_on_off,
14595 (void *)&cmd_macsec_offload_on_replay_protect,
14596 (void *)&cmd_macsec_offload_on_rp_on_off,
14601 /* Common result structure for MACsec offload disable */
14602 struct cmd_macsec_offload_off_result {
14603 cmdline_fixed_string_t set;
14604 cmdline_fixed_string_t macsec;
14605 cmdline_fixed_string_t offload;
14607 cmdline_fixed_string_t off;
14610 /* Common CLI fields for MACsec offload disable */
14611 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
14612 TOKEN_STRING_INITIALIZER
14613 (struct cmd_macsec_offload_off_result,
14615 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
14616 TOKEN_STRING_INITIALIZER
14617 (struct cmd_macsec_offload_off_result,
14619 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
14620 TOKEN_STRING_INITIALIZER
14621 (struct cmd_macsec_offload_off_result,
14622 offload, "offload");
14623 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
14624 TOKEN_NUM_INITIALIZER
14625 (struct cmd_macsec_offload_off_result,
14627 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
14628 TOKEN_STRING_INITIALIZER
14629 (struct cmd_macsec_offload_off_result,
14633 cmd_set_macsec_offload_off_parsed(
14634 void *parsed_result,
14635 __rte_unused struct cmdline *cl,
14636 __rte_unused void *data)
14638 struct cmd_macsec_offload_off_result *res = parsed_result;
14639 int ret = -ENOTSUP;
14640 struct rte_eth_dev_info dev_info;
14641 portid_t port_id = res->port_id;
14643 if (port_id_is_invalid(port_id, ENABLED_WARN))
14645 if (!port_is_stopped(port_id)) {
14646 printf("Please stop port %d first\n", port_id);
14650 ret = eth_dev_info_get_print_err(port_id, &dev_info);
14654 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
14655 #ifdef RTE_NET_IXGBE
14656 ret = rte_pmd_ixgbe_macsec_disable(port_id);
14661 ports[port_id].dev_conf.txmode.offloads &=
14662 ~DEV_TX_OFFLOAD_MACSEC_INSERT;
14663 cmd_reconfig_device_queue(port_id, 1, 1);
14666 printf("invalid port_id %d\n", port_id);
14669 printf("not supported on port %d\n", port_id);
14672 printf("programming error: (%s)\n", strerror(-ret));
14676 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
14677 .f = cmd_set_macsec_offload_off_parsed,
14679 .help_str = "set macsec offload <port_id> off",
14681 (void *)&cmd_macsec_offload_off_set,
14682 (void *)&cmd_macsec_offload_off_macsec,
14683 (void *)&cmd_macsec_offload_off_offload,
14684 (void *)&cmd_macsec_offload_off_port_id,
14685 (void *)&cmd_macsec_offload_off_off,
14690 /* Common result structure for MACsec secure connection configure */
14691 struct cmd_macsec_sc_result {
14692 cmdline_fixed_string_t set;
14693 cmdline_fixed_string_t macsec;
14694 cmdline_fixed_string_t sc;
14695 cmdline_fixed_string_t tx_rx;
14697 struct rte_ether_addr mac;
14701 /* Common CLI fields for MACsec secure connection configure */
14702 cmdline_parse_token_string_t cmd_macsec_sc_set =
14703 TOKEN_STRING_INITIALIZER
14704 (struct cmd_macsec_sc_result,
14706 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
14707 TOKEN_STRING_INITIALIZER
14708 (struct cmd_macsec_sc_result,
14710 cmdline_parse_token_string_t cmd_macsec_sc_sc =
14711 TOKEN_STRING_INITIALIZER
14712 (struct cmd_macsec_sc_result,
14714 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
14715 TOKEN_STRING_INITIALIZER
14716 (struct cmd_macsec_sc_result,
14718 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
14719 TOKEN_NUM_INITIALIZER
14720 (struct cmd_macsec_sc_result,
14722 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
14723 TOKEN_ETHERADDR_INITIALIZER
14724 (struct cmd_macsec_sc_result,
14726 cmdline_parse_token_num_t cmd_macsec_sc_pi =
14727 TOKEN_NUM_INITIALIZER
14728 (struct cmd_macsec_sc_result,
14732 cmd_set_macsec_sc_parsed(
14733 void *parsed_result,
14734 __rte_unused struct cmdline *cl,
14735 __rte_unused void *data)
14737 struct cmd_macsec_sc_result *res = parsed_result;
14738 int ret = -ENOTSUP;
14739 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
14741 #ifdef RTE_NET_IXGBE
14743 rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
14744 res->mac.addr_bytes) :
14745 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
14746 res->mac.addr_bytes, res->pi);
14748 RTE_SET_USED(is_tx);
14754 printf("invalid port_id %d\n", res->port_id);
14757 printf("not supported on port %d\n", res->port_id);
14760 printf("programming error: (%s)\n", strerror(-ret));
14764 cmdline_parse_inst_t cmd_set_macsec_sc = {
14765 .f = cmd_set_macsec_sc_parsed,
14767 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
14769 (void *)&cmd_macsec_sc_set,
14770 (void *)&cmd_macsec_sc_macsec,
14771 (void *)&cmd_macsec_sc_sc,
14772 (void *)&cmd_macsec_sc_tx_rx,
14773 (void *)&cmd_macsec_sc_port_id,
14774 (void *)&cmd_macsec_sc_mac,
14775 (void *)&cmd_macsec_sc_pi,
14780 /* Common result structure for MACsec secure connection configure */
14781 struct cmd_macsec_sa_result {
14782 cmdline_fixed_string_t set;
14783 cmdline_fixed_string_t macsec;
14784 cmdline_fixed_string_t sa;
14785 cmdline_fixed_string_t tx_rx;
14790 cmdline_fixed_string_t key;
14793 /* Common CLI fields for MACsec secure connection configure */
14794 cmdline_parse_token_string_t cmd_macsec_sa_set =
14795 TOKEN_STRING_INITIALIZER
14796 (struct cmd_macsec_sa_result,
14798 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
14799 TOKEN_STRING_INITIALIZER
14800 (struct cmd_macsec_sa_result,
14802 cmdline_parse_token_string_t cmd_macsec_sa_sa =
14803 TOKEN_STRING_INITIALIZER
14804 (struct cmd_macsec_sa_result,
14806 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
14807 TOKEN_STRING_INITIALIZER
14808 (struct cmd_macsec_sa_result,
14810 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
14811 TOKEN_NUM_INITIALIZER
14812 (struct cmd_macsec_sa_result,
14814 cmdline_parse_token_num_t cmd_macsec_sa_idx =
14815 TOKEN_NUM_INITIALIZER
14816 (struct cmd_macsec_sa_result,
14818 cmdline_parse_token_num_t cmd_macsec_sa_an =
14819 TOKEN_NUM_INITIALIZER
14820 (struct cmd_macsec_sa_result,
14822 cmdline_parse_token_num_t cmd_macsec_sa_pn =
14823 TOKEN_NUM_INITIALIZER
14824 (struct cmd_macsec_sa_result,
14826 cmdline_parse_token_string_t cmd_macsec_sa_key =
14827 TOKEN_STRING_INITIALIZER
14828 (struct cmd_macsec_sa_result,
14832 cmd_set_macsec_sa_parsed(
14833 void *parsed_result,
14834 __rte_unused struct cmdline *cl,
14835 __rte_unused void *data)
14837 struct cmd_macsec_sa_result *res = parsed_result;
14838 int ret = -ENOTSUP;
14839 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
14840 uint8_t key[16] = { 0 };
14846 key_len = strlen(res->key) / 2;
14850 for (i = 0; i < key_len; i++) {
14851 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
14854 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
14857 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
14860 #ifdef RTE_NET_IXGBE
14862 rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
14863 res->idx, res->an, res->pn, key) :
14864 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
14865 res->idx, res->an, res->pn, key);
14867 RTE_SET_USED(is_tx);
14874 printf("invalid idx %d or an %d\n", res->idx, res->an);
14877 printf("invalid port_id %d\n", res->port_id);
14880 printf("not supported on port %d\n", res->port_id);
14883 printf("programming error: (%s)\n", strerror(-ret));
14887 cmdline_parse_inst_t cmd_set_macsec_sa = {
14888 .f = cmd_set_macsec_sa_parsed,
14890 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
14892 (void *)&cmd_macsec_sa_set,
14893 (void *)&cmd_macsec_sa_macsec,
14894 (void *)&cmd_macsec_sa_sa,
14895 (void *)&cmd_macsec_sa_tx_rx,
14896 (void *)&cmd_macsec_sa_port_id,
14897 (void *)&cmd_macsec_sa_idx,
14898 (void *)&cmd_macsec_sa_an,
14899 (void *)&cmd_macsec_sa_pn,
14900 (void *)&cmd_macsec_sa_key,
14905 /* VF unicast promiscuous mode configuration */
14907 /* Common result structure for VF unicast promiscuous mode */
14908 struct cmd_vf_promisc_result {
14909 cmdline_fixed_string_t set;
14910 cmdline_fixed_string_t vf;
14911 cmdline_fixed_string_t promisc;
14914 cmdline_fixed_string_t on_off;
14917 /* Common CLI fields for VF unicast promiscuous mode enable disable */
14918 cmdline_parse_token_string_t cmd_vf_promisc_set =
14919 TOKEN_STRING_INITIALIZER
14920 (struct cmd_vf_promisc_result,
14922 cmdline_parse_token_string_t cmd_vf_promisc_vf =
14923 TOKEN_STRING_INITIALIZER
14924 (struct cmd_vf_promisc_result,
14926 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
14927 TOKEN_STRING_INITIALIZER
14928 (struct cmd_vf_promisc_result,
14929 promisc, "promisc");
14930 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
14931 TOKEN_NUM_INITIALIZER
14932 (struct cmd_vf_promisc_result,
14934 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
14935 TOKEN_NUM_INITIALIZER
14936 (struct cmd_vf_promisc_result,
14938 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
14939 TOKEN_STRING_INITIALIZER
14940 (struct cmd_vf_promisc_result,
14944 cmd_set_vf_promisc_parsed(
14945 void *parsed_result,
14946 __rte_unused struct cmdline *cl,
14947 __rte_unused void *data)
14949 struct cmd_vf_promisc_result *res = parsed_result;
14950 int ret = -ENOTSUP;
14952 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14954 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14957 #ifdef RTE_NET_I40E
14958 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
14959 res->vf_id, is_on);
14966 printf("invalid vf_id %d\n", res->vf_id);
14969 printf("invalid port_id %d\n", res->port_id);
14972 printf("function not implemented\n");
14975 printf("programming error: (%s)\n", strerror(-ret));
14979 cmdline_parse_inst_t cmd_set_vf_promisc = {
14980 .f = cmd_set_vf_promisc_parsed,
14982 .help_str = "set vf promisc <port_id> <vf_id> on|off: "
14983 "Set unicast promiscuous mode for a VF from the PF",
14985 (void *)&cmd_vf_promisc_set,
14986 (void *)&cmd_vf_promisc_vf,
14987 (void *)&cmd_vf_promisc_promisc,
14988 (void *)&cmd_vf_promisc_port_id,
14989 (void *)&cmd_vf_promisc_vf_id,
14990 (void *)&cmd_vf_promisc_on_off,
14995 /* VF multicast promiscuous mode configuration */
14997 /* Common result structure for VF multicast promiscuous mode */
14998 struct cmd_vf_allmulti_result {
14999 cmdline_fixed_string_t set;
15000 cmdline_fixed_string_t vf;
15001 cmdline_fixed_string_t allmulti;
15004 cmdline_fixed_string_t on_off;
15007 /* Common CLI fields for VF multicast promiscuous mode enable disable */
15008 cmdline_parse_token_string_t cmd_vf_allmulti_set =
15009 TOKEN_STRING_INITIALIZER
15010 (struct cmd_vf_allmulti_result,
15012 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
15013 TOKEN_STRING_INITIALIZER
15014 (struct cmd_vf_allmulti_result,
15016 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
15017 TOKEN_STRING_INITIALIZER
15018 (struct cmd_vf_allmulti_result,
15019 allmulti, "allmulti");
15020 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
15021 TOKEN_NUM_INITIALIZER
15022 (struct cmd_vf_allmulti_result,
15024 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
15025 TOKEN_NUM_INITIALIZER
15026 (struct cmd_vf_allmulti_result,
15028 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
15029 TOKEN_STRING_INITIALIZER
15030 (struct cmd_vf_allmulti_result,
15034 cmd_set_vf_allmulti_parsed(
15035 void *parsed_result,
15036 __rte_unused struct cmdline *cl,
15037 __rte_unused void *data)
15039 struct cmd_vf_allmulti_result *res = parsed_result;
15040 int ret = -ENOTSUP;
15042 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
15044 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15047 #ifdef RTE_NET_I40E
15048 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
15049 res->vf_id, is_on);
15056 printf("invalid vf_id %d\n", res->vf_id);
15059 printf("invalid port_id %d\n", res->port_id);
15062 printf("function not implemented\n");
15065 printf("programming error: (%s)\n", strerror(-ret));
15069 cmdline_parse_inst_t cmd_set_vf_allmulti = {
15070 .f = cmd_set_vf_allmulti_parsed,
15072 .help_str = "set vf allmulti <port_id> <vf_id> on|off: "
15073 "Set multicast promiscuous mode for a VF from the PF",
15075 (void *)&cmd_vf_allmulti_set,
15076 (void *)&cmd_vf_allmulti_vf,
15077 (void *)&cmd_vf_allmulti_allmulti,
15078 (void *)&cmd_vf_allmulti_port_id,
15079 (void *)&cmd_vf_allmulti_vf_id,
15080 (void *)&cmd_vf_allmulti_on_off,
15085 /* vf broadcast mode configuration */
15087 /* Common result structure for vf broadcast */
15088 struct cmd_set_vf_broadcast_result {
15089 cmdline_fixed_string_t set;
15090 cmdline_fixed_string_t vf;
15091 cmdline_fixed_string_t broadcast;
15094 cmdline_fixed_string_t on_off;
15097 /* Common CLI fields for vf broadcast enable disable */
15098 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
15099 TOKEN_STRING_INITIALIZER
15100 (struct cmd_set_vf_broadcast_result,
15102 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
15103 TOKEN_STRING_INITIALIZER
15104 (struct cmd_set_vf_broadcast_result,
15106 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
15107 TOKEN_STRING_INITIALIZER
15108 (struct cmd_set_vf_broadcast_result,
15109 broadcast, "broadcast");
15110 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
15111 TOKEN_NUM_INITIALIZER
15112 (struct cmd_set_vf_broadcast_result,
15114 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
15115 TOKEN_NUM_INITIALIZER
15116 (struct cmd_set_vf_broadcast_result,
15118 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
15119 TOKEN_STRING_INITIALIZER
15120 (struct cmd_set_vf_broadcast_result,
15124 cmd_set_vf_broadcast_parsed(
15125 void *parsed_result,
15126 __rte_unused struct cmdline *cl,
15127 __rte_unused void *data)
15129 struct cmd_set_vf_broadcast_result *res = parsed_result;
15130 int ret = -ENOTSUP;
15132 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
15134 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15137 #ifdef RTE_NET_I40E
15138 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
15139 res->vf_id, is_on);
15146 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
15149 printf("invalid port_id %d\n", res->port_id);
15152 printf("function not implemented\n");
15155 printf("programming error: (%s)\n", strerror(-ret));
15159 cmdline_parse_inst_t cmd_set_vf_broadcast = {
15160 .f = cmd_set_vf_broadcast_parsed,
15162 .help_str = "set vf broadcast <port_id> <vf_id> on|off",
15164 (void *)&cmd_set_vf_broadcast_set,
15165 (void *)&cmd_set_vf_broadcast_vf,
15166 (void *)&cmd_set_vf_broadcast_broadcast,
15167 (void *)&cmd_set_vf_broadcast_port_id,
15168 (void *)&cmd_set_vf_broadcast_vf_id,
15169 (void *)&cmd_set_vf_broadcast_on_off,
15174 /* vf vlan tag configuration */
15176 /* Common result structure for vf vlan tag */
15177 struct cmd_set_vf_vlan_tag_result {
15178 cmdline_fixed_string_t set;
15179 cmdline_fixed_string_t vf;
15180 cmdline_fixed_string_t vlan;
15181 cmdline_fixed_string_t tag;
15184 cmdline_fixed_string_t on_off;
15187 /* Common CLI fields for vf vlan tag enable disable */
15188 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
15189 TOKEN_STRING_INITIALIZER
15190 (struct cmd_set_vf_vlan_tag_result,
15192 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
15193 TOKEN_STRING_INITIALIZER
15194 (struct cmd_set_vf_vlan_tag_result,
15196 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
15197 TOKEN_STRING_INITIALIZER
15198 (struct cmd_set_vf_vlan_tag_result,
15200 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
15201 TOKEN_STRING_INITIALIZER
15202 (struct cmd_set_vf_vlan_tag_result,
15204 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
15205 TOKEN_NUM_INITIALIZER
15206 (struct cmd_set_vf_vlan_tag_result,
15208 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
15209 TOKEN_NUM_INITIALIZER
15210 (struct cmd_set_vf_vlan_tag_result,
15212 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
15213 TOKEN_STRING_INITIALIZER
15214 (struct cmd_set_vf_vlan_tag_result,
15218 cmd_set_vf_vlan_tag_parsed(
15219 void *parsed_result,
15220 __rte_unused struct cmdline *cl,
15221 __rte_unused void *data)
15223 struct cmd_set_vf_vlan_tag_result *res = parsed_result;
15224 int ret = -ENOTSUP;
15226 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
15228 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15231 #ifdef RTE_NET_I40E
15232 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
15233 res->vf_id, is_on);
15240 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
15243 printf("invalid port_id %d\n", res->port_id);
15246 printf("function not implemented\n");
15249 printf("programming error: (%s)\n", strerror(-ret));
15253 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
15254 .f = cmd_set_vf_vlan_tag_parsed,
15256 .help_str = "set vf vlan tag <port_id> <vf_id> on|off",
15258 (void *)&cmd_set_vf_vlan_tag_set,
15259 (void *)&cmd_set_vf_vlan_tag_vf,
15260 (void *)&cmd_set_vf_vlan_tag_vlan,
15261 (void *)&cmd_set_vf_vlan_tag_tag,
15262 (void *)&cmd_set_vf_vlan_tag_port_id,
15263 (void *)&cmd_set_vf_vlan_tag_vf_id,
15264 (void *)&cmd_set_vf_vlan_tag_on_off,
15269 /* Common definition of VF and TC TX bandwidth configuration */
15270 struct cmd_vf_tc_bw_result {
15271 cmdline_fixed_string_t set;
15272 cmdline_fixed_string_t vf;
15273 cmdline_fixed_string_t tc;
15274 cmdline_fixed_string_t tx;
15275 cmdline_fixed_string_t min_bw;
15276 cmdline_fixed_string_t max_bw;
15277 cmdline_fixed_string_t strict_link_prio;
15282 cmdline_fixed_string_t bw_list;
15286 cmdline_parse_token_string_t cmd_vf_tc_bw_set =
15287 TOKEN_STRING_INITIALIZER
15288 (struct cmd_vf_tc_bw_result,
15290 cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
15291 TOKEN_STRING_INITIALIZER
15292 (struct cmd_vf_tc_bw_result,
15294 cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
15295 TOKEN_STRING_INITIALIZER
15296 (struct cmd_vf_tc_bw_result,
15298 cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
15299 TOKEN_STRING_INITIALIZER
15300 (struct cmd_vf_tc_bw_result,
15302 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio =
15303 TOKEN_STRING_INITIALIZER
15304 (struct cmd_vf_tc_bw_result,
15305 strict_link_prio, "strict-link-priority");
15306 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw =
15307 TOKEN_STRING_INITIALIZER
15308 (struct cmd_vf_tc_bw_result,
15309 min_bw, "min-bandwidth");
15310 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
15311 TOKEN_STRING_INITIALIZER
15312 (struct cmd_vf_tc_bw_result,
15313 max_bw, "max-bandwidth");
15314 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
15315 TOKEN_NUM_INITIALIZER
15316 (struct cmd_vf_tc_bw_result,
15318 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
15319 TOKEN_NUM_INITIALIZER
15320 (struct cmd_vf_tc_bw_result,
15322 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no =
15323 TOKEN_NUM_INITIALIZER
15324 (struct cmd_vf_tc_bw_result,
15326 cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
15327 TOKEN_NUM_INITIALIZER
15328 (struct cmd_vf_tc_bw_result,
15330 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
15331 TOKEN_STRING_INITIALIZER
15332 (struct cmd_vf_tc_bw_result,
15334 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map =
15335 TOKEN_NUM_INITIALIZER
15336 (struct cmd_vf_tc_bw_result,
15339 /* VF max bandwidth setting */
15341 cmd_vf_max_bw_parsed(
15342 void *parsed_result,
15343 __rte_unused struct cmdline *cl,
15344 __rte_unused void *data)
15346 struct cmd_vf_tc_bw_result *res = parsed_result;
15347 int ret = -ENOTSUP;
15349 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15352 #ifdef RTE_NET_I40E
15353 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id,
15354 res->vf_id, res->bw);
15361 printf("invalid vf_id %d or bandwidth %d\n",
15362 res->vf_id, res->bw);
15365 printf("invalid port_id %d\n", res->port_id);
15368 printf("function not implemented\n");
15371 printf("programming error: (%s)\n", strerror(-ret));
15375 cmdline_parse_inst_t cmd_vf_max_bw = {
15376 .f = cmd_vf_max_bw_parsed,
15378 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
15380 (void *)&cmd_vf_tc_bw_set,
15381 (void *)&cmd_vf_tc_bw_vf,
15382 (void *)&cmd_vf_tc_bw_tx,
15383 (void *)&cmd_vf_tc_bw_max_bw,
15384 (void *)&cmd_vf_tc_bw_port_id,
15385 (void *)&cmd_vf_tc_bw_vf_id,
15386 (void *)&cmd_vf_tc_bw_bw,
15392 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
15397 const char *p, *p0 = str;
15404 p = strchr(p0, '(');
15406 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
15410 p0 = strchr(p, ')');
15412 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
15416 if (size >= sizeof(s)) {
15417 printf("The string size exceeds the internal buffer size\n");
15420 snprintf(s, sizeof(s), "%.*s", size, p);
15421 ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
15423 printf("Failed to get the bandwidth list. ");
15427 for (i = 0; i < ret; i++)
15428 bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
15433 /* TC min bandwidth setting */
15435 cmd_vf_tc_min_bw_parsed(
15436 void *parsed_result,
15437 __rte_unused struct cmdline *cl,
15438 __rte_unused void *data)
15440 struct cmd_vf_tc_bw_result *res = parsed_result;
15443 int ret = -ENOTSUP;
15445 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15448 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
15452 #ifdef RTE_NET_I40E
15453 ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
15461 printf("invalid vf_id %d or bandwidth\n", res->vf_id);
15464 printf("invalid port_id %d\n", res->port_id);
15467 printf("function not implemented\n");
15470 printf("programming error: (%s)\n", strerror(-ret));
15474 cmdline_parse_inst_t cmd_vf_tc_min_bw = {
15475 .f = cmd_vf_tc_min_bw_parsed,
15477 .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
15478 " <bw1, bw2, ...>",
15480 (void *)&cmd_vf_tc_bw_set,
15481 (void *)&cmd_vf_tc_bw_vf,
15482 (void *)&cmd_vf_tc_bw_tc,
15483 (void *)&cmd_vf_tc_bw_tx,
15484 (void *)&cmd_vf_tc_bw_min_bw,
15485 (void *)&cmd_vf_tc_bw_port_id,
15486 (void *)&cmd_vf_tc_bw_vf_id,
15487 (void *)&cmd_vf_tc_bw_bw_list,
15493 cmd_tc_min_bw_parsed(
15494 void *parsed_result,
15495 __rte_unused struct cmdline *cl,
15496 __rte_unused void *data)
15498 struct cmd_vf_tc_bw_result *res = parsed_result;
15499 struct rte_port *port;
15502 int ret = -ENOTSUP;
15504 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15507 port = &ports[res->port_id];
15508 /** Check if the port is not started **/
15509 if (port->port_status != RTE_PORT_STOPPED) {
15510 printf("Please stop port %d first\n", res->port_id);
15514 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
15518 #ifdef RTE_NET_IXGBE
15519 ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw);
15526 printf("invalid bandwidth\n");
15529 printf("invalid port_id %d\n", res->port_id);
15532 printf("function not implemented\n");
15535 printf("programming error: (%s)\n", strerror(-ret));
15539 cmdline_parse_inst_t cmd_tc_min_bw = {
15540 .f = cmd_tc_min_bw_parsed,
15542 .help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>",
15544 (void *)&cmd_vf_tc_bw_set,
15545 (void *)&cmd_vf_tc_bw_tc,
15546 (void *)&cmd_vf_tc_bw_tx,
15547 (void *)&cmd_vf_tc_bw_min_bw,
15548 (void *)&cmd_vf_tc_bw_port_id,
15549 (void *)&cmd_vf_tc_bw_bw_list,
15554 /* TC max bandwidth setting */
15556 cmd_vf_tc_max_bw_parsed(
15557 void *parsed_result,
15558 __rte_unused struct cmdline *cl,
15559 __rte_unused void *data)
15561 struct cmd_vf_tc_bw_result *res = parsed_result;
15562 int ret = -ENOTSUP;
15564 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15567 #ifdef RTE_NET_I40E
15568 ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id,
15569 res->tc_no, res->bw);
15576 printf("invalid vf_id %d, tc_no %d or bandwidth %d\n",
15577 res->vf_id, res->tc_no, res->bw);
15580 printf("invalid port_id %d\n", res->port_id);
15583 printf("function not implemented\n");
15586 printf("programming error: (%s)\n", strerror(-ret));
15590 cmdline_parse_inst_t cmd_vf_tc_max_bw = {
15591 .f = cmd_vf_tc_max_bw_parsed,
15593 .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>"
15596 (void *)&cmd_vf_tc_bw_set,
15597 (void *)&cmd_vf_tc_bw_vf,
15598 (void *)&cmd_vf_tc_bw_tc,
15599 (void *)&cmd_vf_tc_bw_tx,
15600 (void *)&cmd_vf_tc_bw_max_bw,
15601 (void *)&cmd_vf_tc_bw_port_id,
15602 (void *)&cmd_vf_tc_bw_vf_id,
15603 (void *)&cmd_vf_tc_bw_tc_no,
15604 (void *)&cmd_vf_tc_bw_bw,
15609 /** Set VXLAN encapsulation details */
15610 struct cmd_set_vxlan_result {
15611 cmdline_fixed_string_t set;
15612 cmdline_fixed_string_t vxlan;
15613 cmdline_fixed_string_t pos_token;
15614 cmdline_fixed_string_t ip_version;
15615 uint32_t vlan_present:1;
15619 cmdline_ipaddr_t ip_src;
15620 cmdline_ipaddr_t ip_dst;
15624 struct rte_ether_addr eth_src;
15625 struct rte_ether_addr eth_dst;
15628 cmdline_parse_token_string_t cmd_set_vxlan_set =
15629 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, set, "set");
15630 cmdline_parse_token_string_t cmd_set_vxlan_vxlan =
15631 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan, "vxlan");
15632 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_tos_ttl =
15633 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
15635 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_with_vlan =
15636 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
15637 "vxlan-with-vlan");
15638 cmdline_parse_token_string_t cmd_set_vxlan_ip_version =
15639 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15641 cmdline_parse_token_string_t cmd_set_vxlan_ip_version_value =
15642 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, ip_version,
15644 cmdline_parse_token_string_t cmd_set_vxlan_vni =
15645 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15647 cmdline_parse_token_num_t cmd_set_vxlan_vni_value =
15648 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, vni, UINT32);
15649 cmdline_parse_token_string_t cmd_set_vxlan_udp_src =
15650 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15652 cmdline_parse_token_num_t cmd_set_vxlan_udp_src_value =
15653 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_src, UINT16);
15654 cmdline_parse_token_string_t cmd_set_vxlan_udp_dst =
15655 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15657 cmdline_parse_token_num_t cmd_set_vxlan_udp_dst_value =
15658 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_dst, UINT16);
15659 cmdline_parse_token_string_t cmd_set_vxlan_ip_tos =
15660 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15662 cmdline_parse_token_num_t cmd_set_vxlan_ip_tos_value =
15663 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tos, UINT8);
15664 cmdline_parse_token_string_t cmd_set_vxlan_ip_ttl =
15665 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15667 cmdline_parse_token_num_t cmd_set_vxlan_ip_ttl_value =
15668 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, ttl, UINT8);
15669 cmdline_parse_token_string_t cmd_set_vxlan_ip_src =
15670 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15672 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_src_value =
15673 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_src);
15674 cmdline_parse_token_string_t cmd_set_vxlan_ip_dst =
15675 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15677 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_dst_value =
15678 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_dst);
15679 cmdline_parse_token_string_t cmd_set_vxlan_vlan =
15680 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15682 cmdline_parse_token_num_t cmd_set_vxlan_vlan_value =
15683 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tci, UINT16);
15684 cmdline_parse_token_string_t cmd_set_vxlan_eth_src =
15685 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15687 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_src_value =
15688 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_src);
15689 cmdline_parse_token_string_t cmd_set_vxlan_eth_dst =
15690 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15692 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_dst_value =
15693 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_dst);
15695 static void cmd_set_vxlan_parsed(void *parsed_result,
15696 __rte_unused struct cmdline *cl,
15697 __rte_unused void *data)
15699 struct cmd_set_vxlan_result *res = parsed_result;
15704 .vxlan_id = rte_cpu_to_be_32(res->vni) & RTE_BE32(0x00ffffff),
15707 vxlan_encap_conf.select_tos_ttl = 0;
15708 if (strcmp(res->vxlan, "vxlan") == 0)
15709 vxlan_encap_conf.select_vlan = 0;
15710 else if (strcmp(res->vxlan, "vxlan-with-vlan") == 0)
15711 vxlan_encap_conf.select_vlan = 1;
15712 else if (strcmp(res->vxlan, "vxlan-tos-ttl") == 0) {
15713 vxlan_encap_conf.select_vlan = 0;
15714 vxlan_encap_conf.select_tos_ttl = 1;
15716 if (strcmp(res->ip_version, "ipv4") == 0)
15717 vxlan_encap_conf.select_ipv4 = 1;
15718 else if (strcmp(res->ip_version, "ipv6") == 0)
15719 vxlan_encap_conf.select_ipv4 = 0;
15722 rte_memcpy(vxlan_encap_conf.vni, &id.vni[1], 3);
15723 vxlan_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
15724 vxlan_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
15725 vxlan_encap_conf.ip_tos = res->tos;
15726 vxlan_encap_conf.ip_ttl = res->ttl;
15727 if (vxlan_encap_conf.select_ipv4) {
15728 IPV4_ADDR_TO_UINT(res->ip_src, vxlan_encap_conf.ipv4_src);
15729 IPV4_ADDR_TO_UINT(res->ip_dst, vxlan_encap_conf.ipv4_dst);
15731 IPV6_ADDR_TO_ARRAY(res->ip_src, vxlan_encap_conf.ipv6_src);
15732 IPV6_ADDR_TO_ARRAY(res->ip_dst, vxlan_encap_conf.ipv6_dst);
15734 if (vxlan_encap_conf.select_vlan)
15735 vxlan_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15736 rte_memcpy(vxlan_encap_conf.eth_src, res->eth_src.addr_bytes,
15737 RTE_ETHER_ADDR_LEN);
15738 rte_memcpy(vxlan_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15739 RTE_ETHER_ADDR_LEN);
15742 cmdline_parse_inst_t cmd_set_vxlan = {
15743 .f = cmd_set_vxlan_parsed,
15745 .help_str = "set vxlan ip-version ipv4|ipv6 vni <vni> udp-src"
15746 " <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst <ip-dst>"
15747 " eth-src <eth-src> eth-dst <eth-dst>",
15749 (void *)&cmd_set_vxlan_set,
15750 (void *)&cmd_set_vxlan_vxlan,
15751 (void *)&cmd_set_vxlan_ip_version,
15752 (void *)&cmd_set_vxlan_ip_version_value,
15753 (void *)&cmd_set_vxlan_vni,
15754 (void *)&cmd_set_vxlan_vni_value,
15755 (void *)&cmd_set_vxlan_udp_src,
15756 (void *)&cmd_set_vxlan_udp_src_value,
15757 (void *)&cmd_set_vxlan_udp_dst,
15758 (void *)&cmd_set_vxlan_udp_dst_value,
15759 (void *)&cmd_set_vxlan_ip_src,
15760 (void *)&cmd_set_vxlan_ip_src_value,
15761 (void *)&cmd_set_vxlan_ip_dst,
15762 (void *)&cmd_set_vxlan_ip_dst_value,
15763 (void *)&cmd_set_vxlan_eth_src,
15764 (void *)&cmd_set_vxlan_eth_src_value,
15765 (void *)&cmd_set_vxlan_eth_dst,
15766 (void *)&cmd_set_vxlan_eth_dst_value,
15771 cmdline_parse_inst_t cmd_set_vxlan_tos_ttl = {
15772 .f = cmd_set_vxlan_parsed,
15774 .help_str = "set vxlan-tos-ttl ip-version ipv4|ipv6 vni <vni> udp-src"
15775 " <udp-src> udp-dst <udp-dst> ip-tos <ip-tos> ip-ttl <ip-ttl>"
15776 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
15777 " eth-dst <eth-dst>",
15779 (void *)&cmd_set_vxlan_set,
15780 (void *)&cmd_set_vxlan_vxlan_tos_ttl,
15781 (void *)&cmd_set_vxlan_ip_version,
15782 (void *)&cmd_set_vxlan_ip_version_value,
15783 (void *)&cmd_set_vxlan_vni,
15784 (void *)&cmd_set_vxlan_vni_value,
15785 (void *)&cmd_set_vxlan_udp_src,
15786 (void *)&cmd_set_vxlan_udp_src_value,
15787 (void *)&cmd_set_vxlan_udp_dst,
15788 (void *)&cmd_set_vxlan_udp_dst_value,
15789 (void *)&cmd_set_vxlan_ip_tos,
15790 (void *)&cmd_set_vxlan_ip_tos_value,
15791 (void *)&cmd_set_vxlan_ip_ttl,
15792 (void *)&cmd_set_vxlan_ip_ttl_value,
15793 (void *)&cmd_set_vxlan_ip_src,
15794 (void *)&cmd_set_vxlan_ip_src_value,
15795 (void *)&cmd_set_vxlan_ip_dst,
15796 (void *)&cmd_set_vxlan_ip_dst_value,
15797 (void *)&cmd_set_vxlan_eth_src,
15798 (void *)&cmd_set_vxlan_eth_src_value,
15799 (void *)&cmd_set_vxlan_eth_dst,
15800 (void *)&cmd_set_vxlan_eth_dst_value,
15805 cmdline_parse_inst_t cmd_set_vxlan_with_vlan = {
15806 .f = cmd_set_vxlan_parsed,
15808 .help_str = "set vxlan-with-vlan ip-version ipv4|ipv6 vni <vni>"
15809 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst"
15810 " <ip-dst> vlan-tci <vlan-tci> eth-src <eth-src> eth-dst"
15813 (void *)&cmd_set_vxlan_set,
15814 (void *)&cmd_set_vxlan_vxlan_with_vlan,
15815 (void *)&cmd_set_vxlan_ip_version,
15816 (void *)&cmd_set_vxlan_ip_version_value,
15817 (void *)&cmd_set_vxlan_vni,
15818 (void *)&cmd_set_vxlan_vni_value,
15819 (void *)&cmd_set_vxlan_udp_src,
15820 (void *)&cmd_set_vxlan_udp_src_value,
15821 (void *)&cmd_set_vxlan_udp_dst,
15822 (void *)&cmd_set_vxlan_udp_dst_value,
15823 (void *)&cmd_set_vxlan_ip_src,
15824 (void *)&cmd_set_vxlan_ip_src_value,
15825 (void *)&cmd_set_vxlan_ip_dst,
15826 (void *)&cmd_set_vxlan_ip_dst_value,
15827 (void *)&cmd_set_vxlan_vlan,
15828 (void *)&cmd_set_vxlan_vlan_value,
15829 (void *)&cmd_set_vxlan_eth_src,
15830 (void *)&cmd_set_vxlan_eth_src_value,
15831 (void *)&cmd_set_vxlan_eth_dst,
15832 (void *)&cmd_set_vxlan_eth_dst_value,
15837 /** Set NVGRE encapsulation details */
15838 struct cmd_set_nvgre_result {
15839 cmdline_fixed_string_t set;
15840 cmdline_fixed_string_t nvgre;
15841 cmdline_fixed_string_t pos_token;
15842 cmdline_fixed_string_t ip_version;
15844 cmdline_ipaddr_t ip_src;
15845 cmdline_ipaddr_t ip_dst;
15847 struct rte_ether_addr eth_src;
15848 struct rte_ether_addr eth_dst;
15851 cmdline_parse_token_string_t cmd_set_nvgre_set =
15852 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, set, "set");
15853 cmdline_parse_token_string_t cmd_set_nvgre_nvgre =
15854 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre, "nvgre");
15855 cmdline_parse_token_string_t cmd_set_nvgre_nvgre_with_vlan =
15856 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre,
15857 "nvgre-with-vlan");
15858 cmdline_parse_token_string_t cmd_set_nvgre_ip_version =
15859 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15861 cmdline_parse_token_string_t cmd_set_nvgre_ip_version_value =
15862 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, ip_version,
15864 cmdline_parse_token_string_t cmd_set_nvgre_tni =
15865 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15867 cmdline_parse_token_num_t cmd_set_nvgre_tni_value =
15868 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tni, UINT32);
15869 cmdline_parse_token_string_t cmd_set_nvgre_ip_src =
15870 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15872 cmdline_parse_token_num_t cmd_set_nvgre_ip_src_value =
15873 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_src);
15874 cmdline_parse_token_string_t cmd_set_nvgre_ip_dst =
15875 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15877 cmdline_parse_token_ipaddr_t cmd_set_nvgre_ip_dst_value =
15878 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_dst);
15879 cmdline_parse_token_string_t cmd_set_nvgre_vlan =
15880 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15882 cmdline_parse_token_num_t cmd_set_nvgre_vlan_value =
15883 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tci, UINT16);
15884 cmdline_parse_token_string_t cmd_set_nvgre_eth_src =
15885 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15887 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_src_value =
15888 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_src);
15889 cmdline_parse_token_string_t cmd_set_nvgre_eth_dst =
15890 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15892 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_dst_value =
15893 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_dst);
15895 static void cmd_set_nvgre_parsed(void *parsed_result,
15896 __rte_unused struct cmdline *cl,
15897 __rte_unused void *data)
15899 struct cmd_set_nvgre_result *res = parsed_result;
15901 uint32_t nvgre_tni;
15904 .nvgre_tni = rte_cpu_to_be_32(res->tni) & RTE_BE32(0x00ffffff),
15907 if (strcmp(res->nvgre, "nvgre") == 0)
15908 nvgre_encap_conf.select_vlan = 0;
15909 else if (strcmp(res->nvgre, "nvgre-with-vlan") == 0)
15910 nvgre_encap_conf.select_vlan = 1;
15911 if (strcmp(res->ip_version, "ipv4") == 0)
15912 nvgre_encap_conf.select_ipv4 = 1;
15913 else if (strcmp(res->ip_version, "ipv6") == 0)
15914 nvgre_encap_conf.select_ipv4 = 0;
15917 rte_memcpy(nvgre_encap_conf.tni, &id.tni[1], 3);
15918 if (nvgre_encap_conf.select_ipv4) {
15919 IPV4_ADDR_TO_UINT(res->ip_src, nvgre_encap_conf.ipv4_src);
15920 IPV4_ADDR_TO_UINT(res->ip_dst, nvgre_encap_conf.ipv4_dst);
15922 IPV6_ADDR_TO_ARRAY(res->ip_src, nvgre_encap_conf.ipv6_src);
15923 IPV6_ADDR_TO_ARRAY(res->ip_dst, nvgre_encap_conf.ipv6_dst);
15925 if (nvgre_encap_conf.select_vlan)
15926 nvgre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15927 rte_memcpy(nvgre_encap_conf.eth_src, res->eth_src.addr_bytes,
15928 RTE_ETHER_ADDR_LEN);
15929 rte_memcpy(nvgre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15930 RTE_ETHER_ADDR_LEN);
15933 cmdline_parse_inst_t cmd_set_nvgre = {
15934 .f = cmd_set_nvgre_parsed,
15936 .help_str = "set nvgre ip-version <ipv4|ipv6> tni <tni> ip-src"
15937 " <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
15938 " eth-dst <eth-dst>",
15940 (void *)&cmd_set_nvgre_set,
15941 (void *)&cmd_set_nvgre_nvgre,
15942 (void *)&cmd_set_nvgre_ip_version,
15943 (void *)&cmd_set_nvgre_ip_version_value,
15944 (void *)&cmd_set_nvgre_tni,
15945 (void *)&cmd_set_nvgre_tni_value,
15946 (void *)&cmd_set_nvgre_ip_src,
15947 (void *)&cmd_set_nvgre_ip_src_value,
15948 (void *)&cmd_set_nvgre_ip_dst,
15949 (void *)&cmd_set_nvgre_ip_dst_value,
15950 (void *)&cmd_set_nvgre_eth_src,
15951 (void *)&cmd_set_nvgre_eth_src_value,
15952 (void *)&cmd_set_nvgre_eth_dst,
15953 (void *)&cmd_set_nvgre_eth_dst_value,
15958 cmdline_parse_inst_t cmd_set_nvgre_with_vlan = {
15959 .f = cmd_set_nvgre_parsed,
15961 .help_str = "set nvgre-with-vlan ip-version <ipv4|ipv6> tni <tni>"
15962 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
15963 " eth-src <eth-src> eth-dst <eth-dst>",
15965 (void *)&cmd_set_nvgre_set,
15966 (void *)&cmd_set_nvgre_nvgre_with_vlan,
15967 (void *)&cmd_set_nvgre_ip_version,
15968 (void *)&cmd_set_nvgre_ip_version_value,
15969 (void *)&cmd_set_nvgre_tni,
15970 (void *)&cmd_set_nvgre_tni_value,
15971 (void *)&cmd_set_nvgre_ip_src,
15972 (void *)&cmd_set_nvgre_ip_src_value,
15973 (void *)&cmd_set_nvgre_ip_dst,
15974 (void *)&cmd_set_nvgre_ip_dst_value,
15975 (void *)&cmd_set_nvgre_vlan,
15976 (void *)&cmd_set_nvgre_vlan_value,
15977 (void *)&cmd_set_nvgre_eth_src,
15978 (void *)&cmd_set_nvgre_eth_src_value,
15979 (void *)&cmd_set_nvgre_eth_dst,
15980 (void *)&cmd_set_nvgre_eth_dst_value,
15985 /** Set L2 encapsulation details */
15986 struct cmd_set_l2_encap_result {
15987 cmdline_fixed_string_t set;
15988 cmdline_fixed_string_t l2_encap;
15989 cmdline_fixed_string_t pos_token;
15990 cmdline_fixed_string_t ip_version;
15991 uint32_t vlan_present:1;
15993 struct rte_ether_addr eth_src;
15994 struct rte_ether_addr eth_dst;
15997 cmdline_parse_token_string_t cmd_set_l2_encap_set =
15998 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, set, "set");
15999 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap =
16000 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap, "l2_encap");
16001 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap_with_vlan =
16002 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap,
16003 "l2_encap-with-vlan");
16004 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version =
16005 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
16007 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version_value =
16008 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, ip_version,
16010 cmdline_parse_token_string_t cmd_set_l2_encap_vlan =
16011 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
16013 cmdline_parse_token_num_t cmd_set_l2_encap_vlan_value =
16014 TOKEN_NUM_INITIALIZER(struct cmd_set_l2_encap_result, tci, UINT16);
16015 cmdline_parse_token_string_t cmd_set_l2_encap_eth_src =
16016 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
16018 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_src_value =
16019 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_src);
16020 cmdline_parse_token_string_t cmd_set_l2_encap_eth_dst =
16021 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
16023 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_dst_value =
16024 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_dst);
16026 static void cmd_set_l2_encap_parsed(void *parsed_result,
16027 __rte_unused struct cmdline *cl,
16028 __rte_unused void *data)
16030 struct cmd_set_l2_encap_result *res = parsed_result;
16032 if (strcmp(res->l2_encap, "l2_encap") == 0)
16033 l2_encap_conf.select_vlan = 0;
16034 else if (strcmp(res->l2_encap, "l2_encap-with-vlan") == 0)
16035 l2_encap_conf.select_vlan = 1;
16036 if (strcmp(res->ip_version, "ipv4") == 0)
16037 l2_encap_conf.select_ipv4 = 1;
16038 else if (strcmp(res->ip_version, "ipv6") == 0)
16039 l2_encap_conf.select_ipv4 = 0;
16042 if (l2_encap_conf.select_vlan)
16043 l2_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
16044 rte_memcpy(l2_encap_conf.eth_src, res->eth_src.addr_bytes,
16045 RTE_ETHER_ADDR_LEN);
16046 rte_memcpy(l2_encap_conf.eth_dst, res->eth_dst.addr_bytes,
16047 RTE_ETHER_ADDR_LEN);
16050 cmdline_parse_inst_t cmd_set_l2_encap = {
16051 .f = cmd_set_l2_encap_parsed,
16053 .help_str = "set l2_encap ip-version ipv4|ipv6"
16054 " eth-src <eth-src> eth-dst <eth-dst>",
16056 (void *)&cmd_set_l2_encap_set,
16057 (void *)&cmd_set_l2_encap_l2_encap,
16058 (void *)&cmd_set_l2_encap_ip_version,
16059 (void *)&cmd_set_l2_encap_ip_version_value,
16060 (void *)&cmd_set_l2_encap_eth_src,
16061 (void *)&cmd_set_l2_encap_eth_src_value,
16062 (void *)&cmd_set_l2_encap_eth_dst,
16063 (void *)&cmd_set_l2_encap_eth_dst_value,
16068 cmdline_parse_inst_t cmd_set_l2_encap_with_vlan = {
16069 .f = cmd_set_l2_encap_parsed,
16071 .help_str = "set l2_encap-with-vlan ip-version ipv4|ipv6"
16072 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
16074 (void *)&cmd_set_l2_encap_set,
16075 (void *)&cmd_set_l2_encap_l2_encap_with_vlan,
16076 (void *)&cmd_set_l2_encap_ip_version,
16077 (void *)&cmd_set_l2_encap_ip_version_value,
16078 (void *)&cmd_set_l2_encap_vlan,
16079 (void *)&cmd_set_l2_encap_vlan_value,
16080 (void *)&cmd_set_l2_encap_eth_src,
16081 (void *)&cmd_set_l2_encap_eth_src_value,
16082 (void *)&cmd_set_l2_encap_eth_dst,
16083 (void *)&cmd_set_l2_encap_eth_dst_value,
16088 /** Set L2 decapsulation details */
16089 struct cmd_set_l2_decap_result {
16090 cmdline_fixed_string_t set;
16091 cmdline_fixed_string_t l2_decap;
16092 cmdline_fixed_string_t pos_token;
16093 uint32_t vlan_present:1;
16096 cmdline_parse_token_string_t cmd_set_l2_decap_set =
16097 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, set, "set");
16098 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap =
16099 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
16101 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap_with_vlan =
16102 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
16103 "l2_decap-with-vlan");
16105 static void cmd_set_l2_decap_parsed(void *parsed_result,
16106 __rte_unused struct cmdline *cl,
16107 __rte_unused void *data)
16109 struct cmd_set_l2_decap_result *res = parsed_result;
16111 if (strcmp(res->l2_decap, "l2_decap") == 0)
16112 l2_decap_conf.select_vlan = 0;
16113 else if (strcmp(res->l2_decap, "l2_decap-with-vlan") == 0)
16114 l2_decap_conf.select_vlan = 1;
16117 cmdline_parse_inst_t cmd_set_l2_decap = {
16118 .f = cmd_set_l2_decap_parsed,
16120 .help_str = "set l2_decap",
16122 (void *)&cmd_set_l2_decap_set,
16123 (void *)&cmd_set_l2_decap_l2_decap,
16128 cmdline_parse_inst_t cmd_set_l2_decap_with_vlan = {
16129 .f = cmd_set_l2_decap_parsed,
16131 .help_str = "set l2_decap-with-vlan",
16133 (void *)&cmd_set_l2_decap_set,
16134 (void *)&cmd_set_l2_decap_l2_decap_with_vlan,
16139 /** Set MPLSoGRE encapsulation details */
16140 struct cmd_set_mplsogre_encap_result {
16141 cmdline_fixed_string_t set;
16142 cmdline_fixed_string_t mplsogre;
16143 cmdline_fixed_string_t pos_token;
16144 cmdline_fixed_string_t ip_version;
16145 uint32_t vlan_present:1;
16147 cmdline_ipaddr_t ip_src;
16148 cmdline_ipaddr_t ip_dst;
16150 struct rte_ether_addr eth_src;
16151 struct rte_ether_addr eth_dst;
16154 cmdline_parse_token_string_t cmd_set_mplsogre_encap_set =
16155 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, set,
16157 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap =
16158 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, mplsogre,
16160 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap_with_vlan =
16161 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
16162 mplsogre, "mplsogre_encap-with-vlan");
16163 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version =
16164 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
16165 pos_token, "ip-version");
16166 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version_value =
16167 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
16168 ip_version, "ipv4#ipv6");
16169 cmdline_parse_token_string_t cmd_set_mplsogre_encap_label =
16170 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
16171 pos_token, "label");
16172 cmdline_parse_token_num_t cmd_set_mplsogre_encap_label_value =
16173 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, label,
16175 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_src =
16176 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
16177 pos_token, "ip-src");
16178 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_src_value =
16179 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_src);
16180 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_dst =
16181 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
16182 pos_token, "ip-dst");
16183 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_dst_value =
16184 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_dst);
16185 cmdline_parse_token_string_t cmd_set_mplsogre_encap_vlan =
16186 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
16187 pos_token, "vlan-tci");
16188 cmdline_parse_token_num_t cmd_set_mplsogre_encap_vlan_value =
16189 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, tci,
16191 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_src =
16192 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
16193 pos_token, "eth-src");
16194 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_src_value =
16195 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
16197 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_dst =
16198 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
16199 pos_token, "eth-dst");
16200 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_dst_value =
16201 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
16204 static void cmd_set_mplsogre_encap_parsed(void *parsed_result,
16205 __rte_unused struct cmdline *cl,
16206 __rte_unused void *data)
16208 struct cmd_set_mplsogre_encap_result *res = parsed_result;
16210 uint32_t mplsogre_label;
16213 .mplsogre_label = rte_cpu_to_be_32(res->label<<12),
16216 if (strcmp(res->mplsogre, "mplsogre_encap") == 0)
16217 mplsogre_encap_conf.select_vlan = 0;
16218 else if (strcmp(res->mplsogre, "mplsogre_encap-with-vlan") == 0)
16219 mplsogre_encap_conf.select_vlan = 1;
16220 if (strcmp(res->ip_version, "ipv4") == 0)
16221 mplsogre_encap_conf.select_ipv4 = 1;
16222 else if (strcmp(res->ip_version, "ipv6") == 0)
16223 mplsogre_encap_conf.select_ipv4 = 0;
16226 rte_memcpy(mplsogre_encap_conf.label, &id.label, 3);
16227 if (mplsogre_encap_conf.select_ipv4) {
16228 IPV4_ADDR_TO_UINT(res->ip_src, mplsogre_encap_conf.ipv4_src);
16229 IPV4_ADDR_TO_UINT(res->ip_dst, mplsogre_encap_conf.ipv4_dst);
16231 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsogre_encap_conf.ipv6_src);
16232 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsogre_encap_conf.ipv6_dst);
16234 if (mplsogre_encap_conf.select_vlan)
16235 mplsogre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
16236 rte_memcpy(mplsogre_encap_conf.eth_src, res->eth_src.addr_bytes,
16237 RTE_ETHER_ADDR_LEN);
16238 rte_memcpy(mplsogre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
16239 RTE_ETHER_ADDR_LEN);
16242 cmdline_parse_inst_t cmd_set_mplsogre_encap = {
16243 .f = cmd_set_mplsogre_encap_parsed,
16245 .help_str = "set mplsogre_encap ip-version ipv4|ipv6 label <label>"
16246 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
16247 " eth-dst <eth-dst>",
16249 (void *)&cmd_set_mplsogre_encap_set,
16250 (void *)&cmd_set_mplsogre_encap_mplsogre_encap,
16251 (void *)&cmd_set_mplsogre_encap_ip_version,
16252 (void *)&cmd_set_mplsogre_encap_ip_version_value,
16253 (void *)&cmd_set_mplsogre_encap_label,
16254 (void *)&cmd_set_mplsogre_encap_label_value,
16255 (void *)&cmd_set_mplsogre_encap_ip_src,
16256 (void *)&cmd_set_mplsogre_encap_ip_src_value,
16257 (void *)&cmd_set_mplsogre_encap_ip_dst,
16258 (void *)&cmd_set_mplsogre_encap_ip_dst_value,
16259 (void *)&cmd_set_mplsogre_encap_eth_src,
16260 (void *)&cmd_set_mplsogre_encap_eth_src_value,
16261 (void *)&cmd_set_mplsogre_encap_eth_dst,
16262 (void *)&cmd_set_mplsogre_encap_eth_dst_value,
16267 cmdline_parse_inst_t cmd_set_mplsogre_encap_with_vlan = {
16268 .f = cmd_set_mplsogre_encap_parsed,
16270 .help_str = "set mplsogre_encap-with-vlan ip-version ipv4|ipv6"
16271 " label <label> ip-src <ip-src> ip-dst <ip-dst>"
16272 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
16274 (void *)&cmd_set_mplsogre_encap_set,
16275 (void *)&cmd_set_mplsogre_encap_mplsogre_encap_with_vlan,
16276 (void *)&cmd_set_mplsogre_encap_ip_version,
16277 (void *)&cmd_set_mplsogre_encap_ip_version_value,
16278 (void *)&cmd_set_mplsogre_encap_label,
16279 (void *)&cmd_set_mplsogre_encap_label_value,
16280 (void *)&cmd_set_mplsogre_encap_ip_src,
16281 (void *)&cmd_set_mplsogre_encap_ip_src_value,
16282 (void *)&cmd_set_mplsogre_encap_ip_dst,
16283 (void *)&cmd_set_mplsogre_encap_ip_dst_value,
16284 (void *)&cmd_set_mplsogre_encap_vlan,
16285 (void *)&cmd_set_mplsogre_encap_vlan_value,
16286 (void *)&cmd_set_mplsogre_encap_eth_src,
16287 (void *)&cmd_set_mplsogre_encap_eth_src_value,
16288 (void *)&cmd_set_mplsogre_encap_eth_dst,
16289 (void *)&cmd_set_mplsogre_encap_eth_dst_value,
16294 /** Set MPLSoGRE decapsulation details */
16295 struct cmd_set_mplsogre_decap_result {
16296 cmdline_fixed_string_t set;
16297 cmdline_fixed_string_t mplsogre;
16298 cmdline_fixed_string_t pos_token;
16299 cmdline_fixed_string_t ip_version;
16300 uint32_t vlan_present:1;
16303 cmdline_parse_token_string_t cmd_set_mplsogre_decap_set =
16304 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, set,
16306 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap =
16307 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, mplsogre,
16309 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap_with_vlan =
16310 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
16311 mplsogre, "mplsogre_decap-with-vlan");
16312 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version =
16313 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
16314 pos_token, "ip-version");
16315 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version_value =
16316 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
16317 ip_version, "ipv4#ipv6");
16319 static void cmd_set_mplsogre_decap_parsed(void *parsed_result,
16320 __rte_unused struct cmdline *cl,
16321 __rte_unused void *data)
16323 struct cmd_set_mplsogre_decap_result *res = parsed_result;
16325 if (strcmp(res->mplsogre, "mplsogre_decap") == 0)
16326 mplsogre_decap_conf.select_vlan = 0;
16327 else if (strcmp(res->mplsogre, "mplsogre_decap-with-vlan") == 0)
16328 mplsogre_decap_conf.select_vlan = 1;
16329 if (strcmp(res->ip_version, "ipv4") == 0)
16330 mplsogre_decap_conf.select_ipv4 = 1;
16331 else if (strcmp(res->ip_version, "ipv6") == 0)
16332 mplsogre_decap_conf.select_ipv4 = 0;
16335 cmdline_parse_inst_t cmd_set_mplsogre_decap = {
16336 .f = cmd_set_mplsogre_decap_parsed,
16338 .help_str = "set mplsogre_decap ip-version ipv4|ipv6",
16340 (void *)&cmd_set_mplsogre_decap_set,
16341 (void *)&cmd_set_mplsogre_decap_mplsogre_decap,
16342 (void *)&cmd_set_mplsogre_decap_ip_version,
16343 (void *)&cmd_set_mplsogre_decap_ip_version_value,
16348 cmdline_parse_inst_t cmd_set_mplsogre_decap_with_vlan = {
16349 .f = cmd_set_mplsogre_decap_parsed,
16351 .help_str = "set mplsogre_decap-with-vlan ip-version ipv4|ipv6",
16353 (void *)&cmd_set_mplsogre_decap_set,
16354 (void *)&cmd_set_mplsogre_decap_mplsogre_decap_with_vlan,
16355 (void *)&cmd_set_mplsogre_decap_ip_version,
16356 (void *)&cmd_set_mplsogre_decap_ip_version_value,
16361 /** Set MPLSoUDP encapsulation details */
16362 struct cmd_set_mplsoudp_encap_result {
16363 cmdline_fixed_string_t set;
16364 cmdline_fixed_string_t mplsoudp;
16365 cmdline_fixed_string_t pos_token;
16366 cmdline_fixed_string_t ip_version;
16367 uint32_t vlan_present:1;
16371 cmdline_ipaddr_t ip_src;
16372 cmdline_ipaddr_t ip_dst;
16374 struct rte_ether_addr eth_src;
16375 struct rte_ether_addr eth_dst;
16378 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_set =
16379 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, set,
16381 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap =
16382 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, mplsoudp,
16384 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan =
16385 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16386 mplsoudp, "mplsoudp_encap-with-vlan");
16387 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version =
16388 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16389 pos_token, "ip-version");
16390 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version_value =
16391 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16392 ip_version, "ipv4#ipv6");
16393 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_label =
16394 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16395 pos_token, "label");
16396 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_label_value =
16397 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, label,
16399 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_src =
16400 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16401 pos_token, "udp-src");
16402 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_src_value =
16403 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_src,
16405 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_dst =
16406 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16407 pos_token, "udp-dst");
16408 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_dst_value =
16409 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_dst,
16411 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_src =
16412 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16413 pos_token, "ip-src");
16414 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_src_value =
16415 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_src);
16416 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_dst =
16417 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16418 pos_token, "ip-dst");
16419 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_dst_value =
16420 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_dst);
16421 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_vlan =
16422 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16423 pos_token, "vlan-tci");
16424 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_vlan_value =
16425 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, tci,
16427 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_src =
16428 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16429 pos_token, "eth-src");
16430 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_src_value =
16431 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16433 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_dst =
16434 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16435 pos_token, "eth-dst");
16436 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_dst_value =
16437 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16440 static void cmd_set_mplsoudp_encap_parsed(void *parsed_result,
16441 __rte_unused struct cmdline *cl,
16442 __rte_unused void *data)
16444 struct cmd_set_mplsoudp_encap_result *res = parsed_result;
16446 uint32_t mplsoudp_label;
16449 .mplsoudp_label = rte_cpu_to_be_32(res->label<<12),
16452 if (strcmp(res->mplsoudp, "mplsoudp_encap") == 0)
16453 mplsoudp_encap_conf.select_vlan = 0;
16454 else if (strcmp(res->mplsoudp, "mplsoudp_encap-with-vlan") == 0)
16455 mplsoudp_encap_conf.select_vlan = 1;
16456 if (strcmp(res->ip_version, "ipv4") == 0)
16457 mplsoudp_encap_conf.select_ipv4 = 1;
16458 else if (strcmp(res->ip_version, "ipv6") == 0)
16459 mplsoudp_encap_conf.select_ipv4 = 0;
16462 rte_memcpy(mplsoudp_encap_conf.label, &id.label, 3);
16463 mplsoudp_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
16464 mplsoudp_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
16465 if (mplsoudp_encap_conf.select_ipv4) {
16466 IPV4_ADDR_TO_UINT(res->ip_src, mplsoudp_encap_conf.ipv4_src);
16467 IPV4_ADDR_TO_UINT(res->ip_dst, mplsoudp_encap_conf.ipv4_dst);
16469 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsoudp_encap_conf.ipv6_src);
16470 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsoudp_encap_conf.ipv6_dst);
16472 if (mplsoudp_encap_conf.select_vlan)
16473 mplsoudp_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
16474 rte_memcpy(mplsoudp_encap_conf.eth_src, res->eth_src.addr_bytes,
16475 RTE_ETHER_ADDR_LEN);
16476 rte_memcpy(mplsoudp_encap_conf.eth_dst, res->eth_dst.addr_bytes,
16477 RTE_ETHER_ADDR_LEN);
16480 cmdline_parse_inst_t cmd_set_mplsoudp_encap = {
16481 .f = cmd_set_mplsoudp_encap_parsed,
16483 .help_str = "set mplsoudp_encap ip-version ipv4|ipv6 label <label>"
16484 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src>"
16485 " ip-dst <ip-dst> eth-src <eth-src> eth-dst <eth-dst>",
16487 (void *)&cmd_set_mplsoudp_encap_set,
16488 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap,
16489 (void *)&cmd_set_mplsoudp_encap_ip_version,
16490 (void *)&cmd_set_mplsoudp_encap_ip_version_value,
16491 (void *)&cmd_set_mplsoudp_encap_label,
16492 (void *)&cmd_set_mplsoudp_encap_label_value,
16493 (void *)&cmd_set_mplsoudp_encap_udp_src,
16494 (void *)&cmd_set_mplsoudp_encap_udp_src_value,
16495 (void *)&cmd_set_mplsoudp_encap_udp_dst,
16496 (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
16497 (void *)&cmd_set_mplsoudp_encap_ip_src,
16498 (void *)&cmd_set_mplsoudp_encap_ip_src_value,
16499 (void *)&cmd_set_mplsoudp_encap_ip_dst,
16500 (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
16501 (void *)&cmd_set_mplsoudp_encap_eth_src,
16502 (void *)&cmd_set_mplsoudp_encap_eth_src_value,
16503 (void *)&cmd_set_mplsoudp_encap_eth_dst,
16504 (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
16509 cmdline_parse_inst_t cmd_set_mplsoudp_encap_with_vlan = {
16510 .f = cmd_set_mplsoudp_encap_parsed,
16512 .help_str = "set mplsoudp_encap-with-vlan ip-version ipv4|ipv6"
16513 " label <label> udp-src <udp-src> udp-dst <udp-dst>"
16514 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
16515 " eth-src <eth-src> eth-dst <eth-dst>",
16517 (void *)&cmd_set_mplsoudp_encap_set,
16518 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan,
16519 (void *)&cmd_set_mplsoudp_encap_ip_version,
16520 (void *)&cmd_set_mplsoudp_encap_ip_version_value,
16521 (void *)&cmd_set_mplsoudp_encap_label,
16522 (void *)&cmd_set_mplsoudp_encap_label_value,
16523 (void *)&cmd_set_mplsoudp_encap_udp_src,
16524 (void *)&cmd_set_mplsoudp_encap_udp_src_value,
16525 (void *)&cmd_set_mplsoudp_encap_udp_dst,
16526 (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
16527 (void *)&cmd_set_mplsoudp_encap_ip_src,
16528 (void *)&cmd_set_mplsoudp_encap_ip_src_value,
16529 (void *)&cmd_set_mplsoudp_encap_ip_dst,
16530 (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
16531 (void *)&cmd_set_mplsoudp_encap_vlan,
16532 (void *)&cmd_set_mplsoudp_encap_vlan_value,
16533 (void *)&cmd_set_mplsoudp_encap_eth_src,
16534 (void *)&cmd_set_mplsoudp_encap_eth_src_value,
16535 (void *)&cmd_set_mplsoudp_encap_eth_dst,
16536 (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
16541 /** Set MPLSoUDP decapsulation details */
16542 struct cmd_set_mplsoudp_decap_result {
16543 cmdline_fixed_string_t set;
16544 cmdline_fixed_string_t mplsoudp;
16545 cmdline_fixed_string_t pos_token;
16546 cmdline_fixed_string_t ip_version;
16547 uint32_t vlan_present:1;
16550 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_set =
16551 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, set,
16553 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap =
16554 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, mplsoudp,
16556 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan =
16557 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
16558 mplsoudp, "mplsoudp_decap-with-vlan");
16559 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version =
16560 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
16561 pos_token, "ip-version");
16562 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version_value =
16563 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
16564 ip_version, "ipv4#ipv6");
16566 static void cmd_set_mplsoudp_decap_parsed(void *parsed_result,
16567 __rte_unused struct cmdline *cl,
16568 __rte_unused void *data)
16570 struct cmd_set_mplsoudp_decap_result *res = parsed_result;
16572 if (strcmp(res->mplsoudp, "mplsoudp_decap") == 0)
16573 mplsoudp_decap_conf.select_vlan = 0;
16574 else if (strcmp(res->mplsoudp, "mplsoudp_decap-with-vlan") == 0)
16575 mplsoudp_decap_conf.select_vlan = 1;
16576 if (strcmp(res->ip_version, "ipv4") == 0)
16577 mplsoudp_decap_conf.select_ipv4 = 1;
16578 else if (strcmp(res->ip_version, "ipv6") == 0)
16579 mplsoudp_decap_conf.select_ipv4 = 0;
16582 cmdline_parse_inst_t cmd_set_mplsoudp_decap = {
16583 .f = cmd_set_mplsoudp_decap_parsed,
16585 .help_str = "set mplsoudp_decap ip-version ipv4|ipv6",
16587 (void *)&cmd_set_mplsoudp_decap_set,
16588 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap,
16589 (void *)&cmd_set_mplsoudp_decap_ip_version,
16590 (void *)&cmd_set_mplsoudp_decap_ip_version_value,
16595 cmdline_parse_inst_t cmd_set_mplsoudp_decap_with_vlan = {
16596 .f = cmd_set_mplsoudp_decap_parsed,
16598 .help_str = "set mplsoudp_decap-with-vlan ip-version ipv4|ipv6",
16600 (void *)&cmd_set_mplsoudp_decap_set,
16601 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan,
16602 (void *)&cmd_set_mplsoudp_decap_ip_version,
16603 (void *)&cmd_set_mplsoudp_decap_ip_version_value,
16608 /* Strict link priority scheduling mode setting */
16610 cmd_strict_link_prio_parsed(
16611 void *parsed_result,
16612 __rte_unused struct cmdline *cl,
16613 __rte_unused void *data)
16615 struct cmd_vf_tc_bw_result *res = parsed_result;
16616 int ret = -ENOTSUP;
16618 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16621 #ifdef RTE_NET_I40E
16622 ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map);
16629 printf("invalid tc_bitmap 0x%x\n", res->tc_map);
16632 printf("invalid port_id %d\n", res->port_id);
16635 printf("function not implemented\n");
16638 printf("programming error: (%s)\n", strerror(-ret));
16642 cmdline_parse_inst_t cmd_strict_link_prio = {
16643 .f = cmd_strict_link_prio_parsed,
16645 .help_str = "set tx strict-link-priority <port_id> <tc_bitmap>",
16647 (void *)&cmd_vf_tc_bw_set,
16648 (void *)&cmd_vf_tc_bw_tx,
16649 (void *)&cmd_vf_tc_bw_strict_link_prio,
16650 (void *)&cmd_vf_tc_bw_port_id,
16651 (void *)&cmd_vf_tc_bw_tc_map,
16656 /* Load dynamic device personalization*/
16657 struct cmd_ddp_add_result {
16658 cmdline_fixed_string_t ddp;
16659 cmdline_fixed_string_t add;
16664 cmdline_parse_token_string_t cmd_ddp_add_ddp =
16665 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp");
16666 cmdline_parse_token_string_t cmd_ddp_add_add =
16667 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add");
16668 cmdline_parse_token_num_t cmd_ddp_add_port_id =
16669 TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id, UINT16);
16670 cmdline_parse_token_string_t cmd_ddp_add_filepath =
16671 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL);
16674 cmd_ddp_add_parsed(
16675 void *parsed_result,
16676 __rte_unused struct cmdline *cl,
16677 __rte_unused void *data)
16679 struct cmd_ddp_add_result *res = parsed_result;
16685 int ret = -ENOTSUP;
16687 if (!all_ports_stopped()) {
16688 printf("Please stop all ports first\n");
16692 filepath = strdup(res->filepath);
16693 if (filepath == NULL) {
16694 printf("Failed to allocate memory\n");
16697 file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ',');
16699 buff = open_file(file_fld[0], &size);
16701 free((void *)filepath);
16705 #ifdef RTE_NET_I40E
16706 if (ret == -ENOTSUP)
16707 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
16709 RTE_PMD_I40E_PKG_OP_WR_ADD);
16712 if (ret == -EEXIST)
16713 printf("Profile has already existed.\n");
16715 printf("Failed to load profile.\n");
16716 else if (file_num == 2)
16717 save_file(file_fld[1], buff, size);
16720 free((void *)filepath);
16723 cmdline_parse_inst_t cmd_ddp_add = {
16724 .f = cmd_ddp_add_parsed,
16726 .help_str = "ddp add <port_id> <profile_path[,backup_profile_path]>",
16728 (void *)&cmd_ddp_add_ddp,
16729 (void *)&cmd_ddp_add_add,
16730 (void *)&cmd_ddp_add_port_id,
16731 (void *)&cmd_ddp_add_filepath,
16736 /* Delete dynamic device personalization*/
16737 struct cmd_ddp_del_result {
16738 cmdline_fixed_string_t ddp;
16739 cmdline_fixed_string_t del;
16744 cmdline_parse_token_string_t cmd_ddp_del_ddp =
16745 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp");
16746 cmdline_parse_token_string_t cmd_ddp_del_del =
16747 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del");
16748 cmdline_parse_token_num_t cmd_ddp_del_port_id =
16749 TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, UINT16);
16750 cmdline_parse_token_string_t cmd_ddp_del_filepath =
16751 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL);
16754 cmd_ddp_del_parsed(
16755 void *parsed_result,
16756 __rte_unused struct cmdline *cl,
16757 __rte_unused void *data)
16759 struct cmd_ddp_del_result *res = parsed_result;
16762 int ret = -ENOTSUP;
16764 if (!all_ports_stopped()) {
16765 printf("Please stop all ports first\n");
16769 buff = open_file(res->filepath, &size);
16773 #ifdef RTE_NET_I40E
16774 if (ret == -ENOTSUP)
16775 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
16777 RTE_PMD_I40E_PKG_OP_WR_DEL);
16780 if (ret == -EACCES)
16781 printf("Profile does not exist.\n");
16783 printf("Failed to delete profile.\n");
16788 cmdline_parse_inst_t cmd_ddp_del = {
16789 .f = cmd_ddp_del_parsed,
16791 .help_str = "ddp del <port_id> <backup_profile_path>",
16793 (void *)&cmd_ddp_del_ddp,
16794 (void *)&cmd_ddp_del_del,
16795 (void *)&cmd_ddp_del_port_id,
16796 (void *)&cmd_ddp_del_filepath,
16801 /* Get dynamic device personalization profile info */
16802 struct cmd_ddp_info_result {
16803 cmdline_fixed_string_t ddp;
16804 cmdline_fixed_string_t get;
16805 cmdline_fixed_string_t info;
16809 cmdline_parse_token_string_t cmd_ddp_info_ddp =
16810 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp");
16811 cmdline_parse_token_string_t cmd_ddp_info_get =
16812 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get");
16813 cmdline_parse_token_string_t cmd_ddp_info_info =
16814 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info");
16815 cmdline_parse_token_string_t cmd_ddp_info_filepath =
16816 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL);
16819 cmd_ddp_info_parsed(
16820 void *parsed_result,
16821 __rte_unused struct cmdline *cl,
16822 __rte_unused void *data)
16824 struct cmd_ddp_info_result *res = parsed_result;
16827 int ret = -ENOTSUP;
16828 #ifdef RTE_NET_I40E
16831 uint32_t buff_size = 0;
16832 struct rte_pmd_i40e_profile_info info;
16833 uint32_t dev_num = 0;
16834 struct rte_pmd_i40e_ddp_device_id *devs;
16835 uint32_t proto_num = 0;
16836 struct rte_pmd_i40e_proto_info *proto = NULL;
16837 uint32_t pctype_num = 0;
16838 struct rte_pmd_i40e_ptype_info *pctype;
16839 uint32_t ptype_num = 0;
16840 struct rte_pmd_i40e_ptype_info *ptype;
16845 pkg = open_file(res->filepath, &pkg_size);
16849 #ifdef RTE_NET_I40E
16850 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16851 (uint8_t *)&info, sizeof(info),
16852 RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER);
16854 printf("Global Track id: 0x%x\n", info.track_id);
16855 printf("Global Version: %d.%d.%d.%d\n",
16856 info.version.major,
16857 info.version.minor,
16858 info.version.update,
16859 info.version.draft);
16860 printf("Global Package name: %s\n\n", info.name);
16863 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16864 (uint8_t *)&info, sizeof(info),
16865 RTE_PMD_I40E_PKG_INFO_HEADER);
16867 printf("i40e Profile Track id: 0x%x\n", info.track_id);
16868 printf("i40e Profile Version: %d.%d.%d.%d\n",
16869 info.version.major,
16870 info.version.minor,
16871 info.version.update,
16872 info.version.draft);
16873 printf("i40e Profile name: %s\n\n", info.name);
16876 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16877 (uint8_t *)&buff_size, sizeof(buff_size),
16878 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE);
16879 if (!ret && buff_size) {
16880 buff = (uint8_t *)malloc(buff_size);
16882 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16884 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES);
16886 printf("Package Notes:\n%s\n\n", buff);
16891 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16892 (uint8_t *)&dev_num, sizeof(dev_num),
16893 RTE_PMD_I40E_PKG_INFO_DEVID_NUM);
16894 if (!ret && dev_num) {
16895 buff_size = dev_num * sizeof(struct rte_pmd_i40e_ddp_device_id);
16896 devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(buff_size);
16898 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16899 (uint8_t *)devs, buff_size,
16900 RTE_PMD_I40E_PKG_INFO_DEVID_LIST);
16902 printf("List of supported devices:\n");
16903 for (i = 0; i < dev_num; i++) {
16904 printf(" %04X:%04X %04X:%04X\n",
16905 devs[i].vendor_dev_id >> 16,
16906 devs[i].vendor_dev_id & 0xFFFF,
16907 devs[i].sub_vendor_dev_id >> 16,
16908 devs[i].sub_vendor_dev_id & 0xFFFF);
16916 /* get information about protocols and packet types */
16917 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16918 (uint8_t *)&proto_num, sizeof(proto_num),
16919 RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM);
16920 if (ret || !proto_num)
16921 goto no_print_return;
16923 buff_size = proto_num * sizeof(struct rte_pmd_i40e_proto_info);
16924 proto = (struct rte_pmd_i40e_proto_info *)malloc(buff_size);
16926 goto no_print_return;
16928 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)proto,
16930 RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST);
16932 printf("List of used protocols:\n");
16933 for (i = 0; i < proto_num; i++)
16934 printf(" %2u: %s\n", proto[i].proto_id,
16938 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16939 (uint8_t *)&pctype_num, sizeof(pctype_num),
16940 RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM);
16941 if (ret || !pctype_num)
16942 goto no_print_pctypes;
16944 buff_size = pctype_num * sizeof(struct rte_pmd_i40e_ptype_info);
16945 pctype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
16947 goto no_print_pctypes;
16949 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)pctype,
16951 RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST);
16954 goto no_print_pctypes;
16957 printf("List of defined packet classification types:\n");
16958 for (i = 0; i < pctype_num; i++) {
16959 printf(" %2u:", pctype[i].ptype_id);
16960 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
16961 proto_id = pctype[i].protocols[j];
16962 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
16963 for (n = 0; n < proto_num; n++) {
16964 if (proto[n].proto_id == proto_id) {
16965 printf(" %s", proto[n].name);
16978 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)&ptype_num,
16980 RTE_PMD_I40E_PKG_INFO_PTYPE_NUM);
16981 if (ret || !ptype_num)
16982 goto no_print_return;
16984 buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_info);
16985 ptype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
16987 goto no_print_return;
16989 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)ptype,
16991 RTE_PMD_I40E_PKG_INFO_PTYPE_LIST);
16994 goto no_print_return;
16996 printf("List of defined packet types:\n");
16997 for (i = 0; i < ptype_num; i++) {
16998 printf(" %2u:", ptype[i].ptype_id);
16999 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
17000 proto_id = ptype[i].protocols[j];
17001 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
17002 for (n = 0; n < proto_num; n++) {
17003 if (proto[n].proto_id == proto_id) {
17004 printf(" %s", proto[n].name);
17020 if (ret == -ENOTSUP)
17021 printf("Function not supported in PMD driver\n");
17025 cmdline_parse_inst_t cmd_ddp_get_info = {
17026 .f = cmd_ddp_info_parsed,
17028 .help_str = "ddp get info <profile_path>",
17030 (void *)&cmd_ddp_info_ddp,
17031 (void *)&cmd_ddp_info_get,
17032 (void *)&cmd_ddp_info_info,
17033 (void *)&cmd_ddp_info_filepath,
17038 /* Get dynamic device personalization profile info list*/
17039 #define PROFILE_INFO_SIZE 48
17040 #define MAX_PROFILE_NUM 16
17042 struct cmd_ddp_get_list_result {
17043 cmdline_fixed_string_t ddp;
17044 cmdline_fixed_string_t get;
17045 cmdline_fixed_string_t list;
17049 cmdline_parse_token_string_t cmd_ddp_get_list_ddp =
17050 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp");
17051 cmdline_parse_token_string_t cmd_ddp_get_list_get =
17052 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get");
17053 cmdline_parse_token_string_t cmd_ddp_get_list_list =
17054 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list");
17055 cmdline_parse_token_num_t cmd_ddp_get_list_port_id =
17056 TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id, UINT16);
17059 cmd_ddp_get_list_parsed(
17060 __rte_unused void *parsed_result,
17061 __rte_unused struct cmdline *cl,
17062 __rte_unused void *data)
17064 #ifdef RTE_NET_I40E
17065 struct cmd_ddp_get_list_result *res = parsed_result;
17066 struct rte_pmd_i40e_profile_list *p_list;
17067 struct rte_pmd_i40e_profile_info *p_info;
17072 int ret = -ENOTSUP;
17074 #ifdef RTE_NET_I40E
17075 size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4;
17076 p_list = (struct rte_pmd_i40e_profile_list *)malloc(size);
17078 printf("%s: Failed to malloc buffer\n", __func__);
17082 if (ret == -ENOTSUP)
17083 ret = rte_pmd_i40e_get_ddp_list(res->port_id,
17084 (uint8_t *)p_list, size);
17087 p_num = p_list->p_count;
17088 printf("Profile number is: %d\n\n", p_num);
17090 for (i = 0; i < p_num; i++) {
17091 p_info = &p_list->p_info[i];
17092 printf("Profile %d:\n", i);
17093 printf("Track id: 0x%x\n", p_info->track_id);
17094 printf("Version: %d.%d.%d.%d\n",
17095 p_info->version.major,
17096 p_info->version.minor,
17097 p_info->version.update,
17098 p_info->version.draft);
17099 printf("Profile name: %s\n\n", p_info->name);
17107 printf("Failed to get ddp list\n");
17110 cmdline_parse_inst_t cmd_ddp_get_list = {
17111 .f = cmd_ddp_get_list_parsed,
17113 .help_str = "ddp get list <port_id>",
17115 (void *)&cmd_ddp_get_list_ddp,
17116 (void *)&cmd_ddp_get_list_get,
17117 (void *)&cmd_ddp_get_list_list,
17118 (void *)&cmd_ddp_get_list_port_id,
17123 /* Configure input set */
17124 struct cmd_cfg_input_set_result {
17125 cmdline_fixed_string_t port;
17126 cmdline_fixed_string_t cfg;
17128 cmdline_fixed_string_t pctype;
17130 cmdline_fixed_string_t inset_type;
17131 cmdline_fixed_string_t opt;
17132 cmdline_fixed_string_t field;
17137 cmd_cfg_input_set_parsed(
17138 __rte_unused void *parsed_result,
17139 __rte_unused struct cmdline *cl,
17140 __rte_unused void *data)
17142 #ifdef RTE_NET_I40E
17143 struct cmd_cfg_input_set_result *res = parsed_result;
17144 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
17145 struct rte_pmd_i40e_inset inset;
17147 int ret = -ENOTSUP;
17149 if (!all_ports_stopped()) {
17150 printf("Please stop all ports first\n");
17154 #ifdef RTE_NET_I40E
17155 if (!strcmp(res->inset_type, "hash_inset"))
17156 inset_type = INSET_HASH;
17157 else if (!strcmp(res->inset_type, "fdir_inset"))
17158 inset_type = INSET_FDIR;
17159 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
17160 inset_type = INSET_FDIR_FLX;
17161 ret = rte_pmd_i40e_inset_get(res->port_id, res->pctype_id,
17162 &inset, inset_type);
17164 printf("Failed to get input set.\n");
17168 if (!strcmp(res->opt, "get")) {
17169 ret = rte_pmd_i40e_inset_field_get(inset.inset,
17172 printf("Field index %d is enabled.\n", res->field_idx);
17174 printf("Field index %d is disabled.\n", res->field_idx);
17176 } else if (!strcmp(res->opt, "set"))
17177 ret = rte_pmd_i40e_inset_field_set(&inset.inset,
17179 else if (!strcmp(res->opt, "clear"))
17180 ret = rte_pmd_i40e_inset_field_clear(&inset.inset,
17183 printf("Failed to configure input set field.\n");
17187 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
17188 &inset, inset_type);
17190 printf("Failed to set input set.\n");
17195 if (ret == -ENOTSUP)
17196 printf("Function not supported\n");
17199 cmdline_parse_token_string_t cmd_cfg_input_set_port =
17200 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
17202 cmdline_parse_token_string_t cmd_cfg_input_set_cfg =
17203 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
17205 cmdline_parse_token_num_t cmd_cfg_input_set_port_id =
17206 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
17208 cmdline_parse_token_string_t cmd_cfg_input_set_pctype =
17209 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
17211 cmdline_parse_token_num_t cmd_cfg_input_set_pctype_id =
17212 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
17214 cmdline_parse_token_string_t cmd_cfg_input_set_inset_type =
17215 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
17217 "hash_inset#fdir_inset#fdir_flx_inset");
17218 cmdline_parse_token_string_t cmd_cfg_input_set_opt =
17219 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
17220 opt, "get#set#clear");
17221 cmdline_parse_token_string_t cmd_cfg_input_set_field =
17222 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
17224 cmdline_parse_token_num_t cmd_cfg_input_set_field_idx =
17225 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
17228 cmdline_parse_inst_t cmd_cfg_input_set = {
17229 .f = cmd_cfg_input_set_parsed,
17231 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
17232 "fdir_inset|fdir_flx_inset get|set|clear field <field_idx>",
17234 (void *)&cmd_cfg_input_set_port,
17235 (void *)&cmd_cfg_input_set_cfg,
17236 (void *)&cmd_cfg_input_set_port_id,
17237 (void *)&cmd_cfg_input_set_pctype,
17238 (void *)&cmd_cfg_input_set_pctype_id,
17239 (void *)&cmd_cfg_input_set_inset_type,
17240 (void *)&cmd_cfg_input_set_opt,
17241 (void *)&cmd_cfg_input_set_field,
17242 (void *)&cmd_cfg_input_set_field_idx,
17247 /* Clear input set */
17248 struct cmd_clear_input_set_result {
17249 cmdline_fixed_string_t port;
17250 cmdline_fixed_string_t cfg;
17252 cmdline_fixed_string_t pctype;
17254 cmdline_fixed_string_t inset_type;
17255 cmdline_fixed_string_t clear;
17256 cmdline_fixed_string_t all;
17260 cmd_clear_input_set_parsed(
17261 __rte_unused void *parsed_result,
17262 __rte_unused struct cmdline *cl,
17263 __rte_unused void *data)
17265 #ifdef RTE_NET_I40E
17266 struct cmd_clear_input_set_result *res = parsed_result;
17267 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
17268 struct rte_pmd_i40e_inset inset;
17270 int ret = -ENOTSUP;
17272 if (!all_ports_stopped()) {
17273 printf("Please stop all ports first\n");
17277 #ifdef RTE_NET_I40E
17278 if (!strcmp(res->inset_type, "hash_inset"))
17279 inset_type = INSET_HASH;
17280 else if (!strcmp(res->inset_type, "fdir_inset"))
17281 inset_type = INSET_FDIR;
17282 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
17283 inset_type = INSET_FDIR_FLX;
17285 memset(&inset, 0, sizeof(inset));
17287 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
17288 &inset, inset_type);
17290 printf("Failed to clear input set.\n");
17296 if (ret == -ENOTSUP)
17297 printf("Function not supported\n");
17300 cmdline_parse_token_string_t cmd_clear_input_set_port =
17301 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17303 cmdline_parse_token_string_t cmd_clear_input_set_cfg =
17304 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17306 cmdline_parse_token_num_t cmd_clear_input_set_port_id =
17307 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
17309 cmdline_parse_token_string_t cmd_clear_input_set_pctype =
17310 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17312 cmdline_parse_token_num_t cmd_clear_input_set_pctype_id =
17313 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
17315 cmdline_parse_token_string_t cmd_clear_input_set_inset_type =
17316 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17318 "hash_inset#fdir_inset#fdir_flx_inset");
17319 cmdline_parse_token_string_t cmd_clear_input_set_clear =
17320 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17322 cmdline_parse_token_string_t cmd_clear_input_set_all =
17323 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17326 cmdline_parse_inst_t cmd_clear_input_set = {
17327 .f = cmd_clear_input_set_parsed,
17329 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
17330 "fdir_inset|fdir_flx_inset clear all",
17332 (void *)&cmd_clear_input_set_port,
17333 (void *)&cmd_clear_input_set_cfg,
17334 (void *)&cmd_clear_input_set_port_id,
17335 (void *)&cmd_clear_input_set_pctype,
17336 (void *)&cmd_clear_input_set_pctype_id,
17337 (void *)&cmd_clear_input_set_inset_type,
17338 (void *)&cmd_clear_input_set_clear,
17339 (void *)&cmd_clear_input_set_all,
17344 /* show vf stats */
17346 /* Common result structure for show vf stats */
17347 struct cmd_show_vf_stats_result {
17348 cmdline_fixed_string_t show;
17349 cmdline_fixed_string_t vf;
17350 cmdline_fixed_string_t stats;
17355 /* Common CLI fields show vf stats*/
17356 cmdline_parse_token_string_t cmd_show_vf_stats_show =
17357 TOKEN_STRING_INITIALIZER
17358 (struct cmd_show_vf_stats_result,
17360 cmdline_parse_token_string_t cmd_show_vf_stats_vf =
17361 TOKEN_STRING_INITIALIZER
17362 (struct cmd_show_vf_stats_result,
17364 cmdline_parse_token_string_t cmd_show_vf_stats_stats =
17365 TOKEN_STRING_INITIALIZER
17366 (struct cmd_show_vf_stats_result,
17368 cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
17369 TOKEN_NUM_INITIALIZER
17370 (struct cmd_show_vf_stats_result,
17372 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
17373 TOKEN_NUM_INITIALIZER
17374 (struct cmd_show_vf_stats_result,
17378 cmd_show_vf_stats_parsed(
17379 void *parsed_result,
17380 __rte_unused struct cmdline *cl,
17381 __rte_unused void *data)
17383 struct cmd_show_vf_stats_result *res = parsed_result;
17384 struct rte_eth_stats stats;
17385 int ret = -ENOTSUP;
17386 static const char *nic_stats_border = "########################";
17388 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17391 memset(&stats, 0, sizeof(stats));
17393 #ifdef RTE_NET_I40E
17394 if (ret == -ENOTSUP)
17395 ret = rte_pmd_i40e_get_vf_stats(res->port_id,
17399 #ifdef RTE_NET_BNXT
17400 if (ret == -ENOTSUP)
17401 ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
17410 printf("invalid vf_id %d\n", res->vf_id);
17413 printf("invalid port_id %d\n", res->port_id);
17416 printf("function not implemented\n");
17419 printf("programming error: (%s)\n", strerror(-ret));
17422 printf("\n %s NIC statistics for port %-2d vf %-2d %s\n",
17423 nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
17425 printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: "
17427 stats.ipackets, stats.imissed, stats.ibytes);
17428 printf(" RX-errors: %-"PRIu64"\n", stats.ierrors);
17429 printf(" RX-nombuf: %-10"PRIu64"\n",
17431 printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: "
17433 stats.opackets, stats.oerrors, stats.obytes);
17435 printf(" %s############################%s\n",
17436 nic_stats_border, nic_stats_border);
17439 cmdline_parse_inst_t cmd_show_vf_stats = {
17440 .f = cmd_show_vf_stats_parsed,
17442 .help_str = "show vf stats <port_id> <vf_id>",
17444 (void *)&cmd_show_vf_stats_show,
17445 (void *)&cmd_show_vf_stats_vf,
17446 (void *)&cmd_show_vf_stats_stats,
17447 (void *)&cmd_show_vf_stats_port_id,
17448 (void *)&cmd_show_vf_stats_vf_id,
17453 /* clear vf stats */
17455 /* Common result structure for clear vf stats */
17456 struct cmd_clear_vf_stats_result {
17457 cmdline_fixed_string_t clear;
17458 cmdline_fixed_string_t vf;
17459 cmdline_fixed_string_t stats;
17464 /* Common CLI fields clear vf stats*/
17465 cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
17466 TOKEN_STRING_INITIALIZER
17467 (struct cmd_clear_vf_stats_result,
17469 cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
17470 TOKEN_STRING_INITIALIZER
17471 (struct cmd_clear_vf_stats_result,
17473 cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
17474 TOKEN_STRING_INITIALIZER
17475 (struct cmd_clear_vf_stats_result,
17477 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
17478 TOKEN_NUM_INITIALIZER
17479 (struct cmd_clear_vf_stats_result,
17481 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
17482 TOKEN_NUM_INITIALIZER
17483 (struct cmd_clear_vf_stats_result,
17487 cmd_clear_vf_stats_parsed(
17488 void *parsed_result,
17489 __rte_unused struct cmdline *cl,
17490 __rte_unused void *data)
17492 struct cmd_clear_vf_stats_result *res = parsed_result;
17493 int ret = -ENOTSUP;
17495 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17498 #ifdef RTE_NET_I40E
17499 if (ret == -ENOTSUP)
17500 ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
17503 #ifdef RTE_NET_BNXT
17504 if (ret == -ENOTSUP)
17505 ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
17513 printf("invalid vf_id %d\n", res->vf_id);
17516 printf("invalid port_id %d\n", res->port_id);
17519 printf("function not implemented\n");
17522 printf("programming error: (%s)\n", strerror(-ret));
17526 cmdline_parse_inst_t cmd_clear_vf_stats = {
17527 .f = cmd_clear_vf_stats_parsed,
17529 .help_str = "clear vf stats <port_id> <vf_id>",
17531 (void *)&cmd_clear_vf_stats_clear,
17532 (void *)&cmd_clear_vf_stats_vf,
17533 (void *)&cmd_clear_vf_stats_stats,
17534 (void *)&cmd_clear_vf_stats_port_id,
17535 (void *)&cmd_clear_vf_stats_vf_id,
17540 /* port config pctype mapping reset */
17542 /* Common result structure for port config pctype mapping reset */
17543 struct cmd_pctype_mapping_reset_result {
17544 cmdline_fixed_string_t port;
17545 cmdline_fixed_string_t config;
17547 cmdline_fixed_string_t pctype;
17548 cmdline_fixed_string_t mapping;
17549 cmdline_fixed_string_t reset;
17552 /* Common CLI fields for port config pctype mapping reset*/
17553 cmdline_parse_token_string_t cmd_pctype_mapping_reset_port =
17554 TOKEN_STRING_INITIALIZER
17555 (struct cmd_pctype_mapping_reset_result,
17557 cmdline_parse_token_string_t cmd_pctype_mapping_reset_config =
17558 TOKEN_STRING_INITIALIZER
17559 (struct cmd_pctype_mapping_reset_result,
17561 cmdline_parse_token_num_t cmd_pctype_mapping_reset_port_id =
17562 TOKEN_NUM_INITIALIZER
17563 (struct cmd_pctype_mapping_reset_result,
17565 cmdline_parse_token_string_t cmd_pctype_mapping_reset_pctype =
17566 TOKEN_STRING_INITIALIZER
17567 (struct cmd_pctype_mapping_reset_result,
17569 cmdline_parse_token_string_t cmd_pctype_mapping_reset_mapping =
17570 TOKEN_STRING_INITIALIZER
17571 (struct cmd_pctype_mapping_reset_result,
17572 mapping, "mapping");
17573 cmdline_parse_token_string_t cmd_pctype_mapping_reset_reset =
17574 TOKEN_STRING_INITIALIZER
17575 (struct cmd_pctype_mapping_reset_result,
17579 cmd_pctype_mapping_reset_parsed(
17580 void *parsed_result,
17581 __rte_unused struct cmdline *cl,
17582 __rte_unused void *data)
17584 struct cmd_pctype_mapping_reset_result *res = parsed_result;
17585 int ret = -ENOTSUP;
17587 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17590 #ifdef RTE_NET_I40E
17591 ret = rte_pmd_i40e_flow_type_mapping_reset(res->port_id);
17598 printf("invalid port_id %d\n", res->port_id);
17601 printf("function not implemented\n");
17604 printf("programming error: (%s)\n", strerror(-ret));
17608 cmdline_parse_inst_t cmd_pctype_mapping_reset = {
17609 .f = cmd_pctype_mapping_reset_parsed,
17611 .help_str = "port config <port_id> pctype mapping reset",
17613 (void *)&cmd_pctype_mapping_reset_port,
17614 (void *)&cmd_pctype_mapping_reset_config,
17615 (void *)&cmd_pctype_mapping_reset_port_id,
17616 (void *)&cmd_pctype_mapping_reset_pctype,
17617 (void *)&cmd_pctype_mapping_reset_mapping,
17618 (void *)&cmd_pctype_mapping_reset_reset,
17623 /* show port pctype mapping */
17625 /* Common result structure for show port pctype mapping */
17626 struct cmd_pctype_mapping_get_result {
17627 cmdline_fixed_string_t show;
17628 cmdline_fixed_string_t port;
17630 cmdline_fixed_string_t pctype;
17631 cmdline_fixed_string_t mapping;
17634 /* Common CLI fields for pctype mapping get */
17635 cmdline_parse_token_string_t cmd_pctype_mapping_get_show =
17636 TOKEN_STRING_INITIALIZER
17637 (struct cmd_pctype_mapping_get_result,
17639 cmdline_parse_token_string_t cmd_pctype_mapping_get_port =
17640 TOKEN_STRING_INITIALIZER
17641 (struct cmd_pctype_mapping_get_result,
17643 cmdline_parse_token_num_t cmd_pctype_mapping_get_port_id =
17644 TOKEN_NUM_INITIALIZER
17645 (struct cmd_pctype_mapping_get_result,
17647 cmdline_parse_token_string_t cmd_pctype_mapping_get_pctype =
17648 TOKEN_STRING_INITIALIZER
17649 (struct cmd_pctype_mapping_get_result,
17651 cmdline_parse_token_string_t cmd_pctype_mapping_get_mapping =
17652 TOKEN_STRING_INITIALIZER
17653 (struct cmd_pctype_mapping_get_result,
17654 mapping, "mapping");
17657 cmd_pctype_mapping_get_parsed(
17658 void *parsed_result,
17659 __rte_unused struct cmdline *cl,
17660 __rte_unused void *data)
17662 struct cmd_pctype_mapping_get_result *res = parsed_result;
17663 int ret = -ENOTSUP;
17664 #ifdef RTE_NET_I40E
17665 struct rte_pmd_i40e_flow_type_mapping
17666 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
17667 int i, j, first_pctype;
17670 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17673 #ifdef RTE_NET_I40E
17674 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, mapping);
17681 printf("invalid port_id %d\n", res->port_id);
17684 printf("function not implemented\n");
17687 printf("programming error: (%s)\n", strerror(-ret));
17691 #ifdef RTE_NET_I40E
17692 for (i = 0; i < RTE_PMD_I40E_FLOW_TYPE_MAX; i++) {
17693 if (mapping[i].pctype != 0ULL) {
17696 printf("pctype: ");
17697 for (j = 0; j < RTE_PMD_I40E_PCTYPE_MAX; j++) {
17698 if (mapping[i].pctype & (1ULL << j)) {
17699 printf(first_pctype ?
17700 "%02d" : ",%02d", j);
17704 printf(" -> flowtype: %02d\n", mapping[i].flow_type);
17710 cmdline_parse_inst_t cmd_pctype_mapping_get = {
17711 .f = cmd_pctype_mapping_get_parsed,
17713 .help_str = "show port <port_id> pctype mapping",
17715 (void *)&cmd_pctype_mapping_get_show,
17716 (void *)&cmd_pctype_mapping_get_port,
17717 (void *)&cmd_pctype_mapping_get_port_id,
17718 (void *)&cmd_pctype_mapping_get_pctype,
17719 (void *)&cmd_pctype_mapping_get_mapping,
17724 /* port config pctype mapping update */
17726 /* Common result structure for port config pctype mapping update */
17727 struct cmd_pctype_mapping_update_result {
17728 cmdline_fixed_string_t port;
17729 cmdline_fixed_string_t config;
17731 cmdline_fixed_string_t pctype;
17732 cmdline_fixed_string_t mapping;
17733 cmdline_fixed_string_t update;
17734 cmdline_fixed_string_t pctype_list;
17735 uint16_t flow_type;
17738 /* Common CLI fields for pctype mapping update*/
17739 cmdline_parse_token_string_t cmd_pctype_mapping_update_port =
17740 TOKEN_STRING_INITIALIZER
17741 (struct cmd_pctype_mapping_update_result,
17743 cmdline_parse_token_string_t cmd_pctype_mapping_update_config =
17744 TOKEN_STRING_INITIALIZER
17745 (struct cmd_pctype_mapping_update_result,
17747 cmdline_parse_token_num_t cmd_pctype_mapping_update_port_id =
17748 TOKEN_NUM_INITIALIZER
17749 (struct cmd_pctype_mapping_update_result,
17751 cmdline_parse_token_string_t cmd_pctype_mapping_update_pctype =
17752 TOKEN_STRING_INITIALIZER
17753 (struct cmd_pctype_mapping_update_result,
17755 cmdline_parse_token_string_t cmd_pctype_mapping_update_mapping =
17756 TOKEN_STRING_INITIALIZER
17757 (struct cmd_pctype_mapping_update_result,
17758 mapping, "mapping");
17759 cmdline_parse_token_string_t cmd_pctype_mapping_update_update =
17760 TOKEN_STRING_INITIALIZER
17761 (struct cmd_pctype_mapping_update_result,
17763 cmdline_parse_token_string_t cmd_pctype_mapping_update_pc_type =
17764 TOKEN_STRING_INITIALIZER
17765 (struct cmd_pctype_mapping_update_result,
17766 pctype_list, NULL);
17767 cmdline_parse_token_num_t cmd_pctype_mapping_update_flow_type =
17768 TOKEN_NUM_INITIALIZER
17769 (struct cmd_pctype_mapping_update_result,
17770 flow_type, UINT16);
17773 cmd_pctype_mapping_update_parsed(
17774 void *parsed_result,
17775 __rte_unused struct cmdline *cl,
17776 __rte_unused void *data)
17778 struct cmd_pctype_mapping_update_result *res = parsed_result;
17779 int ret = -ENOTSUP;
17780 #ifdef RTE_NET_I40E
17781 struct rte_pmd_i40e_flow_type_mapping mapping;
17783 unsigned int nb_item;
17784 unsigned int pctype_list[RTE_PMD_I40E_PCTYPE_MAX];
17787 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17790 #ifdef RTE_NET_I40E
17791 nb_item = parse_item_list(res->pctype_list, "pctypes",
17792 RTE_PMD_I40E_PCTYPE_MAX, pctype_list, 1);
17793 mapping.flow_type = res->flow_type;
17794 for (i = 0, mapping.pctype = 0ULL; i < nb_item; i++)
17795 mapping.pctype |= (1ULL << pctype_list[i]);
17796 ret = rte_pmd_i40e_flow_type_mapping_update(res->port_id,
17806 printf("invalid pctype or flow type\n");
17809 printf("invalid port_id %d\n", res->port_id);
17812 printf("function not implemented\n");
17815 printf("programming error: (%s)\n", strerror(-ret));
17819 cmdline_parse_inst_t cmd_pctype_mapping_update = {
17820 .f = cmd_pctype_mapping_update_parsed,
17822 .help_str = "port config <port_id> pctype mapping update"
17823 " <pctype_id_0,[pctype_id_1]*> <flowtype_id>",
17825 (void *)&cmd_pctype_mapping_update_port,
17826 (void *)&cmd_pctype_mapping_update_config,
17827 (void *)&cmd_pctype_mapping_update_port_id,
17828 (void *)&cmd_pctype_mapping_update_pctype,
17829 (void *)&cmd_pctype_mapping_update_mapping,
17830 (void *)&cmd_pctype_mapping_update_update,
17831 (void *)&cmd_pctype_mapping_update_pc_type,
17832 (void *)&cmd_pctype_mapping_update_flow_type,
17837 /* ptype mapping get */
17839 /* Common result structure for ptype mapping get */
17840 struct cmd_ptype_mapping_get_result {
17841 cmdline_fixed_string_t ptype;
17842 cmdline_fixed_string_t mapping;
17843 cmdline_fixed_string_t get;
17845 uint8_t valid_only;
17848 /* Common CLI fields for ptype mapping get */
17849 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype =
17850 TOKEN_STRING_INITIALIZER
17851 (struct cmd_ptype_mapping_get_result,
17853 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping =
17854 TOKEN_STRING_INITIALIZER
17855 (struct cmd_ptype_mapping_get_result,
17856 mapping, "mapping");
17857 cmdline_parse_token_string_t cmd_ptype_mapping_get_get =
17858 TOKEN_STRING_INITIALIZER
17859 (struct cmd_ptype_mapping_get_result,
17861 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id =
17862 TOKEN_NUM_INITIALIZER
17863 (struct cmd_ptype_mapping_get_result,
17865 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only =
17866 TOKEN_NUM_INITIALIZER
17867 (struct cmd_ptype_mapping_get_result,
17868 valid_only, UINT8);
17871 cmd_ptype_mapping_get_parsed(
17872 void *parsed_result,
17873 __rte_unused struct cmdline *cl,
17874 __rte_unused void *data)
17876 struct cmd_ptype_mapping_get_result *res = parsed_result;
17877 int ret = -ENOTSUP;
17878 #ifdef RTE_NET_I40E
17879 int max_ptype_num = 256;
17880 struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num];
17885 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17888 #ifdef RTE_NET_I40E
17889 ret = rte_pmd_i40e_ptype_mapping_get(res->port_id,
17900 printf("invalid port_id %d\n", res->port_id);
17903 printf("function not implemented\n");
17906 printf("programming error: (%s)\n", strerror(-ret));
17909 #ifdef RTE_NET_I40E
17911 for (i = 0; i < count; i++)
17912 printf("%3d\t0x%08x\n",
17913 mapping[i].hw_ptype, mapping[i].sw_ptype);
17918 cmdline_parse_inst_t cmd_ptype_mapping_get = {
17919 .f = cmd_ptype_mapping_get_parsed,
17921 .help_str = "ptype mapping get <port_id> <valid_only>",
17923 (void *)&cmd_ptype_mapping_get_ptype,
17924 (void *)&cmd_ptype_mapping_get_mapping,
17925 (void *)&cmd_ptype_mapping_get_get,
17926 (void *)&cmd_ptype_mapping_get_port_id,
17927 (void *)&cmd_ptype_mapping_get_valid_only,
17932 /* ptype mapping replace */
17934 /* Common result structure for ptype mapping replace */
17935 struct cmd_ptype_mapping_replace_result {
17936 cmdline_fixed_string_t ptype;
17937 cmdline_fixed_string_t mapping;
17938 cmdline_fixed_string_t replace;
17945 /* Common CLI fields for ptype mapping replace */
17946 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype =
17947 TOKEN_STRING_INITIALIZER
17948 (struct cmd_ptype_mapping_replace_result,
17950 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping =
17951 TOKEN_STRING_INITIALIZER
17952 (struct cmd_ptype_mapping_replace_result,
17953 mapping, "mapping");
17954 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace =
17955 TOKEN_STRING_INITIALIZER
17956 (struct cmd_ptype_mapping_replace_result,
17957 replace, "replace");
17958 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id =
17959 TOKEN_NUM_INITIALIZER
17960 (struct cmd_ptype_mapping_replace_result,
17962 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target =
17963 TOKEN_NUM_INITIALIZER
17964 (struct cmd_ptype_mapping_replace_result,
17966 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask =
17967 TOKEN_NUM_INITIALIZER
17968 (struct cmd_ptype_mapping_replace_result,
17970 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type =
17971 TOKEN_NUM_INITIALIZER
17972 (struct cmd_ptype_mapping_replace_result,
17976 cmd_ptype_mapping_replace_parsed(
17977 void *parsed_result,
17978 __rte_unused struct cmdline *cl,
17979 __rte_unused void *data)
17981 struct cmd_ptype_mapping_replace_result *res = parsed_result;
17982 int ret = -ENOTSUP;
17984 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17987 #ifdef RTE_NET_I40E
17988 ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id,
17998 printf("invalid ptype 0x%8x or 0x%8x\n",
17999 res->target, res->pkt_type);
18002 printf("invalid port_id %d\n", res->port_id);
18005 printf("function not implemented\n");
18008 printf("programming error: (%s)\n", strerror(-ret));
18012 cmdline_parse_inst_t cmd_ptype_mapping_replace = {
18013 .f = cmd_ptype_mapping_replace_parsed,
18016 "ptype mapping replace <port_id> <target> <mask> <pkt_type>",
18018 (void *)&cmd_ptype_mapping_replace_ptype,
18019 (void *)&cmd_ptype_mapping_replace_mapping,
18020 (void *)&cmd_ptype_mapping_replace_replace,
18021 (void *)&cmd_ptype_mapping_replace_port_id,
18022 (void *)&cmd_ptype_mapping_replace_target,
18023 (void *)&cmd_ptype_mapping_replace_mask,
18024 (void *)&cmd_ptype_mapping_replace_pkt_type,
18029 /* ptype mapping reset */
18031 /* Common result structure for ptype mapping reset */
18032 struct cmd_ptype_mapping_reset_result {
18033 cmdline_fixed_string_t ptype;
18034 cmdline_fixed_string_t mapping;
18035 cmdline_fixed_string_t reset;
18039 /* Common CLI fields for ptype mapping reset*/
18040 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype =
18041 TOKEN_STRING_INITIALIZER
18042 (struct cmd_ptype_mapping_reset_result,
18044 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping =
18045 TOKEN_STRING_INITIALIZER
18046 (struct cmd_ptype_mapping_reset_result,
18047 mapping, "mapping");
18048 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset =
18049 TOKEN_STRING_INITIALIZER
18050 (struct cmd_ptype_mapping_reset_result,
18052 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id =
18053 TOKEN_NUM_INITIALIZER
18054 (struct cmd_ptype_mapping_reset_result,
18058 cmd_ptype_mapping_reset_parsed(
18059 void *parsed_result,
18060 __rte_unused struct cmdline *cl,
18061 __rte_unused void *data)
18063 struct cmd_ptype_mapping_reset_result *res = parsed_result;
18064 int ret = -ENOTSUP;
18066 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
18069 #ifdef RTE_NET_I40E
18070 ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id);
18077 printf("invalid port_id %d\n", res->port_id);
18080 printf("function not implemented\n");
18083 printf("programming error: (%s)\n", strerror(-ret));
18087 cmdline_parse_inst_t cmd_ptype_mapping_reset = {
18088 .f = cmd_ptype_mapping_reset_parsed,
18090 .help_str = "ptype mapping reset <port_id>",
18092 (void *)&cmd_ptype_mapping_reset_ptype,
18093 (void *)&cmd_ptype_mapping_reset_mapping,
18094 (void *)&cmd_ptype_mapping_reset_reset,
18095 (void *)&cmd_ptype_mapping_reset_port_id,
18100 /* ptype mapping update */
18102 /* Common result structure for ptype mapping update */
18103 struct cmd_ptype_mapping_update_result {
18104 cmdline_fixed_string_t ptype;
18105 cmdline_fixed_string_t mapping;
18106 cmdline_fixed_string_t reset;
18112 /* Common CLI fields for ptype mapping update*/
18113 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype =
18114 TOKEN_STRING_INITIALIZER
18115 (struct cmd_ptype_mapping_update_result,
18117 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping =
18118 TOKEN_STRING_INITIALIZER
18119 (struct cmd_ptype_mapping_update_result,
18120 mapping, "mapping");
18121 cmdline_parse_token_string_t cmd_ptype_mapping_update_update =
18122 TOKEN_STRING_INITIALIZER
18123 (struct cmd_ptype_mapping_update_result,
18125 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id =
18126 TOKEN_NUM_INITIALIZER
18127 (struct cmd_ptype_mapping_update_result,
18129 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype =
18130 TOKEN_NUM_INITIALIZER
18131 (struct cmd_ptype_mapping_update_result,
18133 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype =
18134 TOKEN_NUM_INITIALIZER
18135 (struct cmd_ptype_mapping_update_result,
18139 cmd_ptype_mapping_update_parsed(
18140 void *parsed_result,
18141 __rte_unused struct cmdline *cl,
18142 __rte_unused void *data)
18144 struct cmd_ptype_mapping_update_result *res = parsed_result;
18145 int ret = -ENOTSUP;
18146 #ifdef RTE_NET_I40E
18147 struct rte_pmd_i40e_ptype_mapping mapping;
18149 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
18152 #ifdef RTE_NET_I40E
18153 mapping.hw_ptype = res->hw_ptype;
18154 mapping.sw_ptype = res->sw_ptype;
18155 ret = rte_pmd_i40e_ptype_mapping_update(res->port_id,
18165 printf("invalid ptype 0x%8x\n", res->sw_ptype);
18168 printf("invalid port_id %d\n", res->port_id);
18171 printf("function not implemented\n");
18174 printf("programming error: (%s)\n", strerror(-ret));
18178 cmdline_parse_inst_t cmd_ptype_mapping_update = {
18179 .f = cmd_ptype_mapping_update_parsed,
18181 .help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>",
18183 (void *)&cmd_ptype_mapping_update_ptype,
18184 (void *)&cmd_ptype_mapping_update_mapping,
18185 (void *)&cmd_ptype_mapping_update_update,
18186 (void *)&cmd_ptype_mapping_update_port_id,
18187 (void *)&cmd_ptype_mapping_update_hw_ptype,
18188 (void *)&cmd_ptype_mapping_update_sw_ptype,
18193 /* Common result structure for file commands */
18194 struct cmd_cmdfile_result {
18195 cmdline_fixed_string_t load;
18196 cmdline_fixed_string_t filename;
18199 /* Common CLI fields for file commands */
18200 cmdline_parse_token_string_t cmd_load_cmdfile =
18201 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
18202 cmdline_parse_token_string_t cmd_load_cmdfile_filename =
18203 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
18206 cmd_load_from_file_parsed(
18207 void *parsed_result,
18208 __rte_unused struct cmdline *cl,
18209 __rte_unused void *data)
18211 struct cmd_cmdfile_result *res = parsed_result;
18213 cmdline_read_from_file(res->filename);
18216 cmdline_parse_inst_t cmd_load_from_file = {
18217 .f = cmd_load_from_file_parsed,
18219 .help_str = "load <filename>",
18221 (void *)&cmd_load_cmdfile,
18222 (void *)&cmd_load_cmdfile_filename,
18227 /* Get Rx offloads capabilities */
18228 struct cmd_rx_offload_get_capa_result {
18229 cmdline_fixed_string_t show;
18230 cmdline_fixed_string_t port;
18232 cmdline_fixed_string_t rx_offload;
18233 cmdline_fixed_string_t capabilities;
18236 cmdline_parse_token_string_t cmd_rx_offload_get_capa_show =
18237 TOKEN_STRING_INITIALIZER
18238 (struct cmd_rx_offload_get_capa_result,
18240 cmdline_parse_token_string_t cmd_rx_offload_get_capa_port =
18241 TOKEN_STRING_INITIALIZER
18242 (struct cmd_rx_offload_get_capa_result,
18244 cmdline_parse_token_num_t cmd_rx_offload_get_capa_port_id =
18245 TOKEN_NUM_INITIALIZER
18246 (struct cmd_rx_offload_get_capa_result,
18248 cmdline_parse_token_string_t cmd_rx_offload_get_capa_rx_offload =
18249 TOKEN_STRING_INITIALIZER
18250 (struct cmd_rx_offload_get_capa_result,
18251 rx_offload, "rx_offload");
18252 cmdline_parse_token_string_t cmd_rx_offload_get_capa_capabilities =
18253 TOKEN_STRING_INITIALIZER
18254 (struct cmd_rx_offload_get_capa_result,
18255 capabilities, "capabilities");
18258 print_rx_offloads(uint64_t offloads)
18260 uint64_t single_offload;
18268 begin = __builtin_ctzll(offloads);
18269 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
18271 single_offload = 1ULL << begin;
18272 for (bit = begin; bit < end; bit++) {
18273 if (offloads & single_offload)
18275 rte_eth_dev_rx_offload_name(single_offload));
18276 single_offload <<= 1;
18281 cmd_rx_offload_get_capa_parsed(
18282 void *parsed_result,
18283 __rte_unused struct cmdline *cl,
18284 __rte_unused void *data)
18286 struct cmd_rx_offload_get_capa_result *res = parsed_result;
18287 struct rte_eth_dev_info dev_info;
18288 portid_t port_id = res->port_id;
18289 uint64_t queue_offloads;
18290 uint64_t port_offloads;
18293 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18297 queue_offloads = dev_info.rx_queue_offload_capa;
18298 port_offloads = dev_info.rx_offload_capa ^ queue_offloads;
18300 printf("Rx Offloading Capabilities of port %d :\n", port_id);
18301 printf(" Per Queue :");
18302 print_rx_offloads(queue_offloads);
18305 printf(" Per Port :");
18306 print_rx_offloads(port_offloads);
18310 cmdline_parse_inst_t cmd_rx_offload_get_capa = {
18311 .f = cmd_rx_offload_get_capa_parsed,
18313 .help_str = "show port <port_id> rx_offload capabilities",
18315 (void *)&cmd_rx_offload_get_capa_show,
18316 (void *)&cmd_rx_offload_get_capa_port,
18317 (void *)&cmd_rx_offload_get_capa_port_id,
18318 (void *)&cmd_rx_offload_get_capa_rx_offload,
18319 (void *)&cmd_rx_offload_get_capa_capabilities,
18324 /* Get Rx offloads configuration */
18325 struct cmd_rx_offload_get_configuration_result {
18326 cmdline_fixed_string_t show;
18327 cmdline_fixed_string_t port;
18329 cmdline_fixed_string_t rx_offload;
18330 cmdline_fixed_string_t configuration;
18333 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_show =
18334 TOKEN_STRING_INITIALIZER
18335 (struct cmd_rx_offload_get_configuration_result,
18337 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_port =
18338 TOKEN_STRING_INITIALIZER
18339 (struct cmd_rx_offload_get_configuration_result,
18341 cmdline_parse_token_num_t cmd_rx_offload_get_configuration_port_id =
18342 TOKEN_NUM_INITIALIZER
18343 (struct cmd_rx_offload_get_configuration_result,
18345 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_rx_offload =
18346 TOKEN_STRING_INITIALIZER
18347 (struct cmd_rx_offload_get_configuration_result,
18348 rx_offload, "rx_offload");
18349 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_configuration =
18350 TOKEN_STRING_INITIALIZER
18351 (struct cmd_rx_offload_get_configuration_result,
18352 configuration, "configuration");
18355 cmd_rx_offload_get_configuration_parsed(
18356 void *parsed_result,
18357 __rte_unused struct cmdline *cl,
18358 __rte_unused void *data)
18360 struct cmd_rx_offload_get_configuration_result *res = parsed_result;
18361 struct rte_eth_dev_info dev_info;
18362 portid_t port_id = res->port_id;
18363 struct rte_port *port = &ports[port_id];
18364 uint64_t port_offloads;
18365 uint64_t queue_offloads;
18366 uint16_t nb_rx_queues;
18370 printf("Rx Offloading Configuration of port %d :\n", port_id);
18372 port_offloads = port->dev_conf.rxmode.offloads;
18374 print_rx_offloads(port_offloads);
18377 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18381 nb_rx_queues = dev_info.nb_rx_queues;
18382 for (q = 0; q < nb_rx_queues; q++) {
18383 queue_offloads = port->rx_conf[q].offloads;
18384 printf(" Queue[%2d] :", q);
18385 print_rx_offloads(queue_offloads);
18391 cmdline_parse_inst_t cmd_rx_offload_get_configuration = {
18392 .f = cmd_rx_offload_get_configuration_parsed,
18394 .help_str = "show port <port_id> rx_offload configuration",
18396 (void *)&cmd_rx_offload_get_configuration_show,
18397 (void *)&cmd_rx_offload_get_configuration_port,
18398 (void *)&cmd_rx_offload_get_configuration_port_id,
18399 (void *)&cmd_rx_offload_get_configuration_rx_offload,
18400 (void *)&cmd_rx_offload_get_configuration_configuration,
18405 /* Enable/Disable a per port offloading */
18406 struct cmd_config_per_port_rx_offload_result {
18407 cmdline_fixed_string_t port;
18408 cmdline_fixed_string_t config;
18410 cmdline_fixed_string_t rx_offload;
18411 cmdline_fixed_string_t offload;
18412 cmdline_fixed_string_t on_off;
18415 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_port =
18416 TOKEN_STRING_INITIALIZER
18417 (struct cmd_config_per_port_rx_offload_result,
18419 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_config =
18420 TOKEN_STRING_INITIALIZER
18421 (struct cmd_config_per_port_rx_offload_result,
18423 cmdline_parse_token_num_t cmd_config_per_port_rx_offload_result_port_id =
18424 TOKEN_NUM_INITIALIZER
18425 (struct cmd_config_per_port_rx_offload_result,
18427 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_rx_offload =
18428 TOKEN_STRING_INITIALIZER
18429 (struct cmd_config_per_port_rx_offload_result,
18430 rx_offload, "rx_offload");
18431 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_offload =
18432 TOKEN_STRING_INITIALIZER
18433 (struct cmd_config_per_port_rx_offload_result,
18434 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
18435 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
18436 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
18437 "scatter#buffer_split#timestamp#security#"
18438 "keep_crc#rss_hash");
18439 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_on_off =
18440 TOKEN_STRING_INITIALIZER
18441 (struct cmd_config_per_port_rx_offload_result,
18445 search_rx_offload(const char *name)
18447 uint64_t single_offload;
18448 const char *single_name;
18452 single_offload = 1;
18453 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
18454 single_name = rte_eth_dev_rx_offload_name(single_offload);
18455 if (!strcasecmp(single_name, name)) {
18459 single_offload <<= 1;
18463 return single_offload;
18469 cmd_config_per_port_rx_offload_parsed(void *parsed_result,
18470 __rte_unused struct cmdline *cl,
18471 __rte_unused void *data)
18473 struct cmd_config_per_port_rx_offload_result *res = parsed_result;
18474 portid_t port_id = res->port_id;
18475 struct rte_eth_dev_info dev_info;
18476 struct rte_port *port = &ports[port_id];
18477 uint64_t single_offload;
18478 uint16_t nb_rx_queues;
18482 if (port->port_status != RTE_PORT_STOPPED) {
18483 printf("Error: Can't config offload when Port %d "
18484 "is not stopped\n", port_id);
18488 single_offload = search_rx_offload(res->offload);
18489 if (single_offload == 0) {
18490 printf("Unknown offload name: %s\n", res->offload);
18494 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18498 nb_rx_queues = dev_info.nb_rx_queues;
18499 if (!strcmp(res->on_off, "on")) {
18500 port->dev_conf.rxmode.offloads |= single_offload;
18501 for (q = 0; q < nb_rx_queues; q++)
18502 port->rx_conf[q].offloads |= single_offload;
18504 port->dev_conf.rxmode.offloads &= ~single_offload;
18505 for (q = 0; q < nb_rx_queues; q++)
18506 port->rx_conf[q].offloads &= ~single_offload;
18509 cmd_reconfig_device_queue(port_id, 1, 1);
18512 cmdline_parse_inst_t cmd_config_per_port_rx_offload = {
18513 .f = cmd_config_per_port_rx_offload_parsed,
18515 .help_str = "port config <port_id> rx_offload vlan_strip|ipv4_cksum|"
18516 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
18517 "macsec_strip|header_split|vlan_filter|vlan_extend|"
18518 "jumbo_frame|scatter|buffer_split|timestamp|security|"
18519 "keep_crc|rss_hash on|off",
18521 (void *)&cmd_config_per_port_rx_offload_result_port,
18522 (void *)&cmd_config_per_port_rx_offload_result_config,
18523 (void *)&cmd_config_per_port_rx_offload_result_port_id,
18524 (void *)&cmd_config_per_port_rx_offload_result_rx_offload,
18525 (void *)&cmd_config_per_port_rx_offload_result_offload,
18526 (void *)&cmd_config_per_port_rx_offload_result_on_off,
18531 /* Enable/Disable a per queue offloading */
18532 struct cmd_config_per_queue_rx_offload_result {
18533 cmdline_fixed_string_t port;
18535 cmdline_fixed_string_t rxq;
18537 cmdline_fixed_string_t rx_offload;
18538 cmdline_fixed_string_t offload;
18539 cmdline_fixed_string_t on_off;
18542 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_port =
18543 TOKEN_STRING_INITIALIZER
18544 (struct cmd_config_per_queue_rx_offload_result,
18546 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_port_id =
18547 TOKEN_NUM_INITIALIZER
18548 (struct cmd_config_per_queue_rx_offload_result,
18550 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxq =
18551 TOKEN_STRING_INITIALIZER
18552 (struct cmd_config_per_queue_rx_offload_result,
18554 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_queue_id =
18555 TOKEN_NUM_INITIALIZER
18556 (struct cmd_config_per_queue_rx_offload_result,
18558 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxoffload =
18559 TOKEN_STRING_INITIALIZER
18560 (struct cmd_config_per_queue_rx_offload_result,
18561 rx_offload, "rx_offload");
18562 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_offload =
18563 TOKEN_STRING_INITIALIZER
18564 (struct cmd_config_per_queue_rx_offload_result,
18565 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
18566 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
18567 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
18568 "scatter#buffer_split#timestamp#security#keep_crc");
18569 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_on_off =
18570 TOKEN_STRING_INITIALIZER
18571 (struct cmd_config_per_queue_rx_offload_result,
18575 cmd_config_per_queue_rx_offload_parsed(void *parsed_result,
18576 __rte_unused struct cmdline *cl,
18577 __rte_unused void *data)
18579 struct cmd_config_per_queue_rx_offload_result *res = parsed_result;
18580 struct rte_eth_dev_info dev_info;
18581 portid_t port_id = res->port_id;
18582 uint16_t queue_id = res->queue_id;
18583 struct rte_port *port = &ports[port_id];
18584 uint64_t single_offload;
18587 if (port->port_status != RTE_PORT_STOPPED) {
18588 printf("Error: Can't config offload when Port %d "
18589 "is not stopped\n", port_id);
18593 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18597 if (queue_id >= dev_info.nb_rx_queues) {
18598 printf("Error: input queue_id should be 0 ... "
18599 "%d\n", dev_info.nb_rx_queues - 1);
18603 single_offload = search_rx_offload(res->offload);
18604 if (single_offload == 0) {
18605 printf("Unknown offload name: %s\n", res->offload);
18609 if (!strcmp(res->on_off, "on"))
18610 port->rx_conf[queue_id].offloads |= single_offload;
18612 port->rx_conf[queue_id].offloads &= ~single_offload;
18614 cmd_reconfig_device_queue(port_id, 1, 1);
18617 cmdline_parse_inst_t cmd_config_per_queue_rx_offload = {
18618 .f = cmd_config_per_queue_rx_offload_parsed,
18620 .help_str = "port <port_id> rxq <queue_id> rx_offload "
18621 "vlan_strip|ipv4_cksum|"
18622 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
18623 "macsec_strip|header_split|vlan_filter|vlan_extend|"
18624 "jumbo_frame|scatter|buffer_split|timestamp|security|"
18627 (void *)&cmd_config_per_queue_rx_offload_result_port,
18628 (void *)&cmd_config_per_queue_rx_offload_result_port_id,
18629 (void *)&cmd_config_per_queue_rx_offload_result_rxq,
18630 (void *)&cmd_config_per_queue_rx_offload_result_queue_id,
18631 (void *)&cmd_config_per_queue_rx_offload_result_rxoffload,
18632 (void *)&cmd_config_per_queue_rx_offload_result_offload,
18633 (void *)&cmd_config_per_queue_rx_offload_result_on_off,
18638 /* Get Tx offloads capabilities */
18639 struct cmd_tx_offload_get_capa_result {
18640 cmdline_fixed_string_t show;
18641 cmdline_fixed_string_t port;
18643 cmdline_fixed_string_t tx_offload;
18644 cmdline_fixed_string_t capabilities;
18647 cmdline_parse_token_string_t cmd_tx_offload_get_capa_show =
18648 TOKEN_STRING_INITIALIZER
18649 (struct cmd_tx_offload_get_capa_result,
18651 cmdline_parse_token_string_t cmd_tx_offload_get_capa_port =
18652 TOKEN_STRING_INITIALIZER
18653 (struct cmd_tx_offload_get_capa_result,
18655 cmdline_parse_token_num_t cmd_tx_offload_get_capa_port_id =
18656 TOKEN_NUM_INITIALIZER
18657 (struct cmd_tx_offload_get_capa_result,
18659 cmdline_parse_token_string_t cmd_tx_offload_get_capa_tx_offload =
18660 TOKEN_STRING_INITIALIZER
18661 (struct cmd_tx_offload_get_capa_result,
18662 tx_offload, "tx_offload");
18663 cmdline_parse_token_string_t cmd_tx_offload_get_capa_capabilities =
18664 TOKEN_STRING_INITIALIZER
18665 (struct cmd_tx_offload_get_capa_result,
18666 capabilities, "capabilities");
18669 print_tx_offloads(uint64_t offloads)
18671 uint64_t single_offload;
18679 begin = __builtin_ctzll(offloads);
18680 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
18682 single_offload = 1ULL << begin;
18683 for (bit = begin; bit < end; bit++) {
18684 if (offloads & single_offload)
18686 rte_eth_dev_tx_offload_name(single_offload));
18687 single_offload <<= 1;
18692 cmd_tx_offload_get_capa_parsed(
18693 void *parsed_result,
18694 __rte_unused struct cmdline *cl,
18695 __rte_unused void *data)
18697 struct cmd_tx_offload_get_capa_result *res = parsed_result;
18698 struct rte_eth_dev_info dev_info;
18699 portid_t port_id = res->port_id;
18700 uint64_t queue_offloads;
18701 uint64_t port_offloads;
18704 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18708 queue_offloads = dev_info.tx_queue_offload_capa;
18709 port_offloads = dev_info.tx_offload_capa ^ queue_offloads;
18711 printf("Tx Offloading Capabilities of port %d :\n", port_id);
18712 printf(" Per Queue :");
18713 print_tx_offloads(queue_offloads);
18716 printf(" Per Port :");
18717 print_tx_offloads(port_offloads);
18721 cmdline_parse_inst_t cmd_tx_offload_get_capa = {
18722 .f = cmd_tx_offload_get_capa_parsed,
18724 .help_str = "show port <port_id> tx_offload capabilities",
18726 (void *)&cmd_tx_offload_get_capa_show,
18727 (void *)&cmd_tx_offload_get_capa_port,
18728 (void *)&cmd_tx_offload_get_capa_port_id,
18729 (void *)&cmd_tx_offload_get_capa_tx_offload,
18730 (void *)&cmd_tx_offload_get_capa_capabilities,
18735 /* Get Tx offloads configuration */
18736 struct cmd_tx_offload_get_configuration_result {
18737 cmdline_fixed_string_t show;
18738 cmdline_fixed_string_t port;
18740 cmdline_fixed_string_t tx_offload;
18741 cmdline_fixed_string_t configuration;
18744 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_show =
18745 TOKEN_STRING_INITIALIZER
18746 (struct cmd_tx_offload_get_configuration_result,
18748 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_port =
18749 TOKEN_STRING_INITIALIZER
18750 (struct cmd_tx_offload_get_configuration_result,
18752 cmdline_parse_token_num_t cmd_tx_offload_get_configuration_port_id =
18753 TOKEN_NUM_INITIALIZER
18754 (struct cmd_tx_offload_get_configuration_result,
18756 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_tx_offload =
18757 TOKEN_STRING_INITIALIZER
18758 (struct cmd_tx_offload_get_configuration_result,
18759 tx_offload, "tx_offload");
18760 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_configuration =
18761 TOKEN_STRING_INITIALIZER
18762 (struct cmd_tx_offload_get_configuration_result,
18763 configuration, "configuration");
18766 cmd_tx_offload_get_configuration_parsed(
18767 void *parsed_result,
18768 __rte_unused struct cmdline *cl,
18769 __rte_unused void *data)
18771 struct cmd_tx_offload_get_configuration_result *res = parsed_result;
18772 struct rte_eth_dev_info dev_info;
18773 portid_t port_id = res->port_id;
18774 struct rte_port *port = &ports[port_id];
18775 uint64_t port_offloads;
18776 uint64_t queue_offloads;
18777 uint16_t nb_tx_queues;
18781 printf("Tx Offloading Configuration of port %d :\n", port_id);
18783 port_offloads = port->dev_conf.txmode.offloads;
18785 print_tx_offloads(port_offloads);
18788 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18792 nb_tx_queues = dev_info.nb_tx_queues;
18793 for (q = 0; q < nb_tx_queues; q++) {
18794 queue_offloads = port->tx_conf[q].offloads;
18795 printf(" Queue[%2d] :", q);
18796 print_tx_offloads(queue_offloads);
18802 cmdline_parse_inst_t cmd_tx_offload_get_configuration = {
18803 .f = cmd_tx_offload_get_configuration_parsed,
18805 .help_str = "show port <port_id> tx_offload configuration",
18807 (void *)&cmd_tx_offload_get_configuration_show,
18808 (void *)&cmd_tx_offload_get_configuration_port,
18809 (void *)&cmd_tx_offload_get_configuration_port_id,
18810 (void *)&cmd_tx_offload_get_configuration_tx_offload,
18811 (void *)&cmd_tx_offload_get_configuration_configuration,
18816 /* Enable/Disable a per port offloading */
18817 struct cmd_config_per_port_tx_offload_result {
18818 cmdline_fixed_string_t port;
18819 cmdline_fixed_string_t config;
18821 cmdline_fixed_string_t tx_offload;
18822 cmdline_fixed_string_t offload;
18823 cmdline_fixed_string_t on_off;
18826 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_port =
18827 TOKEN_STRING_INITIALIZER
18828 (struct cmd_config_per_port_tx_offload_result,
18830 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_config =
18831 TOKEN_STRING_INITIALIZER
18832 (struct cmd_config_per_port_tx_offload_result,
18834 cmdline_parse_token_num_t cmd_config_per_port_tx_offload_result_port_id =
18835 TOKEN_NUM_INITIALIZER
18836 (struct cmd_config_per_port_tx_offload_result,
18838 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_tx_offload =
18839 TOKEN_STRING_INITIALIZER
18840 (struct cmd_config_per_port_tx_offload_result,
18841 tx_offload, "tx_offload");
18842 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_offload =
18843 TOKEN_STRING_INITIALIZER
18844 (struct cmd_config_per_port_tx_offload_result,
18845 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
18846 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
18847 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
18848 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
18849 "mt_lockfree#multi_segs#mbuf_fast_free#security#"
18850 "send_on_timestamp");
18851 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_on_off =
18852 TOKEN_STRING_INITIALIZER
18853 (struct cmd_config_per_port_tx_offload_result,
18857 search_tx_offload(const char *name)
18859 uint64_t single_offload;
18860 const char *single_name;
18864 single_offload = 1;
18865 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
18866 single_name = rte_eth_dev_tx_offload_name(single_offload);
18867 if (single_name == NULL)
18869 if (!strcasecmp(single_name, name)) {
18872 } else if (!strcasecmp(single_name, "UNKNOWN"))
18874 single_offload <<= 1;
18878 return single_offload;
18884 cmd_config_per_port_tx_offload_parsed(void *parsed_result,
18885 __rte_unused struct cmdline *cl,
18886 __rte_unused void *data)
18888 struct cmd_config_per_port_tx_offload_result *res = parsed_result;
18889 portid_t port_id = res->port_id;
18890 struct rte_eth_dev_info dev_info;
18891 struct rte_port *port = &ports[port_id];
18892 uint64_t single_offload;
18893 uint16_t nb_tx_queues;
18897 if (port->port_status != RTE_PORT_STOPPED) {
18898 printf("Error: Can't config offload when Port %d "
18899 "is not stopped\n", port_id);
18903 single_offload = search_tx_offload(res->offload);
18904 if (single_offload == 0) {
18905 printf("Unknown offload name: %s\n", res->offload);
18909 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18913 nb_tx_queues = dev_info.nb_tx_queues;
18914 if (!strcmp(res->on_off, "on")) {
18915 port->dev_conf.txmode.offloads |= single_offload;
18916 for (q = 0; q < nb_tx_queues; q++)
18917 port->tx_conf[q].offloads |= single_offload;
18919 port->dev_conf.txmode.offloads &= ~single_offload;
18920 for (q = 0; q < nb_tx_queues; q++)
18921 port->tx_conf[q].offloads &= ~single_offload;
18924 cmd_reconfig_device_queue(port_id, 1, 1);
18927 cmdline_parse_inst_t cmd_config_per_port_tx_offload = {
18928 .f = cmd_config_per_port_tx_offload_parsed,
18930 .help_str = "port config <port_id> tx_offload "
18931 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
18932 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
18933 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
18934 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
18935 "mt_lockfree|multi_segs|mbuf_fast_free|security|"
18936 "send_on_timestamp on|off",
18938 (void *)&cmd_config_per_port_tx_offload_result_port,
18939 (void *)&cmd_config_per_port_tx_offload_result_config,
18940 (void *)&cmd_config_per_port_tx_offload_result_port_id,
18941 (void *)&cmd_config_per_port_tx_offload_result_tx_offload,
18942 (void *)&cmd_config_per_port_tx_offload_result_offload,
18943 (void *)&cmd_config_per_port_tx_offload_result_on_off,
18948 /* Enable/Disable a per queue offloading */
18949 struct cmd_config_per_queue_tx_offload_result {
18950 cmdline_fixed_string_t port;
18952 cmdline_fixed_string_t txq;
18954 cmdline_fixed_string_t tx_offload;
18955 cmdline_fixed_string_t offload;
18956 cmdline_fixed_string_t on_off;
18959 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_port =
18960 TOKEN_STRING_INITIALIZER
18961 (struct cmd_config_per_queue_tx_offload_result,
18963 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_port_id =
18964 TOKEN_NUM_INITIALIZER
18965 (struct cmd_config_per_queue_tx_offload_result,
18967 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txq =
18968 TOKEN_STRING_INITIALIZER
18969 (struct cmd_config_per_queue_tx_offload_result,
18971 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_queue_id =
18972 TOKEN_NUM_INITIALIZER
18973 (struct cmd_config_per_queue_tx_offload_result,
18975 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txoffload =
18976 TOKEN_STRING_INITIALIZER
18977 (struct cmd_config_per_queue_tx_offload_result,
18978 tx_offload, "tx_offload");
18979 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_offload =
18980 TOKEN_STRING_INITIALIZER
18981 (struct cmd_config_per_queue_tx_offload_result,
18982 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
18983 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
18984 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
18985 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
18986 "mt_lockfree#multi_segs#mbuf_fast_free#security");
18987 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_on_off =
18988 TOKEN_STRING_INITIALIZER
18989 (struct cmd_config_per_queue_tx_offload_result,
18993 cmd_config_per_queue_tx_offload_parsed(void *parsed_result,
18994 __rte_unused struct cmdline *cl,
18995 __rte_unused void *data)
18997 struct cmd_config_per_queue_tx_offload_result *res = parsed_result;
18998 struct rte_eth_dev_info dev_info;
18999 portid_t port_id = res->port_id;
19000 uint16_t queue_id = res->queue_id;
19001 struct rte_port *port = &ports[port_id];
19002 uint64_t single_offload;
19005 if (port->port_status != RTE_PORT_STOPPED) {
19006 printf("Error: Can't config offload when Port %d "
19007 "is not stopped\n", port_id);
19011 ret = eth_dev_info_get_print_err(port_id, &dev_info);
19015 if (queue_id >= dev_info.nb_tx_queues) {
19016 printf("Error: input queue_id should be 0 ... "
19017 "%d\n", dev_info.nb_tx_queues - 1);
19021 single_offload = search_tx_offload(res->offload);
19022 if (single_offload == 0) {
19023 printf("Unknown offload name: %s\n", res->offload);
19027 if (!strcmp(res->on_off, "on"))
19028 port->tx_conf[queue_id].offloads |= single_offload;
19030 port->tx_conf[queue_id].offloads &= ~single_offload;
19032 cmd_reconfig_device_queue(port_id, 1, 1);
19035 cmdline_parse_inst_t cmd_config_per_queue_tx_offload = {
19036 .f = cmd_config_per_queue_tx_offload_parsed,
19038 .help_str = "port <port_id> txq <queue_id> tx_offload "
19039 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
19040 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
19041 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
19042 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
19043 "mt_lockfree|multi_segs|mbuf_fast_free|security "
19046 (void *)&cmd_config_per_queue_tx_offload_result_port,
19047 (void *)&cmd_config_per_queue_tx_offload_result_port_id,
19048 (void *)&cmd_config_per_queue_tx_offload_result_txq,
19049 (void *)&cmd_config_per_queue_tx_offload_result_queue_id,
19050 (void *)&cmd_config_per_queue_tx_offload_result_txoffload,
19051 (void *)&cmd_config_per_queue_tx_offload_result_offload,
19052 (void *)&cmd_config_per_queue_tx_offload_result_on_off,
19057 /* *** configure tx_metadata for specific port *** */
19058 struct cmd_config_tx_metadata_specific_result {
19059 cmdline_fixed_string_t port;
19060 cmdline_fixed_string_t keyword;
19062 cmdline_fixed_string_t item;
19067 cmd_config_tx_metadata_specific_parsed(void *parsed_result,
19068 __rte_unused struct cmdline *cl,
19069 __rte_unused void *data)
19071 struct cmd_config_tx_metadata_specific_result *res = parsed_result;
19073 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
19075 ports[res->port_id].tx_metadata = res->value;
19076 /* Add/remove callback to insert valid metadata in every Tx packet. */
19077 if (ports[res->port_id].tx_metadata)
19078 add_tx_md_callback(res->port_id);
19080 remove_tx_md_callback(res->port_id);
19081 rte_flow_dynf_metadata_register();
19084 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_port =
19085 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
19087 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_keyword =
19088 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
19089 keyword, "config");
19090 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_id =
19091 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
19093 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_item =
19094 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
19095 item, "tx_metadata");
19096 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_value =
19097 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
19100 cmdline_parse_inst_t cmd_config_tx_metadata_specific = {
19101 .f = cmd_config_tx_metadata_specific_parsed,
19103 .help_str = "port config <port_id> tx_metadata <value>",
19105 (void *)&cmd_config_tx_metadata_specific_port,
19106 (void *)&cmd_config_tx_metadata_specific_keyword,
19107 (void *)&cmd_config_tx_metadata_specific_id,
19108 (void *)&cmd_config_tx_metadata_specific_item,
19109 (void *)&cmd_config_tx_metadata_specific_value,
19114 /* *** set dynf *** */
19115 struct cmd_config_tx_dynf_specific_result {
19116 cmdline_fixed_string_t port;
19117 cmdline_fixed_string_t keyword;
19119 cmdline_fixed_string_t item;
19120 cmdline_fixed_string_t name;
19121 cmdline_fixed_string_t value;
19125 cmd_config_dynf_specific_parsed(void *parsed_result,
19126 __rte_unused struct cmdline *cl,
19127 __rte_unused void *data)
19129 struct cmd_config_tx_dynf_specific_result *res = parsed_result;
19130 struct rte_mbuf_dynflag desc_flag;
19132 uint64_t old_port_flags;
19134 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
19136 flag = rte_mbuf_dynflag_lookup(res->name, NULL);
19138 if (strlcpy(desc_flag.name, res->name,
19139 RTE_MBUF_DYN_NAMESIZE) >= RTE_MBUF_DYN_NAMESIZE) {
19140 printf("Flag name too long\n");
19143 desc_flag.flags = 0;
19144 flag = rte_mbuf_dynflag_register(&desc_flag);
19146 printf("Can't register flag\n");
19149 strcpy(dynf_names[flag], desc_flag.name);
19151 old_port_flags = ports[res->port_id].mbuf_dynf;
19152 if (!strcmp(res->value, "set")) {
19153 ports[res->port_id].mbuf_dynf |= 1UL << flag;
19154 if (old_port_flags == 0)
19155 add_tx_dynf_callback(res->port_id);
19157 ports[res->port_id].mbuf_dynf &= ~(1UL << flag);
19158 if (ports[res->port_id].mbuf_dynf == 0)
19159 remove_tx_dynf_callback(res->port_id);
19163 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_port =
19164 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
19166 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_keyword =
19167 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
19168 keyword, "config");
19169 cmdline_parse_token_num_t cmd_config_tx_dynf_specific_port_id =
19170 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
19172 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_item =
19173 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
19175 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_name =
19176 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
19178 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_value =
19179 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
19180 value, "set#clear");
19182 cmdline_parse_inst_t cmd_config_tx_dynf_specific = {
19183 .f = cmd_config_dynf_specific_parsed,
19185 .help_str = "port config <port id> dynf <name> set|clear",
19187 (void *)&cmd_config_tx_dynf_specific_port,
19188 (void *)&cmd_config_tx_dynf_specific_keyword,
19189 (void *)&cmd_config_tx_dynf_specific_port_id,
19190 (void *)&cmd_config_tx_dynf_specific_item,
19191 (void *)&cmd_config_tx_dynf_specific_name,
19192 (void *)&cmd_config_tx_dynf_specific_value,
19197 /* *** display tx_metadata per port configuration *** */
19198 struct cmd_show_tx_metadata_result {
19199 cmdline_fixed_string_t cmd_show;
19200 cmdline_fixed_string_t cmd_port;
19201 cmdline_fixed_string_t cmd_keyword;
19206 cmd_show_tx_metadata_parsed(void *parsed_result,
19207 __rte_unused struct cmdline *cl,
19208 __rte_unused void *data)
19210 struct cmd_show_tx_metadata_result *res = parsed_result;
19212 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
19213 printf("invalid port id %u\n", res->cmd_pid);
19216 if (!strcmp(res->cmd_keyword, "tx_metadata")) {
19217 printf("Port %u tx_metadata: %u\n", res->cmd_pid,
19218 ports[res->cmd_pid].tx_metadata);
19222 cmdline_parse_token_string_t cmd_show_tx_metadata_show =
19223 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
19225 cmdline_parse_token_string_t cmd_show_tx_metadata_port =
19226 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
19228 cmdline_parse_token_num_t cmd_show_tx_metadata_pid =
19229 TOKEN_NUM_INITIALIZER(struct cmd_show_tx_metadata_result,
19231 cmdline_parse_token_string_t cmd_show_tx_metadata_keyword =
19232 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
19233 cmd_keyword, "tx_metadata");
19235 cmdline_parse_inst_t cmd_show_tx_metadata = {
19236 .f = cmd_show_tx_metadata_parsed,
19238 .help_str = "show port <port_id> tx_metadata",
19240 (void *)&cmd_show_tx_metadata_show,
19241 (void *)&cmd_show_tx_metadata_port,
19242 (void *)&cmd_show_tx_metadata_pid,
19243 (void *)&cmd_show_tx_metadata_keyword,
19248 /* *** show fec capability per port configuration *** */
19249 struct cmd_show_fec_capability_result {
19250 cmdline_fixed_string_t cmd_show;
19251 cmdline_fixed_string_t cmd_port;
19252 cmdline_fixed_string_t cmd_fec;
19253 cmdline_fixed_string_t cmd_keyword;
19258 cmd_show_fec_capability_parsed(void *parsed_result,
19259 __rte_unused struct cmdline *cl,
19260 __rte_unused void *data)
19262 #define FEC_CAP_NUM 2
19263 struct cmd_show_fec_capability_result *res = parsed_result;
19264 struct rte_eth_fec_capa speed_fec_capa[FEC_CAP_NUM];
19265 unsigned int num = FEC_CAP_NUM;
19266 unsigned int ret_num;
19269 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
19270 printf("Invalid port id %u\n", res->cmd_pid);
19274 ret = rte_eth_fec_get_capability(res->cmd_pid, speed_fec_capa, num);
19275 if (ret == -ENOTSUP) {
19276 printf("Function not implemented\n");
19278 } else if (ret < 0) {
19279 printf("Get FEC capability failed\n");
19283 ret_num = (unsigned int)ret;
19284 show_fec_capability(ret_num, speed_fec_capa);
19287 cmdline_parse_token_string_t cmd_show_fec_capability_show =
19288 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
19290 cmdline_parse_token_string_t cmd_show_fec_capability_port =
19291 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
19293 cmdline_parse_token_num_t cmd_show_fec_capability_pid =
19294 TOKEN_NUM_INITIALIZER(struct cmd_show_fec_capability_result,
19296 cmdline_parse_token_string_t cmd_show_fec_capability_fec =
19297 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
19299 cmdline_parse_token_string_t cmd_show_fec_capability_keyword =
19300 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
19301 cmd_keyword, "capabilities");
19303 cmdline_parse_inst_t cmd_show_capability = {
19304 .f = cmd_show_fec_capability_parsed,
19306 .help_str = "show port <port_id> fec capabilities",
19308 (void *)&cmd_show_fec_capability_show,
19309 (void *)&cmd_show_fec_capability_port,
19310 (void *)&cmd_show_fec_capability_pid,
19311 (void *)&cmd_show_fec_capability_fec,
19312 (void *)&cmd_show_fec_capability_keyword,
19317 /* *** show fec mode per port configuration *** */
19318 struct cmd_show_fec_metadata_result {
19319 cmdline_fixed_string_t cmd_show;
19320 cmdline_fixed_string_t cmd_port;
19321 cmdline_fixed_string_t cmd_keyword;
19326 cmd_show_fec_mode_parsed(void *parsed_result,
19327 __rte_unused struct cmdline *cl,
19328 __rte_unused void *data)
19330 #define FEC_NAME_SIZE 16
19331 struct cmd_show_fec_metadata_result *res = parsed_result;
19333 char buf[FEC_NAME_SIZE];
19336 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
19337 printf("Invalid port id %u\n", res->cmd_pid);
19340 ret = rte_eth_fec_get(res->cmd_pid, &mode);
19341 if (ret == -ENOTSUP) {
19342 printf("Function not implemented\n");
19344 } else if (ret < 0) {
19345 printf("Get FEC mode failed\n");
19350 case RTE_ETH_FEC_MODE_CAPA_MASK(NOFEC):
19351 strlcpy(buf, "off", sizeof(buf));
19353 case RTE_ETH_FEC_MODE_CAPA_MASK(AUTO):
19354 strlcpy(buf, "auto", sizeof(buf));
19356 case RTE_ETH_FEC_MODE_CAPA_MASK(BASER):
19357 strlcpy(buf, "baser", sizeof(buf));
19359 case RTE_ETH_FEC_MODE_CAPA_MASK(RS):
19360 strlcpy(buf, "rs", sizeof(buf));
19366 printf("%s\n", buf);
19369 cmdline_parse_token_string_t cmd_show_fec_mode_show =
19370 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
19372 cmdline_parse_token_string_t cmd_show_fec_mode_port =
19373 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
19375 cmdline_parse_token_num_t cmd_show_fec_mode_pid =
19376 TOKEN_NUM_INITIALIZER(struct cmd_show_fec_metadata_result,
19378 cmdline_parse_token_string_t cmd_show_fec_mode_keyword =
19379 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
19380 cmd_keyword, "fec_mode");
19382 cmdline_parse_inst_t cmd_show_fec_mode = {
19383 .f = cmd_show_fec_mode_parsed,
19385 .help_str = "show port <port_id> fec_mode",
19387 (void *)&cmd_show_fec_mode_show,
19388 (void *)&cmd_show_fec_mode_port,
19389 (void *)&cmd_show_fec_mode_pid,
19390 (void *)&cmd_show_fec_mode_keyword,
19395 /* *** set fec mode per port configuration *** */
19396 struct cmd_set_port_fec_mode {
19397 cmdline_fixed_string_t set;
19398 cmdline_fixed_string_t port;
19400 cmdline_fixed_string_t fec_mode;
19401 cmdline_fixed_string_t fec_value;
19404 /* Common CLI fields for set fec mode */
19405 cmdline_parse_token_string_t cmd_set_port_fec_mode_set =
19406 TOKEN_STRING_INITIALIZER
19407 (struct cmd_set_port_fec_mode,
19409 cmdline_parse_token_string_t cmd_set_port_fec_mode_port =
19410 TOKEN_STRING_INITIALIZER
19411 (struct cmd_set_port_fec_mode,
19413 cmdline_parse_token_num_t cmd_set_port_fec_mode_port_id =
19414 TOKEN_NUM_INITIALIZER
19415 (struct cmd_set_port_fec_mode,
19417 cmdline_parse_token_string_t cmd_set_port_fec_mode_str =
19418 TOKEN_STRING_INITIALIZER
19419 (struct cmd_set_port_fec_mode,
19420 fec_mode, "fec_mode");
19421 cmdline_parse_token_string_t cmd_set_port_fec_mode_value =
19422 TOKEN_STRING_INITIALIZER
19423 (struct cmd_set_port_fec_mode,
19427 cmd_set_port_fec_mode_parsed(
19428 void *parsed_result,
19429 __rte_unused struct cmdline *cl,
19430 __rte_unused void *data)
19432 struct cmd_set_port_fec_mode *res = parsed_result;
19433 uint16_t port_id = res->port_id;
19437 ret = parse_fec_mode(res->fec_value, &mode);
19439 printf("Unknown fec mode: %s for Port %d\n", res->fec_value,
19444 ret = rte_eth_fec_set(port_id, mode);
19445 if (ret == -ENOTSUP) {
19446 printf("Function not implemented\n");
19448 } else if (ret < 0) {
19449 printf("Set FEC mode failed\n");
19454 cmdline_parse_inst_t cmd_set_fec_mode = {
19455 .f = cmd_set_port_fec_mode_parsed,
19457 .help_str = "set port <port_id> fec_mode auto|off|rs|baser",
19459 (void *)&cmd_set_port_fec_mode_set,
19460 (void *)&cmd_set_port_fec_mode_port,
19461 (void *)&cmd_set_port_fec_mode_port_id,
19462 (void *)&cmd_set_port_fec_mode_str,
19463 (void *)&cmd_set_port_fec_mode_value,
19468 /* show port supported ptypes */
19470 /* Common result structure for show port ptypes */
19471 struct cmd_show_port_supported_ptypes_result {
19472 cmdline_fixed_string_t show;
19473 cmdline_fixed_string_t port;
19475 cmdline_fixed_string_t ptypes;
19478 /* Common CLI fields for show port ptypes */
19479 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_show =
19480 TOKEN_STRING_INITIALIZER
19481 (struct cmd_show_port_supported_ptypes_result,
19483 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_port =
19484 TOKEN_STRING_INITIALIZER
19485 (struct cmd_show_port_supported_ptypes_result,
19487 cmdline_parse_token_num_t cmd_show_port_supported_ptypes_port_id =
19488 TOKEN_NUM_INITIALIZER
19489 (struct cmd_show_port_supported_ptypes_result,
19491 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_ptypes =
19492 TOKEN_STRING_INITIALIZER
19493 (struct cmd_show_port_supported_ptypes_result,
19497 cmd_show_port_supported_ptypes_parsed(
19498 void *parsed_result,
19499 __rte_unused struct cmdline *cl,
19500 __rte_unused void *data)
19502 #define RSVD_PTYPE_MASK 0xf0000000
19503 #define MAX_PTYPES_PER_LAYER 16
19504 #define LTYPE_NAMESIZE 32
19505 #define PTYPE_NAMESIZE 256
19506 struct cmd_show_port_supported_ptypes_result *res = parsed_result;
19507 char buf[PTYPE_NAMESIZE], ltype[LTYPE_NAMESIZE];
19508 uint32_t ptype_mask = RTE_PTYPE_L2_MASK;
19509 uint32_t ptypes[MAX_PTYPES_PER_LAYER];
19510 uint16_t port_id = res->port_id;
19513 ret = rte_eth_dev_get_supported_ptypes(port_id, ptype_mask, NULL, 0);
19517 while (ptype_mask != RSVD_PTYPE_MASK) {
19519 switch (ptype_mask) {
19520 case RTE_PTYPE_L2_MASK:
19521 strlcpy(ltype, "L2", sizeof(ltype));
19523 case RTE_PTYPE_L3_MASK:
19524 strlcpy(ltype, "L3", sizeof(ltype));
19526 case RTE_PTYPE_L4_MASK:
19527 strlcpy(ltype, "L4", sizeof(ltype));
19529 case RTE_PTYPE_TUNNEL_MASK:
19530 strlcpy(ltype, "Tunnel", sizeof(ltype));
19532 case RTE_PTYPE_INNER_L2_MASK:
19533 strlcpy(ltype, "Inner L2", sizeof(ltype));
19535 case RTE_PTYPE_INNER_L3_MASK:
19536 strlcpy(ltype, "Inner L3", sizeof(ltype));
19538 case RTE_PTYPE_INNER_L4_MASK:
19539 strlcpy(ltype, "Inner L4", sizeof(ltype));
19545 ret = rte_eth_dev_get_supported_ptypes(res->port_id,
19546 ptype_mask, ptypes,
19547 MAX_PTYPES_PER_LAYER);
19550 printf("Supported %s ptypes:\n", ltype);
19552 printf("%s ptypes unsupported\n", ltype);
19554 for (i = 0; i < ret; ++i) {
19555 rte_get_ptype_name(ptypes[i], buf, sizeof(buf));
19556 printf("%s\n", buf);
19563 cmdline_parse_inst_t cmd_show_port_supported_ptypes = {
19564 .f = cmd_show_port_supported_ptypes_parsed,
19566 .help_str = "show port <port_id> ptypes",
19568 (void *)&cmd_show_port_supported_ptypes_show,
19569 (void *)&cmd_show_port_supported_ptypes_port,
19570 (void *)&cmd_show_port_supported_ptypes_port_id,
19571 (void *)&cmd_show_port_supported_ptypes_ptypes,
19576 /* *** display rx/tx descriptor status *** */
19577 struct cmd_show_rx_tx_desc_status_result {
19578 cmdline_fixed_string_t cmd_show;
19579 cmdline_fixed_string_t cmd_port;
19580 cmdline_fixed_string_t cmd_keyword;
19581 cmdline_fixed_string_t cmd_desc;
19582 cmdline_fixed_string_t cmd_status;
19589 cmd_show_rx_tx_desc_status_parsed(void *parsed_result,
19590 __rte_unused struct cmdline *cl,
19591 __rte_unused void *data)
19593 struct cmd_show_rx_tx_desc_status_result *res = parsed_result;
19596 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
19597 printf("invalid port id %u\n", res->cmd_pid);
19601 if (!strcmp(res->cmd_keyword, "rxq")) {
19602 rc = rte_eth_rx_descriptor_status(res->cmd_pid, res->cmd_qid,
19605 printf("Invalid queueid = %d\n", res->cmd_qid);
19608 if (rc == RTE_ETH_RX_DESC_AVAIL)
19609 printf("Desc status = AVAILABLE\n");
19610 else if (rc == RTE_ETH_RX_DESC_DONE)
19611 printf("Desc status = DONE\n");
19613 printf("Desc status = UNAVAILABLE\n");
19614 } else if (!strcmp(res->cmd_keyword, "txq")) {
19615 rc = rte_eth_tx_descriptor_status(res->cmd_pid, res->cmd_qid,
19618 printf("Invalid queueid = %d\n", res->cmd_qid);
19621 if (rc == RTE_ETH_TX_DESC_FULL)
19622 printf("Desc status = FULL\n");
19623 else if (rc == RTE_ETH_TX_DESC_DONE)
19624 printf("Desc status = DONE\n");
19626 printf("Desc status = UNAVAILABLE\n");
19630 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_show =
19631 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19633 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_port =
19634 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19636 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_pid =
19637 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19639 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_keyword =
19640 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19641 cmd_keyword, "rxq#txq");
19642 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_qid =
19643 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19645 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_desc =
19646 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19648 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_did =
19649 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19651 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_status =
19652 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19653 cmd_status, "status");
19654 cmdline_parse_inst_t cmd_show_rx_tx_desc_status = {
19655 .f = cmd_show_rx_tx_desc_status_parsed,
19657 .help_str = "show port <port_id> rxq|txq <queue_id> desc <desc_id> "
19660 (void *)&cmd_show_rx_tx_desc_status_show,
19661 (void *)&cmd_show_rx_tx_desc_status_port,
19662 (void *)&cmd_show_rx_tx_desc_status_pid,
19663 (void *)&cmd_show_rx_tx_desc_status_keyword,
19664 (void *)&cmd_show_rx_tx_desc_status_qid,
19665 (void *)&cmd_show_rx_tx_desc_status_desc,
19666 (void *)&cmd_show_rx_tx_desc_status_did,
19667 (void *)&cmd_show_rx_tx_desc_status_status,
19672 /* Common result structure for set port ptypes */
19673 struct cmd_set_port_ptypes_result {
19674 cmdline_fixed_string_t set;
19675 cmdline_fixed_string_t port;
19677 cmdline_fixed_string_t ptype_mask;
19681 /* Common CLI fields for set port ptypes */
19682 cmdline_parse_token_string_t cmd_set_port_ptypes_set =
19683 TOKEN_STRING_INITIALIZER
19684 (struct cmd_set_port_ptypes_result,
19686 cmdline_parse_token_string_t cmd_set_port_ptypes_port =
19687 TOKEN_STRING_INITIALIZER
19688 (struct cmd_set_port_ptypes_result,
19690 cmdline_parse_token_num_t cmd_set_port_ptypes_port_id =
19691 TOKEN_NUM_INITIALIZER
19692 (struct cmd_set_port_ptypes_result,
19694 cmdline_parse_token_string_t cmd_set_port_ptypes_mask_str =
19695 TOKEN_STRING_INITIALIZER
19696 (struct cmd_set_port_ptypes_result,
19697 ptype_mask, "ptype_mask");
19698 cmdline_parse_token_num_t cmd_set_port_ptypes_mask_u32 =
19699 TOKEN_NUM_INITIALIZER
19700 (struct cmd_set_port_ptypes_result,
19704 cmd_set_port_ptypes_parsed(
19705 void *parsed_result,
19706 __rte_unused struct cmdline *cl,
19707 __rte_unused void *data)
19709 struct cmd_set_port_ptypes_result *res = parsed_result;
19710 #define PTYPE_NAMESIZE 256
19711 char ptype_name[PTYPE_NAMESIZE];
19712 uint16_t port_id = res->port_id;
19713 uint32_t ptype_mask = res->mask;
19716 ret = rte_eth_dev_get_supported_ptypes(port_id, RTE_PTYPE_ALL_MASK,
19719 printf("Port %d doesn't support any ptypes.\n", port_id);
19723 uint32_t ptypes[ret];
19725 ret = rte_eth_dev_set_ptypes(port_id, ptype_mask, ptypes, ret);
19727 printf("Unable to set requested ptypes for Port %d\n", port_id);
19731 printf("Successfully set following ptypes for Port %d\n", port_id);
19732 for (i = 0; i < ret && ptypes[i] != RTE_PTYPE_UNKNOWN; i++) {
19733 rte_get_ptype_name(ptypes[i], ptype_name, sizeof(ptype_name));
19734 printf("%s\n", ptype_name);
19737 clear_ptypes = false;
19740 cmdline_parse_inst_t cmd_set_port_ptypes = {
19741 .f = cmd_set_port_ptypes_parsed,
19743 .help_str = "set port <port_id> ptype_mask <mask>",
19745 (void *)&cmd_set_port_ptypes_set,
19746 (void *)&cmd_set_port_ptypes_port,
19747 (void *)&cmd_set_port_ptypes_port_id,
19748 (void *)&cmd_set_port_ptypes_mask_str,
19749 (void *)&cmd_set_port_ptypes_mask_u32,
19754 /* *** display mac addresses added to a port *** */
19755 struct cmd_showport_macs_result {
19756 cmdline_fixed_string_t cmd_show;
19757 cmdline_fixed_string_t cmd_port;
19758 cmdline_fixed_string_t cmd_keyword;
19763 cmd_showport_macs_parsed(void *parsed_result,
19764 __rte_unused struct cmdline *cl,
19765 __rte_unused void *data)
19767 struct cmd_showport_macs_result *res = parsed_result;
19769 if (port_id_is_invalid(res->cmd_pid, ENABLED_WARN))
19772 if (!strcmp(res->cmd_keyword, "macs"))
19773 show_macs(res->cmd_pid);
19774 else if (!strcmp(res->cmd_keyword, "mcast_macs"))
19775 show_mcast_macs(res->cmd_pid);
19778 cmdline_parse_token_string_t cmd_showport_macs_show =
19779 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
19781 cmdline_parse_token_string_t cmd_showport_macs_port =
19782 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
19784 cmdline_parse_token_num_t cmd_showport_macs_pid =
19785 TOKEN_NUM_INITIALIZER(struct cmd_showport_macs_result,
19787 cmdline_parse_token_string_t cmd_showport_macs_keyword =
19788 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
19789 cmd_keyword, "macs#mcast_macs");
19791 cmdline_parse_inst_t cmd_showport_macs = {
19792 .f = cmd_showport_macs_parsed,
19794 .help_str = "show port <port_id> macs|mcast_macs",
19796 (void *)&cmd_showport_macs_show,
19797 (void *)&cmd_showport_macs_port,
19798 (void *)&cmd_showport_macs_pid,
19799 (void *)&cmd_showport_macs_keyword,
19804 /* ******************************************************************************** */
19806 /* list of instructions */
19807 cmdline_parse_ctx_t main_ctx[] = {
19808 (cmdline_parse_inst_t *)&cmd_help_brief,
19809 (cmdline_parse_inst_t *)&cmd_help_long,
19810 (cmdline_parse_inst_t *)&cmd_quit,
19811 (cmdline_parse_inst_t *)&cmd_load_from_file,
19812 (cmdline_parse_inst_t *)&cmd_showport,
19813 (cmdline_parse_inst_t *)&cmd_showqueue,
19814 (cmdline_parse_inst_t *)&cmd_showeeprom,
19815 (cmdline_parse_inst_t *)&cmd_showportall,
19816 (cmdline_parse_inst_t *)&cmd_showdevice,
19817 (cmdline_parse_inst_t *)&cmd_showcfg,
19818 (cmdline_parse_inst_t *)&cmd_showfwdall,
19819 (cmdline_parse_inst_t *)&cmd_start,
19820 (cmdline_parse_inst_t *)&cmd_start_tx_first,
19821 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
19822 (cmdline_parse_inst_t *)&cmd_set_link_up,
19823 (cmdline_parse_inst_t *)&cmd_set_link_down,
19824 (cmdline_parse_inst_t *)&cmd_reset,
19825 (cmdline_parse_inst_t *)&cmd_set_numbers,
19826 (cmdline_parse_inst_t *)&cmd_set_log,
19827 (cmdline_parse_inst_t *)&cmd_set_rxoffs,
19828 (cmdline_parse_inst_t *)&cmd_set_rxpkts,
19829 (cmdline_parse_inst_t *)&cmd_set_txpkts,
19830 (cmdline_parse_inst_t *)&cmd_set_txsplit,
19831 (cmdline_parse_inst_t *)&cmd_set_txtimes,
19832 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
19833 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
19834 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
19835 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
19836 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
19837 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
19838 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
19839 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
19840 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
19841 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
19842 (cmdline_parse_inst_t *)&cmd_set_link_check,
19843 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
19844 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
19845 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
19846 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
19847 #ifdef RTE_NET_BOND
19848 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
19849 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
19850 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
19851 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
19852 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
19853 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
19854 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
19855 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
19856 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
19857 (cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues,
19858 (cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy,
19860 (cmdline_parse_inst_t *)&cmd_vlan_offload,
19861 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
19862 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
19863 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
19864 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
19865 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
19866 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
19867 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
19868 (cmdline_parse_inst_t *)&cmd_csum_set,
19869 (cmdline_parse_inst_t *)&cmd_csum_show,
19870 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
19871 (cmdline_parse_inst_t *)&cmd_tso_set,
19872 (cmdline_parse_inst_t *)&cmd_tso_show,
19873 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
19874 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
19875 (cmdline_parse_inst_t *)&cmd_gro_enable,
19876 (cmdline_parse_inst_t *)&cmd_gro_flush,
19877 (cmdline_parse_inst_t *)&cmd_gro_show,
19878 (cmdline_parse_inst_t *)&cmd_gso_enable,
19879 (cmdline_parse_inst_t *)&cmd_gso_size,
19880 (cmdline_parse_inst_t *)&cmd_gso_show,
19881 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
19882 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
19883 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
19884 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
19885 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
19886 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
19887 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
19888 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
19889 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
19890 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
19891 (cmdline_parse_inst_t *)&cmd_config_dcb,
19892 (cmdline_parse_inst_t *)&cmd_read_reg,
19893 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
19894 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
19895 (cmdline_parse_inst_t *)&cmd_write_reg,
19896 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
19897 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
19898 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
19899 (cmdline_parse_inst_t *)&cmd_stop,
19900 (cmdline_parse_inst_t *)&cmd_mac_addr,
19901 (cmdline_parse_inst_t *)&cmd_set_fwd_eth_peer,
19902 (cmdline_parse_inst_t *)&cmd_set_qmap,
19903 (cmdline_parse_inst_t *)&cmd_set_xstats_hide_zero,
19904 (cmdline_parse_inst_t *)&cmd_set_record_core_cycles,
19905 (cmdline_parse_inst_t *)&cmd_set_record_burst_stats,
19906 (cmdline_parse_inst_t *)&cmd_operate_port,
19907 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
19908 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
19909 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
19910 (cmdline_parse_inst_t *)&cmd_operate_detach_device,
19911 (cmdline_parse_inst_t *)&cmd_set_port_setup_on,
19912 (cmdline_parse_inst_t *)&cmd_config_speed_all,
19913 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
19914 (cmdline_parse_inst_t *)&cmd_config_loopback_all,
19915 (cmdline_parse_inst_t *)&cmd_config_loopback_specific,
19916 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
19917 (cmdline_parse_inst_t *)&cmd_config_mtu,
19918 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
19919 (cmdline_parse_inst_t *)&cmd_config_max_lro_pkt_size,
19920 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
19921 (cmdline_parse_inst_t *)&cmd_config_rss,
19922 (cmdline_parse_inst_t *)&cmd_config_rxtx_ring_size,
19923 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
19924 (cmdline_parse_inst_t *)&cmd_config_deferred_start_rxtx_queue,
19925 (cmdline_parse_inst_t *)&cmd_setup_rxtx_queue,
19926 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
19927 (cmdline_parse_inst_t *)&cmd_showport_reta,
19928 (cmdline_parse_inst_t *)&cmd_showport_macs,
19929 (cmdline_parse_inst_t *)&cmd_config_burst,
19930 (cmdline_parse_inst_t *)&cmd_config_thresh,
19931 (cmdline_parse_inst_t *)&cmd_config_threshold,
19932 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
19933 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
19934 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
19935 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
19936 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
19937 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
19938 (cmdline_parse_inst_t *)&cmd_global_config,
19939 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
19940 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
19941 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
19942 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
19943 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
19944 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
19945 (cmdline_parse_inst_t *)&cmd_dump,
19946 (cmdline_parse_inst_t *)&cmd_dump_one,
19947 (cmdline_parse_inst_t *)&cmd_ethertype_filter,
19948 (cmdline_parse_inst_t *)&cmd_syn_filter,
19949 (cmdline_parse_inst_t *)&cmd_2tuple_filter,
19950 (cmdline_parse_inst_t *)&cmd_5tuple_filter,
19951 (cmdline_parse_inst_t *)&cmd_flex_filter,
19952 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
19953 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
19954 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
19955 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director,
19956 (cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director,
19957 (cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director,
19958 (cmdline_parse_inst_t *)&cmd_add_del_raw_flow_director,
19959 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
19960 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
19961 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
19962 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
19963 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
19964 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
19965 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
19966 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
19967 (cmdline_parse_inst_t *)&cmd_get_hash_global_config,
19968 (cmdline_parse_inst_t *)&cmd_set_hash_global_config,
19969 (cmdline_parse_inst_t *)&cmd_set_hash_input_set,
19970 (cmdline_parse_inst_t *)&cmd_set_fdir_input_set,
19971 (cmdline_parse_inst_t *)&cmd_flow,
19972 (cmdline_parse_inst_t *)&cmd_show_port_meter_cap,
19973 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm,
19974 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm,
19975 (cmdline_parse_inst_t *)&cmd_del_port_meter_profile,
19976 (cmdline_parse_inst_t *)&cmd_create_port_meter,
19977 (cmdline_parse_inst_t *)&cmd_enable_port_meter,
19978 (cmdline_parse_inst_t *)&cmd_disable_port_meter,
19979 (cmdline_parse_inst_t *)&cmd_del_port_meter,
19980 (cmdline_parse_inst_t *)&cmd_set_port_meter_profile,
19981 (cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table,
19982 (cmdline_parse_inst_t *)&cmd_set_port_meter_policer_action,
19983 (cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask,
19984 (cmdline_parse_inst_t *)&cmd_show_port_meter_stats,
19985 (cmdline_parse_inst_t *)&cmd_mcast_addr,
19986 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all,
19987 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific,
19988 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all,
19989 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific,
19990 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_en,
19991 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_dis,
19992 (cmdline_parse_inst_t *)&cmd_config_e_tag_stripping_en_dis,
19993 (cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis,
19994 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_add,
19995 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_del,
19996 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
19997 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
19998 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
19999 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
20000 (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
20001 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
20002 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
20003 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
20004 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
20005 (cmdline_parse_inst_t *)&cmd_set_macsec_sc,
20006 (cmdline_parse_inst_t *)&cmd_set_macsec_sa,
20007 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
20008 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
20009 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
20010 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
20011 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
20012 (cmdline_parse_inst_t *)&cmd_set_vf_promisc,
20013 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
20014 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
20015 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
20016 (cmdline_parse_inst_t *)&cmd_vf_max_bw,
20017 (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
20018 (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
20019 (cmdline_parse_inst_t *)&cmd_strict_link_prio,
20020 (cmdline_parse_inst_t *)&cmd_tc_min_bw,
20021 (cmdline_parse_inst_t *)&cmd_set_vxlan,
20022 (cmdline_parse_inst_t *)&cmd_set_vxlan_tos_ttl,
20023 (cmdline_parse_inst_t *)&cmd_set_vxlan_with_vlan,
20024 (cmdline_parse_inst_t *)&cmd_set_nvgre,
20025 (cmdline_parse_inst_t *)&cmd_set_nvgre_with_vlan,
20026 (cmdline_parse_inst_t *)&cmd_set_l2_encap,
20027 (cmdline_parse_inst_t *)&cmd_set_l2_encap_with_vlan,
20028 (cmdline_parse_inst_t *)&cmd_set_l2_decap,
20029 (cmdline_parse_inst_t *)&cmd_set_l2_decap_with_vlan,
20030 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap,
20031 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap_with_vlan,
20032 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap,
20033 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap_with_vlan,
20034 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap,
20035 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap_with_vlan,
20036 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap,
20037 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap_with_vlan,
20038 (cmdline_parse_inst_t *)&cmd_ddp_add,
20039 (cmdline_parse_inst_t *)&cmd_ddp_del,
20040 (cmdline_parse_inst_t *)&cmd_ddp_get_list,
20041 (cmdline_parse_inst_t *)&cmd_ddp_get_info,
20042 (cmdline_parse_inst_t *)&cmd_cfg_input_set,
20043 (cmdline_parse_inst_t *)&cmd_clear_input_set,
20044 (cmdline_parse_inst_t *)&cmd_show_vf_stats,
20045 (cmdline_parse_inst_t *)&cmd_clear_vf_stats,
20046 (cmdline_parse_inst_t *)&cmd_show_port_supported_ptypes,
20047 (cmdline_parse_inst_t *)&cmd_set_port_ptypes,
20048 (cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
20049 (cmdline_parse_inst_t *)&cmd_ptype_mapping_replace,
20050 (cmdline_parse_inst_t *)&cmd_ptype_mapping_reset,
20051 (cmdline_parse_inst_t *)&cmd_ptype_mapping_update,
20053 (cmdline_parse_inst_t *)&cmd_pctype_mapping_get,
20054 (cmdline_parse_inst_t *)&cmd_pctype_mapping_reset,
20055 (cmdline_parse_inst_t *)&cmd_pctype_mapping_update,
20056 (cmdline_parse_inst_t *)&cmd_queue_region,
20057 (cmdline_parse_inst_t *)&cmd_region_flowtype,
20058 (cmdline_parse_inst_t *)&cmd_user_priority_region,
20059 (cmdline_parse_inst_t *)&cmd_flush_queue_region,
20060 (cmdline_parse_inst_t *)&cmd_show_queue_region_info_all,
20061 (cmdline_parse_inst_t *)&cmd_show_port_tm_cap,
20062 (cmdline_parse_inst_t *)&cmd_show_port_tm_level_cap,
20063 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_cap,
20064 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_type,
20065 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_stats,
20066 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shaper_profile,
20067 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shaper_profile,
20068 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shared_shaper,
20069 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shared_shaper,
20070 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_wred_profile,
20071 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_wred_profile,
20072 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_shaper_profile,
20073 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node,
20074 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node_pmode,
20075 (cmdline_parse_inst_t *)&cmd_add_port_tm_leaf_node,
20076 (cmdline_parse_inst_t *)&cmd_del_port_tm_node,
20077 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_parent,
20078 (cmdline_parse_inst_t *)&cmd_suspend_port_tm_node,
20079 (cmdline_parse_inst_t *)&cmd_resume_port_tm_node,
20080 (cmdline_parse_inst_t *)&cmd_port_tm_hierarchy_commit,
20081 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_ecn,
20082 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_dscp,
20083 (cmdline_parse_inst_t *)&cmd_port_tm_mark_vlan_dei,
20084 (cmdline_parse_inst_t *)&cmd_cfg_tunnel_udp_port,
20085 (cmdline_parse_inst_t *)&cmd_rx_offload_get_capa,
20086 (cmdline_parse_inst_t *)&cmd_rx_offload_get_configuration,
20087 (cmdline_parse_inst_t *)&cmd_config_per_port_rx_offload,
20088 (cmdline_parse_inst_t *)&cmd_config_per_queue_rx_offload,
20089 (cmdline_parse_inst_t *)&cmd_tx_offload_get_capa,
20090 (cmdline_parse_inst_t *)&cmd_tx_offload_get_configuration,
20091 (cmdline_parse_inst_t *)&cmd_config_per_port_tx_offload,
20092 (cmdline_parse_inst_t *)&cmd_config_per_queue_tx_offload,
20094 (cmdline_parse_inst_t *)&cmd_operate_bpf_ld_parse,
20095 (cmdline_parse_inst_t *)&cmd_operate_bpf_unld_parse,
20097 (cmdline_parse_inst_t *)&cmd_config_tx_metadata_specific,
20098 (cmdline_parse_inst_t *)&cmd_show_tx_metadata,
20099 (cmdline_parse_inst_t *)&cmd_show_rx_tx_desc_status,
20100 (cmdline_parse_inst_t *)&cmd_set_raw,
20101 (cmdline_parse_inst_t *)&cmd_show_set_raw,
20102 (cmdline_parse_inst_t *)&cmd_show_set_raw_all,
20103 (cmdline_parse_inst_t *)&cmd_config_tx_dynf_specific,
20104 (cmdline_parse_inst_t *)&cmd_show_fec_mode,
20105 (cmdline_parse_inst_t *)&cmd_set_fec_mode,
20106 (cmdline_parse_inst_t *)&cmd_show_capability,
20110 /* read cmdline commands from file */
20112 cmdline_read_from_file(const char *filename)
20114 struct cmdline *cl;
20116 cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
20118 printf("Failed to create file based cmdline context: %s\n",
20123 cmdline_interact(cl);
20128 printf("Read CLI commands from %s\n", filename);
20131 /* prompt function, called from main on MAIN lcore */
20135 /* initialize non-constant commands */
20136 cmd_set_fwd_mode_init();
20137 cmd_set_fwd_retry_mode_init();
20139 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
20140 if (testpmd_cl == NULL)
20142 cmdline_interact(testpmd_cl);
20143 cmdline_stdin_exit(testpmd_cl);
20149 if (testpmd_cl != NULL)
20150 cmdline_quit(testpmd_cl);
20154 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
20156 if (id == (portid_t)RTE_PORT_ALL) {
20159 RTE_ETH_FOREACH_DEV(pid) {
20160 /* check if need_reconfig has been set to 1 */
20161 if (ports[pid].need_reconfig == 0)
20162 ports[pid].need_reconfig = dev;
20163 /* check if need_reconfig_queues has been set to 1 */
20164 if (ports[pid].need_reconfig_queues == 0)
20165 ports[pid].need_reconfig_queues = queue;
20167 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
20168 /* check if need_reconfig has been set to 1 */
20169 if (ports[id].need_reconfig == 0)
20170 ports[id].need_reconfig = dev;
20171 /* check if need_reconfig_queues has been set to 1 */
20172 if (ports[id].need_reconfig_queues == 0)
20173 ports[id].need_reconfig_queues = queue;