1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2010-2016 Intel Corporation.
3 * Copyright(c) 2014 6WIND S.A.
14 #include <sys/socket.h>
15 #include <netinet/in.h>
17 #include <sys/queue.h>
19 #include <rte_common.h>
20 #include <rte_byteorder.h>
22 #include <rte_debug.h>
23 #include <rte_cycles.h>
24 #include <rte_memory.h>
25 #include <rte_memzone.h>
26 #include <rte_malloc.h>
27 #include <rte_launch.h>
29 #include <rte_per_lcore.h>
30 #include <rte_lcore.h>
31 #include <rte_atomic.h>
32 #include <rte_branch_prediction.h>
34 #include <rte_mempool.h>
35 #include <rte_interrupts.h>
37 #include <rte_ether.h>
38 #include <rte_ethdev.h>
39 #include <rte_string_fns.h>
40 #include <rte_devargs.h>
43 #include <rte_mbuf_dyn.h>
45 #include <cmdline_rdline.h>
46 #include <cmdline_parse.h>
47 #include <cmdline_parse_num.h>
48 #include <cmdline_parse_string.h>
49 #include <cmdline_parse_ipaddr.h>
50 #include <cmdline_parse_etheraddr.h>
51 #include <cmdline_socket.h>
54 #include <rte_eth_bond.h>
55 #include <rte_eth_bond_8023ad.h>
57 #if defined RTE_BUS_DPAA && defined RTE_NET_DPAA
58 #include <rte_pmd_dpaa.h>
61 #include <rte_pmd_ixgbe.h>
64 #include <rte_pmd_i40e.h>
67 #include <rte_pmd_bnxt.h>
70 #include "cmdline_mtr.h"
71 #include "cmdline_tm.h"
74 static struct cmdline *testpmd_cl;
76 static void cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue);
78 /* *** Help command with introduction. *** */
79 struct cmd_help_brief_result {
80 cmdline_fixed_string_t help;
83 static void cmd_help_brief_parsed(__rte_unused void *parsed_result,
85 __rte_unused void *data)
90 "Help is available for the following sections:\n\n"
91 " help control : Start and stop forwarding.\n"
92 " help display : Displaying port, stats and config "
94 " help config : Configuration information.\n"
95 " help ports : Configuring ports.\n"
96 " help registers : Reading and setting port registers.\n"
97 " help filters : Filters configuration help.\n"
98 " help traffic_management : Traffic Management commands.\n"
99 " help devices : Device related cmds.\n"
100 " help all : All of the above sections.\n\n"
105 cmdline_parse_token_string_t cmd_help_brief_help =
106 TOKEN_STRING_INITIALIZER(struct cmd_help_brief_result, help, "help");
108 cmdline_parse_inst_t cmd_help_brief = {
109 .f = cmd_help_brief_parsed,
111 .help_str = "help: Show help",
113 (void *)&cmd_help_brief_help,
118 /* *** Help command with help sections. *** */
119 struct cmd_help_long_result {
120 cmdline_fixed_string_t help;
121 cmdline_fixed_string_t section;
124 static void cmd_help_long_parsed(void *parsed_result,
126 __rte_unused void *data)
129 struct cmd_help_long_result *res = parsed_result;
131 if (!strcmp(res->section, "all"))
134 if (show_all || !strcmp(res->section, "control")) {
139 "Control forwarding:\n"
140 "-------------------\n\n"
143 " Start packet forwarding with current configuration.\n\n"
146 " Start packet forwarding with current config"
147 " after sending one burst of packets.\n\n"
150 " Stop packet forwarding, and display accumulated"
154 " Quit to prompt.\n\n"
158 if (show_all || !strcmp(res->section, "display")) {
166 "show port (info|stats|summary|xstats|fdir|stat_qmap|dcb_tc|cap) (port_id|all)\n"
167 " Display information for port_id, or all.\n\n"
169 "show port port_id (module_eeprom|eeprom)\n"
170 " Display the module EEPROM or EEPROM information for port_id.\n\n"
172 "show port X rss reta (size) (mask0,mask1,...)\n"
173 " Display the rss redirection table entry indicated"
174 " by masks on port X. size is used to indicate the"
175 " hardware supported reta size\n\n"
177 "show port (port_id) rss-hash [key]\n"
178 " Display the RSS hash functions and RSS hash key of port\n\n"
180 "clear port (info|stats|xstats|fdir|stat_qmap) (port_id|all)\n"
181 " Clear information for port_id, or all.\n\n"
183 "show (rxq|txq) info (port_id) (queue_id)\n"
184 " Display information for configured RX/TX queue.\n\n"
186 "show config (rxtx|cores|fwd|rxoffs|rxpkts|txpkts)\n"
187 " Display the given configuration.\n\n"
189 "read rxd (port_id) (queue_id) (rxd_id)\n"
190 " Display an RX descriptor of a port RX queue.\n\n"
192 "read txd (port_id) (queue_id) (txd_id)\n"
193 " Display a TX descriptor of a port TX queue.\n\n"
195 "ddp get list (port_id)\n"
196 " Get ddp profile info list\n\n"
198 "ddp get info (profile_path)\n"
199 " Get ddp profile information.\n\n"
201 "show vf stats (port_id) (vf_id)\n"
202 " Display a VF's statistics.\n\n"
204 "clear vf stats (port_id) (vf_id)\n"
205 " Reset a VF's statistics.\n\n"
207 "show port (port_id) pctype mapping\n"
208 " Get flow ptype to pctype mapping on a port\n\n"
210 "show port meter stats (port_id) (meter_id) (clear)\n"
211 " Get meter stats on a port\n\n"
213 "show fwd stats all\n"
214 " Display statistics for all fwd engines.\n\n"
216 "clear fwd stats all\n"
217 " Clear statistics for all fwd engines.\n\n"
219 "show port (port_id) rx_offload capabilities\n"
220 " List all per queue and per port Rx offloading"
221 " capabilities of a port\n\n"
223 "show port (port_id) rx_offload configuration\n"
224 " List port level and all queue level"
225 " Rx offloading configuration\n\n"
227 "show port (port_id) tx_offload capabilities\n"
228 " List all per queue and per port"
229 " Tx offloading capabilities of a port\n\n"
231 "show port (port_id) tx_offload configuration\n"
232 " List port level and all queue level"
233 " Tx offloading configuration\n\n"
235 "show port (port_id) tx_metadata\n"
236 " Show Tx metadata value set"
237 " for a specific port\n\n"
239 "show port (port_id) ptypes\n"
240 " Show port supported ptypes"
241 " for a specific port\n\n"
243 "show device info (<identifier>|all)"
244 " Show general information about devices probed.\n\n"
246 "show port (port_id) rxq|txq (queue_id) desc (desc_id) status"
247 " Show status of rx|tx descriptor.\n\n"
249 "show port (port_id) macs|mcast_macs"
250 " Display list of mac addresses added to port.\n\n"
252 "show port (port_id) fec capabilities"
253 " Show fec capabilities of a port.\n\n"
255 "show port (port_id) fec_mode"
256 " Show fec mode of a port.\n\n"
260 if (show_all || !strcmp(res->section, "config")) {
266 "Configuration changes only become active when"
267 " forwarding is started/restarted.\n\n"
270 " Reset forwarding to the default configuration.\n\n"
272 "set verbose (level)\n"
273 " Set the debug verbosity level X.\n\n"
275 "set log global|(type) (level)\n"
276 " Set the log level.\n\n"
279 " Set number of ports.\n\n"
282 " Set number of cores.\n\n"
284 "set coremask (mask)\n"
285 " Set the forwarding cores hexadecimal mask.\n\n"
287 "set portmask (mask)\n"
288 " Set the forwarding ports hexadecimal mask.\n\n"
291 " Set number of packets per burst.\n\n"
293 "set burst tx delay (microseconds) retry (num)\n"
294 " Set the transmit delay time and number of retries,"
295 " effective when retry is enabled.\n\n"
297 "set rxoffs (x[,y]*)\n"
298 " Set the offset of each packet segment on"
299 " receiving if split feature is engaged."
300 " Affects only the queues configured with split"
303 "set rxpkts (x[,y]*)\n"
304 " Set the length of each segment to scatter"
305 " packets on receiving if split feature is engaged."
306 " Affects only the queues configured with split"
309 "set txpkts (x[,y]*)\n"
310 " Set the length of each segment of TXONLY"
311 " and optionally CSUM packets.\n\n"
313 "set txsplit (off|on|rand)\n"
314 " Set the split policy for the TX packets."
315 " Right now only applicable for CSUM and TXONLY"
318 "set txtimes (x, y)\n"
319 " Set the scheduling on timestamps"
320 " timings for the TXONLY mode\n\n"
322 "set corelist (x[,y]*)\n"
323 " Set the list of forwarding cores.\n\n"
325 "set portlist (x[,y]*)\n"
326 " Set the list of forwarding ports.\n\n"
328 "set port setup on (iterator|event)\n"
329 " Select how attached port is retrieved for setup.\n\n"
331 "set tx loopback (port_id) (on|off)\n"
332 " Enable or disable tx loopback.\n\n"
334 "set all queues drop (port_id) (on|off)\n"
335 " Set drop enable bit for all queues.\n\n"
337 "set vf split drop (port_id) (vf_id) (on|off)\n"
338 " Set split drop enable bit for a VF from the PF.\n\n"
340 "set vf mac antispoof (port_id) (vf_id) (on|off).\n"
341 " Set MAC antispoof for a VF from the PF.\n\n"
343 "set macsec offload (port_id) on encrypt (on|off) replay-protect (on|off)\n"
344 " Enable MACsec offload.\n\n"
346 "set macsec offload (port_id) off\n"
347 " Disable MACsec offload.\n\n"
349 "set macsec sc (tx|rx) (port_id) (mac) (pi)\n"
350 " Configure MACsec secure connection (SC).\n\n"
352 "set macsec sa (tx|rx) (port_id) (idx) (an) (pn) (key)\n"
353 " Configure MACsec secure association (SA).\n\n"
355 "set vf broadcast (port_id) (vf_id) (on|off)\n"
356 " Set VF broadcast for a VF from the PF.\n\n"
358 "vlan set stripq (on|off) (port_id,queue_id)\n"
359 " Set the VLAN strip for a queue on a port.\n\n"
361 "set vf vlan stripq (port_id) (vf_id) (on|off)\n"
362 " Set the VLAN strip for all queues in a pool for a VF from the PF.\n\n"
364 "set vf vlan insert (port_id) (vf_id) (vlan_id)\n"
365 " Set VLAN insert for a VF from the PF.\n\n"
367 "set vf vlan antispoof (port_id) (vf_id) (on|off)\n"
368 " Set VLAN antispoof for a VF from the PF.\n\n"
370 "set vf vlan tag (port_id) (vf_id) (on|off)\n"
371 " Set VLAN tag for a VF from the PF.\n\n"
373 "set vf tx max-bandwidth (port_id) (vf_id) (bandwidth)\n"
374 " Set a VF's max bandwidth(Mbps).\n\n"
376 "set vf tc tx min-bandwidth (port_id) (vf_id) (bw1, bw2, ...)\n"
377 " Set all TCs' min bandwidth(%%) on a VF.\n\n"
379 "set vf tc tx max-bandwidth (port_id) (vf_id) (tc_no) (bandwidth)\n"
380 " Set a TC's max bandwidth(Mbps) on a VF.\n\n"
382 "set tx strict-link-priority (port_id) (tc_bitmap)\n"
383 " Set some TCs' strict link priority mode on a physical port.\n\n"
385 "set tc tx min-bandwidth (port_id) (bw1, bw2, ...)\n"
386 " Set all TCs' min bandwidth(%%) for all PF and VFs.\n\n"
388 "vlan set (strip|filter|qinq_strip|extend) (on|off) (port_id)\n"
389 " Set the VLAN strip or filter or qinq strip or extend\n\n"
391 "vlan set (inner|outer) tpid (value) (port_id)\n"
392 " Set the VLAN TPID for Packet Filtering on"
395 "rx_vlan add (vlan_id|all) (port_id)\n"
396 " Add a vlan_id, or all identifiers, to the set"
397 " of VLAN identifiers filtered by port_id.\n\n"
399 "rx_vlan rm (vlan_id|all) (port_id)\n"
400 " Remove a vlan_id, or all identifiers, from the set"
401 " of VLAN identifiers filtered by port_id.\n\n"
403 "rx_vlan add (vlan_id) port (port_id) vf (vf_mask)\n"
404 " Add a vlan_id, to the set of VLAN identifiers"
405 "filtered for VF(s) from port_id.\n\n"
407 "rx_vlan rm (vlan_id) port (port_id) vf (vf_mask)\n"
408 " Remove a vlan_id, to the set of VLAN identifiers"
409 "filtered for VF(s) from port_id.\n\n"
411 "tunnel_filter add (port_id) (outer_mac) (inner_mac) (ip_addr) "
412 "(inner_vlan) (vxlan|nvgre|ipingre|vxlan-gpe) (imac-ivlan|imac-ivlan-tenid|"
413 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n"
414 " add a tunnel filter of a port.\n\n"
416 "tunnel_filter rm (port_id) (outer_mac) (inner_mac) (ip_addr) "
417 "(inner_vlan) (vxlan|nvgre|ipingre|vxlan-gpe) (imac-ivlan|imac-ivlan-tenid|"
418 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n"
419 " remove a tunnel filter of a port.\n\n"
421 "rx_vxlan_port add (udp_port) (port_id)\n"
422 " Add an UDP port for VXLAN packet filter on a port\n\n"
424 "rx_vxlan_port rm (udp_port) (port_id)\n"
425 " Remove an UDP port for VXLAN packet filter on a port\n\n"
427 "tx_vlan set (port_id) vlan_id[, vlan_id_outer]\n"
428 " Set hardware insertion of VLAN IDs (single or double VLAN "
429 "depends on the number of VLAN IDs) in packets sent on a port.\n\n"
431 "tx_vlan set pvid port_id vlan_id (on|off)\n"
432 " Set port based TX VLAN insertion.\n\n"
434 "tx_vlan reset (port_id)\n"
435 " Disable hardware insertion of a VLAN header in"
436 " packets sent on a port.\n\n"
438 "csum set (ip|udp|tcp|sctp|outer-ip|outer-udp) (hw|sw) (port_id)\n"
439 " Select hardware or software calculation of the"
440 " checksum when transmitting a packet using the"
441 " csum forward engine.\n"
442 " ip|udp|tcp|sctp always concern the inner layer.\n"
443 " outer-ip concerns the outer IP layer in"
444 " outer-udp concerns the outer UDP layer in"
445 " case the packet is recognized as a tunnel packet by"
446 " the forward engine (vxlan, gre and ipip are supported)\n"
447 " Please check the NIC datasheet for HW limits.\n\n"
449 "csum parse-tunnel (on|off) (tx_port_id)\n"
450 " If disabled, treat tunnel packets as non-tunneled"
451 " packets (treat inner headers as payload). The port\n"
452 " argument is the port used for TX in csum forward"
455 "csum show (port_id)\n"
456 " Display tx checksum offload configuration\n\n"
458 "tso set (segsize) (portid)\n"
459 " Enable TCP Segmentation Offload in csum forward"
461 " Please check the NIC datasheet for HW limits.\n\n"
464 " Display the status of TCP Segmentation Offload.\n\n"
466 "set port (port_id) gro on|off\n"
467 " Enable or disable Generic Receive Offload in"
468 " csum forwarding engine.\n\n"
470 "show port (port_id) gro\n"
471 " Display GRO configuration.\n\n"
473 "set gro flush (cycles)\n"
474 " Set the cycle to flush GROed packets from"
475 " reassembly tables.\n\n"
477 "set port (port_id) gso (on|off)"
478 " Enable or disable Generic Segmentation Offload in"
479 " csum forwarding engine.\n\n"
481 "set gso segsz (length)\n"
482 " Set max packet length for output GSO segments,"
483 " including packet header and payload.\n\n"
485 "show port (port_id) gso\n"
486 " Show GSO configuration.\n\n"
489 " Set packet forwarding mode.\n\n"
491 "mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n"
492 " Add a MAC address on port_id.\n\n"
494 "mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n"
495 " Remove a MAC address from port_id.\n\n"
497 "mac_addr set (port_id) (XX:XX:XX:XX:XX:XX)\n"
498 " Set the default MAC address for port_id.\n\n"
500 "mac_addr add port (port_id) vf (vf_id) (mac_address)\n"
501 " Add a MAC address for a VF on the port.\n\n"
503 "set vf mac addr (port_id) (vf_id) (XX:XX:XX:XX:XX:XX)\n"
504 " Set the MAC address for a VF from the PF.\n\n"
506 "set eth-peer (port_id) (peer_addr)\n"
507 " set the peer address for certain port.\n\n"
509 "set port (port_id) uta (mac_address|all) (on|off)\n"
510 " Add/Remove a or all unicast hash filter(s)"
513 "set promisc (port_id|all) (on|off)\n"
514 " Set the promiscuous mode on port_id, or all.\n\n"
516 "set allmulti (port_id|all) (on|off)\n"
517 " Set the allmulti mode on port_id, or all.\n\n"
519 "set vf promisc (port_id) (vf_id) (on|off)\n"
520 " Set unicast promiscuous mode for a VF from the PF.\n\n"
522 "set vf allmulti (port_id) (vf_id) (on|off)\n"
523 " Set multicast promiscuous mode for a VF from the PF.\n\n"
525 "set flow_ctrl rx (on|off) tx (on|off) (high_water)"
526 " (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd"
527 " (on|off) autoneg (on|off) (port_id)\n"
528 "set flow_ctrl rx (on|off) (portid)\n"
529 "set flow_ctrl tx (on|off) (portid)\n"
530 "set flow_ctrl high_water (high_water) (portid)\n"
531 "set flow_ctrl low_water (low_water) (portid)\n"
532 "set flow_ctrl pause_time (pause_time) (portid)\n"
533 "set flow_ctrl send_xon (send_xon) (portid)\n"
534 "set flow_ctrl mac_ctrl_frame_fwd (on|off) (portid)\n"
535 "set flow_ctrl autoneg (on|off) (port_id)\n"
536 " Set the link flow control parameter on a port.\n\n"
538 "set pfc_ctrl rx (on|off) tx (on|off) (high_water)"
539 " (low_water) (pause_time) (priority) (port_id)\n"
540 " Set the priority flow control parameter on a"
543 "set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n"
544 " Set statistics mapping (qmapping 0..15) for RX/TX"
546 " e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2"
547 " on port 0 to mapping 5.\n\n"
549 "set xstats-hide-zero on|off\n"
550 " Set the option to hide the zero values"
551 " for xstats display.\n"
553 "set record-core-cycles on|off\n"
554 " Set the option to enable measurement of CPU cycles.\n"
556 "set record-burst-stats on|off\n"
557 " Set the option to enable display of RX and TX bursts.\n"
559 "set port (port_id) vf (vf_id) rx|tx on|off\n"
560 " Enable/Disable a VF receive/tranmit from a port\n\n"
562 "set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM"
564 " AUPE:accepts untagged VLAN;"
565 "ROPE:accept unicast hash\n\n"
566 " BAM:accepts broadcast packets;"
567 "MPE:accepts all multicast packets\n\n"
568 " Enable/Disable a VF receive mode of a port\n\n"
570 "set port (port_id) queue (queue_id) rate (rate_num)\n"
571 " Set rate limit for a queue of a port\n\n"
573 "set port (port_id) vf (vf_id) rate (rate_num) "
574 "queue_mask (queue_mask_value)\n"
575 " Set rate limit for queues in VF of a port\n\n"
577 "set port (port_id) mirror-rule (rule_id)"
578 " (pool-mirror-up|pool-mirror-down|vlan-mirror)"
579 " (poolmask|vlanid[,vlanid]*) dst-pool (pool_id) (on|off)\n"
580 " Set pool or vlan type mirror rule on a port.\n"
581 " e.g., 'set port 0 mirror-rule 0 vlan-mirror 0,1"
582 " dst-pool 0 on' enable mirror traffic with vlan 0,1"
585 "set port (port_id) mirror-rule (rule_id)"
586 " (uplink-mirror|downlink-mirror) dst-pool"
587 " (pool_id) (on|off)\n"
588 " Set uplink or downlink type mirror rule on a port.\n"
589 " e.g., 'set port 0 mirror-rule 0 uplink-mirror dst-pool"
590 " 0 on' enable mirror income traffic to pool 0.\n\n"
592 "reset port (port_id) mirror-rule (rule_id)\n"
593 " Reset a mirror rule.\n\n"
595 "set flush_rx (on|off)\n"
596 " Flush (default) or don't flush RX streams before"
597 " forwarding. Mainly used with PCAP drivers.\n\n"
599 "set bypass mode (normal|bypass|isolate) (port_id)\n"
600 " Set the bypass mode for the lowest port on bypass enabled"
603 "set bypass event (timeout|os_on|os_off|power_on|power_off) "
604 "mode (normal|bypass|isolate) (port_id)\n"
605 " Set the event required to initiate specified bypass mode for"
606 " the lowest port on a bypass enabled NIC where:\n"
607 " timeout = enable bypass after watchdog timeout.\n"
608 " os_on = enable bypass when OS/board is powered on.\n"
609 " os_off = enable bypass when OS/board is powered off.\n"
610 " power_on = enable bypass when power supply is turned on.\n"
611 " power_off = enable bypass when power supply is turned off."
614 "set bypass timeout (0|1.5|2|3|4|8|16|32)\n"
615 " Set the bypass watchdog timeout to 'n' seconds"
616 " where 0 = instant.\n\n"
618 "show bypass config (port_id)\n"
619 " Show the bypass configuration for a bypass enabled NIC"
620 " using the lowest port on the NIC.\n\n"
623 "create bonded device (mode) (socket)\n"
624 " Create a new bonded device with specific bonding mode and socket.\n\n"
626 "add bonding slave (slave_id) (port_id)\n"
627 " Add a slave device to a bonded device.\n\n"
629 "remove bonding slave (slave_id) (port_id)\n"
630 " Remove a slave device from a bonded device.\n\n"
632 "set bonding mode (value) (port_id)\n"
633 " Set the bonding mode on a bonded device.\n\n"
635 "set bonding primary (slave_id) (port_id)\n"
636 " Set the primary slave for a bonded device.\n\n"
638 "show bonding config (port_id)\n"
639 " Show the bonding config for port_id.\n\n"
641 "set bonding mac_addr (port_id) (address)\n"
642 " Set the MAC address of a bonded device.\n\n"
644 "set bonding mode IEEE802.3AD aggregator policy (port_id) (agg_name)"
645 " Set Aggregation mode for IEEE802.3AD (mode 4)"
647 "set bonding balance_xmit_policy (port_id) (l2|l23|l34)\n"
648 " Set the transmit balance policy for bonded device running in balance mode.\n\n"
650 "set bonding mon_period (port_id) (value)\n"
651 " Set the bonding link status monitoring polling period in ms.\n\n"
653 "set bonding lacp dedicated_queues <port_id> (enable|disable)\n"
654 " Enable/disable dedicated queues for LACP control traffic.\n\n"
657 "set link-up port (port_id)\n"
658 " Set link up for a port.\n\n"
660 "set link-down port (port_id)\n"
661 " Set link down for a port.\n\n"
663 "E-tag set insertion on port-tag-id (value)"
664 " port (port_id) vf (vf_id)\n"
665 " Enable E-tag insertion for a VF on a port\n\n"
667 "E-tag set insertion off port (port_id) vf (vf_id)\n"
668 " Disable E-tag insertion for a VF on a port\n\n"
670 "E-tag set stripping (on|off) port (port_id)\n"
671 " Enable/disable E-tag stripping on a port\n\n"
673 "E-tag set forwarding (on|off) port (port_id)\n"
674 " Enable/disable E-tag based forwarding"
677 "E-tag set filter add e-tag-id (value) dst-pool"
678 " (pool_id) port (port_id)\n"
679 " Add an E-tag forwarding filter on a port\n\n"
681 "E-tag set filter del e-tag-id (value) port (port_id)\n"
682 " Delete an E-tag forwarding filter on a port\n\n"
684 "ddp add (port_id) (profile_path[,backup_profile_path])\n"
685 " Load a profile package on a port\n\n"
687 "ddp del (port_id) (backup_profile_path)\n"
688 " Delete a profile package from a port\n\n"
690 "ptype mapping get (port_id) (valid_only)\n"
691 " Get ptype mapping on a port\n\n"
693 "ptype mapping replace (port_id) (target) (mask) (pky_type)\n"
694 " Replace target with the pkt_type in ptype mapping\n\n"
696 "ptype mapping reset (port_id)\n"
697 " Reset ptype mapping on a port\n\n"
699 "ptype mapping update (port_id) (hw_ptype) (sw_ptype)\n"
700 " Update a ptype mapping item on a port\n\n"
702 "set port (port_id) ptype_mask (ptype_mask)\n"
703 " set packet types classification for a specific port\n\n"
705 "set port (port_id) queue-region region_id (value) "
706 "queue_start_index (value) queue_num (value)\n"
707 " Set a queue region on a port\n\n"
709 "set port (port_id) queue-region region_id (value) "
711 " Set a flowtype region index on a port\n\n"
713 "set port (port_id) queue-region UP (value) region_id (value)\n"
714 " Set the mapping of User Priority to "
715 "queue region on a port\n\n"
717 "set port (port_id) queue-region flush (on|off)\n"
718 " flush all queue region related configuration\n\n"
720 "show port meter cap (port_id)\n"
721 " Show port meter capability information\n\n"
723 "add port meter profile srtcm_rfc2697 (port_id) (profile_id) (cir) (cbs) (ebs)\n"
724 " meter profile add - srtcm rfc 2697\n\n"
726 "add port meter profile trtcm_rfc2698 (port_id) (profile_id) (cir) (pir) (cbs) (pbs)\n"
727 " meter profile add - trtcm rfc 2698\n\n"
729 "add port meter profile trtcm_rfc4115 (port_id) (profile_id) (cir) (eir) (cbs) (ebs)\n"
730 " meter profile add - trtcm rfc 4115\n\n"
732 "del port meter profile (port_id) (profile_id)\n"
733 " meter profile delete\n\n"
735 "create port meter (port_id) (mtr_id) (profile_id) (meter_enable)\n"
736 "(g_action) (y_action) (r_action) (stats_mask) (shared)\n"
737 "(use_pre_meter_color) [(dscp_tbl_entry0) (dscp_tbl_entry1)...\n"
738 "(dscp_tbl_entry63)]\n"
741 "enable port meter (port_id) (mtr_id)\n"
744 "disable port meter (port_id) (mtr_id)\n"
747 "del port meter (port_id) (mtr_id)\n"
750 "set port meter profile (port_id) (mtr_id) (profile_id)\n"
751 " meter update meter profile\n\n"
753 "set port meter dscp table (port_id) (mtr_id) [(dscp_tbl_entry0)\n"
754 "(dscp_tbl_entry1)...(dscp_tbl_entry63)]\n"
755 " update meter dscp table entries\n\n"
757 "set port meter policer action (port_id) (mtr_id) (action_mask)\n"
758 "(action0) [(action1) (action2)]\n"
759 " meter update policer action\n\n"
761 "set port meter stats mask (port_id) (mtr_id) (stats_mask)\n"
762 " meter update stats\n\n"
764 "show port (port_id) queue-region\n"
765 " show all queue region related configuration info\n\n"
767 "set port (port_id) fec_mode auto|off|rs|baser\n"
768 " set fec mode for a specific port\n\n"
770 , list_pkt_forwarding_modes()
774 if (show_all || !strcmp(res->section, "ports")) {
780 "----------------\n\n"
782 "port start (port_id|all)\n"
783 " Start all ports or port_id.\n\n"
785 "port stop (port_id|all)\n"
786 " Stop all ports or port_id.\n\n"
788 "port close (port_id|all)\n"
789 " Close all ports or port_id.\n\n"
791 "port reset (port_id|all)\n"
792 " Reset all ports or port_id.\n\n"
794 "port attach (ident)\n"
795 " Attach physical or virtual dev by pci address or virtual device name\n\n"
797 "port detach (port_id)\n"
798 " Detach physical or virtual dev by port_id\n\n"
800 "port config (port_id|all)"
801 " speed (10|100|1000|10000|25000|40000|50000|100000|200000|auto)"
802 " duplex (half|full|auto)\n"
803 " Set speed and duplex for all ports or port_id\n\n"
805 "port config (port_id|all) loopback (mode)\n"
806 " Set loopback mode for all ports or port_id\n\n"
808 "port config all (rxq|txq|rxd|txd) (value)\n"
809 " Set number for rxq/txq/rxd/txd.\n\n"
811 "port config all max-pkt-len (value)\n"
812 " Set the max packet length.\n\n"
814 "port config all max-lro-pkt-size (value)\n"
815 " Set the max LRO aggregated packet size.\n\n"
817 "port config all drop-en (on|off)\n"
818 " Enable or disable packet drop on all RX queues of all ports when no "
819 "receive buffers available.\n\n"
821 "port config all rss (all|default|ip|tcp|udp|sctp|"
822 "ether|port|vxlan|geneve|nvgre|vxlan-gpe|none|level-default|"
823 "level-outer|level-inner|<flowtype_id>)\n"
824 " Set the RSS mode.\n\n"
826 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
827 " Set the RSS redirection table.\n\n"
829 "port config (port_id) dcb vt (on|off) (traffic_class)"
831 " Set the DCB mode.\n\n"
833 "port config all burst (value)\n"
834 " Set the number of packets per burst.\n\n"
836 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
838 " Set the ring prefetch/host/writeback threshold"
839 " for tx/rx queue.\n\n"
841 "port config all (txfreet|txrst|rxfreet) (value)\n"
842 " Set free threshold for rx/tx, or set"
843 " tx rs bit threshold.\n\n"
844 "port config mtu X value\n"
845 " Set the MTU of port X to a given value\n\n"
847 "port config (port_id) (rxq|txq) (queue_id) ring_size (value)\n"
848 " Set a rx/tx queue's ring size configuration, the new"
849 " value will take effect after command that (re-)start the port"
850 " or command that setup the specific queue\n\n"
852 "port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
853 " Start/stop a rx/tx queue of port X. Only take effect"
854 " when port X is started\n\n"
856 "port (port_id) (rxq|txq) (queue_id) deferred_start (on|off)\n"
857 " Switch on/off a deferred start of port X rx/tx queue. Only"
858 " take effect when port X is stopped.\n\n"
860 "port (port_id) (rxq|txq) (queue_id) setup\n"
861 " Setup a rx/tx queue of port X.\n\n"
863 "port config (port_id|all) l2-tunnel E-tag ether-type"
865 " Set the value of E-tag ether-type.\n\n"
867 "port config (port_id|all) l2-tunnel E-tag"
868 " (enable|disable)\n"
869 " Enable/disable the E-tag support.\n\n"
871 "port config (port_id) pctype mapping reset\n"
872 " Reset flow type to pctype mapping on a port\n\n"
874 "port config (port_id) pctype mapping update"
875 " (pctype_id_0[,pctype_id_1]*) (flow_type_id)\n"
876 " Update a flow type to pctype mapping item on a port\n\n"
878 "port config (port_id) pctype (pctype_id) hash_inset|"
879 "fdir_inset|fdir_flx_inset get|set|clear field\n"
881 " Configure RSS|FDIR|FDIR_FLX input set for some pctype\n\n"
883 "port config (port_id) pctype (pctype_id) hash_inset|"
884 "fdir_inset|fdir_flx_inset clear all"
885 " Clear RSS|FDIR|FDIR_FLX input set completely for some pctype\n\n"
887 "port config (port_id) udp_tunnel_port add|rm vxlan|geneve (udp_port)\n\n"
888 " Add/remove UDP tunnel port for tunneling offload\n\n"
890 "port config <port_id> rx_offload vlan_strip|"
891 "ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|"
892 "outer_ipv4_cksum|macsec_strip|header_split|"
893 "vlan_filter|vlan_extend|jumbo_frame|scatter|"
894 "buffer_split|timestamp|security|keep_crc on|off\n"
895 " Enable or disable a per port Rx offloading"
896 " on all Rx queues of a port\n\n"
898 "port (port_id) rxq (queue_id) rx_offload vlan_strip|"
899 "ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|"
900 "outer_ipv4_cksum|macsec_strip|header_split|"
901 "vlan_filter|vlan_extend|jumbo_frame|scatter|"
902 "buffer_split|timestamp|security|keep_crc on|off\n"
903 " Enable or disable a per queue Rx offloading"
904 " only on a specific Rx queue\n\n"
906 "port config (port_id) tx_offload vlan_insert|"
907 "ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|"
908 "udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|"
909 "gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|"
910 "macsec_insert|mt_lockfree|multi_segs|mbuf_fast_free|"
912 " Enable or disable a per port Tx offloading"
913 " on all Tx queues of a port\n\n"
915 "port (port_id) txq (queue_id) tx_offload vlan_insert|"
916 "ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|"
917 "udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|"
918 "gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|macsec_insert"
919 "|mt_lockfree|multi_segs|mbuf_fast_free|security"
921 " Enable or disable a per queue Tx offloading"
922 " only on a specific Tx queue\n\n"
924 "bpf-load rx|tx (port) (queue) (J|M|B) (file_name)\n"
925 " Load an eBPF program as a callback"
926 " for particular RX/TX queue\n\n"
928 "bpf-unload rx|tx (port) (queue)\n"
929 " Unload previously loaded eBPF program"
930 " for particular RX/TX queue\n\n"
932 "port config (port_id) tx_metadata (value)\n"
933 " Set Tx metadata value per port. Testpmd will add this value"
934 " to any Tx packet sent from this port\n\n"
936 "port config (port_id) dynf (name) set|clear\n"
937 " Register a dynf and Set/clear this flag on Tx. "
938 "Testpmd will set this value to any Tx packet "
939 "sent from this port\n\n"
943 if (show_all || !strcmp(res->section, "registers")) {
951 "read reg (port_id) (address)\n"
952 " Display value of a port register.\n\n"
954 "read regfield (port_id) (address) (bit_x) (bit_y)\n"
955 " Display a port register bit field.\n\n"
957 "read regbit (port_id) (address) (bit_x)\n"
958 " Display a single port register bit.\n\n"
960 "write reg (port_id) (address) (value)\n"
961 " Set value of a port register.\n\n"
963 "write regfield (port_id) (address) (bit_x) (bit_y)"
965 " Set bit field of a port register.\n\n"
967 "write regbit (port_id) (address) (bit_x) (value)\n"
968 " Set single bit value of a port register.\n\n"
971 if (show_all || !strcmp(res->section, "filters")) {
979 "2tuple_filter (port_id) (add|del)"
980 " dst_port (dst_port_value) protocol (protocol_value)"
981 " mask (mask_value) tcp_flags (tcp_flags_value)"
982 " priority (prio_value) queue (queue_id)\n"
983 " Add/Del a 2tuple filter.\n\n"
985 "5tuple_filter (port_id) (add|del)"
986 " dst_ip (dst_address) src_ip (src_address)"
987 " dst_port (dst_port_value) src_port (src_port_value)"
988 " protocol (protocol_value)"
989 " mask (mask_value) tcp_flags (tcp_flags_value)"
990 " priority (prio_value) queue (queue_id)\n"
991 " Add/Del a 5tuple filter.\n\n"
993 "syn_filter (port_id) (add|del) priority (high|low) queue (queue_id)"
994 " Add/Del syn filter.\n\n"
996 "flow_director_filter (port_id) mode IP (add|del|update)"
997 " flow (ipv4-other|ipv4-frag|ipv6-other|ipv6-frag)"
998 " src (src_ip_address) dst (dst_ip_address)"
999 " tos (tos_value) proto (proto_value) ttl (ttl_value)"
1000 " vlan (vlan_value) flexbytes (flexbytes_value)"
1001 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
1002 " fd_id (fd_id_value)\n"
1003 " Add/Del an IP type flow director filter.\n\n"
1005 "flow_director_filter (port_id) mode IP (add|del|update)"
1006 " flow (ipv4-tcp|ipv4-udp|ipv6-tcp|ipv6-udp)"
1007 " src (src_ip_address) (src_port)"
1008 " dst (dst_ip_address) (dst_port)"
1009 " tos (tos_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 UDP/TCP type flow director filter.\n\n"
1015 "flow_director_filter (port_id) mode IP (add|del|update)"
1016 " flow (ipv4-sctp|ipv6-sctp)"
1017 " src (src_ip_address) (src_port)"
1018 " dst (dst_ip_address) (dst_port)"
1019 " tag (verification_tag) "
1020 " tos (tos_value) ttl (ttl_value)"
1021 " vlan (vlan_value)"
1022 " flexbytes (flexbytes_value) (drop|fwd)"
1023 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
1024 " Add/Del a SCTP type flow director filter.\n\n"
1026 "flow_director_filter (port_id) mode IP (add|del|update)"
1027 " flow l2_payload ether (ethertype)"
1028 " flexbytes (flexbytes_value) (drop|fwd)"
1029 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
1030 " Add/Del a l2 payload type flow director filter.\n\n"
1032 "flow_director_filter (port_id) mode MAC-VLAN (add|del|update)"
1033 " mac (mac_address) vlan (vlan_value)"
1034 " flexbytes (flexbytes_value) (drop|fwd)"
1035 " queue (queue_id) fd_id (fd_id_value)\n"
1036 " Add/Del a MAC-VLAN flow director filter.\n\n"
1038 "flow_director_filter (port_id) mode Tunnel (add|del|update)"
1039 " mac (mac_address) vlan (vlan_value)"
1040 " tunnel (NVGRE|VxLAN) tunnel-id (tunnel_id_value)"
1041 " flexbytes (flexbytes_value) (drop|fwd)"
1042 " queue (queue_id) fd_id (fd_id_value)\n"
1043 " Add/Del a Tunnel flow director filter.\n\n"
1045 "flow_director_filter (port_id) mode raw (add|del|update)"
1046 " flow (flow_id) (drop|fwd) queue (queue_id)"
1047 " fd_id (fd_id_value) packet (packet file name)\n"
1048 " Add/Del a raw type flow director filter.\n\n"
1050 "flush_flow_director (port_id)\n"
1051 " Flush all flow director entries of a device.\n\n"
1053 "flow_director_mask (port_id) mode IP vlan (vlan_value)"
1054 " src_mask (ipv4_src) (ipv6_src) (src_port)"
1055 " dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n"
1056 " Set flow director IP mask.\n\n"
1058 "flow_director_mask (port_id) mode MAC-VLAN"
1059 " vlan (vlan_value)\n"
1060 " Set flow director MAC-VLAN mask.\n\n"
1062 "flow_director_mask (port_id) mode Tunnel"
1063 " vlan (vlan_value) mac (mac_value)"
1064 " tunnel-type (tunnel_type_value)"
1065 " tunnel-id (tunnel_id_value)\n"
1066 " Set flow director Tunnel mask.\n\n"
1068 "flow_director_flex_mask (port_id)"
1069 " flow (none|ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
1070 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|l2_payload|all)"
1072 " Configure mask of flex payload.\n\n"
1074 "flow_director_flex_payload (port_id)"
1075 " (raw|l2|l3|l4) (config)\n"
1076 " Configure flex payload selection.\n\n"
1078 "get_sym_hash_ena_per_port (port_id)\n"
1079 " get symmetric hash enable configuration per port.\n\n"
1081 "set_sym_hash_ena_per_port (port_id) (enable|disable)\n"
1082 " set symmetric hash enable configuration per port"
1083 " to enable or disable.\n\n"
1085 "get_hash_global_config (port_id)\n"
1086 " Get the global configurations of hash filters.\n\n"
1088 "set_hash_global_config (port_id) (toeplitz|simple_xor|symmetric_toeplitz|default)"
1089 " (ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
1090 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload)"
1091 " (enable|disable)\n"
1092 " Set the global configurations of hash filters.\n\n"
1094 "set_hash_input_set (port_id) (ipv4|ipv4-frag|"
1095 "ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
1096 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1097 "l2_payload|<flowtype_id>) (ovlan|ivlan|src-ipv4|dst-ipv4|"
1098 "src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|ipv6-tc|"
1099 "ipv6-next-header|udp-src-port|udp-dst-port|"
1100 "tcp-src-port|tcp-dst-port|sctp-src-port|"
1101 "sctp-dst-port|sctp-veri-tag|udp-key|gre-key|fld-1st|"
1102 "fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|fld-7th|"
1103 "fld-8th|none) (select|add)\n"
1104 " Set the input set for hash.\n\n"
1106 "set_fdir_input_set (port_id) "
1107 "(ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
1108 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1109 "l2_payload) (ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|"
1110 "dst-ipv6|ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|"
1111 "ipv6-next-header|ipv6-hop-limits|udp-src-port|"
1112 "udp-dst-port|tcp-src-port|tcp-dst-port|"
1113 "sctp-src-port|sctp-dst-port|sctp-veri-tag|none)"
1115 " Set the input set for FDir.\n\n"
1117 "flow validate {port_id}"
1118 " [group {group_id}] [priority {level}]"
1119 " [ingress] [egress]"
1120 " pattern {item} [/ {item} [...]] / end"
1121 " actions {action} [/ {action} [...]] / end\n"
1122 " Check whether a flow rule can be created.\n\n"
1124 "flow create {port_id}"
1125 " [group {group_id}] [priority {level}]"
1126 " [ingress] [egress]"
1127 " pattern {item} [/ {item} [...]] / end"
1128 " actions {action} [/ {action} [...]] / end\n"
1129 " Create a flow rule.\n\n"
1131 "flow destroy {port_id} rule {rule_id} [...]\n"
1132 " Destroy specific flow rules.\n\n"
1134 "flow flush {port_id}\n"
1135 " Destroy all flow rules.\n\n"
1137 "flow query {port_id} {rule_id} {action}\n"
1138 " Query an existing flow rule.\n\n"
1140 "flow list {port_id} [group {group_id}] [...]\n"
1141 " List existing flow rules sorted by priority,"
1142 " filtered by group identifiers.\n\n"
1144 "flow isolate {port_id} {boolean}\n"
1145 " Restrict ingress traffic to the defined"
1148 "flow aged {port_id} [destroy]\n"
1149 " List and destroy aged flows"
1152 "flow shared_action {port_id} create"
1153 " [action_id {shared_action_id}]"
1154 " [ingress] [egress]"
1155 " action {action} / end\n"
1156 " Create shared action.\n\n"
1158 "flow shared_action {port_id} update"
1159 " {shared_action_id} action {action} / end\n"
1160 " Update shared action.\n\n"
1162 "flow shared_action {port_id} destroy"
1163 " action_id {shared_action_id} [...]\n"
1164 " Destroy specific shared actions.\n\n"
1166 "flow shared_action {port_id} query"
1167 " {shared_action_id}\n"
1168 " Query an existing shared action.\n\n"
1170 "set vxlan ip-version (ipv4|ipv6) vni (vni) udp-src"
1171 " (udp-src) udp-dst (udp-dst) ip-src (ip-src) ip-dst"
1172 " (ip-dst) eth-src (eth-src) eth-dst (eth-dst)\n"
1173 " Configure the VXLAN encapsulation for flows.\n\n"
1175 "set vxlan-with-vlan ip-version (ipv4|ipv6) vni (vni)"
1176 " udp-src (udp-src) udp-dst (udp-dst) ip-src (ip-src)"
1177 " ip-dst (ip-dst) vlan-tci (vlan-tci) eth-src (eth-src)"
1178 " eth-dst (eth-dst)\n"
1179 " Configure the VXLAN encapsulation for flows.\n\n"
1181 "set vxlan-tos-ttl ip-version (ipv4|ipv6) vni (vni) udp-src"
1182 " (udp-src) udp-dst (udp-dst) ip-tos (ip-tos) ip-ttl (ip-ttl)"
1183 " ip-src (ip-src) ip-dst (ip-dst) eth-src (eth-src)"
1184 " eth-dst (eth-dst)\n"
1185 " Configure the VXLAN encapsulation for flows.\n\n"
1187 "set nvgre ip-version (ipv4|ipv6) tni (tni) ip-src"
1188 " (ip-src) ip-dst (ip-dst) eth-src (eth-src) eth-dst"
1190 " Configure the NVGRE encapsulation for flows.\n\n"
1192 "set nvgre-with-vlan ip-version (ipv4|ipv6) tni (tni)"
1193 " ip-src (ip-src) ip-dst (ip-dst) vlan-tci (vlan-tci)"
1194 " eth-src (eth-src) eth-dst (eth-dst)\n"
1195 " Configure the NVGRE encapsulation for flows.\n\n"
1197 "set raw_encap {flow items}\n"
1198 " Configure the encapsulation with raw data.\n\n"
1200 "set raw_decap {flow items}\n"
1201 " Configure the decapsulation with raw data.\n\n"
1206 if (show_all || !strcmp(res->section, "traffic_management")) {
1210 "Traffic Management:\n"
1212 "show port tm cap (port_id)\n"
1213 " Display the port TM capability.\n\n"
1215 "show port tm level cap (port_id) (level_id)\n"
1216 " Display the port TM hierarchical level capability.\n\n"
1218 "show port tm node cap (port_id) (node_id)\n"
1219 " Display the port TM node capability.\n\n"
1221 "show port tm node type (port_id) (node_id)\n"
1222 " Display the port TM node type.\n\n"
1224 "show port tm node stats (port_id) (node_id) (clear)\n"
1225 " Display the port TM node stats.\n\n"
1227 "add port tm node shaper profile (port_id) (shaper_profile_id)"
1228 " (cmit_tb_rate) (cmit_tb_size) (peak_tb_rate) (peak_tb_size)"
1229 " (packet_length_adjust) (packet_mode)\n"
1230 " Add port tm node private shaper profile.\n\n"
1232 "del port tm node shaper profile (port_id) (shaper_profile_id)\n"
1233 " Delete port tm node private shaper profile.\n\n"
1235 "add port tm node shared shaper (port_id) (shared_shaper_id)"
1236 " (shaper_profile_id)\n"
1237 " Add/update port tm node shared shaper.\n\n"
1239 "del port tm node shared shaper (port_id) (shared_shaper_id)\n"
1240 " Delete port tm node shared shaper.\n\n"
1242 "set port tm node shaper profile (port_id) (node_id)"
1243 " (shaper_profile_id)\n"
1244 " Set port tm node shaper profile.\n\n"
1246 "add port tm node wred profile (port_id) (wred_profile_id)"
1247 " (color_g) (min_th_g) (max_th_g) (maxp_inv_g) (wq_log2_g)"
1248 " (color_y) (min_th_y) (max_th_y) (maxp_inv_y) (wq_log2_y)"
1249 " (color_r) (min_th_r) (max_th_r) (maxp_inv_r) (wq_log2_r)\n"
1250 " Add port tm node wred profile.\n\n"
1252 "del port tm node wred profile (port_id) (wred_profile_id)\n"
1253 " Delete port tm node wred profile.\n\n"
1255 "add port tm nonleaf node (port_id) (node_id) (parent_node_id)"
1256 " (priority) (weight) (level_id) (shaper_profile_id)"
1257 " (n_sp_priorities) (stats_mask) (n_shared_shapers)"
1258 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1259 " Add port tm nonleaf node.\n\n"
1261 "add port tm nonleaf node pktmode (port_id) (node_id) (parent_node_id)"
1262 " (priority) (weight) (level_id) (shaper_profile_id)"
1263 " (n_sp_priorities) (stats_mask) (n_shared_shapers)"
1264 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1265 " Add port tm nonleaf node with pkt mode enabled.\n\n"
1267 "add port tm leaf node (port_id) (node_id) (parent_node_id)"
1268 " (priority) (weight) (level_id) (shaper_profile_id)"
1269 " (cman_mode) (wred_profile_id) (stats_mask) (n_shared_shapers)"
1270 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1271 " Add port tm leaf node.\n\n"
1273 "del port tm node (port_id) (node_id)\n"
1274 " Delete port tm node.\n\n"
1276 "set port tm node parent (port_id) (node_id) (parent_node_id)"
1277 " (priority) (weight)\n"
1278 " Set port tm node parent.\n\n"
1280 "suspend port tm node (port_id) (node_id)"
1281 " Suspend tm node.\n\n"
1283 "resume port tm node (port_id) (node_id)"
1284 " Resume tm node.\n\n"
1286 "port tm hierarchy commit (port_id) (clean_on_fail)\n"
1287 " Commit tm hierarchy.\n\n"
1289 "set port tm mark ip_ecn (port) (green) (yellow)"
1291 " Enables/Disables the traffic management marking"
1292 " for IP ECN (Explicit Congestion Notification)"
1293 " packets on a given port\n\n"
1295 "set port tm mark ip_dscp (port) (green) (yellow)"
1297 " Enables/Disables the traffic management marking"
1298 " on the port for IP dscp packets\n\n"
1300 "set port tm mark vlan_dei (port) (green) (yellow)"
1302 " Enables/Disables the traffic management marking"
1303 " on the port for VLAN packets with DEI enabled\n\n"
1307 if (show_all || !strcmp(res->section, "devices")) {
1311 "Device Operations:\n"
1313 "device detach (identifier)\n"
1314 " Detach device by identifier.\n\n"
1320 cmdline_parse_token_string_t cmd_help_long_help =
1321 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
1323 cmdline_parse_token_string_t cmd_help_long_section =
1324 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
1325 "all#control#display#config#"
1326 "ports#registers#filters#traffic_management#devices");
1328 cmdline_parse_inst_t cmd_help_long = {
1329 .f = cmd_help_long_parsed,
1331 .help_str = "help all|control|display|config|ports|register|"
1332 "filters|traffic_management|devices: "
1335 (void *)&cmd_help_long_help,
1336 (void *)&cmd_help_long_section,
1342 /* *** start/stop/close all ports *** */
1343 struct cmd_operate_port_result {
1344 cmdline_fixed_string_t keyword;
1345 cmdline_fixed_string_t name;
1346 cmdline_fixed_string_t value;
1349 static void cmd_operate_port_parsed(void *parsed_result,
1350 __rte_unused struct cmdline *cl,
1351 __rte_unused void *data)
1353 struct cmd_operate_port_result *res = parsed_result;
1355 if (!strcmp(res->name, "start"))
1356 start_port(RTE_PORT_ALL);
1357 else if (!strcmp(res->name, "stop"))
1358 stop_port(RTE_PORT_ALL);
1359 else if (!strcmp(res->name, "close"))
1360 close_port(RTE_PORT_ALL);
1361 else if (!strcmp(res->name, "reset"))
1362 reset_port(RTE_PORT_ALL);
1364 printf("Unknown parameter\n");
1367 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
1368 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
1370 cmdline_parse_token_string_t cmd_operate_port_all_port =
1371 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
1372 "start#stop#close#reset");
1373 cmdline_parse_token_string_t cmd_operate_port_all_all =
1374 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
1376 cmdline_parse_inst_t cmd_operate_port = {
1377 .f = cmd_operate_port_parsed,
1379 .help_str = "port start|stop|close all: Start/Stop/Close/Reset all ports",
1381 (void *)&cmd_operate_port_all_cmd,
1382 (void *)&cmd_operate_port_all_port,
1383 (void *)&cmd_operate_port_all_all,
1388 /* *** start/stop/close specific port *** */
1389 struct cmd_operate_specific_port_result {
1390 cmdline_fixed_string_t keyword;
1391 cmdline_fixed_string_t name;
1395 static void cmd_operate_specific_port_parsed(void *parsed_result,
1396 __rte_unused struct cmdline *cl,
1397 __rte_unused void *data)
1399 struct cmd_operate_specific_port_result *res = parsed_result;
1401 if (!strcmp(res->name, "start"))
1402 start_port(res->value);
1403 else if (!strcmp(res->name, "stop"))
1404 stop_port(res->value);
1405 else if (!strcmp(res->name, "close"))
1406 close_port(res->value);
1407 else if (!strcmp(res->name, "reset"))
1408 reset_port(res->value);
1410 printf("Unknown parameter\n");
1413 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
1414 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1416 cmdline_parse_token_string_t cmd_operate_specific_port_port =
1417 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1418 name, "start#stop#close#reset");
1419 cmdline_parse_token_num_t cmd_operate_specific_port_id =
1420 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
1423 cmdline_parse_inst_t cmd_operate_specific_port = {
1424 .f = cmd_operate_specific_port_parsed,
1426 .help_str = "port start|stop|close <port_id>: Start/Stop/Close/Reset port_id",
1428 (void *)&cmd_operate_specific_port_cmd,
1429 (void *)&cmd_operate_specific_port_port,
1430 (void *)&cmd_operate_specific_port_id,
1435 /* *** enable port setup (after attach) via iterator or event *** */
1436 struct cmd_set_port_setup_on_result {
1437 cmdline_fixed_string_t set;
1438 cmdline_fixed_string_t port;
1439 cmdline_fixed_string_t setup;
1440 cmdline_fixed_string_t on;
1441 cmdline_fixed_string_t mode;
1444 static void cmd_set_port_setup_on_parsed(void *parsed_result,
1445 __rte_unused struct cmdline *cl,
1446 __rte_unused void *data)
1448 struct cmd_set_port_setup_on_result *res = parsed_result;
1450 if (strcmp(res->mode, "event") == 0)
1451 setup_on_probe_event = true;
1452 else if (strcmp(res->mode, "iterator") == 0)
1453 setup_on_probe_event = false;
1455 printf("Unknown mode\n");
1458 cmdline_parse_token_string_t cmd_set_port_setup_on_set =
1459 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1461 cmdline_parse_token_string_t cmd_set_port_setup_on_port =
1462 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1464 cmdline_parse_token_string_t cmd_set_port_setup_on_setup =
1465 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1467 cmdline_parse_token_string_t cmd_set_port_setup_on_on =
1468 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1470 cmdline_parse_token_string_t cmd_set_port_setup_on_mode =
1471 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1472 mode, "iterator#event");
1474 cmdline_parse_inst_t cmd_set_port_setup_on = {
1475 .f = cmd_set_port_setup_on_parsed,
1477 .help_str = "set port setup on iterator|event",
1479 (void *)&cmd_set_port_setup_on_set,
1480 (void *)&cmd_set_port_setup_on_port,
1481 (void *)&cmd_set_port_setup_on_setup,
1482 (void *)&cmd_set_port_setup_on_on,
1483 (void *)&cmd_set_port_setup_on_mode,
1488 /* *** attach a specified port *** */
1489 struct cmd_operate_attach_port_result {
1490 cmdline_fixed_string_t port;
1491 cmdline_fixed_string_t keyword;
1492 cmdline_multi_string_t identifier;
1495 static void cmd_operate_attach_port_parsed(void *parsed_result,
1496 __rte_unused struct cmdline *cl,
1497 __rte_unused void *data)
1499 struct cmd_operate_attach_port_result *res = parsed_result;
1501 if (!strcmp(res->keyword, "attach"))
1502 attach_port(res->identifier);
1504 printf("Unknown parameter\n");
1507 cmdline_parse_token_string_t cmd_operate_attach_port_port =
1508 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1510 cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
1511 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1513 cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
1514 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1515 identifier, TOKEN_STRING_MULTI);
1517 cmdline_parse_inst_t cmd_operate_attach_port = {
1518 .f = cmd_operate_attach_port_parsed,
1520 .help_str = "port attach <identifier>: "
1521 "(identifier: pci address or virtual dev name)",
1523 (void *)&cmd_operate_attach_port_port,
1524 (void *)&cmd_operate_attach_port_keyword,
1525 (void *)&cmd_operate_attach_port_identifier,
1530 /* *** detach a specified port *** */
1531 struct cmd_operate_detach_port_result {
1532 cmdline_fixed_string_t port;
1533 cmdline_fixed_string_t keyword;
1537 static void cmd_operate_detach_port_parsed(void *parsed_result,
1538 __rte_unused struct cmdline *cl,
1539 __rte_unused void *data)
1541 struct cmd_operate_detach_port_result *res = parsed_result;
1543 if (!strcmp(res->keyword, "detach")) {
1544 RTE_ETH_VALID_PORTID_OR_RET(res->port_id);
1545 detach_port_device(res->port_id);
1547 printf("Unknown parameter\n");
1551 cmdline_parse_token_string_t cmd_operate_detach_port_port =
1552 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1554 cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
1555 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1557 cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
1558 TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
1561 cmdline_parse_inst_t cmd_operate_detach_port = {
1562 .f = cmd_operate_detach_port_parsed,
1564 .help_str = "port detach <port_id>",
1566 (void *)&cmd_operate_detach_port_port,
1567 (void *)&cmd_operate_detach_port_keyword,
1568 (void *)&cmd_operate_detach_port_port_id,
1573 /* *** detach device by identifier *** */
1574 struct cmd_operate_detach_device_result {
1575 cmdline_fixed_string_t device;
1576 cmdline_fixed_string_t keyword;
1577 cmdline_fixed_string_t identifier;
1580 static void cmd_operate_detach_device_parsed(void *parsed_result,
1581 __rte_unused struct cmdline *cl,
1582 __rte_unused void *data)
1584 struct cmd_operate_detach_device_result *res = parsed_result;
1586 if (!strcmp(res->keyword, "detach"))
1587 detach_devargs(res->identifier);
1589 printf("Unknown parameter\n");
1592 cmdline_parse_token_string_t cmd_operate_detach_device_device =
1593 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1595 cmdline_parse_token_string_t cmd_operate_detach_device_keyword =
1596 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1598 cmdline_parse_token_string_t cmd_operate_detach_device_identifier =
1599 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1602 cmdline_parse_inst_t cmd_operate_detach_device = {
1603 .f = cmd_operate_detach_device_parsed,
1605 .help_str = "device detach <identifier>:"
1606 "(identifier: pci address or virtual dev name)",
1608 (void *)&cmd_operate_detach_device_device,
1609 (void *)&cmd_operate_detach_device_keyword,
1610 (void *)&cmd_operate_detach_device_identifier,
1614 /* *** configure speed for all ports *** */
1615 struct cmd_config_speed_all {
1616 cmdline_fixed_string_t port;
1617 cmdline_fixed_string_t keyword;
1618 cmdline_fixed_string_t all;
1619 cmdline_fixed_string_t item1;
1620 cmdline_fixed_string_t item2;
1621 cmdline_fixed_string_t value1;
1622 cmdline_fixed_string_t value2;
1626 parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed)
1631 if (!strcmp(duplexstr, "half")) {
1632 duplex = ETH_LINK_HALF_DUPLEX;
1633 } else if (!strcmp(duplexstr, "full")) {
1634 duplex = ETH_LINK_FULL_DUPLEX;
1635 } else if (!strcmp(duplexstr, "auto")) {
1636 duplex = ETH_LINK_FULL_DUPLEX;
1638 printf("Unknown duplex parameter\n");
1642 if (!strcmp(speedstr, "10")) {
1643 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1644 ETH_LINK_SPEED_10M_HD : ETH_LINK_SPEED_10M;
1645 } else if (!strcmp(speedstr, "100")) {
1646 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1647 ETH_LINK_SPEED_100M_HD : ETH_LINK_SPEED_100M;
1649 if (duplex != ETH_LINK_FULL_DUPLEX) {
1650 printf("Invalid speed/duplex parameters\n");
1653 if (!strcmp(speedstr, "1000")) {
1654 *speed = ETH_LINK_SPEED_1G;
1655 } else if (!strcmp(speedstr, "10000")) {
1656 *speed = ETH_LINK_SPEED_10G;
1657 } else if (!strcmp(speedstr, "25000")) {
1658 *speed = ETH_LINK_SPEED_25G;
1659 } else if (!strcmp(speedstr, "40000")) {
1660 *speed = ETH_LINK_SPEED_40G;
1661 } else if (!strcmp(speedstr, "50000")) {
1662 *speed = ETH_LINK_SPEED_50G;
1663 } else if (!strcmp(speedstr, "100000")) {
1664 *speed = ETH_LINK_SPEED_100G;
1665 } else if (!strcmp(speedstr, "200000")) {
1666 *speed = ETH_LINK_SPEED_200G;
1667 } else if (!strcmp(speedstr, "auto")) {
1668 *speed = ETH_LINK_SPEED_AUTONEG;
1670 printf("Unknown speed parameter\n");
1679 cmd_config_speed_all_parsed(void *parsed_result,
1680 __rte_unused struct cmdline *cl,
1681 __rte_unused void *data)
1683 struct cmd_config_speed_all *res = parsed_result;
1684 uint32_t link_speed;
1687 if (!all_ports_stopped()) {
1688 printf("Please stop all ports first\n");
1692 if (parse_and_check_speed_duplex(res->value1, res->value2,
1696 RTE_ETH_FOREACH_DEV(pid) {
1697 ports[pid].dev_conf.link_speeds = link_speed;
1700 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1703 cmdline_parse_token_string_t cmd_config_speed_all_port =
1704 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1705 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1706 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1708 cmdline_parse_token_string_t cmd_config_speed_all_all =
1709 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1710 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1711 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1712 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1713 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1714 "10#100#1000#10000#25000#40000#50000#100000#200000#auto");
1715 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1716 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1717 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1718 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1721 cmdline_parse_inst_t cmd_config_speed_all = {
1722 .f = cmd_config_speed_all_parsed,
1724 .help_str = "port config all speed "
1725 "10|100|1000|10000|25000|40000|50000|100000|200000|auto duplex "
1728 (void *)&cmd_config_speed_all_port,
1729 (void *)&cmd_config_speed_all_keyword,
1730 (void *)&cmd_config_speed_all_all,
1731 (void *)&cmd_config_speed_all_item1,
1732 (void *)&cmd_config_speed_all_value1,
1733 (void *)&cmd_config_speed_all_item2,
1734 (void *)&cmd_config_speed_all_value2,
1739 /* *** configure speed for specific port *** */
1740 struct cmd_config_speed_specific {
1741 cmdline_fixed_string_t port;
1742 cmdline_fixed_string_t keyword;
1744 cmdline_fixed_string_t item1;
1745 cmdline_fixed_string_t item2;
1746 cmdline_fixed_string_t value1;
1747 cmdline_fixed_string_t value2;
1751 cmd_config_speed_specific_parsed(void *parsed_result,
1752 __rte_unused struct cmdline *cl,
1753 __rte_unused void *data)
1755 struct cmd_config_speed_specific *res = parsed_result;
1756 uint32_t link_speed;
1758 if (!all_ports_stopped()) {
1759 printf("Please stop all ports first\n");
1763 if (port_id_is_invalid(res->id, ENABLED_WARN))
1766 if (parse_and_check_speed_duplex(res->value1, res->value2,
1770 ports[res->id].dev_conf.link_speeds = link_speed;
1772 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1776 cmdline_parse_token_string_t cmd_config_speed_specific_port =
1777 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1779 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1780 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1782 cmdline_parse_token_num_t cmd_config_speed_specific_id =
1783 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT16);
1784 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1785 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1787 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1788 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1789 "10#100#1000#10000#25000#40000#50000#100000#200000#auto");
1790 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1791 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1793 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1794 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1797 cmdline_parse_inst_t cmd_config_speed_specific = {
1798 .f = cmd_config_speed_specific_parsed,
1800 .help_str = "port config <port_id> speed "
1801 "10|100|1000|10000|25000|40000|50000|100000|200000|auto duplex "
1804 (void *)&cmd_config_speed_specific_port,
1805 (void *)&cmd_config_speed_specific_keyword,
1806 (void *)&cmd_config_speed_specific_id,
1807 (void *)&cmd_config_speed_specific_item1,
1808 (void *)&cmd_config_speed_specific_value1,
1809 (void *)&cmd_config_speed_specific_item2,
1810 (void *)&cmd_config_speed_specific_value2,
1815 /* *** configure loopback for all ports *** */
1816 struct cmd_config_loopback_all {
1817 cmdline_fixed_string_t port;
1818 cmdline_fixed_string_t keyword;
1819 cmdline_fixed_string_t all;
1820 cmdline_fixed_string_t item;
1825 cmd_config_loopback_all_parsed(void *parsed_result,
1826 __rte_unused struct cmdline *cl,
1827 __rte_unused void *data)
1829 struct cmd_config_loopback_all *res = parsed_result;
1832 if (!all_ports_stopped()) {
1833 printf("Please stop all ports first\n");
1837 RTE_ETH_FOREACH_DEV(pid) {
1838 ports[pid].dev_conf.lpbk_mode = res->mode;
1841 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1844 cmdline_parse_token_string_t cmd_config_loopback_all_port =
1845 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, port, "port");
1846 cmdline_parse_token_string_t cmd_config_loopback_all_keyword =
1847 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, keyword,
1849 cmdline_parse_token_string_t cmd_config_loopback_all_all =
1850 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, all, "all");
1851 cmdline_parse_token_string_t cmd_config_loopback_all_item =
1852 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, item,
1854 cmdline_parse_token_num_t cmd_config_loopback_all_mode =
1855 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_all, mode, UINT32);
1857 cmdline_parse_inst_t cmd_config_loopback_all = {
1858 .f = cmd_config_loopback_all_parsed,
1860 .help_str = "port config all loopback <mode>",
1862 (void *)&cmd_config_loopback_all_port,
1863 (void *)&cmd_config_loopback_all_keyword,
1864 (void *)&cmd_config_loopback_all_all,
1865 (void *)&cmd_config_loopback_all_item,
1866 (void *)&cmd_config_loopback_all_mode,
1871 /* *** configure loopback for specific port *** */
1872 struct cmd_config_loopback_specific {
1873 cmdline_fixed_string_t port;
1874 cmdline_fixed_string_t keyword;
1876 cmdline_fixed_string_t item;
1881 cmd_config_loopback_specific_parsed(void *parsed_result,
1882 __rte_unused struct cmdline *cl,
1883 __rte_unused void *data)
1885 struct cmd_config_loopback_specific *res = parsed_result;
1887 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
1890 if (!port_is_stopped(res->port_id)) {
1891 printf("Please stop port %u first\n", res->port_id);
1895 ports[res->port_id].dev_conf.lpbk_mode = res->mode;
1897 cmd_reconfig_device_queue(res->port_id, 1, 1);
1901 cmdline_parse_token_string_t cmd_config_loopback_specific_port =
1902 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, port,
1904 cmdline_parse_token_string_t cmd_config_loopback_specific_keyword =
1905 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, keyword,
1907 cmdline_parse_token_num_t cmd_config_loopback_specific_id =
1908 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, port_id,
1910 cmdline_parse_token_string_t cmd_config_loopback_specific_item =
1911 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, item,
1913 cmdline_parse_token_num_t cmd_config_loopback_specific_mode =
1914 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, mode,
1917 cmdline_parse_inst_t cmd_config_loopback_specific = {
1918 .f = cmd_config_loopback_specific_parsed,
1920 .help_str = "port config <port_id> loopback <mode>",
1922 (void *)&cmd_config_loopback_specific_port,
1923 (void *)&cmd_config_loopback_specific_keyword,
1924 (void *)&cmd_config_loopback_specific_id,
1925 (void *)&cmd_config_loopback_specific_item,
1926 (void *)&cmd_config_loopback_specific_mode,
1931 /* *** configure txq/rxq, txd/rxd *** */
1932 struct cmd_config_rx_tx {
1933 cmdline_fixed_string_t port;
1934 cmdline_fixed_string_t keyword;
1935 cmdline_fixed_string_t all;
1936 cmdline_fixed_string_t name;
1941 cmd_config_rx_tx_parsed(void *parsed_result,
1942 __rte_unused struct cmdline *cl,
1943 __rte_unused void *data)
1945 struct cmd_config_rx_tx *res = parsed_result;
1947 if (!all_ports_stopped()) {
1948 printf("Please stop all ports first\n");
1951 if (!strcmp(res->name, "rxq")) {
1952 if (!res->value && !nb_txq) {
1953 printf("Warning: Either rx or tx queues should be non zero\n");
1956 if (check_nb_rxq(res->value) != 0)
1958 nb_rxq = res->value;
1960 else if (!strcmp(res->name, "txq")) {
1961 if (!res->value && !nb_rxq) {
1962 printf("Warning: Either rx or tx queues should be non zero\n");
1965 if (check_nb_txq(res->value) != 0)
1967 nb_txq = res->value;
1969 else if (!strcmp(res->name, "rxd")) {
1970 if (check_nb_rxd(res->value) != 0)
1972 nb_rxd = res->value;
1973 } else if (!strcmp(res->name, "txd")) {
1974 if (check_nb_txd(res->value) != 0)
1977 nb_txd = res->value;
1979 printf("Unknown parameter\n");
1987 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1990 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1991 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1992 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1993 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1994 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1995 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1996 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1997 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1999 cmdline_parse_token_num_t cmd_config_rx_tx_value =
2000 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
2002 cmdline_parse_inst_t cmd_config_rx_tx = {
2003 .f = cmd_config_rx_tx_parsed,
2005 .help_str = "port config all rxq|txq|rxd|txd <value>",
2007 (void *)&cmd_config_rx_tx_port,
2008 (void *)&cmd_config_rx_tx_keyword,
2009 (void *)&cmd_config_rx_tx_all,
2010 (void *)&cmd_config_rx_tx_name,
2011 (void *)&cmd_config_rx_tx_value,
2016 /* *** config max packet length *** */
2017 struct cmd_config_max_pkt_len_result {
2018 cmdline_fixed_string_t port;
2019 cmdline_fixed_string_t keyword;
2020 cmdline_fixed_string_t all;
2021 cmdline_fixed_string_t name;
2026 cmd_config_max_pkt_len_parsed(void *parsed_result,
2027 __rte_unused struct cmdline *cl,
2028 __rte_unused void *data)
2030 struct cmd_config_max_pkt_len_result *res = parsed_result;
2033 if (!all_ports_stopped()) {
2034 printf("Please stop all ports first\n");
2038 RTE_ETH_FOREACH_DEV(pid) {
2039 struct rte_port *port = &ports[pid];
2040 uint64_t rx_offloads = port->dev_conf.rxmode.offloads;
2042 if (!strcmp(res->name, "max-pkt-len")) {
2043 if (res->value < RTE_ETHER_MIN_LEN) {
2044 printf("max-pkt-len can not be less than %d\n",
2048 if (res->value == port->dev_conf.rxmode.max_rx_pkt_len)
2051 port->dev_conf.rxmode.max_rx_pkt_len = res->value;
2052 if (res->value > RTE_ETHER_MAX_LEN)
2053 rx_offloads |= DEV_RX_OFFLOAD_JUMBO_FRAME;
2055 rx_offloads &= ~DEV_RX_OFFLOAD_JUMBO_FRAME;
2056 port->dev_conf.rxmode.offloads = rx_offloads;
2058 printf("Unknown parameter\n");
2065 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2068 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
2069 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
2071 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
2072 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
2074 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
2075 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
2077 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
2078 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
2080 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
2081 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
2084 cmdline_parse_inst_t cmd_config_max_pkt_len = {
2085 .f = cmd_config_max_pkt_len_parsed,
2087 .help_str = "port config all max-pkt-len <value>",
2089 (void *)&cmd_config_max_pkt_len_port,
2090 (void *)&cmd_config_max_pkt_len_keyword,
2091 (void *)&cmd_config_max_pkt_len_all,
2092 (void *)&cmd_config_max_pkt_len_name,
2093 (void *)&cmd_config_max_pkt_len_value,
2098 /* *** config max LRO aggregated packet size *** */
2099 struct cmd_config_max_lro_pkt_size_result {
2100 cmdline_fixed_string_t port;
2101 cmdline_fixed_string_t keyword;
2102 cmdline_fixed_string_t all;
2103 cmdline_fixed_string_t name;
2108 cmd_config_max_lro_pkt_size_parsed(void *parsed_result,
2109 __rte_unused struct cmdline *cl,
2110 __rte_unused void *data)
2112 struct cmd_config_max_lro_pkt_size_result *res = parsed_result;
2115 if (!all_ports_stopped()) {
2116 printf("Please stop all ports first\n");
2120 RTE_ETH_FOREACH_DEV(pid) {
2121 struct rte_port *port = &ports[pid];
2123 if (!strcmp(res->name, "max-lro-pkt-size")) {
2125 port->dev_conf.rxmode.max_lro_pkt_size)
2128 port->dev_conf.rxmode.max_lro_pkt_size = res->value;
2130 printf("Unknown parameter\n");
2137 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2140 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_port =
2141 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2143 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_keyword =
2144 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2146 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_all =
2147 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2149 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_name =
2150 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2151 name, "max-lro-pkt-size");
2152 cmdline_parse_token_num_t cmd_config_max_lro_pkt_size_value =
2153 TOKEN_NUM_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2156 cmdline_parse_inst_t cmd_config_max_lro_pkt_size = {
2157 .f = cmd_config_max_lro_pkt_size_parsed,
2159 .help_str = "port config all max-lro-pkt-size <value>",
2161 (void *)&cmd_config_max_lro_pkt_size_port,
2162 (void *)&cmd_config_max_lro_pkt_size_keyword,
2163 (void *)&cmd_config_max_lro_pkt_size_all,
2164 (void *)&cmd_config_max_lro_pkt_size_name,
2165 (void *)&cmd_config_max_lro_pkt_size_value,
2170 /* *** configure port MTU *** */
2171 struct cmd_config_mtu_result {
2172 cmdline_fixed_string_t port;
2173 cmdline_fixed_string_t keyword;
2174 cmdline_fixed_string_t mtu;
2180 cmd_config_mtu_parsed(void *parsed_result,
2181 __rte_unused struct cmdline *cl,
2182 __rte_unused void *data)
2184 struct cmd_config_mtu_result *res = parsed_result;
2186 if (res->value < RTE_ETHER_MIN_LEN) {
2187 printf("mtu cannot be less than %d\n", RTE_ETHER_MIN_LEN);
2190 port_mtu_set(res->port_id, res->value);
2193 cmdline_parse_token_string_t cmd_config_mtu_port =
2194 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
2196 cmdline_parse_token_string_t cmd_config_mtu_keyword =
2197 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2199 cmdline_parse_token_string_t cmd_config_mtu_mtu =
2200 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2202 cmdline_parse_token_num_t cmd_config_mtu_port_id =
2203 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT16);
2204 cmdline_parse_token_num_t cmd_config_mtu_value =
2205 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
2207 cmdline_parse_inst_t cmd_config_mtu = {
2208 .f = cmd_config_mtu_parsed,
2210 .help_str = "port config mtu <port_id> <value>",
2212 (void *)&cmd_config_mtu_port,
2213 (void *)&cmd_config_mtu_keyword,
2214 (void *)&cmd_config_mtu_mtu,
2215 (void *)&cmd_config_mtu_port_id,
2216 (void *)&cmd_config_mtu_value,
2221 /* *** configure rx mode *** */
2222 struct cmd_config_rx_mode_flag {
2223 cmdline_fixed_string_t port;
2224 cmdline_fixed_string_t keyword;
2225 cmdline_fixed_string_t all;
2226 cmdline_fixed_string_t name;
2227 cmdline_fixed_string_t value;
2231 cmd_config_rx_mode_flag_parsed(void *parsed_result,
2232 __rte_unused struct cmdline *cl,
2233 __rte_unused void *data)
2235 struct cmd_config_rx_mode_flag *res = parsed_result;
2237 if (!all_ports_stopped()) {
2238 printf("Please stop all ports first\n");
2242 if (!strcmp(res->name, "drop-en")) {
2243 if (!strcmp(res->value, "on"))
2245 else if (!strcmp(res->value, "off"))
2248 printf("Unknown parameter\n");
2252 printf("Unknown parameter\n");
2258 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2261 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
2262 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
2263 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
2264 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
2266 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
2267 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
2268 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
2269 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
2271 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
2272 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
2275 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
2276 .f = cmd_config_rx_mode_flag_parsed,
2278 .help_str = "port config all drop-en on|off",
2280 (void *)&cmd_config_rx_mode_flag_port,
2281 (void *)&cmd_config_rx_mode_flag_keyword,
2282 (void *)&cmd_config_rx_mode_flag_all,
2283 (void *)&cmd_config_rx_mode_flag_name,
2284 (void *)&cmd_config_rx_mode_flag_value,
2289 /* *** configure rss *** */
2290 struct cmd_config_rss {
2291 cmdline_fixed_string_t port;
2292 cmdline_fixed_string_t keyword;
2293 cmdline_fixed_string_t all;
2294 cmdline_fixed_string_t name;
2295 cmdline_fixed_string_t value;
2299 cmd_config_rss_parsed(void *parsed_result,
2300 __rte_unused struct cmdline *cl,
2301 __rte_unused void *data)
2303 struct cmd_config_rss *res = parsed_result;
2304 struct rte_eth_rss_conf rss_conf = { .rss_key_len = 0, };
2305 struct rte_eth_dev_info dev_info = { .flow_type_rss_offloads = 0, };
2306 int use_default = 0;
2307 int all_updated = 1;
2312 if (!strcmp(res->value, "all"))
2313 rss_conf.rss_hf = ETH_RSS_ETH | ETH_RSS_VLAN | ETH_RSS_IP |
2314 ETH_RSS_TCP | ETH_RSS_UDP | ETH_RSS_SCTP |
2315 ETH_RSS_L2_PAYLOAD | ETH_RSS_L2TPV3 | ETH_RSS_ESP |
2316 ETH_RSS_AH | ETH_RSS_PFCP | ETH_RSS_GTPU;
2317 else if (!strcmp(res->value, "eth"))
2318 rss_conf.rss_hf = ETH_RSS_ETH;
2319 else if (!strcmp(res->value, "vlan"))
2320 rss_conf.rss_hf = ETH_RSS_VLAN;
2321 else if (!strcmp(res->value, "ip"))
2322 rss_conf.rss_hf = ETH_RSS_IP;
2323 else if (!strcmp(res->value, "udp"))
2324 rss_conf.rss_hf = ETH_RSS_UDP;
2325 else if (!strcmp(res->value, "tcp"))
2326 rss_conf.rss_hf = ETH_RSS_TCP;
2327 else if (!strcmp(res->value, "sctp"))
2328 rss_conf.rss_hf = ETH_RSS_SCTP;
2329 else if (!strcmp(res->value, "ether"))
2330 rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD;
2331 else if (!strcmp(res->value, "port"))
2332 rss_conf.rss_hf = ETH_RSS_PORT;
2333 else if (!strcmp(res->value, "vxlan"))
2334 rss_conf.rss_hf = ETH_RSS_VXLAN;
2335 else if (!strcmp(res->value, "geneve"))
2336 rss_conf.rss_hf = ETH_RSS_GENEVE;
2337 else if (!strcmp(res->value, "nvgre"))
2338 rss_conf.rss_hf = ETH_RSS_NVGRE;
2339 else if (!strcmp(res->value, "l3-pre32"))
2340 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE32;
2341 else if (!strcmp(res->value, "l3-pre40"))
2342 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE40;
2343 else if (!strcmp(res->value, "l3-pre48"))
2344 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE48;
2345 else if (!strcmp(res->value, "l3-pre56"))
2346 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE56;
2347 else if (!strcmp(res->value, "l3-pre64"))
2348 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE64;
2349 else if (!strcmp(res->value, "l3-pre96"))
2350 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE96;
2351 else if (!strcmp(res->value, "l3-src-only"))
2352 rss_conf.rss_hf = ETH_RSS_L3_SRC_ONLY;
2353 else if (!strcmp(res->value, "l3-dst-only"))
2354 rss_conf.rss_hf = ETH_RSS_L3_DST_ONLY;
2355 else if (!strcmp(res->value, "l4-src-only"))
2356 rss_conf.rss_hf = ETH_RSS_L4_SRC_ONLY;
2357 else if (!strcmp(res->value, "l4-dst-only"))
2358 rss_conf.rss_hf = ETH_RSS_L4_DST_ONLY;
2359 else if (!strcmp(res->value, "l2-src-only"))
2360 rss_conf.rss_hf = ETH_RSS_L2_SRC_ONLY;
2361 else if (!strcmp(res->value, "l2-dst-only"))
2362 rss_conf.rss_hf = ETH_RSS_L2_DST_ONLY;
2363 else if (!strcmp(res->value, "l2tpv3"))
2364 rss_conf.rss_hf = ETH_RSS_L2TPV3;
2365 else if (!strcmp(res->value, "esp"))
2366 rss_conf.rss_hf = ETH_RSS_ESP;
2367 else if (!strcmp(res->value, "ah"))
2368 rss_conf.rss_hf = ETH_RSS_AH;
2369 else if (!strcmp(res->value, "pfcp"))
2370 rss_conf.rss_hf = ETH_RSS_PFCP;
2371 else if (!strcmp(res->value, "pppoe"))
2372 rss_conf.rss_hf = ETH_RSS_PPPOE;
2373 else if (!strcmp(res->value, "gtpu"))
2374 rss_conf.rss_hf = ETH_RSS_GTPU;
2375 else if (!strcmp(res->value, "none"))
2376 rss_conf.rss_hf = 0;
2377 else if (!strcmp(res->value, "level-default")) {
2378 rss_hf &= (~ETH_RSS_LEVEL_MASK);
2379 rss_conf.rss_hf = (rss_hf | ETH_RSS_LEVEL_PMD_DEFAULT);
2380 } else if (!strcmp(res->value, "level-outer")) {
2381 rss_hf &= (~ETH_RSS_LEVEL_MASK);
2382 rss_conf.rss_hf = (rss_hf | ETH_RSS_LEVEL_OUTERMOST);
2383 } else if (!strcmp(res->value, "level-inner")) {
2384 rss_hf &= (~ETH_RSS_LEVEL_MASK);
2385 rss_conf.rss_hf = (rss_hf | ETH_RSS_LEVEL_INNERMOST);
2386 } else if (!strcmp(res->value, "default"))
2388 else if (isdigit(res->value[0]) && atoi(res->value) > 0 &&
2389 atoi(res->value) < 64)
2390 rss_conf.rss_hf = 1ULL << atoi(res->value);
2392 printf("Unknown parameter\n");
2395 rss_conf.rss_key = NULL;
2396 /* Update global configuration for RSS types. */
2397 RTE_ETH_FOREACH_DEV(i) {
2398 struct rte_eth_rss_conf local_rss_conf;
2400 ret = eth_dev_info_get_print_err(i, &dev_info);
2405 rss_conf.rss_hf = dev_info.flow_type_rss_offloads;
2407 local_rss_conf = rss_conf;
2408 local_rss_conf.rss_hf = rss_conf.rss_hf &
2409 dev_info.flow_type_rss_offloads;
2410 if (local_rss_conf.rss_hf != rss_conf.rss_hf) {
2411 printf("Port %u modified RSS hash function based on hardware support,"
2412 "requested:%#"PRIx64" configured:%#"PRIx64"\n",
2413 i, rss_conf.rss_hf, local_rss_conf.rss_hf);
2415 diag = rte_eth_dev_rss_hash_update(i, &local_rss_conf);
2418 printf("Configuration of RSS hash at ethernet port %d "
2419 "failed with error (%d): %s.\n",
2420 i, -diag, strerror(-diag));
2423 if (all_updated && !use_default) {
2424 rss_hf = rss_conf.rss_hf;
2425 printf("rss_hf %#"PRIx64"\n", rss_hf);
2429 cmdline_parse_token_string_t cmd_config_rss_port =
2430 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
2431 cmdline_parse_token_string_t cmd_config_rss_keyword =
2432 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
2433 cmdline_parse_token_string_t cmd_config_rss_all =
2434 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
2435 cmdline_parse_token_string_t cmd_config_rss_name =
2436 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
2437 cmdline_parse_token_string_t cmd_config_rss_value =
2438 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, NULL);
2440 cmdline_parse_inst_t cmd_config_rss = {
2441 .f = cmd_config_rss_parsed,
2443 .help_str = "port config all rss "
2444 "all|default|eth|vlan|ip|tcp|udp|sctp|ether|port|vxlan|geneve|"
2445 "nvgre|vxlan-gpe|l2tpv3|esp|ah|pfcp|none|level-default|"
2446 "level-outer|level-inner|<flowtype_id>",
2448 (void *)&cmd_config_rss_port,
2449 (void *)&cmd_config_rss_keyword,
2450 (void *)&cmd_config_rss_all,
2451 (void *)&cmd_config_rss_name,
2452 (void *)&cmd_config_rss_value,
2457 /* *** configure rss hash key *** */
2458 struct cmd_config_rss_hash_key {
2459 cmdline_fixed_string_t port;
2460 cmdline_fixed_string_t config;
2462 cmdline_fixed_string_t rss_hash_key;
2463 cmdline_fixed_string_t rss_type;
2464 cmdline_fixed_string_t key;
2468 hexa_digit_to_value(char hexa_digit)
2470 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
2471 return (uint8_t) (hexa_digit - '0');
2472 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
2473 return (uint8_t) ((hexa_digit - 'a') + 10);
2474 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
2475 return (uint8_t) ((hexa_digit - 'A') + 10);
2476 /* Invalid hexa digit */
2481 parse_and_check_key_hexa_digit(char *key, int idx)
2485 hexa_v = hexa_digit_to_value(key[idx]);
2487 printf("invalid key: character %c at position %d is not a "
2488 "valid hexa digit\n", key[idx], idx);
2493 cmd_config_rss_hash_key_parsed(void *parsed_result,
2494 __rte_unused struct cmdline *cl,
2495 __rte_unused void *data)
2497 struct cmd_config_rss_hash_key *res = parsed_result;
2498 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
2502 struct rte_eth_dev_info dev_info;
2503 uint8_t hash_key_size;
2507 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
2511 if (dev_info.hash_key_size > 0 &&
2512 dev_info.hash_key_size <= sizeof(hash_key))
2513 hash_key_size = dev_info.hash_key_size;
2515 printf("dev_info did not provide a valid hash key size\n");
2518 /* Check the length of the RSS hash key */
2519 key_len = strlen(res->key);
2520 if (key_len != (hash_key_size * 2)) {
2521 printf("key length: %d invalid - key must be a string of %d"
2522 " hexa-decimal numbers\n",
2523 (int) key_len, hash_key_size * 2);
2526 /* Translate RSS hash key into binary representation */
2527 for (i = 0; i < hash_key_size; i++) {
2528 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
2531 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
2534 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
2536 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
2540 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
2541 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
2542 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
2543 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
2545 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
2546 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT16);
2547 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
2548 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
2549 rss_hash_key, "rss-hash-key");
2550 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
2551 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
2552 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2553 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2554 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2555 "ipv6-tcp-ex#ipv6-udp-ex#"
2556 "l3-src-only#l3-dst-only#l4-src-only#l4-dst-only#"
2557 "l2-src-only#l2-dst-only#s-vlan#c-vlan#"
2558 "l2tpv3#esp#ah#pfcp#pppoe#gtpu");
2559 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
2560 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
2562 cmdline_parse_inst_t cmd_config_rss_hash_key = {
2563 .f = cmd_config_rss_hash_key_parsed,
2565 .help_str = "port config <port_id> rss-hash-key "
2566 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2567 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2568 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex|"
2569 "l3-src-only|l3-dst-only|l4-src-only|l4-dst-only|"
2570 "l2-src-only|l2-dst-only|s-vlan|c-vlan|"
2571 "l2tpv3|esp|ah|pfcp|pppoe|gtpu "
2572 "<string of hex digits (variable length, NIC dependent)>",
2574 (void *)&cmd_config_rss_hash_key_port,
2575 (void *)&cmd_config_rss_hash_key_config,
2576 (void *)&cmd_config_rss_hash_key_port_id,
2577 (void *)&cmd_config_rss_hash_key_rss_hash_key,
2578 (void *)&cmd_config_rss_hash_key_rss_type,
2579 (void *)&cmd_config_rss_hash_key_value,
2584 /* *** configure port rxq/txq ring size *** */
2585 struct cmd_config_rxtx_ring_size {
2586 cmdline_fixed_string_t port;
2587 cmdline_fixed_string_t config;
2589 cmdline_fixed_string_t rxtxq;
2591 cmdline_fixed_string_t rsize;
2596 cmd_config_rxtx_ring_size_parsed(void *parsed_result,
2597 __rte_unused struct cmdline *cl,
2598 __rte_unused void *data)
2600 struct cmd_config_rxtx_ring_size *res = parsed_result;
2601 struct rte_port *port;
2604 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2607 if (res->portid == (portid_t)RTE_PORT_ALL) {
2608 printf("Invalid port id\n");
2612 port = &ports[res->portid];
2614 if (!strcmp(res->rxtxq, "rxq"))
2616 else if (!strcmp(res->rxtxq, "txq"))
2619 printf("Unknown parameter\n");
2623 if (isrx && rx_queue_id_is_invalid(res->qid))
2625 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2628 if (isrx && res->size != 0 && res->size <= rx_free_thresh) {
2629 printf("Invalid rx ring_size, must > rx_free_thresh: %d\n",
2635 port->nb_rx_desc[res->qid] = res->size;
2637 port->nb_tx_desc[res->qid] = res->size;
2639 cmd_reconfig_device_queue(res->portid, 0, 1);
2642 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_port =
2643 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2645 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_config =
2646 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2648 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_portid =
2649 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2651 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rxtxq =
2652 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2654 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_qid =
2655 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2657 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rsize =
2658 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2659 rsize, "ring_size");
2660 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_size =
2661 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2664 cmdline_parse_inst_t cmd_config_rxtx_ring_size = {
2665 .f = cmd_config_rxtx_ring_size_parsed,
2667 .help_str = "port config <port_id> rxq|txq <queue_id> ring_size <value>",
2669 (void *)&cmd_config_rxtx_ring_size_port,
2670 (void *)&cmd_config_rxtx_ring_size_config,
2671 (void *)&cmd_config_rxtx_ring_size_portid,
2672 (void *)&cmd_config_rxtx_ring_size_rxtxq,
2673 (void *)&cmd_config_rxtx_ring_size_qid,
2674 (void *)&cmd_config_rxtx_ring_size_rsize,
2675 (void *)&cmd_config_rxtx_ring_size_size,
2680 /* *** configure port rxq/txq start/stop *** */
2681 struct cmd_config_rxtx_queue {
2682 cmdline_fixed_string_t port;
2684 cmdline_fixed_string_t rxtxq;
2686 cmdline_fixed_string_t opname;
2690 cmd_config_rxtx_queue_parsed(void *parsed_result,
2691 __rte_unused struct cmdline *cl,
2692 __rte_unused void *data)
2694 struct cmd_config_rxtx_queue *res = parsed_result;
2699 if (test_done == 0) {
2700 printf("Please stop forwarding first\n");
2704 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2707 if (port_is_started(res->portid) != 1) {
2708 printf("Please start port %u first\n", res->portid);
2712 if (!strcmp(res->rxtxq, "rxq"))
2714 else if (!strcmp(res->rxtxq, "txq"))
2717 printf("Unknown parameter\n");
2721 if (isrx && rx_queue_id_is_invalid(res->qid))
2723 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2726 if (!strcmp(res->opname, "start"))
2728 else if (!strcmp(res->opname, "stop"))
2731 printf("Unknown parameter\n");
2735 if (isstart && isrx)
2736 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
2737 else if (!isstart && isrx)
2738 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
2739 else if (isstart && !isrx)
2740 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
2742 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
2744 if (ret == -ENOTSUP)
2745 printf("Function not supported in PMD driver\n");
2748 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
2749 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
2750 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
2751 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT16);
2752 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
2753 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
2754 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
2755 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
2756 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
2757 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
2760 cmdline_parse_inst_t cmd_config_rxtx_queue = {
2761 .f = cmd_config_rxtx_queue_parsed,
2763 .help_str = "port <port_id> rxq|txq <queue_id> start|stop",
2765 (void *)&cmd_config_rxtx_queue_port,
2766 (void *)&cmd_config_rxtx_queue_portid,
2767 (void *)&cmd_config_rxtx_queue_rxtxq,
2768 (void *)&cmd_config_rxtx_queue_qid,
2769 (void *)&cmd_config_rxtx_queue_opname,
2774 /* *** configure port rxq/txq deferred start on/off *** */
2775 struct cmd_config_deferred_start_rxtx_queue {
2776 cmdline_fixed_string_t port;
2778 cmdline_fixed_string_t rxtxq;
2780 cmdline_fixed_string_t opname;
2781 cmdline_fixed_string_t state;
2785 cmd_config_deferred_start_rxtx_queue_parsed(void *parsed_result,
2786 __rte_unused struct cmdline *cl,
2787 __rte_unused void *data)
2789 struct cmd_config_deferred_start_rxtx_queue *res = parsed_result;
2790 struct rte_port *port;
2793 uint8_t needreconfig = 0;
2795 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
2798 if (port_is_started(res->port_id) != 0) {
2799 printf("Please stop port %u first\n", res->port_id);
2803 port = &ports[res->port_id];
2805 isrx = !strcmp(res->rxtxq, "rxq");
2807 if (isrx && rx_queue_id_is_invalid(res->qid))
2809 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2812 ison = !strcmp(res->state, "on");
2814 if (isrx && port->rx_conf[res->qid].rx_deferred_start != ison) {
2815 port->rx_conf[res->qid].rx_deferred_start = ison;
2817 } else if (!isrx && port->tx_conf[res->qid].tx_deferred_start != ison) {
2818 port->tx_conf[res->qid].tx_deferred_start = ison;
2823 cmd_reconfig_device_queue(res->port_id, 0, 1);
2826 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_port =
2827 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2829 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_port_id =
2830 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2832 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_rxtxq =
2833 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2835 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_qid =
2836 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2838 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_opname =
2839 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2840 opname, "deferred_start");
2841 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_state =
2842 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2845 cmdline_parse_inst_t cmd_config_deferred_start_rxtx_queue = {
2846 .f = cmd_config_deferred_start_rxtx_queue_parsed,
2848 .help_str = "port <port_id> rxq|txq <queue_id> deferred_start on|off",
2850 (void *)&cmd_config_deferred_start_rxtx_queue_port,
2851 (void *)&cmd_config_deferred_start_rxtx_queue_port_id,
2852 (void *)&cmd_config_deferred_start_rxtx_queue_rxtxq,
2853 (void *)&cmd_config_deferred_start_rxtx_queue_qid,
2854 (void *)&cmd_config_deferred_start_rxtx_queue_opname,
2855 (void *)&cmd_config_deferred_start_rxtx_queue_state,
2860 /* *** configure port rxq/txq setup *** */
2861 struct cmd_setup_rxtx_queue {
2862 cmdline_fixed_string_t port;
2864 cmdline_fixed_string_t rxtxq;
2866 cmdline_fixed_string_t setup;
2869 /* Common CLI fields for queue setup */
2870 cmdline_parse_token_string_t cmd_setup_rxtx_queue_port =
2871 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, port, "port");
2872 cmdline_parse_token_num_t cmd_setup_rxtx_queue_portid =
2873 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, portid, UINT16);
2874 cmdline_parse_token_string_t cmd_setup_rxtx_queue_rxtxq =
2875 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, rxtxq, "rxq#txq");
2876 cmdline_parse_token_num_t cmd_setup_rxtx_queue_qid =
2877 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, qid, UINT16);
2878 cmdline_parse_token_string_t cmd_setup_rxtx_queue_setup =
2879 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, setup, "setup");
2882 cmd_setup_rxtx_queue_parsed(
2883 void *parsed_result,
2884 __rte_unused struct cmdline *cl,
2885 __rte_unused void *data)
2887 struct cmd_setup_rxtx_queue *res = parsed_result;
2888 struct rte_port *port;
2889 struct rte_mempool *mp;
2890 unsigned int socket_id;
2894 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2897 if (res->portid == (portid_t)RTE_PORT_ALL) {
2898 printf("Invalid port id\n");
2902 if (!strcmp(res->rxtxq, "rxq"))
2904 else if (!strcmp(res->rxtxq, "txq"))
2907 printf("Unknown parameter\n");
2911 if (isrx && rx_queue_id_is_invalid(res->qid)) {
2912 printf("Invalid rx queue\n");
2914 } else if (!isrx && tx_queue_id_is_invalid(res->qid)) {
2915 printf("Invalid tx queue\n");
2919 port = &ports[res->portid];
2921 socket_id = rxring_numa[res->portid];
2922 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2923 socket_id = port->socket_id;
2925 mp = mbuf_pool_find(socket_id, 0);
2927 printf("Failed to setup RX queue: "
2928 "No mempool allocation"
2929 " on the socket %d\n",
2930 rxring_numa[res->portid]);
2933 ret = rx_queue_setup(res->portid,
2935 port->nb_rx_desc[res->qid],
2937 &port->rx_conf[res->qid],
2940 printf("Failed to setup RX queue\n");
2942 socket_id = txring_numa[res->portid];
2943 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2944 socket_id = port->socket_id;
2946 ret = rte_eth_tx_queue_setup(res->portid,
2948 port->nb_tx_desc[res->qid],
2950 &port->tx_conf[res->qid]);
2952 printf("Failed to setup TX queue\n");
2956 cmdline_parse_inst_t cmd_setup_rxtx_queue = {
2957 .f = cmd_setup_rxtx_queue_parsed,
2959 .help_str = "port <port_id> rxq|txq <queue_idx> setup",
2961 (void *)&cmd_setup_rxtx_queue_port,
2962 (void *)&cmd_setup_rxtx_queue_portid,
2963 (void *)&cmd_setup_rxtx_queue_rxtxq,
2964 (void *)&cmd_setup_rxtx_queue_qid,
2965 (void *)&cmd_setup_rxtx_queue_setup,
2971 /* *** Configure RSS RETA *** */
2972 struct cmd_config_rss_reta {
2973 cmdline_fixed_string_t port;
2974 cmdline_fixed_string_t keyword;
2976 cmdline_fixed_string_t name;
2977 cmdline_fixed_string_t list_name;
2978 cmdline_fixed_string_t list_of_items;
2982 parse_reta_config(const char *str,
2983 struct rte_eth_rss_reta_entry64 *reta_conf,
2984 uint16_t nb_entries)
2988 uint16_t hash_index, idx, shift;
2991 const char *p, *p0 = str;
2998 unsigned long int_fld[_NUM_FLD];
2999 char *str_fld[_NUM_FLD];
3001 while ((p = strchr(p0,'(')) != NULL) {
3003 if((p0 = strchr(p,')')) == NULL)
3007 if(size >= sizeof(s))
3010 snprintf(s, sizeof(s), "%.*s", size, p);
3011 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
3013 for (i = 0; i < _NUM_FLD; i++) {
3015 int_fld[i] = strtoul(str_fld[i], &end, 0);
3016 if (errno != 0 || end == str_fld[i] ||
3021 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
3022 nb_queue = (uint16_t)int_fld[FLD_QUEUE];
3024 if (hash_index >= nb_entries) {
3025 printf("Invalid RETA hash index=%d\n", hash_index);
3029 idx = hash_index / RTE_RETA_GROUP_SIZE;
3030 shift = hash_index % RTE_RETA_GROUP_SIZE;
3031 reta_conf[idx].mask |= (1ULL << shift);
3032 reta_conf[idx].reta[shift] = nb_queue;
3039 cmd_set_rss_reta_parsed(void *parsed_result,
3040 __rte_unused struct cmdline *cl,
3041 __rte_unused void *data)
3044 struct rte_eth_dev_info dev_info;
3045 struct rte_eth_rss_reta_entry64 reta_conf[8];
3046 struct cmd_config_rss_reta *res = parsed_result;
3048 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
3052 if (dev_info.reta_size == 0) {
3053 printf("Redirection table size is 0 which is "
3054 "invalid for RSS\n");
3057 printf("The reta size of port %d is %u\n",
3058 res->port_id, dev_info.reta_size);
3059 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
3060 printf("Currently do not support more than %u entries of "
3061 "redirection table\n", ETH_RSS_RETA_SIZE_512);
3065 memset(reta_conf, 0, sizeof(reta_conf));
3066 if (!strcmp(res->list_name, "reta")) {
3067 if (parse_reta_config(res->list_of_items, reta_conf,
3068 dev_info.reta_size)) {
3069 printf("Invalid RSS Redirection Table "
3070 "config entered\n");
3073 ret = rte_eth_dev_rss_reta_update(res->port_id,
3074 reta_conf, dev_info.reta_size);
3076 printf("Bad redirection table parameter, "
3077 "return code = %d \n", ret);
3081 cmdline_parse_token_string_t cmd_config_rss_reta_port =
3082 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
3083 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
3084 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
3085 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
3086 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT16);
3087 cmdline_parse_token_string_t cmd_config_rss_reta_name =
3088 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
3089 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
3090 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
3091 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
3092 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
3094 cmdline_parse_inst_t cmd_config_rss_reta = {
3095 .f = cmd_set_rss_reta_parsed,
3097 .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
3099 (void *)&cmd_config_rss_reta_port,
3100 (void *)&cmd_config_rss_reta_keyword,
3101 (void *)&cmd_config_rss_reta_port_id,
3102 (void *)&cmd_config_rss_reta_name,
3103 (void *)&cmd_config_rss_reta_list_name,
3104 (void *)&cmd_config_rss_reta_list_of_items,
3109 /* *** SHOW PORT RETA INFO *** */
3110 struct cmd_showport_reta {
3111 cmdline_fixed_string_t show;
3112 cmdline_fixed_string_t port;
3114 cmdline_fixed_string_t rss;
3115 cmdline_fixed_string_t reta;
3117 cmdline_fixed_string_t list_of_items;
3121 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
3122 uint16_t nb_entries,
3126 const char *p, *p0 = str;
3131 uint16_t num = (nb_entries + RTE_RETA_GROUP_SIZE - 1) /
3132 RTE_RETA_GROUP_SIZE;
3135 p = strchr(p0, '(');
3139 p0 = strchr(p, ')');
3143 if (size >= sizeof(s)) {
3144 printf("The string size exceeds the internal buffer size\n");
3147 snprintf(s, sizeof(s), "%.*s", size, p);
3148 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
3149 if (ret <= 0 || ret != num) {
3150 printf("The bits of masks do not match the number of "
3151 "reta entries: %u\n", num);
3154 for (i = 0; i < ret; i++)
3155 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
3161 cmd_showport_reta_parsed(void *parsed_result,
3162 __rte_unused struct cmdline *cl,
3163 __rte_unused void *data)
3165 struct cmd_showport_reta *res = parsed_result;
3166 struct rte_eth_rss_reta_entry64 reta_conf[8];
3167 struct rte_eth_dev_info dev_info;
3168 uint16_t max_reta_size;
3171 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
3175 max_reta_size = RTE_MIN(dev_info.reta_size, ETH_RSS_RETA_SIZE_512);
3176 if (res->size == 0 || res->size > max_reta_size) {
3177 printf("Invalid redirection table size: %u (1-%u)\n",
3178 res->size, max_reta_size);
3182 memset(reta_conf, 0, sizeof(reta_conf));
3183 if (showport_parse_reta_config(reta_conf, res->size,
3184 res->list_of_items) < 0) {
3185 printf("Invalid string: %s for reta masks\n",
3186 res->list_of_items);
3189 port_rss_reta_info(res->port_id, reta_conf, res->size);
3192 cmdline_parse_token_string_t cmd_showport_reta_show =
3193 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
3194 cmdline_parse_token_string_t cmd_showport_reta_port =
3195 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
3196 cmdline_parse_token_num_t cmd_showport_reta_port_id =
3197 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT16);
3198 cmdline_parse_token_string_t cmd_showport_reta_rss =
3199 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
3200 cmdline_parse_token_string_t cmd_showport_reta_reta =
3201 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
3202 cmdline_parse_token_num_t cmd_showport_reta_size =
3203 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16);
3204 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
3205 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
3206 list_of_items, NULL);
3208 cmdline_parse_inst_t cmd_showport_reta = {
3209 .f = cmd_showport_reta_parsed,
3211 .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
3213 (void *)&cmd_showport_reta_show,
3214 (void *)&cmd_showport_reta_port,
3215 (void *)&cmd_showport_reta_port_id,
3216 (void *)&cmd_showport_reta_rss,
3217 (void *)&cmd_showport_reta_reta,
3218 (void *)&cmd_showport_reta_size,
3219 (void *)&cmd_showport_reta_list_of_items,
3224 /* *** Show RSS hash configuration *** */
3225 struct cmd_showport_rss_hash {
3226 cmdline_fixed_string_t show;
3227 cmdline_fixed_string_t port;
3229 cmdline_fixed_string_t rss_hash;
3230 cmdline_fixed_string_t rss_type;
3231 cmdline_fixed_string_t key; /* optional argument */
3234 static void cmd_showport_rss_hash_parsed(void *parsed_result,
3235 __rte_unused struct cmdline *cl,
3238 struct cmd_showport_rss_hash *res = parsed_result;
3240 port_rss_hash_conf_show(res->port_id, show_rss_key != NULL);
3243 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
3244 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
3245 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
3246 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
3247 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
3248 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT16);
3249 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
3250 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
3252 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
3253 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
3255 cmdline_parse_inst_t cmd_showport_rss_hash = {
3256 .f = cmd_showport_rss_hash_parsed,
3258 .help_str = "show port <port_id> rss-hash",
3260 (void *)&cmd_showport_rss_hash_show,
3261 (void *)&cmd_showport_rss_hash_port,
3262 (void *)&cmd_showport_rss_hash_port_id,
3263 (void *)&cmd_showport_rss_hash_rss_hash,
3268 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
3269 .f = cmd_showport_rss_hash_parsed,
3271 .help_str = "show port <port_id> rss-hash key",
3273 (void *)&cmd_showport_rss_hash_show,
3274 (void *)&cmd_showport_rss_hash_port,
3275 (void *)&cmd_showport_rss_hash_port_id,
3276 (void *)&cmd_showport_rss_hash_rss_hash,
3277 (void *)&cmd_showport_rss_hash_rss_key,
3282 /* *** Configure DCB *** */
3283 struct cmd_config_dcb {
3284 cmdline_fixed_string_t port;
3285 cmdline_fixed_string_t config;
3287 cmdline_fixed_string_t dcb;
3288 cmdline_fixed_string_t vt;
3289 cmdline_fixed_string_t vt_en;
3291 cmdline_fixed_string_t pfc;
3292 cmdline_fixed_string_t pfc_en;
3296 cmd_config_dcb_parsed(void *parsed_result,
3297 __rte_unused struct cmdline *cl,
3298 __rte_unused void *data)
3300 struct cmd_config_dcb *res = parsed_result;
3301 portid_t port_id = res->port_id;
3302 struct rte_port *port;
3306 port = &ports[port_id];
3307 /** Check if the port is not started **/
3308 if (port->port_status != RTE_PORT_STOPPED) {
3309 printf("Please stop port %d first\n", port_id);
3313 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
3314 printf("The invalid number of traffic class,"
3315 " only 4 or 8 allowed.\n");
3319 if (nb_fwd_lcores < res->num_tcs) {
3320 printf("nb_cores shouldn't be less than number of TCs.\n");
3323 if (!strncmp(res->pfc_en, "on", 2))
3328 /* DCB in VT mode */
3329 if (!strncmp(res->vt_en, "on", 2))
3330 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
3331 (enum rte_eth_nb_tcs)res->num_tcs,
3334 ret = init_port_dcb_config(port_id, DCB_ENABLED,
3335 (enum rte_eth_nb_tcs)res->num_tcs,
3340 printf("Cannot initialize network ports.\n");
3344 cmd_reconfig_device_queue(port_id, 1, 1);
3347 cmdline_parse_token_string_t cmd_config_dcb_port =
3348 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
3349 cmdline_parse_token_string_t cmd_config_dcb_config =
3350 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
3351 cmdline_parse_token_num_t cmd_config_dcb_port_id =
3352 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT16);
3353 cmdline_parse_token_string_t cmd_config_dcb_dcb =
3354 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
3355 cmdline_parse_token_string_t cmd_config_dcb_vt =
3356 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
3357 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
3358 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
3359 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
3360 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
3361 cmdline_parse_token_string_t cmd_config_dcb_pfc=
3362 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
3363 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
3364 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
3366 cmdline_parse_inst_t cmd_config_dcb = {
3367 .f = cmd_config_dcb_parsed,
3369 .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
3371 (void *)&cmd_config_dcb_port,
3372 (void *)&cmd_config_dcb_config,
3373 (void *)&cmd_config_dcb_port_id,
3374 (void *)&cmd_config_dcb_dcb,
3375 (void *)&cmd_config_dcb_vt,
3376 (void *)&cmd_config_dcb_vt_en,
3377 (void *)&cmd_config_dcb_num_tcs,
3378 (void *)&cmd_config_dcb_pfc,
3379 (void *)&cmd_config_dcb_pfc_en,
3384 /* *** configure number of packets per burst *** */
3385 struct cmd_config_burst {
3386 cmdline_fixed_string_t port;
3387 cmdline_fixed_string_t keyword;
3388 cmdline_fixed_string_t all;
3389 cmdline_fixed_string_t name;
3394 cmd_config_burst_parsed(void *parsed_result,
3395 __rte_unused struct cmdline *cl,
3396 __rte_unused void *data)
3398 struct cmd_config_burst *res = parsed_result;
3399 struct rte_eth_dev_info dev_info;
3400 uint16_t rec_nb_pkts;
3403 if (!all_ports_stopped()) {
3404 printf("Please stop all ports first\n");
3408 if (!strcmp(res->name, "burst")) {
3409 if (res->value == 0) {
3410 /* If user gives a value of zero, query the PMD for
3411 * its recommended Rx burst size. Testpmd uses a single
3412 * size for all ports, so assume all ports are the same
3413 * NIC model and use the values from Port 0.
3415 ret = eth_dev_info_get_print_err(0, &dev_info);
3419 rec_nb_pkts = dev_info.default_rxportconf.burst_size;
3421 if (rec_nb_pkts == 0) {
3422 printf("PMD does not recommend a burst size.\n"
3423 "User provided value must be between"
3424 " 1 and %d\n", MAX_PKT_BURST);
3426 } else if (rec_nb_pkts > MAX_PKT_BURST) {
3427 printf("PMD recommended burst size of %d"
3428 " exceeds maximum value of %d\n",
3429 rec_nb_pkts, MAX_PKT_BURST);
3432 printf("Using PMD-provided burst value of %d\n",
3434 nb_pkt_per_burst = rec_nb_pkts;
3435 } else if (res->value > MAX_PKT_BURST) {
3436 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
3439 nb_pkt_per_burst = res->value;
3441 printf("Unknown parameter\n");
3447 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3450 cmdline_parse_token_string_t cmd_config_burst_port =
3451 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
3452 cmdline_parse_token_string_t cmd_config_burst_keyword =
3453 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
3454 cmdline_parse_token_string_t cmd_config_burst_all =
3455 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
3456 cmdline_parse_token_string_t cmd_config_burst_name =
3457 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
3458 cmdline_parse_token_num_t cmd_config_burst_value =
3459 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
3461 cmdline_parse_inst_t cmd_config_burst = {
3462 .f = cmd_config_burst_parsed,
3464 .help_str = "port config all burst <value>",
3466 (void *)&cmd_config_burst_port,
3467 (void *)&cmd_config_burst_keyword,
3468 (void *)&cmd_config_burst_all,
3469 (void *)&cmd_config_burst_name,
3470 (void *)&cmd_config_burst_value,
3475 /* *** configure rx/tx queues *** */
3476 struct cmd_config_thresh {
3477 cmdline_fixed_string_t port;
3478 cmdline_fixed_string_t keyword;
3479 cmdline_fixed_string_t all;
3480 cmdline_fixed_string_t name;
3485 cmd_config_thresh_parsed(void *parsed_result,
3486 __rte_unused struct cmdline *cl,
3487 __rte_unused void *data)
3489 struct cmd_config_thresh *res = parsed_result;
3491 if (!all_ports_stopped()) {
3492 printf("Please stop all ports first\n");
3496 if (!strcmp(res->name, "txpt"))
3497 tx_pthresh = res->value;
3498 else if(!strcmp(res->name, "txht"))
3499 tx_hthresh = res->value;
3500 else if(!strcmp(res->name, "txwt"))
3501 tx_wthresh = res->value;
3502 else if(!strcmp(res->name, "rxpt"))
3503 rx_pthresh = res->value;
3504 else if(!strcmp(res->name, "rxht"))
3505 rx_hthresh = res->value;
3506 else if(!strcmp(res->name, "rxwt"))
3507 rx_wthresh = res->value;
3509 printf("Unknown parameter\n");
3515 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3518 cmdline_parse_token_string_t cmd_config_thresh_port =
3519 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
3520 cmdline_parse_token_string_t cmd_config_thresh_keyword =
3521 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
3522 cmdline_parse_token_string_t cmd_config_thresh_all =
3523 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
3524 cmdline_parse_token_string_t cmd_config_thresh_name =
3525 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
3526 "txpt#txht#txwt#rxpt#rxht#rxwt");
3527 cmdline_parse_token_num_t cmd_config_thresh_value =
3528 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
3530 cmdline_parse_inst_t cmd_config_thresh = {
3531 .f = cmd_config_thresh_parsed,
3533 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
3535 (void *)&cmd_config_thresh_port,
3536 (void *)&cmd_config_thresh_keyword,
3537 (void *)&cmd_config_thresh_all,
3538 (void *)&cmd_config_thresh_name,
3539 (void *)&cmd_config_thresh_value,
3544 /* *** configure free/rs threshold *** */
3545 struct cmd_config_threshold {
3546 cmdline_fixed_string_t port;
3547 cmdline_fixed_string_t keyword;
3548 cmdline_fixed_string_t all;
3549 cmdline_fixed_string_t name;
3554 cmd_config_threshold_parsed(void *parsed_result,
3555 __rte_unused struct cmdline *cl,
3556 __rte_unused void *data)
3558 struct cmd_config_threshold *res = parsed_result;
3560 if (!all_ports_stopped()) {
3561 printf("Please stop all ports first\n");
3565 if (!strcmp(res->name, "txfreet"))
3566 tx_free_thresh = res->value;
3567 else if (!strcmp(res->name, "txrst"))
3568 tx_rs_thresh = res->value;
3569 else if (!strcmp(res->name, "rxfreet"))
3570 rx_free_thresh = res->value;
3572 printf("Unknown parameter\n");
3578 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3581 cmdline_parse_token_string_t cmd_config_threshold_port =
3582 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
3583 cmdline_parse_token_string_t cmd_config_threshold_keyword =
3584 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
3586 cmdline_parse_token_string_t cmd_config_threshold_all =
3587 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
3588 cmdline_parse_token_string_t cmd_config_threshold_name =
3589 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
3590 "txfreet#txrst#rxfreet");
3591 cmdline_parse_token_num_t cmd_config_threshold_value =
3592 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
3594 cmdline_parse_inst_t cmd_config_threshold = {
3595 .f = cmd_config_threshold_parsed,
3597 .help_str = "port config all txfreet|txrst|rxfreet <value>",
3599 (void *)&cmd_config_threshold_port,
3600 (void *)&cmd_config_threshold_keyword,
3601 (void *)&cmd_config_threshold_all,
3602 (void *)&cmd_config_threshold_name,
3603 (void *)&cmd_config_threshold_value,
3609 struct cmd_stop_result {
3610 cmdline_fixed_string_t stop;
3613 static void cmd_stop_parsed(__rte_unused void *parsed_result,
3614 __rte_unused struct cmdline *cl,
3615 __rte_unused void *data)
3617 stop_packet_forwarding();
3620 cmdline_parse_token_string_t cmd_stop_stop =
3621 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
3623 cmdline_parse_inst_t cmd_stop = {
3624 .f = cmd_stop_parsed,
3626 .help_str = "stop: Stop packet forwarding",
3628 (void *)&cmd_stop_stop,
3633 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
3636 parse_item_list(char* str, const char* item_name, unsigned int max_items,
3637 unsigned int *parsed_items, int check_unique_values)
3639 unsigned int nb_item;
3647 * First parse all items in the list and store their value.
3652 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
3654 if ((c >= '0') && (c <= '9')) {
3655 value = (unsigned int) (value * 10 + (c - '0'));
3660 printf("character %c is not a decimal digit\n", c);
3664 printf("No valid value before comma\n");
3667 if (nb_item < max_items) {
3668 parsed_items[nb_item] = value;
3674 if (nb_item >= max_items) {
3675 printf("Number of %s = %u > %u (maximum items)\n",
3676 item_name, nb_item + 1, max_items);
3679 parsed_items[nb_item++] = value;
3680 if (! check_unique_values)
3684 * Then, check that all values in the list are differents.
3685 * No optimization here...
3687 for (i = 0; i < nb_item; i++) {
3688 for (j = i + 1; j < nb_item; j++) {
3689 if (parsed_items[j] == parsed_items[i]) {
3690 printf("duplicated %s %u at index %u and %u\n",
3691 item_name, parsed_items[i], i, j);
3699 struct cmd_set_list_result {
3700 cmdline_fixed_string_t cmd_keyword;
3701 cmdline_fixed_string_t list_name;
3702 cmdline_fixed_string_t list_of_items;
3705 static void cmd_set_list_parsed(void *parsed_result,
3706 __rte_unused struct cmdline *cl,
3707 __rte_unused void *data)
3709 struct cmd_set_list_result *res;
3711 unsigned int lcorelist[RTE_MAX_LCORE];
3712 unsigned int portlist[RTE_MAX_ETHPORTS];
3714 unsigned int nb_item;
3716 if (test_done == 0) {
3717 printf("Please stop forwarding first\n");
3721 res = parsed_result;
3722 if (!strcmp(res->list_name, "corelist")) {
3723 nb_item = parse_item_list(res->list_of_items, "core",
3725 parsed_items.lcorelist, 1);
3727 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
3732 if (!strcmp(res->list_name, "portlist")) {
3733 nb_item = parse_item_list(res->list_of_items, "port",
3735 parsed_items.portlist, 1);
3737 set_fwd_ports_list(parsed_items.portlist, nb_item);
3743 cmdline_parse_token_string_t cmd_set_list_keyword =
3744 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
3746 cmdline_parse_token_string_t cmd_set_list_name =
3747 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
3748 "corelist#portlist");
3749 cmdline_parse_token_string_t cmd_set_list_of_items =
3750 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
3753 cmdline_parse_inst_t cmd_set_fwd_list = {
3754 .f = cmd_set_list_parsed,
3756 .help_str = "set corelist|portlist <list0[,list1]*>",
3758 (void *)&cmd_set_list_keyword,
3759 (void *)&cmd_set_list_name,
3760 (void *)&cmd_set_list_of_items,
3765 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
3767 struct cmd_setmask_result {
3768 cmdline_fixed_string_t set;
3769 cmdline_fixed_string_t mask;
3773 static void cmd_set_mask_parsed(void *parsed_result,
3774 __rte_unused struct cmdline *cl,
3775 __rte_unused void *data)
3777 struct cmd_setmask_result *res = parsed_result;
3779 if (test_done == 0) {
3780 printf("Please stop forwarding first\n");
3783 if (!strcmp(res->mask, "coremask")) {
3784 set_fwd_lcores_mask(res->hexavalue);
3786 } else if (!strcmp(res->mask, "portmask")) {
3787 set_fwd_ports_mask(res->hexavalue);
3792 cmdline_parse_token_string_t cmd_setmask_set =
3793 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
3794 cmdline_parse_token_string_t cmd_setmask_mask =
3795 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
3796 "coremask#portmask");
3797 cmdline_parse_token_num_t cmd_setmask_value =
3798 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
3800 cmdline_parse_inst_t cmd_set_fwd_mask = {
3801 .f = cmd_set_mask_parsed,
3803 .help_str = "set coremask|portmask <hexadecimal value>",
3805 (void *)&cmd_setmask_set,
3806 (void *)&cmd_setmask_mask,
3807 (void *)&cmd_setmask_value,
3813 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
3815 struct cmd_set_result {
3816 cmdline_fixed_string_t set;
3817 cmdline_fixed_string_t what;
3821 static void cmd_set_parsed(void *parsed_result,
3822 __rte_unused struct cmdline *cl,
3823 __rte_unused void *data)
3825 struct cmd_set_result *res = parsed_result;
3826 if (!strcmp(res->what, "nbport")) {
3827 set_fwd_ports_number(res->value);
3829 } else if (!strcmp(res->what, "nbcore")) {
3830 set_fwd_lcores_number(res->value);
3832 } else if (!strcmp(res->what, "burst"))
3833 set_nb_pkt_per_burst(res->value);
3834 else if (!strcmp(res->what, "verbose"))
3835 set_verbose_level(res->value);
3838 cmdline_parse_token_string_t cmd_set_set =
3839 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
3840 cmdline_parse_token_string_t cmd_set_what =
3841 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
3842 "nbport#nbcore#burst#verbose");
3843 cmdline_parse_token_num_t cmd_set_value =
3844 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
3846 cmdline_parse_inst_t cmd_set_numbers = {
3847 .f = cmd_set_parsed,
3849 .help_str = "set nbport|nbcore|burst|verbose <value>",
3851 (void *)&cmd_set_set,
3852 (void *)&cmd_set_what,
3853 (void *)&cmd_set_value,
3858 /* *** SET LOG LEVEL CONFIGURATION *** */
3860 struct cmd_set_log_result {
3861 cmdline_fixed_string_t set;
3862 cmdline_fixed_string_t log;
3863 cmdline_fixed_string_t type;
3868 cmd_set_log_parsed(void *parsed_result,
3869 __rte_unused struct cmdline *cl,
3870 __rte_unused void *data)
3872 struct cmd_set_log_result *res;
3875 res = parsed_result;
3876 if (!strcmp(res->type, "global"))
3877 rte_log_set_global_level(res->level);
3879 ret = rte_log_set_level_regexp(res->type, res->level);
3881 printf("Unable to set log level\n");
3885 cmdline_parse_token_string_t cmd_set_log_set =
3886 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, set, "set");
3887 cmdline_parse_token_string_t cmd_set_log_log =
3888 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, log, "log");
3889 cmdline_parse_token_string_t cmd_set_log_type =
3890 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, type, NULL);
3891 cmdline_parse_token_num_t cmd_set_log_level =
3892 TOKEN_NUM_INITIALIZER(struct cmd_set_log_result, level, UINT32);
3894 cmdline_parse_inst_t cmd_set_log = {
3895 .f = cmd_set_log_parsed,
3897 .help_str = "set log global|<type> <level>",
3899 (void *)&cmd_set_log_set,
3900 (void *)&cmd_set_log_log,
3901 (void *)&cmd_set_log_type,
3902 (void *)&cmd_set_log_level,
3907 /* *** SET SEGMENT OFFSETS OF RX PACKETS SPLIT *** */
3909 struct cmd_set_rxoffs_result {
3910 cmdline_fixed_string_t cmd_keyword;
3911 cmdline_fixed_string_t rxoffs;
3912 cmdline_fixed_string_t seg_offsets;
3916 cmd_set_rxoffs_parsed(void *parsed_result,
3917 __rte_unused struct cmdline *cl,
3918 __rte_unused void *data)
3920 struct cmd_set_rxoffs_result *res;
3921 unsigned int seg_offsets[MAX_SEGS_BUFFER_SPLIT];
3922 unsigned int nb_segs;
3924 res = parsed_result;
3925 nb_segs = parse_item_list(res->seg_offsets, "segment offsets",
3926 MAX_SEGS_BUFFER_SPLIT, seg_offsets, 0);
3928 set_rx_pkt_offsets(seg_offsets, nb_segs);
3931 cmdline_parse_token_string_t cmd_set_rxoffs_keyword =
3932 TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
3933 cmd_keyword, "set");
3934 cmdline_parse_token_string_t cmd_set_rxoffs_name =
3935 TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
3937 cmdline_parse_token_string_t cmd_set_rxoffs_offsets =
3938 TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
3941 cmdline_parse_inst_t cmd_set_rxoffs = {
3942 .f = cmd_set_rxoffs_parsed,
3944 .help_str = "set rxoffs <len0[,len1]*>",
3946 (void *)&cmd_set_rxoffs_keyword,
3947 (void *)&cmd_set_rxoffs_name,
3948 (void *)&cmd_set_rxoffs_offsets,
3953 /* *** SET SEGMENT LENGTHS OF RX PACKETS SPLIT *** */
3955 struct cmd_set_rxpkts_result {
3956 cmdline_fixed_string_t cmd_keyword;
3957 cmdline_fixed_string_t rxpkts;
3958 cmdline_fixed_string_t seg_lengths;
3962 cmd_set_rxpkts_parsed(void *parsed_result,
3963 __rte_unused struct cmdline *cl,
3964 __rte_unused void *data)
3966 struct cmd_set_rxpkts_result *res;
3967 unsigned int seg_lengths[MAX_SEGS_BUFFER_SPLIT];
3968 unsigned int nb_segs;
3970 res = parsed_result;
3971 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
3972 MAX_SEGS_BUFFER_SPLIT, seg_lengths, 0);
3974 set_rx_pkt_segments(seg_lengths, nb_segs);
3977 cmdline_parse_token_string_t cmd_set_rxpkts_keyword =
3978 TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
3979 cmd_keyword, "set");
3980 cmdline_parse_token_string_t cmd_set_rxpkts_name =
3981 TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
3983 cmdline_parse_token_string_t cmd_set_rxpkts_lengths =
3984 TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
3987 cmdline_parse_inst_t cmd_set_rxpkts = {
3988 .f = cmd_set_rxpkts_parsed,
3990 .help_str = "set rxpkts <len0[,len1]*>",
3992 (void *)&cmd_set_rxpkts_keyword,
3993 (void *)&cmd_set_rxpkts_name,
3994 (void *)&cmd_set_rxpkts_lengths,
3999 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
4001 struct cmd_set_txpkts_result {
4002 cmdline_fixed_string_t cmd_keyword;
4003 cmdline_fixed_string_t txpkts;
4004 cmdline_fixed_string_t seg_lengths;
4008 cmd_set_txpkts_parsed(void *parsed_result,
4009 __rte_unused struct cmdline *cl,
4010 __rte_unused void *data)
4012 struct cmd_set_txpkts_result *res;
4013 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
4014 unsigned int nb_segs;
4016 res = parsed_result;
4017 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
4018 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
4020 set_tx_pkt_segments(seg_lengths, nb_segs);
4023 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
4024 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
4025 cmd_keyword, "set");
4026 cmdline_parse_token_string_t cmd_set_txpkts_name =
4027 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
4029 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
4030 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
4033 cmdline_parse_inst_t cmd_set_txpkts = {
4034 .f = cmd_set_txpkts_parsed,
4036 .help_str = "set txpkts <len0[,len1]*>",
4038 (void *)&cmd_set_txpkts_keyword,
4039 (void *)&cmd_set_txpkts_name,
4040 (void *)&cmd_set_txpkts_lengths,
4045 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
4047 struct cmd_set_txsplit_result {
4048 cmdline_fixed_string_t cmd_keyword;
4049 cmdline_fixed_string_t txsplit;
4050 cmdline_fixed_string_t mode;
4054 cmd_set_txsplit_parsed(void *parsed_result,
4055 __rte_unused struct cmdline *cl,
4056 __rte_unused void *data)
4058 struct cmd_set_txsplit_result *res;
4060 res = parsed_result;
4061 set_tx_pkt_split(res->mode);
4064 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
4065 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
4066 cmd_keyword, "set");
4067 cmdline_parse_token_string_t cmd_set_txsplit_name =
4068 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
4069 txsplit, "txsplit");
4070 cmdline_parse_token_string_t cmd_set_txsplit_mode =
4071 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
4074 cmdline_parse_inst_t cmd_set_txsplit = {
4075 .f = cmd_set_txsplit_parsed,
4077 .help_str = "set txsplit on|off|rand",
4079 (void *)&cmd_set_txsplit_keyword,
4080 (void *)&cmd_set_txsplit_name,
4081 (void *)&cmd_set_txsplit_mode,
4086 /* *** SET TIMES FOR TXONLY PACKETS SCHEDULING ON TIMESTAMPS *** */
4088 struct cmd_set_txtimes_result {
4089 cmdline_fixed_string_t cmd_keyword;
4090 cmdline_fixed_string_t txtimes;
4091 cmdline_fixed_string_t tx_times;
4095 cmd_set_txtimes_parsed(void *parsed_result,
4096 __rte_unused struct cmdline *cl,
4097 __rte_unused void *data)
4099 struct cmd_set_txtimes_result *res;
4100 unsigned int tx_times[2] = {0, 0};
4101 unsigned int n_times;
4103 res = parsed_result;
4104 n_times = parse_item_list(res->tx_times, "tx times",
4107 set_tx_pkt_times(tx_times);
4110 cmdline_parse_token_string_t cmd_set_txtimes_keyword =
4111 TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
4112 cmd_keyword, "set");
4113 cmdline_parse_token_string_t cmd_set_txtimes_name =
4114 TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
4115 txtimes, "txtimes");
4116 cmdline_parse_token_string_t cmd_set_txtimes_value =
4117 TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
4120 cmdline_parse_inst_t cmd_set_txtimes = {
4121 .f = cmd_set_txtimes_parsed,
4123 .help_str = "set txtimes <inter_burst>,<intra_burst>",
4125 (void *)&cmd_set_txtimes_keyword,
4126 (void *)&cmd_set_txtimes_name,
4127 (void *)&cmd_set_txtimes_value,
4132 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
4133 struct cmd_rx_vlan_filter_all_result {
4134 cmdline_fixed_string_t rx_vlan;
4135 cmdline_fixed_string_t what;
4136 cmdline_fixed_string_t all;
4141 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
4142 __rte_unused struct cmdline *cl,
4143 __rte_unused void *data)
4145 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
4147 if (!strcmp(res->what, "add"))
4148 rx_vlan_all_filter_set(res->port_id, 1);
4150 rx_vlan_all_filter_set(res->port_id, 0);
4153 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
4154 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4155 rx_vlan, "rx_vlan");
4156 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
4157 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4159 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
4160 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4162 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
4163 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4166 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
4167 .f = cmd_rx_vlan_filter_all_parsed,
4169 .help_str = "rx_vlan add|rm all <port_id>: "
4170 "Add/Remove all identifiers to/from the set of VLAN "
4171 "identifiers filtered by a port",
4173 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
4174 (void *)&cmd_rx_vlan_filter_all_what,
4175 (void *)&cmd_rx_vlan_filter_all_all,
4176 (void *)&cmd_rx_vlan_filter_all_portid,
4181 /* *** VLAN OFFLOAD SET ON A PORT *** */
4182 struct cmd_vlan_offload_result {
4183 cmdline_fixed_string_t vlan;
4184 cmdline_fixed_string_t set;
4185 cmdline_fixed_string_t vlan_type;
4186 cmdline_fixed_string_t what;
4187 cmdline_fixed_string_t on;
4188 cmdline_fixed_string_t port_id;
4192 cmd_vlan_offload_parsed(void *parsed_result,
4193 __rte_unused struct cmdline *cl,
4194 __rte_unused void *data)
4197 struct cmd_vlan_offload_result *res = parsed_result;
4200 portid_t port_id = 0;
4204 len = strnlen(str, STR_TOKEN_SIZE);
4206 /* Get port_id first */
4214 tmp = strtoul(str, NULL, 0);
4215 /* If port_id greater that what portid_t can represent, return */
4216 if(tmp >= RTE_MAX_ETHPORTS)
4218 port_id = (portid_t)tmp;
4220 if (!strcmp(res->on, "on"))
4225 if (!strcmp(res->what, "strip"))
4226 rx_vlan_strip_set(port_id, on);
4227 else if(!strcmp(res->what, "stripq")){
4228 uint16_t queue_id = 0;
4230 /* No queue_id, return */
4232 printf("must specify (port,queue_id)\n");
4235 tmp = strtoul(str + i + 1, NULL, 0);
4236 /* If queue_id greater that what 16-bits can represent, return */
4240 queue_id = (uint16_t)tmp;
4241 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
4243 else if (!strcmp(res->what, "filter"))
4244 rx_vlan_filter_set(port_id, on);
4245 else if (!strcmp(res->what, "qinq_strip"))
4246 rx_vlan_qinq_strip_set(port_id, on);
4248 vlan_extend_set(port_id, on);
4253 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
4254 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4256 cmdline_parse_token_string_t cmd_vlan_offload_set =
4257 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4259 cmdline_parse_token_string_t cmd_vlan_offload_what =
4260 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4261 what, "strip#filter#qinq_strip#extend#stripq");
4262 cmdline_parse_token_string_t cmd_vlan_offload_on =
4263 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4265 cmdline_parse_token_string_t cmd_vlan_offload_portid =
4266 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4269 cmdline_parse_inst_t cmd_vlan_offload = {
4270 .f = cmd_vlan_offload_parsed,
4272 .help_str = "vlan set strip|filter|qinq_strip|extend|stripq on|off "
4273 "<port_id[,queue_id]>: "
4274 "Strip/Filter/QinQ for rx side Extend for both rx/tx sides",
4276 (void *)&cmd_vlan_offload_vlan,
4277 (void *)&cmd_vlan_offload_set,
4278 (void *)&cmd_vlan_offload_what,
4279 (void *)&cmd_vlan_offload_on,
4280 (void *)&cmd_vlan_offload_portid,
4285 /* *** VLAN TPID SET ON A PORT *** */
4286 struct cmd_vlan_tpid_result {
4287 cmdline_fixed_string_t vlan;
4288 cmdline_fixed_string_t set;
4289 cmdline_fixed_string_t vlan_type;
4290 cmdline_fixed_string_t what;
4296 cmd_vlan_tpid_parsed(void *parsed_result,
4297 __rte_unused struct cmdline *cl,
4298 __rte_unused void *data)
4300 struct cmd_vlan_tpid_result *res = parsed_result;
4301 enum rte_vlan_type vlan_type;
4303 if (!strcmp(res->vlan_type, "inner"))
4304 vlan_type = ETH_VLAN_TYPE_INNER;
4305 else if (!strcmp(res->vlan_type, "outer"))
4306 vlan_type = ETH_VLAN_TYPE_OUTER;
4308 printf("Unknown vlan type\n");
4311 vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
4314 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
4315 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4317 cmdline_parse_token_string_t cmd_vlan_tpid_set =
4318 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4320 cmdline_parse_token_string_t cmd_vlan_type =
4321 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4322 vlan_type, "inner#outer");
4323 cmdline_parse_token_string_t cmd_vlan_tpid_what =
4324 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4326 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
4327 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4329 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
4330 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4333 cmdline_parse_inst_t cmd_vlan_tpid = {
4334 .f = cmd_vlan_tpid_parsed,
4336 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
4337 "Set the VLAN Ether type",
4339 (void *)&cmd_vlan_tpid_vlan,
4340 (void *)&cmd_vlan_tpid_set,
4341 (void *)&cmd_vlan_type,
4342 (void *)&cmd_vlan_tpid_what,
4343 (void *)&cmd_vlan_tpid_tpid,
4344 (void *)&cmd_vlan_tpid_portid,
4349 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
4350 struct cmd_rx_vlan_filter_result {
4351 cmdline_fixed_string_t rx_vlan;
4352 cmdline_fixed_string_t what;
4358 cmd_rx_vlan_filter_parsed(void *parsed_result,
4359 __rte_unused struct cmdline *cl,
4360 __rte_unused void *data)
4362 struct cmd_rx_vlan_filter_result *res = parsed_result;
4364 if (!strcmp(res->what, "add"))
4365 rx_vft_set(res->port_id, res->vlan_id, 1);
4367 rx_vft_set(res->port_id, res->vlan_id, 0);
4370 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
4371 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4372 rx_vlan, "rx_vlan");
4373 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
4374 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4376 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
4377 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4379 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
4380 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4383 cmdline_parse_inst_t cmd_rx_vlan_filter = {
4384 .f = cmd_rx_vlan_filter_parsed,
4386 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
4387 "Add/Remove a VLAN identifier to/from the set of VLAN "
4388 "identifiers filtered by a port",
4390 (void *)&cmd_rx_vlan_filter_rx_vlan,
4391 (void *)&cmd_rx_vlan_filter_what,
4392 (void *)&cmd_rx_vlan_filter_vlanid,
4393 (void *)&cmd_rx_vlan_filter_portid,
4398 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4399 struct cmd_tx_vlan_set_result {
4400 cmdline_fixed_string_t tx_vlan;
4401 cmdline_fixed_string_t set;
4407 cmd_tx_vlan_set_parsed(void *parsed_result,
4408 __rte_unused struct cmdline *cl,
4409 __rte_unused void *data)
4411 struct cmd_tx_vlan_set_result *res = parsed_result;
4413 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4416 if (!port_is_stopped(res->port_id)) {
4417 printf("Please stop port %d first\n", res->port_id);
4421 tx_vlan_set(res->port_id, res->vlan_id);
4423 cmd_reconfig_device_queue(res->port_id, 1, 1);
4426 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
4427 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4428 tx_vlan, "tx_vlan");
4429 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
4430 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4432 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
4433 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4435 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
4436 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4439 cmdline_parse_inst_t cmd_tx_vlan_set = {
4440 .f = cmd_tx_vlan_set_parsed,
4442 .help_str = "tx_vlan set <port_id> <vlan_id>: "
4443 "Enable hardware insertion of a single VLAN header "
4444 "with a given TAG Identifier in packets sent on a port",
4446 (void *)&cmd_tx_vlan_set_tx_vlan,
4447 (void *)&cmd_tx_vlan_set_set,
4448 (void *)&cmd_tx_vlan_set_portid,
4449 (void *)&cmd_tx_vlan_set_vlanid,
4454 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
4455 struct cmd_tx_vlan_set_qinq_result {
4456 cmdline_fixed_string_t tx_vlan;
4457 cmdline_fixed_string_t set;
4460 uint16_t vlan_id_outer;
4464 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
4465 __rte_unused struct cmdline *cl,
4466 __rte_unused void *data)
4468 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
4470 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4473 if (!port_is_stopped(res->port_id)) {
4474 printf("Please stop port %d first\n", res->port_id);
4478 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
4480 cmd_reconfig_device_queue(res->port_id, 1, 1);
4483 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
4484 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4485 tx_vlan, "tx_vlan");
4486 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
4487 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4489 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
4490 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4492 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
4493 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4495 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
4496 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4497 vlan_id_outer, UINT16);
4499 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
4500 .f = cmd_tx_vlan_set_qinq_parsed,
4502 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
4503 "Enable hardware insertion of double VLAN header "
4504 "with given TAG Identifiers in packets sent on a port",
4506 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
4507 (void *)&cmd_tx_vlan_set_qinq_set,
4508 (void *)&cmd_tx_vlan_set_qinq_portid,
4509 (void *)&cmd_tx_vlan_set_qinq_vlanid,
4510 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
4515 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
4516 struct cmd_tx_vlan_set_pvid_result {
4517 cmdline_fixed_string_t tx_vlan;
4518 cmdline_fixed_string_t set;
4519 cmdline_fixed_string_t pvid;
4522 cmdline_fixed_string_t mode;
4526 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
4527 __rte_unused struct cmdline *cl,
4528 __rte_unused void *data)
4530 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
4532 if (strcmp(res->mode, "on") == 0)
4533 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
4535 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
4538 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
4539 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4540 tx_vlan, "tx_vlan");
4541 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
4542 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4544 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
4545 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4547 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
4548 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4550 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
4551 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4553 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
4554 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4557 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
4558 .f = cmd_tx_vlan_set_pvid_parsed,
4560 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
4562 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
4563 (void *)&cmd_tx_vlan_set_pvid_set,
4564 (void *)&cmd_tx_vlan_set_pvid_pvid,
4565 (void *)&cmd_tx_vlan_set_pvid_port_id,
4566 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
4567 (void *)&cmd_tx_vlan_set_pvid_mode,
4572 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4573 struct cmd_tx_vlan_reset_result {
4574 cmdline_fixed_string_t tx_vlan;
4575 cmdline_fixed_string_t reset;
4580 cmd_tx_vlan_reset_parsed(void *parsed_result,
4581 __rte_unused struct cmdline *cl,
4582 __rte_unused void *data)
4584 struct cmd_tx_vlan_reset_result *res = parsed_result;
4586 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4589 if (!port_is_stopped(res->port_id)) {
4590 printf("Please stop port %d first\n", res->port_id);
4594 tx_vlan_reset(res->port_id);
4596 cmd_reconfig_device_queue(res->port_id, 1, 1);
4599 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
4600 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4601 tx_vlan, "tx_vlan");
4602 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
4603 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4605 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
4606 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
4609 cmdline_parse_inst_t cmd_tx_vlan_reset = {
4610 .f = cmd_tx_vlan_reset_parsed,
4612 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
4613 "VLAN header in packets sent on a port",
4615 (void *)&cmd_tx_vlan_reset_tx_vlan,
4616 (void *)&cmd_tx_vlan_reset_reset,
4617 (void *)&cmd_tx_vlan_reset_portid,
4623 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
4624 struct cmd_csum_result {
4625 cmdline_fixed_string_t csum;
4626 cmdline_fixed_string_t mode;
4627 cmdline_fixed_string_t proto;
4628 cmdline_fixed_string_t hwsw;
4633 csum_show(int port_id)
4635 struct rte_eth_dev_info dev_info;
4636 uint64_t tx_offloads;
4639 tx_offloads = ports[port_id].dev_conf.txmode.offloads;
4640 printf("Parse tunnel is %s\n",
4641 (ports[port_id].parse_tunnel) ? "on" : "off");
4642 printf("IP checksum offload is %s\n",
4643 (tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) ? "hw" : "sw");
4644 printf("UDP checksum offload is %s\n",
4645 (tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
4646 printf("TCP checksum offload is %s\n",
4647 (tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
4648 printf("SCTP checksum offload is %s\n",
4649 (tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
4650 printf("Outer-Ip checksum offload is %s\n",
4651 (tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) ? "hw" : "sw");
4652 printf("Outer-Udp checksum offload is %s\n",
4653 (tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) ? "hw" : "sw");
4655 /* display warnings if configuration is not supported by the NIC */
4656 ret = eth_dev_info_get_print_err(port_id, &dev_info);
4660 if ((tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) &&
4661 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
4662 printf("Warning: hardware IP checksum enabled but not "
4663 "supported by port %d\n", port_id);
4665 if ((tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) &&
4666 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
4667 printf("Warning: hardware UDP checksum enabled but not "
4668 "supported by port %d\n", port_id);
4670 if ((tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) &&
4671 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
4672 printf("Warning: hardware TCP checksum enabled but not "
4673 "supported by port %d\n", port_id);
4675 if ((tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) &&
4676 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
4677 printf("Warning: hardware SCTP checksum enabled but not "
4678 "supported by port %d\n", port_id);
4680 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) &&
4681 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
4682 printf("Warning: hardware outer IP checksum enabled but not "
4683 "supported by port %d\n", port_id);
4685 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) &&
4686 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)
4688 printf("Warning: hardware outer UDP checksum enabled but not "
4689 "supported by port %d\n", port_id);
4694 cmd_config_queue_tx_offloads(struct rte_port *port)
4698 /* Apply queue tx offloads configuration */
4699 for (k = 0; k < port->dev_info.max_rx_queues; k++)
4700 port->tx_conf[k].offloads =
4701 port->dev_conf.txmode.offloads;
4705 cmd_csum_parsed(void *parsed_result,
4706 __rte_unused struct cmdline *cl,
4707 __rte_unused void *data)
4709 struct cmd_csum_result *res = parsed_result;
4711 uint64_t csum_offloads = 0;
4712 struct rte_eth_dev_info dev_info;
4715 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
4716 printf("invalid port %d\n", res->port_id);
4719 if (!port_is_stopped(res->port_id)) {
4720 printf("Please stop port %d first\n", res->port_id);
4724 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4728 if (!strcmp(res->mode, "set")) {
4730 if (!strcmp(res->hwsw, "hw"))
4733 if (!strcmp(res->proto, "ip")) {
4734 if (hw == 0 || (dev_info.tx_offload_capa &
4735 DEV_TX_OFFLOAD_IPV4_CKSUM)) {
4736 csum_offloads |= DEV_TX_OFFLOAD_IPV4_CKSUM;
4738 printf("IP checksum offload is not supported "
4739 "by port %u\n", res->port_id);
4741 } else if (!strcmp(res->proto, "udp")) {
4742 if (hw == 0 || (dev_info.tx_offload_capa &
4743 DEV_TX_OFFLOAD_UDP_CKSUM)) {
4744 csum_offloads |= DEV_TX_OFFLOAD_UDP_CKSUM;
4746 printf("UDP checksum offload is not supported "
4747 "by port %u\n", res->port_id);
4749 } else if (!strcmp(res->proto, "tcp")) {
4750 if (hw == 0 || (dev_info.tx_offload_capa &
4751 DEV_TX_OFFLOAD_TCP_CKSUM)) {
4752 csum_offloads |= DEV_TX_OFFLOAD_TCP_CKSUM;
4754 printf("TCP checksum offload is not supported "
4755 "by port %u\n", res->port_id);
4757 } else if (!strcmp(res->proto, "sctp")) {
4758 if (hw == 0 || (dev_info.tx_offload_capa &
4759 DEV_TX_OFFLOAD_SCTP_CKSUM)) {
4760 csum_offloads |= DEV_TX_OFFLOAD_SCTP_CKSUM;
4762 printf("SCTP checksum offload is not supported "
4763 "by port %u\n", res->port_id);
4765 } else if (!strcmp(res->proto, "outer-ip")) {
4766 if (hw == 0 || (dev_info.tx_offload_capa &
4767 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM)) {
4769 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM;
4771 printf("Outer IP checksum offload is not "
4772 "supported by port %u\n", res->port_id);
4774 } else if (!strcmp(res->proto, "outer-udp")) {
4775 if (hw == 0 || (dev_info.tx_offload_capa &
4776 DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)) {
4778 DEV_TX_OFFLOAD_OUTER_UDP_CKSUM;
4780 printf("Outer UDP checksum offload is not "
4781 "supported by port %u\n", res->port_id);
4786 ports[res->port_id].dev_conf.txmode.offloads |=
4789 ports[res->port_id].dev_conf.txmode.offloads &=
4792 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4794 csum_show(res->port_id);
4796 cmd_reconfig_device_queue(res->port_id, 1, 1);
4799 cmdline_parse_token_string_t cmd_csum_csum =
4800 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4802 cmdline_parse_token_string_t cmd_csum_mode =
4803 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4805 cmdline_parse_token_string_t cmd_csum_proto =
4806 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4807 proto, "ip#tcp#udp#sctp#outer-ip#outer-udp");
4808 cmdline_parse_token_string_t cmd_csum_hwsw =
4809 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4811 cmdline_parse_token_num_t cmd_csum_portid =
4812 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
4815 cmdline_parse_inst_t cmd_csum_set = {
4816 .f = cmd_csum_parsed,
4818 .help_str = "csum set ip|tcp|udp|sctp|outer-ip|outer-udp hw|sw <port_id>: "
4819 "Enable/Disable hardware calculation of L3/L4 checksum when "
4820 "using csum forward engine",
4822 (void *)&cmd_csum_csum,
4823 (void *)&cmd_csum_mode,
4824 (void *)&cmd_csum_proto,
4825 (void *)&cmd_csum_hwsw,
4826 (void *)&cmd_csum_portid,
4831 cmdline_parse_token_string_t cmd_csum_mode_show =
4832 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4835 cmdline_parse_inst_t cmd_csum_show = {
4836 .f = cmd_csum_parsed,
4838 .help_str = "csum show <port_id>: Show checksum offload configuration",
4840 (void *)&cmd_csum_csum,
4841 (void *)&cmd_csum_mode_show,
4842 (void *)&cmd_csum_portid,
4847 /* Enable/disable tunnel parsing */
4848 struct cmd_csum_tunnel_result {
4849 cmdline_fixed_string_t csum;
4850 cmdline_fixed_string_t parse;
4851 cmdline_fixed_string_t onoff;
4856 cmd_csum_tunnel_parsed(void *parsed_result,
4857 __rte_unused struct cmdline *cl,
4858 __rte_unused void *data)
4860 struct cmd_csum_tunnel_result *res = parsed_result;
4862 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4865 if (!strcmp(res->onoff, "on"))
4866 ports[res->port_id].parse_tunnel = 1;
4868 ports[res->port_id].parse_tunnel = 0;
4870 csum_show(res->port_id);
4873 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
4874 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4876 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
4877 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4878 parse, "parse-tunnel");
4879 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
4880 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4882 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
4883 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
4886 cmdline_parse_inst_t cmd_csum_tunnel = {
4887 .f = cmd_csum_tunnel_parsed,
4889 .help_str = "csum parse-tunnel on|off <port_id>: "
4890 "Enable/Disable parsing of tunnels for csum engine",
4892 (void *)&cmd_csum_tunnel_csum,
4893 (void *)&cmd_csum_tunnel_parse,
4894 (void *)&cmd_csum_tunnel_onoff,
4895 (void *)&cmd_csum_tunnel_portid,
4900 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
4901 struct cmd_tso_set_result {
4902 cmdline_fixed_string_t tso;
4903 cmdline_fixed_string_t mode;
4909 cmd_tso_set_parsed(void *parsed_result,
4910 __rte_unused struct cmdline *cl,
4911 __rte_unused void *data)
4913 struct cmd_tso_set_result *res = parsed_result;
4914 struct rte_eth_dev_info dev_info;
4917 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4919 if (!port_is_stopped(res->port_id)) {
4920 printf("Please stop port %d first\n", res->port_id);
4924 if (!strcmp(res->mode, "set"))
4925 ports[res->port_id].tso_segsz = res->tso_segsz;
4927 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4931 if ((ports[res->port_id].tso_segsz != 0) &&
4932 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4933 printf("Error: TSO is not supported by port %d\n",
4938 if (ports[res->port_id].tso_segsz == 0) {
4939 ports[res->port_id].dev_conf.txmode.offloads &=
4940 ~DEV_TX_OFFLOAD_TCP_TSO;
4941 printf("TSO for non-tunneled packets is disabled\n");
4943 ports[res->port_id].dev_conf.txmode.offloads |=
4944 DEV_TX_OFFLOAD_TCP_TSO;
4945 printf("TSO segment size for non-tunneled packets is %d\n",
4946 ports[res->port_id].tso_segsz);
4948 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4950 /* display warnings if configuration is not supported by the NIC */
4951 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4955 if ((ports[res->port_id].tso_segsz != 0) &&
4956 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4957 printf("Warning: TSO enabled but not "
4958 "supported by port %d\n", res->port_id);
4961 cmd_reconfig_device_queue(res->port_id, 1, 1);
4964 cmdline_parse_token_string_t cmd_tso_set_tso =
4965 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4967 cmdline_parse_token_string_t cmd_tso_set_mode =
4968 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4970 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
4971 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4973 cmdline_parse_token_num_t cmd_tso_set_portid =
4974 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4977 cmdline_parse_inst_t cmd_tso_set = {
4978 .f = cmd_tso_set_parsed,
4980 .help_str = "tso set <tso_segsz> <port_id>: "
4981 "Set TSO segment size of non-tunneled packets for csum engine "
4984 (void *)&cmd_tso_set_tso,
4985 (void *)&cmd_tso_set_mode,
4986 (void *)&cmd_tso_set_tso_segsz,
4987 (void *)&cmd_tso_set_portid,
4992 cmdline_parse_token_string_t cmd_tso_show_mode =
4993 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4997 cmdline_parse_inst_t cmd_tso_show = {
4998 .f = cmd_tso_set_parsed,
5000 .help_str = "tso show <port_id>: "
5001 "Show TSO segment size of non-tunneled packets for csum engine",
5003 (void *)&cmd_tso_set_tso,
5004 (void *)&cmd_tso_show_mode,
5005 (void *)&cmd_tso_set_portid,
5010 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
5011 struct cmd_tunnel_tso_set_result {
5012 cmdline_fixed_string_t tso;
5013 cmdline_fixed_string_t mode;
5018 static struct rte_eth_dev_info
5019 check_tunnel_tso_nic_support(portid_t port_id)
5021 struct rte_eth_dev_info dev_info;
5023 if (eth_dev_info_get_print_err(port_id, &dev_info) != 0)
5026 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO))
5027 printf("Warning: VXLAN TUNNEL TSO not supported therefore "
5028 "not enabled for port %d\n", port_id);
5029 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO))
5030 printf("Warning: GRE TUNNEL TSO not supported therefore "
5031 "not enabled for port %d\n", port_id);
5032 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO))
5033 printf("Warning: IPIP TUNNEL TSO not supported therefore "
5034 "not enabled for port %d\n", port_id);
5035 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
5036 printf("Warning: GENEVE TUNNEL TSO not supported therefore "
5037 "not enabled for port %d\n", port_id);
5038 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IP_TNL_TSO))
5039 printf("Warning: IP TUNNEL TSO not supported therefore "
5040 "not enabled for port %d\n", port_id);
5041 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_TNL_TSO))
5042 printf("Warning: UDP TUNNEL TSO not supported therefore "
5043 "not enabled for port %d\n", port_id);
5048 cmd_tunnel_tso_set_parsed(void *parsed_result,
5049 __rte_unused struct cmdline *cl,
5050 __rte_unused void *data)
5052 struct cmd_tunnel_tso_set_result *res = parsed_result;
5053 struct rte_eth_dev_info dev_info;
5055 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
5057 if (!port_is_stopped(res->port_id)) {
5058 printf("Please stop port %d first\n", res->port_id);
5062 if (!strcmp(res->mode, "set"))
5063 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
5065 dev_info = check_tunnel_tso_nic_support(res->port_id);
5066 if (ports[res->port_id].tunnel_tso_segsz == 0) {
5067 ports[res->port_id].dev_conf.txmode.offloads &=
5068 ~(DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
5069 DEV_TX_OFFLOAD_GRE_TNL_TSO |
5070 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
5071 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
5072 DEV_TX_OFFLOAD_IP_TNL_TSO |
5073 DEV_TX_OFFLOAD_UDP_TNL_TSO);
5074 printf("TSO for tunneled packets is disabled\n");
5076 uint64_t tso_offloads = (DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
5077 DEV_TX_OFFLOAD_GRE_TNL_TSO |
5078 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
5079 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
5080 DEV_TX_OFFLOAD_IP_TNL_TSO |
5081 DEV_TX_OFFLOAD_UDP_TNL_TSO);
5083 ports[res->port_id].dev_conf.txmode.offloads |=
5084 (tso_offloads & dev_info.tx_offload_capa);
5085 printf("TSO segment size for tunneled packets is %d\n",
5086 ports[res->port_id].tunnel_tso_segsz);
5088 /* Below conditions are needed to make it work:
5089 * (1) tunnel TSO is supported by the NIC;
5090 * (2) "csum parse_tunnel" must be set so that tunneled pkts
5092 * (3) for tunneled pkts with outer L3 of IPv4,
5093 * "csum set outer-ip" must be set to hw, because after tso,
5094 * total_len of outer IP header is changed, and the checksum
5095 * of outer IP header calculated by sw should be wrong; that
5096 * is not necessary for IPv6 tunneled pkts because there's no
5097 * checksum in IP header anymore.
5100 if (!ports[res->port_id].parse_tunnel)
5101 printf("Warning: csum parse_tunnel must be set "
5102 "so that tunneled packets are recognized\n");
5103 if (!(ports[res->port_id].dev_conf.txmode.offloads &
5104 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM))
5105 printf("Warning: csum set outer-ip must be set to hw "
5106 "if outer L3 is IPv4; not necessary for IPv6\n");
5109 cmd_config_queue_tx_offloads(&ports[res->port_id]);
5110 cmd_reconfig_device_queue(res->port_id, 1, 1);
5113 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
5114 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
5116 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
5117 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
5119 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
5120 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
5122 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
5123 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
5126 cmdline_parse_inst_t cmd_tunnel_tso_set = {
5127 .f = cmd_tunnel_tso_set_parsed,
5129 .help_str = "tunnel_tso set <tso_segsz> <port_id>: "
5130 "Set TSO segment size of tunneled packets for csum engine "
5133 (void *)&cmd_tunnel_tso_set_tso,
5134 (void *)&cmd_tunnel_tso_set_mode,
5135 (void *)&cmd_tunnel_tso_set_tso_segsz,
5136 (void *)&cmd_tunnel_tso_set_portid,
5141 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
5142 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
5146 cmdline_parse_inst_t cmd_tunnel_tso_show = {
5147 .f = cmd_tunnel_tso_set_parsed,
5149 .help_str = "tunnel_tso show <port_id> "
5150 "Show TSO segment size of tunneled packets for csum engine",
5152 (void *)&cmd_tunnel_tso_set_tso,
5153 (void *)&cmd_tunnel_tso_show_mode,
5154 (void *)&cmd_tunnel_tso_set_portid,
5159 /* *** SET GRO FOR A PORT *** */
5160 struct cmd_gro_enable_result {
5161 cmdline_fixed_string_t cmd_set;
5162 cmdline_fixed_string_t cmd_port;
5163 cmdline_fixed_string_t cmd_keyword;
5164 cmdline_fixed_string_t cmd_onoff;
5169 cmd_gro_enable_parsed(void *parsed_result,
5170 __rte_unused struct cmdline *cl,
5171 __rte_unused void *data)
5173 struct cmd_gro_enable_result *res;
5175 res = parsed_result;
5176 if (!strcmp(res->cmd_keyword, "gro"))
5177 setup_gro(res->cmd_onoff, res->cmd_pid);
5180 cmdline_parse_token_string_t cmd_gro_enable_set =
5181 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5183 cmdline_parse_token_string_t cmd_gro_enable_port =
5184 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5185 cmd_keyword, "port");
5186 cmdline_parse_token_num_t cmd_gro_enable_pid =
5187 TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result,
5189 cmdline_parse_token_string_t cmd_gro_enable_keyword =
5190 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5191 cmd_keyword, "gro");
5192 cmdline_parse_token_string_t cmd_gro_enable_onoff =
5193 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5194 cmd_onoff, "on#off");
5196 cmdline_parse_inst_t cmd_gro_enable = {
5197 .f = cmd_gro_enable_parsed,
5199 .help_str = "set port <port_id> gro on|off",
5201 (void *)&cmd_gro_enable_set,
5202 (void *)&cmd_gro_enable_port,
5203 (void *)&cmd_gro_enable_pid,
5204 (void *)&cmd_gro_enable_keyword,
5205 (void *)&cmd_gro_enable_onoff,
5210 /* *** DISPLAY GRO CONFIGURATION *** */
5211 struct cmd_gro_show_result {
5212 cmdline_fixed_string_t cmd_show;
5213 cmdline_fixed_string_t cmd_port;
5214 cmdline_fixed_string_t cmd_keyword;
5219 cmd_gro_show_parsed(void *parsed_result,
5220 __rte_unused struct cmdline *cl,
5221 __rte_unused void *data)
5223 struct cmd_gro_show_result *res;
5225 res = parsed_result;
5226 if (!strcmp(res->cmd_keyword, "gro"))
5227 show_gro(res->cmd_pid);
5230 cmdline_parse_token_string_t cmd_gro_show_show =
5231 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5233 cmdline_parse_token_string_t cmd_gro_show_port =
5234 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5236 cmdline_parse_token_num_t cmd_gro_show_pid =
5237 TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result,
5239 cmdline_parse_token_string_t cmd_gro_show_keyword =
5240 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5241 cmd_keyword, "gro");
5243 cmdline_parse_inst_t cmd_gro_show = {
5244 .f = cmd_gro_show_parsed,
5246 .help_str = "show port <port_id> gro",
5248 (void *)&cmd_gro_show_show,
5249 (void *)&cmd_gro_show_port,
5250 (void *)&cmd_gro_show_pid,
5251 (void *)&cmd_gro_show_keyword,
5256 /* *** SET FLUSH CYCLES FOR GRO *** */
5257 struct cmd_gro_flush_result {
5258 cmdline_fixed_string_t cmd_set;
5259 cmdline_fixed_string_t cmd_keyword;
5260 cmdline_fixed_string_t cmd_flush;
5265 cmd_gro_flush_parsed(void *parsed_result,
5266 __rte_unused struct cmdline *cl,
5267 __rte_unused void *data)
5269 struct cmd_gro_flush_result *res;
5271 res = parsed_result;
5272 if ((!strcmp(res->cmd_keyword, "gro")) &&
5273 (!strcmp(res->cmd_flush, "flush")))
5274 setup_gro_flush_cycles(res->cmd_cycles);
5277 cmdline_parse_token_string_t cmd_gro_flush_set =
5278 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5280 cmdline_parse_token_string_t cmd_gro_flush_keyword =
5281 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5282 cmd_keyword, "gro");
5283 cmdline_parse_token_string_t cmd_gro_flush_flush =
5284 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5285 cmd_flush, "flush");
5286 cmdline_parse_token_num_t cmd_gro_flush_cycles =
5287 TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result,
5290 cmdline_parse_inst_t cmd_gro_flush = {
5291 .f = cmd_gro_flush_parsed,
5293 .help_str = "set gro flush <cycles>",
5295 (void *)&cmd_gro_flush_set,
5296 (void *)&cmd_gro_flush_keyword,
5297 (void *)&cmd_gro_flush_flush,
5298 (void *)&cmd_gro_flush_cycles,
5303 /* *** ENABLE/DISABLE GSO *** */
5304 struct cmd_gso_enable_result {
5305 cmdline_fixed_string_t cmd_set;
5306 cmdline_fixed_string_t cmd_port;
5307 cmdline_fixed_string_t cmd_keyword;
5308 cmdline_fixed_string_t cmd_mode;
5313 cmd_gso_enable_parsed(void *parsed_result,
5314 __rte_unused struct cmdline *cl,
5315 __rte_unused void *data)
5317 struct cmd_gso_enable_result *res;
5319 res = parsed_result;
5320 if (!strcmp(res->cmd_keyword, "gso"))
5321 setup_gso(res->cmd_mode, res->cmd_pid);
5324 cmdline_parse_token_string_t cmd_gso_enable_set =
5325 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5327 cmdline_parse_token_string_t cmd_gso_enable_port =
5328 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5330 cmdline_parse_token_string_t cmd_gso_enable_keyword =
5331 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5332 cmd_keyword, "gso");
5333 cmdline_parse_token_string_t cmd_gso_enable_mode =
5334 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5335 cmd_mode, "on#off");
5336 cmdline_parse_token_num_t cmd_gso_enable_pid =
5337 TOKEN_NUM_INITIALIZER(struct cmd_gso_enable_result,
5340 cmdline_parse_inst_t cmd_gso_enable = {
5341 .f = cmd_gso_enable_parsed,
5343 .help_str = "set port <port_id> gso on|off",
5345 (void *)&cmd_gso_enable_set,
5346 (void *)&cmd_gso_enable_port,
5347 (void *)&cmd_gso_enable_pid,
5348 (void *)&cmd_gso_enable_keyword,
5349 (void *)&cmd_gso_enable_mode,
5354 /* *** SET MAX PACKET LENGTH FOR GSO SEGMENTS *** */
5355 struct cmd_gso_size_result {
5356 cmdline_fixed_string_t cmd_set;
5357 cmdline_fixed_string_t cmd_keyword;
5358 cmdline_fixed_string_t cmd_segsz;
5363 cmd_gso_size_parsed(void *parsed_result,
5364 __rte_unused struct cmdline *cl,
5365 __rte_unused void *data)
5367 struct cmd_gso_size_result *res = parsed_result;
5369 if (test_done == 0) {
5370 printf("Before setting GSO segsz, please first"
5371 " stop forwarding\n");
5375 if (!strcmp(res->cmd_keyword, "gso") &&
5376 !strcmp(res->cmd_segsz, "segsz")) {
5377 if (res->cmd_size < RTE_GSO_SEG_SIZE_MIN)
5378 printf("gso_size should be larger than %zu."
5379 " Please input a legal value\n",
5380 RTE_GSO_SEG_SIZE_MIN);
5382 gso_max_segment_size = res->cmd_size;
5386 cmdline_parse_token_string_t cmd_gso_size_set =
5387 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5389 cmdline_parse_token_string_t cmd_gso_size_keyword =
5390 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5391 cmd_keyword, "gso");
5392 cmdline_parse_token_string_t cmd_gso_size_segsz =
5393 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5394 cmd_segsz, "segsz");
5395 cmdline_parse_token_num_t cmd_gso_size_size =
5396 TOKEN_NUM_INITIALIZER(struct cmd_gso_size_result,
5399 cmdline_parse_inst_t cmd_gso_size = {
5400 .f = cmd_gso_size_parsed,
5402 .help_str = "set gso segsz <length>",
5404 (void *)&cmd_gso_size_set,
5405 (void *)&cmd_gso_size_keyword,
5406 (void *)&cmd_gso_size_segsz,
5407 (void *)&cmd_gso_size_size,
5412 /* *** SHOW GSO CONFIGURATION *** */
5413 struct cmd_gso_show_result {
5414 cmdline_fixed_string_t cmd_show;
5415 cmdline_fixed_string_t cmd_port;
5416 cmdline_fixed_string_t cmd_keyword;
5421 cmd_gso_show_parsed(void *parsed_result,
5422 __rte_unused struct cmdline *cl,
5423 __rte_unused void *data)
5425 struct cmd_gso_show_result *res = parsed_result;
5427 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
5428 printf("invalid port id %u\n", res->cmd_pid);
5431 if (!strcmp(res->cmd_keyword, "gso")) {
5432 if (gso_ports[res->cmd_pid].enable) {
5433 printf("Max GSO'd packet size: %uB\n"
5434 "Supported GSO types: TCP/IPv4, "
5435 "UDP/IPv4, VxLAN with inner "
5436 "TCP/IPv4 packet, GRE with inner "
5437 "TCP/IPv4 packet\n",
5438 gso_max_segment_size);
5440 printf("GSO is not enabled on Port %u\n", res->cmd_pid);
5444 cmdline_parse_token_string_t cmd_gso_show_show =
5445 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5447 cmdline_parse_token_string_t cmd_gso_show_port =
5448 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5450 cmdline_parse_token_string_t cmd_gso_show_keyword =
5451 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5452 cmd_keyword, "gso");
5453 cmdline_parse_token_num_t cmd_gso_show_pid =
5454 TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result,
5457 cmdline_parse_inst_t cmd_gso_show = {
5458 .f = cmd_gso_show_parsed,
5460 .help_str = "show port <port_id> gso",
5462 (void *)&cmd_gso_show_show,
5463 (void *)&cmd_gso_show_port,
5464 (void *)&cmd_gso_show_pid,
5465 (void *)&cmd_gso_show_keyword,
5470 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
5471 struct cmd_set_flush_rx {
5472 cmdline_fixed_string_t set;
5473 cmdline_fixed_string_t flush_rx;
5474 cmdline_fixed_string_t mode;
5478 cmd_set_flush_rx_parsed(void *parsed_result,
5479 __rte_unused struct cmdline *cl,
5480 __rte_unused void *data)
5482 struct cmd_set_flush_rx *res = parsed_result;
5483 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5486 cmdline_parse_token_string_t cmd_setflushrx_set =
5487 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5489 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
5490 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5491 flush_rx, "flush_rx");
5492 cmdline_parse_token_string_t cmd_setflushrx_mode =
5493 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5497 cmdline_parse_inst_t cmd_set_flush_rx = {
5498 .f = cmd_set_flush_rx_parsed,
5499 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
5502 (void *)&cmd_setflushrx_set,
5503 (void *)&cmd_setflushrx_flush_rx,
5504 (void *)&cmd_setflushrx_mode,
5509 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
5510 struct cmd_set_link_check {
5511 cmdline_fixed_string_t set;
5512 cmdline_fixed_string_t link_check;
5513 cmdline_fixed_string_t mode;
5517 cmd_set_link_check_parsed(void *parsed_result,
5518 __rte_unused struct cmdline *cl,
5519 __rte_unused void *data)
5521 struct cmd_set_link_check *res = parsed_result;
5522 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5525 cmdline_parse_token_string_t cmd_setlinkcheck_set =
5526 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5528 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
5529 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5530 link_check, "link_check");
5531 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
5532 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5536 cmdline_parse_inst_t cmd_set_link_check = {
5537 .f = cmd_set_link_check_parsed,
5538 .help_str = "set link_check on|off: Enable/Disable link status check "
5539 "when starting/stopping a port",
5542 (void *)&cmd_setlinkcheck_set,
5543 (void *)&cmd_setlinkcheck_link_check,
5544 (void *)&cmd_setlinkcheck_mode,
5549 /* *** SET NIC BYPASS MODE *** */
5550 struct cmd_set_bypass_mode_result {
5551 cmdline_fixed_string_t set;
5552 cmdline_fixed_string_t bypass;
5553 cmdline_fixed_string_t mode;
5554 cmdline_fixed_string_t value;
5559 cmd_set_bypass_mode_parsed(void *parsed_result,
5560 __rte_unused struct cmdline *cl,
5561 __rte_unused void *data)
5563 struct cmd_set_bypass_mode_result *res = parsed_result;
5564 portid_t port_id = res->port_id;
5565 int32_t rc = -EINVAL;
5567 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5568 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5570 if (!strcmp(res->value, "bypass"))
5571 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5572 else if (!strcmp(res->value, "isolate"))
5573 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5575 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5577 /* Set the bypass mode for the relevant port. */
5578 rc = rte_pmd_ixgbe_bypass_state_set(port_id, &bypass_mode);
5581 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
5584 cmdline_parse_token_string_t cmd_setbypass_mode_set =
5585 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5587 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
5588 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5590 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
5591 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5593 cmdline_parse_token_string_t cmd_setbypass_mode_value =
5594 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5595 value, "normal#bypass#isolate");
5596 cmdline_parse_token_num_t cmd_setbypass_mode_port =
5597 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
5600 cmdline_parse_inst_t cmd_set_bypass_mode = {
5601 .f = cmd_set_bypass_mode_parsed,
5602 .help_str = "set bypass mode normal|bypass|isolate <port_id>: "
5603 "Set the NIC bypass mode for port_id",
5606 (void *)&cmd_setbypass_mode_set,
5607 (void *)&cmd_setbypass_mode_bypass,
5608 (void *)&cmd_setbypass_mode_mode,
5609 (void *)&cmd_setbypass_mode_value,
5610 (void *)&cmd_setbypass_mode_port,
5615 /* *** SET NIC BYPASS EVENT *** */
5616 struct cmd_set_bypass_event_result {
5617 cmdline_fixed_string_t set;
5618 cmdline_fixed_string_t bypass;
5619 cmdline_fixed_string_t event;
5620 cmdline_fixed_string_t event_value;
5621 cmdline_fixed_string_t mode;
5622 cmdline_fixed_string_t mode_value;
5627 cmd_set_bypass_event_parsed(void *parsed_result,
5628 __rte_unused struct cmdline *cl,
5629 __rte_unused void *data)
5631 int32_t rc = -EINVAL;
5632 struct cmd_set_bypass_event_result *res = parsed_result;
5633 portid_t port_id = res->port_id;
5635 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5636 uint32_t bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5637 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5639 if (!strcmp(res->event_value, "timeout"))
5640 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT;
5641 else if (!strcmp(res->event_value, "os_on"))
5642 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_ON;
5643 else if (!strcmp(res->event_value, "os_off"))
5644 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_OFF;
5645 else if (!strcmp(res->event_value, "power_on"))
5646 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_ON;
5647 else if (!strcmp(res->event_value, "power_off"))
5648 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_OFF;
5650 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5652 if (!strcmp(res->mode_value, "bypass"))
5653 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5654 else if (!strcmp(res->mode_value, "isolate"))
5655 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5657 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5659 /* Set the watchdog timeout. */
5660 if (bypass_event == RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT) {
5663 if (RTE_PMD_IXGBE_BYPASS_TMT_VALID(bypass_timeout)) {
5664 rc = rte_pmd_ixgbe_bypass_wd_timeout_store(port_id,
5668 printf("Failed to set timeout value %u "
5669 "for port %d, errto code: %d.\n",
5670 bypass_timeout, port_id, rc);
5674 /* Set the bypass event to transition to bypass mode. */
5675 rc = rte_pmd_ixgbe_bypass_event_store(port_id, bypass_event,
5680 printf("\t Failed to set bypass event for port = %d.\n",
5684 cmdline_parse_token_string_t cmd_setbypass_event_set =
5685 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5687 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
5688 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5690 cmdline_parse_token_string_t cmd_setbypass_event_event =
5691 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5693 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
5694 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5695 event_value, "none#timeout#os_off#os_on#power_on#power_off");
5696 cmdline_parse_token_string_t cmd_setbypass_event_mode =
5697 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5699 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
5700 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5701 mode_value, "normal#bypass#isolate");
5702 cmdline_parse_token_num_t cmd_setbypass_event_port =
5703 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
5706 cmdline_parse_inst_t cmd_set_bypass_event = {
5707 .f = cmd_set_bypass_event_parsed,
5708 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
5709 "power_off mode normal|bypass|isolate <port_id>: "
5710 "Set the NIC bypass event mode for port_id",
5713 (void *)&cmd_setbypass_event_set,
5714 (void *)&cmd_setbypass_event_bypass,
5715 (void *)&cmd_setbypass_event_event,
5716 (void *)&cmd_setbypass_event_event_value,
5717 (void *)&cmd_setbypass_event_mode,
5718 (void *)&cmd_setbypass_event_mode_value,
5719 (void *)&cmd_setbypass_event_port,
5725 /* *** SET NIC BYPASS TIMEOUT *** */
5726 struct cmd_set_bypass_timeout_result {
5727 cmdline_fixed_string_t set;
5728 cmdline_fixed_string_t bypass;
5729 cmdline_fixed_string_t timeout;
5730 cmdline_fixed_string_t value;
5734 cmd_set_bypass_timeout_parsed(void *parsed_result,
5735 __rte_unused struct cmdline *cl,
5736 __rte_unused void *data)
5738 __rte_unused struct cmd_set_bypass_timeout_result *res = parsed_result;
5740 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5741 if (!strcmp(res->value, "1.5"))
5742 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_1_5_SEC;
5743 else if (!strcmp(res->value, "2"))
5744 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_2_SEC;
5745 else if (!strcmp(res->value, "3"))
5746 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_3_SEC;
5747 else if (!strcmp(res->value, "4"))
5748 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_4_SEC;
5749 else if (!strcmp(res->value, "8"))
5750 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_8_SEC;
5751 else if (!strcmp(res->value, "16"))
5752 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_16_SEC;
5753 else if (!strcmp(res->value, "32"))
5754 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_32_SEC;
5756 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5760 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
5761 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5763 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
5764 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5766 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
5767 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5768 timeout, "timeout");
5769 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
5770 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5771 value, "0#1.5#2#3#4#8#16#32");
5773 cmdline_parse_inst_t cmd_set_bypass_timeout = {
5774 .f = cmd_set_bypass_timeout_parsed,
5775 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
5776 "Set the NIC bypass watchdog timeout in seconds",
5779 (void *)&cmd_setbypass_timeout_set,
5780 (void *)&cmd_setbypass_timeout_bypass,
5781 (void *)&cmd_setbypass_timeout_timeout,
5782 (void *)&cmd_setbypass_timeout_value,
5787 /* *** SHOW NIC BYPASS MODE *** */
5788 struct cmd_show_bypass_config_result {
5789 cmdline_fixed_string_t show;
5790 cmdline_fixed_string_t bypass;
5791 cmdline_fixed_string_t config;
5796 cmd_show_bypass_config_parsed(void *parsed_result,
5797 __rte_unused struct cmdline *cl,
5798 __rte_unused void *data)
5800 struct cmd_show_bypass_config_result *res = parsed_result;
5801 portid_t port_id = res->port_id;
5803 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5804 uint32_t event_mode;
5805 uint32_t bypass_mode;
5806 uint32_t timeout = bypass_timeout;
5809 static const char * const timeouts[RTE_PMD_IXGBE_BYPASS_TMT_NUM] =
5810 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
5811 static const char * const modes[RTE_PMD_IXGBE_BYPASS_MODE_NUM] =
5812 {"UNKNOWN", "normal", "bypass", "isolate"};
5813 static const char * const events[RTE_PMD_IXGBE_BYPASS_EVENT_NUM] = {
5821 /* Display the bypass mode.*/
5822 if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) != 0) {
5823 printf("\tFailed to get bypass mode for port = %d\n", port_id);
5827 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(bypass_mode))
5828 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5830 printf("\tbypass mode = %s\n", modes[bypass_mode]);
5833 /* Display the bypass timeout.*/
5834 if (!RTE_PMD_IXGBE_BYPASS_TMT_VALID(timeout))
5835 timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5837 printf("\tbypass timeout = %s\n", timeouts[timeout]);
5839 /* Display the bypass events and associated modes. */
5840 for (i = RTE_PMD_IXGBE_BYPASS_EVENT_START; i < RTE_DIM(events); i++) {
5842 if (rte_pmd_ixgbe_bypass_event_show(port_id, i, &event_mode)) {
5843 printf("\tFailed to get bypass mode for event = %s\n",
5846 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(event_mode))
5847 event_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5849 printf("\tbypass event: %-16s = %s\n", events[i],
5855 printf("\tFailed to get bypass configuration for port = %d\n",
5859 cmdline_parse_token_string_t cmd_showbypass_config_show =
5860 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5862 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
5863 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5865 cmdline_parse_token_string_t cmd_showbypass_config_config =
5866 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5868 cmdline_parse_token_num_t cmd_showbypass_config_port =
5869 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
5872 cmdline_parse_inst_t cmd_show_bypass_config = {
5873 .f = cmd_show_bypass_config_parsed,
5874 .help_str = "show bypass config <port_id>: "
5875 "Show the NIC bypass config for port_id",
5878 (void *)&cmd_showbypass_config_show,
5879 (void *)&cmd_showbypass_config_bypass,
5880 (void *)&cmd_showbypass_config_config,
5881 (void *)&cmd_showbypass_config_port,
5887 /* *** SET BONDING MODE *** */
5888 struct cmd_set_bonding_mode_result {
5889 cmdline_fixed_string_t set;
5890 cmdline_fixed_string_t bonding;
5891 cmdline_fixed_string_t mode;
5896 static void cmd_set_bonding_mode_parsed(void *parsed_result,
5897 __rte_unused struct cmdline *cl,
5898 __rte_unused void *data)
5900 struct cmd_set_bonding_mode_result *res = parsed_result;
5901 portid_t port_id = res->port_id;
5903 /* Set the bonding mode for the relevant port. */
5904 if (0 != rte_eth_bond_mode_set(port_id, res->value))
5905 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
5908 cmdline_parse_token_string_t cmd_setbonding_mode_set =
5909 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5911 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
5912 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5913 bonding, "bonding");
5914 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
5915 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5917 cmdline_parse_token_num_t cmd_setbonding_mode_value =
5918 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5920 cmdline_parse_token_num_t cmd_setbonding_mode_port =
5921 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5924 cmdline_parse_inst_t cmd_set_bonding_mode = {
5925 .f = cmd_set_bonding_mode_parsed,
5926 .help_str = "set bonding mode <mode_value> <port_id>: "
5927 "Set the bonding mode for port_id",
5930 (void *) &cmd_setbonding_mode_set,
5931 (void *) &cmd_setbonding_mode_bonding,
5932 (void *) &cmd_setbonding_mode_mode,
5933 (void *) &cmd_setbonding_mode_value,
5934 (void *) &cmd_setbonding_mode_port,
5939 /* *** SET BONDING SLOW_QUEUE SW/HW *** */
5940 struct cmd_set_bonding_lacp_dedicated_queues_result {
5941 cmdline_fixed_string_t set;
5942 cmdline_fixed_string_t bonding;
5943 cmdline_fixed_string_t lacp;
5944 cmdline_fixed_string_t dedicated_queues;
5946 cmdline_fixed_string_t mode;
5949 static void cmd_set_bonding_lacp_dedicated_queues_parsed(void *parsed_result,
5950 __rte_unused struct cmdline *cl,
5951 __rte_unused void *data)
5953 struct cmd_set_bonding_lacp_dedicated_queues_result *res = parsed_result;
5954 portid_t port_id = res->port_id;
5955 struct rte_port *port;
5957 port = &ports[port_id];
5959 /** Check if the port is not started **/
5960 if (port->port_status != RTE_PORT_STOPPED) {
5961 printf("Please stop port %d first\n", port_id);
5965 if (!strcmp(res->mode, "enable")) {
5966 if (rte_eth_bond_8023ad_dedicated_queues_enable(port_id) == 0)
5967 printf("Dedicate queues for LACP control packets"
5970 printf("Enabling dedicate queues for LACP control "
5971 "packets on port %d failed\n", port_id);
5972 } else if (!strcmp(res->mode, "disable")) {
5973 if (rte_eth_bond_8023ad_dedicated_queues_disable(port_id) == 0)
5974 printf("Dedicated queues for LACP control packets "
5977 printf("Disabling dedicated queues for LACP control "
5978 "traffic on port %d failed\n", port_id);
5982 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_set =
5983 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5985 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_bonding =
5986 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5987 bonding, "bonding");
5988 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_lacp =
5989 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5991 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_dedicated_queues =
5992 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5993 dedicated_queues, "dedicated_queues");
5994 cmdline_parse_token_num_t cmd_setbonding_lacp_dedicated_queues_port_id =
5995 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5997 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_mode =
5998 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5999 mode, "enable#disable");
6001 cmdline_parse_inst_t cmd_set_lacp_dedicated_queues = {
6002 .f = cmd_set_bonding_lacp_dedicated_queues_parsed,
6003 .help_str = "set bonding lacp dedicated_queues <port_id> "
6005 "Enable/disable dedicated queues for LACP control traffic for port_id",
6008 (void *)&cmd_setbonding_lacp_dedicated_queues_set,
6009 (void *)&cmd_setbonding_lacp_dedicated_queues_bonding,
6010 (void *)&cmd_setbonding_lacp_dedicated_queues_lacp,
6011 (void *)&cmd_setbonding_lacp_dedicated_queues_dedicated_queues,
6012 (void *)&cmd_setbonding_lacp_dedicated_queues_port_id,
6013 (void *)&cmd_setbonding_lacp_dedicated_queues_mode,
6018 /* *** SET BALANCE XMIT POLICY *** */
6019 struct cmd_set_bonding_balance_xmit_policy_result {
6020 cmdline_fixed_string_t set;
6021 cmdline_fixed_string_t bonding;
6022 cmdline_fixed_string_t balance_xmit_policy;
6024 cmdline_fixed_string_t policy;
6027 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
6028 __rte_unused struct cmdline *cl,
6029 __rte_unused void *data)
6031 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
6032 portid_t port_id = res->port_id;
6035 if (!strcmp(res->policy, "l2")) {
6036 policy = BALANCE_XMIT_POLICY_LAYER2;
6037 } else if (!strcmp(res->policy, "l23")) {
6038 policy = BALANCE_XMIT_POLICY_LAYER23;
6039 } else if (!strcmp(res->policy, "l34")) {
6040 policy = BALANCE_XMIT_POLICY_LAYER34;
6042 printf("\t Invalid xmit policy selection");
6046 /* Set the bonding mode for the relevant port. */
6047 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
6048 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
6053 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
6054 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6056 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
6057 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6058 bonding, "bonding");
6059 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
6060 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6061 balance_xmit_policy, "balance_xmit_policy");
6062 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
6063 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6065 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
6066 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6067 policy, "l2#l23#l34");
6069 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
6070 .f = cmd_set_bonding_balance_xmit_policy_parsed,
6071 .help_str = "set bonding balance_xmit_policy <port_id> "
6073 "Set the bonding balance_xmit_policy for port_id",
6076 (void *)&cmd_setbonding_balance_xmit_policy_set,
6077 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
6078 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
6079 (void *)&cmd_setbonding_balance_xmit_policy_port,
6080 (void *)&cmd_setbonding_balance_xmit_policy_policy,
6085 /* *** SHOW NIC BONDING CONFIGURATION *** */
6086 struct cmd_show_bonding_config_result {
6087 cmdline_fixed_string_t show;
6088 cmdline_fixed_string_t bonding;
6089 cmdline_fixed_string_t config;
6093 static void cmd_show_bonding_config_parsed(void *parsed_result,
6094 __rte_unused struct cmdline *cl,
6095 __rte_unused void *data)
6097 struct cmd_show_bonding_config_result *res = parsed_result;
6098 int bonding_mode, agg_mode;
6099 portid_t slaves[RTE_MAX_ETHPORTS];
6100 int num_slaves, num_active_slaves;
6103 portid_t port_id = res->port_id;
6105 /* Display the bonding mode.*/
6106 bonding_mode = rte_eth_bond_mode_get(port_id);
6107 if (bonding_mode < 0) {
6108 printf("\tFailed to get bonding mode for port = %d\n", port_id);
6111 printf("\tBonding mode: %d\n", bonding_mode);
6113 if (bonding_mode == BONDING_MODE_BALANCE) {
6114 int balance_xmit_policy;
6116 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
6117 if (balance_xmit_policy < 0) {
6118 printf("\tFailed to get balance xmit policy for port = %d\n",
6122 printf("\tBalance Xmit Policy: ");
6124 switch (balance_xmit_policy) {
6125 case BALANCE_XMIT_POLICY_LAYER2:
6126 printf("BALANCE_XMIT_POLICY_LAYER2");
6128 case BALANCE_XMIT_POLICY_LAYER23:
6129 printf("BALANCE_XMIT_POLICY_LAYER23");
6131 case BALANCE_XMIT_POLICY_LAYER34:
6132 printf("BALANCE_XMIT_POLICY_LAYER34");
6139 if (bonding_mode == BONDING_MODE_8023AD) {
6140 agg_mode = rte_eth_bond_8023ad_agg_selection_get(port_id);
6141 printf("\tIEEE802.3AD Aggregator Mode: ");
6144 printf("bandwidth");
6156 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
6158 if (num_slaves < 0) {
6159 printf("\tFailed to get slave list for port = %d\n", port_id);
6162 if (num_slaves > 0) {
6163 printf("\tSlaves (%d): [", num_slaves);
6164 for (i = 0; i < num_slaves - 1; i++)
6165 printf("%d ", slaves[i]);
6167 printf("%d]\n", slaves[num_slaves - 1]);
6169 printf("\tSlaves: []\n");
6173 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
6176 if (num_active_slaves < 0) {
6177 printf("\tFailed to get active slave list for port = %d\n", port_id);
6180 if (num_active_slaves > 0) {
6181 printf("\tActive Slaves (%d): [", num_active_slaves);
6182 for (i = 0; i < num_active_slaves - 1; i++)
6183 printf("%d ", slaves[i]);
6185 printf("%d]\n", slaves[num_active_slaves - 1]);
6188 printf("\tActive Slaves: []\n");
6192 primary_id = rte_eth_bond_primary_get(port_id);
6193 if (primary_id < 0) {
6194 printf("\tFailed to get primary slave for port = %d\n", port_id);
6197 printf("\tPrimary: [%d]\n", primary_id);
6201 cmdline_parse_token_string_t cmd_showbonding_config_show =
6202 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6204 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
6205 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6206 bonding, "bonding");
6207 cmdline_parse_token_string_t cmd_showbonding_config_config =
6208 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6210 cmdline_parse_token_num_t cmd_showbonding_config_port =
6211 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
6214 cmdline_parse_inst_t cmd_show_bonding_config = {
6215 .f = cmd_show_bonding_config_parsed,
6216 .help_str = "show bonding config <port_id>: "
6217 "Show the bonding config for port_id",
6220 (void *)&cmd_showbonding_config_show,
6221 (void *)&cmd_showbonding_config_bonding,
6222 (void *)&cmd_showbonding_config_config,
6223 (void *)&cmd_showbonding_config_port,
6228 /* *** SET BONDING PRIMARY *** */
6229 struct cmd_set_bonding_primary_result {
6230 cmdline_fixed_string_t set;
6231 cmdline_fixed_string_t bonding;
6232 cmdline_fixed_string_t primary;
6237 static void cmd_set_bonding_primary_parsed(void *parsed_result,
6238 __rte_unused struct cmdline *cl,
6239 __rte_unused void *data)
6241 struct cmd_set_bonding_primary_result *res = parsed_result;
6242 portid_t master_port_id = res->port_id;
6243 portid_t slave_port_id = res->slave_id;
6245 /* Set the primary slave for a bonded device. */
6246 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
6247 printf("\t Failed to set primary slave for port = %d.\n",
6254 cmdline_parse_token_string_t cmd_setbonding_primary_set =
6255 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6257 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
6258 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6259 bonding, "bonding");
6260 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
6261 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6262 primary, "primary");
6263 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
6264 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
6266 cmdline_parse_token_num_t cmd_setbonding_primary_port =
6267 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
6270 cmdline_parse_inst_t cmd_set_bonding_primary = {
6271 .f = cmd_set_bonding_primary_parsed,
6272 .help_str = "set bonding primary <slave_id> <port_id>: "
6273 "Set the primary slave for port_id",
6276 (void *)&cmd_setbonding_primary_set,
6277 (void *)&cmd_setbonding_primary_bonding,
6278 (void *)&cmd_setbonding_primary_primary,
6279 (void *)&cmd_setbonding_primary_slave,
6280 (void *)&cmd_setbonding_primary_port,
6285 /* *** ADD SLAVE *** */
6286 struct cmd_add_bonding_slave_result {
6287 cmdline_fixed_string_t add;
6288 cmdline_fixed_string_t bonding;
6289 cmdline_fixed_string_t slave;
6294 static void cmd_add_bonding_slave_parsed(void *parsed_result,
6295 __rte_unused struct cmdline *cl,
6296 __rte_unused void *data)
6298 struct cmd_add_bonding_slave_result *res = parsed_result;
6299 portid_t master_port_id = res->port_id;
6300 portid_t slave_port_id = res->slave_id;
6302 /* add the slave for a bonded device. */
6303 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
6304 printf("\t Failed to add slave %d to master port = %d.\n",
6305 slave_port_id, master_port_id);
6309 set_port_slave_flag(slave_port_id);
6312 cmdline_parse_token_string_t cmd_addbonding_slave_add =
6313 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6315 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
6316 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6317 bonding, "bonding");
6318 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
6319 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6321 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
6322 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
6324 cmdline_parse_token_num_t cmd_addbonding_slave_port =
6325 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
6328 cmdline_parse_inst_t cmd_add_bonding_slave = {
6329 .f = cmd_add_bonding_slave_parsed,
6330 .help_str = "add bonding slave <slave_id> <port_id>: "
6331 "Add a slave device to a bonded device",
6334 (void *)&cmd_addbonding_slave_add,
6335 (void *)&cmd_addbonding_slave_bonding,
6336 (void *)&cmd_addbonding_slave_slave,
6337 (void *)&cmd_addbonding_slave_slaveid,
6338 (void *)&cmd_addbonding_slave_port,
6343 /* *** REMOVE SLAVE *** */
6344 struct cmd_remove_bonding_slave_result {
6345 cmdline_fixed_string_t remove;
6346 cmdline_fixed_string_t bonding;
6347 cmdline_fixed_string_t slave;
6352 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
6353 __rte_unused struct cmdline *cl,
6354 __rte_unused void *data)
6356 struct cmd_remove_bonding_slave_result *res = parsed_result;
6357 portid_t master_port_id = res->port_id;
6358 portid_t slave_port_id = res->slave_id;
6360 /* remove the slave from a bonded device. */
6361 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
6362 printf("\t Failed to remove slave %d from master port = %d.\n",
6363 slave_port_id, master_port_id);
6367 clear_port_slave_flag(slave_port_id);
6370 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
6371 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6373 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
6374 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6375 bonding, "bonding");
6376 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
6377 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6379 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
6380 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6382 cmdline_parse_token_num_t cmd_removebonding_slave_port =
6383 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6386 cmdline_parse_inst_t cmd_remove_bonding_slave = {
6387 .f = cmd_remove_bonding_slave_parsed,
6388 .help_str = "remove bonding slave <slave_id> <port_id>: "
6389 "Remove a slave device from a bonded device",
6392 (void *)&cmd_removebonding_slave_remove,
6393 (void *)&cmd_removebonding_slave_bonding,
6394 (void *)&cmd_removebonding_slave_slave,
6395 (void *)&cmd_removebonding_slave_slaveid,
6396 (void *)&cmd_removebonding_slave_port,
6401 /* *** CREATE BONDED DEVICE *** */
6402 struct cmd_create_bonded_device_result {
6403 cmdline_fixed_string_t create;
6404 cmdline_fixed_string_t bonded;
6405 cmdline_fixed_string_t device;
6410 static int bond_dev_num = 0;
6412 static void cmd_create_bonded_device_parsed(void *parsed_result,
6413 __rte_unused struct cmdline *cl,
6414 __rte_unused void *data)
6416 struct cmd_create_bonded_device_result *res = parsed_result;
6417 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
6421 if (test_done == 0) {
6422 printf("Please stop forwarding first\n");
6426 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bonding_testpmd_%d",
6429 /* Create a new bonded device. */
6430 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
6432 printf("\t Failed to create bonded device.\n");
6435 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
6438 /* Update number of ports */
6439 nb_ports = rte_eth_dev_count_avail();
6440 reconfig(port_id, res->socket);
6441 ret = rte_eth_promiscuous_enable(port_id);
6443 printf("Failed to enable promiscuous mode for port %u: %s - ignore\n",
6444 port_id, rte_strerror(-ret));
6446 ports[port_id].need_setup = 0;
6447 ports[port_id].port_status = RTE_PORT_STOPPED;
6452 cmdline_parse_token_string_t cmd_createbonded_device_create =
6453 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6455 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
6456 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6458 cmdline_parse_token_string_t cmd_createbonded_device_device =
6459 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6461 cmdline_parse_token_num_t cmd_createbonded_device_mode =
6462 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6464 cmdline_parse_token_num_t cmd_createbonded_device_socket =
6465 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6468 cmdline_parse_inst_t cmd_create_bonded_device = {
6469 .f = cmd_create_bonded_device_parsed,
6470 .help_str = "create bonded device <mode> <socket>: "
6471 "Create a new bonded device with specific bonding mode and socket",
6474 (void *)&cmd_createbonded_device_create,
6475 (void *)&cmd_createbonded_device_bonded,
6476 (void *)&cmd_createbonded_device_device,
6477 (void *)&cmd_createbonded_device_mode,
6478 (void *)&cmd_createbonded_device_socket,
6483 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
6484 struct cmd_set_bond_mac_addr_result {
6485 cmdline_fixed_string_t set;
6486 cmdline_fixed_string_t bonding;
6487 cmdline_fixed_string_t mac_addr;
6489 struct rte_ether_addr address;
6492 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
6493 __rte_unused struct cmdline *cl,
6494 __rte_unused void *data)
6496 struct cmd_set_bond_mac_addr_result *res = parsed_result;
6499 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
6502 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
6504 /* check the return value and print it if is < 0 */
6506 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
6509 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
6510 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
6511 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
6512 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
6514 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
6515 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
6517 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
6518 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result,
6520 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
6521 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
6523 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
6524 .f = cmd_set_bond_mac_addr_parsed,
6526 .help_str = "set bonding mac_addr <port_id> <mac_addr>",
6528 (void *)&cmd_set_bond_mac_addr_set,
6529 (void *)&cmd_set_bond_mac_addr_bonding,
6530 (void *)&cmd_set_bond_mac_addr_mac,
6531 (void *)&cmd_set_bond_mac_addr_portnum,
6532 (void *)&cmd_set_bond_mac_addr_addr,
6538 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
6539 struct cmd_set_bond_mon_period_result {
6540 cmdline_fixed_string_t set;
6541 cmdline_fixed_string_t bonding;
6542 cmdline_fixed_string_t mon_period;
6547 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
6548 __rte_unused struct cmdline *cl,
6549 __rte_unused void *data)
6551 struct cmd_set_bond_mon_period_result *res = parsed_result;
6554 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
6556 /* check the return value and print it if is < 0 */
6558 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
6561 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
6562 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6564 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
6565 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6566 bonding, "bonding");
6567 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
6568 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6569 mon_period, "mon_period");
6570 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
6571 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6573 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
6574 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6577 cmdline_parse_inst_t cmd_set_bond_mon_period = {
6578 .f = cmd_set_bond_mon_period_parsed,
6580 .help_str = "set bonding mon_period <port_id> <period_ms>",
6582 (void *)&cmd_set_bond_mon_period_set,
6583 (void *)&cmd_set_bond_mon_period_bonding,
6584 (void *)&cmd_set_bond_mon_period_mon_period,
6585 (void *)&cmd_set_bond_mon_period_portnum,
6586 (void *)&cmd_set_bond_mon_period_period_ms,
6593 struct cmd_set_bonding_agg_mode_policy_result {
6594 cmdline_fixed_string_t set;
6595 cmdline_fixed_string_t bonding;
6596 cmdline_fixed_string_t agg_mode;
6598 cmdline_fixed_string_t policy;
6603 cmd_set_bonding_agg_mode(void *parsed_result,
6604 __rte_unused struct cmdline *cl,
6605 __rte_unused void *data)
6607 struct cmd_set_bonding_agg_mode_policy_result *res = parsed_result;
6608 uint8_t policy = AGG_BANDWIDTH;
6610 if (!strcmp(res->policy, "bandwidth"))
6611 policy = AGG_BANDWIDTH;
6612 else if (!strcmp(res->policy, "stable"))
6613 policy = AGG_STABLE;
6614 else if (!strcmp(res->policy, "count"))
6617 rte_eth_bond_8023ad_agg_selection_set(res->port_num, policy);
6621 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_set =
6622 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6624 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_bonding =
6625 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6626 bonding, "bonding");
6628 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_agg_mode =
6629 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6630 agg_mode, "agg_mode");
6632 cmdline_parse_token_num_t cmd_set_bonding_agg_mode_portnum =
6633 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6636 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_policy_string =
6637 TOKEN_STRING_INITIALIZER(
6638 struct cmd_set_bonding_balance_xmit_policy_result,
6639 policy, "stable#bandwidth#count");
6641 cmdline_parse_inst_t cmd_set_bonding_agg_mode_policy = {
6642 .f = cmd_set_bonding_agg_mode,
6644 .help_str = "set bonding mode IEEE802.3AD aggregator policy <port_id> <agg_name>",
6646 (void *)&cmd_set_bonding_agg_mode_set,
6647 (void *)&cmd_set_bonding_agg_mode_bonding,
6648 (void *)&cmd_set_bonding_agg_mode_agg_mode,
6649 (void *)&cmd_set_bonding_agg_mode_portnum,
6650 (void *)&cmd_set_bonding_agg_mode_policy_string,
6656 #endif /* RTE_NET_BOND */
6658 /* *** SET FORWARDING MODE *** */
6659 struct cmd_set_fwd_mode_result {
6660 cmdline_fixed_string_t set;
6661 cmdline_fixed_string_t fwd;
6662 cmdline_fixed_string_t mode;
6665 static void cmd_set_fwd_mode_parsed(void *parsed_result,
6666 __rte_unused struct cmdline *cl,
6667 __rte_unused void *data)
6669 struct cmd_set_fwd_mode_result *res = parsed_result;
6672 set_pkt_forwarding_mode(res->mode);
6675 cmdline_parse_token_string_t cmd_setfwd_set =
6676 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
6677 cmdline_parse_token_string_t cmd_setfwd_fwd =
6678 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
6679 cmdline_parse_token_string_t cmd_setfwd_mode =
6680 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
6681 "" /* defined at init */);
6683 cmdline_parse_inst_t cmd_set_fwd_mode = {
6684 .f = cmd_set_fwd_mode_parsed,
6686 .help_str = NULL, /* defined at init */
6688 (void *)&cmd_setfwd_set,
6689 (void *)&cmd_setfwd_fwd,
6690 (void *)&cmd_setfwd_mode,
6695 static void cmd_set_fwd_mode_init(void)
6698 static char token[128];
6699 static char help[256];
6700 cmdline_parse_token_string_t *token_struct;
6702 modes = list_pkt_forwarding_modes();
6703 snprintf(help, sizeof(help), "set fwd %s: "
6704 "Set packet forwarding mode", modes);
6705 cmd_set_fwd_mode.help_str = help;
6707 /* string token separator is # */
6708 for (c = token; *modes != '\0'; modes++)
6713 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
6714 token_struct->string_data.str = token;
6717 /* *** SET RETRY FORWARDING MODE *** */
6718 struct cmd_set_fwd_retry_mode_result {
6719 cmdline_fixed_string_t set;
6720 cmdline_fixed_string_t fwd;
6721 cmdline_fixed_string_t mode;
6722 cmdline_fixed_string_t retry;
6725 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
6726 __rte_unused struct cmdline *cl,
6727 __rte_unused void *data)
6729 struct cmd_set_fwd_retry_mode_result *res = parsed_result;
6732 set_pkt_forwarding_mode(res->mode);
6735 cmdline_parse_token_string_t cmd_setfwd_retry_set =
6736 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6738 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
6739 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6741 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
6742 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6744 "" /* defined at init */);
6745 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
6746 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6749 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
6750 .f = cmd_set_fwd_retry_mode_parsed,
6752 .help_str = NULL, /* defined at init */
6754 (void *)&cmd_setfwd_retry_set,
6755 (void *)&cmd_setfwd_retry_fwd,
6756 (void *)&cmd_setfwd_retry_mode,
6757 (void *)&cmd_setfwd_retry_retry,
6762 static void cmd_set_fwd_retry_mode_init(void)
6765 static char token[128];
6766 static char help[256];
6767 cmdline_parse_token_string_t *token_struct;
6769 modes = list_pkt_forwarding_retry_modes();
6770 snprintf(help, sizeof(help), "set fwd %s retry: "
6771 "Set packet forwarding mode with retry", modes);
6772 cmd_set_fwd_retry_mode.help_str = help;
6774 /* string token separator is # */
6775 for (c = token; *modes != '\0'; modes++)
6780 token_struct = (cmdline_parse_token_string_t *)
6781 cmd_set_fwd_retry_mode.tokens[2];
6782 token_struct->string_data.str = token;
6785 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
6786 struct cmd_set_burst_tx_retry_result {
6787 cmdline_fixed_string_t set;
6788 cmdline_fixed_string_t burst;
6789 cmdline_fixed_string_t tx;
6790 cmdline_fixed_string_t delay;
6792 cmdline_fixed_string_t retry;
6796 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
6797 __rte_unused struct cmdline *cl,
6798 __rte_unused void *data)
6800 struct cmd_set_burst_tx_retry_result *res = parsed_result;
6802 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
6803 && !strcmp(res->tx, "tx")) {
6804 if (!strcmp(res->delay, "delay"))
6805 burst_tx_delay_time = res->time;
6806 if (!strcmp(res->retry, "retry"))
6807 burst_tx_retry_num = res->retry_num;
6812 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
6813 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
6814 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
6815 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
6817 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
6818 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
6819 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
6820 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
6821 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
6822 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
6823 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
6824 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
6825 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
6826 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
6828 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
6829 .f = cmd_set_burst_tx_retry_parsed,
6830 .help_str = "set burst tx delay <delay_usec> retry <num_retry>",
6832 (void *)&cmd_set_burst_tx_retry_set,
6833 (void *)&cmd_set_burst_tx_retry_burst,
6834 (void *)&cmd_set_burst_tx_retry_tx,
6835 (void *)&cmd_set_burst_tx_retry_delay,
6836 (void *)&cmd_set_burst_tx_retry_time,
6837 (void *)&cmd_set_burst_tx_retry_retry,
6838 (void *)&cmd_set_burst_tx_retry_retry_num,
6843 /* *** SET PROMISC MODE *** */
6844 struct cmd_set_promisc_mode_result {
6845 cmdline_fixed_string_t set;
6846 cmdline_fixed_string_t promisc;
6847 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6848 uint16_t port_num; /* valid if "allports" argument == 0 */
6849 cmdline_fixed_string_t mode;
6852 static void cmd_set_promisc_mode_parsed(void *parsed_result,
6853 __rte_unused struct cmdline *cl,
6856 struct cmd_set_promisc_mode_result *res = parsed_result;
6860 if (!strcmp(res->mode, "on"))
6867 RTE_ETH_FOREACH_DEV(i)
6868 eth_set_promisc_mode(i, enable);
6870 eth_set_promisc_mode(res->port_num, enable);
6874 cmdline_parse_token_string_t cmd_setpromisc_set =
6875 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
6876 cmdline_parse_token_string_t cmd_setpromisc_promisc =
6877 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
6879 cmdline_parse_token_string_t cmd_setpromisc_portall =
6880 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
6882 cmdline_parse_token_num_t cmd_setpromisc_portnum =
6883 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
6885 cmdline_parse_token_string_t cmd_setpromisc_mode =
6886 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
6889 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
6890 .f = cmd_set_promisc_mode_parsed,
6892 .help_str = "set promisc all on|off: Set promisc mode for all ports",
6894 (void *)&cmd_setpromisc_set,
6895 (void *)&cmd_setpromisc_promisc,
6896 (void *)&cmd_setpromisc_portall,
6897 (void *)&cmd_setpromisc_mode,
6902 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
6903 .f = cmd_set_promisc_mode_parsed,
6905 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
6907 (void *)&cmd_setpromisc_set,
6908 (void *)&cmd_setpromisc_promisc,
6909 (void *)&cmd_setpromisc_portnum,
6910 (void *)&cmd_setpromisc_mode,
6915 /* *** SET ALLMULTI MODE *** */
6916 struct cmd_set_allmulti_mode_result {
6917 cmdline_fixed_string_t set;
6918 cmdline_fixed_string_t allmulti;
6919 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6920 uint16_t port_num; /* valid if "allports" argument == 0 */
6921 cmdline_fixed_string_t mode;
6924 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
6925 __rte_unused struct cmdline *cl,
6928 struct cmd_set_allmulti_mode_result *res = parsed_result;
6932 if (!strcmp(res->mode, "on"))
6939 RTE_ETH_FOREACH_DEV(i) {
6940 eth_set_allmulticast_mode(i, enable);
6944 eth_set_allmulticast_mode(res->port_num, enable);
6948 cmdline_parse_token_string_t cmd_setallmulti_set =
6949 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
6950 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
6951 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
6953 cmdline_parse_token_string_t cmd_setallmulti_portall =
6954 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
6956 cmdline_parse_token_num_t cmd_setallmulti_portnum =
6957 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
6959 cmdline_parse_token_string_t cmd_setallmulti_mode =
6960 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
6963 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
6964 .f = cmd_set_allmulti_mode_parsed,
6966 .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
6968 (void *)&cmd_setallmulti_set,
6969 (void *)&cmd_setallmulti_allmulti,
6970 (void *)&cmd_setallmulti_portall,
6971 (void *)&cmd_setallmulti_mode,
6976 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
6977 .f = cmd_set_allmulti_mode_parsed,
6979 .help_str = "set allmulti <port_id> on|off: "
6980 "Set allmulti mode on port_id",
6982 (void *)&cmd_setallmulti_set,
6983 (void *)&cmd_setallmulti_allmulti,
6984 (void *)&cmd_setallmulti_portnum,
6985 (void *)&cmd_setallmulti_mode,
6990 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
6991 struct cmd_link_flow_ctrl_set_result {
6992 cmdline_fixed_string_t set;
6993 cmdline_fixed_string_t flow_ctrl;
6994 cmdline_fixed_string_t rx;
6995 cmdline_fixed_string_t rx_lfc_mode;
6996 cmdline_fixed_string_t tx;
6997 cmdline_fixed_string_t tx_lfc_mode;
6998 cmdline_fixed_string_t mac_ctrl_frame_fwd;
6999 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
7000 cmdline_fixed_string_t autoneg_str;
7001 cmdline_fixed_string_t autoneg;
7002 cmdline_fixed_string_t hw_str;
7003 uint32_t high_water;
7004 cmdline_fixed_string_t lw_str;
7006 cmdline_fixed_string_t pt_str;
7007 uint16_t pause_time;
7008 cmdline_fixed_string_t xon_str;
7013 cmdline_parse_token_string_t cmd_lfc_set_set =
7014 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7016 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
7017 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7018 flow_ctrl, "flow_ctrl");
7019 cmdline_parse_token_string_t cmd_lfc_set_rx =
7020 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7022 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
7023 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7024 rx_lfc_mode, "on#off");
7025 cmdline_parse_token_string_t cmd_lfc_set_tx =
7026 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7028 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
7029 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7030 tx_lfc_mode, "on#off");
7031 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
7032 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7033 hw_str, "high_water");
7034 cmdline_parse_token_num_t cmd_lfc_set_high_water =
7035 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7036 high_water, UINT32);
7037 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
7038 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7039 lw_str, "low_water");
7040 cmdline_parse_token_num_t cmd_lfc_set_low_water =
7041 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7043 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
7044 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7045 pt_str, "pause_time");
7046 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
7047 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7048 pause_time, UINT16);
7049 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
7050 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7051 xon_str, "send_xon");
7052 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
7053 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7055 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
7056 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7057 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
7058 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
7059 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7060 mac_ctrl_frame_fwd_mode, "on#off");
7061 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
7062 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7063 autoneg_str, "autoneg");
7064 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
7065 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7067 cmdline_parse_token_num_t cmd_lfc_set_portid =
7068 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7071 /* forward declaration */
7073 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
7076 cmdline_parse_inst_t cmd_link_flow_control_set = {
7077 .f = cmd_link_flow_ctrl_set_parsed,
7079 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
7080 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
7081 "autoneg on|off <port_id>: Configure the Ethernet flow control",
7083 (void *)&cmd_lfc_set_set,
7084 (void *)&cmd_lfc_set_flow_ctrl,
7085 (void *)&cmd_lfc_set_rx,
7086 (void *)&cmd_lfc_set_rx_mode,
7087 (void *)&cmd_lfc_set_tx,
7088 (void *)&cmd_lfc_set_tx_mode,
7089 (void *)&cmd_lfc_set_high_water,
7090 (void *)&cmd_lfc_set_low_water,
7091 (void *)&cmd_lfc_set_pause_time,
7092 (void *)&cmd_lfc_set_send_xon,
7093 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
7094 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
7095 (void *)&cmd_lfc_set_autoneg_str,
7096 (void *)&cmd_lfc_set_autoneg,
7097 (void *)&cmd_lfc_set_portid,
7102 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
7103 .f = cmd_link_flow_ctrl_set_parsed,
7104 .data = (void *)&cmd_link_flow_control_set_rx,
7105 .help_str = "set flow_ctrl rx on|off <port_id>: "
7106 "Change rx flow control parameter",
7108 (void *)&cmd_lfc_set_set,
7109 (void *)&cmd_lfc_set_flow_ctrl,
7110 (void *)&cmd_lfc_set_rx,
7111 (void *)&cmd_lfc_set_rx_mode,
7112 (void *)&cmd_lfc_set_portid,
7117 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
7118 .f = cmd_link_flow_ctrl_set_parsed,
7119 .data = (void *)&cmd_link_flow_control_set_tx,
7120 .help_str = "set flow_ctrl tx on|off <port_id>: "
7121 "Change tx flow control parameter",
7123 (void *)&cmd_lfc_set_set,
7124 (void *)&cmd_lfc_set_flow_ctrl,
7125 (void *)&cmd_lfc_set_tx,
7126 (void *)&cmd_lfc_set_tx_mode,
7127 (void *)&cmd_lfc_set_portid,
7132 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
7133 .f = cmd_link_flow_ctrl_set_parsed,
7134 .data = (void *)&cmd_link_flow_control_set_hw,
7135 .help_str = "set flow_ctrl high_water <value> <port_id>: "
7136 "Change high water flow control parameter",
7138 (void *)&cmd_lfc_set_set,
7139 (void *)&cmd_lfc_set_flow_ctrl,
7140 (void *)&cmd_lfc_set_high_water_str,
7141 (void *)&cmd_lfc_set_high_water,
7142 (void *)&cmd_lfc_set_portid,
7147 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
7148 .f = cmd_link_flow_ctrl_set_parsed,
7149 .data = (void *)&cmd_link_flow_control_set_lw,
7150 .help_str = "set flow_ctrl low_water <value> <port_id>: "
7151 "Change low water flow control parameter",
7153 (void *)&cmd_lfc_set_set,
7154 (void *)&cmd_lfc_set_flow_ctrl,
7155 (void *)&cmd_lfc_set_low_water_str,
7156 (void *)&cmd_lfc_set_low_water,
7157 (void *)&cmd_lfc_set_portid,
7162 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
7163 .f = cmd_link_flow_ctrl_set_parsed,
7164 .data = (void *)&cmd_link_flow_control_set_pt,
7165 .help_str = "set flow_ctrl pause_time <value> <port_id>: "
7166 "Change pause time flow control parameter",
7168 (void *)&cmd_lfc_set_set,
7169 (void *)&cmd_lfc_set_flow_ctrl,
7170 (void *)&cmd_lfc_set_pause_time_str,
7171 (void *)&cmd_lfc_set_pause_time,
7172 (void *)&cmd_lfc_set_portid,
7177 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
7178 .f = cmd_link_flow_ctrl_set_parsed,
7179 .data = (void *)&cmd_link_flow_control_set_xon,
7180 .help_str = "set flow_ctrl send_xon <value> <port_id>: "
7181 "Change send_xon flow control parameter",
7183 (void *)&cmd_lfc_set_set,
7184 (void *)&cmd_lfc_set_flow_ctrl,
7185 (void *)&cmd_lfc_set_send_xon_str,
7186 (void *)&cmd_lfc_set_send_xon,
7187 (void *)&cmd_lfc_set_portid,
7192 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
7193 .f = cmd_link_flow_ctrl_set_parsed,
7194 .data = (void *)&cmd_link_flow_control_set_macfwd,
7195 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
7196 "Change mac ctrl fwd flow control parameter",
7198 (void *)&cmd_lfc_set_set,
7199 (void *)&cmd_lfc_set_flow_ctrl,
7200 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
7201 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
7202 (void *)&cmd_lfc_set_portid,
7207 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
7208 .f = cmd_link_flow_ctrl_set_parsed,
7209 .data = (void *)&cmd_link_flow_control_set_autoneg,
7210 .help_str = "set flow_ctrl autoneg on|off <port_id>: "
7211 "Change autoneg flow control parameter",
7213 (void *)&cmd_lfc_set_set,
7214 (void *)&cmd_lfc_set_flow_ctrl,
7215 (void *)&cmd_lfc_set_autoneg_str,
7216 (void *)&cmd_lfc_set_autoneg,
7217 (void *)&cmd_lfc_set_portid,
7223 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
7224 __rte_unused struct cmdline *cl,
7227 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
7228 cmdline_parse_inst_t *cmd = data;
7229 struct rte_eth_fc_conf fc_conf;
7235 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
7236 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
7237 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
7238 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
7240 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
7241 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
7244 /* Partial command line, retrieve current configuration */
7246 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
7248 printf("cannot get current flow ctrl parameters, return"
7249 "code = %d\n", ret);
7253 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
7254 (fc_conf.mode == RTE_FC_FULL))
7256 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
7257 (fc_conf.mode == RTE_FC_FULL))
7261 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
7262 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
7264 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
7265 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
7267 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
7269 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
7270 fc_conf.high_water = res->high_water;
7272 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
7273 fc_conf.low_water = res->low_water;
7275 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
7276 fc_conf.pause_time = res->pause_time;
7278 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
7279 fc_conf.send_xon = res->send_xon;
7281 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
7282 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
7283 fc_conf.mac_ctrl_frame_fwd = 1;
7285 fc_conf.mac_ctrl_frame_fwd = 0;
7288 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
7289 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
7291 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
7293 printf("bad flow contrl parameter, return code = %d \n", ret);
7296 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
7297 struct cmd_priority_flow_ctrl_set_result {
7298 cmdline_fixed_string_t set;
7299 cmdline_fixed_string_t pfc_ctrl;
7300 cmdline_fixed_string_t rx;
7301 cmdline_fixed_string_t rx_pfc_mode;
7302 cmdline_fixed_string_t tx;
7303 cmdline_fixed_string_t tx_pfc_mode;
7304 uint32_t high_water;
7306 uint16_t pause_time;
7312 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
7313 __rte_unused struct cmdline *cl,
7314 __rte_unused void *data)
7316 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
7317 struct rte_eth_pfc_conf pfc_conf;
7318 int rx_fc_enable, tx_fc_enable;
7322 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
7323 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
7324 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
7325 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
7327 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
7328 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
7331 memset(&pfc_conf, 0, sizeof(struct rte_eth_pfc_conf));
7332 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
7333 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
7334 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
7335 pfc_conf.fc.high_water = res->high_water;
7336 pfc_conf.fc.low_water = res->low_water;
7337 pfc_conf.fc.pause_time = res->pause_time;
7338 pfc_conf.priority = res->priority;
7340 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
7342 printf("bad priority flow contrl parameter, return code = %d \n", ret);
7345 cmdline_parse_token_string_t cmd_pfc_set_set =
7346 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7348 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
7349 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7350 pfc_ctrl, "pfc_ctrl");
7351 cmdline_parse_token_string_t cmd_pfc_set_rx =
7352 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7354 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
7355 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7356 rx_pfc_mode, "on#off");
7357 cmdline_parse_token_string_t cmd_pfc_set_tx =
7358 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7360 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
7361 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7362 tx_pfc_mode, "on#off");
7363 cmdline_parse_token_num_t cmd_pfc_set_high_water =
7364 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7365 high_water, UINT32);
7366 cmdline_parse_token_num_t cmd_pfc_set_low_water =
7367 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7369 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
7370 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7371 pause_time, UINT16);
7372 cmdline_parse_token_num_t cmd_pfc_set_priority =
7373 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7375 cmdline_parse_token_num_t cmd_pfc_set_portid =
7376 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7379 cmdline_parse_inst_t cmd_priority_flow_control_set = {
7380 .f = cmd_priority_flow_ctrl_set_parsed,
7382 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
7383 "<pause_time> <priority> <port_id>: "
7384 "Configure the Ethernet priority flow control",
7386 (void *)&cmd_pfc_set_set,
7387 (void *)&cmd_pfc_set_flow_ctrl,
7388 (void *)&cmd_pfc_set_rx,
7389 (void *)&cmd_pfc_set_rx_mode,
7390 (void *)&cmd_pfc_set_tx,
7391 (void *)&cmd_pfc_set_tx_mode,
7392 (void *)&cmd_pfc_set_high_water,
7393 (void *)&cmd_pfc_set_low_water,
7394 (void *)&cmd_pfc_set_pause_time,
7395 (void *)&cmd_pfc_set_priority,
7396 (void *)&cmd_pfc_set_portid,
7401 /* *** RESET CONFIGURATION *** */
7402 struct cmd_reset_result {
7403 cmdline_fixed_string_t reset;
7404 cmdline_fixed_string_t def;
7407 static void cmd_reset_parsed(__rte_unused void *parsed_result,
7409 __rte_unused void *data)
7411 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
7412 set_def_fwd_config();
7415 cmdline_parse_token_string_t cmd_reset_set =
7416 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
7417 cmdline_parse_token_string_t cmd_reset_def =
7418 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
7421 cmdline_parse_inst_t cmd_reset = {
7422 .f = cmd_reset_parsed,
7424 .help_str = "set default: Reset default forwarding configuration",
7426 (void *)&cmd_reset_set,
7427 (void *)&cmd_reset_def,
7432 /* *** START FORWARDING *** */
7433 struct cmd_start_result {
7434 cmdline_fixed_string_t start;
7437 cmdline_parse_token_string_t cmd_start_start =
7438 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
7440 static void cmd_start_parsed(__rte_unused void *parsed_result,
7441 __rte_unused struct cmdline *cl,
7442 __rte_unused void *data)
7444 start_packet_forwarding(0);
7447 cmdline_parse_inst_t cmd_start = {
7448 .f = cmd_start_parsed,
7450 .help_str = "start: Start packet forwarding",
7452 (void *)&cmd_start_start,
7457 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
7458 struct cmd_start_tx_first_result {
7459 cmdline_fixed_string_t start;
7460 cmdline_fixed_string_t tx_first;
7464 cmd_start_tx_first_parsed(__rte_unused void *parsed_result,
7465 __rte_unused struct cmdline *cl,
7466 __rte_unused void *data)
7468 start_packet_forwarding(1);
7471 cmdline_parse_token_string_t cmd_start_tx_first_start =
7472 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
7474 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
7475 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
7476 tx_first, "tx_first");
7478 cmdline_parse_inst_t cmd_start_tx_first = {
7479 .f = cmd_start_tx_first_parsed,
7481 .help_str = "start tx_first: Start packet forwarding, "
7482 "after sending 1 burst of packets",
7484 (void *)&cmd_start_tx_first_start,
7485 (void *)&cmd_start_tx_first_tx_first,
7490 /* *** START FORWARDING WITH N TX BURST FIRST *** */
7491 struct cmd_start_tx_first_n_result {
7492 cmdline_fixed_string_t start;
7493 cmdline_fixed_string_t tx_first;
7498 cmd_start_tx_first_n_parsed(void *parsed_result,
7499 __rte_unused struct cmdline *cl,
7500 __rte_unused void *data)
7502 struct cmd_start_tx_first_n_result *res = parsed_result;
7504 start_packet_forwarding(res->tx_num);
7507 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
7508 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7510 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
7511 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7512 tx_first, "tx_first");
7513 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
7514 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
7517 cmdline_parse_inst_t cmd_start_tx_first_n = {
7518 .f = cmd_start_tx_first_n_parsed,
7520 .help_str = "start tx_first <num>: "
7521 "packet forwarding, after sending <num> bursts of packets",
7523 (void *)&cmd_start_tx_first_n_start,
7524 (void *)&cmd_start_tx_first_n_tx_first,
7525 (void *)&cmd_start_tx_first_n_tx_num,
7530 /* *** SET LINK UP *** */
7531 struct cmd_set_link_up_result {
7532 cmdline_fixed_string_t set;
7533 cmdline_fixed_string_t link_up;
7534 cmdline_fixed_string_t port;
7538 cmdline_parse_token_string_t cmd_set_link_up_set =
7539 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
7540 cmdline_parse_token_string_t cmd_set_link_up_link_up =
7541 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
7543 cmdline_parse_token_string_t cmd_set_link_up_port =
7544 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
7545 cmdline_parse_token_num_t cmd_set_link_up_port_id =
7546 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT16);
7548 static void cmd_set_link_up_parsed(__rte_unused void *parsed_result,
7549 __rte_unused struct cmdline *cl,
7550 __rte_unused void *data)
7552 struct cmd_set_link_up_result *res = parsed_result;
7553 dev_set_link_up(res->port_id);
7556 cmdline_parse_inst_t cmd_set_link_up = {
7557 .f = cmd_set_link_up_parsed,
7559 .help_str = "set link-up port <port id>",
7561 (void *)&cmd_set_link_up_set,
7562 (void *)&cmd_set_link_up_link_up,
7563 (void *)&cmd_set_link_up_port,
7564 (void *)&cmd_set_link_up_port_id,
7569 /* *** SET LINK DOWN *** */
7570 struct cmd_set_link_down_result {
7571 cmdline_fixed_string_t set;
7572 cmdline_fixed_string_t link_down;
7573 cmdline_fixed_string_t port;
7577 cmdline_parse_token_string_t cmd_set_link_down_set =
7578 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
7579 cmdline_parse_token_string_t cmd_set_link_down_link_down =
7580 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
7582 cmdline_parse_token_string_t cmd_set_link_down_port =
7583 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
7584 cmdline_parse_token_num_t cmd_set_link_down_port_id =
7585 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT16);
7587 static void cmd_set_link_down_parsed(
7588 __rte_unused void *parsed_result,
7589 __rte_unused struct cmdline *cl,
7590 __rte_unused void *data)
7592 struct cmd_set_link_down_result *res = parsed_result;
7593 dev_set_link_down(res->port_id);
7596 cmdline_parse_inst_t cmd_set_link_down = {
7597 .f = cmd_set_link_down_parsed,
7599 .help_str = "set link-down port <port id>",
7601 (void *)&cmd_set_link_down_set,
7602 (void *)&cmd_set_link_down_link_down,
7603 (void *)&cmd_set_link_down_port,
7604 (void *)&cmd_set_link_down_port_id,
7609 /* *** SHOW CFG *** */
7610 struct cmd_showcfg_result {
7611 cmdline_fixed_string_t show;
7612 cmdline_fixed_string_t cfg;
7613 cmdline_fixed_string_t what;
7616 static void cmd_showcfg_parsed(void *parsed_result,
7617 __rte_unused struct cmdline *cl,
7618 __rte_unused void *data)
7620 struct cmd_showcfg_result *res = parsed_result;
7621 if (!strcmp(res->what, "rxtx"))
7622 rxtx_config_display();
7623 else if (!strcmp(res->what, "cores"))
7624 fwd_lcores_config_display();
7625 else if (!strcmp(res->what, "fwd"))
7626 pkt_fwd_config_display(&cur_fwd_config);
7627 else if (!strcmp(res->what, "rxoffs"))
7628 show_rx_pkt_offsets();
7629 else if (!strcmp(res->what, "rxpkts"))
7630 show_rx_pkt_segments();
7631 else if (!strcmp(res->what, "txpkts"))
7632 show_tx_pkt_segments();
7633 else if (!strcmp(res->what, "txtimes"))
7634 show_tx_pkt_times();
7637 cmdline_parse_token_string_t cmd_showcfg_show =
7638 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
7639 cmdline_parse_token_string_t cmd_showcfg_port =
7640 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
7641 cmdline_parse_token_string_t cmd_showcfg_what =
7642 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
7643 "rxtx#cores#fwd#rxoffs#rxpkts#txpkts#txtimes");
7645 cmdline_parse_inst_t cmd_showcfg = {
7646 .f = cmd_showcfg_parsed,
7648 .help_str = "show config rxtx|cores|fwd|rxoffs|rxpkts|txpkts|txtimes",
7650 (void *)&cmd_showcfg_show,
7651 (void *)&cmd_showcfg_port,
7652 (void *)&cmd_showcfg_what,
7657 /* *** SHOW ALL PORT INFO *** */
7658 struct cmd_showportall_result {
7659 cmdline_fixed_string_t show;
7660 cmdline_fixed_string_t port;
7661 cmdline_fixed_string_t what;
7662 cmdline_fixed_string_t all;
7665 static void cmd_showportall_parsed(void *parsed_result,
7666 __rte_unused struct cmdline *cl,
7667 __rte_unused void *data)
7671 struct cmd_showportall_result *res = parsed_result;
7672 if (!strcmp(res->show, "clear")) {
7673 if (!strcmp(res->what, "stats"))
7674 RTE_ETH_FOREACH_DEV(i)
7676 else if (!strcmp(res->what, "xstats"))
7677 RTE_ETH_FOREACH_DEV(i)
7678 nic_xstats_clear(i);
7679 } else if (!strcmp(res->what, "info"))
7680 RTE_ETH_FOREACH_DEV(i)
7681 port_infos_display(i);
7682 else if (!strcmp(res->what, "summary")) {
7683 port_summary_header_display();
7684 RTE_ETH_FOREACH_DEV(i)
7685 port_summary_display(i);
7687 else if (!strcmp(res->what, "stats"))
7688 RTE_ETH_FOREACH_DEV(i)
7689 nic_stats_display(i);
7690 else if (!strcmp(res->what, "xstats"))
7691 RTE_ETH_FOREACH_DEV(i)
7692 nic_xstats_display(i);
7693 else if (!strcmp(res->what, "fdir"))
7694 RTE_ETH_FOREACH_DEV(i)
7696 else if (!strcmp(res->what, "stat_qmap"))
7697 RTE_ETH_FOREACH_DEV(i)
7698 nic_stats_mapping_display(i);
7699 else if (!strcmp(res->what, "dcb_tc"))
7700 RTE_ETH_FOREACH_DEV(i)
7701 port_dcb_info_display(i);
7702 else if (!strcmp(res->what, "cap"))
7703 RTE_ETH_FOREACH_DEV(i)
7704 port_offload_cap_display(i);
7707 cmdline_parse_token_string_t cmd_showportall_show =
7708 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
7710 cmdline_parse_token_string_t cmd_showportall_port =
7711 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
7712 cmdline_parse_token_string_t cmd_showportall_what =
7713 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
7714 "info#summary#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
7715 cmdline_parse_token_string_t cmd_showportall_all =
7716 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
7717 cmdline_parse_inst_t cmd_showportall = {
7718 .f = cmd_showportall_parsed,
7720 .help_str = "show|clear port "
7721 "info|summary|stats|xstats|fdir|stat_qmap|dcb_tc|cap all",
7723 (void *)&cmd_showportall_show,
7724 (void *)&cmd_showportall_port,
7725 (void *)&cmd_showportall_what,
7726 (void *)&cmd_showportall_all,
7731 /* *** SHOW PORT INFO *** */
7732 struct cmd_showport_result {
7733 cmdline_fixed_string_t show;
7734 cmdline_fixed_string_t port;
7735 cmdline_fixed_string_t what;
7739 static void cmd_showport_parsed(void *parsed_result,
7740 __rte_unused struct cmdline *cl,
7741 __rte_unused void *data)
7743 struct cmd_showport_result *res = parsed_result;
7744 if (!strcmp(res->show, "clear")) {
7745 if (!strcmp(res->what, "stats"))
7746 nic_stats_clear(res->portnum);
7747 else if (!strcmp(res->what, "xstats"))
7748 nic_xstats_clear(res->portnum);
7749 } else if (!strcmp(res->what, "info"))
7750 port_infos_display(res->portnum);
7751 else if (!strcmp(res->what, "summary")) {
7752 port_summary_header_display();
7753 port_summary_display(res->portnum);
7755 else if (!strcmp(res->what, "stats"))
7756 nic_stats_display(res->portnum);
7757 else if (!strcmp(res->what, "xstats"))
7758 nic_xstats_display(res->portnum);
7759 else if (!strcmp(res->what, "fdir"))
7760 fdir_get_infos(res->portnum);
7761 else if (!strcmp(res->what, "stat_qmap"))
7762 nic_stats_mapping_display(res->portnum);
7763 else if (!strcmp(res->what, "dcb_tc"))
7764 port_dcb_info_display(res->portnum);
7765 else if (!strcmp(res->what, "cap"))
7766 port_offload_cap_display(res->portnum);
7769 cmdline_parse_token_string_t cmd_showport_show =
7770 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
7772 cmdline_parse_token_string_t cmd_showport_port =
7773 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
7774 cmdline_parse_token_string_t cmd_showport_what =
7775 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
7776 "info#summary#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
7777 cmdline_parse_token_num_t cmd_showport_portnum =
7778 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT16);
7780 cmdline_parse_inst_t cmd_showport = {
7781 .f = cmd_showport_parsed,
7783 .help_str = "show|clear port "
7784 "info|summary|stats|xstats|fdir|stat_qmap|dcb_tc|cap "
7787 (void *)&cmd_showport_show,
7788 (void *)&cmd_showport_port,
7789 (void *)&cmd_showport_what,
7790 (void *)&cmd_showport_portnum,
7795 /* *** SHOW DEVICE INFO *** */
7796 struct cmd_showdevice_result {
7797 cmdline_fixed_string_t show;
7798 cmdline_fixed_string_t device;
7799 cmdline_fixed_string_t what;
7800 cmdline_fixed_string_t identifier;
7803 static void cmd_showdevice_parsed(void *parsed_result,
7804 __rte_unused struct cmdline *cl,
7805 __rte_unused void *data)
7807 struct cmd_showdevice_result *res = parsed_result;
7808 if (!strcmp(res->what, "info")) {
7809 if (!strcmp(res->identifier, "all"))
7810 device_infos_display(NULL);
7812 device_infos_display(res->identifier);
7816 cmdline_parse_token_string_t cmd_showdevice_show =
7817 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, show,
7819 cmdline_parse_token_string_t cmd_showdevice_device =
7820 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, device, "device");
7821 cmdline_parse_token_string_t cmd_showdevice_what =
7822 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, what,
7824 cmdline_parse_token_string_t cmd_showdevice_identifier =
7825 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result,
7828 cmdline_parse_inst_t cmd_showdevice = {
7829 .f = cmd_showdevice_parsed,
7831 .help_str = "show device info <identifier>|all",
7833 (void *)&cmd_showdevice_show,
7834 (void *)&cmd_showdevice_device,
7835 (void *)&cmd_showdevice_what,
7836 (void *)&cmd_showdevice_identifier,
7841 /* *** SHOW MODULE EEPROM/EEPROM port INFO *** */
7842 struct cmd_showeeprom_result {
7843 cmdline_fixed_string_t show;
7844 cmdline_fixed_string_t port;
7846 cmdline_fixed_string_t type;
7849 static void cmd_showeeprom_parsed(void *parsed_result,
7850 __rte_unused struct cmdline *cl,
7851 __rte_unused void *data)
7853 struct cmd_showeeprom_result *res = parsed_result;
7855 if (!strcmp(res->type, "eeprom"))
7856 port_eeprom_display(res->portnum);
7857 else if (!strcmp(res->type, "module_eeprom"))
7858 port_module_eeprom_display(res->portnum);
7860 printf("Unknown argument\n");
7863 cmdline_parse_token_string_t cmd_showeeprom_show =
7864 TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, show, "show");
7865 cmdline_parse_token_string_t cmd_showeeprom_port =
7866 TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, port, "port");
7867 cmdline_parse_token_num_t cmd_showeeprom_portnum =
7868 TOKEN_NUM_INITIALIZER(struct cmd_showeeprom_result, portnum, UINT16);
7869 cmdline_parse_token_string_t cmd_showeeprom_type =
7870 TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, type, "module_eeprom#eeprom");
7872 cmdline_parse_inst_t cmd_showeeprom = {
7873 .f = cmd_showeeprom_parsed,
7875 .help_str = "show port <port_id> module_eeprom|eeprom",
7877 (void *)&cmd_showeeprom_show,
7878 (void *)&cmd_showeeprom_port,
7879 (void *)&cmd_showeeprom_portnum,
7880 (void *)&cmd_showeeprom_type,
7885 /* *** SHOW QUEUE INFO *** */
7886 struct cmd_showqueue_result {
7887 cmdline_fixed_string_t show;
7888 cmdline_fixed_string_t type;
7889 cmdline_fixed_string_t what;
7895 cmd_showqueue_parsed(void *parsed_result,
7896 __rte_unused struct cmdline *cl,
7897 __rte_unused void *data)
7899 struct cmd_showqueue_result *res = parsed_result;
7901 if (!strcmp(res->type, "rxq"))
7902 rx_queue_infos_display(res->portnum, res->queuenum);
7903 else if (!strcmp(res->type, "txq"))
7904 tx_queue_infos_display(res->portnum, res->queuenum);
7907 cmdline_parse_token_string_t cmd_showqueue_show =
7908 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
7909 cmdline_parse_token_string_t cmd_showqueue_type =
7910 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
7911 cmdline_parse_token_string_t cmd_showqueue_what =
7912 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
7913 cmdline_parse_token_num_t cmd_showqueue_portnum =
7914 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, UINT16);
7915 cmdline_parse_token_num_t cmd_showqueue_queuenum =
7916 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, UINT16);
7918 cmdline_parse_inst_t cmd_showqueue = {
7919 .f = cmd_showqueue_parsed,
7921 .help_str = "show rxq|txq info <port_id> <queue_id>",
7923 (void *)&cmd_showqueue_show,
7924 (void *)&cmd_showqueue_type,
7925 (void *)&cmd_showqueue_what,
7926 (void *)&cmd_showqueue_portnum,
7927 (void *)&cmd_showqueue_queuenum,
7932 /* show/clear fwd engine statistics */
7934 cmdline_fixed_string_t action;
7935 cmdline_fixed_string_t fwd;
7936 cmdline_fixed_string_t stats;
7937 cmdline_fixed_string_t all;
7940 cmdline_parse_token_string_t cmd_fwd_action =
7941 TOKEN_STRING_INITIALIZER(struct fwd_result, action, "show#clear");
7942 cmdline_parse_token_string_t cmd_fwd_fwd =
7943 TOKEN_STRING_INITIALIZER(struct fwd_result, fwd, "fwd");
7944 cmdline_parse_token_string_t cmd_fwd_stats =
7945 TOKEN_STRING_INITIALIZER(struct fwd_result, stats, "stats");
7946 cmdline_parse_token_string_t cmd_fwd_all =
7947 TOKEN_STRING_INITIALIZER(struct fwd_result, all, "all");
7950 cmd_showfwdall_parsed(void *parsed_result,
7951 __rte_unused struct cmdline *cl,
7952 __rte_unused void *data)
7954 struct fwd_result *res = parsed_result;
7956 if (!strcmp(res->action, "show"))
7957 fwd_stats_display();
7962 static cmdline_parse_inst_t cmd_showfwdall = {
7963 .f = cmd_showfwdall_parsed,
7965 .help_str = "show|clear fwd stats all",
7967 (void *)&cmd_fwd_action,
7968 (void *)&cmd_fwd_fwd,
7969 (void *)&cmd_fwd_stats,
7970 (void *)&cmd_fwd_all,
7975 /* *** READ PORT REGISTER *** */
7976 struct cmd_read_reg_result {
7977 cmdline_fixed_string_t read;
7978 cmdline_fixed_string_t reg;
7984 cmd_read_reg_parsed(void *parsed_result,
7985 __rte_unused struct cmdline *cl,
7986 __rte_unused void *data)
7988 struct cmd_read_reg_result *res = parsed_result;
7989 port_reg_display(res->port_id, res->reg_off);
7992 cmdline_parse_token_string_t cmd_read_reg_read =
7993 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
7994 cmdline_parse_token_string_t cmd_read_reg_reg =
7995 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
7996 cmdline_parse_token_num_t cmd_read_reg_port_id =
7997 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT16);
7998 cmdline_parse_token_num_t cmd_read_reg_reg_off =
7999 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
8001 cmdline_parse_inst_t cmd_read_reg = {
8002 .f = cmd_read_reg_parsed,
8004 .help_str = "read reg <port_id> <reg_off>",
8006 (void *)&cmd_read_reg_read,
8007 (void *)&cmd_read_reg_reg,
8008 (void *)&cmd_read_reg_port_id,
8009 (void *)&cmd_read_reg_reg_off,
8014 /* *** READ PORT REGISTER BIT FIELD *** */
8015 struct cmd_read_reg_bit_field_result {
8016 cmdline_fixed_string_t read;
8017 cmdline_fixed_string_t regfield;
8025 cmd_read_reg_bit_field_parsed(void *parsed_result,
8026 __rte_unused struct cmdline *cl,
8027 __rte_unused void *data)
8029 struct cmd_read_reg_bit_field_result *res = parsed_result;
8030 port_reg_bit_field_display(res->port_id, res->reg_off,
8031 res->bit1_pos, res->bit2_pos);
8034 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
8035 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
8037 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
8038 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
8039 regfield, "regfield");
8040 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
8041 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
8043 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
8044 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
8046 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
8047 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
8049 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
8050 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
8053 cmdline_parse_inst_t cmd_read_reg_bit_field = {
8054 .f = cmd_read_reg_bit_field_parsed,
8056 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
8057 "Read register bit field between bit_x and bit_y included",
8059 (void *)&cmd_read_reg_bit_field_read,
8060 (void *)&cmd_read_reg_bit_field_regfield,
8061 (void *)&cmd_read_reg_bit_field_port_id,
8062 (void *)&cmd_read_reg_bit_field_reg_off,
8063 (void *)&cmd_read_reg_bit_field_bit1_pos,
8064 (void *)&cmd_read_reg_bit_field_bit2_pos,
8069 /* *** READ PORT REGISTER BIT *** */
8070 struct cmd_read_reg_bit_result {
8071 cmdline_fixed_string_t read;
8072 cmdline_fixed_string_t regbit;
8079 cmd_read_reg_bit_parsed(void *parsed_result,
8080 __rte_unused struct cmdline *cl,
8081 __rte_unused void *data)
8083 struct cmd_read_reg_bit_result *res = parsed_result;
8084 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
8087 cmdline_parse_token_string_t cmd_read_reg_bit_read =
8088 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
8089 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
8090 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
8092 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
8093 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT16);
8094 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
8095 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
8096 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
8097 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
8099 cmdline_parse_inst_t cmd_read_reg_bit = {
8100 .f = cmd_read_reg_bit_parsed,
8102 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
8104 (void *)&cmd_read_reg_bit_read,
8105 (void *)&cmd_read_reg_bit_regbit,
8106 (void *)&cmd_read_reg_bit_port_id,
8107 (void *)&cmd_read_reg_bit_reg_off,
8108 (void *)&cmd_read_reg_bit_bit_pos,
8113 /* *** WRITE PORT REGISTER *** */
8114 struct cmd_write_reg_result {
8115 cmdline_fixed_string_t write;
8116 cmdline_fixed_string_t reg;
8123 cmd_write_reg_parsed(void *parsed_result,
8124 __rte_unused struct cmdline *cl,
8125 __rte_unused void *data)
8127 struct cmd_write_reg_result *res = parsed_result;
8128 port_reg_set(res->port_id, res->reg_off, res->value);
8131 cmdline_parse_token_string_t cmd_write_reg_write =
8132 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
8133 cmdline_parse_token_string_t cmd_write_reg_reg =
8134 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
8135 cmdline_parse_token_num_t cmd_write_reg_port_id =
8136 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT16);
8137 cmdline_parse_token_num_t cmd_write_reg_reg_off =
8138 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
8139 cmdline_parse_token_num_t cmd_write_reg_value =
8140 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
8142 cmdline_parse_inst_t cmd_write_reg = {
8143 .f = cmd_write_reg_parsed,
8145 .help_str = "write reg <port_id> <reg_off> <reg_value>",
8147 (void *)&cmd_write_reg_write,
8148 (void *)&cmd_write_reg_reg,
8149 (void *)&cmd_write_reg_port_id,
8150 (void *)&cmd_write_reg_reg_off,
8151 (void *)&cmd_write_reg_value,
8156 /* *** WRITE PORT REGISTER BIT FIELD *** */
8157 struct cmd_write_reg_bit_field_result {
8158 cmdline_fixed_string_t write;
8159 cmdline_fixed_string_t regfield;
8168 cmd_write_reg_bit_field_parsed(void *parsed_result,
8169 __rte_unused struct cmdline *cl,
8170 __rte_unused void *data)
8172 struct cmd_write_reg_bit_field_result *res = parsed_result;
8173 port_reg_bit_field_set(res->port_id, res->reg_off,
8174 res->bit1_pos, res->bit2_pos, res->value);
8177 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
8178 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
8180 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
8181 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
8182 regfield, "regfield");
8183 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
8184 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
8186 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
8187 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
8189 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
8190 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
8192 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
8193 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
8195 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
8196 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
8199 cmdline_parse_inst_t cmd_write_reg_bit_field = {
8200 .f = cmd_write_reg_bit_field_parsed,
8202 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
8204 "Set register bit field between bit_x and bit_y included",
8206 (void *)&cmd_write_reg_bit_field_write,
8207 (void *)&cmd_write_reg_bit_field_regfield,
8208 (void *)&cmd_write_reg_bit_field_port_id,
8209 (void *)&cmd_write_reg_bit_field_reg_off,
8210 (void *)&cmd_write_reg_bit_field_bit1_pos,
8211 (void *)&cmd_write_reg_bit_field_bit2_pos,
8212 (void *)&cmd_write_reg_bit_field_value,
8217 /* *** WRITE PORT REGISTER BIT *** */
8218 struct cmd_write_reg_bit_result {
8219 cmdline_fixed_string_t write;
8220 cmdline_fixed_string_t regbit;
8228 cmd_write_reg_bit_parsed(void *parsed_result,
8229 __rte_unused struct cmdline *cl,
8230 __rte_unused void *data)
8232 struct cmd_write_reg_bit_result *res = parsed_result;
8233 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
8236 cmdline_parse_token_string_t cmd_write_reg_bit_write =
8237 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
8239 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
8240 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
8242 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
8243 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT16);
8244 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
8245 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
8246 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
8247 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
8248 cmdline_parse_token_num_t cmd_write_reg_bit_value =
8249 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
8251 cmdline_parse_inst_t cmd_write_reg_bit = {
8252 .f = cmd_write_reg_bit_parsed,
8254 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
8257 (void *)&cmd_write_reg_bit_write,
8258 (void *)&cmd_write_reg_bit_regbit,
8259 (void *)&cmd_write_reg_bit_port_id,
8260 (void *)&cmd_write_reg_bit_reg_off,
8261 (void *)&cmd_write_reg_bit_bit_pos,
8262 (void *)&cmd_write_reg_bit_value,
8267 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
8268 struct cmd_read_rxd_txd_result {
8269 cmdline_fixed_string_t read;
8270 cmdline_fixed_string_t rxd_txd;
8277 cmd_read_rxd_txd_parsed(void *parsed_result,
8278 __rte_unused struct cmdline *cl,
8279 __rte_unused void *data)
8281 struct cmd_read_rxd_txd_result *res = parsed_result;
8283 if (!strcmp(res->rxd_txd, "rxd"))
8284 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
8285 else if (!strcmp(res->rxd_txd, "txd"))
8286 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
8289 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
8290 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
8291 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
8292 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
8294 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
8295 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT16);
8296 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
8297 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
8298 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
8299 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
8301 cmdline_parse_inst_t cmd_read_rxd_txd = {
8302 .f = cmd_read_rxd_txd_parsed,
8304 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
8306 (void *)&cmd_read_rxd_txd_read,
8307 (void *)&cmd_read_rxd_txd_rxd_txd,
8308 (void *)&cmd_read_rxd_txd_port_id,
8309 (void *)&cmd_read_rxd_txd_queue_id,
8310 (void *)&cmd_read_rxd_txd_desc_id,
8316 struct cmd_quit_result {
8317 cmdline_fixed_string_t quit;
8320 static void cmd_quit_parsed(__rte_unused void *parsed_result,
8322 __rte_unused void *data)
8327 cmdline_parse_token_string_t cmd_quit_quit =
8328 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
8330 cmdline_parse_inst_t cmd_quit = {
8331 .f = cmd_quit_parsed,
8333 .help_str = "quit: Exit application",
8335 (void *)&cmd_quit_quit,
8340 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
8341 struct cmd_mac_addr_result {
8342 cmdline_fixed_string_t mac_addr_cmd;
8343 cmdline_fixed_string_t what;
8345 struct rte_ether_addr address;
8348 static void cmd_mac_addr_parsed(void *parsed_result,
8349 __rte_unused struct cmdline *cl,
8350 __rte_unused void *data)
8352 struct cmd_mac_addr_result *res = parsed_result;
8355 if (strcmp(res->what, "add") == 0)
8356 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
8357 else if (strcmp(res->what, "set") == 0)
8358 ret = rte_eth_dev_default_mac_addr_set(res->port_num,
8361 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
8363 /* check the return value and print it if is < 0 */
8365 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
8369 cmdline_parse_token_string_t cmd_mac_addr_cmd =
8370 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
8372 cmdline_parse_token_string_t cmd_mac_addr_what =
8373 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
8375 cmdline_parse_token_num_t cmd_mac_addr_portnum =
8376 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num,
8378 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
8379 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
8381 cmdline_parse_inst_t cmd_mac_addr = {
8382 .f = cmd_mac_addr_parsed,
8384 .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
8385 "Add/Remove/Set MAC address on port_id",
8387 (void *)&cmd_mac_addr_cmd,
8388 (void *)&cmd_mac_addr_what,
8389 (void *)&cmd_mac_addr_portnum,
8390 (void *)&cmd_mac_addr_addr,
8395 /* *** SET THE PEER ADDRESS FOR CERTAIN PORT *** */
8396 struct cmd_eth_peer_result {
8397 cmdline_fixed_string_t set;
8398 cmdline_fixed_string_t eth_peer;
8400 cmdline_fixed_string_t peer_addr;
8403 static void cmd_set_eth_peer_parsed(void *parsed_result,
8404 __rte_unused struct cmdline *cl,
8405 __rte_unused void *data)
8407 struct cmd_eth_peer_result *res = parsed_result;
8409 if (test_done == 0) {
8410 printf("Please stop forwarding first\n");
8413 if (!strcmp(res->eth_peer, "eth-peer")) {
8414 set_fwd_eth_peer(res->port_id, res->peer_addr);
8418 cmdline_parse_token_string_t cmd_eth_peer_set =
8419 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, set, "set");
8420 cmdline_parse_token_string_t cmd_eth_peer =
8421 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, eth_peer, "eth-peer");
8422 cmdline_parse_token_num_t cmd_eth_peer_port_id =
8423 TOKEN_NUM_INITIALIZER(struct cmd_eth_peer_result, port_id, UINT16);
8424 cmdline_parse_token_string_t cmd_eth_peer_addr =
8425 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, peer_addr, NULL);
8427 cmdline_parse_inst_t cmd_set_fwd_eth_peer = {
8428 .f = cmd_set_eth_peer_parsed,
8430 .help_str = "set eth-peer <port_id> <peer_mac>",
8432 (void *)&cmd_eth_peer_set,
8433 (void *)&cmd_eth_peer,
8434 (void *)&cmd_eth_peer_port_id,
8435 (void *)&cmd_eth_peer_addr,
8440 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
8441 struct cmd_set_qmap_result {
8442 cmdline_fixed_string_t set;
8443 cmdline_fixed_string_t qmap;
8444 cmdline_fixed_string_t what;
8451 cmd_set_qmap_parsed(void *parsed_result,
8452 __rte_unused struct cmdline *cl,
8453 __rte_unused void *data)
8455 struct cmd_set_qmap_result *res = parsed_result;
8456 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
8458 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
8461 cmdline_parse_token_string_t cmd_setqmap_set =
8462 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8464 cmdline_parse_token_string_t cmd_setqmap_qmap =
8465 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8467 cmdline_parse_token_string_t cmd_setqmap_what =
8468 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8470 cmdline_parse_token_num_t cmd_setqmap_portid =
8471 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8473 cmdline_parse_token_num_t cmd_setqmap_queueid =
8474 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8476 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
8477 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8480 cmdline_parse_inst_t cmd_set_qmap = {
8481 .f = cmd_set_qmap_parsed,
8483 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
8484 "Set statistics mapping value on tx|rx queue_id of port_id",
8486 (void *)&cmd_setqmap_set,
8487 (void *)&cmd_setqmap_qmap,
8488 (void *)&cmd_setqmap_what,
8489 (void *)&cmd_setqmap_portid,
8490 (void *)&cmd_setqmap_queueid,
8491 (void *)&cmd_setqmap_mapvalue,
8496 /* *** SET OPTION TO HIDE ZERO VALUES FOR XSTATS DISPLAY *** */
8497 struct cmd_set_xstats_hide_zero_result {
8498 cmdline_fixed_string_t keyword;
8499 cmdline_fixed_string_t name;
8500 cmdline_fixed_string_t on_off;
8504 cmd_set_xstats_hide_zero_parsed(void *parsed_result,
8505 __rte_unused struct cmdline *cl,
8506 __rte_unused void *data)
8508 struct cmd_set_xstats_hide_zero_result *res;
8509 uint16_t on_off = 0;
8511 res = parsed_result;
8512 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8513 set_xstats_hide_zero(on_off);
8516 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_keyword =
8517 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8519 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_name =
8520 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8521 name, "xstats-hide-zero");
8522 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_on_off =
8523 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8526 cmdline_parse_inst_t cmd_set_xstats_hide_zero = {
8527 .f = cmd_set_xstats_hide_zero_parsed,
8529 .help_str = "set xstats-hide-zero on|off",
8531 (void *)&cmd_set_xstats_hide_zero_keyword,
8532 (void *)&cmd_set_xstats_hide_zero_name,
8533 (void *)&cmd_set_xstats_hide_zero_on_off,
8538 /* *** SET OPTION TO ENABLE MEASUREMENT OF CPU CYCLES *** */
8539 struct cmd_set_record_core_cycles_result {
8540 cmdline_fixed_string_t keyword;
8541 cmdline_fixed_string_t name;
8542 cmdline_fixed_string_t on_off;
8546 cmd_set_record_core_cycles_parsed(void *parsed_result,
8547 __rte_unused struct cmdline *cl,
8548 __rte_unused void *data)
8550 struct cmd_set_record_core_cycles_result *res;
8551 uint16_t on_off = 0;
8553 res = parsed_result;
8554 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8555 set_record_core_cycles(on_off);
8558 cmdline_parse_token_string_t cmd_set_record_core_cycles_keyword =
8559 TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
8561 cmdline_parse_token_string_t cmd_set_record_core_cycles_name =
8562 TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
8563 name, "record-core-cycles");
8564 cmdline_parse_token_string_t cmd_set_record_core_cycles_on_off =
8565 TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
8568 cmdline_parse_inst_t cmd_set_record_core_cycles = {
8569 .f = cmd_set_record_core_cycles_parsed,
8571 .help_str = "set record-core-cycles on|off",
8573 (void *)&cmd_set_record_core_cycles_keyword,
8574 (void *)&cmd_set_record_core_cycles_name,
8575 (void *)&cmd_set_record_core_cycles_on_off,
8580 /* *** SET OPTION TO ENABLE DISPLAY OF RX AND TX BURSTS *** */
8581 struct cmd_set_record_burst_stats_result {
8582 cmdline_fixed_string_t keyword;
8583 cmdline_fixed_string_t name;
8584 cmdline_fixed_string_t on_off;
8588 cmd_set_record_burst_stats_parsed(void *parsed_result,
8589 __rte_unused struct cmdline *cl,
8590 __rte_unused void *data)
8592 struct cmd_set_record_burst_stats_result *res;
8593 uint16_t on_off = 0;
8595 res = parsed_result;
8596 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8597 set_record_burst_stats(on_off);
8600 cmdline_parse_token_string_t cmd_set_record_burst_stats_keyword =
8601 TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
8603 cmdline_parse_token_string_t cmd_set_record_burst_stats_name =
8604 TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
8605 name, "record-burst-stats");
8606 cmdline_parse_token_string_t cmd_set_record_burst_stats_on_off =
8607 TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
8610 cmdline_parse_inst_t cmd_set_record_burst_stats = {
8611 .f = cmd_set_record_burst_stats_parsed,
8613 .help_str = "set record-burst-stats on|off",
8615 (void *)&cmd_set_record_burst_stats_keyword,
8616 (void *)&cmd_set_record_burst_stats_name,
8617 (void *)&cmd_set_record_burst_stats_on_off,
8622 /* *** CONFIGURE UNICAST HASH TABLE *** */
8623 struct cmd_set_uc_hash_table {
8624 cmdline_fixed_string_t set;
8625 cmdline_fixed_string_t port;
8627 cmdline_fixed_string_t what;
8628 struct rte_ether_addr address;
8629 cmdline_fixed_string_t mode;
8633 cmd_set_uc_hash_parsed(void *parsed_result,
8634 __rte_unused struct cmdline *cl,
8635 __rte_unused void *data)
8638 struct cmd_set_uc_hash_table *res = parsed_result;
8640 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8642 if (strcmp(res->what, "uta") == 0)
8643 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
8644 &res->address,(uint8_t)is_on);
8646 printf("bad unicast hash table parameter, return code = %d \n", ret);
8650 cmdline_parse_token_string_t cmd_set_uc_hash_set =
8651 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8653 cmdline_parse_token_string_t cmd_set_uc_hash_port =
8654 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8656 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
8657 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
8659 cmdline_parse_token_string_t cmd_set_uc_hash_what =
8660 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8662 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
8663 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
8665 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
8666 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8669 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
8670 .f = cmd_set_uc_hash_parsed,
8672 .help_str = "set port <port_id> uta <mac_addr> on|off)",
8674 (void *)&cmd_set_uc_hash_set,
8675 (void *)&cmd_set_uc_hash_port,
8676 (void *)&cmd_set_uc_hash_portid,
8677 (void *)&cmd_set_uc_hash_what,
8678 (void *)&cmd_set_uc_hash_mac,
8679 (void *)&cmd_set_uc_hash_mode,
8684 struct cmd_set_uc_all_hash_table {
8685 cmdline_fixed_string_t set;
8686 cmdline_fixed_string_t port;
8688 cmdline_fixed_string_t what;
8689 cmdline_fixed_string_t value;
8690 cmdline_fixed_string_t mode;
8694 cmd_set_uc_all_hash_parsed(void *parsed_result,
8695 __rte_unused struct cmdline *cl,
8696 __rte_unused void *data)
8699 struct cmd_set_uc_all_hash_table *res = parsed_result;
8701 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8703 if ((strcmp(res->what, "uta") == 0) &&
8704 (strcmp(res->value, "all") == 0))
8705 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
8707 printf("bad unicast hash table parameter,"
8708 "return code = %d \n", ret);
8711 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
8712 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8714 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
8715 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8717 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
8718 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
8720 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
8721 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8723 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
8724 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8726 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
8727 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8730 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
8731 .f = cmd_set_uc_all_hash_parsed,
8733 .help_str = "set port <port_id> uta all on|off",
8735 (void *)&cmd_set_uc_all_hash_set,
8736 (void *)&cmd_set_uc_all_hash_port,
8737 (void *)&cmd_set_uc_all_hash_portid,
8738 (void *)&cmd_set_uc_all_hash_what,
8739 (void *)&cmd_set_uc_all_hash_value,
8740 (void *)&cmd_set_uc_all_hash_mode,
8745 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
8746 struct cmd_set_vf_traffic {
8747 cmdline_fixed_string_t set;
8748 cmdline_fixed_string_t port;
8750 cmdline_fixed_string_t vf;
8752 cmdline_fixed_string_t what;
8753 cmdline_fixed_string_t mode;
8757 cmd_set_vf_traffic_parsed(void *parsed_result,
8758 __rte_unused struct cmdline *cl,
8759 __rte_unused void *data)
8761 struct cmd_set_vf_traffic *res = parsed_result;
8762 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
8763 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8765 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
8768 cmdline_parse_token_string_t cmd_setvf_traffic_set =
8769 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8771 cmdline_parse_token_string_t cmd_setvf_traffic_port =
8772 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8774 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
8775 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8777 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
8778 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8780 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
8781 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8783 cmdline_parse_token_string_t cmd_setvf_traffic_what =
8784 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8786 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
8787 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8790 cmdline_parse_inst_t cmd_set_vf_traffic = {
8791 .f = cmd_set_vf_traffic_parsed,
8793 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
8795 (void *)&cmd_setvf_traffic_set,
8796 (void *)&cmd_setvf_traffic_port,
8797 (void *)&cmd_setvf_traffic_portid,
8798 (void *)&cmd_setvf_traffic_vf,
8799 (void *)&cmd_setvf_traffic_vfid,
8800 (void *)&cmd_setvf_traffic_what,
8801 (void *)&cmd_setvf_traffic_mode,
8806 /* *** CONFIGURE VF RECEIVE MODE *** */
8807 struct cmd_set_vf_rxmode {
8808 cmdline_fixed_string_t set;
8809 cmdline_fixed_string_t port;
8811 cmdline_fixed_string_t vf;
8813 cmdline_fixed_string_t what;
8814 cmdline_fixed_string_t mode;
8815 cmdline_fixed_string_t on;
8819 cmd_set_vf_rxmode_parsed(void *parsed_result,
8820 __rte_unused struct cmdline *cl,
8821 __rte_unused void *data)
8824 uint16_t vf_rxmode = 0;
8825 struct cmd_set_vf_rxmode *res = parsed_result;
8827 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
8828 if (!strcmp(res->what,"rxmode")) {
8829 if (!strcmp(res->mode, "AUPE"))
8830 vf_rxmode |= ETH_VMDQ_ACCEPT_UNTAG;
8831 else if (!strcmp(res->mode, "ROPE"))
8832 vf_rxmode |= ETH_VMDQ_ACCEPT_HASH_UC;
8833 else if (!strcmp(res->mode, "BAM"))
8834 vf_rxmode |= ETH_VMDQ_ACCEPT_BROADCAST;
8835 else if (!strncmp(res->mode, "MPE",3))
8836 vf_rxmode |= ETH_VMDQ_ACCEPT_MULTICAST;
8839 RTE_SET_USED(is_on);
8841 #ifdef RTE_NET_IXGBE
8842 if (ret == -ENOTSUP)
8843 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id,
8844 vf_rxmode, (uint8_t)is_on);
8847 if (ret == -ENOTSUP)
8848 ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id,
8849 vf_rxmode, (uint8_t)is_on);
8852 printf("bad VF receive mode parameter, return code = %d \n",
8856 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
8857 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8859 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
8860 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8862 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
8863 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8865 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
8866 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8868 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
8869 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8871 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
8872 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8874 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
8875 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8876 mode, "AUPE#ROPE#BAM#MPE");
8877 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
8878 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8881 cmdline_parse_inst_t cmd_set_vf_rxmode = {
8882 .f = cmd_set_vf_rxmode_parsed,
8884 .help_str = "set port <port_id> vf <vf_id> rxmode "
8885 "AUPE|ROPE|BAM|MPE on|off",
8887 (void *)&cmd_set_vf_rxmode_set,
8888 (void *)&cmd_set_vf_rxmode_port,
8889 (void *)&cmd_set_vf_rxmode_portid,
8890 (void *)&cmd_set_vf_rxmode_vf,
8891 (void *)&cmd_set_vf_rxmode_vfid,
8892 (void *)&cmd_set_vf_rxmode_what,
8893 (void *)&cmd_set_vf_rxmode_mode,
8894 (void *)&cmd_set_vf_rxmode_on,
8899 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
8900 struct cmd_vf_mac_addr_result {
8901 cmdline_fixed_string_t mac_addr_cmd;
8902 cmdline_fixed_string_t what;
8903 cmdline_fixed_string_t port;
8905 cmdline_fixed_string_t vf;
8907 struct rte_ether_addr address;
8910 static void cmd_vf_mac_addr_parsed(void *parsed_result,
8911 __rte_unused struct cmdline *cl,
8912 __rte_unused void *data)
8914 struct cmd_vf_mac_addr_result *res = parsed_result;
8917 if (strcmp(res->what, "add") != 0)
8921 if (ret == -ENOTSUP)
8922 ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num,
8926 if (ret == -ENOTSUP)
8927 ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address,
8932 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
8936 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
8937 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8938 mac_addr_cmd,"mac_addr");
8939 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
8940 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8942 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
8943 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8945 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
8946 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8948 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
8949 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8951 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
8952 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8954 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
8955 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
8958 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
8959 .f = cmd_vf_mac_addr_parsed,
8961 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
8962 "Add MAC address filtering for a VF on port_id",
8964 (void *)&cmd_vf_mac_addr_cmd,
8965 (void *)&cmd_vf_mac_addr_what,
8966 (void *)&cmd_vf_mac_addr_port,
8967 (void *)&cmd_vf_mac_addr_portnum,
8968 (void *)&cmd_vf_mac_addr_vf,
8969 (void *)&cmd_vf_mac_addr_vfnum,
8970 (void *)&cmd_vf_mac_addr_addr,
8975 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
8976 struct cmd_vf_rx_vlan_filter {
8977 cmdline_fixed_string_t rx_vlan;
8978 cmdline_fixed_string_t what;
8980 cmdline_fixed_string_t port;
8982 cmdline_fixed_string_t vf;
8987 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
8988 __rte_unused struct cmdline *cl,
8989 __rte_unused void *data)
8991 struct cmd_vf_rx_vlan_filter *res = parsed_result;
8994 __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
8996 #ifdef RTE_NET_IXGBE
8997 if (ret == -ENOTSUP)
8998 ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
8999 res->vlan_id, res->vf_mask, is_add);
9002 if (ret == -ENOTSUP)
9003 ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
9004 res->vlan_id, res->vf_mask, is_add);
9007 if (ret == -ENOTSUP)
9008 ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id,
9009 res->vlan_id, res->vf_mask, is_add);
9016 printf("invalid vlan_id %d or vf_mask %"PRIu64"\n",
9017 res->vlan_id, res->vf_mask);
9020 printf("invalid port_id %d\n", res->port_id);
9023 printf("function not implemented or supported\n");
9026 printf("programming error: (%s)\n", strerror(-ret));
9030 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
9031 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9032 rx_vlan, "rx_vlan");
9033 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
9034 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9036 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
9037 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9039 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
9040 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9042 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
9043 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9045 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
9046 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9048 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
9049 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9052 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
9053 .f = cmd_vf_rx_vlan_filter_parsed,
9055 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
9056 "(vf_mask = hexadecimal VF mask)",
9058 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
9059 (void *)&cmd_vf_rx_vlan_filter_what,
9060 (void *)&cmd_vf_rx_vlan_filter_vlanid,
9061 (void *)&cmd_vf_rx_vlan_filter_port,
9062 (void *)&cmd_vf_rx_vlan_filter_portid,
9063 (void *)&cmd_vf_rx_vlan_filter_vf,
9064 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
9069 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
9070 struct cmd_queue_rate_limit_result {
9071 cmdline_fixed_string_t set;
9072 cmdline_fixed_string_t port;
9074 cmdline_fixed_string_t queue;
9076 cmdline_fixed_string_t rate;
9080 static void cmd_queue_rate_limit_parsed(void *parsed_result,
9081 __rte_unused struct cmdline *cl,
9082 __rte_unused void *data)
9084 struct cmd_queue_rate_limit_result *res = parsed_result;
9087 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
9088 && (strcmp(res->queue, "queue") == 0)
9089 && (strcmp(res->rate, "rate") == 0))
9090 ret = set_queue_rate_limit(res->port_num, res->queue_num,
9093 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
9097 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
9098 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9100 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
9101 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9103 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
9104 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
9106 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
9107 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9109 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
9110 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
9112 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
9113 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9115 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
9116 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
9119 cmdline_parse_inst_t cmd_queue_rate_limit = {
9120 .f = cmd_queue_rate_limit_parsed,
9122 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
9123 "Set rate limit for a queue on port_id",
9125 (void *)&cmd_queue_rate_limit_set,
9126 (void *)&cmd_queue_rate_limit_port,
9127 (void *)&cmd_queue_rate_limit_portnum,
9128 (void *)&cmd_queue_rate_limit_queue,
9129 (void *)&cmd_queue_rate_limit_queuenum,
9130 (void *)&cmd_queue_rate_limit_rate,
9131 (void *)&cmd_queue_rate_limit_ratenum,
9136 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
9137 struct cmd_vf_rate_limit_result {
9138 cmdline_fixed_string_t set;
9139 cmdline_fixed_string_t port;
9141 cmdline_fixed_string_t vf;
9143 cmdline_fixed_string_t rate;
9145 cmdline_fixed_string_t q_msk;
9149 static void cmd_vf_rate_limit_parsed(void *parsed_result,
9150 __rte_unused struct cmdline *cl,
9151 __rte_unused void *data)
9153 struct cmd_vf_rate_limit_result *res = parsed_result;
9156 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
9157 && (strcmp(res->vf, "vf") == 0)
9158 && (strcmp(res->rate, "rate") == 0)
9159 && (strcmp(res->q_msk, "queue_mask") == 0))
9160 ret = set_vf_rate_limit(res->port_num, res->vf_num,
9161 res->rate_num, res->q_msk_val);
9163 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
9167 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
9168 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9170 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
9171 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9173 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
9174 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9176 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
9177 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9179 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
9180 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9182 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
9183 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9185 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
9186 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9188 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
9189 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9190 q_msk, "queue_mask");
9191 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
9192 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9195 cmdline_parse_inst_t cmd_vf_rate_limit = {
9196 .f = cmd_vf_rate_limit_parsed,
9198 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
9199 "queue_mask <queue_mask_value>: "
9200 "Set rate limit for queues of VF on port_id",
9202 (void *)&cmd_vf_rate_limit_set,
9203 (void *)&cmd_vf_rate_limit_port,
9204 (void *)&cmd_vf_rate_limit_portnum,
9205 (void *)&cmd_vf_rate_limit_vf,
9206 (void *)&cmd_vf_rate_limit_vfnum,
9207 (void *)&cmd_vf_rate_limit_rate,
9208 (void *)&cmd_vf_rate_limit_ratenum,
9209 (void *)&cmd_vf_rate_limit_q_msk,
9210 (void *)&cmd_vf_rate_limit_q_msk_val,
9215 /* *** ADD TUNNEL FILTER OF A PORT *** */
9216 struct cmd_tunnel_filter_result {
9217 cmdline_fixed_string_t cmd;
9218 cmdline_fixed_string_t what;
9220 struct rte_ether_addr outer_mac;
9221 struct rte_ether_addr inner_mac;
9222 cmdline_ipaddr_t ip_value;
9223 uint16_t inner_vlan;
9224 cmdline_fixed_string_t tunnel_type;
9225 cmdline_fixed_string_t filter_type;
9231 cmd_tunnel_filter_parsed(void *parsed_result,
9232 __rte_unused struct cmdline *cl,
9233 __rte_unused void *data)
9235 struct cmd_tunnel_filter_result *res = parsed_result;
9236 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
9239 memset(&tunnel_filter_conf, 0, sizeof(tunnel_filter_conf));
9241 rte_ether_addr_copy(&res->outer_mac, &tunnel_filter_conf.outer_mac);
9242 rte_ether_addr_copy(&res->inner_mac, &tunnel_filter_conf.inner_mac);
9243 tunnel_filter_conf.inner_vlan = res->inner_vlan;
9245 if (res->ip_value.family == AF_INET) {
9246 tunnel_filter_conf.ip_addr.ipv4_addr =
9247 res->ip_value.addr.ipv4.s_addr;
9248 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
9250 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
9251 &(res->ip_value.addr.ipv6),
9252 sizeof(struct in6_addr));
9253 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
9256 if (!strcmp(res->filter_type, "imac-ivlan"))
9257 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
9258 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
9259 tunnel_filter_conf.filter_type =
9260 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
9261 else if (!strcmp(res->filter_type, "imac-tenid"))
9262 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
9263 else if (!strcmp(res->filter_type, "imac"))
9264 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
9265 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
9266 tunnel_filter_conf.filter_type =
9267 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
9268 else if (!strcmp(res->filter_type, "oip"))
9269 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_OIP;
9270 else if (!strcmp(res->filter_type, "iip"))
9271 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IIP;
9273 printf("The filter type is not supported");
9277 if (!strcmp(res->tunnel_type, "vxlan"))
9278 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
9279 else if (!strcmp(res->tunnel_type, "vxlan-gpe"))
9280 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN_GPE;
9281 else if (!strcmp(res->tunnel_type, "nvgre"))
9282 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE;
9283 else if (!strcmp(res->tunnel_type, "ipingre"))
9284 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_IP_IN_GRE;
9286 printf("The tunnel type %s not supported.\n", res->tunnel_type);
9290 tunnel_filter_conf.tenant_id = res->tenant_id;
9291 tunnel_filter_conf.queue_id = res->queue_num;
9292 if (!strcmp(res->what, "add"))
9293 ret = rte_eth_dev_filter_ctrl(res->port_id,
9294 RTE_ETH_FILTER_TUNNEL,
9296 &tunnel_filter_conf);
9298 ret = rte_eth_dev_filter_ctrl(res->port_id,
9299 RTE_ETH_FILTER_TUNNEL,
9300 RTE_ETH_FILTER_DELETE,
9301 &tunnel_filter_conf);
9303 printf("cmd_tunnel_filter_parsed error: (%s)\n",
9307 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
9308 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
9309 cmd, "tunnel_filter");
9310 cmdline_parse_token_string_t cmd_tunnel_filter_what =
9311 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
9313 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
9314 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
9316 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
9317 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
9319 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
9320 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
9322 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
9323 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
9324 inner_vlan, UINT16);
9325 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
9326 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
9328 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
9329 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
9330 tunnel_type, "vxlan#nvgre#ipingre#vxlan-gpe");
9332 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
9333 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
9334 filter_type, "oip#iip#imac-ivlan#imac-ivlan-tenid#imac-tenid#"
9335 "imac#omac-imac-tenid");
9336 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
9337 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
9339 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
9340 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
9343 cmdline_parse_inst_t cmd_tunnel_filter = {
9344 .f = cmd_tunnel_filter_parsed,
9346 .help_str = "tunnel_filter add|rm <port_id> <outer_mac> <inner_mac> "
9347 "<ip> <inner_vlan> vxlan|nvgre|ipingre oip|iip|imac-ivlan|"
9348 "imac-ivlan-tenid|imac-tenid|imac|omac-imac-tenid <tenant_id> "
9349 "<queue_id>: Add/Rm tunnel filter of a port",
9351 (void *)&cmd_tunnel_filter_cmd,
9352 (void *)&cmd_tunnel_filter_what,
9353 (void *)&cmd_tunnel_filter_port_id,
9354 (void *)&cmd_tunnel_filter_outer_mac,
9355 (void *)&cmd_tunnel_filter_inner_mac,
9356 (void *)&cmd_tunnel_filter_ip_value,
9357 (void *)&cmd_tunnel_filter_innner_vlan,
9358 (void *)&cmd_tunnel_filter_tunnel_type,
9359 (void *)&cmd_tunnel_filter_filter_type,
9360 (void *)&cmd_tunnel_filter_tenant_id,
9361 (void *)&cmd_tunnel_filter_queue_num,
9366 /* *** CONFIGURE TUNNEL UDP PORT *** */
9367 struct cmd_tunnel_udp_config {
9368 cmdline_fixed_string_t cmd;
9369 cmdline_fixed_string_t what;
9375 cmd_tunnel_udp_config_parsed(void *parsed_result,
9376 __rte_unused struct cmdline *cl,
9377 __rte_unused void *data)
9379 struct cmd_tunnel_udp_config *res = parsed_result;
9380 struct rte_eth_udp_tunnel tunnel_udp;
9383 tunnel_udp.udp_port = res->udp_port;
9385 if (!strcmp(res->cmd, "rx_vxlan_port"))
9386 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
9388 if (!strcmp(res->what, "add"))
9389 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9392 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9396 printf("udp tunneling add error: (%s)\n", strerror(-ret));
9399 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
9400 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9401 cmd, "rx_vxlan_port");
9402 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
9403 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9405 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
9406 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9408 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
9409 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9412 cmdline_parse_inst_t cmd_tunnel_udp_config = {
9413 .f = cmd_tunnel_udp_config_parsed,
9415 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
9416 "Add/Remove a tunneling UDP port filter",
9418 (void *)&cmd_tunnel_udp_config_cmd,
9419 (void *)&cmd_tunnel_udp_config_what,
9420 (void *)&cmd_tunnel_udp_config_udp_port,
9421 (void *)&cmd_tunnel_udp_config_port_id,
9426 struct cmd_config_tunnel_udp_port {
9427 cmdline_fixed_string_t port;
9428 cmdline_fixed_string_t config;
9430 cmdline_fixed_string_t udp_tunnel_port;
9431 cmdline_fixed_string_t action;
9432 cmdline_fixed_string_t tunnel_type;
9437 cmd_cfg_tunnel_udp_port_parsed(void *parsed_result,
9438 __rte_unused struct cmdline *cl,
9439 __rte_unused void *data)
9441 struct cmd_config_tunnel_udp_port *res = parsed_result;
9442 struct rte_eth_udp_tunnel tunnel_udp;
9445 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9448 tunnel_udp.udp_port = res->udp_port;
9450 if (!strcmp(res->tunnel_type, "vxlan")) {
9451 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
9452 } else if (!strcmp(res->tunnel_type, "geneve")) {
9453 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_GENEVE;
9454 } else if (!strcmp(res->tunnel_type, "vxlan-gpe")) {
9455 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN_GPE;
9457 printf("Invalid tunnel type\n");
9461 if (!strcmp(res->action, "add"))
9462 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9465 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9469 printf("udp tunneling port add error: (%s)\n", strerror(-ret));
9472 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_port =
9473 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, port,
9475 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_config =
9476 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, config,
9478 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_port_id =
9479 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, port_id,
9481 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_port =
9482 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port,
9485 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_action =
9486 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, action,
9488 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_type =
9489 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, tunnel_type,
9490 "vxlan#geneve#vxlan-gpe");
9491 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_value =
9492 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, udp_port,
9495 cmdline_parse_inst_t cmd_cfg_tunnel_udp_port = {
9496 .f = cmd_cfg_tunnel_udp_port_parsed,
9498 .help_str = "port config <port_id> udp_tunnel_port add|rm vxlan|geneve|vxlan-gpe <udp_port>",
9500 (void *)&cmd_config_tunnel_udp_port_port,
9501 (void *)&cmd_config_tunnel_udp_port_config,
9502 (void *)&cmd_config_tunnel_udp_port_port_id,
9503 (void *)&cmd_config_tunnel_udp_port_tunnel_port,
9504 (void *)&cmd_config_tunnel_udp_port_action,
9505 (void *)&cmd_config_tunnel_udp_port_tunnel_type,
9506 (void *)&cmd_config_tunnel_udp_port_value,
9511 /* *** GLOBAL CONFIG *** */
9512 struct cmd_global_config_result {
9513 cmdline_fixed_string_t cmd;
9515 cmdline_fixed_string_t cfg_type;
9520 cmd_global_config_parsed(void *parsed_result,
9521 __rte_unused struct cmdline *cl,
9522 __rte_unused void *data)
9524 struct cmd_global_config_result *res = parsed_result;
9525 struct rte_eth_global_cfg conf;
9528 memset(&conf, 0, sizeof(conf));
9529 conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN;
9530 conf.cfg.gre_key_len = res->len;
9531 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE,
9532 RTE_ETH_FILTER_SET, &conf);
9534 if (ret == -ENOTSUP)
9535 ret = rte_pmd_i40e_set_gre_key_len(res->port_id, res->len);
9538 printf("Global config error\n");
9541 cmdline_parse_token_string_t cmd_global_config_cmd =
9542 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd,
9544 cmdline_parse_token_num_t cmd_global_config_port_id =
9545 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id,
9547 cmdline_parse_token_string_t cmd_global_config_type =
9548 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result,
9549 cfg_type, "gre-key-len");
9550 cmdline_parse_token_num_t cmd_global_config_gre_key_len =
9551 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result,
9554 cmdline_parse_inst_t cmd_global_config = {
9555 .f = cmd_global_config_parsed,
9556 .data = (void *)NULL,
9557 .help_str = "global_config <port_id> gre-key-len <key_len>",
9559 (void *)&cmd_global_config_cmd,
9560 (void *)&cmd_global_config_port_id,
9561 (void *)&cmd_global_config_type,
9562 (void *)&cmd_global_config_gre_key_len,
9567 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
9568 struct cmd_set_mirror_mask_result {
9569 cmdline_fixed_string_t set;
9570 cmdline_fixed_string_t port;
9572 cmdline_fixed_string_t mirror;
9574 cmdline_fixed_string_t what;
9575 cmdline_fixed_string_t value;
9576 cmdline_fixed_string_t dstpool;
9578 cmdline_fixed_string_t on;
9581 cmdline_parse_token_string_t cmd_mirror_mask_set =
9582 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9584 cmdline_parse_token_string_t cmd_mirror_mask_port =
9585 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9587 cmdline_parse_token_num_t cmd_mirror_mask_portid =
9588 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9590 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
9591 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9592 mirror, "mirror-rule");
9593 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
9594 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9596 cmdline_parse_token_string_t cmd_mirror_mask_what =
9597 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9598 what, "pool-mirror-up#pool-mirror-down"
9600 cmdline_parse_token_string_t cmd_mirror_mask_value =
9601 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9603 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
9604 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9605 dstpool, "dst-pool");
9606 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
9607 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9609 cmdline_parse_token_string_t cmd_mirror_mask_on =
9610 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9614 cmd_set_mirror_mask_parsed(void *parsed_result,
9615 __rte_unused struct cmdline *cl,
9616 __rte_unused void *data)
9619 struct cmd_set_mirror_mask_result *res = parsed_result;
9620 struct rte_eth_mirror_conf mr_conf;
9622 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
9624 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
9626 mr_conf.dst_pool = res->dstpool_id;
9628 if (!strcmp(res->what, "pool-mirror-up")) {
9629 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
9630 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
9631 } else if (!strcmp(res->what, "pool-mirror-down")) {
9632 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
9633 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
9634 } else if (!strcmp(res->what, "vlan-mirror")) {
9635 mr_conf.rule_type = ETH_MIRROR_VLAN;
9636 nb_item = parse_item_list(res->value, "vlan",
9637 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
9641 for (i = 0; i < nb_item; i++) {
9642 if (vlan_list[i] > RTE_ETHER_MAX_VLAN_ID) {
9643 printf("Invalid vlan_id: must be < 4096\n");
9647 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
9648 mr_conf.vlan.vlan_mask |= 1ULL << i;
9652 if (!strcmp(res->on, "on"))
9653 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9656 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9659 printf("mirror rule add error: (%s)\n", strerror(-ret));
9662 cmdline_parse_inst_t cmd_set_mirror_mask = {
9663 .f = cmd_set_mirror_mask_parsed,
9665 .help_str = "set port <port_id> mirror-rule <rule_id> "
9666 "pool-mirror-up|pool-mirror-down|vlan-mirror "
9667 "<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off",
9669 (void *)&cmd_mirror_mask_set,
9670 (void *)&cmd_mirror_mask_port,
9671 (void *)&cmd_mirror_mask_portid,
9672 (void *)&cmd_mirror_mask_mirror,
9673 (void *)&cmd_mirror_mask_ruleid,
9674 (void *)&cmd_mirror_mask_what,
9675 (void *)&cmd_mirror_mask_value,
9676 (void *)&cmd_mirror_mask_dstpool,
9677 (void *)&cmd_mirror_mask_poolid,
9678 (void *)&cmd_mirror_mask_on,
9683 /* *** CONFIGURE VM MIRROR UPLINK/DOWNLINK RULE *** */
9684 struct cmd_set_mirror_link_result {
9685 cmdline_fixed_string_t set;
9686 cmdline_fixed_string_t port;
9688 cmdline_fixed_string_t mirror;
9690 cmdline_fixed_string_t what;
9691 cmdline_fixed_string_t dstpool;
9693 cmdline_fixed_string_t on;
9696 cmdline_parse_token_string_t cmd_mirror_link_set =
9697 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9699 cmdline_parse_token_string_t cmd_mirror_link_port =
9700 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9702 cmdline_parse_token_num_t cmd_mirror_link_portid =
9703 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9705 cmdline_parse_token_string_t cmd_mirror_link_mirror =
9706 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9707 mirror, "mirror-rule");
9708 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
9709 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9711 cmdline_parse_token_string_t cmd_mirror_link_what =
9712 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9713 what, "uplink-mirror#downlink-mirror");
9714 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
9715 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9716 dstpool, "dst-pool");
9717 cmdline_parse_token_num_t cmd_mirror_link_poolid =
9718 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9720 cmdline_parse_token_string_t cmd_mirror_link_on =
9721 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9725 cmd_set_mirror_link_parsed(void *parsed_result,
9726 __rte_unused struct cmdline *cl,
9727 __rte_unused void *data)
9730 struct cmd_set_mirror_link_result *res = parsed_result;
9731 struct rte_eth_mirror_conf mr_conf;
9733 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
9734 if (!strcmp(res->what, "uplink-mirror"))
9735 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
9737 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
9739 mr_conf.dst_pool = res->dstpool_id;
9741 if (!strcmp(res->on, "on"))
9742 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9745 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9748 /* check the return value and print it if is < 0 */
9750 printf("mirror rule add error: (%s)\n", strerror(-ret));
9754 cmdline_parse_inst_t cmd_set_mirror_link = {
9755 .f = cmd_set_mirror_link_parsed,
9757 .help_str = "set port <port_id> mirror-rule <rule_id> "
9758 "uplink-mirror|downlink-mirror dst-pool <pool_id> on|off",
9760 (void *)&cmd_mirror_link_set,
9761 (void *)&cmd_mirror_link_port,
9762 (void *)&cmd_mirror_link_portid,
9763 (void *)&cmd_mirror_link_mirror,
9764 (void *)&cmd_mirror_link_ruleid,
9765 (void *)&cmd_mirror_link_what,
9766 (void *)&cmd_mirror_link_dstpool,
9767 (void *)&cmd_mirror_link_poolid,
9768 (void *)&cmd_mirror_link_on,
9773 /* *** RESET VM MIRROR RULE *** */
9774 struct cmd_rm_mirror_rule_result {
9775 cmdline_fixed_string_t reset;
9776 cmdline_fixed_string_t port;
9778 cmdline_fixed_string_t mirror;
9782 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
9783 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9785 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
9786 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9788 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
9789 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9791 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
9792 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9793 mirror, "mirror-rule");
9794 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
9795 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9799 cmd_reset_mirror_rule_parsed(void *parsed_result,
9800 __rte_unused struct cmdline *cl,
9801 __rte_unused void *data)
9804 struct cmd_set_mirror_link_result *res = parsed_result;
9806 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
9808 printf("mirror rule remove error: (%s)\n", strerror(-ret));
9811 cmdline_parse_inst_t cmd_reset_mirror_rule = {
9812 .f = cmd_reset_mirror_rule_parsed,
9814 .help_str = "reset port <port_id> mirror-rule <rule_id>",
9816 (void *)&cmd_rm_mirror_rule_reset,
9817 (void *)&cmd_rm_mirror_rule_port,
9818 (void *)&cmd_rm_mirror_rule_portid,
9819 (void *)&cmd_rm_mirror_rule_mirror,
9820 (void *)&cmd_rm_mirror_rule_ruleid,
9825 /* ******************************************************************************** */
9827 struct cmd_dump_result {
9828 cmdline_fixed_string_t dump;
9832 dump_struct_sizes(void)
9834 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
9835 DUMP_SIZE(struct rte_mbuf);
9836 DUMP_SIZE(struct rte_mempool);
9837 DUMP_SIZE(struct rte_ring);
9842 /* Dump the socket memory statistics on console */
9844 dump_socket_mem(FILE *f)
9846 struct rte_malloc_socket_stats socket_stats;
9851 unsigned int n_alloc = 0;
9852 unsigned int n_free = 0;
9853 static size_t last_allocs;
9854 static size_t last_total;
9857 for (i = 0; i < RTE_MAX_NUMA_NODES; i++) {
9858 if (rte_malloc_get_socket_stats(i, &socket_stats) ||
9859 !socket_stats.heap_totalsz_bytes)
9861 total += socket_stats.heap_totalsz_bytes;
9862 alloc += socket_stats.heap_allocsz_bytes;
9863 free += socket_stats.heap_freesz_bytes;
9864 n_alloc += socket_stats.alloc_count;
9865 n_free += socket_stats.free_count;
9867 "Socket %u: size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n",
9869 (double)socket_stats.heap_totalsz_bytes / (1024 * 1024),
9870 (double)socket_stats.heap_allocsz_bytes / (1024 * 1024),
9871 (double)socket_stats.heap_allocsz_bytes * 100 /
9872 (double)socket_stats.heap_totalsz_bytes,
9873 (double)socket_stats.heap_freesz_bytes / (1024 * 1024),
9874 socket_stats.alloc_count,
9875 socket_stats.free_count);
9878 "Total : size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n",
9879 (double)total / (1024 * 1024), (double)alloc / (1024 * 1024),
9880 (double)alloc * 100 / (double)total,
9881 (double)free / (1024 * 1024),
9884 fprintf(stdout, "Memory total change: %.6lf(M), allocation change: %.6lf(M)\n",
9885 ((double)total - (double)last_total) / (1024 * 1024),
9886 (double)(alloc - (double)last_allocs) / 1024 / 1024);
9887 last_allocs = alloc;
9891 static void cmd_dump_parsed(void *parsed_result,
9892 __rte_unused struct cmdline *cl,
9893 __rte_unused void *data)
9895 struct cmd_dump_result *res = parsed_result;
9897 if (!strcmp(res->dump, "dump_physmem"))
9898 rte_dump_physmem_layout(stdout);
9899 else if (!strcmp(res->dump, "dump_socket_mem"))
9900 dump_socket_mem(stdout);
9901 else if (!strcmp(res->dump, "dump_memzone"))
9902 rte_memzone_dump(stdout);
9903 else if (!strcmp(res->dump, "dump_struct_sizes"))
9904 dump_struct_sizes();
9905 else if (!strcmp(res->dump, "dump_ring"))
9906 rte_ring_list_dump(stdout);
9907 else if (!strcmp(res->dump, "dump_mempool"))
9908 rte_mempool_list_dump(stdout);
9909 else if (!strcmp(res->dump, "dump_devargs"))
9910 rte_devargs_dump(stdout);
9911 else if (!strcmp(res->dump, "dump_log_types"))
9912 rte_log_dump(stdout);
9915 cmdline_parse_token_string_t cmd_dump_dump =
9916 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
9920 "dump_struct_sizes#"
9926 cmdline_parse_inst_t cmd_dump = {
9927 .f = cmd_dump_parsed, /* function to call */
9928 .data = NULL, /* 2nd arg of func */
9929 .help_str = "Dump status",
9930 .tokens = { /* token list, NULL terminated */
9931 (void *)&cmd_dump_dump,
9936 /* ******************************************************************************** */
9938 struct cmd_dump_one_result {
9939 cmdline_fixed_string_t dump;
9940 cmdline_fixed_string_t name;
9943 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
9944 __rte_unused void *data)
9946 struct cmd_dump_one_result *res = parsed_result;
9948 if (!strcmp(res->dump, "dump_ring")) {
9950 r = rte_ring_lookup(res->name);
9952 cmdline_printf(cl, "Cannot find ring\n");
9955 rte_ring_dump(stdout, r);
9956 } else if (!strcmp(res->dump, "dump_mempool")) {
9957 struct rte_mempool *mp;
9958 mp = rte_mempool_lookup(res->name);
9960 cmdline_printf(cl, "Cannot find mempool\n");
9963 rte_mempool_dump(stdout, mp);
9967 cmdline_parse_token_string_t cmd_dump_one_dump =
9968 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
9969 "dump_ring#dump_mempool");
9971 cmdline_parse_token_string_t cmd_dump_one_name =
9972 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
9974 cmdline_parse_inst_t cmd_dump_one = {
9975 .f = cmd_dump_one_parsed, /* function to call */
9976 .data = NULL, /* 2nd arg of func */
9977 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
9978 .tokens = { /* token list, NULL terminated */
9979 (void *)&cmd_dump_one_dump,
9980 (void *)&cmd_dump_one_name,
9985 /* *** Add/Del syn filter *** */
9986 struct cmd_syn_filter_result {
9987 cmdline_fixed_string_t filter;
9989 cmdline_fixed_string_t ops;
9990 cmdline_fixed_string_t priority;
9991 cmdline_fixed_string_t high;
9992 cmdline_fixed_string_t queue;
9997 cmd_syn_filter_parsed(void *parsed_result,
9998 __rte_unused struct cmdline *cl,
9999 __rte_unused void *data)
10001 struct cmd_syn_filter_result *res = parsed_result;
10002 struct rte_eth_syn_filter syn_filter;
10005 ret = rte_eth_dev_filter_supported(res->port_id,
10006 RTE_ETH_FILTER_SYN);
10008 printf("syn filter is not supported on port %u.\n",
10013 memset(&syn_filter, 0, sizeof(syn_filter));
10015 if (!strcmp(res->ops, "add")) {
10016 if (!strcmp(res->high, "high"))
10017 syn_filter.hig_pri = 1;
10019 syn_filter.hig_pri = 0;
10021 syn_filter.queue = res->queue_id;
10022 ret = rte_eth_dev_filter_ctrl(res->port_id,
10023 RTE_ETH_FILTER_SYN,
10024 RTE_ETH_FILTER_ADD,
10027 ret = rte_eth_dev_filter_ctrl(res->port_id,
10028 RTE_ETH_FILTER_SYN,
10029 RTE_ETH_FILTER_DELETE,
10033 printf("syn filter programming error: (%s)\n",
10037 cmdline_parse_token_string_t cmd_syn_filter_filter =
10038 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
10039 filter, "syn_filter");
10040 cmdline_parse_token_num_t cmd_syn_filter_port_id =
10041 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
10043 cmdline_parse_token_string_t cmd_syn_filter_ops =
10044 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
10046 cmdline_parse_token_string_t cmd_syn_filter_priority =
10047 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
10048 priority, "priority");
10049 cmdline_parse_token_string_t cmd_syn_filter_high =
10050 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
10052 cmdline_parse_token_string_t cmd_syn_filter_queue =
10053 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
10055 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
10056 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
10059 cmdline_parse_inst_t cmd_syn_filter = {
10060 .f = cmd_syn_filter_parsed,
10062 .help_str = "syn_filter <port_id> add|del priority high|low queue "
10063 "<queue_id>: Add/Delete syn filter",
10065 (void *)&cmd_syn_filter_filter,
10066 (void *)&cmd_syn_filter_port_id,
10067 (void *)&cmd_syn_filter_ops,
10068 (void *)&cmd_syn_filter_priority,
10069 (void *)&cmd_syn_filter_high,
10070 (void *)&cmd_syn_filter_queue,
10071 (void *)&cmd_syn_filter_queue_id,
10076 /* *** queue region set *** */
10077 struct cmd_queue_region_result {
10078 cmdline_fixed_string_t set;
10079 cmdline_fixed_string_t port;
10081 cmdline_fixed_string_t cmd;
10082 cmdline_fixed_string_t region;
10084 cmdline_fixed_string_t queue_start_index;
10086 cmdline_fixed_string_t queue_num;
10087 uint8_t queue_num_value;
10091 cmd_queue_region_parsed(void *parsed_result,
10092 __rte_unused struct cmdline *cl,
10093 __rte_unused void *data)
10095 struct cmd_queue_region_result *res = parsed_result;
10096 int ret = -ENOTSUP;
10097 #ifdef RTE_NET_I40E
10098 struct rte_pmd_i40e_queue_region_conf region_conf;
10099 enum rte_pmd_i40e_queue_region_op op_type;
10102 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10105 #ifdef RTE_NET_I40E
10106 memset(®ion_conf, 0, sizeof(region_conf));
10107 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_SET;
10108 region_conf.region_id = res->region_id;
10109 region_conf.queue_num = res->queue_num_value;
10110 region_conf.queue_start_index = res->queue_id;
10112 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10113 op_type, ®ion_conf);
10120 printf("function not implemented or supported\n");
10123 printf("queue region config error: (%s)\n", strerror(-ret));
10127 cmdline_parse_token_string_t cmd_queue_region_set =
10128 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
10130 cmdline_parse_token_string_t cmd_queue_region_port =
10131 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, port, "port");
10132 cmdline_parse_token_num_t cmd_queue_region_port_id =
10133 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
10135 cmdline_parse_token_string_t cmd_queue_region_cmd =
10136 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
10137 cmd, "queue-region");
10138 cmdline_parse_token_string_t cmd_queue_region_id =
10139 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
10140 region, "region_id");
10141 cmdline_parse_token_num_t cmd_queue_region_index =
10142 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
10144 cmdline_parse_token_string_t cmd_queue_region_queue_start_index =
10145 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
10146 queue_start_index, "queue_start_index");
10147 cmdline_parse_token_num_t cmd_queue_region_queue_id =
10148 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
10150 cmdline_parse_token_string_t cmd_queue_region_queue_num =
10151 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
10152 queue_num, "queue_num");
10153 cmdline_parse_token_num_t cmd_queue_region_queue_num_value =
10154 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
10155 queue_num_value, UINT8);
10157 cmdline_parse_inst_t cmd_queue_region = {
10158 .f = cmd_queue_region_parsed,
10160 .help_str = "set port <port_id> queue-region region_id <value> "
10161 "queue_start_index <value> queue_num <value>: Set a queue region",
10163 (void *)&cmd_queue_region_set,
10164 (void *)&cmd_queue_region_port,
10165 (void *)&cmd_queue_region_port_id,
10166 (void *)&cmd_queue_region_cmd,
10167 (void *)&cmd_queue_region_id,
10168 (void *)&cmd_queue_region_index,
10169 (void *)&cmd_queue_region_queue_start_index,
10170 (void *)&cmd_queue_region_queue_id,
10171 (void *)&cmd_queue_region_queue_num,
10172 (void *)&cmd_queue_region_queue_num_value,
10177 /* *** queue region and flowtype set *** */
10178 struct cmd_region_flowtype_result {
10179 cmdline_fixed_string_t set;
10180 cmdline_fixed_string_t port;
10182 cmdline_fixed_string_t cmd;
10183 cmdline_fixed_string_t region;
10185 cmdline_fixed_string_t flowtype;
10186 uint8_t flowtype_id;
10190 cmd_region_flowtype_parsed(void *parsed_result,
10191 __rte_unused struct cmdline *cl,
10192 __rte_unused void *data)
10194 struct cmd_region_flowtype_result *res = parsed_result;
10195 int ret = -ENOTSUP;
10196 #ifdef RTE_NET_I40E
10197 struct rte_pmd_i40e_queue_region_conf region_conf;
10198 enum rte_pmd_i40e_queue_region_op op_type;
10201 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10204 #ifdef RTE_NET_I40E
10205 memset(®ion_conf, 0, sizeof(region_conf));
10207 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_FLOWTYPE_SET;
10208 region_conf.region_id = res->region_id;
10209 region_conf.hw_flowtype = res->flowtype_id;
10211 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10212 op_type, ®ion_conf);
10219 printf("function not implemented or supported\n");
10222 printf("region flowtype config error: (%s)\n", strerror(-ret));
10226 cmdline_parse_token_string_t cmd_region_flowtype_set =
10227 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10229 cmdline_parse_token_string_t cmd_region_flowtype_port =
10230 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10232 cmdline_parse_token_num_t cmd_region_flowtype_port_index =
10233 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
10235 cmdline_parse_token_string_t cmd_region_flowtype_cmd =
10236 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10237 cmd, "queue-region");
10238 cmdline_parse_token_string_t cmd_region_flowtype_index =
10239 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10240 region, "region_id");
10241 cmdline_parse_token_num_t cmd_region_flowtype_id =
10242 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
10244 cmdline_parse_token_string_t cmd_region_flowtype_flow_index =
10245 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10246 flowtype, "flowtype");
10247 cmdline_parse_token_num_t cmd_region_flowtype_flow_id =
10248 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
10249 flowtype_id, UINT8);
10250 cmdline_parse_inst_t cmd_region_flowtype = {
10251 .f = cmd_region_flowtype_parsed,
10253 .help_str = "set port <port_id> queue-region region_id <value> "
10254 "flowtype <value>: Set a flowtype region index",
10256 (void *)&cmd_region_flowtype_set,
10257 (void *)&cmd_region_flowtype_port,
10258 (void *)&cmd_region_flowtype_port_index,
10259 (void *)&cmd_region_flowtype_cmd,
10260 (void *)&cmd_region_flowtype_index,
10261 (void *)&cmd_region_flowtype_id,
10262 (void *)&cmd_region_flowtype_flow_index,
10263 (void *)&cmd_region_flowtype_flow_id,
10268 /* *** User Priority (UP) to queue region (region_id) set *** */
10269 struct cmd_user_priority_region_result {
10270 cmdline_fixed_string_t set;
10271 cmdline_fixed_string_t port;
10273 cmdline_fixed_string_t cmd;
10274 cmdline_fixed_string_t user_priority;
10275 uint8_t user_priority_id;
10276 cmdline_fixed_string_t region;
10281 cmd_user_priority_region_parsed(void *parsed_result,
10282 __rte_unused struct cmdline *cl,
10283 __rte_unused void *data)
10285 struct cmd_user_priority_region_result *res = parsed_result;
10286 int ret = -ENOTSUP;
10287 #ifdef RTE_NET_I40E
10288 struct rte_pmd_i40e_queue_region_conf region_conf;
10289 enum rte_pmd_i40e_queue_region_op op_type;
10292 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10295 #ifdef RTE_NET_I40E
10296 memset(®ion_conf, 0, sizeof(region_conf));
10297 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_USER_PRIORITY_SET;
10298 region_conf.user_priority = res->user_priority_id;
10299 region_conf.region_id = res->region_id;
10301 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10302 op_type, ®ion_conf);
10309 printf("function not implemented or supported\n");
10312 printf("user_priority region config error: (%s)\n",
10317 cmdline_parse_token_string_t cmd_user_priority_region_set =
10318 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10320 cmdline_parse_token_string_t cmd_user_priority_region_port =
10321 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10323 cmdline_parse_token_num_t cmd_user_priority_region_port_index =
10324 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10326 cmdline_parse_token_string_t cmd_user_priority_region_cmd =
10327 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10328 cmd, "queue-region");
10329 cmdline_parse_token_string_t cmd_user_priority_region_UP =
10330 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10331 user_priority, "UP");
10332 cmdline_parse_token_num_t cmd_user_priority_region_UP_id =
10333 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10334 user_priority_id, UINT8);
10335 cmdline_parse_token_string_t cmd_user_priority_region_region =
10336 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10337 region, "region_id");
10338 cmdline_parse_token_num_t cmd_user_priority_region_region_id =
10339 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10342 cmdline_parse_inst_t cmd_user_priority_region = {
10343 .f = cmd_user_priority_region_parsed,
10345 .help_str = "set port <port_id> queue-region UP <value> "
10346 "region_id <value>: Set the mapping of User Priority (UP) "
10347 "to queue region (region_id) ",
10349 (void *)&cmd_user_priority_region_set,
10350 (void *)&cmd_user_priority_region_port,
10351 (void *)&cmd_user_priority_region_port_index,
10352 (void *)&cmd_user_priority_region_cmd,
10353 (void *)&cmd_user_priority_region_UP,
10354 (void *)&cmd_user_priority_region_UP_id,
10355 (void *)&cmd_user_priority_region_region,
10356 (void *)&cmd_user_priority_region_region_id,
10361 /* *** flush all queue region related configuration *** */
10362 struct cmd_flush_queue_region_result {
10363 cmdline_fixed_string_t set;
10364 cmdline_fixed_string_t port;
10366 cmdline_fixed_string_t cmd;
10367 cmdline_fixed_string_t flush;
10368 cmdline_fixed_string_t what;
10372 cmd_flush_queue_region_parsed(void *parsed_result,
10373 __rte_unused struct cmdline *cl,
10374 __rte_unused void *data)
10376 struct cmd_flush_queue_region_result *res = parsed_result;
10377 int ret = -ENOTSUP;
10378 #ifdef RTE_NET_I40E
10379 struct rte_pmd_i40e_queue_region_conf region_conf;
10380 enum rte_pmd_i40e_queue_region_op op_type;
10383 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10386 #ifdef RTE_NET_I40E
10387 memset(®ion_conf, 0, sizeof(region_conf));
10389 if (strcmp(res->what, "on") == 0)
10390 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_ON;
10392 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_OFF;
10394 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10395 op_type, ®ion_conf);
10402 printf("function not implemented or supported\n");
10405 printf("queue region config flush error: (%s)\n",
10410 cmdline_parse_token_string_t cmd_flush_queue_region_set =
10411 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10413 cmdline_parse_token_string_t cmd_flush_queue_region_port =
10414 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10416 cmdline_parse_token_num_t cmd_flush_queue_region_port_index =
10417 TOKEN_NUM_INITIALIZER(struct cmd_flush_queue_region_result,
10419 cmdline_parse_token_string_t cmd_flush_queue_region_cmd =
10420 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10421 cmd, "queue-region");
10422 cmdline_parse_token_string_t cmd_flush_queue_region_flush =
10423 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10425 cmdline_parse_token_string_t cmd_flush_queue_region_what =
10426 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10429 cmdline_parse_inst_t cmd_flush_queue_region = {
10430 .f = cmd_flush_queue_region_parsed,
10432 .help_str = "set port <port_id> queue-region flush on|off"
10433 ": flush all queue region related configuration",
10435 (void *)&cmd_flush_queue_region_set,
10436 (void *)&cmd_flush_queue_region_port,
10437 (void *)&cmd_flush_queue_region_port_index,
10438 (void *)&cmd_flush_queue_region_cmd,
10439 (void *)&cmd_flush_queue_region_flush,
10440 (void *)&cmd_flush_queue_region_what,
10445 /* *** get all queue region related configuration info *** */
10446 struct cmd_show_queue_region_info {
10447 cmdline_fixed_string_t show;
10448 cmdline_fixed_string_t port;
10450 cmdline_fixed_string_t cmd;
10454 cmd_show_queue_region_info_parsed(void *parsed_result,
10455 __rte_unused struct cmdline *cl,
10456 __rte_unused void *data)
10458 struct cmd_show_queue_region_info *res = parsed_result;
10459 int ret = -ENOTSUP;
10460 #ifdef RTE_NET_I40E
10461 struct rte_pmd_i40e_queue_regions rte_pmd_regions;
10462 enum rte_pmd_i40e_queue_region_op op_type;
10465 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10468 #ifdef RTE_NET_I40E
10469 memset(&rte_pmd_regions, 0, sizeof(rte_pmd_regions));
10471 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_INFO_GET;
10473 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10474 op_type, &rte_pmd_regions);
10476 port_queue_region_info_display(res->port_id, &rte_pmd_regions);
10483 printf("function not implemented or supported\n");
10486 printf("queue region config info show error: (%s)\n",
10491 cmdline_parse_token_string_t cmd_show_queue_region_info_get =
10492 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10494 cmdline_parse_token_string_t cmd_show_queue_region_info_port =
10495 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10497 cmdline_parse_token_num_t cmd_show_queue_region_info_port_index =
10498 TOKEN_NUM_INITIALIZER(struct cmd_show_queue_region_info,
10500 cmdline_parse_token_string_t cmd_show_queue_region_info_cmd =
10501 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10502 cmd, "queue-region");
10504 cmdline_parse_inst_t cmd_show_queue_region_info_all = {
10505 .f = cmd_show_queue_region_info_parsed,
10507 .help_str = "show port <port_id> queue-region"
10508 ": show all queue region related configuration info",
10510 (void *)&cmd_show_queue_region_info_get,
10511 (void *)&cmd_show_queue_region_info_port,
10512 (void *)&cmd_show_queue_region_info_port_index,
10513 (void *)&cmd_show_queue_region_info_cmd,
10518 /* *** ADD/REMOVE A 2tuple FILTER *** */
10519 struct cmd_2tuple_filter_result {
10520 cmdline_fixed_string_t filter;
10522 cmdline_fixed_string_t ops;
10523 cmdline_fixed_string_t dst_port;
10524 uint16_t dst_port_value;
10525 cmdline_fixed_string_t protocol;
10526 uint8_t protocol_value;
10527 cmdline_fixed_string_t mask;
10528 uint8_t mask_value;
10529 cmdline_fixed_string_t tcp_flags;
10530 uint8_t tcp_flags_value;
10531 cmdline_fixed_string_t priority;
10532 uint8_t priority_value;
10533 cmdline_fixed_string_t queue;
10538 cmd_2tuple_filter_parsed(void *parsed_result,
10539 __rte_unused struct cmdline *cl,
10540 __rte_unused void *data)
10542 struct rte_eth_ntuple_filter filter;
10543 struct cmd_2tuple_filter_result *res = parsed_result;
10546 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
10548 printf("ntuple filter is not supported on port %u.\n",
10553 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
10555 filter.flags = RTE_2TUPLE_FLAGS;
10556 filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
10557 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
10558 filter.proto = res->protocol_value;
10559 filter.priority = res->priority_value;
10560 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
10561 printf("nonzero tcp_flags is only meaningful"
10562 " when protocol is TCP.\n");
10565 if (res->tcp_flags_value > RTE_NTUPLE_TCP_FLAGS_MASK) {
10566 printf("invalid TCP flags.\n");
10570 if (res->tcp_flags_value != 0) {
10571 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
10572 filter.tcp_flags = res->tcp_flags_value;
10575 /* need convert to big endian. */
10576 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
10577 filter.queue = res->queue_id;
10579 if (!strcmp(res->ops, "add"))
10580 ret = rte_eth_dev_filter_ctrl(res->port_id,
10581 RTE_ETH_FILTER_NTUPLE,
10582 RTE_ETH_FILTER_ADD,
10585 ret = rte_eth_dev_filter_ctrl(res->port_id,
10586 RTE_ETH_FILTER_NTUPLE,
10587 RTE_ETH_FILTER_DELETE,
10590 printf("2tuple filter programming error: (%s)\n",
10595 cmdline_parse_token_string_t cmd_2tuple_filter_filter =
10596 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10597 filter, "2tuple_filter");
10598 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
10599 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10601 cmdline_parse_token_string_t cmd_2tuple_filter_ops =
10602 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10604 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
10605 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10606 dst_port, "dst_port");
10607 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
10608 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10609 dst_port_value, UINT16);
10610 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
10611 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10612 protocol, "protocol");
10613 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
10614 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10615 protocol_value, UINT8);
10616 cmdline_parse_token_string_t cmd_2tuple_filter_mask =
10617 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10619 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value =
10620 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10622 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags =
10623 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10624 tcp_flags, "tcp_flags");
10625 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value =
10626 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10627 tcp_flags_value, UINT8);
10628 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
10629 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10630 priority, "priority");
10631 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
10632 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10633 priority_value, UINT8);
10634 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
10635 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10637 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
10638 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10641 cmdline_parse_inst_t cmd_2tuple_filter = {
10642 .f = cmd_2tuple_filter_parsed,
10644 .help_str = "2tuple_filter <port_id> add|del dst_port <value> protocol "
10645 "<value> mask <value> tcp_flags <value> priority <value> queue "
10646 "<queue_id>: Add a 2tuple filter",
10648 (void *)&cmd_2tuple_filter_filter,
10649 (void *)&cmd_2tuple_filter_port_id,
10650 (void *)&cmd_2tuple_filter_ops,
10651 (void *)&cmd_2tuple_filter_dst_port,
10652 (void *)&cmd_2tuple_filter_dst_port_value,
10653 (void *)&cmd_2tuple_filter_protocol,
10654 (void *)&cmd_2tuple_filter_protocol_value,
10655 (void *)&cmd_2tuple_filter_mask,
10656 (void *)&cmd_2tuple_filter_mask_value,
10657 (void *)&cmd_2tuple_filter_tcp_flags,
10658 (void *)&cmd_2tuple_filter_tcp_flags_value,
10659 (void *)&cmd_2tuple_filter_priority,
10660 (void *)&cmd_2tuple_filter_priority_value,
10661 (void *)&cmd_2tuple_filter_queue,
10662 (void *)&cmd_2tuple_filter_queue_id,
10667 /* *** ADD/REMOVE A 5tuple FILTER *** */
10668 struct cmd_5tuple_filter_result {
10669 cmdline_fixed_string_t filter;
10671 cmdline_fixed_string_t ops;
10672 cmdline_fixed_string_t dst_ip;
10673 cmdline_ipaddr_t dst_ip_value;
10674 cmdline_fixed_string_t src_ip;
10675 cmdline_ipaddr_t src_ip_value;
10676 cmdline_fixed_string_t dst_port;
10677 uint16_t dst_port_value;
10678 cmdline_fixed_string_t src_port;
10679 uint16_t src_port_value;
10680 cmdline_fixed_string_t protocol;
10681 uint8_t protocol_value;
10682 cmdline_fixed_string_t mask;
10683 uint8_t mask_value;
10684 cmdline_fixed_string_t tcp_flags;
10685 uint8_t tcp_flags_value;
10686 cmdline_fixed_string_t priority;
10687 uint8_t priority_value;
10688 cmdline_fixed_string_t queue;
10693 cmd_5tuple_filter_parsed(void *parsed_result,
10694 __rte_unused struct cmdline *cl,
10695 __rte_unused void *data)
10697 struct rte_eth_ntuple_filter filter;
10698 struct cmd_5tuple_filter_result *res = parsed_result;
10701 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
10703 printf("ntuple filter is not supported on port %u.\n",
10708 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
10710 filter.flags = RTE_5TUPLE_FLAGS;
10711 filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0;
10712 filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0;
10713 filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0;
10714 filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
10715 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
10716 filter.proto = res->protocol_value;
10717 filter.priority = res->priority_value;
10718 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
10719 printf("nonzero tcp_flags is only meaningful"
10720 " when protocol is TCP.\n");
10723 if (res->tcp_flags_value > RTE_NTUPLE_TCP_FLAGS_MASK) {
10724 printf("invalid TCP flags.\n");
10728 if (res->tcp_flags_value != 0) {
10729 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
10730 filter.tcp_flags = res->tcp_flags_value;
10733 if (res->dst_ip_value.family == AF_INET)
10734 /* no need to convert, already big endian. */
10735 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
10737 if (filter.dst_ip_mask == 0) {
10738 printf("can not support ipv6 involved compare.\n");
10744 if (res->src_ip_value.family == AF_INET)
10745 /* no need to convert, already big endian. */
10746 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
10748 if (filter.src_ip_mask == 0) {
10749 printf("can not support ipv6 involved compare.\n");
10754 /* need convert to big endian. */
10755 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
10756 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
10757 filter.queue = res->queue_id;
10759 if (!strcmp(res->ops, "add"))
10760 ret = rte_eth_dev_filter_ctrl(res->port_id,
10761 RTE_ETH_FILTER_NTUPLE,
10762 RTE_ETH_FILTER_ADD,
10765 ret = rte_eth_dev_filter_ctrl(res->port_id,
10766 RTE_ETH_FILTER_NTUPLE,
10767 RTE_ETH_FILTER_DELETE,
10770 printf("5tuple filter programming error: (%s)\n",
10774 cmdline_parse_token_string_t cmd_5tuple_filter_filter =
10775 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10776 filter, "5tuple_filter");
10777 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
10778 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10780 cmdline_parse_token_string_t cmd_5tuple_filter_ops =
10781 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10783 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
10784 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10786 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
10787 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
10789 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
10790 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10792 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
10793 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
10795 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
10796 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10797 dst_port, "dst_port");
10798 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
10799 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10800 dst_port_value, UINT16);
10801 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
10802 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10803 src_port, "src_port");
10804 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
10805 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10806 src_port_value, UINT16);
10807 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
10808 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10809 protocol, "protocol");
10810 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
10811 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10812 protocol_value, UINT8);
10813 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
10814 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10816 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
10817 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10819 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags =
10820 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10821 tcp_flags, "tcp_flags");
10822 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value =
10823 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10824 tcp_flags_value, UINT8);
10825 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
10826 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10827 priority, "priority");
10828 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
10829 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10830 priority_value, UINT8);
10831 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
10832 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10834 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
10835 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10838 cmdline_parse_inst_t cmd_5tuple_filter = {
10839 .f = cmd_5tuple_filter_parsed,
10841 .help_str = "5tuple_filter <port_id> add|del dst_ip <value> "
10842 "src_ip <value> dst_port <value> src_port <value> "
10843 "protocol <value> mask <value> tcp_flags <value> "
10844 "priority <value> queue <queue_id>: Add/Del a 5tuple filter",
10846 (void *)&cmd_5tuple_filter_filter,
10847 (void *)&cmd_5tuple_filter_port_id,
10848 (void *)&cmd_5tuple_filter_ops,
10849 (void *)&cmd_5tuple_filter_dst_ip,
10850 (void *)&cmd_5tuple_filter_dst_ip_value,
10851 (void *)&cmd_5tuple_filter_src_ip,
10852 (void *)&cmd_5tuple_filter_src_ip_value,
10853 (void *)&cmd_5tuple_filter_dst_port,
10854 (void *)&cmd_5tuple_filter_dst_port_value,
10855 (void *)&cmd_5tuple_filter_src_port,
10856 (void *)&cmd_5tuple_filter_src_port_value,
10857 (void *)&cmd_5tuple_filter_protocol,
10858 (void *)&cmd_5tuple_filter_protocol_value,
10859 (void *)&cmd_5tuple_filter_mask,
10860 (void *)&cmd_5tuple_filter_mask_value,
10861 (void *)&cmd_5tuple_filter_tcp_flags,
10862 (void *)&cmd_5tuple_filter_tcp_flags_value,
10863 (void *)&cmd_5tuple_filter_priority,
10864 (void *)&cmd_5tuple_filter_priority_value,
10865 (void *)&cmd_5tuple_filter_queue,
10866 (void *)&cmd_5tuple_filter_queue_id,
10871 /* *** Filters Control *** */
10873 /* *** deal with flow director filter *** */
10874 struct cmd_flow_director_result {
10875 cmdline_fixed_string_t flow_director_filter;
10877 cmdline_fixed_string_t mode;
10878 cmdline_fixed_string_t mode_value;
10879 cmdline_fixed_string_t ops;
10880 cmdline_fixed_string_t flow;
10881 cmdline_fixed_string_t flow_type;
10882 cmdline_fixed_string_t ether;
10883 uint16_t ether_type;
10884 cmdline_fixed_string_t src;
10885 cmdline_ipaddr_t ip_src;
10887 cmdline_fixed_string_t dst;
10888 cmdline_ipaddr_t ip_dst;
10890 cmdline_fixed_string_t verify_tag;
10891 uint32_t verify_tag_value;
10892 cmdline_fixed_string_t tos;
10894 cmdline_fixed_string_t proto;
10895 uint8_t proto_value;
10896 cmdline_fixed_string_t ttl;
10898 cmdline_fixed_string_t vlan;
10899 uint16_t vlan_value;
10900 cmdline_fixed_string_t flexbytes;
10901 cmdline_fixed_string_t flexbytes_value;
10902 cmdline_fixed_string_t pf_vf;
10903 cmdline_fixed_string_t drop;
10904 cmdline_fixed_string_t queue;
10906 cmdline_fixed_string_t fd_id;
10907 uint32_t fd_id_value;
10908 cmdline_fixed_string_t mac;
10909 struct rte_ether_addr mac_addr;
10910 cmdline_fixed_string_t tunnel;
10911 cmdline_fixed_string_t tunnel_type;
10912 cmdline_fixed_string_t tunnel_id;
10913 uint32_t tunnel_id_value;
10914 cmdline_fixed_string_t packet;
10919 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
10922 const char *p, *p0 = q_arg;
10924 unsigned long int_fld;
10925 char *str_fld[max_num];
10930 p = strchr(p0, '(');
10934 p0 = strchr(p, ')');
10939 if (size >= sizeof(s))
10942 snprintf(s, sizeof(s), "%.*s", size, p);
10943 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
10944 if (ret < 0 || ret > max_num)
10946 for (i = 0; i < ret; i++) {
10948 int_fld = strtoul(str_fld[i], &end, 0);
10949 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
10951 flexbytes[i] = (uint8_t)int_fld;
10957 str2flowtype(char *string)
10960 static const struct {
10963 } flowtype_str[] = {
10964 {"raw", RTE_ETH_FLOW_RAW},
10965 {"ipv4", RTE_ETH_FLOW_IPV4},
10966 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
10967 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
10968 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
10969 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
10970 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
10971 {"ipv6", RTE_ETH_FLOW_IPV6},
10972 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
10973 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
10974 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
10975 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
10976 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
10977 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
10980 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
10981 if (!strcmp(flowtype_str[i].str, string))
10982 return flowtype_str[i].type;
10985 if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64)
10986 return (uint16_t)atoi(string);
10988 return RTE_ETH_FLOW_UNKNOWN;
10991 static enum rte_eth_fdir_tunnel_type
10992 str2fdir_tunneltype(char *string)
10996 static const struct {
10998 enum rte_eth_fdir_tunnel_type type;
10999 } tunneltype_str[] = {
11000 {"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE},
11001 {"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN},
11004 for (i = 0; i < RTE_DIM(tunneltype_str); i++) {
11005 if (!strcmp(tunneltype_str[i].str, string))
11006 return tunneltype_str[i].type;
11008 return RTE_FDIR_TUNNEL_TYPE_UNKNOWN;
11011 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
11013 if ((ip_addr).family == AF_INET) \
11014 (ip) = (ip_addr).addr.ipv4.s_addr; \
11016 printf("invalid parameter.\n"); \
11021 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
11023 if ((ip_addr).family == AF_INET6) \
11024 rte_memcpy(&(ip), \
11025 &((ip_addr).addr.ipv6), \
11026 sizeof(struct in6_addr)); \
11028 printf("invalid parameter.\n"); \
11034 cmd_flow_director_filter_parsed(void *parsed_result,
11035 __rte_unused struct cmdline *cl,
11036 __rte_unused void *data)
11038 struct cmd_flow_director_result *res = parsed_result;
11039 struct rte_eth_fdir_filter entry;
11040 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
11042 unsigned long vf_id;
11045 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
11047 printf("flow director is not supported on port %u.\n",
11051 memset(flexbytes, 0, sizeof(flexbytes));
11052 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
11054 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
11055 if (strcmp(res->mode_value, "MAC-VLAN")) {
11056 printf("Please set mode to MAC-VLAN.\n");
11059 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
11060 if (strcmp(res->mode_value, "Tunnel")) {
11061 printf("Please set mode to Tunnel.\n");
11065 if (!strcmp(res->mode_value, "raw")) {
11066 #ifdef RTE_NET_I40E
11067 struct rte_pmd_i40e_flow_type_mapping
11068 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
11069 struct rte_pmd_i40e_pkt_template_conf conf;
11070 uint16_t flow_type = str2flowtype(res->flow_type);
11071 uint16_t i, port = res->port_id;
11074 memset(&conf, 0, sizeof(conf));
11076 if (flow_type == RTE_ETH_FLOW_UNKNOWN) {
11077 printf("Invalid flow type specified.\n");
11080 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id,
11084 if (mapping[flow_type].pctype == 0ULL) {
11085 printf("Invalid flow type specified.\n");
11088 for (i = 0; i < RTE_PMD_I40E_PCTYPE_MAX; i++) {
11089 if (mapping[flow_type].pctype & (1ULL << i)) {
11090 conf.input.pctype = i;
11095 conf.input.packet = open_file(res->filepath,
11096 &conf.input.length);
11097 if (!conf.input.packet)
11099 if (!strcmp(res->drop, "drop"))
11100 conf.action.behavior =
11101 RTE_PMD_I40E_PKT_TEMPLATE_REJECT;
11103 conf.action.behavior =
11104 RTE_PMD_I40E_PKT_TEMPLATE_ACCEPT;
11105 conf.action.report_status =
11106 RTE_PMD_I40E_PKT_TEMPLATE_REPORT_ID;
11107 conf.action.rx_queue = res->queue_id;
11108 conf.soft_id = res->fd_id_value;
11109 add = strcmp(res->ops, "del") ? 1 : 0;
11110 ret = rte_pmd_i40e_flow_add_del_packet_template(port,
11114 printf("flow director config error: (%s)\n",
11116 close_file(conf.input.packet);
11119 } else if (strcmp(res->mode_value, "IP")) {
11120 printf("Please set mode to IP or raw.\n");
11123 entry.input.flow_type = str2flowtype(res->flow_type);
11126 ret = parse_flexbytes(res->flexbytes_value,
11128 RTE_ETH_FDIR_MAX_FLEXLEN);
11130 printf("error: Cannot parse flexbytes input.\n");
11134 switch (entry.input.flow_type) {
11135 case RTE_ETH_FLOW_FRAG_IPV4:
11136 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
11137 entry.input.flow.ip4_flow.proto = res->proto_value;
11139 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
11140 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
11141 IPV4_ADDR_TO_UINT(res->ip_dst,
11142 entry.input.flow.ip4_flow.dst_ip);
11143 IPV4_ADDR_TO_UINT(res->ip_src,
11144 entry.input.flow.ip4_flow.src_ip);
11145 entry.input.flow.ip4_flow.tos = res->tos_value;
11146 entry.input.flow.ip4_flow.ttl = res->ttl_value;
11147 /* need convert to big endian. */
11148 entry.input.flow.udp4_flow.dst_port =
11149 rte_cpu_to_be_16(res->port_dst);
11150 entry.input.flow.udp4_flow.src_port =
11151 rte_cpu_to_be_16(res->port_src);
11153 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
11154 IPV4_ADDR_TO_UINT(res->ip_dst,
11155 entry.input.flow.sctp4_flow.ip.dst_ip);
11156 IPV4_ADDR_TO_UINT(res->ip_src,
11157 entry.input.flow.sctp4_flow.ip.src_ip);
11158 entry.input.flow.ip4_flow.tos = res->tos_value;
11159 entry.input.flow.ip4_flow.ttl = res->ttl_value;
11160 /* need convert to big endian. */
11161 entry.input.flow.sctp4_flow.dst_port =
11162 rte_cpu_to_be_16(res->port_dst);
11163 entry.input.flow.sctp4_flow.src_port =
11164 rte_cpu_to_be_16(res->port_src);
11165 entry.input.flow.sctp4_flow.verify_tag =
11166 rte_cpu_to_be_32(res->verify_tag_value);
11168 case RTE_ETH_FLOW_FRAG_IPV6:
11169 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
11170 entry.input.flow.ipv6_flow.proto = res->proto_value;
11172 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
11173 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
11174 IPV6_ADDR_TO_ARRAY(res->ip_dst,
11175 entry.input.flow.ipv6_flow.dst_ip);
11176 IPV6_ADDR_TO_ARRAY(res->ip_src,
11177 entry.input.flow.ipv6_flow.src_ip);
11178 entry.input.flow.ipv6_flow.tc = res->tos_value;
11179 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
11180 /* need convert to big endian. */
11181 entry.input.flow.udp6_flow.dst_port =
11182 rte_cpu_to_be_16(res->port_dst);
11183 entry.input.flow.udp6_flow.src_port =
11184 rte_cpu_to_be_16(res->port_src);
11186 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
11187 IPV6_ADDR_TO_ARRAY(res->ip_dst,
11188 entry.input.flow.sctp6_flow.ip.dst_ip);
11189 IPV6_ADDR_TO_ARRAY(res->ip_src,
11190 entry.input.flow.sctp6_flow.ip.src_ip);
11191 entry.input.flow.ipv6_flow.tc = res->tos_value;
11192 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
11193 /* need convert to big endian. */
11194 entry.input.flow.sctp6_flow.dst_port =
11195 rte_cpu_to_be_16(res->port_dst);
11196 entry.input.flow.sctp6_flow.src_port =
11197 rte_cpu_to_be_16(res->port_src);
11198 entry.input.flow.sctp6_flow.verify_tag =
11199 rte_cpu_to_be_32(res->verify_tag_value);
11201 case RTE_ETH_FLOW_L2_PAYLOAD:
11202 entry.input.flow.l2_flow.ether_type =
11203 rte_cpu_to_be_16(res->ether_type);
11209 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN)
11210 rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr,
11212 sizeof(struct rte_ether_addr));
11214 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
11215 rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr,
11217 sizeof(struct rte_ether_addr));
11218 entry.input.flow.tunnel_flow.tunnel_type =
11219 str2fdir_tunneltype(res->tunnel_type);
11220 entry.input.flow.tunnel_flow.tunnel_id =
11221 rte_cpu_to_be_32(res->tunnel_id_value);
11224 rte_memcpy(entry.input.flow_ext.flexbytes,
11226 RTE_ETH_FDIR_MAX_FLEXLEN);
11228 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
11230 entry.action.flex_off = 0; /*use 0 by default */
11231 if (!strcmp(res->drop, "drop"))
11232 entry.action.behavior = RTE_ETH_FDIR_REJECT;
11234 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
11236 if (fdir_conf.mode != RTE_FDIR_MODE_PERFECT_MAC_VLAN &&
11237 fdir_conf.mode != RTE_FDIR_MODE_PERFECT_TUNNEL) {
11238 if (!strcmp(res->pf_vf, "pf"))
11239 entry.input.flow_ext.is_vf = 0;
11240 else if (!strncmp(res->pf_vf, "vf", 2)) {
11241 struct rte_eth_dev_info dev_info;
11243 ret = eth_dev_info_get_print_err(res->port_id,
11249 vf_id = strtoul(res->pf_vf + 2, &end, 10);
11250 if (errno != 0 || *end != '\0' ||
11251 vf_id >= dev_info.max_vfs) {
11252 printf("invalid parameter %s.\n", res->pf_vf);
11255 entry.input.flow_ext.is_vf = 1;
11256 entry.input.flow_ext.dst_id = (uint16_t)vf_id;
11258 printf("invalid parameter %s.\n", res->pf_vf);
11263 /* set to report FD ID by default */
11264 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
11265 entry.action.rx_queue = res->queue_id;
11266 entry.soft_id = res->fd_id_value;
11267 if (!strcmp(res->ops, "add"))
11268 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11269 RTE_ETH_FILTER_ADD, &entry);
11270 else if (!strcmp(res->ops, "del"))
11271 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11272 RTE_ETH_FILTER_DELETE, &entry);
11274 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11275 RTE_ETH_FILTER_UPDATE, &entry);
11277 printf("flow director programming error: (%s)\n",
11281 cmdline_parse_token_string_t cmd_flow_director_filter =
11282 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11283 flow_director_filter, "flow_director_filter");
11284 cmdline_parse_token_num_t cmd_flow_director_port_id =
11285 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11287 cmdline_parse_token_string_t cmd_flow_director_ops =
11288 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11289 ops, "add#del#update");
11290 cmdline_parse_token_string_t cmd_flow_director_flow =
11291 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11293 cmdline_parse_token_string_t cmd_flow_director_flow_type =
11294 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11296 cmdline_parse_token_string_t cmd_flow_director_ether =
11297 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11299 cmdline_parse_token_num_t cmd_flow_director_ether_type =
11300 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11301 ether_type, UINT16);
11302 cmdline_parse_token_string_t cmd_flow_director_src =
11303 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11305 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
11306 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
11308 cmdline_parse_token_num_t cmd_flow_director_port_src =
11309 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11311 cmdline_parse_token_string_t cmd_flow_director_dst =
11312 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11314 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
11315 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
11317 cmdline_parse_token_num_t cmd_flow_director_port_dst =
11318 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11320 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
11321 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11322 verify_tag, "verify_tag");
11323 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
11324 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11325 verify_tag_value, UINT32);
11326 cmdline_parse_token_string_t cmd_flow_director_tos =
11327 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11329 cmdline_parse_token_num_t cmd_flow_director_tos_value =
11330 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11332 cmdline_parse_token_string_t cmd_flow_director_proto =
11333 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11335 cmdline_parse_token_num_t cmd_flow_director_proto_value =
11336 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11337 proto_value, UINT8);
11338 cmdline_parse_token_string_t cmd_flow_director_ttl =
11339 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11341 cmdline_parse_token_num_t cmd_flow_director_ttl_value =
11342 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11344 cmdline_parse_token_string_t cmd_flow_director_vlan =
11345 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11347 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
11348 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11349 vlan_value, UINT16);
11350 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
11351 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11352 flexbytes, "flexbytes");
11353 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
11354 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11355 flexbytes_value, NULL);
11356 cmdline_parse_token_string_t cmd_flow_director_drop =
11357 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11359 cmdline_parse_token_string_t cmd_flow_director_pf_vf =
11360 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11362 cmdline_parse_token_string_t cmd_flow_director_queue =
11363 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11365 cmdline_parse_token_num_t cmd_flow_director_queue_id =
11366 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11368 cmdline_parse_token_string_t cmd_flow_director_fd_id =
11369 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11371 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
11372 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11373 fd_id_value, UINT32);
11375 cmdline_parse_token_string_t cmd_flow_director_mode =
11376 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11378 cmdline_parse_token_string_t cmd_flow_director_mode_ip =
11379 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11381 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan =
11382 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11383 mode_value, "MAC-VLAN");
11384 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel =
11385 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11386 mode_value, "Tunnel");
11387 cmdline_parse_token_string_t cmd_flow_director_mode_raw =
11388 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11389 mode_value, "raw");
11390 cmdline_parse_token_string_t cmd_flow_director_mac =
11391 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11393 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr =
11394 TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result,
11396 cmdline_parse_token_string_t cmd_flow_director_tunnel =
11397 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11399 cmdline_parse_token_string_t cmd_flow_director_tunnel_type =
11400 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11401 tunnel_type, "NVGRE#VxLAN");
11402 cmdline_parse_token_string_t cmd_flow_director_tunnel_id =
11403 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11404 tunnel_id, "tunnel-id");
11405 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value =
11406 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11407 tunnel_id_value, UINT32);
11408 cmdline_parse_token_string_t cmd_flow_director_packet =
11409 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11411 cmdline_parse_token_string_t cmd_flow_director_filepath =
11412 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11415 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
11416 .f = cmd_flow_director_filter_parsed,
11418 .help_str = "flow_director_filter <port_id> mode IP add|del|update flow"
11419 " ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
11420 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
11421 "l2_payload src <src_ip> dst <dst_ip> tos <tos_value> "
11422 "proto <proto_value> ttl <ttl_value> vlan <vlan_value> "
11423 "flexbytes <flexbyte_values> drop|fw <pf_vf> queue <queue_id> "
11424 "fd_id <fd_id_value>: "
11425 "Add or delete an ip flow director entry on NIC",
11427 (void *)&cmd_flow_director_filter,
11428 (void *)&cmd_flow_director_port_id,
11429 (void *)&cmd_flow_director_mode,
11430 (void *)&cmd_flow_director_mode_ip,
11431 (void *)&cmd_flow_director_ops,
11432 (void *)&cmd_flow_director_flow,
11433 (void *)&cmd_flow_director_flow_type,
11434 (void *)&cmd_flow_director_src,
11435 (void *)&cmd_flow_director_ip_src,
11436 (void *)&cmd_flow_director_dst,
11437 (void *)&cmd_flow_director_ip_dst,
11438 (void *)&cmd_flow_director_tos,
11439 (void *)&cmd_flow_director_tos_value,
11440 (void *)&cmd_flow_director_proto,
11441 (void *)&cmd_flow_director_proto_value,
11442 (void *)&cmd_flow_director_ttl,
11443 (void *)&cmd_flow_director_ttl_value,
11444 (void *)&cmd_flow_director_vlan,
11445 (void *)&cmd_flow_director_vlan_value,
11446 (void *)&cmd_flow_director_flexbytes,
11447 (void *)&cmd_flow_director_flexbytes_value,
11448 (void *)&cmd_flow_director_drop,
11449 (void *)&cmd_flow_director_pf_vf,
11450 (void *)&cmd_flow_director_queue,
11451 (void *)&cmd_flow_director_queue_id,
11452 (void *)&cmd_flow_director_fd_id,
11453 (void *)&cmd_flow_director_fd_id_value,
11458 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
11459 .f = cmd_flow_director_filter_parsed,
11461 .help_str = "flow_director_filter ... : Add or delete an udp/tcp flow "
11462 "director entry on NIC",
11464 (void *)&cmd_flow_director_filter,
11465 (void *)&cmd_flow_director_port_id,
11466 (void *)&cmd_flow_director_mode,
11467 (void *)&cmd_flow_director_mode_ip,
11468 (void *)&cmd_flow_director_ops,
11469 (void *)&cmd_flow_director_flow,
11470 (void *)&cmd_flow_director_flow_type,
11471 (void *)&cmd_flow_director_src,
11472 (void *)&cmd_flow_director_ip_src,
11473 (void *)&cmd_flow_director_port_src,
11474 (void *)&cmd_flow_director_dst,
11475 (void *)&cmd_flow_director_ip_dst,
11476 (void *)&cmd_flow_director_port_dst,
11477 (void *)&cmd_flow_director_tos,
11478 (void *)&cmd_flow_director_tos_value,
11479 (void *)&cmd_flow_director_ttl,
11480 (void *)&cmd_flow_director_ttl_value,
11481 (void *)&cmd_flow_director_vlan,
11482 (void *)&cmd_flow_director_vlan_value,
11483 (void *)&cmd_flow_director_flexbytes,
11484 (void *)&cmd_flow_director_flexbytes_value,
11485 (void *)&cmd_flow_director_drop,
11486 (void *)&cmd_flow_director_pf_vf,
11487 (void *)&cmd_flow_director_queue,
11488 (void *)&cmd_flow_director_queue_id,
11489 (void *)&cmd_flow_director_fd_id,
11490 (void *)&cmd_flow_director_fd_id_value,
11495 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
11496 .f = cmd_flow_director_filter_parsed,
11498 .help_str = "flow_director_filter ... : Add or delete a sctp flow "
11499 "director entry on NIC",
11501 (void *)&cmd_flow_director_filter,
11502 (void *)&cmd_flow_director_port_id,
11503 (void *)&cmd_flow_director_mode,
11504 (void *)&cmd_flow_director_mode_ip,
11505 (void *)&cmd_flow_director_ops,
11506 (void *)&cmd_flow_director_flow,
11507 (void *)&cmd_flow_director_flow_type,
11508 (void *)&cmd_flow_director_src,
11509 (void *)&cmd_flow_director_ip_src,
11510 (void *)&cmd_flow_director_port_src,
11511 (void *)&cmd_flow_director_dst,
11512 (void *)&cmd_flow_director_ip_dst,
11513 (void *)&cmd_flow_director_port_dst,
11514 (void *)&cmd_flow_director_verify_tag,
11515 (void *)&cmd_flow_director_verify_tag_value,
11516 (void *)&cmd_flow_director_tos,
11517 (void *)&cmd_flow_director_tos_value,
11518 (void *)&cmd_flow_director_ttl,
11519 (void *)&cmd_flow_director_ttl_value,
11520 (void *)&cmd_flow_director_vlan,
11521 (void *)&cmd_flow_director_vlan_value,
11522 (void *)&cmd_flow_director_flexbytes,
11523 (void *)&cmd_flow_director_flexbytes_value,
11524 (void *)&cmd_flow_director_drop,
11525 (void *)&cmd_flow_director_pf_vf,
11526 (void *)&cmd_flow_director_queue,
11527 (void *)&cmd_flow_director_queue_id,
11528 (void *)&cmd_flow_director_fd_id,
11529 (void *)&cmd_flow_director_fd_id_value,
11534 cmdline_parse_inst_t cmd_add_del_l2_flow_director = {
11535 .f = cmd_flow_director_filter_parsed,
11537 .help_str = "flow_director_filter ... : Add or delete a L2 flow "
11538 "director entry on NIC",
11540 (void *)&cmd_flow_director_filter,
11541 (void *)&cmd_flow_director_port_id,
11542 (void *)&cmd_flow_director_mode,
11543 (void *)&cmd_flow_director_mode_ip,
11544 (void *)&cmd_flow_director_ops,
11545 (void *)&cmd_flow_director_flow,
11546 (void *)&cmd_flow_director_flow_type,
11547 (void *)&cmd_flow_director_ether,
11548 (void *)&cmd_flow_director_ether_type,
11549 (void *)&cmd_flow_director_flexbytes,
11550 (void *)&cmd_flow_director_flexbytes_value,
11551 (void *)&cmd_flow_director_drop,
11552 (void *)&cmd_flow_director_pf_vf,
11553 (void *)&cmd_flow_director_queue,
11554 (void *)&cmd_flow_director_queue_id,
11555 (void *)&cmd_flow_director_fd_id,
11556 (void *)&cmd_flow_director_fd_id_value,
11561 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = {
11562 .f = cmd_flow_director_filter_parsed,
11564 .help_str = "flow_director_filter ... : Add or delete a MAC VLAN flow "
11565 "director entry on NIC",
11567 (void *)&cmd_flow_director_filter,
11568 (void *)&cmd_flow_director_port_id,
11569 (void *)&cmd_flow_director_mode,
11570 (void *)&cmd_flow_director_mode_mac_vlan,
11571 (void *)&cmd_flow_director_ops,
11572 (void *)&cmd_flow_director_mac,
11573 (void *)&cmd_flow_director_mac_addr,
11574 (void *)&cmd_flow_director_vlan,
11575 (void *)&cmd_flow_director_vlan_value,
11576 (void *)&cmd_flow_director_flexbytes,
11577 (void *)&cmd_flow_director_flexbytes_value,
11578 (void *)&cmd_flow_director_drop,
11579 (void *)&cmd_flow_director_queue,
11580 (void *)&cmd_flow_director_queue_id,
11581 (void *)&cmd_flow_director_fd_id,
11582 (void *)&cmd_flow_director_fd_id_value,
11587 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = {
11588 .f = cmd_flow_director_filter_parsed,
11590 .help_str = "flow_director_filter ... : Add or delete a tunnel flow "
11591 "director entry on NIC",
11593 (void *)&cmd_flow_director_filter,
11594 (void *)&cmd_flow_director_port_id,
11595 (void *)&cmd_flow_director_mode,
11596 (void *)&cmd_flow_director_mode_tunnel,
11597 (void *)&cmd_flow_director_ops,
11598 (void *)&cmd_flow_director_mac,
11599 (void *)&cmd_flow_director_mac_addr,
11600 (void *)&cmd_flow_director_vlan,
11601 (void *)&cmd_flow_director_vlan_value,
11602 (void *)&cmd_flow_director_tunnel,
11603 (void *)&cmd_flow_director_tunnel_type,
11604 (void *)&cmd_flow_director_tunnel_id,
11605 (void *)&cmd_flow_director_tunnel_id_value,
11606 (void *)&cmd_flow_director_flexbytes,
11607 (void *)&cmd_flow_director_flexbytes_value,
11608 (void *)&cmd_flow_director_drop,
11609 (void *)&cmd_flow_director_queue,
11610 (void *)&cmd_flow_director_queue_id,
11611 (void *)&cmd_flow_director_fd_id,
11612 (void *)&cmd_flow_director_fd_id_value,
11617 cmdline_parse_inst_t cmd_add_del_raw_flow_director = {
11618 .f = cmd_flow_director_filter_parsed,
11620 .help_str = "flow_director_filter ... : Add or delete a raw flow "
11621 "director entry on NIC",
11623 (void *)&cmd_flow_director_filter,
11624 (void *)&cmd_flow_director_port_id,
11625 (void *)&cmd_flow_director_mode,
11626 (void *)&cmd_flow_director_mode_raw,
11627 (void *)&cmd_flow_director_ops,
11628 (void *)&cmd_flow_director_flow,
11629 (void *)&cmd_flow_director_flow_type,
11630 (void *)&cmd_flow_director_drop,
11631 (void *)&cmd_flow_director_queue,
11632 (void *)&cmd_flow_director_queue_id,
11633 (void *)&cmd_flow_director_fd_id,
11634 (void *)&cmd_flow_director_fd_id_value,
11635 (void *)&cmd_flow_director_packet,
11636 (void *)&cmd_flow_director_filepath,
11641 struct cmd_flush_flow_director_result {
11642 cmdline_fixed_string_t flush_flow_director;
11646 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
11647 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
11648 flush_flow_director, "flush_flow_director");
11649 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
11650 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
11654 cmd_flush_flow_director_parsed(void *parsed_result,
11655 __rte_unused struct cmdline *cl,
11656 __rte_unused void *data)
11658 struct cmd_flow_director_result *res = parsed_result;
11661 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
11663 printf("flow director is not supported on port %u.\n",
11668 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11669 RTE_ETH_FILTER_FLUSH, NULL);
11671 printf("flow director table flushing error: (%s)\n",
11675 cmdline_parse_inst_t cmd_flush_flow_director = {
11676 .f = cmd_flush_flow_director_parsed,
11678 .help_str = "flush_flow_director <port_id>: "
11679 "Flush all flow director entries of a device on NIC",
11681 (void *)&cmd_flush_flow_director_flush,
11682 (void *)&cmd_flush_flow_director_port_id,
11687 /* *** deal with flow director mask *** */
11688 struct cmd_flow_director_mask_result {
11689 cmdline_fixed_string_t flow_director_mask;
11691 cmdline_fixed_string_t mode;
11692 cmdline_fixed_string_t mode_value;
11693 cmdline_fixed_string_t vlan;
11694 uint16_t vlan_mask;
11695 cmdline_fixed_string_t src_mask;
11696 cmdline_ipaddr_t ipv4_src;
11697 cmdline_ipaddr_t ipv6_src;
11699 cmdline_fixed_string_t dst_mask;
11700 cmdline_ipaddr_t ipv4_dst;
11701 cmdline_ipaddr_t ipv6_dst;
11703 cmdline_fixed_string_t mac;
11704 uint8_t mac_addr_byte_mask;
11705 cmdline_fixed_string_t tunnel_id;
11706 uint32_t tunnel_id_mask;
11707 cmdline_fixed_string_t tunnel_type;
11708 uint8_t tunnel_type_mask;
11712 cmd_flow_director_mask_parsed(void *parsed_result,
11713 __rte_unused struct cmdline *cl,
11714 __rte_unused void *data)
11716 struct cmd_flow_director_mask_result *res = parsed_result;
11717 struct rte_eth_fdir_masks *mask;
11718 struct rte_port *port;
11720 port = &ports[res->port_id];
11721 /** Check if the port is not started **/
11722 if (port->port_status != RTE_PORT_STOPPED) {
11723 printf("Please stop port %d first\n", res->port_id);
11727 mask = &port->dev_conf.fdir_conf.mask;
11729 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
11730 if (strcmp(res->mode_value, "MAC-VLAN")) {
11731 printf("Please set mode to MAC-VLAN.\n");
11735 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11736 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
11737 if (strcmp(res->mode_value, "Tunnel")) {
11738 printf("Please set mode to Tunnel.\n");
11742 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11743 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
11744 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
11745 mask->tunnel_type_mask = res->tunnel_type_mask;
11747 if (strcmp(res->mode_value, "IP")) {
11748 printf("Please set mode to IP.\n");
11752 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11753 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
11754 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
11755 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
11756 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
11757 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
11758 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
11761 cmd_reconfig_device_queue(res->port_id, 1, 1);
11764 cmdline_parse_token_string_t cmd_flow_director_mask =
11765 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11766 flow_director_mask, "flow_director_mask");
11767 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
11768 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11770 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
11771 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11773 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
11774 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11775 vlan_mask, UINT16);
11776 cmdline_parse_token_string_t cmd_flow_director_mask_src =
11777 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11778 src_mask, "src_mask");
11779 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
11780 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11782 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
11783 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11785 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
11786 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11788 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
11789 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11790 dst_mask, "dst_mask");
11791 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
11792 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11794 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
11795 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11797 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
11798 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11801 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
11802 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11804 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
11805 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11807 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
11808 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11809 mode_value, "MAC-VLAN");
11810 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
11811 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11812 mode_value, "Tunnel");
11813 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
11814 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11816 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
11817 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11818 mac_addr_byte_mask, UINT8);
11819 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
11820 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11821 tunnel_type, "tunnel-type");
11822 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
11823 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11824 tunnel_type_mask, UINT8);
11825 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
11826 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11827 tunnel_id, "tunnel-id");
11828 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
11829 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11830 tunnel_id_mask, UINT32);
11832 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
11833 .f = cmd_flow_director_mask_parsed,
11835 .help_str = "flow_director_mask ... : "
11836 "Set IP mode flow director's mask on NIC",
11838 (void *)&cmd_flow_director_mask,
11839 (void *)&cmd_flow_director_mask_port_id,
11840 (void *)&cmd_flow_director_mask_mode,
11841 (void *)&cmd_flow_director_mask_mode_ip,
11842 (void *)&cmd_flow_director_mask_vlan,
11843 (void *)&cmd_flow_director_mask_vlan_value,
11844 (void *)&cmd_flow_director_mask_src,
11845 (void *)&cmd_flow_director_mask_ipv4_src,
11846 (void *)&cmd_flow_director_mask_ipv6_src,
11847 (void *)&cmd_flow_director_mask_port_src,
11848 (void *)&cmd_flow_director_mask_dst,
11849 (void *)&cmd_flow_director_mask_ipv4_dst,
11850 (void *)&cmd_flow_director_mask_ipv6_dst,
11851 (void *)&cmd_flow_director_mask_port_dst,
11856 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
11857 .f = cmd_flow_director_mask_parsed,
11859 .help_str = "flow_director_mask ... : Set MAC VLAN mode "
11860 "flow director's mask on NIC",
11862 (void *)&cmd_flow_director_mask,
11863 (void *)&cmd_flow_director_mask_port_id,
11864 (void *)&cmd_flow_director_mask_mode,
11865 (void *)&cmd_flow_director_mask_mode_mac_vlan,
11866 (void *)&cmd_flow_director_mask_vlan,
11867 (void *)&cmd_flow_director_mask_vlan_value,
11872 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
11873 .f = cmd_flow_director_mask_parsed,
11875 .help_str = "flow_director_mask ... : Set tunnel mode "
11876 "flow director's mask on NIC",
11878 (void *)&cmd_flow_director_mask,
11879 (void *)&cmd_flow_director_mask_port_id,
11880 (void *)&cmd_flow_director_mask_mode,
11881 (void *)&cmd_flow_director_mask_mode_tunnel,
11882 (void *)&cmd_flow_director_mask_vlan,
11883 (void *)&cmd_flow_director_mask_vlan_value,
11884 (void *)&cmd_flow_director_mask_mac,
11885 (void *)&cmd_flow_director_mask_mac_value,
11886 (void *)&cmd_flow_director_mask_tunnel_type,
11887 (void *)&cmd_flow_director_mask_tunnel_type_value,
11888 (void *)&cmd_flow_director_mask_tunnel_id,
11889 (void *)&cmd_flow_director_mask_tunnel_id_value,
11894 /* *** deal with flow director mask on flexible payload *** */
11895 struct cmd_flow_director_flex_mask_result {
11896 cmdline_fixed_string_t flow_director_flexmask;
11898 cmdline_fixed_string_t flow;
11899 cmdline_fixed_string_t flow_type;
11900 cmdline_fixed_string_t mask;
11904 cmd_flow_director_flex_mask_parsed(void *parsed_result,
11905 __rte_unused struct cmdline *cl,
11906 __rte_unused void *data)
11908 struct cmd_flow_director_flex_mask_result *res = parsed_result;
11909 struct rte_eth_fdir_info fdir_info;
11910 struct rte_eth_fdir_flex_mask flex_mask;
11911 struct rte_port *port;
11912 uint64_t flow_type_mask;
11916 port = &ports[res->port_id];
11917 /** Check if the port is not started **/
11918 if (port->port_status != RTE_PORT_STOPPED) {
11919 printf("Please stop port %d first\n", res->port_id);
11923 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
11924 ret = parse_flexbytes(res->mask,
11926 RTE_ETH_FDIR_MAX_FLEXLEN);
11928 printf("error: Cannot parse mask input.\n");
11932 memset(&fdir_info, 0, sizeof(fdir_info));
11933 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11934 RTE_ETH_FILTER_INFO, &fdir_info);
11936 printf("Cannot get FDir filter info\n");
11940 if (!strcmp(res->flow_type, "none")) {
11941 /* means don't specify the flow type */
11942 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN;
11943 for (i = 0; i < RTE_ETH_FLOW_MAX; i++)
11944 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i],
11945 0, sizeof(struct rte_eth_fdir_flex_mask));
11946 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1;
11947 rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0],
11949 sizeof(struct rte_eth_fdir_flex_mask));
11950 cmd_reconfig_device_queue(res->port_id, 1, 1);
11953 flow_type_mask = fdir_info.flow_types_mask[0];
11954 if (!strcmp(res->flow_type, "all")) {
11955 if (!flow_type_mask) {
11956 printf("No flow type supported\n");
11959 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
11960 if (flow_type_mask & (1ULL << i)) {
11961 flex_mask.flow_type = i;
11962 fdir_set_flex_mask(res->port_id, &flex_mask);
11965 cmd_reconfig_device_queue(res->port_id, 1, 1);
11968 flex_mask.flow_type = str2flowtype(res->flow_type);
11969 if (!(flow_type_mask & (1ULL << flex_mask.flow_type))) {
11970 printf("Flow type %s not supported on port %d\n",
11971 res->flow_type, res->port_id);
11974 fdir_set_flex_mask(res->port_id, &flex_mask);
11975 cmd_reconfig_device_queue(res->port_id, 1, 1);
11978 cmdline_parse_token_string_t cmd_flow_director_flexmask =
11979 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11980 flow_director_flexmask,
11981 "flow_director_flex_mask");
11982 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
11983 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11985 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
11986 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11988 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
11989 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11990 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
11991 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all");
11992 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
11993 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11996 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
11997 .f = cmd_flow_director_flex_mask_parsed,
11999 .help_str = "flow_director_flex_mask ... : "
12000 "Set flow director's flex mask on NIC",
12002 (void *)&cmd_flow_director_flexmask,
12003 (void *)&cmd_flow_director_flexmask_port_id,
12004 (void *)&cmd_flow_director_flexmask_flow,
12005 (void *)&cmd_flow_director_flexmask_flow_type,
12006 (void *)&cmd_flow_director_flexmask_mask,
12011 /* *** deal with flow director flexible payload configuration *** */
12012 struct cmd_flow_director_flexpayload_result {
12013 cmdline_fixed_string_t flow_director_flexpayload;
12015 cmdline_fixed_string_t payload_layer;
12016 cmdline_fixed_string_t payload_cfg;
12020 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
12023 const char *p, *p0 = q_arg;
12025 unsigned long int_fld;
12026 char *str_fld[max_num];
12031 p = strchr(p0, '(');
12035 p0 = strchr(p, ')');
12040 if (size >= sizeof(s))
12043 snprintf(s, sizeof(s), "%.*s", size, p);
12044 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
12045 if (ret < 0 || ret > max_num)
12047 for (i = 0; i < ret; i++) {
12049 int_fld = strtoul(str_fld[i], &end, 0);
12050 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
12052 offsets[i] = (uint16_t)int_fld;
12058 cmd_flow_director_flxpld_parsed(void *parsed_result,
12059 __rte_unused struct cmdline *cl,
12060 __rte_unused void *data)
12062 struct cmd_flow_director_flexpayload_result *res = parsed_result;
12063 struct rte_eth_flex_payload_cfg flex_cfg;
12064 struct rte_port *port;
12067 port = &ports[res->port_id];
12068 /** Check if the port is not started **/
12069 if (port->port_status != RTE_PORT_STOPPED) {
12070 printf("Please stop port %d first\n", res->port_id);
12074 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
12076 if (!strcmp(res->payload_layer, "raw"))
12077 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
12078 else if (!strcmp(res->payload_layer, "l2"))
12079 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
12080 else if (!strcmp(res->payload_layer, "l3"))
12081 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
12082 else if (!strcmp(res->payload_layer, "l4"))
12083 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
12085 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
12086 RTE_ETH_FDIR_MAX_FLEXLEN);
12088 printf("error: Cannot parse flex payload input.\n");
12092 fdir_set_flex_payload(res->port_id, &flex_cfg);
12093 cmd_reconfig_device_queue(res->port_id, 1, 1);
12096 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
12097 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
12098 flow_director_flexpayload,
12099 "flow_director_flex_payload");
12100 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
12101 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
12103 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
12104 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
12105 payload_layer, "raw#l2#l3#l4");
12106 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
12107 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
12108 payload_cfg, NULL);
12110 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
12111 .f = cmd_flow_director_flxpld_parsed,
12113 .help_str = "flow_director_flexpayload ... : "
12114 "Set flow director's flex payload on NIC",
12116 (void *)&cmd_flow_director_flexpayload,
12117 (void *)&cmd_flow_director_flexpayload_port_id,
12118 (void *)&cmd_flow_director_flexpayload_payload_layer,
12119 (void *)&cmd_flow_director_flexpayload_payload_cfg,
12124 /* Generic flow interface command. */
12125 extern cmdline_parse_inst_t cmd_flow;
12127 /* *** Classification Filters Control *** */
12128 /* *** Get symmetric hash enable per port *** */
12129 struct cmd_get_sym_hash_ena_per_port_result {
12130 cmdline_fixed_string_t get_sym_hash_ena_per_port;
12135 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
12136 __rte_unused struct cmdline *cl,
12137 __rte_unused void *data)
12139 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
12140 struct rte_eth_hash_filter_info info;
12143 if (rte_eth_dev_filter_supported(res->port_id,
12144 RTE_ETH_FILTER_HASH) < 0) {
12145 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
12150 memset(&info, 0, sizeof(info));
12151 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
12152 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12153 RTE_ETH_FILTER_GET, &info);
12156 printf("Cannot get symmetric hash enable per port "
12157 "on port %u\n", res->port_id);
12161 printf("Symmetric hash is %s on port %u\n", info.info.enable ?
12162 "enabled" : "disabled", res->port_id);
12165 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
12166 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
12167 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
12168 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
12169 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
12172 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
12173 .f = cmd_get_sym_hash_per_port_parsed,
12175 .help_str = "get_sym_hash_ena_per_port <port_id>",
12177 (void *)&cmd_get_sym_hash_ena_per_port_all,
12178 (void *)&cmd_get_sym_hash_ena_per_port_port_id,
12183 /* *** Set symmetric hash enable per port *** */
12184 struct cmd_set_sym_hash_ena_per_port_result {
12185 cmdline_fixed_string_t set_sym_hash_ena_per_port;
12186 cmdline_fixed_string_t enable;
12191 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
12192 __rte_unused struct cmdline *cl,
12193 __rte_unused void *data)
12195 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
12196 struct rte_eth_hash_filter_info info;
12199 if (rte_eth_dev_filter_supported(res->port_id,
12200 RTE_ETH_FILTER_HASH) < 0) {
12201 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
12206 memset(&info, 0, sizeof(info));
12207 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
12208 if (!strcmp(res->enable, "enable"))
12209 info.info.enable = 1;
12210 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12211 RTE_ETH_FILTER_SET, &info);
12213 printf("Cannot set symmetric hash enable per port on "
12214 "port %u\n", res->port_id);
12217 printf("Symmetric hash has been set to %s on port %u\n",
12218 res->enable, res->port_id);
12221 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
12222 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
12223 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
12224 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
12225 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
12227 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
12228 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
12229 enable, "enable#disable");
12231 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
12232 .f = cmd_set_sym_hash_per_port_parsed,
12234 .help_str = "set_sym_hash_ena_per_port <port_id> enable|disable",
12236 (void *)&cmd_set_sym_hash_ena_per_port_all,
12237 (void *)&cmd_set_sym_hash_ena_per_port_port_id,
12238 (void *)&cmd_set_sym_hash_ena_per_port_enable,
12243 /* Get global config of hash function */
12244 struct cmd_get_hash_global_config_result {
12245 cmdline_fixed_string_t get_hash_global_config;
12250 flowtype_to_str(uint16_t ftype)
12256 } ftype_table[] = {
12257 {"ipv4", RTE_ETH_FLOW_IPV4},
12258 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
12259 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
12260 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
12261 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
12262 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
12263 {"ipv6", RTE_ETH_FLOW_IPV6},
12264 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
12265 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
12266 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
12267 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
12268 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
12269 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
12270 {"port", RTE_ETH_FLOW_PORT},
12271 {"vxlan", RTE_ETH_FLOW_VXLAN},
12272 {"geneve", RTE_ETH_FLOW_GENEVE},
12273 {"nvgre", RTE_ETH_FLOW_NVGRE},
12274 {"vxlan-gpe", RTE_ETH_FLOW_VXLAN_GPE},
12277 for (i = 0; i < RTE_DIM(ftype_table); i++) {
12278 if (ftype_table[i].ftype == ftype)
12279 return ftype_table[i].str;
12286 cmd_get_hash_global_config_parsed(void *parsed_result,
12287 __rte_unused struct cmdline *cl,
12288 __rte_unused void *data)
12290 struct cmd_get_hash_global_config_result *res = parsed_result;
12291 struct rte_eth_hash_filter_info info;
12292 uint32_t idx, offset;
12297 if (rte_eth_dev_filter_supported(res->port_id,
12298 RTE_ETH_FILTER_HASH) < 0) {
12299 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
12304 memset(&info, 0, sizeof(info));
12305 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
12306 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12307 RTE_ETH_FILTER_GET, &info);
12309 printf("Cannot get hash global configurations by port %d\n",
12314 switch (info.info.global_conf.hash_func) {
12315 case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
12316 printf("Hash function is Toeplitz\n");
12318 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
12319 printf("Hash function is Simple XOR\n");
12321 case RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ:
12322 printf("Hash function is Symmetric Toeplitz\n");
12325 printf("Unknown hash function\n");
12329 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) {
12330 idx = i / UINT64_BIT;
12331 offset = i % UINT64_BIT;
12332 if (!(info.info.global_conf.valid_bit_mask[idx] &
12335 str = flowtype_to_str(i);
12338 printf("Symmetric hash is %s globally for flow type %s "
12340 ((info.info.global_conf.sym_hash_enable_mask[idx] &
12341 (1ULL << offset)) ? "enabled" : "disabled"), str,
12346 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
12347 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
12348 get_hash_global_config, "get_hash_global_config");
12349 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
12350 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
12353 cmdline_parse_inst_t cmd_get_hash_global_config = {
12354 .f = cmd_get_hash_global_config_parsed,
12356 .help_str = "get_hash_global_config <port_id>",
12358 (void *)&cmd_get_hash_global_config_all,
12359 (void *)&cmd_get_hash_global_config_port_id,
12364 /* Set global config of hash function */
12365 struct cmd_set_hash_global_config_result {
12366 cmdline_fixed_string_t set_hash_global_config;
12368 cmdline_fixed_string_t hash_func;
12369 cmdline_fixed_string_t flow_type;
12370 cmdline_fixed_string_t enable;
12374 cmd_set_hash_global_config_parsed(void *parsed_result,
12375 __rte_unused struct cmdline *cl,
12376 __rte_unused void *data)
12378 struct cmd_set_hash_global_config_result *res = parsed_result;
12379 struct rte_eth_hash_filter_info info;
12380 uint32_t ftype, idx, offset;
12383 if (rte_eth_dev_filter_supported(res->port_id,
12384 RTE_ETH_FILTER_HASH) < 0) {
12385 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
12389 memset(&info, 0, sizeof(info));
12390 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
12391 if (!strcmp(res->hash_func, "toeplitz"))
12392 info.info.global_conf.hash_func =
12393 RTE_ETH_HASH_FUNCTION_TOEPLITZ;
12394 else if (!strcmp(res->hash_func, "simple_xor"))
12395 info.info.global_conf.hash_func =
12396 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
12397 else if (!strcmp(res->hash_func, "symmetric_toeplitz"))
12398 info.info.global_conf.hash_func =
12399 RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ;
12400 else if (!strcmp(res->hash_func, "default"))
12401 info.info.global_conf.hash_func =
12402 RTE_ETH_HASH_FUNCTION_DEFAULT;
12404 ftype = str2flowtype(res->flow_type);
12405 idx = ftype / UINT64_BIT;
12406 offset = ftype % UINT64_BIT;
12407 info.info.global_conf.valid_bit_mask[idx] |= (1ULL << offset);
12408 if (!strcmp(res->enable, "enable"))
12409 info.info.global_conf.sym_hash_enable_mask[idx] |=
12411 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12412 RTE_ETH_FILTER_SET, &info);
12414 printf("Cannot set global hash configurations by port %d\n",
12417 printf("Global hash configurations have been set "
12418 "successfully by port %d\n", res->port_id);
12421 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
12422 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12423 set_hash_global_config, "set_hash_global_config");
12424 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
12425 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
12427 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
12428 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12429 hash_func, "toeplitz#simple_xor#symmetric_toeplitz#default");
12430 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
12431 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12433 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
12434 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
12435 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
12436 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12437 enable, "enable#disable");
12439 cmdline_parse_inst_t cmd_set_hash_global_config = {
12440 .f = cmd_set_hash_global_config_parsed,
12442 .help_str = "set_hash_global_config <port_id> "
12443 "toeplitz|simple_xor|symmetric_toeplitz|default "
12444 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12445 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
12446 "l2_payload enable|disable",
12448 (void *)&cmd_set_hash_global_config_all,
12449 (void *)&cmd_set_hash_global_config_port_id,
12450 (void *)&cmd_set_hash_global_config_hash_func,
12451 (void *)&cmd_set_hash_global_config_flow_type,
12452 (void *)&cmd_set_hash_global_config_enable,
12457 /* Set hash input set */
12458 struct cmd_set_hash_input_set_result {
12459 cmdline_fixed_string_t set_hash_input_set;
12461 cmdline_fixed_string_t flow_type;
12462 cmdline_fixed_string_t inset_field;
12463 cmdline_fixed_string_t select;
12466 static enum rte_eth_input_set_field
12467 str2inset(char *string)
12471 static const struct {
12473 enum rte_eth_input_set_field inset;
12474 } inset_table[] = {
12475 {"ethertype", RTE_ETH_INPUT_SET_L2_ETHERTYPE},
12476 {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN},
12477 {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN},
12478 {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4},
12479 {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4},
12480 {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS},
12481 {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO},
12482 {"ipv4-ttl", RTE_ETH_INPUT_SET_L3_IP4_TTL},
12483 {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6},
12484 {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6},
12485 {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC},
12486 {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER},
12487 {"ipv6-hop-limits", RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS},
12488 {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT},
12489 {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT},
12490 {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT},
12491 {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT},
12492 {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT},
12493 {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT},
12494 {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG},
12495 {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY},
12496 {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY},
12497 {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD},
12498 {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD},
12499 {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD},
12500 {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD},
12501 {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD},
12502 {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD},
12503 {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD},
12504 {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD},
12505 {"none", RTE_ETH_INPUT_SET_NONE},
12508 for (i = 0; i < RTE_DIM(inset_table); i++) {
12509 if (!strcmp(string, inset_table[i].str))
12510 return inset_table[i].inset;
12513 return RTE_ETH_INPUT_SET_UNKNOWN;
12517 cmd_set_hash_input_set_parsed(void *parsed_result,
12518 __rte_unused struct cmdline *cl,
12519 __rte_unused void *data)
12521 struct cmd_set_hash_input_set_result *res = parsed_result;
12522 struct rte_eth_hash_filter_info info;
12524 memset(&info, 0, sizeof(info));
12525 info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT;
12526 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
12527 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
12528 info.info.input_set_conf.inset_size = 1;
12529 if (!strcmp(res->select, "select"))
12530 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
12531 else if (!strcmp(res->select, "add"))
12532 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
12533 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12534 RTE_ETH_FILTER_SET, &info);
12537 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd =
12538 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12539 set_hash_input_set, "set_hash_input_set");
12540 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id =
12541 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result,
12543 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type =
12544 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12546 cmdline_parse_token_string_t cmd_set_hash_input_set_field =
12547 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12549 "ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
12550 "ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#"
12551 "udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#"
12552 "sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#"
12553 "fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#"
12555 cmdline_parse_token_string_t cmd_set_hash_input_set_select =
12556 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12557 select, "select#add");
12559 cmdline_parse_inst_t cmd_set_hash_input_set = {
12560 .f = cmd_set_hash_input_set_parsed,
12562 .help_str = "set_hash_input_set <port_id> "
12563 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12564 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload|<flowtype_id> "
12565 "ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|"
12566 "ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|"
12567 "tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|"
12568 "gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
12569 "fld-7th|fld-8th|none select|add",
12571 (void *)&cmd_set_hash_input_set_cmd,
12572 (void *)&cmd_set_hash_input_set_port_id,
12573 (void *)&cmd_set_hash_input_set_flow_type,
12574 (void *)&cmd_set_hash_input_set_field,
12575 (void *)&cmd_set_hash_input_set_select,
12580 /* Set flow director input set */
12581 struct cmd_set_fdir_input_set_result {
12582 cmdline_fixed_string_t set_fdir_input_set;
12584 cmdline_fixed_string_t flow_type;
12585 cmdline_fixed_string_t inset_field;
12586 cmdline_fixed_string_t select;
12590 cmd_set_fdir_input_set_parsed(void *parsed_result,
12591 __rte_unused struct cmdline *cl,
12592 __rte_unused void *data)
12594 struct cmd_set_fdir_input_set_result *res = parsed_result;
12595 struct rte_eth_fdir_filter_info info;
12597 memset(&info, 0, sizeof(info));
12598 info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT;
12599 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
12600 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
12601 info.info.input_set_conf.inset_size = 1;
12602 if (!strcmp(res->select, "select"))
12603 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
12604 else if (!strcmp(res->select, "add"))
12605 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
12606 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
12607 RTE_ETH_FILTER_SET, &info);
12610 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd =
12611 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12612 set_fdir_input_set, "set_fdir_input_set");
12613 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id =
12614 TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result,
12616 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type =
12617 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12619 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
12620 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
12621 cmdline_parse_token_string_t cmd_set_fdir_input_set_field =
12622 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12624 "ivlan#ethertype#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
12625 "ipv4-tos#ipv4-proto#ipv4-ttl#ipv6-tc#ipv6-next-header#"
12626 "ipv6-hop-limits#udp-src-port#udp-dst-port#"
12627 "tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#"
12628 "sctp-veri-tag#none");
12629 cmdline_parse_token_string_t cmd_set_fdir_input_set_select =
12630 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12631 select, "select#add");
12633 cmdline_parse_inst_t cmd_set_fdir_input_set = {
12634 .f = cmd_set_fdir_input_set_parsed,
12636 .help_str = "set_fdir_input_set <port_id> "
12637 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12638 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
12639 "ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|"
12640 "ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|ipv6-next-header|"
12641 "ipv6-hop-limits|udp-src-port|udp-dst-port|"
12642 "tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|"
12643 "sctp-veri-tag|none select|add",
12645 (void *)&cmd_set_fdir_input_set_cmd,
12646 (void *)&cmd_set_fdir_input_set_port_id,
12647 (void *)&cmd_set_fdir_input_set_flow_type,
12648 (void *)&cmd_set_fdir_input_set_field,
12649 (void *)&cmd_set_fdir_input_set_select,
12654 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
12655 struct cmd_mcast_addr_result {
12656 cmdline_fixed_string_t mcast_addr_cmd;
12657 cmdline_fixed_string_t what;
12659 struct rte_ether_addr mc_addr;
12662 static void cmd_mcast_addr_parsed(void *parsed_result,
12663 __rte_unused struct cmdline *cl,
12664 __rte_unused void *data)
12666 struct cmd_mcast_addr_result *res = parsed_result;
12668 if (!rte_is_multicast_ether_addr(&res->mc_addr)) {
12669 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
12670 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
12671 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
12672 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
12675 if (strcmp(res->what, "add") == 0)
12676 mcast_addr_add(res->port_num, &res->mc_addr);
12678 mcast_addr_remove(res->port_num, &res->mc_addr);
12681 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
12682 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
12683 mcast_addr_cmd, "mcast_addr");
12684 cmdline_parse_token_string_t cmd_mcast_addr_what =
12685 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
12687 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
12688 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT16);
12689 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
12690 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
12692 cmdline_parse_inst_t cmd_mcast_addr = {
12693 .f = cmd_mcast_addr_parsed,
12695 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
12696 "Add/Remove multicast MAC address on port_id",
12698 (void *)&cmd_mcast_addr_cmd,
12699 (void *)&cmd_mcast_addr_what,
12700 (void *)&cmd_mcast_addr_portnum,
12701 (void *)&cmd_mcast_addr_addr,
12706 /* l2 tunnel config
12707 * only support E-tag now.
12710 /* Ether type config */
12711 struct cmd_config_l2_tunnel_eth_type_result {
12712 cmdline_fixed_string_t port;
12713 cmdline_fixed_string_t config;
12714 cmdline_fixed_string_t all;
12716 cmdline_fixed_string_t l2_tunnel;
12717 cmdline_fixed_string_t l2_tunnel_type;
12718 cmdline_fixed_string_t eth_type;
12719 uint16_t eth_type_val;
12722 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port =
12723 TOKEN_STRING_INITIALIZER
12724 (struct cmd_config_l2_tunnel_eth_type_result,
12726 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config =
12727 TOKEN_STRING_INITIALIZER
12728 (struct cmd_config_l2_tunnel_eth_type_result,
12730 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str =
12731 TOKEN_STRING_INITIALIZER
12732 (struct cmd_config_l2_tunnel_eth_type_result,
12734 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id =
12735 TOKEN_NUM_INITIALIZER
12736 (struct cmd_config_l2_tunnel_eth_type_result,
12738 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel =
12739 TOKEN_STRING_INITIALIZER
12740 (struct cmd_config_l2_tunnel_eth_type_result,
12741 l2_tunnel, "l2-tunnel");
12742 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type =
12743 TOKEN_STRING_INITIALIZER
12744 (struct cmd_config_l2_tunnel_eth_type_result,
12745 l2_tunnel_type, "E-tag");
12746 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type =
12747 TOKEN_STRING_INITIALIZER
12748 (struct cmd_config_l2_tunnel_eth_type_result,
12749 eth_type, "ether-type");
12750 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val =
12751 TOKEN_NUM_INITIALIZER
12752 (struct cmd_config_l2_tunnel_eth_type_result,
12753 eth_type_val, UINT16);
12755 static enum rte_eth_tunnel_type
12756 str2fdir_l2_tunnel_type(char *string)
12760 static const struct {
12762 enum rte_eth_tunnel_type type;
12763 } l2_tunnel_type_str[] = {
12764 {"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG},
12767 for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) {
12768 if (!strcmp(l2_tunnel_type_str[i].str, string))
12769 return l2_tunnel_type_str[i].type;
12771 return RTE_TUNNEL_TYPE_NONE;
12774 /* ether type config for all ports */
12776 cmd_config_l2_tunnel_eth_type_all_parsed
12777 (void *parsed_result,
12778 __rte_unused struct cmdline *cl,
12779 __rte_unused void *data)
12781 struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result;
12782 struct rte_eth_l2_tunnel_conf entry;
12785 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12786 entry.ether_type = res->eth_type_val;
12788 RTE_ETH_FOREACH_DEV(pid) {
12789 rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry);
12793 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = {
12794 .f = cmd_config_l2_tunnel_eth_type_all_parsed,
12796 .help_str = "port config all l2-tunnel E-tag ether-type <value>",
12798 (void *)&cmd_config_l2_tunnel_eth_type_port,
12799 (void *)&cmd_config_l2_tunnel_eth_type_config,
12800 (void *)&cmd_config_l2_tunnel_eth_type_all_str,
12801 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
12802 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
12803 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
12804 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
12809 /* ether type config for a specific port */
12811 cmd_config_l2_tunnel_eth_type_specific_parsed(
12812 void *parsed_result,
12813 __rte_unused struct cmdline *cl,
12814 __rte_unused void *data)
12816 struct cmd_config_l2_tunnel_eth_type_result *res =
12818 struct rte_eth_l2_tunnel_conf entry;
12820 if (port_id_is_invalid(res->id, ENABLED_WARN))
12823 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12824 entry.ether_type = res->eth_type_val;
12826 rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry);
12829 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = {
12830 .f = cmd_config_l2_tunnel_eth_type_specific_parsed,
12832 .help_str = "port config <port_id> l2-tunnel E-tag ether-type <value>",
12834 (void *)&cmd_config_l2_tunnel_eth_type_port,
12835 (void *)&cmd_config_l2_tunnel_eth_type_config,
12836 (void *)&cmd_config_l2_tunnel_eth_type_id,
12837 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
12838 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
12839 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
12840 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
12845 /* Enable/disable l2 tunnel */
12846 struct cmd_config_l2_tunnel_en_dis_result {
12847 cmdline_fixed_string_t port;
12848 cmdline_fixed_string_t config;
12849 cmdline_fixed_string_t all;
12851 cmdline_fixed_string_t l2_tunnel;
12852 cmdline_fixed_string_t l2_tunnel_type;
12853 cmdline_fixed_string_t en_dis;
12856 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port =
12857 TOKEN_STRING_INITIALIZER
12858 (struct cmd_config_l2_tunnel_en_dis_result,
12860 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config =
12861 TOKEN_STRING_INITIALIZER
12862 (struct cmd_config_l2_tunnel_en_dis_result,
12864 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str =
12865 TOKEN_STRING_INITIALIZER
12866 (struct cmd_config_l2_tunnel_en_dis_result,
12868 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id =
12869 TOKEN_NUM_INITIALIZER
12870 (struct cmd_config_l2_tunnel_en_dis_result,
12872 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel =
12873 TOKEN_STRING_INITIALIZER
12874 (struct cmd_config_l2_tunnel_en_dis_result,
12875 l2_tunnel, "l2-tunnel");
12876 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type =
12877 TOKEN_STRING_INITIALIZER
12878 (struct cmd_config_l2_tunnel_en_dis_result,
12879 l2_tunnel_type, "E-tag");
12880 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis =
12881 TOKEN_STRING_INITIALIZER
12882 (struct cmd_config_l2_tunnel_en_dis_result,
12883 en_dis, "enable#disable");
12885 /* enable/disable l2 tunnel for all ports */
12887 cmd_config_l2_tunnel_en_dis_all_parsed(
12888 void *parsed_result,
12889 __rte_unused struct cmdline *cl,
12890 __rte_unused void *data)
12892 struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result;
12893 struct rte_eth_l2_tunnel_conf entry;
12897 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12899 if (!strcmp("enable", res->en_dis))
12904 RTE_ETH_FOREACH_DEV(pid) {
12905 rte_eth_dev_l2_tunnel_offload_set(pid,
12907 ETH_L2_TUNNEL_ENABLE_MASK,
12912 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = {
12913 .f = cmd_config_l2_tunnel_en_dis_all_parsed,
12915 .help_str = "port config all l2-tunnel E-tag enable|disable",
12917 (void *)&cmd_config_l2_tunnel_en_dis_port,
12918 (void *)&cmd_config_l2_tunnel_en_dis_config,
12919 (void *)&cmd_config_l2_tunnel_en_dis_all_str,
12920 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
12921 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
12922 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
12927 /* enable/disable l2 tunnel for a port */
12929 cmd_config_l2_tunnel_en_dis_specific_parsed(
12930 void *parsed_result,
12931 __rte_unused struct cmdline *cl,
12932 __rte_unused void *data)
12934 struct cmd_config_l2_tunnel_en_dis_result *res =
12936 struct rte_eth_l2_tunnel_conf entry;
12938 if (port_id_is_invalid(res->id, ENABLED_WARN))
12941 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12943 if (!strcmp("enable", res->en_dis))
12944 rte_eth_dev_l2_tunnel_offload_set(res->id,
12946 ETH_L2_TUNNEL_ENABLE_MASK,
12949 rte_eth_dev_l2_tunnel_offload_set(res->id,
12951 ETH_L2_TUNNEL_ENABLE_MASK,
12955 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = {
12956 .f = cmd_config_l2_tunnel_en_dis_specific_parsed,
12958 .help_str = "port config <port_id> l2-tunnel E-tag enable|disable",
12960 (void *)&cmd_config_l2_tunnel_en_dis_port,
12961 (void *)&cmd_config_l2_tunnel_en_dis_config,
12962 (void *)&cmd_config_l2_tunnel_en_dis_id,
12963 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
12964 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
12965 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
12970 /* E-tag configuration */
12972 /* Common result structure for all E-tag configuration */
12973 struct cmd_config_e_tag_result {
12974 cmdline_fixed_string_t e_tag;
12975 cmdline_fixed_string_t set;
12976 cmdline_fixed_string_t insertion;
12977 cmdline_fixed_string_t stripping;
12978 cmdline_fixed_string_t forwarding;
12979 cmdline_fixed_string_t filter;
12980 cmdline_fixed_string_t add;
12981 cmdline_fixed_string_t del;
12982 cmdline_fixed_string_t on;
12983 cmdline_fixed_string_t off;
12984 cmdline_fixed_string_t on_off;
12985 cmdline_fixed_string_t port_tag_id;
12986 uint32_t port_tag_id_val;
12987 cmdline_fixed_string_t e_tag_id;
12988 uint16_t e_tag_id_val;
12989 cmdline_fixed_string_t dst_pool;
12990 uint8_t dst_pool_val;
12991 cmdline_fixed_string_t port;
12993 cmdline_fixed_string_t vf;
12997 /* Common CLI fields for all E-tag configuration */
12998 cmdline_parse_token_string_t cmd_config_e_tag_e_tag =
12999 TOKEN_STRING_INITIALIZER
13000 (struct cmd_config_e_tag_result,
13002 cmdline_parse_token_string_t cmd_config_e_tag_set =
13003 TOKEN_STRING_INITIALIZER
13004 (struct cmd_config_e_tag_result,
13006 cmdline_parse_token_string_t cmd_config_e_tag_insertion =
13007 TOKEN_STRING_INITIALIZER
13008 (struct cmd_config_e_tag_result,
13009 insertion, "insertion");
13010 cmdline_parse_token_string_t cmd_config_e_tag_stripping =
13011 TOKEN_STRING_INITIALIZER
13012 (struct cmd_config_e_tag_result,
13013 stripping, "stripping");
13014 cmdline_parse_token_string_t cmd_config_e_tag_forwarding =
13015 TOKEN_STRING_INITIALIZER
13016 (struct cmd_config_e_tag_result,
13017 forwarding, "forwarding");
13018 cmdline_parse_token_string_t cmd_config_e_tag_filter =
13019 TOKEN_STRING_INITIALIZER
13020 (struct cmd_config_e_tag_result,
13022 cmdline_parse_token_string_t cmd_config_e_tag_add =
13023 TOKEN_STRING_INITIALIZER
13024 (struct cmd_config_e_tag_result,
13026 cmdline_parse_token_string_t cmd_config_e_tag_del =
13027 TOKEN_STRING_INITIALIZER
13028 (struct cmd_config_e_tag_result,
13030 cmdline_parse_token_string_t cmd_config_e_tag_on =
13031 TOKEN_STRING_INITIALIZER
13032 (struct cmd_config_e_tag_result,
13034 cmdline_parse_token_string_t cmd_config_e_tag_off =
13035 TOKEN_STRING_INITIALIZER
13036 (struct cmd_config_e_tag_result,
13038 cmdline_parse_token_string_t cmd_config_e_tag_on_off =
13039 TOKEN_STRING_INITIALIZER
13040 (struct cmd_config_e_tag_result,
13042 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id =
13043 TOKEN_STRING_INITIALIZER
13044 (struct cmd_config_e_tag_result,
13045 port_tag_id, "port-tag-id");
13046 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val =
13047 TOKEN_NUM_INITIALIZER
13048 (struct cmd_config_e_tag_result,
13049 port_tag_id_val, UINT32);
13050 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id =
13051 TOKEN_STRING_INITIALIZER
13052 (struct cmd_config_e_tag_result,
13053 e_tag_id, "e-tag-id");
13054 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val =
13055 TOKEN_NUM_INITIALIZER
13056 (struct cmd_config_e_tag_result,
13057 e_tag_id_val, UINT16);
13058 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool =
13059 TOKEN_STRING_INITIALIZER
13060 (struct cmd_config_e_tag_result,
13061 dst_pool, "dst-pool");
13062 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val =
13063 TOKEN_NUM_INITIALIZER
13064 (struct cmd_config_e_tag_result,
13065 dst_pool_val, UINT8);
13066 cmdline_parse_token_string_t cmd_config_e_tag_port =
13067 TOKEN_STRING_INITIALIZER
13068 (struct cmd_config_e_tag_result,
13070 cmdline_parse_token_num_t cmd_config_e_tag_port_id =
13071 TOKEN_NUM_INITIALIZER
13072 (struct cmd_config_e_tag_result,
13074 cmdline_parse_token_string_t cmd_config_e_tag_vf =
13075 TOKEN_STRING_INITIALIZER
13076 (struct cmd_config_e_tag_result,
13078 cmdline_parse_token_num_t cmd_config_e_tag_vf_id =
13079 TOKEN_NUM_INITIALIZER
13080 (struct cmd_config_e_tag_result,
13083 /* E-tag insertion configuration */
13085 cmd_config_e_tag_insertion_en_parsed(
13086 void *parsed_result,
13087 __rte_unused struct cmdline *cl,
13088 __rte_unused void *data)
13090 struct cmd_config_e_tag_result *res =
13092 struct rte_eth_l2_tunnel_conf entry;
13094 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13097 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13098 entry.tunnel_id = res->port_tag_id_val;
13099 entry.vf_id = res->vf_id;
13100 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
13102 ETH_L2_TUNNEL_INSERTION_MASK,
13107 cmd_config_e_tag_insertion_dis_parsed(
13108 void *parsed_result,
13109 __rte_unused struct cmdline *cl,
13110 __rte_unused void *data)
13112 struct cmd_config_e_tag_result *res =
13114 struct rte_eth_l2_tunnel_conf entry;
13116 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13119 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13120 entry.vf_id = res->vf_id;
13122 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
13124 ETH_L2_TUNNEL_INSERTION_MASK,
13128 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = {
13129 .f = cmd_config_e_tag_insertion_en_parsed,
13131 .help_str = "E-tag ... : E-tag insertion enable",
13133 (void *)&cmd_config_e_tag_e_tag,
13134 (void *)&cmd_config_e_tag_set,
13135 (void *)&cmd_config_e_tag_insertion,
13136 (void *)&cmd_config_e_tag_on,
13137 (void *)&cmd_config_e_tag_port_tag_id,
13138 (void *)&cmd_config_e_tag_port_tag_id_val,
13139 (void *)&cmd_config_e_tag_port,
13140 (void *)&cmd_config_e_tag_port_id,
13141 (void *)&cmd_config_e_tag_vf,
13142 (void *)&cmd_config_e_tag_vf_id,
13147 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = {
13148 .f = cmd_config_e_tag_insertion_dis_parsed,
13150 .help_str = "E-tag ... : E-tag insertion disable",
13152 (void *)&cmd_config_e_tag_e_tag,
13153 (void *)&cmd_config_e_tag_set,
13154 (void *)&cmd_config_e_tag_insertion,
13155 (void *)&cmd_config_e_tag_off,
13156 (void *)&cmd_config_e_tag_port,
13157 (void *)&cmd_config_e_tag_port_id,
13158 (void *)&cmd_config_e_tag_vf,
13159 (void *)&cmd_config_e_tag_vf_id,
13164 /* E-tag stripping configuration */
13166 cmd_config_e_tag_stripping_parsed(
13167 void *parsed_result,
13168 __rte_unused struct cmdline *cl,
13169 __rte_unused void *data)
13171 struct cmd_config_e_tag_result *res =
13173 struct rte_eth_l2_tunnel_conf entry;
13175 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13178 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13180 if (!strcmp(res->on_off, "on"))
13181 rte_eth_dev_l2_tunnel_offload_set
13184 ETH_L2_TUNNEL_STRIPPING_MASK,
13187 rte_eth_dev_l2_tunnel_offload_set
13190 ETH_L2_TUNNEL_STRIPPING_MASK,
13194 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = {
13195 .f = cmd_config_e_tag_stripping_parsed,
13197 .help_str = "E-tag ... : E-tag stripping enable/disable",
13199 (void *)&cmd_config_e_tag_e_tag,
13200 (void *)&cmd_config_e_tag_set,
13201 (void *)&cmd_config_e_tag_stripping,
13202 (void *)&cmd_config_e_tag_on_off,
13203 (void *)&cmd_config_e_tag_port,
13204 (void *)&cmd_config_e_tag_port_id,
13209 /* E-tag forwarding configuration */
13211 cmd_config_e_tag_forwarding_parsed(
13212 void *parsed_result,
13213 __rte_unused struct cmdline *cl,
13214 __rte_unused void *data)
13216 struct cmd_config_e_tag_result *res = parsed_result;
13217 struct rte_eth_l2_tunnel_conf entry;
13219 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13222 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13224 if (!strcmp(res->on_off, "on"))
13225 rte_eth_dev_l2_tunnel_offload_set
13228 ETH_L2_TUNNEL_FORWARDING_MASK,
13231 rte_eth_dev_l2_tunnel_offload_set
13234 ETH_L2_TUNNEL_FORWARDING_MASK,
13238 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = {
13239 .f = cmd_config_e_tag_forwarding_parsed,
13241 .help_str = "E-tag ... : E-tag forwarding enable/disable",
13243 (void *)&cmd_config_e_tag_e_tag,
13244 (void *)&cmd_config_e_tag_set,
13245 (void *)&cmd_config_e_tag_forwarding,
13246 (void *)&cmd_config_e_tag_on_off,
13247 (void *)&cmd_config_e_tag_port,
13248 (void *)&cmd_config_e_tag_port_id,
13253 /* E-tag filter configuration */
13255 cmd_config_e_tag_filter_add_parsed(
13256 void *parsed_result,
13257 __rte_unused struct cmdline *cl,
13258 __rte_unused void *data)
13260 struct cmd_config_e_tag_result *res = parsed_result;
13261 struct rte_eth_l2_tunnel_conf entry;
13264 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13267 if (res->e_tag_id_val > 0x3fff) {
13268 printf("e-tag-id must be equal or less than 0x3fff.\n");
13272 ret = rte_eth_dev_filter_supported(res->port_id,
13273 RTE_ETH_FILTER_L2_TUNNEL);
13275 printf("E-tag filter is not supported on port %u.\n",
13280 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13281 entry.tunnel_id = res->e_tag_id_val;
13282 entry.pool = res->dst_pool_val;
13284 ret = rte_eth_dev_filter_ctrl(res->port_id,
13285 RTE_ETH_FILTER_L2_TUNNEL,
13286 RTE_ETH_FILTER_ADD,
13289 printf("E-tag filter programming error: (%s)\n",
13293 cmdline_parse_inst_t cmd_config_e_tag_filter_add = {
13294 .f = cmd_config_e_tag_filter_add_parsed,
13296 .help_str = "E-tag ... : E-tag filter add",
13298 (void *)&cmd_config_e_tag_e_tag,
13299 (void *)&cmd_config_e_tag_set,
13300 (void *)&cmd_config_e_tag_filter,
13301 (void *)&cmd_config_e_tag_add,
13302 (void *)&cmd_config_e_tag_e_tag_id,
13303 (void *)&cmd_config_e_tag_e_tag_id_val,
13304 (void *)&cmd_config_e_tag_dst_pool,
13305 (void *)&cmd_config_e_tag_dst_pool_val,
13306 (void *)&cmd_config_e_tag_port,
13307 (void *)&cmd_config_e_tag_port_id,
13313 cmd_config_e_tag_filter_del_parsed(
13314 void *parsed_result,
13315 __rte_unused struct cmdline *cl,
13316 __rte_unused void *data)
13318 struct cmd_config_e_tag_result *res = parsed_result;
13319 struct rte_eth_l2_tunnel_conf entry;
13322 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13325 if (res->e_tag_id_val > 0x3fff) {
13326 printf("e-tag-id must be less than 0x3fff.\n");
13330 ret = rte_eth_dev_filter_supported(res->port_id,
13331 RTE_ETH_FILTER_L2_TUNNEL);
13333 printf("E-tag filter is not supported on port %u.\n",
13338 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13339 entry.tunnel_id = res->e_tag_id_val;
13341 ret = rte_eth_dev_filter_ctrl(res->port_id,
13342 RTE_ETH_FILTER_L2_TUNNEL,
13343 RTE_ETH_FILTER_DELETE,
13346 printf("E-tag filter programming error: (%s)\n",
13350 cmdline_parse_inst_t cmd_config_e_tag_filter_del = {
13351 .f = cmd_config_e_tag_filter_del_parsed,
13353 .help_str = "E-tag ... : E-tag filter delete",
13355 (void *)&cmd_config_e_tag_e_tag,
13356 (void *)&cmd_config_e_tag_set,
13357 (void *)&cmd_config_e_tag_filter,
13358 (void *)&cmd_config_e_tag_del,
13359 (void *)&cmd_config_e_tag_e_tag_id,
13360 (void *)&cmd_config_e_tag_e_tag_id_val,
13361 (void *)&cmd_config_e_tag_port,
13362 (void *)&cmd_config_e_tag_port_id,
13367 /* vf vlan anti spoof configuration */
13369 /* Common result structure for vf vlan anti spoof */
13370 struct cmd_vf_vlan_anti_spoof_result {
13371 cmdline_fixed_string_t set;
13372 cmdline_fixed_string_t vf;
13373 cmdline_fixed_string_t vlan;
13374 cmdline_fixed_string_t antispoof;
13377 cmdline_fixed_string_t on_off;
13380 /* Common CLI fields for vf vlan anti spoof enable disable */
13381 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
13382 TOKEN_STRING_INITIALIZER
13383 (struct cmd_vf_vlan_anti_spoof_result,
13385 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
13386 TOKEN_STRING_INITIALIZER
13387 (struct cmd_vf_vlan_anti_spoof_result,
13389 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
13390 TOKEN_STRING_INITIALIZER
13391 (struct cmd_vf_vlan_anti_spoof_result,
13393 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
13394 TOKEN_STRING_INITIALIZER
13395 (struct cmd_vf_vlan_anti_spoof_result,
13396 antispoof, "antispoof");
13397 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
13398 TOKEN_NUM_INITIALIZER
13399 (struct cmd_vf_vlan_anti_spoof_result,
13401 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
13402 TOKEN_NUM_INITIALIZER
13403 (struct cmd_vf_vlan_anti_spoof_result,
13405 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
13406 TOKEN_STRING_INITIALIZER
13407 (struct cmd_vf_vlan_anti_spoof_result,
13411 cmd_set_vf_vlan_anti_spoof_parsed(
13412 void *parsed_result,
13413 __rte_unused struct cmdline *cl,
13414 __rte_unused void *data)
13416 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
13417 int ret = -ENOTSUP;
13419 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13421 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13424 #ifdef RTE_NET_IXGBE
13425 if (ret == -ENOTSUP)
13426 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
13427 res->vf_id, is_on);
13429 #ifdef RTE_NET_I40E
13430 if (ret == -ENOTSUP)
13431 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
13432 res->vf_id, is_on);
13434 #ifdef RTE_NET_BNXT
13435 if (ret == -ENOTSUP)
13436 ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
13437 res->vf_id, is_on);
13444 printf("invalid vf_id %d\n", res->vf_id);
13447 printf("invalid port_id %d\n", res->port_id);
13450 printf("function not implemented\n");
13453 printf("programming error: (%s)\n", strerror(-ret));
13457 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
13458 .f = cmd_set_vf_vlan_anti_spoof_parsed,
13460 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
13462 (void *)&cmd_vf_vlan_anti_spoof_set,
13463 (void *)&cmd_vf_vlan_anti_spoof_vf,
13464 (void *)&cmd_vf_vlan_anti_spoof_vlan,
13465 (void *)&cmd_vf_vlan_anti_spoof_antispoof,
13466 (void *)&cmd_vf_vlan_anti_spoof_port_id,
13467 (void *)&cmd_vf_vlan_anti_spoof_vf_id,
13468 (void *)&cmd_vf_vlan_anti_spoof_on_off,
13473 /* vf mac anti spoof configuration */
13475 /* Common result structure for vf mac anti spoof */
13476 struct cmd_vf_mac_anti_spoof_result {
13477 cmdline_fixed_string_t set;
13478 cmdline_fixed_string_t vf;
13479 cmdline_fixed_string_t mac;
13480 cmdline_fixed_string_t antispoof;
13483 cmdline_fixed_string_t on_off;
13486 /* Common CLI fields for vf mac anti spoof enable disable */
13487 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
13488 TOKEN_STRING_INITIALIZER
13489 (struct cmd_vf_mac_anti_spoof_result,
13491 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
13492 TOKEN_STRING_INITIALIZER
13493 (struct cmd_vf_mac_anti_spoof_result,
13495 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
13496 TOKEN_STRING_INITIALIZER
13497 (struct cmd_vf_mac_anti_spoof_result,
13499 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
13500 TOKEN_STRING_INITIALIZER
13501 (struct cmd_vf_mac_anti_spoof_result,
13502 antispoof, "antispoof");
13503 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
13504 TOKEN_NUM_INITIALIZER
13505 (struct cmd_vf_mac_anti_spoof_result,
13507 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
13508 TOKEN_NUM_INITIALIZER
13509 (struct cmd_vf_mac_anti_spoof_result,
13511 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
13512 TOKEN_STRING_INITIALIZER
13513 (struct cmd_vf_mac_anti_spoof_result,
13517 cmd_set_vf_mac_anti_spoof_parsed(
13518 void *parsed_result,
13519 __rte_unused struct cmdline *cl,
13520 __rte_unused void *data)
13522 struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
13523 int ret = -ENOTSUP;
13525 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13527 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13530 #ifdef RTE_NET_IXGBE
13531 if (ret == -ENOTSUP)
13532 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
13533 res->vf_id, is_on);
13535 #ifdef RTE_NET_I40E
13536 if (ret == -ENOTSUP)
13537 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
13538 res->vf_id, is_on);
13540 #ifdef RTE_NET_BNXT
13541 if (ret == -ENOTSUP)
13542 ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
13543 res->vf_id, is_on);
13550 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13553 printf("invalid port_id %d\n", res->port_id);
13556 printf("function not implemented\n");
13559 printf("programming error: (%s)\n", strerror(-ret));
13563 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
13564 .f = cmd_set_vf_mac_anti_spoof_parsed,
13566 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
13568 (void *)&cmd_vf_mac_anti_spoof_set,
13569 (void *)&cmd_vf_mac_anti_spoof_vf,
13570 (void *)&cmd_vf_mac_anti_spoof_mac,
13571 (void *)&cmd_vf_mac_anti_spoof_antispoof,
13572 (void *)&cmd_vf_mac_anti_spoof_port_id,
13573 (void *)&cmd_vf_mac_anti_spoof_vf_id,
13574 (void *)&cmd_vf_mac_anti_spoof_on_off,
13579 /* vf vlan strip queue configuration */
13581 /* Common result structure for vf mac anti spoof */
13582 struct cmd_vf_vlan_stripq_result {
13583 cmdline_fixed_string_t set;
13584 cmdline_fixed_string_t vf;
13585 cmdline_fixed_string_t vlan;
13586 cmdline_fixed_string_t stripq;
13589 cmdline_fixed_string_t on_off;
13592 /* Common CLI fields for vf vlan strip enable disable */
13593 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
13594 TOKEN_STRING_INITIALIZER
13595 (struct cmd_vf_vlan_stripq_result,
13597 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
13598 TOKEN_STRING_INITIALIZER
13599 (struct cmd_vf_vlan_stripq_result,
13601 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
13602 TOKEN_STRING_INITIALIZER
13603 (struct cmd_vf_vlan_stripq_result,
13605 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
13606 TOKEN_STRING_INITIALIZER
13607 (struct cmd_vf_vlan_stripq_result,
13609 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
13610 TOKEN_NUM_INITIALIZER
13611 (struct cmd_vf_vlan_stripq_result,
13613 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
13614 TOKEN_NUM_INITIALIZER
13615 (struct cmd_vf_vlan_stripq_result,
13617 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
13618 TOKEN_STRING_INITIALIZER
13619 (struct cmd_vf_vlan_stripq_result,
13623 cmd_set_vf_vlan_stripq_parsed(
13624 void *parsed_result,
13625 __rte_unused struct cmdline *cl,
13626 __rte_unused void *data)
13628 struct cmd_vf_vlan_stripq_result *res = parsed_result;
13629 int ret = -ENOTSUP;
13631 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13633 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13636 #ifdef RTE_NET_IXGBE
13637 if (ret == -ENOTSUP)
13638 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
13639 res->vf_id, is_on);
13641 #ifdef RTE_NET_I40E
13642 if (ret == -ENOTSUP)
13643 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
13644 res->vf_id, is_on);
13646 #ifdef RTE_NET_BNXT
13647 if (ret == -ENOTSUP)
13648 ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
13649 res->vf_id, is_on);
13656 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13659 printf("invalid port_id %d\n", res->port_id);
13662 printf("function not implemented\n");
13665 printf("programming error: (%s)\n", strerror(-ret));
13669 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
13670 .f = cmd_set_vf_vlan_stripq_parsed,
13672 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
13674 (void *)&cmd_vf_vlan_stripq_set,
13675 (void *)&cmd_vf_vlan_stripq_vf,
13676 (void *)&cmd_vf_vlan_stripq_vlan,
13677 (void *)&cmd_vf_vlan_stripq_stripq,
13678 (void *)&cmd_vf_vlan_stripq_port_id,
13679 (void *)&cmd_vf_vlan_stripq_vf_id,
13680 (void *)&cmd_vf_vlan_stripq_on_off,
13685 /* vf vlan insert configuration */
13687 /* Common result structure for vf vlan insert */
13688 struct cmd_vf_vlan_insert_result {
13689 cmdline_fixed_string_t set;
13690 cmdline_fixed_string_t vf;
13691 cmdline_fixed_string_t vlan;
13692 cmdline_fixed_string_t insert;
13698 /* Common CLI fields for vf vlan insert enable disable */
13699 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
13700 TOKEN_STRING_INITIALIZER
13701 (struct cmd_vf_vlan_insert_result,
13703 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
13704 TOKEN_STRING_INITIALIZER
13705 (struct cmd_vf_vlan_insert_result,
13707 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
13708 TOKEN_STRING_INITIALIZER
13709 (struct cmd_vf_vlan_insert_result,
13711 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
13712 TOKEN_STRING_INITIALIZER
13713 (struct cmd_vf_vlan_insert_result,
13715 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
13716 TOKEN_NUM_INITIALIZER
13717 (struct cmd_vf_vlan_insert_result,
13719 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
13720 TOKEN_NUM_INITIALIZER
13721 (struct cmd_vf_vlan_insert_result,
13723 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
13724 TOKEN_NUM_INITIALIZER
13725 (struct cmd_vf_vlan_insert_result,
13729 cmd_set_vf_vlan_insert_parsed(
13730 void *parsed_result,
13731 __rte_unused struct cmdline *cl,
13732 __rte_unused void *data)
13734 struct cmd_vf_vlan_insert_result *res = parsed_result;
13735 int ret = -ENOTSUP;
13737 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13740 #ifdef RTE_NET_IXGBE
13741 if (ret == -ENOTSUP)
13742 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
13745 #ifdef RTE_NET_I40E
13746 if (ret == -ENOTSUP)
13747 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
13750 #ifdef RTE_NET_BNXT
13751 if (ret == -ENOTSUP)
13752 ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
13760 printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id);
13763 printf("invalid port_id %d\n", res->port_id);
13766 printf("function not implemented\n");
13769 printf("programming error: (%s)\n", strerror(-ret));
13773 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
13774 .f = cmd_set_vf_vlan_insert_parsed,
13776 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
13778 (void *)&cmd_vf_vlan_insert_set,
13779 (void *)&cmd_vf_vlan_insert_vf,
13780 (void *)&cmd_vf_vlan_insert_vlan,
13781 (void *)&cmd_vf_vlan_insert_insert,
13782 (void *)&cmd_vf_vlan_insert_port_id,
13783 (void *)&cmd_vf_vlan_insert_vf_id,
13784 (void *)&cmd_vf_vlan_insert_vlan_id,
13789 /* tx loopback configuration */
13791 /* Common result structure for tx loopback */
13792 struct cmd_tx_loopback_result {
13793 cmdline_fixed_string_t set;
13794 cmdline_fixed_string_t tx;
13795 cmdline_fixed_string_t loopback;
13797 cmdline_fixed_string_t on_off;
13800 /* Common CLI fields for tx loopback enable disable */
13801 cmdline_parse_token_string_t cmd_tx_loopback_set =
13802 TOKEN_STRING_INITIALIZER
13803 (struct cmd_tx_loopback_result,
13805 cmdline_parse_token_string_t cmd_tx_loopback_tx =
13806 TOKEN_STRING_INITIALIZER
13807 (struct cmd_tx_loopback_result,
13809 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
13810 TOKEN_STRING_INITIALIZER
13811 (struct cmd_tx_loopback_result,
13812 loopback, "loopback");
13813 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
13814 TOKEN_NUM_INITIALIZER
13815 (struct cmd_tx_loopback_result,
13817 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
13818 TOKEN_STRING_INITIALIZER
13819 (struct cmd_tx_loopback_result,
13823 cmd_set_tx_loopback_parsed(
13824 void *parsed_result,
13825 __rte_unused struct cmdline *cl,
13826 __rte_unused void *data)
13828 struct cmd_tx_loopback_result *res = parsed_result;
13829 int ret = -ENOTSUP;
13831 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13833 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13836 #ifdef RTE_NET_IXGBE
13837 if (ret == -ENOTSUP)
13838 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
13840 #ifdef RTE_NET_I40E
13841 if (ret == -ENOTSUP)
13842 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
13844 #ifdef RTE_NET_BNXT
13845 if (ret == -ENOTSUP)
13846 ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
13848 #if defined RTE_BUS_DPAA && defined RTE_NET_DPAA
13849 if (ret == -ENOTSUP)
13850 ret = rte_pmd_dpaa_set_tx_loopback(res->port_id, is_on);
13857 printf("invalid is_on %d\n", is_on);
13860 printf("invalid port_id %d\n", res->port_id);
13863 printf("function not implemented\n");
13866 printf("programming error: (%s)\n", strerror(-ret));
13870 cmdline_parse_inst_t cmd_set_tx_loopback = {
13871 .f = cmd_set_tx_loopback_parsed,
13873 .help_str = "set tx loopback <port_id> on|off",
13875 (void *)&cmd_tx_loopback_set,
13876 (void *)&cmd_tx_loopback_tx,
13877 (void *)&cmd_tx_loopback_loopback,
13878 (void *)&cmd_tx_loopback_port_id,
13879 (void *)&cmd_tx_loopback_on_off,
13884 /* all queues drop enable configuration */
13886 /* Common result structure for all queues drop enable */
13887 struct cmd_all_queues_drop_en_result {
13888 cmdline_fixed_string_t set;
13889 cmdline_fixed_string_t all;
13890 cmdline_fixed_string_t queues;
13891 cmdline_fixed_string_t drop;
13893 cmdline_fixed_string_t on_off;
13896 /* Common CLI fields for tx loopback enable disable */
13897 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
13898 TOKEN_STRING_INITIALIZER
13899 (struct cmd_all_queues_drop_en_result,
13901 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
13902 TOKEN_STRING_INITIALIZER
13903 (struct cmd_all_queues_drop_en_result,
13905 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
13906 TOKEN_STRING_INITIALIZER
13907 (struct cmd_all_queues_drop_en_result,
13909 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
13910 TOKEN_STRING_INITIALIZER
13911 (struct cmd_all_queues_drop_en_result,
13913 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
13914 TOKEN_NUM_INITIALIZER
13915 (struct cmd_all_queues_drop_en_result,
13917 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
13918 TOKEN_STRING_INITIALIZER
13919 (struct cmd_all_queues_drop_en_result,
13923 cmd_set_all_queues_drop_en_parsed(
13924 void *parsed_result,
13925 __rte_unused struct cmdline *cl,
13926 __rte_unused void *data)
13928 struct cmd_all_queues_drop_en_result *res = parsed_result;
13929 int ret = -ENOTSUP;
13930 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13932 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13935 #ifdef RTE_NET_IXGBE
13936 if (ret == -ENOTSUP)
13937 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
13939 #ifdef RTE_NET_BNXT
13940 if (ret == -ENOTSUP)
13941 ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
13947 printf("invalid is_on %d\n", is_on);
13950 printf("invalid port_id %d\n", res->port_id);
13953 printf("function not implemented\n");
13956 printf("programming error: (%s)\n", strerror(-ret));
13960 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
13961 .f = cmd_set_all_queues_drop_en_parsed,
13963 .help_str = "set all queues drop <port_id> on|off",
13965 (void *)&cmd_all_queues_drop_en_set,
13966 (void *)&cmd_all_queues_drop_en_all,
13967 (void *)&cmd_all_queues_drop_en_queues,
13968 (void *)&cmd_all_queues_drop_en_drop,
13969 (void *)&cmd_all_queues_drop_en_port_id,
13970 (void *)&cmd_all_queues_drop_en_on_off,
13975 /* vf split drop enable configuration */
13977 /* Common result structure for vf split drop enable */
13978 struct cmd_vf_split_drop_en_result {
13979 cmdline_fixed_string_t set;
13980 cmdline_fixed_string_t vf;
13981 cmdline_fixed_string_t split;
13982 cmdline_fixed_string_t drop;
13985 cmdline_fixed_string_t on_off;
13988 /* Common CLI fields for vf split drop enable disable */
13989 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
13990 TOKEN_STRING_INITIALIZER
13991 (struct cmd_vf_split_drop_en_result,
13993 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
13994 TOKEN_STRING_INITIALIZER
13995 (struct cmd_vf_split_drop_en_result,
13997 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
13998 TOKEN_STRING_INITIALIZER
13999 (struct cmd_vf_split_drop_en_result,
14001 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
14002 TOKEN_STRING_INITIALIZER
14003 (struct cmd_vf_split_drop_en_result,
14005 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
14006 TOKEN_NUM_INITIALIZER
14007 (struct cmd_vf_split_drop_en_result,
14009 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
14010 TOKEN_NUM_INITIALIZER
14011 (struct cmd_vf_split_drop_en_result,
14013 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
14014 TOKEN_STRING_INITIALIZER
14015 (struct cmd_vf_split_drop_en_result,
14019 cmd_set_vf_split_drop_en_parsed(
14020 void *parsed_result,
14021 __rte_unused struct cmdline *cl,
14022 __rte_unused void *data)
14024 struct cmd_vf_split_drop_en_result *res = parsed_result;
14025 int ret = -ENOTSUP;
14026 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14028 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14031 #ifdef RTE_NET_IXGBE
14032 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
14039 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
14042 printf("invalid port_id %d\n", res->port_id);
14045 printf("not supported on port %d\n", res->port_id);
14048 printf("programming error: (%s)\n", strerror(-ret));
14052 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
14053 .f = cmd_set_vf_split_drop_en_parsed,
14055 .help_str = "set vf split drop <port_id> <vf_id> on|off",
14057 (void *)&cmd_vf_split_drop_en_set,
14058 (void *)&cmd_vf_split_drop_en_vf,
14059 (void *)&cmd_vf_split_drop_en_split,
14060 (void *)&cmd_vf_split_drop_en_drop,
14061 (void *)&cmd_vf_split_drop_en_port_id,
14062 (void *)&cmd_vf_split_drop_en_vf_id,
14063 (void *)&cmd_vf_split_drop_en_on_off,
14068 /* vf mac address configuration */
14070 /* Common result structure for vf mac address */
14071 struct cmd_set_vf_mac_addr_result {
14072 cmdline_fixed_string_t set;
14073 cmdline_fixed_string_t vf;
14074 cmdline_fixed_string_t mac;
14075 cmdline_fixed_string_t addr;
14078 struct rte_ether_addr mac_addr;
14082 /* Common CLI fields for vf split drop enable disable */
14083 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
14084 TOKEN_STRING_INITIALIZER
14085 (struct cmd_set_vf_mac_addr_result,
14087 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
14088 TOKEN_STRING_INITIALIZER
14089 (struct cmd_set_vf_mac_addr_result,
14091 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
14092 TOKEN_STRING_INITIALIZER
14093 (struct cmd_set_vf_mac_addr_result,
14095 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
14096 TOKEN_STRING_INITIALIZER
14097 (struct cmd_set_vf_mac_addr_result,
14099 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
14100 TOKEN_NUM_INITIALIZER
14101 (struct cmd_set_vf_mac_addr_result,
14103 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
14104 TOKEN_NUM_INITIALIZER
14105 (struct cmd_set_vf_mac_addr_result,
14107 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
14108 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
14112 cmd_set_vf_mac_addr_parsed(
14113 void *parsed_result,
14114 __rte_unused struct cmdline *cl,
14115 __rte_unused void *data)
14117 struct cmd_set_vf_mac_addr_result *res = parsed_result;
14118 int ret = -ENOTSUP;
14120 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14123 #ifdef RTE_NET_IXGBE
14124 if (ret == -ENOTSUP)
14125 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
14128 #ifdef RTE_NET_I40E
14129 if (ret == -ENOTSUP)
14130 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
14133 #ifdef RTE_NET_BNXT
14134 if (ret == -ENOTSUP)
14135 ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
14143 printf("invalid vf_id %d or mac_addr\n", res->vf_id);
14146 printf("invalid port_id %d\n", res->port_id);
14149 printf("function not implemented\n");
14152 printf("programming error: (%s)\n", strerror(-ret));
14156 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
14157 .f = cmd_set_vf_mac_addr_parsed,
14159 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
14161 (void *)&cmd_set_vf_mac_addr_set,
14162 (void *)&cmd_set_vf_mac_addr_vf,
14163 (void *)&cmd_set_vf_mac_addr_mac,
14164 (void *)&cmd_set_vf_mac_addr_addr,
14165 (void *)&cmd_set_vf_mac_addr_port_id,
14166 (void *)&cmd_set_vf_mac_addr_vf_id,
14167 (void *)&cmd_set_vf_mac_addr_mac_addr,
14172 /* MACsec configuration */
14174 /* Common result structure for MACsec offload enable */
14175 struct cmd_macsec_offload_on_result {
14176 cmdline_fixed_string_t set;
14177 cmdline_fixed_string_t macsec;
14178 cmdline_fixed_string_t offload;
14180 cmdline_fixed_string_t on;
14181 cmdline_fixed_string_t encrypt;
14182 cmdline_fixed_string_t en_on_off;
14183 cmdline_fixed_string_t replay_protect;
14184 cmdline_fixed_string_t rp_on_off;
14187 /* Common CLI fields for MACsec offload disable */
14188 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
14189 TOKEN_STRING_INITIALIZER
14190 (struct cmd_macsec_offload_on_result,
14192 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
14193 TOKEN_STRING_INITIALIZER
14194 (struct cmd_macsec_offload_on_result,
14196 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
14197 TOKEN_STRING_INITIALIZER
14198 (struct cmd_macsec_offload_on_result,
14199 offload, "offload");
14200 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
14201 TOKEN_NUM_INITIALIZER
14202 (struct cmd_macsec_offload_on_result,
14204 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
14205 TOKEN_STRING_INITIALIZER
14206 (struct cmd_macsec_offload_on_result,
14208 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
14209 TOKEN_STRING_INITIALIZER
14210 (struct cmd_macsec_offload_on_result,
14211 encrypt, "encrypt");
14212 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
14213 TOKEN_STRING_INITIALIZER
14214 (struct cmd_macsec_offload_on_result,
14215 en_on_off, "on#off");
14216 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
14217 TOKEN_STRING_INITIALIZER
14218 (struct cmd_macsec_offload_on_result,
14219 replay_protect, "replay-protect");
14220 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
14221 TOKEN_STRING_INITIALIZER
14222 (struct cmd_macsec_offload_on_result,
14223 rp_on_off, "on#off");
14226 cmd_set_macsec_offload_on_parsed(
14227 void *parsed_result,
14228 __rte_unused struct cmdline *cl,
14229 __rte_unused void *data)
14231 struct cmd_macsec_offload_on_result *res = parsed_result;
14232 int ret = -ENOTSUP;
14233 portid_t port_id = res->port_id;
14234 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
14235 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
14236 struct rte_eth_dev_info dev_info;
14238 if (port_id_is_invalid(port_id, ENABLED_WARN))
14240 if (!port_is_stopped(port_id)) {
14241 printf("Please stop port %d first\n", port_id);
14245 ret = eth_dev_info_get_print_err(port_id, &dev_info);
14249 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
14250 #ifdef RTE_NET_IXGBE
14251 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
14259 ports[port_id].dev_conf.txmode.offloads |=
14260 DEV_TX_OFFLOAD_MACSEC_INSERT;
14261 cmd_reconfig_device_queue(port_id, 1, 1);
14264 printf("invalid port_id %d\n", port_id);
14267 printf("not supported on port %d\n", port_id);
14270 printf("programming error: (%s)\n", strerror(-ret));
14274 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
14275 .f = cmd_set_macsec_offload_on_parsed,
14277 .help_str = "set macsec offload <port_id> on "
14278 "encrypt on|off replay-protect on|off",
14280 (void *)&cmd_macsec_offload_on_set,
14281 (void *)&cmd_macsec_offload_on_macsec,
14282 (void *)&cmd_macsec_offload_on_offload,
14283 (void *)&cmd_macsec_offload_on_port_id,
14284 (void *)&cmd_macsec_offload_on_on,
14285 (void *)&cmd_macsec_offload_on_encrypt,
14286 (void *)&cmd_macsec_offload_on_en_on_off,
14287 (void *)&cmd_macsec_offload_on_replay_protect,
14288 (void *)&cmd_macsec_offload_on_rp_on_off,
14293 /* Common result structure for MACsec offload disable */
14294 struct cmd_macsec_offload_off_result {
14295 cmdline_fixed_string_t set;
14296 cmdline_fixed_string_t macsec;
14297 cmdline_fixed_string_t offload;
14299 cmdline_fixed_string_t off;
14302 /* Common CLI fields for MACsec offload disable */
14303 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
14304 TOKEN_STRING_INITIALIZER
14305 (struct cmd_macsec_offload_off_result,
14307 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
14308 TOKEN_STRING_INITIALIZER
14309 (struct cmd_macsec_offload_off_result,
14311 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
14312 TOKEN_STRING_INITIALIZER
14313 (struct cmd_macsec_offload_off_result,
14314 offload, "offload");
14315 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
14316 TOKEN_NUM_INITIALIZER
14317 (struct cmd_macsec_offload_off_result,
14319 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
14320 TOKEN_STRING_INITIALIZER
14321 (struct cmd_macsec_offload_off_result,
14325 cmd_set_macsec_offload_off_parsed(
14326 void *parsed_result,
14327 __rte_unused struct cmdline *cl,
14328 __rte_unused void *data)
14330 struct cmd_macsec_offload_off_result *res = parsed_result;
14331 int ret = -ENOTSUP;
14332 struct rte_eth_dev_info dev_info;
14333 portid_t port_id = res->port_id;
14335 if (port_id_is_invalid(port_id, ENABLED_WARN))
14337 if (!port_is_stopped(port_id)) {
14338 printf("Please stop port %d first\n", port_id);
14342 ret = eth_dev_info_get_print_err(port_id, &dev_info);
14346 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
14347 #ifdef RTE_NET_IXGBE
14348 ret = rte_pmd_ixgbe_macsec_disable(port_id);
14353 ports[port_id].dev_conf.txmode.offloads &=
14354 ~DEV_TX_OFFLOAD_MACSEC_INSERT;
14355 cmd_reconfig_device_queue(port_id, 1, 1);
14358 printf("invalid port_id %d\n", port_id);
14361 printf("not supported on port %d\n", port_id);
14364 printf("programming error: (%s)\n", strerror(-ret));
14368 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
14369 .f = cmd_set_macsec_offload_off_parsed,
14371 .help_str = "set macsec offload <port_id> off",
14373 (void *)&cmd_macsec_offload_off_set,
14374 (void *)&cmd_macsec_offload_off_macsec,
14375 (void *)&cmd_macsec_offload_off_offload,
14376 (void *)&cmd_macsec_offload_off_port_id,
14377 (void *)&cmd_macsec_offload_off_off,
14382 /* Common result structure for MACsec secure connection configure */
14383 struct cmd_macsec_sc_result {
14384 cmdline_fixed_string_t set;
14385 cmdline_fixed_string_t macsec;
14386 cmdline_fixed_string_t sc;
14387 cmdline_fixed_string_t tx_rx;
14389 struct rte_ether_addr mac;
14393 /* Common CLI fields for MACsec secure connection configure */
14394 cmdline_parse_token_string_t cmd_macsec_sc_set =
14395 TOKEN_STRING_INITIALIZER
14396 (struct cmd_macsec_sc_result,
14398 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
14399 TOKEN_STRING_INITIALIZER
14400 (struct cmd_macsec_sc_result,
14402 cmdline_parse_token_string_t cmd_macsec_sc_sc =
14403 TOKEN_STRING_INITIALIZER
14404 (struct cmd_macsec_sc_result,
14406 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
14407 TOKEN_STRING_INITIALIZER
14408 (struct cmd_macsec_sc_result,
14410 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
14411 TOKEN_NUM_INITIALIZER
14412 (struct cmd_macsec_sc_result,
14414 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
14415 TOKEN_ETHERADDR_INITIALIZER
14416 (struct cmd_macsec_sc_result,
14418 cmdline_parse_token_num_t cmd_macsec_sc_pi =
14419 TOKEN_NUM_INITIALIZER
14420 (struct cmd_macsec_sc_result,
14424 cmd_set_macsec_sc_parsed(
14425 void *parsed_result,
14426 __rte_unused struct cmdline *cl,
14427 __rte_unused void *data)
14429 struct cmd_macsec_sc_result *res = parsed_result;
14430 int ret = -ENOTSUP;
14431 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
14433 #ifdef RTE_NET_IXGBE
14435 rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
14436 res->mac.addr_bytes) :
14437 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
14438 res->mac.addr_bytes, res->pi);
14440 RTE_SET_USED(is_tx);
14446 printf("invalid port_id %d\n", res->port_id);
14449 printf("not supported on port %d\n", res->port_id);
14452 printf("programming error: (%s)\n", strerror(-ret));
14456 cmdline_parse_inst_t cmd_set_macsec_sc = {
14457 .f = cmd_set_macsec_sc_parsed,
14459 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
14461 (void *)&cmd_macsec_sc_set,
14462 (void *)&cmd_macsec_sc_macsec,
14463 (void *)&cmd_macsec_sc_sc,
14464 (void *)&cmd_macsec_sc_tx_rx,
14465 (void *)&cmd_macsec_sc_port_id,
14466 (void *)&cmd_macsec_sc_mac,
14467 (void *)&cmd_macsec_sc_pi,
14472 /* Common result structure for MACsec secure connection configure */
14473 struct cmd_macsec_sa_result {
14474 cmdline_fixed_string_t set;
14475 cmdline_fixed_string_t macsec;
14476 cmdline_fixed_string_t sa;
14477 cmdline_fixed_string_t tx_rx;
14482 cmdline_fixed_string_t key;
14485 /* Common CLI fields for MACsec secure connection configure */
14486 cmdline_parse_token_string_t cmd_macsec_sa_set =
14487 TOKEN_STRING_INITIALIZER
14488 (struct cmd_macsec_sa_result,
14490 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
14491 TOKEN_STRING_INITIALIZER
14492 (struct cmd_macsec_sa_result,
14494 cmdline_parse_token_string_t cmd_macsec_sa_sa =
14495 TOKEN_STRING_INITIALIZER
14496 (struct cmd_macsec_sa_result,
14498 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
14499 TOKEN_STRING_INITIALIZER
14500 (struct cmd_macsec_sa_result,
14502 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
14503 TOKEN_NUM_INITIALIZER
14504 (struct cmd_macsec_sa_result,
14506 cmdline_parse_token_num_t cmd_macsec_sa_idx =
14507 TOKEN_NUM_INITIALIZER
14508 (struct cmd_macsec_sa_result,
14510 cmdline_parse_token_num_t cmd_macsec_sa_an =
14511 TOKEN_NUM_INITIALIZER
14512 (struct cmd_macsec_sa_result,
14514 cmdline_parse_token_num_t cmd_macsec_sa_pn =
14515 TOKEN_NUM_INITIALIZER
14516 (struct cmd_macsec_sa_result,
14518 cmdline_parse_token_string_t cmd_macsec_sa_key =
14519 TOKEN_STRING_INITIALIZER
14520 (struct cmd_macsec_sa_result,
14524 cmd_set_macsec_sa_parsed(
14525 void *parsed_result,
14526 __rte_unused struct cmdline *cl,
14527 __rte_unused void *data)
14529 struct cmd_macsec_sa_result *res = parsed_result;
14530 int ret = -ENOTSUP;
14531 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
14532 uint8_t key[16] = { 0 };
14538 key_len = strlen(res->key) / 2;
14542 for (i = 0; i < key_len; i++) {
14543 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
14546 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
14549 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
14552 #ifdef RTE_NET_IXGBE
14554 rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
14555 res->idx, res->an, res->pn, key) :
14556 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
14557 res->idx, res->an, res->pn, key);
14559 RTE_SET_USED(is_tx);
14566 printf("invalid idx %d or an %d\n", res->idx, res->an);
14569 printf("invalid port_id %d\n", res->port_id);
14572 printf("not supported on port %d\n", res->port_id);
14575 printf("programming error: (%s)\n", strerror(-ret));
14579 cmdline_parse_inst_t cmd_set_macsec_sa = {
14580 .f = cmd_set_macsec_sa_parsed,
14582 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
14584 (void *)&cmd_macsec_sa_set,
14585 (void *)&cmd_macsec_sa_macsec,
14586 (void *)&cmd_macsec_sa_sa,
14587 (void *)&cmd_macsec_sa_tx_rx,
14588 (void *)&cmd_macsec_sa_port_id,
14589 (void *)&cmd_macsec_sa_idx,
14590 (void *)&cmd_macsec_sa_an,
14591 (void *)&cmd_macsec_sa_pn,
14592 (void *)&cmd_macsec_sa_key,
14597 /* VF unicast promiscuous mode configuration */
14599 /* Common result structure for VF unicast promiscuous mode */
14600 struct cmd_vf_promisc_result {
14601 cmdline_fixed_string_t set;
14602 cmdline_fixed_string_t vf;
14603 cmdline_fixed_string_t promisc;
14606 cmdline_fixed_string_t on_off;
14609 /* Common CLI fields for VF unicast promiscuous mode enable disable */
14610 cmdline_parse_token_string_t cmd_vf_promisc_set =
14611 TOKEN_STRING_INITIALIZER
14612 (struct cmd_vf_promisc_result,
14614 cmdline_parse_token_string_t cmd_vf_promisc_vf =
14615 TOKEN_STRING_INITIALIZER
14616 (struct cmd_vf_promisc_result,
14618 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
14619 TOKEN_STRING_INITIALIZER
14620 (struct cmd_vf_promisc_result,
14621 promisc, "promisc");
14622 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
14623 TOKEN_NUM_INITIALIZER
14624 (struct cmd_vf_promisc_result,
14626 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
14627 TOKEN_NUM_INITIALIZER
14628 (struct cmd_vf_promisc_result,
14630 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
14631 TOKEN_STRING_INITIALIZER
14632 (struct cmd_vf_promisc_result,
14636 cmd_set_vf_promisc_parsed(
14637 void *parsed_result,
14638 __rte_unused struct cmdline *cl,
14639 __rte_unused void *data)
14641 struct cmd_vf_promisc_result *res = parsed_result;
14642 int ret = -ENOTSUP;
14644 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14646 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14649 #ifdef RTE_NET_I40E
14650 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
14651 res->vf_id, is_on);
14658 printf("invalid vf_id %d\n", res->vf_id);
14661 printf("invalid port_id %d\n", res->port_id);
14664 printf("function not implemented\n");
14667 printf("programming error: (%s)\n", strerror(-ret));
14671 cmdline_parse_inst_t cmd_set_vf_promisc = {
14672 .f = cmd_set_vf_promisc_parsed,
14674 .help_str = "set vf promisc <port_id> <vf_id> on|off: "
14675 "Set unicast promiscuous mode for a VF from the PF",
14677 (void *)&cmd_vf_promisc_set,
14678 (void *)&cmd_vf_promisc_vf,
14679 (void *)&cmd_vf_promisc_promisc,
14680 (void *)&cmd_vf_promisc_port_id,
14681 (void *)&cmd_vf_promisc_vf_id,
14682 (void *)&cmd_vf_promisc_on_off,
14687 /* VF multicast promiscuous mode configuration */
14689 /* Common result structure for VF multicast promiscuous mode */
14690 struct cmd_vf_allmulti_result {
14691 cmdline_fixed_string_t set;
14692 cmdline_fixed_string_t vf;
14693 cmdline_fixed_string_t allmulti;
14696 cmdline_fixed_string_t on_off;
14699 /* Common CLI fields for VF multicast promiscuous mode enable disable */
14700 cmdline_parse_token_string_t cmd_vf_allmulti_set =
14701 TOKEN_STRING_INITIALIZER
14702 (struct cmd_vf_allmulti_result,
14704 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
14705 TOKEN_STRING_INITIALIZER
14706 (struct cmd_vf_allmulti_result,
14708 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
14709 TOKEN_STRING_INITIALIZER
14710 (struct cmd_vf_allmulti_result,
14711 allmulti, "allmulti");
14712 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
14713 TOKEN_NUM_INITIALIZER
14714 (struct cmd_vf_allmulti_result,
14716 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
14717 TOKEN_NUM_INITIALIZER
14718 (struct cmd_vf_allmulti_result,
14720 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
14721 TOKEN_STRING_INITIALIZER
14722 (struct cmd_vf_allmulti_result,
14726 cmd_set_vf_allmulti_parsed(
14727 void *parsed_result,
14728 __rte_unused struct cmdline *cl,
14729 __rte_unused void *data)
14731 struct cmd_vf_allmulti_result *res = parsed_result;
14732 int ret = -ENOTSUP;
14734 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14736 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14739 #ifdef RTE_NET_I40E
14740 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
14741 res->vf_id, is_on);
14748 printf("invalid vf_id %d\n", res->vf_id);
14751 printf("invalid port_id %d\n", res->port_id);
14754 printf("function not implemented\n");
14757 printf("programming error: (%s)\n", strerror(-ret));
14761 cmdline_parse_inst_t cmd_set_vf_allmulti = {
14762 .f = cmd_set_vf_allmulti_parsed,
14764 .help_str = "set vf allmulti <port_id> <vf_id> on|off: "
14765 "Set multicast promiscuous mode for a VF from the PF",
14767 (void *)&cmd_vf_allmulti_set,
14768 (void *)&cmd_vf_allmulti_vf,
14769 (void *)&cmd_vf_allmulti_allmulti,
14770 (void *)&cmd_vf_allmulti_port_id,
14771 (void *)&cmd_vf_allmulti_vf_id,
14772 (void *)&cmd_vf_allmulti_on_off,
14777 /* vf broadcast mode configuration */
14779 /* Common result structure for vf broadcast */
14780 struct cmd_set_vf_broadcast_result {
14781 cmdline_fixed_string_t set;
14782 cmdline_fixed_string_t vf;
14783 cmdline_fixed_string_t broadcast;
14786 cmdline_fixed_string_t on_off;
14789 /* Common CLI fields for vf broadcast enable disable */
14790 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
14791 TOKEN_STRING_INITIALIZER
14792 (struct cmd_set_vf_broadcast_result,
14794 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
14795 TOKEN_STRING_INITIALIZER
14796 (struct cmd_set_vf_broadcast_result,
14798 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
14799 TOKEN_STRING_INITIALIZER
14800 (struct cmd_set_vf_broadcast_result,
14801 broadcast, "broadcast");
14802 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
14803 TOKEN_NUM_INITIALIZER
14804 (struct cmd_set_vf_broadcast_result,
14806 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
14807 TOKEN_NUM_INITIALIZER
14808 (struct cmd_set_vf_broadcast_result,
14810 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
14811 TOKEN_STRING_INITIALIZER
14812 (struct cmd_set_vf_broadcast_result,
14816 cmd_set_vf_broadcast_parsed(
14817 void *parsed_result,
14818 __rte_unused struct cmdline *cl,
14819 __rte_unused void *data)
14821 struct cmd_set_vf_broadcast_result *res = parsed_result;
14822 int ret = -ENOTSUP;
14824 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14826 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14829 #ifdef RTE_NET_I40E
14830 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
14831 res->vf_id, is_on);
14838 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
14841 printf("invalid port_id %d\n", res->port_id);
14844 printf("function not implemented\n");
14847 printf("programming error: (%s)\n", strerror(-ret));
14851 cmdline_parse_inst_t cmd_set_vf_broadcast = {
14852 .f = cmd_set_vf_broadcast_parsed,
14854 .help_str = "set vf broadcast <port_id> <vf_id> on|off",
14856 (void *)&cmd_set_vf_broadcast_set,
14857 (void *)&cmd_set_vf_broadcast_vf,
14858 (void *)&cmd_set_vf_broadcast_broadcast,
14859 (void *)&cmd_set_vf_broadcast_port_id,
14860 (void *)&cmd_set_vf_broadcast_vf_id,
14861 (void *)&cmd_set_vf_broadcast_on_off,
14866 /* vf vlan tag configuration */
14868 /* Common result structure for vf vlan tag */
14869 struct cmd_set_vf_vlan_tag_result {
14870 cmdline_fixed_string_t set;
14871 cmdline_fixed_string_t vf;
14872 cmdline_fixed_string_t vlan;
14873 cmdline_fixed_string_t tag;
14876 cmdline_fixed_string_t on_off;
14879 /* Common CLI fields for vf vlan tag enable disable */
14880 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
14881 TOKEN_STRING_INITIALIZER
14882 (struct cmd_set_vf_vlan_tag_result,
14884 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
14885 TOKEN_STRING_INITIALIZER
14886 (struct cmd_set_vf_vlan_tag_result,
14888 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
14889 TOKEN_STRING_INITIALIZER
14890 (struct cmd_set_vf_vlan_tag_result,
14892 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
14893 TOKEN_STRING_INITIALIZER
14894 (struct cmd_set_vf_vlan_tag_result,
14896 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
14897 TOKEN_NUM_INITIALIZER
14898 (struct cmd_set_vf_vlan_tag_result,
14900 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
14901 TOKEN_NUM_INITIALIZER
14902 (struct cmd_set_vf_vlan_tag_result,
14904 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
14905 TOKEN_STRING_INITIALIZER
14906 (struct cmd_set_vf_vlan_tag_result,
14910 cmd_set_vf_vlan_tag_parsed(
14911 void *parsed_result,
14912 __rte_unused struct cmdline *cl,
14913 __rte_unused void *data)
14915 struct cmd_set_vf_vlan_tag_result *res = parsed_result;
14916 int ret = -ENOTSUP;
14918 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14920 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14923 #ifdef RTE_NET_I40E
14924 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
14925 res->vf_id, is_on);
14932 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
14935 printf("invalid port_id %d\n", res->port_id);
14938 printf("function not implemented\n");
14941 printf("programming error: (%s)\n", strerror(-ret));
14945 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
14946 .f = cmd_set_vf_vlan_tag_parsed,
14948 .help_str = "set vf vlan tag <port_id> <vf_id> on|off",
14950 (void *)&cmd_set_vf_vlan_tag_set,
14951 (void *)&cmd_set_vf_vlan_tag_vf,
14952 (void *)&cmd_set_vf_vlan_tag_vlan,
14953 (void *)&cmd_set_vf_vlan_tag_tag,
14954 (void *)&cmd_set_vf_vlan_tag_port_id,
14955 (void *)&cmd_set_vf_vlan_tag_vf_id,
14956 (void *)&cmd_set_vf_vlan_tag_on_off,
14961 /* Common definition of VF and TC TX bandwidth configuration */
14962 struct cmd_vf_tc_bw_result {
14963 cmdline_fixed_string_t set;
14964 cmdline_fixed_string_t vf;
14965 cmdline_fixed_string_t tc;
14966 cmdline_fixed_string_t tx;
14967 cmdline_fixed_string_t min_bw;
14968 cmdline_fixed_string_t max_bw;
14969 cmdline_fixed_string_t strict_link_prio;
14974 cmdline_fixed_string_t bw_list;
14978 cmdline_parse_token_string_t cmd_vf_tc_bw_set =
14979 TOKEN_STRING_INITIALIZER
14980 (struct cmd_vf_tc_bw_result,
14982 cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
14983 TOKEN_STRING_INITIALIZER
14984 (struct cmd_vf_tc_bw_result,
14986 cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
14987 TOKEN_STRING_INITIALIZER
14988 (struct cmd_vf_tc_bw_result,
14990 cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
14991 TOKEN_STRING_INITIALIZER
14992 (struct cmd_vf_tc_bw_result,
14994 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio =
14995 TOKEN_STRING_INITIALIZER
14996 (struct cmd_vf_tc_bw_result,
14997 strict_link_prio, "strict-link-priority");
14998 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw =
14999 TOKEN_STRING_INITIALIZER
15000 (struct cmd_vf_tc_bw_result,
15001 min_bw, "min-bandwidth");
15002 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
15003 TOKEN_STRING_INITIALIZER
15004 (struct cmd_vf_tc_bw_result,
15005 max_bw, "max-bandwidth");
15006 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
15007 TOKEN_NUM_INITIALIZER
15008 (struct cmd_vf_tc_bw_result,
15010 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
15011 TOKEN_NUM_INITIALIZER
15012 (struct cmd_vf_tc_bw_result,
15014 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no =
15015 TOKEN_NUM_INITIALIZER
15016 (struct cmd_vf_tc_bw_result,
15018 cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
15019 TOKEN_NUM_INITIALIZER
15020 (struct cmd_vf_tc_bw_result,
15022 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
15023 TOKEN_STRING_INITIALIZER
15024 (struct cmd_vf_tc_bw_result,
15026 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map =
15027 TOKEN_NUM_INITIALIZER
15028 (struct cmd_vf_tc_bw_result,
15031 /* VF max bandwidth setting */
15033 cmd_vf_max_bw_parsed(
15034 void *parsed_result,
15035 __rte_unused struct cmdline *cl,
15036 __rte_unused void *data)
15038 struct cmd_vf_tc_bw_result *res = parsed_result;
15039 int ret = -ENOTSUP;
15041 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15044 #ifdef RTE_NET_I40E
15045 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id,
15046 res->vf_id, res->bw);
15053 printf("invalid vf_id %d or bandwidth %d\n",
15054 res->vf_id, res->bw);
15057 printf("invalid port_id %d\n", res->port_id);
15060 printf("function not implemented\n");
15063 printf("programming error: (%s)\n", strerror(-ret));
15067 cmdline_parse_inst_t cmd_vf_max_bw = {
15068 .f = cmd_vf_max_bw_parsed,
15070 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
15072 (void *)&cmd_vf_tc_bw_set,
15073 (void *)&cmd_vf_tc_bw_vf,
15074 (void *)&cmd_vf_tc_bw_tx,
15075 (void *)&cmd_vf_tc_bw_max_bw,
15076 (void *)&cmd_vf_tc_bw_port_id,
15077 (void *)&cmd_vf_tc_bw_vf_id,
15078 (void *)&cmd_vf_tc_bw_bw,
15084 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
15089 const char *p, *p0 = str;
15096 p = strchr(p0, '(');
15098 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
15102 p0 = strchr(p, ')');
15104 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
15108 if (size >= sizeof(s)) {
15109 printf("The string size exceeds the internal buffer size\n");
15112 snprintf(s, sizeof(s), "%.*s", size, p);
15113 ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
15115 printf("Failed to get the bandwidth list. ");
15119 for (i = 0; i < ret; i++)
15120 bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
15125 /* TC min bandwidth setting */
15127 cmd_vf_tc_min_bw_parsed(
15128 void *parsed_result,
15129 __rte_unused struct cmdline *cl,
15130 __rte_unused void *data)
15132 struct cmd_vf_tc_bw_result *res = parsed_result;
15135 int ret = -ENOTSUP;
15137 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15140 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
15144 #ifdef RTE_NET_I40E
15145 ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
15153 printf("invalid vf_id %d or bandwidth\n", res->vf_id);
15156 printf("invalid port_id %d\n", res->port_id);
15159 printf("function not implemented\n");
15162 printf("programming error: (%s)\n", strerror(-ret));
15166 cmdline_parse_inst_t cmd_vf_tc_min_bw = {
15167 .f = cmd_vf_tc_min_bw_parsed,
15169 .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
15170 " <bw1, bw2, ...>",
15172 (void *)&cmd_vf_tc_bw_set,
15173 (void *)&cmd_vf_tc_bw_vf,
15174 (void *)&cmd_vf_tc_bw_tc,
15175 (void *)&cmd_vf_tc_bw_tx,
15176 (void *)&cmd_vf_tc_bw_min_bw,
15177 (void *)&cmd_vf_tc_bw_port_id,
15178 (void *)&cmd_vf_tc_bw_vf_id,
15179 (void *)&cmd_vf_tc_bw_bw_list,
15185 cmd_tc_min_bw_parsed(
15186 void *parsed_result,
15187 __rte_unused struct cmdline *cl,
15188 __rte_unused void *data)
15190 struct cmd_vf_tc_bw_result *res = parsed_result;
15191 struct rte_port *port;
15194 int ret = -ENOTSUP;
15196 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15199 port = &ports[res->port_id];
15200 /** Check if the port is not started **/
15201 if (port->port_status != RTE_PORT_STOPPED) {
15202 printf("Please stop port %d first\n", res->port_id);
15206 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
15210 #ifdef RTE_NET_IXGBE
15211 ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw);
15218 printf("invalid bandwidth\n");
15221 printf("invalid port_id %d\n", res->port_id);
15224 printf("function not implemented\n");
15227 printf("programming error: (%s)\n", strerror(-ret));
15231 cmdline_parse_inst_t cmd_tc_min_bw = {
15232 .f = cmd_tc_min_bw_parsed,
15234 .help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>",
15236 (void *)&cmd_vf_tc_bw_set,
15237 (void *)&cmd_vf_tc_bw_tc,
15238 (void *)&cmd_vf_tc_bw_tx,
15239 (void *)&cmd_vf_tc_bw_min_bw,
15240 (void *)&cmd_vf_tc_bw_port_id,
15241 (void *)&cmd_vf_tc_bw_bw_list,
15246 /* TC max bandwidth setting */
15248 cmd_vf_tc_max_bw_parsed(
15249 void *parsed_result,
15250 __rte_unused struct cmdline *cl,
15251 __rte_unused void *data)
15253 struct cmd_vf_tc_bw_result *res = parsed_result;
15254 int ret = -ENOTSUP;
15256 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15259 #ifdef RTE_NET_I40E
15260 ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id,
15261 res->tc_no, res->bw);
15268 printf("invalid vf_id %d, tc_no %d or bandwidth %d\n",
15269 res->vf_id, res->tc_no, res->bw);
15272 printf("invalid port_id %d\n", res->port_id);
15275 printf("function not implemented\n");
15278 printf("programming error: (%s)\n", strerror(-ret));
15282 cmdline_parse_inst_t cmd_vf_tc_max_bw = {
15283 .f = cmd_vf_tc_max_bw_parsed,
15285 .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>"
15288 (void *)&cmd_vf_tc_bw_set,
15289 (void *)&cmd_vf_tc_bw_vf,
15290 (void *)&cmd_vf_tc_bw_tc,
15291 (void *)&cmd_vf_tc_bw_tx,
15292 (void *)&cmd_vf_tc_bw_max_bw,
15293 (void *)&cmd_vf_tc_bw_port_id,
15294 (void *)&cmd_vf_tc_bw_vf_id,
15295 (void *)&cmd_vf_tc_bw_tc_no,
15296 (void *)&cmd_vf_tc_bw_bw,
15301 /** Set VXLAN encapsulation details */
15302 struct cmd_set_vxlan_result {
15303 cmdline_fixed_string_t set;
15304 cmdline_fixed_string_t vxlan;
15305 cmdline_fixed_string_t pos_token;
15306 cmdline_fixed_string_t ip_version;
15307 uint32_t vlan_present:1;
15311 cmdline_ipaddr_t ip_src;
15312 cmdline_ipaddr_t ip_dst;
15316 struct rte_ether_addr eth_src;
15317 struct rte_ether_addr eth_dst;
15320 cmdline_parse_token_string_t cmd_set_vxlan_set =
15321 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, set, "set");
15322 cmdline_parse_token_string_t cmd_set_vxlan_vxlan =
15323 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan, "vxlan");
15324 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_tos_ttl =
15325 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
15327 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_with_vlan =
15328 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
15329 "vxlan-with-vlan");
15330 cmdline_parse_token_string_t cmd_set_vxlan_ip_version =
15331 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15333 cmdline_parse_token_string_t cmd_set_vxlan_ip_version_value =
15334 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, ip_version,
15336 cmdline_parse_token_string_t cmd_set_vxlan_vni =
15337 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15339 cmdline_parse_token_num_t cmd_set_vxlan_vni_value =
15340 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, vni, UINT32);
15341 cmdline_parse_token_string_t cmd_set_vxlan_udp_src =
15342 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15344 cmdline_parse_token_num_t cmd_set_vxlan_udp_src_value =
15345 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_src, UINT16);
15346 cmdline_parse_token_string_t cmd_set_vxlan_udp_dst =
15347 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15349 cmdline_parse_token_num_t cmd_set_vxlan_udp_dst_value =
15350 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_dst, UINT16);
15351 cmdline_parse_token_string_t cmd_set_vxlan_ip_tos =
15352 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15354 cmdline_parse_token_num_t cmd_set_vxlan_ip_tos_value =
15355 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tos, UINT8);
15356 cmdline_parse_token_string_t cmd_set_vxlan_ip_ttl =
15357 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15359 cmdline_parse_token_num_t cmd_set_vxlan_ip_ttl_value =
15360 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, ttl, UINT8);
15361 cmdline_parse_token_string_t cmd_set_vxlan_ip_src =
15362 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15364 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_src_value =
15365 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_src);
15366 cmdline_parse_token_string_t cmd_set_vxlan_ip_dst =
15367 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15369 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_dst_value =
15370 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_dst);
15371 cmdline_parse_token_string_t cmd_set_vxlan_vlan =
15372 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15374 cmdline_parse_token_num_t cmd_set_vxlan_vlan_value =
15375 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tci, UINT16);
15376 cmdline_parse_token_string_t cmd_set_vxlan_eth_src =
15377 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15379 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_src_value =
15380 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_src);
15381 cmdline_parse_token_string_t cmd_set_vxlan_eth_dst =
15382 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15384 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_dst_value =
15385 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_dst);
15387 static void cmd_set_vxlan_parsed(void *parsed_result,
15388 __rte_unused struct cmdline *cl,
15389 __rte_unused void *data)
15391 struct cmd_set_vxlan_result *res = parsed_result;
15396 .vxlan_id = rte_cpu_to_be_32(res->vni) & RTE_BE32(0x00ffffff),
15399 vxlan_encap_conf.select_tos_ttl = 0;
15400 if (strcmp(res->vxlan, "vxlan") == 0)
15401 vxlan_encap_conf.select_vlan = 0;
15402 else if (strcmp(res->vxlan, "vxlan-with-vlan") == 0)
15403 vxlan_encap_conf.select_vlan = 1;
15404 else if (strcmp(res->vxlan, "vxlan-tos-ttl") == 0) {
15405 vxlan_encap_conf.select_vlan = 0;
15406 vxlan_encap_conf.select_tos_ttl = 1;
15408 if (strcmp(res->ip_version, "ipv4") == 0)
15409 vxlan_encap_conf.select_ipv4 = 1;
15410 else if (strcmp(res->ip_version, "ipv6") == 0)
15411 vxlan_encap_conf.select_ipv4 = 0;
15414 rte_memcpy(vxlan_encap_conf.vni, &id.vni[1], 3);
15415 vxlan_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
15416 vxlan_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
15417 vxlan_encap_conf.ip_tos = res->tos;
15418 vxlan_encap_conf.ip_ttl = res->ttl;
15419 if (vxlan_encap_conf.select_ipv4) {
15420 IPV4_ADDR_TO_UINT(res->ip_src, vxlan_encap_conf.ipv4_src);
15421 IPV4_ADDR_TO_UINT(res->ip_dst, vxlan_encap_conf.ipv4_dst);
15423 IPV6_ADDR_TO_ARRAY(res->ip_src, vxlan_encap_conf.ipv6_src);
15424 IPV6_ADDR_TO_ARRAY(res->ip_dst, vxlan_encap_conf.ipv6_dst);
15426 if (vxlan_encap_conf.select_vlan)
15427 vxlan_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15428 rte_memcpy(vxlan_encap_conf.eth_src, res->eth_src.addr_bytes,
15429 RTE_ETHER_ADDR_LEN);
15430 rte_memcpy(vxlan_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15431 RTE_ETHER_ADDR_LEN);
15434 cmdline_parse_inst_t cmd_set_vxlan = {
15435 .f = cmd_set_vxlan_parsed,
15437 .help_str = "set vxlan ip-version ipv4|ipv6 vni <vni> udp-src"
15438 " <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst <ip-dst>"
15439 " eth-src <eth-src> eth-dst <eth-dst>",
15441 (void *)&cmd_set_vxlan_set,
15442 (void *)&cmd_set_vxlan_vxlan,
15443 (void *)&cmd_set_vxlan_ip_version,
15444 (void *)&cmd_set_vxlan_ip_version_value,
15445 (void *)&cmd_set_vxlan_vni,
15446 (void *)&cmd_set_vxlan_vni_value,
15447 (void *)&cmd_set_vxlan_udp_src,
15448 (void *)&cmd_set_vxlan_udp_src_value,
15449 (void *)&cmd_set_vxlan_udp_dst,
15450 (void *)&cmd_set_vxlan_udp_dst_value,
15451 (void *)&cmd_set_vxlan_ip_src,
15452 (void *)&cmd_set_vxlan_ip_src_value,
15453 (void *)&cmd_set_vxlan_ip_dst,
15454 (void *)&cmd_set_vxlan_ip_dst_value,
15455 (void *)&cmd_set_vxlan_eth_src,
15456 (void *)&cmd_set_vxlan_eth_src_value,
15457 (void *)&cmd_set_vxlan_eth_dst,
15458 (void *)&cmd_set_vxlan_eth_dst_value,
15463 cmdline_parse_inst_t cmd_set_vxlan_tos_ttl = {
15464 .f = cmd_set_vxlan_parsed,
15466 .help_str = "set vxlan-tos-ttl ip-version ipv4|ipv6 vni <vni> udp-src"
15467 " <udp-src> udp-dst <udp-dst> ip-tos <ip-tos> ip-ttl <ip-ttl>"
15468 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
15469 " eth-dst <eth-dst>",
15471 (void *)&cmd_set_vxlan_set,
15472 (void *)&cmd_set_vxlan_vxlan_tos_ttl,
15473 (void *)&cmd_set_vxlan_ip_version,
15474 (void *)&cmd_set_vxlan_ip_version_value,
15475 (void *)&cmd_set_vxlan_vni,
15476 (void *)&cmd_set_vxlan_vni_value,
15477 (void *)&cmd_set_vxlan_udp_src,
15478 (void *)&cmd_set_vxlan_udp_src_value,
15479 (void *)&cmd_set_vxlan_udp_dst,
15480 (void *)&cmd_set_vxlan_udp_dst_value,
15481 (void *)&cmd_set_vxlan_ip_tos,
15482 (void *)&cmd_set_vxlan_ip_tos_value,
15483 (void *)&cmd_set_vxlan_ip_ttl,
15484 (void *)&cmd_set_vxlan_ip_ttl_value,
15485 (void *)&cmd_set_vxlan_ip_src,
15486 (void *)&cmd_set_vxlan_ip_src_value,
15487 (void *)&cmd_set_vxlan_ip_dst,
15488 (void *)&cmd_set_vxlan_ip_dst_value,
15489 (void *)&cmd_set_vxlan_eth_src,
15490 (void *)&cmd_set_vxlan_eth_src_value,
15491 (void *)&cmd_set_vxlan_eth_dst,
15492 (void *)&cmd_set_vxlan_eth_dst_value,
15497 cmdline_parse_inst_t cmd_set_vxlan_with_vlan = {
15498 .f = cmd_set_vxlan_parsed,
15500 .help_str = "set vxlan-with-vlan ip-version ipv4|ipv6 vni <vni>"
15501 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst"
15502 " <ip-dst> vlan-tci <vlan-tci> eth-src <eth-src> eth-dst"
15505 (void *)&cmd_set_vxlan_set,
15506 (void *)&cmd_set_vxlan_vxlan_with_vlan,
15507 (void *)&cmd_set_vxlan_ip_version,
15508 (void *)&cmd_set_vxlan_ip_version_value,
15509 (void *)&cmd_set_vxlan_vni,
15510 (void *)&cmd_set_vxlan_vni_value,
15511 (void *)&cmd_set_vxlan_udp_src,
15512 (void *)&cmd_set_vxlan_udp_src_value,
15513 (void *)&cmd_set_vxlan_udp_dst,
15514 (void *)&cmd_set_vxlan_udp_dst_value,
15515 (void *)&cmd_set_vxlan_ip_src,
15516 (void *)&cmd_set_vxlan_ip_src_value,
15517 (void *)&cmd_set_vxlan_ip_dst,
15518 (void *)&cmd_set_vxlan_ip_dst_value,
15519 (void *)&cmd_set_vxlan_vlan,
15520 (void *)&cmd_set_vxlan_vlan_value,
15521 (void *)&cmd_set_vxlan_eth_src,
15522 (void *)&cmd_set_vxlan_eth_src_value,
15523 (void *)&cmd_set_vxlan_eth_dst,
15524 (void *)&cmd_set_vxlan_eth_dst_value,
15529 /** Set NVGRE encapsulation details */
15530 struct cmd_set_nvgre_result {
15531 cmdline_fixed_string_t set;
15532 cmdline_fixed_string_t nvgre;
15533 cmdline_fixed_string_t pos_token;
15534 cmdline_fixed_string_t ip_version;
15536 cmdline_ipaddr_t ip_src;
15537 cmdline_ipaddr_t ip_dst;
15539 struct rte_ether_addr eth_src;
15540 struct rte_ether_addr eth_dst;
15543 cmdline_parse_token_string_t cmd_set_nvgre_set =
15544 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, set, "set");
15545 cmdline_parse_token_string_t cmd_set_nvgre_nvgre =
15546 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre, "nvgre");
15547 cmdline_parse_token_string_t cmd_set_nvgre_nvgre_with_vlan =
15548 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre,
15549 "nvgre-with-vlan");
15550 cmdline_parse_token_string_t cmd_set_nvgre_ip_version =
15551 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15553 cmdline_parse_token_string_t cmd_set_nvgre_ip_version_value =
15554 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, ip_version,
15556 cmdline_parse_token_string_t cmd_set_nvgre_tni =
15557 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15559 cmdline_parse_token_num_t cmd_set_nvgre_tni_value =
15560 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tni, UINT32);
15561 cmdline_parse_token_string_t cmd_set_nvgre_ip_src =
15562 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15564 cmdline_parse_token_num_t cmd_set_nvgre_ip_src_value =
15565 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_src);
15566 cmdline_parse_token_string_t cmd_set_nvgre_ip_dst =
15567 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15569 cmdline_parse_token_ipaddr_t cmd_set_nvgre_ip_dst_value =
15570 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_dst);
15571 cmdline_parse_token_string_t cmd_set_nvgre_vlan =
15572 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15574 cmdline_parse_token_num_t cmd_set_nvgre_vlan_value =
15575 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tci, UINT16);
15576 cmdline_parse_token_string_t cmd_set_nvgre_eth_src =
15577 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15579 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_src_value =
15580 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_src);
15581 cmdline_parse_token_string_t cmd_set_nvgre_eth_dst =
15582 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15584 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_dst_value =
15585 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_dst);
15587 static void cmd_set_nvgre_parsed(void *parsed_result,
15588 __rte_unused struct cmdline *cl,
15589 __rte_unused void *data)
15591 struct cmd_set_nvgre_result *res = parsed_result;
15593 uint32_t nvgre_tni;
15596 .nvgre_tni = rte_cpu_to_be_32(res->tni) & RTE_BE32(0x00ffffff),
15599 if (strcmp(res->nvgre, "nvgre") == 0)
15600 nvgre_encap_conf.select_vlan = 0;
15601 else if (strcmp(res->nvgre, "nvgre-with-vlan") == 0)
15602 nvgre_encap_conf.select_vlan = 1;
15603 if (strcmp(res->ip_version, "ipv4") == 0)
15604 nvgre_encap_conf.select_ipv4 = 1;
15605 else if (strcmp(res->ip_version, "ipv6") == 0)
15606 nvgre_encap_conf.select_ipv4 = 0;
15609 rte_memcpy(nvgre_encap_conf.tni, &id.tni[1], 3);
15610 if (nvgre_encap_conf.select_ipv4) {
15611 IPV4_ADDR_TO_UINT(res->ip_src, nvgre_encap_conf.ipv4_src);
15612 IPV4_ADDR_TO_UINT(res->ip_dst, nvgre_encap_conf.ipv4_dst);
15614 IPV6_ADDR_TO_ARRAY(res->ip_src, nvgre_encap_conf.ipv6_src);
15615 IPV6_ADDR_TO_ARRAY(res->ip_dst, nvgre_encap_conf.ipv6_dst);
15617 if (nvgre_encap_conf.select_vlan)
15618 nvgre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15619 rte_memcpy(nvgre_encap_conf.eth_src, res->eth_src.addr_bytes,
15620 RTE_ETHER_ADDR_LEN);
15621 rte_memcpy(nvgre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15622 RTE_ETHER_ADDR_LEN);
15625 cmdline_parse_inst_t cmd_set_nvgre = {
15626 .f = cmd_set_nvgre_parsed,
15628 .help_str = "set nvgre ip-version <ipv4|ipv6> tni <tni> ip-src"
15629 " <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
15630 " eth-dst <eth-dst>",
15632 (void *)&cmd_set_nvgre_set,
15633 (void *)&cmd_set_nvgre_nvgre,
15634 (void *)&cmd_set_nvgre_ip_version,
15635 (void *)&cmd_set_nvgre_ip_version_value,
15636 (void *)&cmd_set_nvgre_tni,
15637 (void *)&cmd_set_nvgre_tni_value,
15638 (void *)&cmd_set_nvgre_ip_src,
15639 (void *)&cmd_set_nvgre_ip_src_value,
15640 (void *)&cmd_set_nvgre_ip_dst,
15641 (void *)&cmd_set_nvgre_ip_dst_value,
15642 (void *)&cmd_set_nvgre_eth_src,
15643 (void *)&cmd_set_nvgre_eth_src_value,
15644 (void *)&cmd_set_nvgre_eth_dst,
15645 (void *)&cmd_set_nvgre_eth_dst_value,
15650 cmdline_parse_inst_t cmd_set_nvgre_with_vlan = {
15651 .f = cmd_set_nvgre_parsed,
15653 .help_str = "set nvgre-with-vlan ip-version <ipv4|ipv6> tni <tni>"
15654 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
15655 " eth-src <eth-src> eth-dst <eth-dst>",
15657 (void *)&cmd_set_nvgre_set,
15658 (void *)&cmd_set_nvgre_nvgre_with_vlan,
15659 (void *)&cmd_set_nvgre_ip_version,
15660 (void *)&cmd_set_nvgre_ip_version_value,
15661 (void *)&cmd_set_nvgre_tni,
15662 (void *)&cmd_set_nvgre_tni_value,
15663 (void *)&cmd_set_nvgre_ip_src,
15664 (void *)&cmd_set_nvgre_ip_src_value,
15665 (void *)&cmd_set_nvgre_ip_dst,
15666 (void *)&cmd_set_nvgre_ip_dst_value,
15667 (void *)&cmd_set_nvgre_vlan,
15668 (void *)&cmd_set_nvgre_vlan_value,
15669 (void *)&cmd_set_nvgre_eth_src,
15670 (void *)&cmd_set_nvgre_eth_src_value,
15671 (void *)&cmd_set_nvgre_eth_dst,
15672 (void *)&cmd_set_nvgre_eth_dst_value,
15677 /** Set L2 encapsulation details */
15678 struct cmd_set_l2_encap_result {
15679 cmdline_fixed_string_t set;
15680 cmdline_fixed_string_t l2_encap;
15681 cmdline_fixed_string_t pos_token;
15682 cmdline_fixed_string_t ip_version;
15683 uint32_t vlan_present:1;
15685 struct rte_ether_addr eth_src;
15686 struct rte_ether_addr eth_dst;
15689 cmdline_parse_token_string_t cmd_set_l2_encap_set =
15690 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, set, "set");
15691 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap =
15692 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap, "l2_encap");
15693 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap_with_vlan =
15694 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap,
15695 "l2_encap-with-vlan");
15696 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version =
15697 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15699 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version_value =
15700 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, ip_version,
15702 cmdline_parse_token_string_t cmd_set_l2_encap_vlan =
15703 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15705 cmdline_parse_token_num_t cmd_set_l2_encap_vlan_value =
15706 TOKEN_NUM_INITIALIZER(struct cmd_set_l2_encap_result, tci, UINT16);
15707 cmdline_parse_token_string_t cmd_set_l2_encap_eth_src =
15708 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15710 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_src_value =
15711 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_src);
15712 cmdline_parse_token_string_t cmd_set_l2_encap_eth_dst =
15713 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15715 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_dst_value =
15716 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_dst);
15718 static void cmd_set_l2_encap_parsed(void *parsed_result,
15719 __rte_unused struct cmdline *cl,
15720 __rte_unused void *data)
15722 struct cmd_set_l2_encap_result *res = parsed_result;
15724 if (strcmp(res->l2_encap, "l2_encap") == 0)
15725 l2_encap_conf.select_vlan = 0;
15726 else if (strcmp(res->l2_encap, "l2_encap-with-vlan") == 0)
15727 l2_encap_conf.select_vlan = 1;
15728 if (strcmp(res->ip_version, "ipv4") == 0)
15729 l2_encap_conf.select_ipv4 = 1;
15730 else if (strcmp(res->ip_version, "ipv6") == 0)
15731 l2_encap_conf.select_ipv4 = 0;
15734 if (l2_encap_conf.select_vlan)
15735 l2_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15736 rte_memcpy(l2_encap_conf.eth_src, res->eth_src.addr_bytes,
15737 RTE_ETHER_ADDR_LEN);
15738 rte_memcpy(l2_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15739 RTE_ETHER_ADDR_LEN);
15742 cmdline_parse_inst_t cmd_set_l2_encap = {
15743 .f = cmd_set_l2_encap_parsed,
15745 .help_str = "set l2_encap ip-version ipv4|ipv6"
15746 " eth-src <eth-src> eth-dst <eth-dst>",
15748 (void *)&cmd_set_l2_encap_set,
15749 (void *)&cmd_set_l2_encap_l2_encap,
15750 (void *)&cmd_set_l2_encap_ip_version,
15751 (void *)&cmd_set_l2_encap_ip_version_value,
15752 (void *)&cmd_set_l2_encap_eth_src,
15753 (void *)&cmd_set_l2_encap_eth_src_value,
15754 (void *)&cmd_set_l2_encap_eth_dst,
15755 (void *)&cmd_set_l2_encap_eth_dst_value,
15760 cmdline_parse_inst_t cmd_set_l2_encap_with_vlan = {
15761 .f = cmd_set_l2_encap_parsed,
15763 .help_str = "set l2_encap-with-vlan ip-version ipv4|ipv6"
15764 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
15766 (void *)&cmd_set_l2_encap_set,
15767 (void *)&cmd_set_l2_encap_l2_encap_with_vlan,
15768 (void *)&cmd_set_l2_encap_ip_version,
15769 (void *)&cmd_set_l2_encap_ip_version_value,
15770 (void *)&cmd_set_l2_encap_vlan,
15771 (void *)&cmd_set_l2_encap_vlan_value,
15772 (void *)&cmd_set_l2_encap_eth_src,
15773 (void *)&cmd_set_l2_encap_eth_src_value,
15774 (void *)&cmd_set_l2_encap_eth_dst,
15775 (void *)&cmd_set_l2_encap_eth_dst_value,
15780 /** Set L2 decapsulation details */
15781 struct cmd_set_l2_decap_result {
15782 cmdline_fixed_string_t set;
15783 cmdline_fixed_string_t l2_decap;
15784 cmdline_fixed_string_t pos_token;
15785 uint32_t vlan_present:1;
15788 cmdline_parse_token_string_t cmd_set_l2_decap_set =
15789 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, set, "set");
15790 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap =
15791 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
15793 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap_with_vlan =
15794 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
15795 "l2_decap-with-vlan");
15797 static void cmd_set_l2_decap_parsed(void *parsed_result,
15798 __rte_unused struct cmdline *cl,
15799 __rte_unused void *data)
15801 struct cmd_set_l2_decap_result *res = parsed_result;
15803 if (strcmp(res->l2_decap, "l2_decap") == 0)
15804 l2_decap_conf.select_vlan = 0;
15805 else if (strcmp(res->l2_decap, "l2_decap-with-vlan") == 0)
15806 l2_decap_conf.select_vlan = 1;
15809 cmdline_parse_inst_t cmd_set_l2_decap = {
15810 .f = cmd_set_l2_decap_parsed,
15812 .help_str = "set l2_decap",
15814 (void *)&cmd_set_l2_decap_set,
15815 (void *)&cmd_set_l2_decap_l2_decap,
15820 cmdline_parse_inst_t cmd_set_l2_decap_with_vlan = {
15821 .f = cmd_set_l2_decap_parsed,
15823 .help_str = "set l2_decap-with-vlan",
15825 (void *)&cmd_set_l2_decap_set,
15826 (void *)&cmd_set_l2_decap_l2_decap_with_vlan,
15831 /** Set MPLSoGRE encapsulation details */
15832 struct cmd_set_mplsogre_encap_result {
15833 cmdline_fixed_string_t set;
15834 cmdline_fixed_string_t mplsogre;
15835 cmdline_fixed_string_t pos_token;
15836 cmdline_fixed_string_t ip_version;
15837 uint32_t vlan_present:1;
15839 cmdline_ipaddr_t ip_src;
15840 cmdline_ipaddr_t ip_dst;
15842 struct rte_ether_addr eth_src;
15843 struct rte_ether_addr eth_dst;
15846 cmdline_parse_token_string_t cmd_set_mplsogre_encap_set =
15847 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, set,
15849 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap =
15850 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, mplsogre,
15852 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap_with_vlan =
15853 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15854 mplsogre, "mplsogre_encap-with-vlan");
15855 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version =
15856 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15857 pos_token, "ip-version");
15858 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version_value =
15859 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15860 ip_version, "ipv4#ipv6");
15861 cmdline_parse_token_string_t cmd_set_mplsogre_encap_label =
15862 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15863 pos_token, "label");
15864 cmdline_parse_token_num_t cmd_set_mplsogre_encap_label_value =
15865 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, label,
15867 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_src =
15868 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15869 pos_token, "ip-src");
15870 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_src_value =
15871 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_src);
15872 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_dst =
15873 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15874 pos_token, "ip-dst");
15875 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_dst_value =
15876 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_dst);
15877 cmdline_parse_token_string_t cmd_set_mplsogre_encap_vlan =
15878 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15879 pos_token, "vlan-tci");
15880 cmdline_parse_token_num_t cmd_set_mplsogre_encap_vlan_value =
15881 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, tci,
15883 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_src =
15884 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15885 pos_token, "eth-src");
15886 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_src_value =
15887 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15889 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_dst =
15890 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15891 pos_token, "eth-dst");
15892 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_dst_value =
15893 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15896 static void cmd_set_mplsogre_encap_parsed(void *parsed_result,
15897 __rte_unused struct cmdline *cl,
15898 __rte_unused void *data)
15900 struct cmd_set_mplsogre_encap_result *res = parsed_result;
15902 uint32_t mplsogre_label;
15905 .mplsogre_label = rte_cpu_to_be_32(res->label<<12),
15908 if (strcmp(res->mplsogre, "mplsogre_encap") == 0)
15909 mplsogre_encap_conf.select_vlan = 0;
15910 else if (strcmp(res->mplsogre, "mplsogre_encap-with-vlan") == 0)
15911 mplsogre_encap_conf.select_vlan = 1;
15912 if (strcmp(res->ip_version, "ipv4") == 0)
15913 mplsogre_encap_conf.select_ipv4 = 1;
15914 else if (strcmp(res->ip_version, "ipv6") == 0)
15915 mplsogre_encap_conf.select_ipv4 = 0;
15918 rte_memcpy(mplsogre_encap_conf.label, &id.label, 3);
15919 if (mplsogre_encap_conf.select_ipv4) {
15920 IPV4_ADDR_TO_UINT(res->ip_src, mplsogre_encap_conf.ipv4_src);
15921 IPV4_ADDR_TO_UINT(res->ip_dst, mplsogre_encap_conf.ipv4_dst);
15923 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsogre_encap_conf.ipv6_src);
15924 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsogre_encap_conf.ipv6_dst);
15926 if (mplsogre_encap_conf.select_vlan)
15927 mplsogre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15928 rte_memcpy(mplsogre_encap_conf.eth_src, res->eth_src.addr_bytes,
15929 RTE_ETHER_ADDR_LEN);
15930 rte_memcpy(mplsogre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15931 RTE_ETHER_ADDR_LEN);
15934 cmdline_parse_inst_t cmd_set_mplsogre_encap = {
15935 .f = cmd_set_mplsogre_encap_parsed,
15937 .help_str = "set mplsogre_encap ip-version ipv4|ipv6 label <label>"
15938 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
15939 " eth-dst <eth-dst>",
15941 (void *)&cmd_set_mplsogre_encap_set,
15942 (void *)&cmd_set_mplsogre_encap_mplsogre_encap,
15943 (void *)&cmd_set_mplsogre_encap_ip_version,
15944 (void *)&cmd_set_mplsogre_encap_ip_version_value,
15945 (void *)&cmd_set_mplsogre_encap_label,
15946 (void *)&cmd_set_mplsogre_encap_label_value,
15947 (void *)&cmd_set_mplsogre_encap_ip_src,
15948 (void *)&cmd_set_mplsogre_encap_ip_src_value,
15949 (void *)&cmd_set_mplsogre_encap_ip_dst,
15950 (void *)&cmd_set_mplsogre_encap_ip_dst_value,
15951 (void *)&cmd_set_mplsogre_encap_eth_src,
15952 (void *)&cmd_set_mplsogre_encap_eth_src_value,
15953 (void *)&cmd_set_mplsogre_encap_eth_dst,
15954 (void *)&cmd_set_mplsogre_encap_eth_dst_value,
15959 cmdline_parse_inst_t cmd_set_mplsogre_encap_with_vlan = {
15960 .f = cmd_set_mplsogre_encap_parsed,
15962 .help_str = "set mplsogre_encap-with-vlan ip-version ipv4|ipv6"
15963 " label <label> ip-src <ip-src> ip-dst <ip-dst>"
15964 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
15966 (void *)&cmd_set_mplsogre_encap_set,
15967 (void *)&cmd_set_mplsogre_encap_mplsogre_encap_with_vlan,
15968 (void *)&cmd_set_mplsogre_encap_ip_version,
15969 (void *)&cmd_set_mplsogre_encap_ip_version_value,
15970 (void *)&cmd_set_mplsogre_encap_label,
15971 (void *)&cmd_set_mplsogre_encap_label_value,
15972 (void *)&cmd_set_mplsogre_encap_ip_src,
15973 (void *)&cmd_set_mplsogre_encap_ip_src_value,
15974 (void *)&cmd_set_mplsogre_encap_ip_dst,
15975 (void *)&cmd_set_mplsogre_encap_ip_dst_value,
15976 (void *)&cmd_set_mplsogre_encap_vlan,
15977 (void *)&cmd_set_mplsogre_encap_vlan_value,
15978 (void *)&cmd_set_mplsogre_encap_eth_src,
15979 (void *)&cmd_set_mplsogre_encap_eth_src_value,
15980 (void *)&cmd_set_mplsogre_encap_eth_dst,
15981 (void *)&cmd_set_mplsogre_encap_eth_dst_value,
15986 /** Set MPLSoGRE decapsulation details */
15987 struct cmd_set_mplsogre_decap_result {
15988 cmdline_fixed_string_t set;
15989 cmdline_fixed_string_t mplsogre;
15990 cmdline_fixed_string_t pos_token;
15991 cmdline_fixed_string_t ip_version;
15992 uint32_t vlan_present:1;
15995 cmdline_parse_token_string_t cmd_set_mplsogre_decap_set =
15996 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, set,
15998 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap =
15999 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, mplsogre,
16001 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap_with_vlan =
16002 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
16003 mplsogre, "mplsogre_decap-with-vlan");
16004 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version =
16005 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
16006 pos_token, "ip-version");
16007 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version_value =
16008 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
16009 ip_version, "ipv4#ipv6");
16011 static void cmd_set_mplsogre_decap_parsed(void *parsed_result,
16012 __rte_unused struct cmdline *cl,
16013 __rte_unused void *data)
16015 struct cmd_set_mplsogre_decap_result *res = parsed_result;
16017 if (strcmp(res->mplsogre, "mplsogre_decap") == 0)
16018 mplsogre_decap_conf.select_vlan = 0;
16019 else if (strcmp(res->mplsogre, "mplsogre_decap-with-vlan") == 0)
16020 mplsogre_decap_conf.select_vlan = 1;
16021 if (strcmp(res->ip_version, "ipv4") == 0)
16022 mplsogre_decap_conf.select_ipv4 = 1;
16023 else if (strcmp(res->ip_version, "ipv6") == 0)
16024 mplsogre_decap_conf.select_ipv4 = 0;
16027 cmdline_parse_inst_t cmd_set_mplsogre_decap = {
16028 .f = cmd_set_mplsogre_decap_parsed,
16030 .help_str = "set mplsogre_decap ip-version ipv4|ipv6",
16032 (void *)&cmd_set_mplsogre_decap_set,
16033 (void *)&cmd_set_mplsogre_decap_mplsogre_decap,
16034 (void *)&cmd_set_mplsogre_decap_ip_version,
16035 (void *)&cmd_set_mplsogre_decap_ip_version_value,
16040 cmdline_parse_inst_t cmd_set_mplsogre_decap_with_vlan = {
16041 .f = cmd_set_mplsogre_decap_parsed,
16043 .help_str = "set mplsogre_decap-with-vlan ip-version ipv4|ipv6",
16045 (void *)&cmd_set_mplsogre_decap_set,
16046 (void *)&cmd_set_mplsogre_decap_mplsogre_decap_with_vlan,
16047 (void *)&cmd_set_mplsogre_decap_ip_version,
16048 (void *)&cmd_set_mplsogre_decap_ip_version_value,
16053 /** Set MPLSoUDP encapsulation details */
16054 struct cmd_set_mplsoudp_encap_result {
16055 cmdline_fixed_string_t set;
16056 cmdline_fixed_string_t mplsoudp;
16057 cmdline_fixed_string_t pos_token;
16058 cmdline_fixed_string_t ip_version;
16059 uint32_t vlan_present:1;
16063 cmdline_ipaddr_t ip_src;
16064 cmdline_ipaddr_t ip_dst;
16066 struct rte_ether_addr eth_src;
16067 struct rte_ether_addr eth_dst;
16070 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_set =
16071 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, set,
16073 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap =
16074 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, mplsoudp,
16076 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan =
16077 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16078 mplsoudp, "mplsoudp_encap-with-vlan");
16079 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version =
16080 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16081 pos_token, "ip-version");
16082 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version_value =
16083 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16084 ip_version, "ipv4#ipv6");
16085 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_label =
16086 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16087 pos_token, "label");
16088 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_label_value =
16089 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, label,
16091 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_src =
16092 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16093 pos_token, "udp-src");
16094 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_src_value =
16095 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_src,
16097 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_dst =
16098 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16099 pos_token, "udp-dst");
16100 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_dst_value =
16101 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_dst,
16103 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_src =
16104 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16105 pos_token, "ip-src");
16106 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_src_value =
16107 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_src);
16108 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_dst =
16109 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16110 pos_token, "ip-dst");
16111 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_dst_value =
16112 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_dst);
16113 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_vlan =
16114 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16115 pos_token, "vlan-tci");
16116 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_vlan_value =
16117 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, tci,
16119 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_src =
16120 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16121 pos_token, "eth-src");
16122 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_src_value =
16123 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16125 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_dst =
16126 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16127 pos_token, "eth-dst");
16128 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_dst_value =
16129 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16132 static void cmd_set_mplsoudp_encap_parsed(void *parsed_result,
16133 __rte_unused struct cmdline *cl,
16134 __rte_unused void *data)
16136 struct cmd_set_mplsoudp_encap_result *res = parsed_result;
16138 uint32_t mplsoudp_label;
16141 .mplsoudp_label = rte_cpu_to_be_32(res->label<<12),
16144 if (strcmp(res->mplsoudp, "mplsoudp_encap") == 0)
16145 mplsoudp_encap_conf.select_vlan = 0;
16146 else if (strcmp(res->mplsoudp, "mplsoudp_encap-with-vlan") == 0)
16147 mplsoudp_encap_conf.select_vlan = 1;
16148 if (strcmp(res->ip_version, "ipv4") == 0)
16149 mplsoudp_encap_conf.select_ipv4 = 1;
16150 else if (strcmp(res->ip_version, "ipv6") == 0)
16151 mplsoudp_encap_conf.select_ipv4 = 0;
16154 rte_memcpy(mplsoudp_encap_conf.label, &id.label, 3);
16155 mplsoudp_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
16156 mplsoudp_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
16157 if (mplsoudp_encap_conf.select_ipv4) {
16158 IPV4_ADDR_TO_UINT(res->ip_src, mplsoudp_encap_conf.ipv4_src);
16159 IPV4_ADDR_TO_UINT(res->ip_dst, mplsoudp_encap_conf.ipv4_dst);
16161 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsoudp_encap_conf.ipv6_src);
16162 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsoudp_encap_conf.ipv6_dst);
16164 if (mplsoudp_encap_conf.select_vlan)
16165 mplsoudp_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
16166 rte_memcpy(mplsoudp_encap_conf.eth_src, res->eth_src.addr_bytes,
16167 RTE_ETHER_ADDR_LEN);
16168 rte_memcpy(mplsoudp_encap_conf.eth_dst, res->eth_dst.addr_bytes,
16169 RTE_ETHER_ADDR_LEN);
16172 cmdline_parse_inst_t cmd_set_mplsoudp_encap = {
16173 .f = cmd_set_mplsoudp_encap_parsed,
16175 .help_str = "set mplsoudp_encap ip-version ipv4|ipv6 label <label>"
16176 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src>"
16177 " ip-dst <ip-dst> eth-src <eth-src> eth-dst <eth-dst>",
16179 (void *)&cmd_set_mplsoudp_encap_set,
16180 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap,
16181 (void *)&cmd_set_mplsoudp_encap_ip_version,
16182 (void *)&cmd_set_mplsoudp_encap_ip_version_value,
16183 (void *)&cmd_set_mplsoudp_encap_label,
16184 (void *)&cmd_set_mplsoudp_encap_label_value,
16185 (void *)&cmd_set_mplsoudp_encap_udp_src,
16186 (void *)&cmd_set_mplsoudp_encap_udp_src_value,
16187 (void *)&cmd_set_mplsoudp_encap_udp_dst,
16188 (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
16189 (void *)&cmd_set_mplsoudp_encap_ip_src,
16190 (void *)&cmd_set_mplsoudp_encap_ip_src_value,
16191 (void *)&cmd_set_mplsoudp_encap_ip_dst,
16192 (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
16193 (void *)&cmd_set_mplsoudp_encap_eth_src,
16194 (void *)&cmd_set_mplsoudp_encap_eth_src_value,
16195 (void *)&cmd_set_mplsoudp_encap_eth_dst,
16196 (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
16201 cmdline_parse_inst_t cmd_set_mplsoudp_encap_with_vlan = {
16202 .f = cmd_set_mplsoudp_encap_parsed,
16204 .help_str = "set mplsoudp_encap-with-vlan ip-version ipv4|ipv6"
16205 " label <label> udp-src <udp-src> udp-dst <udp-dst>"
16206 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
16207 " eth-src <eth-src> eth-dst <eth-dst>",
16209 (void *)&cmd_set_mplsoudp_encap_set,
16210 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan,
16211 (void *)&cmd_set_mplsoudp_encap_ip_version,
16212 (void *)&cmd_set_mplsoudp_encap_ip_version_value,
16213 (void *)&cmd_set_mplsoudp_encap_label,
16214 (void *)&cmd_set_mplsoudp_encap_label_value,
16215 (void *)&cmd_set_mplsoudp_encap_udp_src,
16216 (void *)&cmd_set_mplsoudp_encap_udp_src_value,
16217 (void *)&cmd_set_mplsoudp_encap_udp_dst,
16218 (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
16219 (void *)&cmd_set_mplsoudp_encap_ip_src,
16220 (void *)&cmd_set_mplsoudp_encap_ip_src_value,
16221 (void *)&cmd_set_mplsoudp_encap_ip_dst,
16222 (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
16223 (void *)&cmd_set_mplsoudp_encap_vlan,
16224 (void *)&cmd_set_mplsoudp_encap_vlan_value,
16225 (void *)&cmd_set_mplsoudp_encap_eth_src,
16226 (void *)&cmd_set_mplsoudp_encap_eth_src_value,
16227 (void *)&cmd_set_mplsoudp_encap_eth_dst,
16228 (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
16233 /** Set MPLSoUDP decapsulation details */
16234 struct cmd_set_mplsoudp_decap_result {
16235 cmdline_fixed_string_t set;
16236 cmdline_fixed_string_t mplsoudp;
16237 cmdline_fixed_string_t pos_token;
16238 cmdline_fixed_string_t ip_version;
16239 uint32_t vlan_present:1;
16242 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_set =
16243 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, set,
16245 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap =
16246 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, mplsoudp,
16248 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan =
16249 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
16250 mplsoudp, "mplsoudp_decap-with-vlan");
16251 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version =
16252 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
16253 pos_token, "ip-version");
16254 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version_value =
16255 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
16256 ip_version, "ipv4#ipv6");
16258 static void cmd_set_mplsoudp_decap_parsed(void *parsed_result,
16259 __rte_unused struct cmdline *cl,
16260 __rte_unused void *data)
16262 struct cmd_set_mplsoudp_decap_result *res = parsed_result;
16264 if (strcmp(res->mplsoudp, "mplsoudp_decap") == 0)
16265 mplsoudp_decap_conf.select_vlan = 0;
16266 else if (strcmp(res->mplsoudp, "mplsoudp_decap-with-vlan") == 0)
16267 mplsoudp_decap_conf.select_vlan = 1;
16268 if (strcmp(res->ip_version, "ipv4") == 0)
16269 mplsoudp_decap_conf.select_ipv4 = 1;
16270 else if (strcmp(res->ip_version, "ipv6") == 0)
16271 mplsoudp_decap_conf.select_ipv4 = 0;
16274 cmdline_parse_inst_t cmd_set_mplsoudp_decap = {
16275 .f = cmd_set_mplsoudp_decap_parsed,
16277 .help_str = "set mplsoudp_decap ip-version ipv4|ipv6",
16279 (void *)&cmd_set_mplsoudp_decap_set,
16280 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap,
16281 (void *)&cmd_set_mplsoudp_decap_ip_version,
16282 (void *)&cmd_set_mplsoudp_decap_ip_version_value,
16287 cmdline_parse_inst_t cmd_set_mplsoudp_decap_with_vlan = {
16288 .f = cmd_set_mplsoudp_decap_parsed,
16290 .help_str = "set mplsoudp_decap-with-vlan ip-version ipv4|ipv6",
16292 (void *)&cmd_set_mplsoudp_decap_set,
16293 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan,
16294 (void *)&cmd_set_mplsoudp_decap_ip_version,
16295 (void *)&cmd_set_mplsoudp_decap_ip_version_value,
16300 /* Strict link priority scheduling mode setting */
16302 cmd_strict_link_prio_parsed(
16303 void *parsed_result,
16304 __rte_unused struct cmdline *cl,
16305 __rte_unused void *data)
16307 struct cmd_vf_tc_bw_result *res = parsed_result;
16308 int ret = -ENOTSUP;
16310 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16313 #ifdef RTE_NET_I40E
16314 ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map);
16321 printf("invalid tc_bitmap 0x%x\n", res->tc_map);
16324 printf("invalid port_id %d\n", res->port_id);
16327 printf("function not implemented\n");
16330 printf("programming error: (%s)\n", strerror(-ret));
16334 cmdline_parse_inst_t cmd_strict_link_prio = {
16335 .f = cmd_strict_link_prio_parsed,
16337 .help_str = "set tx strict-link-priority <port_id> <tc_bitmap>",
16339 (void *)&cmd_vf_tc_bw_set,
16340 (void *)&cmd_vf_tc_bw_tx,
16341 (void *)&cmd_vf_tc_bw_strict_link_prio,
16342 (void *)&cmd_vf_tc_bw_port_id,
16343 (void *)&cmd_vf_tc_bw_tc_map,
16348 /* Load dynamic device personalization*/
16349 struct cmd_ddp_add_result {
16350 cmdline_fixed_string_t ddp;
16351 cmdline_fixed_string_t add;
16356 cmdline_parse_token_string_t cmd_ddp_add_ddp =
16357 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp");
16358 cmdline_parse_token_string_t cmd_ddp_add_add =
16359 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add");
16360 cmdline_parse_token_num_t cmd_ddp_add_port_id =
16361 TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id, UINT16);
16362 cmdline_parse_token_string_t cmd_ddp_add_filepath =
16363 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL);
16366 cmd_ddp_add_parsed(
16367 void *parsed_result,
16368 __rte_unused struct cmdline *cl,
16369 __rte_unused void *data)
16371 struct cmd_ddp_add_result *res = parsed_result;
16377 int ret = -ENOTSUP;
16379 if (!all_ports_stopped()) {
16380 printf("Please stop all ports first\n");
16384 filepath = strdup(res->filepath);
16385 if (filepath == NULL) {
16386 printf("Failed to allocate memory\n");
16389 file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ',');
16391 buff = open_file(file_fld[0], &size);
16393 free((void *)filepath);
16397 #ifdef RTE_NET_I40E
16398 if (ret == -ENOTSUP)
16399 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
16401 RTE_PMD_I40E_PKG_OP_WR_ADD);
16404 if (ret == -EEXIST)
16405 printf("Profile has already existed.\n");
16407 printf("Failed to load profile.\n");
16408 else if (file_num == 2)
16409 save_file(file_fld[1], buff, size);
16412 free((void *)filepath);
16415 cmdline_parse_inst_t cmd_ddp_add = {
16416 .f = cmd_ddp_add_parsed,
16418 .help_str = "ddp add <port_id> <profile_path[,backup_profile_path]>",
16420 (void *)&cmd_ddp_add_ddp,
16421 (void *)&cmd_ddp_add_add,
16422 (void *)&cmd_ddp_add_port_id,
16423 (void *)&cmd_ddp_add_filepath,
16428 /* Delete dynamic device personalization*/
16429 struct cmd_ddp_del_result {
16430 cmdline_fixed_string_t ddp;
16431 cmdline_fixed_string_t del;
16436 cmdline_parse_token_string_t cmd_ddp_del_ddp =
16437 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp");
16438 cmdline_parse_token_string_t cmd_ddp_del_del =
16439 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del");
16440 cmdline_parse_token_num_t cmd_ddp_del_port_id =
16441 TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, UINT16);
16442 cmdline_parse_token_string_t cmd_ddp_del_filepath =
16443 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL);
16446 cmd_ddp_del_parsed(
16447 void *parsed_result,
16448 __rte_unused struct cmdline *cl,
16449 __rte_unused void *data)
16451 struct cmd_ddp_del_result *res = parsed_result;
16454 int ret = -ENOTSUP;
16456 if (!all_ports_stopped()) {
16457 printf("Please stop all ports first\n");
16461 buff = open_file(res->filepath, &size);
16465 #ifdef RTE_NET_I40E
16466 if (ret == -ENOTSUP)
16467 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
16469 RTE_PMD_I40E_PKG_OP_WR_DEL);
16472 if (ret == -EACCES)
16473 printf("Profile does not exist.\n");
16475 printf("Failed to delete profile.\n");
16480 cmdline_parse_inst_t cmd_ddp_del = {
16481 .f = cmd_ddp_del_parsed,
16483 .help_str = "ddp del <port_id> <backup_profile_path>",
16485 (void *)&cmd_ddp_del_ddp,
16486 (void *)&cmd_ddp_del_del,
16487 (void *)&cmd_ddp_del_port_id,
16488 (void *)&cmd_ddp_del_filepath,
16493 /* Get dynamic device personalization profile info */
16494 struct cmd_ddp_info_result {
16495 cmdline_fixed_string_t ddp;
16496 cmdline_fixed_string_t get;
16497 cmdline_fixed_string_t info;
16501 cmdline_parse_token_string_t cmd_ddp_info_ddp =
16502 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp");
16503 cmdline_parse_token_string_t cmd_ddp_info_get =
16504 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get");
16505 cmdline_parse_token_string_t cmd_ddp_info_info =
16506 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info");
16507 cmdline_parse_token_string_t cmd_ddp_info_filepath =
16508 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL);
16511 cmd_ddp_info_parsed(
16512 void *parsed_result,
16513 __rte_unused struct cmdline *cl,
16514 __rte_unused void *data)
16516 struct cmd_ddp_info_result *res = parsed_result;
16519 int ret = -ENOTSUP;
16520 #ifdef RTE_NET_I40E
16523 uint32_t buff_size = 0;
16524 struct rte_pmd_i40e_profile_info info;
16525 uint32_t dev_num = 0;
16526 struct rte_pmd_i40e_ddp_device_id *devs;
16527 uint32_t proto_num = 0;
16528 struct rte_pmd_i40e_proto_info *proto = NULL;
16529 uint32_t pctype_num = 0;
16530 struct rte_pmd_i40e_ptype_info *pctype;
16531 uint32_t ptype_num = 0;
16532 struct rte_pmd_i40e_ptype_info *ptype;
16537 pkg = open_file(res->filepath, &pkg_size);
16541 #ifdef RTE_NET_I40E
16542 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16543 (uint8_t *)&info, sizeof(info),
16544 RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER);
16546 printf("Global Track id: 0x%x\n", info.track_id);
16547 printf("Global Version: %d.%d.%d.%d\n",
16548 info.version.major,
16549 info.version.minor,
16550 info.version.update,
16551 info.version.draft);
16552 printf("Global Package name: %s\n\n", info.name);
16555 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16556 (uint8_t *)&info, sizeof(info),
16557 RTE_PMD_I40E_PKG_INFO_HEADER);
16559 printf("i40e Profile Track id: 0x%x\n", info.track_id);
16560 printf("i40e Profile Version: %d.%d.%d.%d\n",
16561 info.version.major,
16562 info.version.minor,
16563 info.version.update,
16564 info.version.draft);
16565 printf("i40e Profile name: %s\n\n", info.name);
16568 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16569 (uint8_t *)&buff_size, sizeof(buff_size),
16570 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE);
16571 if (!ret && buff_size) {
16572 buff = (uint8_t *)malloc(buff_size);
16574 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16576 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES);
16578 printf("Package Notes:\n%s\n\n", buff);
16583 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16584 (uint8_t *)&dev_num, sizeof(dev_num),
16585 RTE_PMD_I40E_PKG_INFO_DEVID_NUM);
16586 if (!ret && dev_num) {
16587 buff_size = dev_num * sizeof(struct rte_pmd_i40e_ddp_device_id);
16588 devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(buff_size);
16590 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16591 (uint8_t *)devs, buff_size,
16592 RTE_PMD_I40E_PKG_INFO_DEVID_LIST);
16594 printf("List of supported devices:\n");
16595 for (i = 0; i < dev_num; i++) {
16596 printf(" %04X:%04X %04X:%04X\n",
16597 devs[i].vendor_dev_id >> 16,
16598 devs[i].vendor_dev_id & 0xFFFF,
16599 devs[i].sub_vendor_dev_id >> 16,
16600 devs[i].sub_vendor_dev_id & 0xFFFF);
16608 /* get information about protocols and packet types */
16609 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16610 (uint8_t *)&proto_num, sizeof(proto_num),
16611 RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM);
16612 if (ret || !proto_num)
16613 goto no_print_return;
16615 buff_size = proto_num * sizeof(struct rte_pmd_i40e_proto_info);
16616 proto = (struct rte_pmd_i40e_proto_info *)malloc(buff_size);
16618 goto no_print_return;
16620 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)proto,
16622 RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST);
16624 printf("List of used protocols:\n");
16625 for (i = 0; i < proto_num; i++)
16626 printf(" %2u: %s\n", proto[i].proto_id,
16630 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16631 (uint8_t *)&pctype_num, sizeof(pctype_num),
16632 RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM);
16633 if (ret || !pctype_num)
16634 goto no_print_pctypes;
16636 buff_size = pctype_num * sizeof(struct rte_pmd_i40e_ptype_info);
16637 pctype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
16639 goto no_print_pctypes;
16641 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)pctype,
16643 RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST);
16646 goto no_print_pctypes;
16649 printf("List of defined packet classification types:\n");
16650 for (i = 0; i < pctype_num; i++) {
16651 printf(" %2u:", pctype[i].ptype_id);
16652 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
16653 proto_id = pctype[i].protocols[j];
16654 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
16655 for (n = 0; n < proto_num; n++) {
16656 if (proto[n].proto_id == proto_id) {
16657 printf(" %s", proto[n].name);
16670 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)&ptype_num,
16672 RTE_PMD_I40E_PKG_INFO_PTYPE_NUM);
16673 if (ret || !ptype_num)
16674 goto no_print_return;
16676 buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_info);
16677 ptype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
16679 goto no_print_return;
16681 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)ptype,
16683 RTE_PMD_I40E_PKG_INFO_PTYPE_LIST);
16686 goto no_print_return;
16688 printf("List of defined packet types:\n");
16689 for (i = 0; i < ptype_num; i++) {
16690 printf(" %2u:", ptype[i].ptype_id);
16691 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
16692 proto_id = ptype[i].protocols[j];
16693 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
16694 for (n = 0; n < proto_num; n++) {
16695 if (proto[n].proto_id == proto_id) {
16696 printf(" %s", proto[n].name);
16712 if (ret == -ENOTSUP)
16713 printf("Function not supported in PMD driver\n");
16717 cmdline_parse_inst_t cmd_ddp_get_info = {
16718 .f = cmd_ddp_info_parsed,
16720 .help_str = "ddp get info <profile_path>",
16722 (void *)&cmd_ddp_info_ddp,
16723 (void *)&cmd_ddp_info_get,
16724 (void *)&cmd_ddp_info_info,
16725 (void *)&cmd_ddp_info_filepath,
16730 /* Get dynamic device personalization profile info list*/
16731 #define PROFILE_INFO_SIZE 48
16732 #define MAX_PROFILE_NUM 16
16734 struct cmd_ddp_get_list_result {
16735 cmdline_fixed_string_t ddp;
16736 cmdline_fixed_string_t get;
16737 cmdline_fixed_string_t list;
16741 cmdline_parse_token_string_t cmd_ddp_get_list_ddp =
16742 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp");
16743 cmdline_parse_token_string_t cmd_ddp_get_list_get =
16744 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get");
16745 cmdline_parse_token_string_t cmd_ddp_get_list_list =
16746 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list");
16747 cmdline_parse_token_num_t cmd_ddp_get_list_port_id =
16748 TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id, UINT16);
16751 cmd_ddp_get_list_parsed(
16752 __rte_unused void *parsed_result,
16753 __rte_unused struct cmdline *cl,
16754 __rte_unused void *data)
16756 #ifdef RTE_NET_I40E
16757 struct cmd_ddp_get_list_result *res = parsed_result;
16758 struct rte_pmd_i40e_profile_list *p_list;
16759 struct rte_pmd_i40e_profile_info *p_info;
16764 int ret = -ENOTSUP;
16766 #ifdef RTE_NET_I40E
16767 size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4;
16768 p_list = (struct rte_pmd_i40e_profile_list *)malloc(size);
16770 printf("%s: Failed to malloc buffer\n", __func__);
16774 if (ret == -ENOTSUP)
16775 ret = rte_pmd_i40e_get_ddp_list(res->port_id,
16776 (uint8_t *)p_list, size);
16779 p_num = p_list->p_count;
16780 printf("Profile number is: %d\n\n", p_num);
16782 for (i = 0; i < p_num; i++) {
16783 p_info = &p_list->p_info[i];
16784 printf("Profile %d:\n", i);
16785 printf("Track id: 0x%x\n", p_info->track_id);
16786 printf("Version: %d.%d.%d.%d\n",
16787 p_info->version.major,
16788 p_info->version.minor,
16789 p_info->version.update,
16790 p_info->version.draft);
16791 printf("Profile name: %s\n\n", p_info->name);
16799 printf("Failed to get ddp list\n");
16802 cmdline_parse_inst_t cmd_ddp_get_list = {
16803 .f = cmd_ddp_get_list_parsed,
16805 .help_str = "ddp get list <port_id>",
16807 (void *)&cmd_ddp_get_list_ddp,
16808 (void *)&cmd_ddp_get_list_get,
16809 (void *)&cmd_ddp_get_list_list,
16810 (void *)&cmd_ddp_get_list_port_id,
16815 /* Configure input set */
16816 struct cmd_cfg_input_set_result {
16817 cmdline_fixed_string_t port;
16818 cmdline_fixed_string_t cfg;
16820 cmdline_fixed_string_t pctype;
16822 cmdline_fixed_string_t inset_type;
16823 cmdline_fixed_string_t opt;
16824 cmdline_fixed_string_t field;
16829 cmd_cfg_input_set_parsed(
16830 __rte_unused void *parsed_result,
16831 __rte_unused struct cmdline *cl,
16832 __rte_unused void *data)
16834 #ifdef RTE_NET_I40E
16835 struct cmd_cfg_input_set_result *res = parsed_result;
16836 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
16837 struct rte_pmd_i40e_inset inset;
16839 int ret = -ENOTSUP;
16841 if (!all_ports_stopped()) {
16842 printf("Please stop all ports first\n");
16846 #ifdef RTE_NET_I40E
16847 if (!strcmp(res->inset_type, "hash_inset"))
16848 inset_type = INSET_HASH;
16849 else if (!strcmp(res->inset_type, "fdir_inset"))
16850 inset_type = INSET_FDIR;
16851 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
16852 inset_type = INSET_FDIR_FLX;
16853 ret = rte_pmd_i40e_inset_get(res->port_id, res->pctype_id,
16854 &inset, inset_type);
16856 printf("Failed to get input set.\n");
16860 if (!strcmp(res->opt, "get")) {
16861 ret = rte_pmd_i40e_inset_field_get(inset.inset,
16864 printf("Field index %d is enabled.\n", res->field_idx);
16866 printf("Field index %d is disabled.\n", res->field_idx);
16868 } else if (!strcmp(res->opt, "set"))
16869 ret = rte_pmd_i40e_inset_field_set(&inset.inset,
16871 else if (!strcmp(res->opt, "clear"))
16872 ret = rte_pmd_i40e_inset_field_clear(&inset.inset,
16875 printf("Failed to configure input set field.\n");
16879 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
16880 &inset, inset_type);
16882 printf("Failed to set input set.\n");
16887 if (ret == -ENOTSUP)
16888 printf("Function not supported\n");
16891 cmdline_parse_token_string_t cmd_cfg_input_set_port =
16892 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16894 cmdline_parse_token_string_t cmd_cfg_input_set_cfg =
16895 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16897 cmdline_parse_token_num_t cmd_cfg_input_set_port_id =
16898 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
16900 cmdline_parse_token_string_t cmd_cfg_input_set_pctype =
16901 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16903 cmdline_parse_token_num_t cmd_cfg_input_set_pctype_id =
16904 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
16906 cmdline_parse_token_string_t cmd_cfg_input_set_inset_type =
16907 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16909 "hash_inset#fdir_inset#fdir_flx_inset");
16910 cmdline_parse_token_string_t cmd_cfg_input_set_opt =
16911 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16912 opt, "get#set#clear");
16913 cmdline_parse_token_string_t cmd_cfg_input_set_field =
16914 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16916 cmdline_parse_token_num_t cmd_cfg_input_set_field_idx =
16917 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
16920 cmdline_parse_inst_t cmd_cfg_input_set = {
16921 .f = cmd_cfg_input_set_parsed,
16923 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
16924 "fdir_inset|fdir_flx_inset get|set|clear field <field_idx>",
16926 (void *)&cmd_cfg_input_set_port,
16927 (void *)&cmd_cfg_input_set_cfg,
16928 (void *)&cmd_cfg_input_set_port_id,
16929 (void *)&cmd_cfg_input_set_pctype,
16930 (void *)&cmd_cfg_input_set_pctype_id,
16931 (void *)&cmd_cfg_input_set_inset_type,
16932 (void *)&cmd_cfg_input_set_opt,
16933 (void *)&cmd_cfg_input_set_field,
16934 (void *)&cmd_cfg_input_set_field_idx,
16939 /* Clear input set */
16940 struct cmd_clear_input_set_result {
16941 cmdline_fixed_string_t port;
16942 cmdline_fixed_string_t cfg;
16944 cmdline_fixed_string_t pctype;
16946 cmdline_fixed_string_t inset_type;
16947 cmdline_fixed_string_t clear;
16948 cmdline_fixed_string_t all;
16952 cmd_clear_input_set_parsed(
16953 __rte_unused void *parsed_result,
16954 __rte_unused struct cmdline *cl,
16955 __rte_unused void *data)
16957 #ifdef RTE_NET_I40E
16958 struct cmd_clear_input_set_result *res = parsed_result;
16959 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
16960 struct rte_pmd_i40e_inset inset;
16962 int ret = -ENOTSUP;
16964 if (!all_ports_stopped()) {
16965 printf("Please stop all ports first\n");
16969 #ifdef RTE_NET_I40E
16970 if (!strcmp(res->inset_type, "hash_inset"))
16971 inset_type = INSET_HASH;
16972 else if (!strcmp(res->inset_type, "fdir_inset"))
16973 inset_type = INSET_FDIR;
16974 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
16975 inset_type = INSET_FDIR_FLX;
16977 memset(&inset, 0, sizeof(inset));
16979 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
16980 &inset, inset_type);
16982 printf("Failed to clear input set.\n");
16988 if (ret == -ENOTSUP)
16989 printf("Function not supported\n");
16992 cmdline_parse_token_string_t cmd_clear_input_set_port =
16993 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
16995 cmdline_parse_token_string_t cmd_clear_input_set_cfg =
16996 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
16998 cmdline_parse_token_num_t cmd_clear_input_set_port_id =
16999 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
17001 cmdline_parse_token_string_t cmd_clear_input_set_pctype =
17002 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17004 cmdline_parse_token_num_t cmd_clear_input_set_pctype_id =
17005 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
17007 cmdline_parse_token_string_t cmd_clear_input_set_inset_type =
17008 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17010 "hash_inset#fdir_inset#fdir_flx_inset");
17011 cmdline_parse_token_string_t cmd_clear_input_set_clear =
17012 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17014 cmdline_parse_token_string_t cmd_clear_input_set_all =
17015 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17018 cmdline_parse_inst_t cmd_clear_input_set = {
17019 .f = cmd_clear_input_set_parsed,
17021 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
17022 "fdir_inset|fdir_flx_inset clear all",
17024 (void *)&cmd_clear_input_set_port,
17025 (void *)&cmd_clear_input_set_cfg,
17026 (void *)&cmd_clear_input_set_port_id,
17027 (void *)&cmd_clear_input_set_pctype,
17028 (void *)&cmd_clear_input_set_pctype_id,
17029 (void *)&cmd_clear_input_set_inset_type,
17030 (void *)&cmd_clear_input_set_clear,
17031 (void *)&cmd_clear_input_set_all,
17036 /* show vf stats */
17038 /* Common result structure for show vf stats */
17039 struct cmd_show_vf_stats_result {
17040 cmdline_fixed_string_t show;
17041 cmdline_fixed_string_t vf;
17042 cmdline_fixed_string_t stats;
17047 /* Common CLI fields show vf stats*/
17048 cmdline_parse_token_string_t cmd_show_vf_stats_show =
17049 TOKEN_STRING_INITIALIZER
17050 (struct cmd_show_vf_stats_result,
17052 cmdline_parse_token_string_t cmd_show_vf_stats_vf =
17053 TOKEN_STRING_INITIALIZER
17054 (struct cmd_show_vf_stats_result,
17056 cmdline_parse_token_string_t cmd_show_vf_stats_stats =
17057 TOKEN_STRING_INITIALIZER
17058 (struct cmd_show_vf_stats_result,
17060 cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
17061 TOKEN_NUM_INITIALIZER
17062 (struct cmd_show_vf_stats_result,
17064 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
17065 TOKEN_NUM_INITIALIZER
17066 (struct cmd_show_vf_stats_result,
17070 cmd_show_vf_stats_parsed(
17071 void *parsed_result,
17072 __rte_unused struct cmdline *cl,
17073 __rte_unused void *data)
17075 struct cmd_show_vf_stats_result *res = parsed_result;
17076 struct rte_eth_stats stats;
17077 int ret = -ENOTSUP;
17078 static const char *nic_stats_border = "########################";
17080 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17083 memset(&stats, 0, sizeof(stats));
17085 #ifdef RTE_NET_I40E
17086 if (ret == -ENOTSUP)
17087 ret = rte_pmd_i40e_get_vf_stats(res->port_id,
17091 #ifdef RTE_NET_BNXT
17092 if (ret == -ENOTSUP)
17093 ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
17102 printf("invalid vf_id %d\n", res->vf_id);
17105 printf("invalid port_id %d\n", res->port_id);
17108 printf("function not implemented\n");
17111 printf("programming error: (%s)\n", strerror(-ret));
17114 printf("\n %s NIC statistics for port %-2d vf %-2d %s\n",
17115 nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
17117 printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: "
17119 stats.ipackets, stats.imissed, stats.ibytes);
17120 printf(" RX-errors: %-"PRIu64"\n", stats.ierrors);
17121 printf(" RX-nombuf: %-10"PRIu64"\n",
17123 printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: "
17125 stats.opackets, stats.oerrors, stats.obytes);
17127 printf(" %s############################%s\n",
17128 nic_stats_border, nic_stats_border);
17131 cmdline_parse_inst_t cmd_show_vf_stats = {
17132 .f = cmd_show_vf_stats_parsed,
17134 .help_str = "show vf stats <port_id> <vf_id>",
17136 (void *)&cmd_show_vf_stats_show,
17137 (void *)&cmd_show_vf_stats_vf,
17138 (void *)&cmd_show_vf_stats_stats,
17139 (void *)&cmd_show_vf_stats_port_id,
17140 (void *)&cmd_show_vf_stats_vf_id,
17145 /* clear vf stats */
17147 /* Common result structure for clear vf stats */
17148 struct cmd_clear_vf_stats_result {
17149 cmdline_fixed_string_t clear;
17150 cmdline_fixed_string_t vf;
17151 cmdline_fixed_string_t stats;
17156 /* Common CLI fields clear vf stats*/
17157 cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
17158 TOKEN_STRING_INITIALIZER
17159 (struct cmd_clear_vf_stats_result,
17161 cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
17162 TOKEN_STRING_INITIALIZER
17163 (struct cmd_clear_vf_stats_result,
17165 cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
17166 TOKEN_STRING_INITIALIZER
17167 (struct cmd_clear_vf_stats_result,
17169 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
17170 TOKEN_NUM_INITIALIZER
17171 (struct cmd_clear_vf_stats_result,
17173 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
17174 TOKEN_NUM_INITIALIZER
17175 (struct cmd_clear_vf_stats_result,
17179 cmd_clear_vf_stats_parsed(
17180 void *parsed_result,
17181 __rte_unused struct cmdline *cl,
17182 __rte_unused void *data)
17184 struct cmd_clear_vf_stats_result *res = parsed_result;
17185 int ret = -ENOTSUP;
17187 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17190 #ifdef RTE_NET_I40E
17191 if (ret == -ENOTSUP)
17192 ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
17195 #ifdef RTE_NET_BNXT
17196 if (ret == -ENOTSUP)
17197 ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
17205 printf("invalid vf_id %d\n", res->vf_id);
17208 printf("invalid port_id %d\n", res->port_id);
17211 printf("function not implemented\n");
17214 printf("programming error: (%s)\n", strerror(-ret));
17218 cmdline_parse_inst_t cmd_clear_vf_stats = {
17219 .f = cmd_clear_vf_stats_parsed,
17221 .help_str = "clear vf stats <port_id> <vf_id>",
17223 (void *)&cmd_clear_vf_stats_clear,
17224 (void *)&cmd_clear_vf_stats_vf,
17225 (void *)&cmd_clear_vf_stats_stats,
17226 (void *)&cmd_clear_vf_stats_port_id,
17227 (void *)&cmd_clear_vf_stats_vf_id,
17232 /* port config pctype mapping reset */
17234 /* Common result structure for port config pctype mapping reset */
17235 struct cmd_pctype_mapping_reset_result {
17236 cmdline_fixed_string_t port;
17237 cmdline_fixed_string_t config;
17239 cmdline_fixed_string_t pctype;
17240 cmdline_fixed_string_t mapping;
17241 cmdline_fixed_string_t reset;
17244 /* Common CLI fields for port config pctype mapping reset*/
17245 cmdline_parse_token_string_t cmd_pctype_mapping_reset_port =
17246 TOKEN_STRING_INITIALIZER
17247 (struct cmd_pctype_mapping_reset_result,
17249 cmdline_parse_token_string_t cmd_pctype_mapping_reset_config =
17250 TOKEN_STRING_INITIALIZER
17251 (struct cmd_pctype_mapping_reset_result,
17253 cmdline_parse_token_num_t cmd_pctype_mapping_reset_port_id =
17254 TOKEN_NUM_INITIALIZER
17255 (struct cmd_pctype_mapping_reset_result,
17257 cmdline_parse_token_string_t cmd_pctype_mapping_reset_pctype =
17258 TOKEN_STRING_INITIALIZER
17259 (struct cmd_pctype_mapping_reset_result,
17261 cmdline_parse_token_string_t cmd_pctype_mapping_reset_mapping =
17262 TOKEN_STRING_INITIALIZER
17263 (struct cmd_pctype_mapping_reset_result,
17264 mapping, "mapping");
17265 cmdline_parse_token_string_t cmd_pctype_mapping_reset_reset =
17266 TOKEN_STRING_INITIALIZER
17267 (struct cmd_pctype_mapping_reset_result,
17271 cmd_pctype_mapping_reset_parsed(
17272 void *parsed_result,
17273 __rte_unused struct cmdline *cl,
17274 __rte_unused void *data)
17276 struct cmd_pctype_mapping_reset_result *res = parsed_result;
17277 int ret = -ENOTSUP;
17279 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17282 #ifdef RTE_NET_I40E
17283 ret = rte_pmd_i40e_flow_type_mapping_reset(res->port_id);
17290 printf("invalid port_id %d\n", res->port_id);
17293 printf("function not implemented\n");
17296 printf("programming error: (%s)\n", strerror(-ret));
17300 cmdline_parse_inst_t cmd_pctype_mapping_reset = {
17301 .f = cmd_pctype_mapping_reset_parsed,
17303 .help_str = "port config <port_id> pctype mapping reset",
17305 (void *)&cmd_pctype_mapping_reset_port,
17306 (void *)&cmd_pctype_mapping_reset_config,
17307 (void *)&cmd_pctype_mapping_reset_port_id,
17308 (void *)&cmd_pctype_mapping_reset_pctype,
17309 (void *)&cmd_pctype_mapping_reset_mapping,
17310 (void *)&cmd_pctype_mapping_reset_reset,
17315 /* show port pctype mapping */
17317 /* Common result structure for show port pctype mapping */
17318 struct cmd_pctype_mapping_get_result {
17319 cmdline_fixed_string_t show;
17320 cmdline_fixed_string_t port;
17322 cmdline_fixed_string_t pctype;
17323 cmdline_fixed_string_t mapping;
17326 /* Common CLI fields for pctype mapping get */
17327 cmdline_parse_token_string_t cmd_pctype_mapping_get_show =
17328 TOKEN_STRING_INITIALIZER
17329 (struct cmd_pctype_mapping_get_result,
17331 cmdline_parse_token_string_t cmd_pctype_mapping_get_port =
17332 TOKEN_STRING_INITIALIZER
17333 (struct cmd_pctype_mapping_get_result,
17335 cmdline_parse_token_num_t cmd_pctype_mapping_get_port_id =
17336 TOKEN_NUM_INITIALIZER
17337 (struct cmd_pctype_mapping_get_result,
17339 cmdline_parse_token_string_t cmd_pctype_mapping_get_pctype =
17340 TOKEN_STRING_INITIALIZER
17341 (struct cmd_pctype_mapping_get_result,
17343 cmdline_parse_token_string_t cmd_pctype_mapping_get_mapping =
17344 TOKEN_STRING_INITIALIZER
17345 (struct cmd_pctype_mapping_get_result,
17346 mapping, "mapping");
17349 cmd_pctype_mapping_get_parsed(
17350 void *parsed_result,
17351 __rte_unused struct cmdline *cl,
17352 __rte_unused void *data)
17354 struct cmd_pctype_mapping_get_result *res = parsed_result;
17355 int ret = -ENOTSUP;
17356 #ifdef RTE_NET_I40E
17357 struct rte_pmd_i40e_flow_type_mapping
17358 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
17359 int i, j, first_pctype;
17362 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17365 #ifdef RTE_NET_I40E
17366 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, mapping);
17373 printf("invalid port_id %d\n", res->port_id);
17376 printf("function not implemented\n");
17379 printf("programming error: (%s)\n", strerror(-ret));
17383 #ifdef RTE_NET_I40E
17384 for (i = 0; i < RTE_PMD_I40E_FLOW_TYPE_MAX; i++) {
17385 if (mapping[i].pctype != 0ULL) {
17388 printf("pctype: ");
17389 for (j = 0; j < RTE_PMD_I40E_PCTYPE_MAX; j++) {
17390 if (mapping[i].pctype & (1ULL << j)) {
17391 printf(first_pctype ?
17392 "%02d" : ",%02d", j);
17396 printf(" -> flowtype: %02d\n", mapping[i].flow_type);
17402 cmdline_parse_inst_t cmd_pctype_mapping_get = {
17403 .f = cmd_pctype_mapping_get_parsed,
17405 .help_str = "show port <port_id> pctype mapping",
17407 (void *)&cmd_pctype_mapping_get_show,
17408 (void *)&cmd_pctype_mapping_get_port,
17409 (void *)&cmd_pctype_mapping_get_port_id,
17410 (void *)&cmd_pctype_mapping_get_pctype,
17411 (void *)&cmd_pctype_mapping_get_mapping,
17416 /* port config pctype mapping update */
17418 /* Common result structure for port config pctype mapping update */
17419 struct cmd_pctype_mapping_update_result {
17420 cmdline_fixed_string_t port;
17421 cmdline_fixed_string_t config;
17423 cmdline_fixed_string_t pctype;
17424 cmdline_fixed_string_t mapping;
17425 cmdline_fixed_string_t update;
17426 cmdline_fixed_string_t pctype_list;
17427 uint16_t flow_type;
17430 /* Common CLI fields for pctype mapping update*/
17431 cmdline_parse_token_string_t cmd_pctype_mapping_update_port =
17432 TOKEN_STRING_INITIALIZER
17433 (struct cmd_pctype_mapping_update_result,
17435 cmdline_parse_token_string_t cmd_pctype_mapping_update_config =
17436 TOKEN_STRING_INITIALIZER
17437 (struct cmd_pctype_mapping_update_result,
17439 cmdline_parse_token_num_t cmd_pctype_mapping_update_port_id =
17440 TOKEN_NUM_INITIALIZER
17441 (struct cmd_pctype_mapping_update_result,
17443 cmdline_parse_token_string_t cmd_pctype_mapping_update_pctype =
17444 TOKEN_STRING_INITIALIZER
17445 (struct cmd_pctype_mapping_update_result,
17447 cmdline_parse_token_string_t cmd_pctype_mapping_update_mapping =
17448 TOKEN_STRING_INITIALIZER
17449 (struct cmd_pctype_mapping_update_result,
17450 mapping, "mapping");
17451 cmdline_parse_token_string_t cmd_pctype_mapping_update_update =
17452 TOKEN_STRING_INITIALIZER
17453 (struct cmd_pctype_mapping_update_result,
17455 cmdline_parse_token_string_t cmd_pctype_mapping_update_pc_type =
17456 TOKEN_STRING_INITIALIZER
17457 (struct cmd_pctype_mapping_update_result,
17458 pctype_list, NULL);
17459 cmdline_parse_token_num_t cmd_pctype_mapping_update_flow_type =
17460 TOKEN_NUM_INITIALIZER
17461 (struct cmd_pctype_mapping_update_result,
17462 flow_type, UINT16);
17465 cmd_pctype_mapping_update_parsed(
17466 void *parsed_result,
17467 __rte_unused struct cmdline *cl,
17468 __rte_unused void *data)
17470 struct cmd_pctype_mapping_update_result *res = parsed_result;
17471 int ret = -ENOTSUP;
17472 #ifdef RTE_NET_I40E
17473 struct rte_pmd_i40e_flow_type_mapping mapping;
17475 unsigned int nb_item;
17476 unsigned int pctype_list[RTE_PMD_I40E_PCTYPE_MAX];
17479 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17482 #ifdef RTE_NET_I40E
17483 nb_item = parse_item_list(res->pctype_list, "pctypes",
17484 RTE_PMD_I40E_PCTYPE_MAX, pctype_list, 1);
17485 mapping.flow_type = res->flow_type;
17486 for (i = 0, mapping.pctype = 0ULL; i < nb_item; i++)
17487 mapping.pctype |= (1ULL << pctype_list[i]);
17488 ret = rte_pmd_i40e_flow_type_mapping_update(res->port_id,
17498 printf("invalid pctype or flow type\n");
17501 printf("invalid port_id %d\n", res->port_id);
17504 printf("function not implemented\n");
17507 printf("programming error: (%s)\n", strerror(-ret));
17511 cmdline_parse_inst_t cmd_pctype_mapping_update = {
17512 .f = cmd_pctype_mapping_update_parsed,
17514 .help_str = "port config <port_id> pctype mapping update"
17515 " <pctype_id_0,[pctype_id_1]*> <flowtype_id>",
17517 (void *)&cmd_pctype_mapping_update_port,
17518 (void *)&cmd_pctype_mapping_update_config,
17519 (void *)&cmd_pctype_mapping_update_port_id,
17520 (void *)&cmd_pctype_mapping_update_pctype,
17521 (void *)&cmd_pctype_mapping_update_mapping,
17522 (void *)&cmd_pctype_mapping_update_update,
17523 (void *)&cmd_pctype_mapping_update_pc_type,
17524 (void *)&cmd_pctype_mapping_update_flow_type,
17529 /* ptype mapping get */
17531 /* Common result structure for ptype mapping get */
17532 struct cmd_ptype_mapping_get_result {
17533 cmdline_fixed_string_t ptype;
17534 cmdline_fixed_string_t mapping;
17535 cmdline_fixed_string_t get;
17537 uint8_t valid_only;
17540 /* Common CLI fields for ptype mapping get */
17541 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype =
17542 TOKEN_STRING_INITIALIZER
17543 (struct cmd_ptype_mapping_get_result,
17545 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping =
17546 TOKEN_STRING_INITIALIZER
17547 (struct cmd_ptype_mapping_get_result,
17548 mapping, "mapping");
17549 cmdline_parse_token_string_t cmd_ptype_mapping_get_get =
17550 TOKEN_STRING_INITIALIZER
17551 (struct cmd_ptype_mapping_get_result,
17553 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id =
17554 TOKEN_NUM_INITIALIZER
17555 (struct cmd_ptype_mapping_get_result,
17557 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only =
17558 TOKEN_NUM_INITIALIZER
17559 (struct cmd_ptype_mapping_get_result,
17560 valid_only, UINT8);
17563 cmd_ptype_mapping_get_parsed(
17564 void *parsed_result,
17565 __rte_unused struct cmdline *cl,
17566 __rte_unused void *data)
17568 struct cmd_ptype_mapping_get_result *res = parsed_result;
17569 int ret = -ENOTSUP;
17570 #ifdef RTE_NET_I40E
17571 int max_ptype_num = 256;
17572 struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num];
17577 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17580 #ifdef RTE_NET_I40E
17581 ret = rte_pmd_i40e_ptype_mapping_get(res->port_id,
17592 printf("invalid port_id %d\n", res->port_id);
17595 printf("function not implemented\n");
17598 printf("programming error: (%s)\n", strerror(-ret));
17601 #ifdef RTE_NET_I40E
17603 for (i = 0; i < count; i++)
17604 printf("%3d\t0x%08x\n",
17605 mapping[i].hw_ptype, mapping[i].sw_ptype);
17610 cmdline_parse_inst_t cmd_ptype_mapping_get = {
17611 .f = cmd_ptype_mapping_get_parsed,
17613 .help_str = "ptype mapping get <port_id> <valid_only>",
17615 (void *)&cmd_ptype_mapping_get_ptype,
17616 (void *)&cmd_ptype_mapping_get_mapping,
17617 (void *)&cmd_ptype_mapping_get_get,
17618 (void *)&cmd_ptype_mapping_get_port_id,
17619 (void *)&cmd_ptype_mapping_get_valid_only,
17624 /* ptype mapping replace */
17626 /* Common result structure for ptype mapping replace */
17627 struct cmd_ptype_mapping_replace_result {
17628 cmdline_fixed_string_t ptype;
17629 cmdline_fixed_string_t mapping;
17630 cmdline_fixed_string_t replace;
17637 /* Common CLI fields for ptype mapping replace */
17638 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype =
17639 TOKEN_STRING_INITIALIZER
17640 (struct cmd_ptype_mapping_replace_result,
17642 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping =
17643 TOKEN_STRING_INITIALIZER
17644 (struct cmd_ptype_mapping_replace_result,
17645 mapping, "mapping");
17646 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace =
17647 TOKEN_STRING_INITIALIZER
17648 (struct cmd_ptype_mapping_replace_result,
17649 replace, "replace");
17650 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id =
17651 TOKEN_NUM_INITIALIZER
17652 (struct cmd_ptype_mapping_replace_result,
17654 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target =
17655 TOKEN_NUM_INITIALIZER
17656 (struct cmd_ptype_mapping_replace_result,
17658 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask =
17659 TOKEN_NUM_INITIALIZER
17660 (struct cmd_ptype_mapping_replace_result,
17662 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type =
17663 TOKEN_NUM_INITIALIZER
17664 (struct cmd_ptype_mapping_replace_result,
17668 cmd_ptype_mapping_replace_parsed(
17669 void *parsed_result,
17670 __rte_unused struct cmdline *cl,
17671 __rte_unused void *data)
17673 struct cmd_ptype_mapping_replace_result *res = parsed_result;
17674 int ret = -ENOTSUP;
17676 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17679 #ifdef RTE_NET_I40E
17680 ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id,
17690 printf("invalid ptype 0x%8x or 0x%8x\n",
17691 res->target, res->pkt_type);
17694 printf("invalid port_id %d\n", res->port_id);
17697 printf("function not implemented\n");
17700 printf("programming error: (%s)\n", strerror(-ret));
17704 cmdline_parse_inst_t cmd_ptype_mapping_replace = {
17705 .f = cmd_ptype_mapping_replace_parsed,
17708 "ptype mapping replace <port_id> <target> <mask> <pkt_type>",
17710 (void *)&cmd_ptype_mapping_replace_ptype,
17711 (void *)&cmd_ptype_mapping_replace_mapping,
17712 (void *)&cmd_ptype_mapping_replace_replace,
17713 (void *)&cmd_ptype_mapping_replace_port_id,
17714 (void *)&cmd_ptype_mapping_replace_target,
17715 (void *)&cmd_ptype_mapping_replace_mask,
17716 (void *)&cmd_ptype_mapping_replace_pkt_type,
17721 /* ptype mapping reset */
17723 /* Common result structure for ptype mapping reset */
17724 struct cmd_ptype_mapping_reset_result {
17725 cmdline_fixed_string_t ptype;
17726 cmdline_fixed_string_t mapping;
17727 cmdline_fixed_string_t reset;
17731 /* Common CLI fields for ptype mapping reset*/
17732 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype =
17733 TOKEN_STRING_INITIALIZER
17734 (struct cmd_ptype_mapping_reset_result,
17736 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping =
17737 TOKEN_STRING_INITIALIZER
17738 (struct cmd_ptype_mapping_reset_result,
17739 mapping, "mapping");
17740 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset =
17741 TOKEN_STRING_INITIALIZER
17742 (struct cmd_ptype_mapping_reset_result,
17744 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id =
17745 TOKEN_NUM_INITIALIZER
17746 (struct cmd_ptype_mapping_reset_result,
17750 cmd_ptype_mapping_reset_parsed(
17751 void *parsed_result,
17752 __rte_unused struct cmdline *cl,
17753 __rte_unused void *data)
17755 struct cmd_ptype_mapping_reset_result *res = parsed_result;
17756 int ret = -ENOTSUP;
17758 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17761 #ifdef RTE_NET_I40E
17762 ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id);
17769 printf("invalid port_id %d\n", res->port_id);
17772 printf("function not implemented\n");
17775 printf("programming error: (%s)\n", strerror(-ret));
17779 cmdline_parse_inst_t cmd_ptype_mapping_reset = {
17780 .f = cmd_ptype_mapping_reset_parsed,
17782 .help_str = "ptype mapping reset <port_id>",
17784 (void *)&cmd_ptype_mapping_reset_ptype,
17785 (void *)&cmd_ptype_mapping_reset_mapping,
17786 (void *)&cmd_ptype_mapping_reset_reset,
17787 (void *)&cmd_ptype_mapping_reset_port_id,
17792 /* ptype mapping update */
17794 /* Common result structure for ptype mapping update */
17795 struct cmd_ptype_mapping_update_result {
17796 cmdline_fixed_string_t ptype;
17797 cmdline_fixed_string_t mapping;
17798 cmdline_fixed_string_t reset;
17804 /* Common CLI fields for ptype mapping update*/
17805 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype =
17806 TOKEN_STRING_INITIALIZER
17807 (struct cmd_ptype_mapping_update_result,
17809 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping =
17810 TOKEN_STRING_INITIALIZER
17811 (struct cmd_ptype_mapping_update_result,
17812 mapping, "mapping");
17813 cmdline_parse_token_string_t cmd_ptype_mapping_update_update =
17814 TOKEN_STRING_INITIALIZER
17815 (struct cmd_ptype_mapping_update_result,
17817 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id =
17818 TOKEN_NUM_INITIALIZER
17819 (struct cmd_ptype_mapping_update_result,
17821 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype =
17822 TOKEN_NUM_INITIALIZER
17823 (struct cmd_ptype_mapping_update_result,
17825 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype =
17826 TOKEN_NUM_INITIALIZER
17827 (struct cmd_ptype_mapping_update_result,
17831 cmd_ptype_mapping_update_parsed(
17832 void *parsed_result,
17833 __rte_unused struct cmdline *cl,
17834 __rte_unused void *data)
17836 struct cmd_ptype_mapping_update_result *res = parsed_result;
17837 int ret = -ENOTSUP;
17838 #ifdef RTE_NET_I40E
17839 struct rte_pmd_i40e_ptype_mapping mapping;
17841 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17844 #ifdef RTE_NET_I40E
17845 mapping.hw_ptype = res->hw_ptype;
17846 mapping.sw_ptype = res->sw_ptype;
17847 ret = rte_pmd_i40e_ptype_mapping_update(res->port_id,
17857 printf("invalid ptype 0x%8x\n", res->sw_ptype);
17860 printf("invalid port_id %d\n", res->port_id);
17863 printf("function not implemented\n");
17866 printf("programming error: (%s)\n", strerror(-ret));
17870 cmdline_parse_inst_t cmd_ptype_mapping_update = {
17871 .f = cmd_ptype_mapping_update_parsed,
17873 .help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>",
17875 (void *)&cmd_ptype_mapping_update_ptype,
17876 (void *)&cmd_ptype_mapping_update_mapping,
17877 (void *)&cmd_ptype_mapping_update_update,
17878 (void *)&cmd_ptype_mapping_update_port_id,
17879 (void *)&cmd_ptype_mapping_update_hw_ptype,
17880 (void *)&cmd_ptype_mapping_update_sw_ptype,
17885 /* Common result structure for file commands */
17886 struct cmd_cmdfile_result {
17887 cmdline_fixed_string_t load;
17888 cmdline_fixed_string_t filename;
17891 /* Common CLI fields for file commands */
17892 cmdline_parse_token_string_t cmd_load_cmdfile =
17893 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
17894 cmdline_parse_token_string_t cmd_load_cmdfile_filename =
17895 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
17898 cmd_load_from_file_parsed(
17899 void *parsed_result,
17900 __rte_unused struct cmdline *cl,
17901 __rte_unused void *data)
17903 struct cmd_cmdfile_result *res = parsed_result;
17905 cmdline_read_from_file(res->filename);
17908 cmdline_parse_inst_t cmd_load_from_file = {
17909 .f = cmd_load_from_file_parsed,
17911 .help_str = "load <filename>",
17913 (void *)&cmd_load_cmdfile,
17914 (void *)&cmd_load_cmdfile_filename,
17919 /* Get Rx offloads capabilities */
17920 struct cmd_rx_offload_get_capa_result {
17921 cmdline_fixed_string_t show;
17922 cmdline_fixed_string_t port;
17924 cmdline_fixed_string_t rx_offload;
17925 cmdline_fixed_string_t capabilities;
17928 cmdline_parse_token_string_t cmd_rx_offload_get_capa_show =
17929 TOKEN_STRING_INITIALIZER
17930 (struct cmd_rx_offload_get_capa_result,
17932 cmdline_parse_token_string_t cmd_rx_offload_get_capa_port =
17933 TOKEN_STRING_INITIALIZER
17934 (struct cmd_rx_offload_get_capa_result,
17936 cmdline_parse_token_num_t cmd_rx_offload_get_capa_port_id =
17937 TOKEN_NUM_INITIALIZER
17938 (struct cmd_rx_offload_get_capa_result,
17940 cmdline_parse_token_string_t cmd_rx_offload_get_capa_rx_offload =
17941 TOKEN_STRING_INITIALIZER
17942 (struct cmd_rx_offload_get_capa_result,
17943 rx_offload, "rx_offload");
17944 cmdline_parse_token_string_t cmd_rx_offload_get_capa_capabilities =
17945 TOKEN_STRING_INITIALIZER
17946 (struct cmd_rx_offload_get_capa_result,
17947 capabilities, "capabilities");
17950 print_rx_offloads(uint64_t offloads)
17952 uint64_t single_offload;
17960 begin = __builtin_ctzll(offloads);
17961 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
17963 single_offload = 1ULL << begin;
17964 for (bit = begin; bit < end; bit++) {
17965 if (offloads & single_offload)
17967 rte_eth_dev_rx_offload_name(single_offload));
17968 single_offload <<= 1;
17973 cmd_rx_offload_get_capa_parsed(
17974 void *parsed_result,
17975 __rte_unused struct cmdline *cl,
17976 __rte_unused void *data)
17978 struct cmd_rx_offload_get_capa_result *res = parsed_result;
17979 struct rte_eth_dev_info dev_info;
17980 portid_t port_id = res->port_id;
17981 uint64_t queue_offloads;
17982 uint64_t port_offloads;
17985 ret = eth_dev_info_get_print_err(port_id, &dev_info);
17989 queue_offloads = dev_info.rx_queue_offload_capa;
17990 port_offloads = dev_info.rx_offload_capa ^ queue_offloads;
17992 printf("Rx Offloading Capabilities of port %d :\n", port_id);
17993 printf(" Per Queue :");
17994 print_rx_offloads(queue_offloads);
17997 printf(" Per Port :");
17998 print_rx_offloads(port_offloads);
18002 cmdline_parse_inst_t cmd_rx_offload_get_capa = {
18003 .f = cmd_rx_offload_get_capa_parsed,
18005 .help_str = "show port <port_id> rx_offload capabilities",
18007 (void *)&cmd_rx_offload_get_capa_show,
18008 (void *)&cmd_rx_offload_get_capa_port,
18009 (void *)&cmd_rx_offload_get_capa_port_id,
18010 (void *)&cmd_rx_offload_get_capa_rx_offload,
18011 (void *)&cmd_rx_offload_get_capa_capabilities,
18016 /* Get Rx offloads configuration */
18017 struct cmd_rx_offload_get_configuration_result {
18018 cmdline_fixed_string_t show;
18019 cmdline_fixed_string_t port;
18021 cmdline_fixed_string_t rx_offload;
18022 cmdline_fixed_string_t configuration;
18025 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_show =
18026 TOKEN_STRING_INITIALIZER
18027 (struct cmd_rx_offload_get_configuration_result,
18029 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_port =
18030 TOKEN_STRING_INITIALIZER
18031 (struct cmd_rx_offload_get_configuration_result,
18033 cmdline_parse_token_num_t cmd_rx_offload_get_configuration_port_id =
18034 TOKEN_NUM_INITIALIZER
18035 (struct cmd_rx_offload_get_configuration_result,
18037 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_rx_offload =
18038 TOKEN_STRING_INITIALIZER
18039 (struct cmd_rx_offload_get_configuration_result,
18040 rx_offload, "rx_offload");
18041 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_configuration =
18042 TOKEN_STRING_INITIALIZER
18043 (struct cmd_rx_offload_get_configuration_result,
18044 configuration, "configuration");
18047 cmd_rx_offload_get_configuration_parsed(
18048 void *parsed_result,
18049 __rte_unused struct cmdline *cl,
18050 __rte_unused void *data)
18052 struct cmd_rx_offload_get_configuration_result *res = parsed_result;
18053 struct rte_eth_dev_info dev_info;
18054 portid_t port_id = res->port_id;
18055 struct rte_port *port = &ports[port_id];
18056 uint64_t port_offloads;
18057 uint64_t queue_offloads;
18058 uint16_t nb_rx_queues;
18062 printf("Rx Offloading Configuration of port %d :\n", port_id);
18064 port_offloads = port->dev_conf.rxmode.offloads;
18066 print_rx_offloads(port_offloads);
18069 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18073 nb_rx_queues = dev_info.nb_rx_queues;
18074 for (q = 0; q < nb_rx_queues; q++) {
18075 queue_offloads = port->rx_conf[q].offloads;
18076 printf(" Queue[%2d] :", q);
18077 print_rx_offloads(queue_offloads);
18083 cmdline_parse_inst_t cmd_rx_offload_get_configuration = {
18084 .f = cmd_rx_offload_get_configuration_parsed,
18086 .help_str = "show port <port_id> rx_offload configuration",
18088 (void *)&cmd_rx_offload_get_configuration_show,
18089 (void *)&cmd_rx_offload_get_configuration_port,
18090 (void *)&cmd_rx_offload_get_configuration_port_id,
18091 (void *)&cmd_rx_offload_get_configuration_rx_offload,
18092 (void *)&cmd_rx_offload_get_configuration_configuration,
18097 /* Enable/Disable a per port offloading */
18098 struct cmd_config_per_port_rx_offload_result {
18099 cmdline_fixed_string_t port;
18100 cmdline_fixed_string_t config;
18102 cmdline_fixed_string_t rx_offload;
18103 cmdline_fixed_string_t offload;
18104 cmdline_fixed_string_t on_off;
18107 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_port =
18108 TOKEN_STRING_INITIALIZER
18109 (struct cmd_config_per_port_rx_offload_result,
18111 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_config =
18112 TOKEN_STRING_INITIALIZER
18113 (struct cmd_config_per_port_rx_offload_result,
18115 cmdline_parse_token_num_t cmd_config_per_port_rx_offload_result_port_id =
18116 TOKEN_NUM_INITIALIZER
18117 (struct cmd_config_per_port_rx_offload_result,
18119 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_rx_offload =
18120 TOKEN_STRING_INITIALIZER
18121 (struct cmd_config_per_port_rx_offload_result,
18122 rx_offload, "rx_offload");
18123 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_offload =
18124 TOKEN_STRING_INITIALIZER
18125 (struct cmd_config_per_port_rx_offload_result,
18126 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
18127 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
18128 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
18129 "scatter#buffer_split#timestamp#security#"
18130 "keep_crc#rss_hash");
18131 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_on_off =
18132 TOKEN_STRING_INITIALIZER
18133 (struct cmd_config_per_port_rx_offload_result,
18137 search_rx_offload(const char *name)
18139 uint64_t single_offload;
18140 const char *single_name;
18144 single_offload = 1;
18145 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
18146 single_name = rte_eth_dev_rx_offload_name(single_offload);
18147 if (!strcasecmp(single_name, name)) {
18151 single_offload <<= 1;
18155 return single_offload;
18161 cmd_config_per_port_rx_offload_parsed(void *parsed_result,
18162 __rte_unused struct cmdline *cl,
18163 __rte_unused void *data)
18165 struct cmd_config_per_port_rx_offload_result *res = parsed_result;
18166 portid_t port_id = res->port_id;
18167 struct rte_eth_dev_info dev_info;
18168 struct rte_port *port = &ports[port_id];
18169 uint64_t single_offload;
18170 uint16_t nb_rx_queues;
18174 if (port->port_status != RTE_PORT_STOPPED) {
18175 printf("Error: Can't config offload when Port %d "
18176 "is not stopped\n", port_id);
18180 single_offload = search_rx_offload(res->offload);
18181 if (single_offload == 0) {
18182 printf("Unknown offload name: %s\n", res->offload);
18186 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18190 nb_rx_queues = dev_info.nb_rx_queues;
18191 if (!strcmp(res->on_off, "on")) {
18192 port->dev_conf.rxmode.offloads |= single_offload;
18193 for (q = 0; q < nb_rx_queues; q++)
18194 port->rx_conf[q].offloads |= single_offload;
18196 port->dev_conf.rxmode.offloads &= ~single_offload;
18197 for (q = 0; q < nb_rx_queues; q++)
18198 port->rx_conf[q].offloads &= ~single_offload;
18201 cmd_reconfig_device_queue(port_id, 1, 1);
18204 cmdline_parse_inst_t cmd_config_per_port_rx_offload = {
18205 .f = cmd_config_per_port_rx_offload_parsed,
18207 .help_str = "port config <port_id> rx_offload vlan_strip|ipv4_cksum|"
18208 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
18209 "macsec_strip|header_split|vlan_filter|vlan_extend|"
18210 "jumbo_frame|scatter|buffer_split|timestamp|security|"
18211 "keep_crc|rss_hash on|off",
18213 (void *)&cmd_config_per_port_rx_offload_result_port,
18214 (void *)&cmd_config_per_port_rx_offload_result_config,
18215 (void *)&cmd_config_per_port_rx_offload_result_port_id,
18216 (void *)&cmd_config_per_port_rx_offload_result_rx_offload,
18217 (void *)&cmd_config_per_port_rx_offload_result_offload,
18218 (void *)&cmd_config_per_port_rx_offload_result_on_off,
18223 /* Enable/Disable a per queue offloading */
18224 struct cmd_config_per_queue_rx_offload_result {
18225 cmdline_fixed_string_t port;
18227 cmdline_fixed_string_t rxq;
18229 cmdline_fixed_string_t rx_offload;
18230 cmdline_fixed_string_t offload;
18231 cmdline_fixed_string_t on_off;
18234 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_port =
18235 TOKEN_STRING_INITIALIZER
18236 (struct cmd_config_per_queue_rx_offload_result,
18238 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_port_id =
18239 TOKEN_NUM_INITIALIZER
18240 (struct cmd_config_per_queue_rx_offload_result,
18242 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxq =
18243 TOKEN_STRING_INITIALIZER
18244 (struct cmd_config_per_queue_rx_offload_result,
18246 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_queue_id =
18247 TOKEN_NUM_INITIALIZER
18248 (struct cmd_config_per_queue_rx_offload_result,
18250 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxoffload =
18251 TOKEN_STRING_INITIALIZER
18252 (struct cmd_config_per_queue_rx_offload_result,
18253 rx_offload, "rx_offload");
18254 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_offload =
18255 TOKEN_STRING_INITIALIZER
18256 (struct cmd_config_per_queue_rx_offload_result,
18257 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
18258 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
18259 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
18260 "scatter#buffer_split#timestamp#security#keep_crc");
18261 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_on_off =
18262 TOKEN_STRING_INITIALIZER
18263 (struct cmd_config_per_queue_rx_offload_result,
18267 cmd_config_per_queue_rx_offload_parsed(void *parsed_result,
18268 __rte_unused struct cmdline *cl,
18269 __rte_unused void *data)
18271 struct cmd_config_per_queue_rx_offload_result *res = parsed_result;
18272 struct rte_eth_dev_info dev_info;
18273 portid_t port_id = res->port_id;
18274 uint16_t queue_id = res->queue_id;
18275 struct rte_port *port = &ports[port_id];
18276 uint64_t single_offload;
18279 if (port->port_status != RTE_PORT_STOPPED) {
18280 printf("Error: Can't config offload when Port %d "
18281 "is not stopped\n", port_id);
18285 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18289 if (queue_id >= dev_info.nb_rx_queues) {
18290 printf("Error: input queue_id should be 0 ... "
18291 "%d\n", dev_info.nb_rx_queues - 1);
18295 single_offload = search_rx_offload(res->offload);
18296 if (single_offload == 0) {
18297 printf("Unknown offload name: %s\n", res->offload);
18301 if (!strcmp(res->on_off, "on"))
18302 port->rx_conf[queue_id].offloads |= single_offload;
18304 port->rx_conf[queue_id].offloads &= ~single_offload;
18306 cmd_reconfig_device_queue(port_id, 1, 1);
18309 cmdline_parse_inst_t cmd_config_per_queue_rx_offload = {
18310 .f = cmd_config_per_queue_rx_offload_parsed,
18312 .help_str = "port <port_id> rxq <queue_id> rx_offload "
18313 "vlan_strip|ipv4_cksum|"
18314 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
18315 "macsec_strip|header_split|vlan_filter|vlan_extend|"
18316 "jumbo_frame|scatter|buffer_split|timestamp|security|"
18319 (void *)&cmd_config_per_queue_rx_offload_result_port,
18320 (void *)&cmd_config_per_queue_rx_offload_result_port_id,
18321 (void *)&cmd_config_per_queue_rx_offload_result_rxq,
18322 (void *)&cmd_config_per_queue_rx_offload_result_queue_id,
18323 (void *)&cmd_config_per_queue_rx_offload_result_rxoffload,
18324 (void *)&cmd_config_per_queue_rx_offload_result_offload,
18325 (void *)&cmd_config_per_queue_rx_offload_result_on_off,
18330 /* Get Tx offloads capabilities */
18331 struct cmd_tx_offload_get_capa_result {
18332 cmdline_fixed_string_t show;
18333 cmdline_fixed_string_t port;
18335 cmdline_fixed_string_t tx_offload;
18336 cmdline_fixed_string_t capabilities;
18339 cmdline_parse_token_string_t cmd_tx_offload_get_capa_show =
18340 TOKEN_STRING_INITIALIZER
18341 (struct cmd_tx_offload_get_capa_result,
18343 cmdline_parse_token_string_t cmd_tx_offload_get_capa_port =
18344 TOKEN_STRING_INITIALIZER
18345 (struct cmd_tx_offload_get_capa_result,
18347 cmdline_parse_token_num_t cmd_tx_offload_get_capa_port_id =
18348 TOKEN_NUM_INITIALIZER
18349 (struct cmd_tx_offload_get_capa_result,
18351 cmdline_parse_token_string_t cmd_tx_offload_get_capa_tx_offload =
18352 TOKEN_STRING_INITIALIZER
18353 (struct cmd_tx_offload_get_capa_result,
18354 tx_offload, "tx_offload");
18355 cmdline_parse_token_string_t cmd_tx_offload_get_capa_capabilities =
18356 TOKEN_STRING_INITIALIZER
18357 (struct cmd_tx_offload_get_capa_result,
18358 capabilities, "capabilities");
18361 print_tx_offloads(uint64_t offloads)
18363 uint64_t single_offload;
18371 begin = __builtin_ctzll(offloads);
18372 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
18374 single_offload = 1ULL << begin;
18375 for (bit = begin; bit < end; bit++) {
18376 if (offloads & single_offload)
18378 rte_eth_dev_tx_offload_name(single_offload));
18379 single_offload <<= 1;
18384 cmd_tx_offload_get_capa_parsed(
18385 void *parsed_result,
18386 __rte_unused struct cmdline *cl,
18387 __rte_unused void *data)
18389 struct cmd_tx_offload_get_capa_result *res = parsed_result;
18390 struct rte_eth_dev_info dev_info;
18391 portid_t port_id = res->port_id;
18392 uint64_t queue_offloads;
18393 uint64_t port_offloads;
18396 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18400 queue_offloads = dev_info.tx_queue_offload_capa;
18401 port_offloads = dev_info.tx_offload_capa ^ queue_offloads;
18403 printf("Tx Offloading Capabilities of port %d :\n", port_id);
18404 printf(" Per Queue :");
18405 print_tx_offloads(queue_offloads);
18408 printf(" Per Port :");
18409 print_tx_offloads(port_offloads);
18413 cmdline_parse_inst_t cmd_tx_offload_get_capa = {
18414 .f = cmd_tx_offload_get_capa_parsed,
18416 .help_str = "show port <port_id> tx_offload capabilities",
18418 (void *)&cmd_tx_offload_get_capa_show,
18419 (void *)&cmd_tx_offload_get_capa_port,
18420 (void *)&cmd_tx_offload_get_capa_port_id,
18421 (void *)&cmd_tx_offload_get_capa_tx_offload,
18422 (void *)&cmd_tx_offload_get_capa_capabilities,
18427 /* Get Tx offloads configuration */
18428 struct cmd_tx_offload_get_configuration_result {
18429 cmdline_fixed_string_t show;
18430 cmdline_fixed_string_t port;
18432 cmdline_fixed_string_t tx_offload;
18433 cmdline_fixed_string_t configuration;
18436 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_show =
18437 TOKEN_STRING_INITIALIZER
18438 (struct cmd_tx_offload_get_configuration_result,
18440 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_port =
18441 TOKEN_STRING_INITIALIZER
18442 (struct cmd_tx_offload_get_configuration_result,
18444 cmdline_parse_token_num_t cmd_tx_offload_get_configuration_port_id =
18445 TOKEN_NUM_INITIALIZER
18446 (struct cmd_tx_offload_get_configuration_result,
18448 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_tx_offload =
18449 TOKEN_STRING_INITIALIZER
18450 (struct cmd_tx_offload_get_configuration_result,
18451 tx_offload, "tx_offload");
18452 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_configuration =
18453 TOKEN_STRING_INITIALIZER
18454 (struct cmd_tx_offload_get_configuration_result,
18455 configuration, "configuration");
18458 cmd_tx_offload_get_configuration_parsed(
18459 void *parsed_result,
18460 __rte_unused struct cmdline *cl,
18461 __rte_unused void *data)
18463 struct cmd_tx_offload_get_configuration_result *res = parsed_result;
18464 struct rte_eth_dev_info dev_info;
18465 portid_t port_id = res->port_id;
18466 struct rte_port *port = &ports[port_id];
18467 uint64_t port_offloads;
18468 uint64_t queue_offloads;
18469 uint16_t nb_tx_queues;
18473 printf("Tx Offloading Configuration of port %d :\n", port_id);
18475 port_offloads = port->dev_conf.txmode.offloads;
18477 print_tx_offloads(port_offloads);
18480 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18484 nb_tx_queues = dev_info.nb_tx_queues;
18485 for (q = 0; q < nb_tx_queues; q++) {
18486 queue_offloads = port->tx_conf[q].offloads;
18487 printf(" Queue[%2d] :", q);
18488 print_tx_offloads(queue_offloads);
18494 cmdline_parse_inst_t cmd_tx_offload_get_configuration = {
18495 .f = cmd_tx_offload_get_configuration_parsed,
18497 .help_str = "show port <port_id> tx_offload configuration",
18499 (void *)&cmd_tx_offload_get_configuration_show,
18500 (void *)&cmd_tx_offload_get_configuration_port,
18501 (void *)&cmd_tx_offload_get_configuration_port_id,
18502 (void *)&cmd_tx_offload_get_configuration_tx_offload,
18503 (void *)&cmd_tx_offload_get_configuration_configuration,
18508 /* Enable/Disable a per port offloading */
18509 struct cmd_config_per_port_tx_offload_result {
18510 cmdline_fixed_string_t port;
18511 cmdline_fixed_string_t config;
18513 cmdline_fixed_string_t tx_offload;
18514 cmdline_fixed_string_t offload;
18515 cmdline_fixed_string_t on_off;
18518 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_port =
18519 TOKEN_STRING_INITIALIZER
18520 (struct cmd_config_per_port_tx_offload_result,
18522 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_config =
18523 TOKEN_STRING_INITIALIZER
18524 (struct cmd_config_per_port_tx_offload_result,
18526 cmdline_parse_token_num_t cmd_config_per_port_tx_offload_result_port_id =
18527 TOKEN_NUM_INITIALIZER
18528 (struct cmd_config_per_port_tx_offload_result,
18530 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_tx_offload =
18531 TOKEN_STRING_INITIALIZER
18532 (struct cmd_config_per_port_tx_offload_result,
18533 tx_offload, "tx_offload");
18534 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_offload =
18535 TOKEN_STRING_INITIALIZER
18536 (struct cmd_config_per_port_tx_offload_result,
18537 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
18538 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
18539 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
18540 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
18541 "mt_lockfree#multi_segs#mbuf_fast_free#security#"
18542 "send_on_timestamp");
18543 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_on_off =
18544 TOKEN_STRING_INITIALIZER
18545 (struct cmd_config_per_port_tx_offload_result,
18549 search_tx_offload(const char *name)
18551 uint64_t single_offload;
18552 const char *single_name;
18556 single_offload = 1;
18557 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
18558 single_name = rte_eth_dev_tx_offload_name(single_offload);
18559 if (single_name == NULL)
18561 if (!strcasecmp(single_name, name)) {
18564 } else if (!strcasecmp(single_name, "UNKNOWN"))
18566 single_offload <<= 1;
18570 return single_offload;
18576 cmd_config_per_port_tx_offload_parsed(void *parsed_result,
18577 __rte_unused struct cmdline *cl,
18578 __rte_unused void *data)
18580 struct cmd_config_per_port_tx_offload_result *res = parsed_result;
18581 portid_t port_id = res->port_id;
18582 struct rte_eth_dev_info dev_info;
18583 struct rte_port *port = &ports[port_id];
18584 uint64_t single_offload;
18585 uint16_t nb_tx_queues;
18589 if (port->port_status != RTE_PORT_STOPPED) {
18590 printf("Error: Can't config offload when Port %d "
18591 "is not stopped\n", port_id);
18595 single_offload = search_tx_offload(res->offload);
18596 if (single_offload == 0) {
18597 printf("Unknown offload name: %s\n", res->offload);
18601 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18605 nb_tx_queues = dev_info.nb_tx_queues;
18606 if (!strcmp(res->on_off, "on")) {
18607 port->dev_conf.txmode.offloads |= single_offload;
18608 for (q = 0; q < nb_tx_queues; q++)
18609 port->tx_conf[q].offloads |= single_offload;
18611 port->dev_conf.txmode.offloads &= ~single_offload;
18612 for (q = 0; q < nb_tx_queues; q++)
18613 port->tx_conf[q].offloads &= ~single_offload;
18616 cmd_reconfig_device_queue(port_id, 1, 1);
18619 cmdline_parse_inst_t cmd_config_per_port_tx_offload = {
18620 .f = cmd_config_per_port_tx_offload_parsed,
18622 .help_str = "port config <port_id> tx_offload "
18623 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
18624 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
18625 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
18626 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
18627 "mt_lockfree|multi_segs|mbuf_fast_free|security|"
18628 "send_on_timestamp on|off",
18630 (void *)&cmd_config_per_port_tx_offload_result_port,
18631 (void *)&cmd_config_per_port_tx_offload_result_config,
18632 (void *)&cmd_config_per_port_tx_offload_result_port_id,
18633 (void *)&cmd_config_per_port_tx_offload_result_tx_offload,
18634 (void *)&cmd_config_per_port_tx_offload_result_offload,
18635 (void *)&cmd_config_per_port_tx_offload_result_on_off,
18640 /* Enable/Disable a per queue offloading */
18641 struct cmd_config_per_queue_tx_offload_result {
18642 cmdline_fixed_string_t port;
18644 cmdline_fixed_string_t txq;
18646 cmdline_fixed_string_t tx_offload;
18647 cmdline_fixed_string_t offload;
18648 cmdline_fixed_string_t on_off;
18651 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_port =
18652 TOKEN_STRING_INITIALIZER
18653 (struct cmd_config_per_queue_tx_offload_result,
18655 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_port_id =
18656 TOKEN_NUM_INITIALIZER
18657 (struct cmd_config_per_queue_tx_offload_result,
18659 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txq =
18660 TOKEN_STRING_INITIALIZER
18661 (struct cmd_config_per_queue_tx_offload_result,
18663 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_queue_id =
18664 TOKEN_NUM_INITIALIZER
18665 (struct cmd_config_per_queue_tx_offload_result,
18667 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txoffload =
18668 TOKEN_STRING_INITIALIZER
18669 (struct cmd_config_per_queue_tx_offload_result,
18670 tx_offload, "tx_offload");
18671 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_offload =
18672 TOKEN_STRING_INITIALIZER
18673 (struct cmd_config_per_queue_tx_offload_result,
18674 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
18675 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
18676 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
18677 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
18678 "mt_lockfree#multi_segs#mbuf_fast_free#security");
18679 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_on_off =
18680 TOKEN_STRING_INITIALIZER
18681 (struct cmd_config_per_queue_tx_offload_result,
18685 cmd_config_per_queue_tx_offload_parsed(void *parsed_result,
18686 __rte_unused struct cmdline *cl,
18687 __rte_unused void *data)
18689 struct cmd_config_per_queue_tx_offload_result *res = parsed_result;
18690 struct rte_eth_dev_info dev_info;
18691 portid_t port_id = res->port_id;
18692 uint16_t queue_id = res->queue_id;
18693 struct rte_port *port = &ports[port_id];
18694 uint64_t single_offload;
18697 if (port->port_status != RTE_PORT_STOPPED) {
18698 printf("Error: Can't config offload when Port %d "
18699 "is not stopped\n", port_id);
18703 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18707 if (queue_id >= dev_info.nb_tx_queues) {
18708 printf("Error: input queue_id should be 0 ... "
18709 "%d\n", dev_info.nb_tx_queues - 1);
18713 single_offload = search_tx_offload(res->offload);
18714 if (single_offload == 0) {
18715 printf("Unknown offload name: %s\n", res->offload);
18719 if (!strcmp(res->on_off, "on"))
18720 port->tx_conf[queue_id].offloads |= single_offload;
18722 port->tx_conf[queue_id].offloads &= ~single_offload;
18724 cmd_reconfig_device_queue(port_id, 1, 1);
18727 cmdline_parse_inst_t cmd_config_per_queue_tx_offload = {
18728 .f = cmd_config_per_queue_tx_offload_parsed,
18730 .help_str = "port <port_id> txq <queue_id> tx_offload "
18731 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
18732 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
18733 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
18734 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
18735 "mt_lockfree|multi_segs|mbuf_fast_free|security "
18738 (void *)&cmd_config_per_queue_tx_offload_result_port,
18739 (void *)&cmd_config_per_queue_tx_offload_result_port_id,
18740 (void *)&cmd_config_per_queue_tx_offload_result_txq,
18741 (void *)&cmd_config_per_queue_tx_offload_result_queue_id,
18742 (void *)&cmd_config_per_queue_tx_offload_result_txoffload,
18743 (void *)&cmd_config_per_queue_tx_offload_result_offload,
18744 (void *)&cmd_config_per_queue_tx_offload_result_on_off,
18749 /* *** configure tx_metadata for specific port *** */
18750 struct cmd_config_tx_metadata_specific_result {
18751 cmdline_fixed_string_t port;
18752 cmdline_fixed_string_t keyword;
18754 cmdline_fixed_string_t item;
18759 cmd_config_tx_metadata_specific_parsed(void *parsed_result,
18760 __rte_unused struct cmdline *cl,
18761 __rte_unused void *data)
18763 struct cmd_config_tx_metadata_specific_result *res = parsed_result;
18765 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
18767 ports[res->port_id].tx_metadata = res->value;
18768 /* Add/remove callback to insert valid metadata in every Tx packet. */
18769 if (ports[res->port_id].tx_metadata)
18770 add_tx_md_callback(res->port_id);
18772 remove_tx_md_callback(res->port_id);
18773 rte_flow_dynf_metadata_register();
18776 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_port =
18777 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18779 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_keyword =
18780 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18781 keyword, "config");
18782 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_id =
18783 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18785 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_item =
18786 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18787 item, "tx_metadata");
18788 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_value =
18789 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18792 cmdline_parse_inst_t cmd_config_tx_metadata_specific = {
18793 .f = cmd_config_tx_metadata_specific_parsed,
18795 .help_str = "port config <port_id> tx_metadata <value>",
18797 (void *)&cmd_config_tx_metadata_specific_port,
18798 (void *)&cmd_config_tx_metadata_specific_keyword,
18799 (void *)&cmd_config_tx_metadata_specific_id,
18800 (void *)&cmd_config_tx_metadata_specific_item,
18801 (void *)&cmd_config_tx_metadata_specific_value,
18806 /* *** set dynf *** */
18807 struct cmd_config_tx_dynf_specific_result {
18808 cmdline_fixed_string_t port;
18809 cmdline_fixed_string_t keyword;
18811 cmdline_fixed_string_t item;
18812 cmdline_fixed_string_t name;
18813 cmdline_fixed_string_t value;
18817 cmd_config_dynf_specific_parsed(void *parsed_result,
18818 __rte_unused struct cmdline *cl,
18819 __rte_unused void *data)
18821 struct cmd_config_tx_dynf_specific_result *res = parsed_result;
18822 struct rte_mbuf_dynflag desc_flag;
18824 uint64_t old_port_flags;
18826 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
18828 flag = rte_mbuf_dynflag_lookup(res->name, NULL);
18830 if (strlcpy(desc_flag.name, res->name,
18831 RTE_MBUF_DYN_NAMESIZE) >= RTE_MBUF_DYN_NAMESIZE) {
18832 printf("Flag name too long\n");
18835 desc_flag.flags = 0;
18836 flag = rte_mbuf_dynflag_register(&desc_flag);
18838 printf("Can't register flag\n");
18841 strcpy(dynf_names[flag], desc_flag.name);
18843 old_port_flags = ports[res->port_id].mbuf_dynf;
18844 if (!strcmp(res->value, "set")) {
18845 ports[res->port_id].mbuf_dynf |= 1UL << flag;
18846 if (old_port_flags == 0)
18847 add_tx_dynf_callback(res->port_id);
18849 ports[res->port_id].mbuf_dynf &= ~(1UL << flag);
18850 if (ports[res->port_id].mbuf_dynf == 0)
18851 remove_tx_dynf_callback(res->port_id);
18855 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_port =
18856 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
18858 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_keyword =
18859 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
18860 keyword, "config");
18861 cmdline_parse_token_num_t cmd_config_tx_dynf_specific_port_id =
18862 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
18864 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_item =
18865 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
18867 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_name =
18868 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
18870 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_value =
18871 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
18872 value, "set#clear");
18874 cmdline_parse_inst_t cmd_config_tx_dynf_specific = {
18875 .f = cmd_config_dynf_specific_parsed,
18877 .help_str = "port config <port id> dynf <name> set|clear",
18879 (void *)&cmd_config_tx_dynf_specific_port,
18880 (void *)&cmd_config_tx_dynf_specific_keyword,
18881 (void *)&cmd_config_tx_dynf_specific_port_id,
18882 (void *)&cmd_config_tx_dynf_specific_item,
18883 (void *)&cmd_config_tx_dynf_specific_name,
18884 (void *)&cmd_config_tx_dynf_specific_value,
18889 /* *** display tx_metadata per port configuration *** */
18890 struct cmd_show_tx_metadata_result {
18891 cmdline_fixed_string_t cmd_show;
18892 cmdline_fixed_string_t cmd_port;
18893 cmdline_fixed_string_t cmd_keyword;
18898 cmd_show_tx_metadata_parsed(void *parsed_result,
18899 __rte_unused struct cmdline *cl,
18900 __rte_unused void *data)
18902 struct cmd_show_tx_metadata_result *res = parsed_result;
18904 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
18905 printf("invalid port id %u\n", res->cmd_pid);
18908 if (!strcmp(res->cmd_keyword, "tx_metadata")) {
18909 printf("Port %u tx_metadata: %u\n", res->cmd_pid,
18910 ports[res->cmd_pid].tx_metadata);
18914 cmdline_parse_token_string_t cmd_show_tx_metadata_show =
18915 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
18917 cmdline_parse_token_string_t cmd_show_tx_metadata_port =
18918 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
18920 cmdline_parse_token_num_t cmd_show_tx_metadata_pid =
18921 TOKEN_NUM_INITIALIZER(struct cmd_show_tx_metadata_result,
18923 cmdline_parse_token_string_t cmd_show_tx_metadata_keyword =
18924 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
18925 cmd_keyword, "tx_metadata");
18927 cmdline_parse_inst_t cmd_show_tx_metadata = {
18928 .f = cmd_show_tx_metadata_parsed,
18930 .help_str = "show port <port_id> tx_metadata",
18932 (void *)&cmd_show_tx_metadata_show,
18933 (void *)&cmd_show_tx_metadata_port,
18934 (void *)&cmd_show_tx_metadata_pid,
18935 (void *)&cmd_show_tx_metadata_keyword,
18940 /* *** show fec capability per port configuration *** */
18941 struct cmd_show_fec_capability_result {
18942 cmdline_fixed_string_t cmd_show;
18943 cmdline_fixed_string_t cmd_port;
18944 cmdline_fixed_string_t cmd_fec;
18945 cmdline_fixed_string_t cmd_keyword;
18950 cmd_show_fec_capability_parsed(void *parsed_result,
18951 __rte_unused struct cmdline *cl,
18952 __rte_unused void *data)
18954 #define FEC_CAP_NUM 2
18955 struct cmd_show_fec_capability_result *res = parsed_result;
18956 struct rte_eth_fec_capa speed_fec_capa[FEC_CAP_NUM];
18957 unsigned int num = FEC_CAP_NUM;
18958 unsigned int ret_num;
18961 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
18962 printf("Invalid port id %u\n", res->cmd_pid);
18966 ret = rte_eth_fec_get_capability(res->cmd_pid, speed_fec_capa, num);
18967 if (ret == -ENOTSUP) {
18968 printf("Function not implemented\n");
18970 } else if (ret < 0) {
18971 printf("Get FEC capability failed\n");
18975 ret_num = (unsigned int)ret;
18976 show_fec_capability(ret_num, speed_fec_capa);
18979 cmdline_parse_token_string_t cmd_show_fec_capability_show =
18980 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
18982 cmdline_parse_token_string_t cmd_show_fec_capability_port =
18983 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
18985 cmdline_parse_token_num_t cmd_show_fec_capability_pid =
18986 TOKEN_NUM_INITIALIZER(struct cmd_show_fec_capability_result,
18988 cmdline_parse_token_string_t cmd_show_fec_capability_fec =
18989 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
18991 cmdline_parse_token_string_t cmd_show_fec_capability_keyword =
18992 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
18993 cmd_keyword, "capabilities");
18995 cmdline_parse_inst_t cmd_show_capability = {
18996 .f = cmd_show_fec_capability_parsed,
18998 .help_str = "show port <port_id> fec capabilities",
19000 (void *)&cmd_show_fec_capability_show,
19001 (void *)&cmd_show_fec_capability_port,
19002 (void *)&cmd_show_fec_capability_pid,
19003 (void *)&cmd_show_fec_capability_fec,
19004 (void *)&cmd_show_fec_capability_keyword,
19009 /* *** show fec mode per port configuration *** */
19010 struct cmd_show_fec_metadata_result {
19011 cmdline_fixed_string_t cmd_show;
19012 cmdline_fixed_string_t cmd_port;
19013 cmdline_fixed_string_t cmd_keyword;
19018 cmd_show_fec_mode_parsed(void *parsed_result,
19019 __rte_unused struct cmdline *cl,
19020 __rte_unused void *data)
19022 #define FEC_NAME_SIZE 16
19023 struct cmd_show_fec_metadata_result *res = parsed_result;
19025 char buf[FEC_NAME_SIZE];
19028 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
19029 printf("Invalid port id %u\n", res->cmd_pid);
19032 ret = rte_eth_fec_get(res->cmd_pid, &mode);
19033 if (ret == -ENOTSUP) {
19034 printf("Function not implemented\n");
19036 } else if (ret < 0) {
19037 printf("Get FEC mode failed\n");
19042 case RTE_ETH_FEC_MODE_CAPA_MASK(NOFEC):
19043 strlcpy(buf, "off", sizeof(buf));
19045 case RTE_ETH_FEC_MODE_CAPA_MASK(AUTO):
19046 strlcpy(buf, "auto", sizeof(buf));
19048 case RTE_ETH_FEC_MODE_CAPA_MASK(BASER):
19049 strlcpy(buf, "baser", sizeof(buf));
19051 case RTE_ETH_FEC_MODE_CAPA_MASK(RS):
19052 strlcpy(buf, "rs", sizeof(buf));
19058 printf("%s\n", buf);
19061 cmdline_parse_token_string_t cmd_show_fec_mode_show =
19062 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
19064 cmdline_parse_token_string_t cmd_show_fec_mode_port =
19065 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
19067 cmdline_parse_token_num_t cmd_show_fec_mode_pid =
19068 TOKEN_NUM_INITIALIZER(struct cmd_show_fec_metadata_result,
19070 cmdline_parse_token_string_t cmd_show_fec_mode_keyword =
19071 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
19072 cmd_keyword, "fec_mode");
19074 cmdline_parse_inst_t cmd_show_fec_mode = {
19075 .f = cmd_show_fec_mode_parsed,
19077 .help_str = "show port <port_id> fec_mode",
19079 (void *)&cmd_show_fec_mode_show,
19080 (void *)&cmd_show_fec_mode_port,
19081 (void *)&cmd_show_fec_mode_pid,
19082 (void *)&cmd_show_fec_mode_keyword,
19087 /* *** set fec mode per port configuration *** */
19088 struct cmd_set_port_fec_mode {
19089 cmdline_fixed_string_t set;
19090 cmdline_fixed_string_t port;
19092 cmdline_fixed_string_t fec_mode;
19093 cmdline_fixed_string_t fec_value;
19096 /* Common CLI fields for set fec mode */
19097 cmdline_parse_token_string_t cmd_set_port_fec_mode_set =
19098 TOKEN_STRING_INITIALIZER
19099 (struct cmd_set_port_fec_mode,
19101 cmdline_parse_token_string_t cmd_set_port_fec_mode_port =
19102 TOKEN_STRING_INITIALIZER
19103 (struct cmd_set_port_fec_mode,
19105 cmdline_parse_token_num_t cmd_set_port_fec_mode_port_id =
19106 TOKEN_NUM_INITIALIZER
19107 (struct cmd_set_port_fec_mode,
19109 cmdline_parse_token_string_t cmd_set_port_fec_mode_str =
19110 TOKEN_STRING_INITIALIZER
19111 (struct cmd_set_port_fec_mode,
19112 fec_mode, "fec_mode");
19113 cmdline_parse_token_string_t cmd_set_port_fec_mode_value =
19114 TOKEN_STRING_INITIALIZER
19115 (struct cmd_set_port_fec_mode,
19119 cmd_set_port_fec_mode_parsed(
19120 void *parsed_result,
19121 __rte_unused struct cmdline *cl,
19122 __rte_unused void *data)
19124 struct cmd_set_port_fec_mode *res = parsed_result;
19125 uint16_t port_id = res->port_id;
19129 ret = parse_fec_mode(res->fec_value, &mode);
19131 printf("Unknown fec mode: %s for Port %d\n", res->fec_value,
19136 ret = rte_eth_fec_set(port_id, mode);
19137 if (ret == -ENOTSUP) {
19138 printf("Function not implemented\n");
19140 } else if (ret < 0) {
19141 printf("Set FEC mode failed\n");
19146 cmdline_parse_inst_t cmd_set_fec_mode = {
19147 .f = cmd_set_port_fec_mode_parsed,
19149 .help_str = "set port <port_id> fec_mode auto|off|rs|baser",
19151 (void *)&cmd_set_port_fec_mode_set,
19152 (void *)&cmd_set_port_fec_mode_port,
19153 (void *)&cmd_set_port_fec_mode_port_id,
19154 (void *)&cmd_set_port_fec_mode_str,
19155 (void *)&cmd_set_port_fec_mode_value,
19160 /* show port supported ptypes */
19162 /* Common result structure for show port ptypes */
19163 struct cmd_show_port_supported_ptypes_result {
19164 cmdline_fixed_string_t show;
19165 cmdline_fixed_string_t port;
19167 cmdline_fixed_string_t ptypes;
19170 /* Common CLI fields for show port ptypes */
19171 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_show =
19172 TOKEN_STRING_INITIALIZER
19173 (struct cmd_show_port_supported_ptypes_result,
19175 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_port =
19176 TOKEN_STRING_INITIALIZER
19177 (struct cmd_show_port_supported_ptypes_result,
19179 cmdline_parse_token_num_t cmd_show_port_supported_ptypes_port_id =
19180 TOKEN_NUM_INITIALIZER
19181 (struct cmd_show_port_supported_ptypes_result,
19183 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_ptypes =
19184 TOKEN_STRING_INITIALIZER
19185 (struct cmd_show_port_supported_ptypes_result,
19189 cmd_show_port_supported_ptypes_parsed(
19190 void *parsed_result,
19191 __rte_unused struct cmdline *cl,
19192 __rte_unused void *data)
19194 #define RSVD_PTYPE_MASK 0xf0000000
19195 #define MAX_PTYPES_PER_LAYER 16
19196 #define LTYPE_NAMESIZE 32
19197 #define PTYPE_NAMESIZE 256
19198 struct cmd_show_port_supported_ptypes_result *res = parsed_result;
19199 char buf[PTYPE_NAMESIZE], ltype[LTYPE_NAMESIZE];
19200 uint32_t ptype_mask = RTE_PTYPE_L2_MASK;
19201 uint32_t ptypes[MAX_PTYPES_PER_LAYER];
19202 uint16_t port_id = res->port_id;
19205 ret = rte_eth_dev_get_supported_ptypes(port_id, ptype_mask, NULL, 0);
19209 while (ptype_mask != RSVD_PTYPE_MASK) {
19211 switch (ptype_mask) {
19212 case RTE_PTYPE_L2_MASK:
19213 strlcpy(ltype, "L2", sizeof(ltype));
19215 case RTE_PTYPE_L3_MASK:
19216 strlcpy(ltype, "L3", sizeof(ltype));
19218 case RTE_PTYPE_L4_MASK:
19219 strlcpy(ltype, "L4", sizeof(ltype));
19221 case RTE_PTYPE_TUNNEL_MASK:
19222 strlcpy(ltype, "Tunnel", sizeof(ltype));
19224 case RTE_PTYPE_INNER_L2_MASK:
19225 strlcpy(ltype, "Inner L2", sizeof(ltype));
19227 case RTE_PTYPE_INNER_L3_MASK:
19228 strlcpy(ltype, "Inner L3", sizeof(ltype));
19230 case RTE_PTYPE_INNER_L4_MASK:
19231 strlcpy(ltype, "Inner L4", sizeof(ltype));
19237 ret = rte_eth_dev_get_supported_ptypes(res->port_id,
19238 ptype_mask, ptypes,
19239 MAX_PTYPES_PER_LAYER);
19242 printf("Supported %s ptypes:\n", ltype);
19244 printf("%s ptypes unsupported\n", ltype);
19246 for (i = 0; i < ret; ++i) {
19247 rte_get_ptype_name(ptypes[i], buf, sizeof(buf));
19248 printf("%s\n", buf);
19255 cmdline_parse_inst_t cmd_show_port_supported_ptypes = {
19256 .f = cmd_show_port_supported_ptypes_parsed,
19258 .help_str = "show port <port_id> ptypes",
19260 (void *)&cmd_show_port_supported_ptypes_show,
19261 (void *)&cmd_show_port_supported_ptypes_port,
19262 (void *)&cmd_show_port_supported_ptypes_port_id,
19263 (void *)&cmd_show_port_supported_ptypes_ptypes,
19268 /* *** display rx/tx descriptor status *** */
19269 struct cmd_show_rx_tx_desc_status_result {
19270 cmdline_fixed_string_t cmd_show;
19271 cmdline_fixed_string_t cmd_port;
19272 cmdline_fixed_string_t cmd_keyword;
19273 cmdline_fixed_string_t cmd_desc;
19274 cmdline_fixed_string_t cmd_status;
19281 cmd_show_rx_tx_desc_status_parsed(void *parsed_result,
19282 __rte_unused struct cmdline *cl,
19283 __rte_unused void *data)
19285 struct cmd_show_rx_tx_desc_status_result *res = parsed_result;
19288 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
19289 printf("invalid port id %u\n", res->cmd_pid);
19293 if (!strcmp(res->cmd_keyword, "rxq")) {
19294 rc = rte_eth_rx_descriptor_status(res->cmd_pid, res->cmd_qid,
19297 printf("Invalid queueid = %d\n", res->cmd_qid);
19300 if (rc == RTE_ETH_RX_DESC_AVAIL)
19301 printf("Desc status = AVAILABLE\n");
19302 else if (rc == RTE_ETH_RX_DESC_DONE)
19303 printf("Desc status = DONE\n");
19305 printf("Desc status = UNAVAILABLE\n");
19306 } else if (!strcmp(res->cmd_keyword, "txq")) {
19307 rc = rte_eth_tx_descriptor_status(res->cmd_pid, res->cmd_qid,
19310 printf("Invalid queueid = %d\n", res->cmd_qid);
19313 if (rc == RTE_ETH_TX_DESC_FULL)
19314 printf("Desc status = FULL\n");
19315 else if (rc == RTE_ETH_TX_DESC_DONE)
19316 printf("Desc status = DONE\n");
19318 printf("Desc status = UNAVAILABLE\n");
19322 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_show =
19323 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19325 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_port =
19326 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19328 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_pid =
19329 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19331 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_keyword =
19332 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19333 cmd_keyword, "rxq#txq");
19334 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_qid =
19335 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19337 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_desc =
19338 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19340 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_did =
19341 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19343 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_status =
19344 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19345 cmd_status, "status");
19346 cmdline_parse_inst_t cmd_show_rx_tx_desc_status = {
19347 .f = cmd_show_rx_tx_desc_status_parsed,
19349 .help_str = "show port <port_id> rxq|txq <queue_id> desc <desc_id> "
19352 (void *)&cmd_show_rx_tx_desc_status_show,
19353 (void *)&cmd_show_rx_tx_desc_status_port,
19354 (void *)&cmd_show_rx_tx_desc_status_pid,
19355 (void *)&cmd_show_rx_tx_desc_status_keyword,
19356 (void *)&cmd_show_rx_tx_desc_status_qid,
19357 (void *)&cmd_show_rx_tx_desc_status_desc,
19358 (void *)&cmd_show_rx_tx_desc_status_did,
19359 (void *)&cmd_show_rx_tx_desc_status_status,
19364 /* Common result structure for set port ptypes */
19365 struct cmd_set_port_ptypes_result {
19366 cmdline_fixed_string_t set;
19367 cmdline_fixed_string_t port;
19369 cmdline_fixed_string_t ptype_mask;
19373 /* Common CLI fields for set port ptypes */
19374 cmdline_parse_token_string_t cmd_set_port_ptypes_set =
19375 TOKEN_STRING_INITIALIZER
19376 (struct cmd_set_port_ptypes_result,
19378 cmdline_parse_token_string_t cmd_set_port_ptypes_port =
19379 TOKEN_STRING_INITIALIZER
19380 (struct cmd_set_port_ptypes_result,
19382 cmdline_parse_token_num_t cmd_set_port_ptypes_port_id =
19383 TOKEN_NUM_INITIALIZER
19384 (struct cmd_set_port_ptypes_result,
19386 cmdline_parse_token_string_t cmd_set_port_ptypes_mask_str =
19387 TOKEN_STRING_INITIALIZER
19388 (struct cmd_set_port_ptypes_result,
19389 ptype_mask, "ptype_mask");
19390 cmdline_parse_token_num_t cmd_set_port_ptypes_mask_u32 =
19391 TOKEN_NUM_INITIALIZER
19392 (struct cmd_set_port_ptypes_result,
19396 cmd_set_port_ptypes_parsed(
19397 void *parsed_result,
19398 __rte_unused struct cmdline *cl,
19399 __rte_unused void *data)
19401 struct cmd_set_port_ptypes_result *res = parsed_result;
19402 #define PTYPE_NAMESIZE 256
19403 char ptype_name[PTYPE_NAMESIZE];
19404 uint16_t port_id = res->port_id;
19405 uint32_t ptype_mask = res->mask;
19408 ret = rte_eth_dev_get_supported_ptypes(port_id, RTE_PTYPE_ALL_MASK,
19411 printf("Port %d doesn't support any ptypes.\n", port_id);
19415 uint32_t ptypes[ret];
19417 ret = rte_eth_dev_set_ptypes(port_id, ptype_mask, ptypes, ret);
19419 printf("Unable to set requested ptypes for Port %d\n", port_id);
19423 printf("Successfully set following ptypes for Port %d\n", port_id);
19424 for (i = 0; i < ret && ptypes[i] != RTE_PTYPE_UNKNOWN; i++) {
19425 rte_get_ptype_name(ptypes[i], ptype_name, sizeof(ptype_name));
19426 printf("%s\n", ptype_name);
19429 clear_ptypes = false;
19432 cmdline_parse_inst_t cmd_set_port_ptypes = {
19433 .f = cmd_set_port_ptypes_parsed,
19435 .help_str = "set port <port_id> ptype_mask <mask>",
19437 (void *)&cmd_set_port_ptypes_set,
19438 (void *)&cmd_set_port_ptypes_port,
19439 (void *)&cmd_set_port_ptypes_port_id,
19440 (void *)&cmd_set_port_ptypes_mask_str,
19441 (void *)&cmd_set_port_ptypes_mask_u32,
19446 /* *** display mac addresses added to a port *** */
19447 struct cmd_showport_macs_result {
19448 cmdline_fixed_string_t cmd_show;
19449 cmdline_fixed_string_t cmd_port;
19450 cmdline_fixed_string_t cmd_keyword;
19455 cmd_showport_macs_parsed(void *parsed_result,
19456 __rte_unused struct cmdline *cl,
19457 __rte_unused void *data)
19459 struct cmd_showport_macs_result *res = parsed_result;
19461 if (port_id_is_invalid(res->cmd_pid, ENABLED_WARN))
19464 if (!strcmp(res->cmd_keyword, "macs"))
19465 show_macs(res->cmd_pid);
19466 else if (!strcmp(res->cmd_keyword, "mcast_macs"))
19467 show_mcast_macs(res->cmd_pid);
19470 cmdline_parse_token_string_t cmd_showport_macs_show =
19471 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
19473 cmdline_parse_token_string_t cmd_showport_macs_port =
19474 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
19476 cmdline_parse_token_num_t cmd_showport_macs_pid =
19477 TOKEN_NUM_INITIALIZER(struct cmd_showport_macs_result,
19479 cmdline_parse_token_string_t cmd_showport_macs_keyword =
19480 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
19481 cmd_keyword, "macs#mcast_macs");
19483 cmdline_parse_inst_t cmd_showport_macs = {
19484 .f = cmd_showport_macs_parsed,
19486 .help_str = "show port <port_id> macs|mcast_macs",
19488 (void *)&cmd_showport_macs_show,
19489 (void *)&cmd_showport_macs_port,
19490 (void *)&cmd_showport_macs_pid,
19491 (void *)&cmd_showport_macs_keyword,
19496 /* ******************************************************************************** */
19498 /* list of instructions */
19499 cmdline_parse_ctx_t main_ctx[] = {
19500 (cmdline_parse_inst_t *)&cmd_help_brief,
19501 (cmdline_parse_inst_t *)&cmd_help_long,
19502 (cmdline_parse_inst_t *)&cmd_quit,
19503 (cmdline_parse_inst_t *)&cmd_load_from_file,
19504 (cmdline_parse_inst_t *)&cmd_showport,
19505 (cmdline_parse_inst_t *)&cmd_showqueue,
19506 (cmdline_parse_inst_t *)&cmd_showeeprom,
19507 (cmdline_parse_inst_t *)&cmd_showportall,
19508 (cmdline_parse_inst_t *)&cmd_showdevice,
19509 (cmdline_parse_inst_t *)&cmd_showcfg,
19510 (cmdline_parse_inst_t *)&cmd_showfwdall,
19511 (cmdline_parse_inst_t *)&cmd_start,
19512 (cmdline_parse_inst_t *)&cmd_start_tx_first,
19513 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
19514 (cmdline_parse_inst_t *)&cmd_set_link_up,
19515 (cmdline_parse_inst_t *)&cmd_set_link_down,
19516 (cmdline_parse_inst_t *)&cmd_reset,
19517 (cmdline_parse_inst_t *)&cmd_set_numbers,
19518 (cmdline_parse_inst_t *)&cmd_set_log,
19519 (cmdline_parse_inst_t *)&cmd_set_rxoffs,
19520 (cmdline_parse_inst_t *)&cmd_set_rxpkts,
19521 (cmdline_parse_inst_t *)&cmd_set_txpkts,
19522 (cmdline_parse_inst_t *)&cmd_set_txsplit,
19523 (cmdline_parse_inst_t *)&cmd_set_txtimes,
19524 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
19525 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
19526 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
19527 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
19528 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
19529 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
19530 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
19531 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
19532 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
19533 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
19534 (cmdline_parse_inst_t *)&cmd_set_link_check,
19535 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
19536 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
19537 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
19538 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
19539 #ifdef RTE_NET_BOND
19540 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
19541 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
19542 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
19543 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
19544 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
19545 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
19546 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
19547 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
19548 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
19549 (cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues,
19550 (cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy,
19552 (cmdline_parse_inst_t *)&cmd_vlan_offload,
19553 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
19554 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
19555 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
19556 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
19557 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
19558 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
19559 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
19560 (cmdline_parse_inst_t *)&cmd_csum_set,
19561 (cmdline_parse_inst_t *)&cmd_csum_show,
19562 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
19563 (cmdline_parse_inst_t *)&cmd_tso_set,
19564 (cmdline_parse_inst_t *)&cmd_tso_show,
19565 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
19566 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
19567 (cmdline_parse_inst_t *)&cmd_gro_enable,
19568 (cmdline_parse_inst_t *)&cmd_gro_flush,
19569 (cmdline_parse_inst_t *)&cmd_gro_show,
19570 (cmdline_parse_inst_t *)&cmd_gso_enable,
19571 (cmdline_parse_inst_t *)&cmd_gso_size,
19572 (cmdline_parse_inst_t *)&cmd_gso_show,
19573 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
19574 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
19575 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
19576 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
19577 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
19578 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
19579 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
19580 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
19581 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
19582 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
19583 (cmdline_parse_inst_t *)&cmd_config_dcb,
19584 (cmdline_parse_inst_t *)&cmd_read_reg,
19585 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
19586 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
19587 (cmdline_parse_inst_t *)&cmd_write_reg,
19588 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
19589 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
19590 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
19591 (cmdline_parse_inst_t *)&cmd_stop,
19592 (cmdline_parse_inst_t *)&cmd_mac_addr,
19593 (cmdline_parse_inst_t *)&cmd_set_fwd_eth_peer,
19594 (cmdline_parse_inst_t *)&cmd_set_qmap,
19595 (cmdline_parse_inst_t *)&cmd_set_xstats_hide_zero,
19596 (cmdline_parse_inst_t *)&cmd_set_record_core_cycles,
19597 (cmdline_parse_inst_t *)&cmd_set_record_burst_stats,
19598 (cmdline_parse_inst_t *)&cmd_operate_port,
19599 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
19600 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
19601 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
19602 (cmdline_parse_inst_t *)&cmd_operate_detach_device,
19603 (cmdline_parse_inst_t *)&cmd_set_port_setup_on,
19604 (cmdline_parse_inst_t *)&cmd_config_speed_all,
19605 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
19606 (cmdline_parse_inst_t *)&cmd_config_loopback_all,
19607 (cmdline_parse_inst_t *)&cmd_config_loopback_specific,
19608 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
19609 (cmdline_parse_inst_t *)&cmd_config_mtu,
19610 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
19611 (cmdline_parse_inst_t *)&cmd_config_max_lro_pkt_size,
19612 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
19613 (cmdline_parse_inst_t *)&cmd_config_rss,
19614 (cmdline_parse_inst_t *)&cmd_config_rxtx_ring_size,
19615 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
19616 (cmdline_parse_inst_t *)&cmd_config_deferred_start_rxtx_queue,
19617 (cmdline_parse_inst_t *)&cmd_setup_rxtx_queue,
19618 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
19619 (cmdline_parse_inst_t *)&cmd_showport_reta,
19620 (cmdline_parse_inst_t *)&cmd_showport_macs,
19621 (cmdline_parse_inst_t *)&cmd_config_burst,
19622 (cmdline_parse_inst_t *)&cmd_config_thresh,
19623 (cmdline_parse_inst_t *)&cmd_config_threshold,
19624 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
19625 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
19626 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
19627 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
19628 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
19629 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
19630 (cmdline_parse_inst_t *)&cmd_global_config,
19631 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
19632 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
19633 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
19634 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
19635 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
19636 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
19637 (cmdline_parse_inst_t *)&cmd_dump,
19638 (cmdline_parse_inst_t *)&cmd_dump_one,
19639 (cmdline_parse_inst_t *)&cmd_syn_filter,
19640 (cmdline_parse_inst_t *)&cmd_2tuple_filter,
19641 (cmdline_parse_inst_t *)&cmd_5tuple_filter,
19642 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
19643 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
19644 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
19645 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director,
19646 (cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director,
19647 (cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director,
19648 (cmdline_parse_inst_t *)&cmd_add_del_raw_flow_director,
19649 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
19650 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
19651 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
19652 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
19653 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
19654 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
19655 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
19656 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
19657 (cmdline_parse_inst_t *)&cmd_get_hash_global_config,
19658 (cmdline_parse_inst_t *)&cmd_set_hash_global_config,
19659 (cmdline_parse_inst_t *)&cmd_set_hash_input_set,
19660 (cmdline_parse_inst_t *)&cmd_set_fdir_input_set,
19661 (cmdline_parse_inst_t *)&cmd_flow,
19662 (cmdline_parse_inst_t *)&cmd_show_port_meter_cap,
19663 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm,
19664 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm,
19665 (cmdline_parse_inst_t *)&cmd_del_port_meter_profile,
19666 (cmdline_parse_inst_t *)&cmd_create_port_meter,
19667 (cmdline_parse_inst_t *)&cmd_enable_port_meter,
19668 (cmdline_parse_inst_t *)&cmd_disable_port_meter,
19669 (cmdline_parse_inst_t *)&cmd_del_port_meter,
19670 (cmdline_parse_inst_t *)&cmd_set_port_meter_profile,
19671 (cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table,
19672 (cmdline_parse_inst_t *)&cmd_set_port_meter_policer_action,
19673 (cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask,
19674 (cmdline_parse_inst_t *)&cmd_show_port_meter_stats,
19675 (cmdline_parse_inst_t *)&cmd_mcast_addr,
19676 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all,
19677 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific,
19678 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all,
19679 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific,
19680 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_en,
19681 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_dis,
19682 (cmdline_parse_inst_t *)&cmd_config_e_tag_stripping_en_dis,
19683 (cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis,
19684 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_add,
19685 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_del,
19686 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
19687 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
19688 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
19689 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
19690 (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
19691 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
19692 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
19693 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
19694 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
19695 (cmdline_parse_inst_t *)&cmd_set_macsec_sc,
19696 (cmdline_parse_inst_t *)&cmd_set_macsec_sa,
19697 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
19698 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
19699 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
19700 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
19701 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
19702 (cmdline_parse_inst_t *)&cmd_set_vf_promisc,
19703 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
19704 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
19705 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
19706 (cmdline_parse_inst_t *)&cmd_vf_max_bw,
19707 (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
19708 (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
19709 (cmdline_parse_inst_t *)&cmd_strict_link_prio,
19710 (cmdline_parse_inst_t *)&cmd_tc_min_bw,
19711 (cmdline_parse_inst_t *)&cmd_set_vxlan,
19712 (cmdline_parse_inst_t *)&cmd_set_vxlan_tos_ttl,
19713 (cmdline_parse_inst_t *)&cmd_set_vxlan_with_vlan,
19714 (cmdline_parse_inst_t *)&cmd_set_nvgre,
19715 (cmdline_parse_inst_t *)&cmd_set_nvgre_with_vlan,
19716 (cmdline_parse_inst_t *)&cmd_set_l2_encap,
19717 (cmdline_parse_inst_t *)&cmd_set_l2_encap_with_vlan,
19718 (cmdline_parse_inst_t *)&cmd_set_l2_decap,
19719 (cmdline_parse_inst_t *)&cmd_set_l2_decap_with_vlan,
19720 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap,
19721 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap_with_vlan,
19722 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap,
19723 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap_with_vlan,
19724 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap,
19725 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap_with_vlan,
19726 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap,
19727 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap_with_vlan,
19728 (cmdline_parse_inst_t *)&cmd_ddp_add,
19729 (cmdline_parse_inst_t *)&cmd_ddp_del,
19730 (cmdline_parse_inst_t *)&cmd_ddp_get_list,
19731 (cmdline_parse_inst_t *)&cmd_ddp_get_info,
19732 (cmdline_parse_inst_t *)&cmd_cfg_input_set,
19733 (cmdline_parse_inst_t *)&cmd_clear_input_set,
19734 (cmdline_parse_inst_t *)&cmd_show_vf_stats,
19735 (cmdline_parse_inst_t *)&cmd_clear_vf_stats,
19736 (cmdline_parse_inst_t *)&cmd_show_port_supported_ptypes,
19737 (cmdline_parse_inst_t *)&cmd_set_port_ptypes,
19738 (cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
19739 (cmdline_parse_inst_t *)&cmd_ptype_mapping_replace,
19740 (cmdline_parse_inst_t *)&cmd_ptype_mapping_reset,
19741 (cmdline_parse_inst_t *)&cmd_ptype_mapping_update,
19743 (cmdline_parse_inst_t *)&cmd_pctype_mapping_get,
19744 (cmdline_parse_inst_t *)&cmd_pctype_mapping_reset,
19745 (cmdline_parse_inst_t *)&cmd_pctype_mapping_update,
19746 (cmdline_parse_inst_t *)&cmd_queue_region,
19747 (cmdline_parse_inst_t *)&cmd_region_flowtype,
19748 (cmdline_parse_inst_t *)&cmd_user_priority_region,
19749 (cmdline_parse_inst_t *)&cmd_flush_queue_region,
19750 (cmdline_parse_inst_t *)&cmd_show_queue_region_info_all,
19751 (cmdline_parse_inst_t *)&cmd_show_port_tm_cap,
19752 (cmdline_parse_inst_t *)&cmd_show_port_tm_level_cap,
19753 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_cap,
19754 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_type,
19755 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_stats,
19756 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shaper_profile,
19757 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shaper_profile,
19758 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shared_shaper,
19759 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shared_shaper,
19760 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_wred_profile,
19761 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_wred_profile,
19762 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_shaper_profile,
19763 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node,
19764 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node_pmode,
19765 (cmdline_parse_inst_t *)&cmd_add_port_tm_leaf_node,
19766 (cmdline_parse_inst_t *)&cmd_del_port_tm_node,
19767 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_parent,
19768 (cmdline_parse_inst_t *)&cmd_suspend_port_tm_node,
19769 (cmdline_parse_inst_t *)&cmd_resume_port_tm_node,
19770 (cmdline_parse_inst_t *)&cmd_port_tm_hierarchy_commit,
19771 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_ecn,
19772 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_dscp,
19773 (cmdline_parse_inst_t *)&cmd_port_tm_mark_vlan_dei,
19774 (cmdline_parse_inst_t *)&cmd_cfg_tunnel_udp_port,
19775 (cmdline_parse_inst_t *)&cmd_rx_offload_get_capa,
19776 (cmdline_parse_inst_t *)&cmd_rx_offload_get_configuration,
19777 (cmdline_parse_inst_t *)&cmd_config_per_port_rx_offload,
19778 (cmdline_parse_inst_t *)&cmd_config_per_queue_rx_offload,
19779 (cmdline_parse_inst_t *)&cmd_tx_offload_get_capa,
19780 (cmdline_parse_inst_t *)&cmd_tx_offload_get_configuration,
19781 (cmdline_parse_inst_t *)&cmd_config_per_port_tx_offload,
19782 (cmdline_parse_inst_t *)&cmd_config_per_queue_tx_offload,
19784 (cmdline_parse_inst_t *)&cmd_operate_bpf_ld_parse,
19785 (cmdline_parse_inst_t *)&cmd_operate_bpf_unld_parse,
19787 (cmdline_parse_inst_t *)&cmd_config_tx_metadata_specific,
19788 (cmdline_parse_inst_t *)&cmd_show_tx_metadata,
19789 (cmdline_parse_inst_t *)&cmd_show_rx_tx_desc_status,
19790 (cmdline_parse_inst_t *)&cmd_set_raw,
19791 (cmdline_parse_inst_t *)&cmd_show_set_raw,
19792 (cmdline_parse_inst_t *)&cmd_show_set_raw_all,
19793 (cmdline_parse_inst_t *)&cmd_config_tx_dynf_specific,
19794 (cmdline_parse_inst_t *)&cmd_show_fec_mode,
19795 (cmdline_parse_inst_t *)&cmd_set_fec_mode,
19796 (cmdline_parse_inst_t *)&cmd_show_capability,
19800 /* read cmdline commands from file */
19802 cmdline_read_from_file(const char *filename)
19804 struct cmdline *cl;
19806 cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
19808 printf("Failed to create file based cmdline context: %s\n",
19813 cmdline_interact(cl);
19818 printf("Read CLI commands from %s\n", filename);
19821 /* prompt function, called from main on MAIN lcore */
19825 /* initialize non-constant commands */
19826 cmd_set_fwd_mode_init();
19827 cmd_set_fwd_retry_mode_init();
19829 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
19830 if (testpmd_cl == NULL)
19832 cmdline_interact(testpmd_cl);
19833 cmdline_stdin_exit(testpmd_cl);
19839 if (testpmd_cl != NULL)
19840 cmdline_quit(testpmd_cl);
19844 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
19846 if (id == (portid_t)RTE_PORT_ALL) {
19849 RTE_ETH_FOREACH_DEV(pid) {
19850 /* check if need_reconfig has been set to 1 */
19851 if (ports[pid].need_reconfig == 0)
19852 ports[pid].need_reconfig = dev;
19853 /* check if need_reconfig_queues has been set to 1 */
19854 if (ports[pid].need_reconfig_queues == 0)
19855 ports[pid].need_reconfig_queues = queue;
19857 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
19858 /* check if need_reconfig has been set to 1 */
19859 if (ports[id].need_reconfig == 0)
19860 ports[id].need_reconfig = dev;
19861 /* check if need_reconfig_queues has been set to 1 */
19862 if (ports[id].need_reconfig_queues == 0)
19863 ports[id].need_reconfig_queues = queue;