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 "flex_filter (port_id) (add|del) len (len_value)"
997 " bytes (bytes_value) mask (mask_value)"
998 " priority (prio_value) queue (queue_id)\n"
999 " Add/Del a flex filter.\n\n"
1001 "flow_director_filter (port_id) mode IP (add|del|update)"
1002 " flow (ipv4-other|ipv4-frag|ipv6-other|ipv6-frag)"
1003 " src (src_ip_address) dst (dst_ip_address)"
1004 " tos (tos_value) proto (proto_value) ttl (ttl_value)"
1005 " vlan (vlan_value) flexbytes (flexbytes_value)"
1006 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
1007 " fd_id (fd_id_value)\n"
1008 " Add/Del an IP type flow director filter.\n\n"
1010 "flow_director_filter (port_id) mode IP (add|del|update)"
1011 " flow (ipv4-tcp|ipv4-udp|ipv6-tcp|ipv6-udp)"
1012 " src (src_ip_address) (src_port)"
1013 " dst (dst_ip_address) (dst_port)"
1014 " tos (tos_value) ttl (ttl_value)"
1015 " vlan (vlan_value) flexbytes (flexbytes_value)"
1016 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
1017 " fd_id (fd_id_value)\n"
1018 " Add/Del an UDP/TCP type flow director filter.\n\n"
1020 "flow_director_filter (port_id) mode IP (add|del|update)"
1021 " flow (ipv4-sctp|ipv6-sctp)"
1022 " src (src_ip_address) (src_port)"
1023 " dst (dst_ip_address) (dst_port)"
1024 " tag (verification_tag) "
1025 " tos (tos_value) ttl (ttl_value)"
1026 " vlan (vlan_value)"
1027 " flexbytes (flexbytes_value) (drop|fwd)"
1028 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
1029 " Add/Del a SCTP type flow director filter.\n\n"
1031 "flow_director_filter (port_id) mode IP (add|del|update)"
1032 " flow l2_payload ether (ethertype)"
1033 " flexbytes (flexbytes_value) (drop|fwd)"
1034 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
1035 " Add/Del a l2 payload type flow director filter.\n\n"
1037 "flow_director_filter (port_id) mode MAC-VLAN (add|del|update)"
1038 " mac (mac_address) vlan (vlan_value)"
1039 " flexbytes (flexbytes_value) (drop|fwd)"
1040 " queue (queue_id) fd_id (fd_id_value)\n"
1041 " Add/Del a MAC-VLAN flow director filter.\n\n"
1043 "flow_director_filter (port_id) mode Tunnel (add|del|update)"
1044 " mac (mac_address) vlan (vlan_value)"
1045 " tunnel (NVGRE|VxLAN) tunnel-id (tunnel_id_value)"
1046 " flexbytes (flexbytes_value) (drop|fwd)"
1047 " queue (queue_id) fd_id (fd_id_value)\n"
1048 " Add/Del a Tunnel flow director filter.\n\n"
1050 "flow_director_filter (port_id) mode raw (add|del|update)"
1051 " flow (flow_id) (drop|fwd) queue (queue_id)"
1052 " fd_id (fd_id_value) packet (packet file name)\n"
1053 " Add/Del a raw type flow director filter.\n\n"
1055 "flush_flow_director (port_id)\n"
1056 " Flush all flow director entries of a device.\n\n"
1058 "flow_director_mask (port_id) mode IP vlan (vlan_value)"
1059 " src_mask (ipv4_src) (ipv6_src) (src_port)"
1060 " dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n"
1061 " Set flow director IP mask.\n\n"
1063 "flow_director_mask (port_id) mode MAC-VLAN"
1064 " vlan (vlan_value)\n"
1065 " Set flow director MAC-VLAN mask.\n\n"
1067 "flow_director_mask (port_id) mode Tunnel"
1068 " vlan (vlan_value) mac (mac_value)"
1069 " tunnel-type (tunnel_type_value)"
1070 " tunnel-id (tunnel_id_value)\n"
1071 " Set flow director Tunnel mask.\n\n"
1073 "flow_director_flex_mask (port_id)"
1074 " flow (none|ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
1075 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|l2_payload|all)"
1077 " Configure mask of flex payload.\n\n"
1079 "flow_director_flex_payload (port_id)"
1080 " (raw|l2|l3|l4) (config)\n"
1081 " Configure flex payload selection.\n\n"
1083 "get_sym_hash_ena_per_port (port_id)\n"
1084 " get symmetric hash enable configuration per port.\n\n"
1086 "set_sym_hash_ena_per_port (port_id) (enable|disable)\n"
1087 " set symmetric hash enable configuration per port"
1088 " to enable or disable.\n\n"
1090 "get_hash_global_config (port_id)\n"
1091 " Get the global configurations of hash filters.\n\n"
1093 "set_hash_global_config (port_id) (toeplitz|simple_xor|symmetric_toeplitz|default)"
1094 " (ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
1095 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload)"
1096 " (enable|disable)\n"
1097 " Set the global configurations of hash filters.\n\n"
1099 "set_hash_input_set (port_id) (ipv4|ipv4-frag|"
1100 "ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
1101 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1102 "l2_payload|<flowtype_id>) (ovlan|ivlan|src-ipv4|dst-ipv4|"
1103 "src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|ipv6-tc|"
1104 "ipv6-next-header|udp-src-port|udp-dst-port|"
1105 "tcp-src-port|tcp-dst-port|sctp-src-port|"
1106 "sctp-dst-port|sctp-veri-tag|udp-key|gre-key|fld-1st|"
1107 "fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|fld-7th|"
1108 "fld-8th|none) (select|add)\n"
1109 " Set the input set for hash.\n\n"
1111 "set_fdir_input_set (port_id) "
1112 "(ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
1113 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1114 "l2_payload) (ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|"
1115 "dst-ipv6|ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|"
1116 "ipv6-next-header|ipv6-hop-limits|udp-src-port|"
1117 "udp-dst-port|tcp-src-port|tcp-dst-port|"
1118 "sctp-src-port|sctp-dst-port|sctp-veri-tag|none)"
1120 " Set the input set for FDir.\n\n"
1122 "flow validate {port_id}"
1123 " [group {group_id}] [priority {level}]"
1124 " [ingress] [egress]"
1125 " pattern {item} [/ {item} [...]] / end"
1126 " actions {action} [/ {action} [...]] / end\n"
1127 " Check whether a flow rule can be created.\n\n"
1129 "flow create {port_id}"
1130 " [group {group_id}] [priority {level}]"
1131 " [ingress] [egress]"
1132 " pattern {item} [/ {item} [...]] / end"
1133 " actions {action} [/ {action} [...]] / end\n"
1134 " Create a flow rule.\n\n"
1136 "flow destroy {port_id} rule {rule_id} [...]\n"
1137 " Destroy specific flow rules.\n\n"
1139 "flow flush {port_id}\n"
1140 " Destroy all flow rules.\n\n"
1142 "flow query {port_id} {rule_id} {action}\n"
1143 " Query an existing flow rule.\n\n"
1145 "flow list {port_id} [group {group_id}] [...]\n"
1146 " List existing flow rules sorted by priority,"
1147 " filtered by group identifiers.\n\n"
1149 "flow isolate {port_id} {boolean}\n"
1150 " Restrict ingress traffic to the defined"
1153 "flow aged {port_id} [destroy]\n"
1154 " List and destroy aged flows"
1157 "flow shared_action {port_id} create"
1158 " [action_id {shared_action_id}]"
1159 " [ingress] [egress]"
1160 " action {action} / end\n"
1161 " Create shared action.\n\n"
1163 "flow shared_action {port_id} update"
1164 " {shared_action_id} action {action} / end\n"
1165 " Update shared action.\n\n"
1167 "flow shared_action {port_id} destroy"
1168 " action_id {shared_action_id} [...]\n"
1169 " Destroy specific shared actions.\n\n"
1171 "flow shared_action {port_id} query"
1172 " {shared_action_id}\n"
1173 " Query an existing shared action.\n\n"
1175 "set vxlan ip-version (ipv4|ipv6) vni (vni) udp-src"
1176 " (udp-src) udp-dst (udp-dst) ip-src (ip-src) ip-dst"
1177 " (ip-dst) eth-src (eth-src) eth-dst (eth-dst)\n"
1178 " Configure the VXLAN encapsulation for flows.\n\n"
1180 "set vxlan-with-vlan ip-version (ipv4|ipv6) vni (vni)"
1181 " udp-src (udp-src) udp-dst (udp-dst) ip-src (ip-src)"
1182 " ip-dst (ip-dst) vlan-tci (vlan-tci) eth-src (eth-src)"
1183 " eth-dst (eth-dst)\n"
1184 " Configure the VXLAN encapsulation for flows.\n\n"
1186 "set vxlan-tos-ttl ip-version (ipv4|ipv6) vni (vni) udp-src"
1187 " (udp-src) udp-dst (udp-dst) ip-tos (ip-tos) ip-ttl (ip-ttl)"
1188 " ip-src (ip-src) ip-dst (ip-dst) eth-src (eth-src)"
1189 " eth-dst (eth-dst)\n"
1190 " Configure the VXLAN encapsulation for flows.\n\n"
1192 "set nvgre ip-version (ipv4|ipv6) tni (tni) ip-src"
1193 " (ip-src) ip-dst (ip-dst) eth-src (eth-src) eth-dst"
1195 " Configure the NVGRE encapsulation for flows.\n\n"
1197 "set nvgre-with-vlan ip-version (ipv4|ipv6) tni (tni)"
1198 " ip-src (ip-src) ip-dst (ip-dst) vlan-tci (vlan-tci)"
1199 " eth-src (eth-src) eth-dst (eth-dst)\n"
1200 " Configure the NVGRE encapsulation for flows.\n\n"
1202 "set raw_encap {flow items}\n"
1203 " Configure the encapsulation with raw data.\n\n"
1205 "set raw_decap {flow items}\n"
1206 " Configure the decapsulation with raw data.\n\n"
1211 if (show_all || !strcmp(res->section, "traffic_management")) {
1215 "Traffic Management:\n"
1217 "show port tm cap (port_id)\n"
1218 " Display the port TM capability.\n\n"
1220 "show port tm level cap (port_id) (level_id)\n"
1221 " Display the port TM hierarchical level capability.\n\n"
1223 "show port tm node cap (port_id) (node_id)\n"
1224 " Display the port TM node capability.\n\n"
1226 "show port tm node type (port_id) (node_id)\n"
1227 " Display the port TM node type.\n\n"
1229 "show port tm node stats (port_id) (node_id) (clear)\n"
1230 " Display the port TM node stats.\n\n"
1232 "add port tm node shaper profile (port_id) (shaper_profile_id)"
1233 " (cmit_tb_rate) (cmit_tb_size) (peak_tb_rate) (peak_tb_size)"
1234 " (packet_length_adjust) (packet_mode)\n"
1235 " Add port tm node private shaper profile.\n\n"
1237 "del port tm node shaper profile (port_id) (shaper_profile_id)\n"
1238 " Delete port tm node private shaper profile.\n\n"
1240 "add port tm node shared shaper (port_id) (shared_shaper_id)"
1241 " (shaper_profile_id)\n"
1242 " Add/update port tm node shared shaper.\n\n"
1244 "del port tm node shared shaper (port_id) (shared_shaper_id)\n"
1245 " Delete port tm node shared shaper.\n\n"
1247 "set port tm node shaper profile (port_id) (node_id)"
1248 " (shaper_profile_id)\n"
1249 " Set port tm node shaper profile.\n\n"
1251 "add port tm node wred profile (port_id) (wred_profile_id)"
1252 " (color_g) (min_th_g) (max_th_g) (maxp_inv_g) (wq_log2_g)"
1253 " (color_y) (min_th_y) (max_th_y) (maxp_inv_y) (wq_log2_y)"
1254 " (color_r) (min_th_r) (max_th_r) (maxp_inv_r) (wq_log2_r)\n"
1255 " Add port tm node wred profile.\n\n"
1257 "del port tm node wred profile (port_id) (wred_profile_id)\n"
1258 " Delete port tm node wred profile.\n\n"
1260 "add port tm nonleaf node (port_id) (node_id) (parent_node_id)"
1261 " (priority) (weight) (level_id) (shaper_profile_id)"
1262 " (n_sp_priorities) (stats_mask) (n_shared_shapers)"
1263 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1264 " Add port tm nonleaf node.\n\n"
1266 "add port tm nonleaf node pktmode (port_id) (node_id) (parent_node_id)"
1267 " (priority) (weight) (level_id) (shaper_profile_id)"
1268 " (n_sp_priorities) (stats_mask) (n_shared_shapers)"
1269 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1270 " Add port tm nonleaf node with pkt mode enabled.\n\n"
1272 "add port tm leaf node (port_id) (node_id) (parent_node_id)"
1273 " (priority) (weight) (level_id) (shaper_profile_id)"
1274 " (cman_mode) (wred_profile_id) (stats_mask) (n_shared_shapers)"
1275 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1276 " Add port tm leaf node.\n\n"
1278 "del port tm node (port_id) (node_id)\n"
1279 " Delete port tm node.\n\n"
1281 "set port tm node parent (port_id) (node_id) (parent_node_id)"
1282 " (priority) (weight)\n"
1283 " Set port tm node parent.\n\n"
1285 "suspend port tm node (port_id) (node_id)"
1286 " Suspend tm node.\n\n"
1288 "resume port tm node (port_id) (node_id)"
1289 " Resume tm node.\n\n"
1291 "port tm hierarchy commit (port_id) (clean_on_fail)\n"
1292 " Commit tm hierarchy.\n\n"
1294 "set port tm mark ip_ecn (port) (green) (yellow)"
1296 " Enables/Disables the traffic management marking"
1297 " for IP ECN (Explicit Congestion Notification)"
1298 " packets on a given port\n\n"
1300 "set port tm mark ip_dscp (port) (green) (yellow)"
1302 " Enables/Disables the traffic management marking"
1303 " on the port for IP dscp packets\n\n"
1305 "set port tm mark vlan_dei (port) (green) (yellow)"
1307 " Enables/Disables the traffic management marking"
1308 " on the port for VLAN packets with DEI enabled\n\n"
1312 if (show_all || !strcmp(res->section, "devices")) {
1316 "Device Operations:\n"
1318 "device detach (identifier)\n"
1319 " Detach device by identifier.\n\n"
1325 cmdline_parse_token_string_t cmd_help_long_help =
1326 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
1328 cmdline_parse_token_string_t cmd_help_long_section =
1329 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
1330 "all#control#display#config#"
1331 "ports#registers#filters#traffic_management#devices");
1333 cmdline_parse_inst_t cmd_help_long = {
1334 .f = cmd_help_long_parsed,
1336 .help_str = "help all|control|display|config|ports|register|"
1337 "filters|traffic_management|devices: "
1340 (void *)&cmd_help_long_help,
1341 (void *)&cmd_help_long_section,
1347 /* *** start/stop/close all ports *** */
1348 struct cmd_operate_port_result {
1349 cmdline_fixed_string_t keyword;
1350 cmdline_fixed_string_t name;
1351 cmdline_fixed_string_t value;
1354 static void cmd_operate_port_parsed(void *parsed_result,
1355 __rte_unused struct cmdline *cl,
1356 __rte_unused void *data)
1358 struct cmd_operate_port_result *res = parsed_result;
1360 if (!strcmp(res->name, "start"))
1361 start_port(RTE_PORT_ALL);
1362 else if (!strcmp(res->name, "stop"))
1363 stop_port(RTE_PORT_ALL);
1364 else if (!strcmp(res->name, "close"))
1365 close_port(RTE_PORT_ALL);
1366 else if (!strcmp(res->name, "reset"))
1367 reset_port(RTE_PORT_ALL);
1369 printf("Unknown parameter\n");
1372 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
1373 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
1375 cmdline_parse_token_string_t cmd_operate_port_all_port =
1376 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
1377 "start#stop#close#reset");
1378 cmdline_parse_token_string_t cmd_operate_port_all_all =
1379 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
1381 cmdline_parse_inst_t cmd_operate_port = {
1382 .f = cmd_operate_port_parsed,
1384 .help_str = "port start|stop|close all: Start/Stop/Close/Reset all ports",
1386 (void *)&cmd_operate_port_all_cmd,
1387 (void *)&cmd_operate_port_all_port,
1388 (void *)&cmd_operate_port_all_all,
1393 /* *** start/stop/close specific port *** */
1394 struct cmd_operate_specific_port_result {
1395 cmdline_fixed_string_t keyword;
1396 cmdline_fixed_string_t name;
1400 static void cmd_operate_specific_port_parsed(void *parsed_result,
1401 __rte_unused struct cmdline *cl,
1402 __rte_unused void *data)
1404 struct cmd_operate_specific_port_result *res = parsed_result;
1406 if (!strcmp(res->name, "start"))
1407 start_port(res->value);
1408 else if (!strcmp(res->name, "stop"))
1409 stop_port(res->value);
1410 else if (!strcmp(res->name, "close"))
1411 close_port(res->value);
1412 else if (!strcmp(res->name, "reset"))
1413 reset_port(res->value);
1415 printf("Unknown parameter\n");
1418 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
1419 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1421 cmdline_parse_token_string_t cmd_operate_specific_port_port =
1422 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1423 name, "start#stop#close#reset");
1424 cmdline_parse_token_num_t cmd_operate_specific_port_id =
1425 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
1428 cmdline_parse_inst_t cmd_operate_specific_port = {
1429 .f = cmd_operate_specific_port_parsed,
1431 .help_str = "port start|stop|close <port_id>: Start/Stop/Close/Reset port_id",
1433 (void *)&cmd_operate_specific_port_cmd,
1434 (void *)&cmd_operate_specific_port_port,
1435 (void *)&cmd_operate_specific_port_id,
1440 /* *** enable port setup (after attach) via iterator or event *** */
1441 struct cmd_set_port_setup_on_result {
1442 cmdline_fixed_string_t set;
1443 cmdline_fixed_string_t port;
1444 cmdline_fixed_string_t setup;
1445 cmdline_fixed_string_t on;
1446 cmdline_fixed_string_t mode;
1449 static void cmd_set_port_setup_on_parsed(void *parsed_result,
1450 __rte_unused struct cmdline *cl,
1451 __rte_unused void *data)
1453 struct cmd_set_port_setup_on_result *res = parsed_result;
1455 if (strcmp(res->mode, "event") == 0)
1456 setup_on_probe_event = true;
1457 else if (strcmp(res->mode, "iterator") == 0)
1458 setup_on_probe_event = false;
1460 printf("Unknown mode\n");
1463 cmdline_parse_token_string_t cmd_set_port_setup_on_set =
1464 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1466 cmdline_parse_token_string_t cmd_set_port_setup_on_port =
1467 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1469 cmdline_parse_token_string_t cmd_set_port_setup_on_setup =
1470 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1472 cmdline_parse_token_string_t cmd_set_port_setup_on_on =
1473 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1475 cmdline_parse_token_string_t cmd_set_port_setup_on_mode =
1476 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1477 mode, "iterator#event");
1479 cmdline_parse_inst_t cmd_set_port_setup_on = {
1480 .f = cmd_set_port_setup_on_parsed,
1482 .help_str = "set port setup on iterator|event",
1484 (void *)&cmd_set_port_setup_on_set,
1485 (void *)&cmd_set_port_setup_on_port,
1486 (void *)&cmd_set_port_setup_on_setup,
1487 (void *)&cmd_set_port_setup_on_on,
1488 (void *)&cmd_set_port_setup_on_mode,
1493 /* *** attach a specified port *** */
1494 struct cmd_operate_attach_port_result {
1495 cmdline_fixed_string_t port;
1496 cmdline_fixed_string_t keyword;
1497 cmdline_multi_string_t identifier;
1500 static void cmd_operate_attach_port_parsed(void *parsed_result,
1501 __rte_unused struct cmdline *cl,
1502 __rte_unused void *data)
1504 struct cmd_operate_attach_port_result *res = parsed_result;
1506 if (!strcmp(res->keyword, "attach"))
1507 attach_port(res->identifier);
1509 printf("Unknown parameter\n");
1512 cmdline_parse_token_string_t cmd_operate_attach_port_port =
1513 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1515 cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
1516 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1518 cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
1519 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1520 identifier, TOKEN_STRING_MULTI);
1522 cmdline_parse_inst_t cmd_operate_attach_port = {
1523 .f = cmd_operate_attach_port_parsed,
1525 .help_str = "port attach <identifier>: "
1526 "(identifier: pci address or virtual dev name)",
1528 (void *)&cmd_operate_attach_port_port,
1529 (void *)&cmd_operate_attach_port_keyword,
1530 (void *)&cmd_operate_attach_port_identifier,
1535 /* *** detach a specified port *** */
1536 struct cmd_operate_detach_port_result {
1537 cmdline_fixed_string_t port;
1538 cmdline_fixed_string_t keyword;
1542 static void cmd_operate_detach_port_parsed(void *parsed_result,
1543 __rte_unused struct cmdline *cl,
1544 __rte_unused void *data)
1546 struct cmd_operate_detach_port_result *res = parsed_result;
1548 if (!strcmp(res->keyword, "detach")) {
1549 RTE_ETH_VALID_PORTID_OR_RET(res->port_id);
1550 detach_port_device(res->port_id);
1552 printf("Unknown parameter\n");
1556 cmdline_parse_token_string_t cmd_operate_detach_port_port =
1557 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1559 cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
1560 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1562 cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
1563 TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
1566 cmdline_parse_inst_t cmd_operate_detach_port = {
1567 .f = cmd_operate_detach_port_parsed,
1569 .help_str = "port detach <port_id>",
1571 (void *)&cmd_operate_detach_port_port,
1572 (void *)&cmd_operate_detach_port_keyword,
1573 (void *)&cmd_operate_detach_port_port_id,
1578 /* *** detach device by identifier *** */
1579 struct cmd_operate_detach_device_result {
1580 cmdline_fixed_string_t device;
1581 cmdline_fixed_string_t keyword;
1582 cmdline_fixed_string_t identifier;
1585 static void cmd_operate_detach_device_parsed(void *parsed_result,
1586 __rte_unused struct cmdline *cl,
1587 __rte_unused void *data)
1589 struct cmd_operate_detach_device_result *res = parsed_result;
1591 if (!strcmp(res->keyword, "detach"))
1592 detach_devargs(res->identifier);
1594 printf("Unknown parameter\n");
1597 cmdline_parse_token_string_t cmd_operate_detach_device_device =
1598 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1600 cmdline_parse_token_string_t cmd_operate_detach_device_keyword =
1601 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1603 cmdline_parse_token_string_t cmd_operate_detach_device_identifier =
1604 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1607 cmdline_parse_inst_t cmd_operate_detach_device = {
1608 .f = cmd_operate_detach_device_parsed,
1610 .help_str = "device detach <identifier>:"
1611 "(identifier: pci address or virtual dev name)",
1613 (void *)&cmd_operate_detach_device_device,
1614 (void *)&cmd_operate_detach_device_keyword,
1615 (void *)&cmd_operate_detach_device_identifier,
1619 /* *** configure speed for all ports *** */
1620 struct cmd_config_speed_all {
1621 cmdline_fixed_string_t port;
1622 cmdline_fixed_string_t keyword;
1623 cmdline_fixed_string_t all;
1624 cmdline_fixed_string_t item1;
1625 cmdline_fixed_string_t item2;
1626 cmdline_fixed_string_t value1;
1627 cmdline_fixed_string_t value2;
1631 parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed)
1636 if (!strcmp(duplexstr, "half")) {
1637 duplex = ETH_LINK_HALF_DUPLEX;
1638 } else if (!strcmp(duplexstr, "full")) {
1639 duplex = ETH_LINK_FULL_DUPLEX;
1640 } else if (!strcmp(duplexstr, "auto")) {
1641 duplex = ETH_LINK_FULL_DUPLEX;
1643 printf("Unknown duplex parameter\n");
1647 if (!strcmp(speedstr, "10")) {
1648 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1649 ETH_LINK_SPEED_10M_HD : ETH_LINK_SPEED_10M;
1650 } else if (!strcmp(speedstr, "100")) {
1651 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1652 ETH_LINK_SPEED_100M_HD : ETH_LINK_SPEED_100M;
1654 if (duplex != ETH_LINK_FULL_DUPLEX) {
1655 printf("Invalid speed/duplex parameters\n");
1658 if (!strcmp(speedstr, "1000")) {
1659 *speed = ETH_LINK_SPEED_1G;
1660 } else if (!strcmp(speedstr, "10000")) {
1661 *speed = ETH_LINK_SPEED_10G;
1662 } else if (!strcmp(speedstr, "25000")) {
1663 *speed = ETH_LINK_SPEED_25G;
1664 } else if (!strcmp(speedstr, "40000")) {
1665 *speed = ETH_LINK_SPEED_40G;
1666 } else if (!strcmp(speedstr, "50000")) {
1667 *speed = ETH_LINK_SPEED_50G;
1668 } else if (!strcmp(speedstr, "100000")) {
1669 *speed = ETH_LINK_SPEED_100G;
1670 } else if (!strcmp(speedstr, "200000")) {
1671 *speed = ETH_LINK_SPEED_200G;
1672 } else if (!strcmp(speedstr, "auto")) {
1673 *speed = ETH_LINK_SPEED_AUTONEG;
1675 printf("Unknown speed parameter\n");
1684 cmd_config_speed_all_parsed(void *parsed_result,
1685 __rte_unused struct cmdline *cl,
1686 __rte_unused void *data)
1688 struct cmd_config_speed_all *res = parsed_result;
1689 uint32_t link_speed;
1692 if (!all_ports_stopped()) {
1693 printf("Please stop all ports first\n");
1697 if (parse_and_check_speed_duplex(res->value1, res->value2,
1701 RTE_ETH_FOREACH_DEV(pid) {
1702 ports[pid].dev_conf.link_speeds = link_speed;
1705 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1708 cmdline_parse_token_string_t cmd_config_speed_all_port =
1709 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1710 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1711 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1713 cmdline_parse_token_string_t cmd_config_speed_all_all =
1714 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1715 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1716 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1717 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1718 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1719 "10#100#1000#10000#25000#40000#50000#100000#200000#auto");
1720 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1721 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1722 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1723 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1726 cmdline_parse_inst_t cmd_config_speed_all = {
1727 .f = cmd_config_speed_all_parsed,
1729 .help_str = "port config all speed "
1730 "10|100|1000|10000|25000|40000|50000|100000|200000|auto duplex "
1733 (void *)&cmd_config_speed_all_port,
1734 (void *)&cmd_config_speed_all_keyword,
1735 (void *)&cmd_config_speed_all_all,
1736 (void *)&cmd_config_speed_all_item1,
1737 (void *)&cmd_config_speed_all_value1,
1738 (void *)&cmd_config_speed_all_item2,
1739 (void *)&cmd_config_speed_all_value2,
1744 /* *** configure speed for specific port *** */
1745 struct cmd_config_speed_specific {
1746 cmdline_fixed_string_t port;
1747 cmdline_fixed_string_t keyword;
1749 cmdline_fixed_string_t item1;
1750 cmdline_fixed_string_t item2;
1751 cmdline_fixed_string_t value1;
1752 cmdline_fixed_string_t value2;
1756 cmd_config_speed_specific_parsed(void *parsed_result,
1757 __rte_unused struct cmdline *cl,
1758 __rte_unused void *data)
1760 struct cmd_config_speed_specific *res = parsed_result;
1761 uint32_t link_speed;
1763 if (!all_ports_stopped()) {
1764 printf("Please stop all ports first\n");
1768 if (port_id_is_invalid(res->id, ENABLED_WARN))
1771 if (parse_and_check_speed_duplex(res->value1, res->value2,
1775 ports[res->id].dev_conf.link_speeds = link_speed;
1777 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1781 cmdline_parse_token_string_t cmd_config_speed_specific_port =
1782 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1784 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1785 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1787 cmdline_parse_token_num_t cmd_config_speed_specific_id =
1788 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT16);
1789 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1790 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1792 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1793 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1794 "10#100#1000#10000#25000#40000#50000#100000#200000#auto");
1795 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1796 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1798 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1799 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1802 cmdline_parse_inst_t cmd_config_speed_specific = {
1803 .f = cmd_config_speed_specific_parsed,
1805 .help_str = "port config <port_id> speed "
1806 "10|100|1000|10000|25000|40000|50000|100000|200000|auto duplex "
1809 (void *)&cmd_config_speed_specific_port,
1810 (void *)&cmd_config_speed_specific_keyword,
1811 (void *)&cmd_config_speed_specific_id,
1812 (void *)&cmd_config_speed_specific_item1,
1813 (void *)&cmd_config_speed_specific_value1,
1814 (void *)&cmd_config_speed_specific_item2,
1815 (void *)&cmd_config_speed_specific_value2,
1820 /* *** configure loopback for all ports *** */
1821 struct cmd_config_loopback_all {
1822 cmdline_fixed_string_t port;
1823 cmdline_fixed_string_t keyword;
1824 cmdline_fixed_string_t all;
1825 cmdline_fixed_string_t item;
1830 cmd_config_loopback_all_parsed(void *parsed_result,
1831 __rte_unused struct cmdline *cl,
1832 __rte_unused void *data)
1834 struct cmd_config_loopback_all *res = parsed_result;
1837 if (!all_ports_stopped()) {
1838 printf("Please stop all ports first\n");
1842 RTE_ETH_FOREACH_DEV(pid) {
1843 ports[pid].dev_conf.lpbk_mode = res->mode;
1846 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1849 cmdline_parse_token_string_t cmd_config_loopback_all_port =
1850 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, port, "port");
1851 cmdline_parse_token_string_t cmd_config_loopback_all_keyword =
1852 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, keyword,
1854 cmdline_parse_token_string_t cmd_config_loopback_all_all =
1855 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, all, "all");
1856 cmdline_parse_token_string_t cmd_config_loopback_all_item =
1857 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, item,
1859 cmdline_parse_token_num_t cmd_config_loopback_all_mode =
1860 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_all, mode, UINT32);
1862 cmdline_parse_inst_t cmd_config_loopback_all = {
1863 .f = cmd_config_loopback_all_parsed,
1865 .help_str = "port config all loopback <mode>",
1867 (void *)&cmd_config_loopback_all_port,
1868 (void *)&cmd_config_loopback_all_keyword,
1869 (void *)&cmd_config_loopback_all_all,
1870 (void *)&cmd_config_loopback_all_item,
1871 (void *)&cmd_config_loopback_all_mode,
1876 /* *** configure loopback for specific port *** */
1877 struct cmd_config_loopback_specific {
1878 cmdline_fixed_string_t port;
1879 cmdline_fixed_string_t keyword;
1881 cmdline_fixed_string_t item;
1886 cmd_config_loopback_specific_parsed(void *parsed_result,
1887 __rte_unused struct cmdline *cl,
1888 __rte_unused void *data)
1890 struct cmd_config_loopback_specific *res = parsed_result;
1892 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
1895 if (!port_is_stopped(res->port_id)) {
1896 printf("Please stop port %u first\n", res->port_id);
1900 ports[res->port_id].dev_conf.lpbk_mode = res->mode;
1902 cmd_reconfig_device_queue(res->port_id, 1, 1);
1906 cmdline_parse_token_string_t cmd_config_loopback_specific_port =
1907 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, port,
1909 cmdline_parse_token_string_t cmd_config_loopback_specific_keyword =
1910 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, keyword,
1912 cmdline_parse_token_num_t cmd_config_loopback_specific_id =
1913 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, port_id,
1915 cmdline_parse_token_string_t cmd_config_loopback_specific_item =
1916 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, item,
1918 cmdline_parse_token_num_t cmd_config_loopback_specific_mode =
1919 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, mode,
1922 cmdline_parse_inst_t cmd_config_loopback_specific = {
1923 .f = cmd_config_loopback_specific_parsed,
1925 .help_str = "port config <port_id> loopback <mode>",
1927 (void *)&cmd_config_loopback_specific_port,
1928 (void *)&cmd_config_loopback_specific_keyword,
1929 (void *)&cmd_config_loopback_specific_id,
1930 (void *)&cmd_config_loopback_specific_item,
1931 (void *)&cmd_config_loopback_specific_mode,
1936 /* *** configure txq/rxq, txd/rxd *** */
1937 struct cmd_config_rx_tx {
1938 cmdline_fixed_string_t port;
1939 cmdline_fixed_string_t keyword;
1940 cmdline_fixed_string_t all;
1941 cmdline_fixed_string_t name;
1946 cmd_config_rx_tx_parsed(void *parsed_result,
1947 __rte_unused struct cmdline *cl,
1948 __rte_unused void *data)
1950 struct cmd_config_rx_tx *res = parsed_result;
1952 if (!all_ports_stopped()) {
1953 printf("Please stop all ports first\n");
1956 if (!strcmp(res->name, "rxq")) {
1957 if (!res->value && !nb_txq) {
1958 printf("Warning: Either rx or tx queues should be non zero\n");
1961 if (check_nb_rxq(res->value) != 0)
1963 nb_rxq = res->value;
1965 else if (!strcmp(res->name, "txq")) {
1966 if (!res->value && !nb_rxq) {
1967 printf("Warning: Either rx or tx queues should be non zero\n");
1970 if (check_nb_txq(res->value) != 0)
1972 nb_txq = res->value;
1974 else if (!strcmp(res->name, "rxd")) {
1975 if (check_nb_rxd(res->value) != 0)
1977 nb_rxd = res->value;
1978 } else if (!strcmp(res->name, "txd")) {
1979 if (check_nb_txd(res->value) != 0)
1982 nb_txd = res->value;
1984 printf("Unknown parameter\n");
1992 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1995 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1996 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1997 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1998 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1999 cmdline_parse_token_string_t cmd_config_rx_tx_all =
2000 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
2001 cmdline_parse_token_string_t cmd_config_rx_tx_name =
2002 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
2004 cmdline_parse_token_num_t cmd_config_rx_tx_value =
2005 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
2007 cmdline_parse_inst_t cmd_config_rx_tx = {
2008 .f = cmd_config_rx_tx_parsed,
2010 .help_str = "port config all rxq|txq|rxd|txd <value>",
2012 (void *)&cmd_config_rx_tx_port,
2013 (void *)&cmd_config_rx_tx_keyword,
2014 (void *)&cmd_config_rx_tx_all,
2015 (void *)&cmd_config_rx_tx_name,
2016 (void *)&cmd_config_rx_tx_value,
2021 /* *** config max packet length *** */
2022 struct cmd_config_max_pkt_len_result {
2023 cmdline_fixed_string_t port;
2024 cmdline_fixed_string_t keyword;
2025 cmdline_fixed_string_t all;
2026 cmdline_fixed_string_t name;
2031 cmd_config_max_pkt_len_parsed(void *parsed_result,
2032 __rte_unused struct cmdline *cl,
2033 __rte_unused void *data)
2035 struct cmd_config_max_pkt_len_result *res = parsed_result;
2038 if (!all_ports_stopped()) {
2039 printf("Please stop all ports first\n");
2043 RTE_ETH_FOREACH_DEV(pid) {
2044 struct rte_port *port = &ports[pid];
2045 uint64_t rx_offloads = port->dev_conf.rxmode.offloads;
2047 if (!strcmp(res->name, "max-pkt-len")) {
2048 if (res->value < RTE_ETHER_MIN_LEN) {
2049 printf("max-pkt-len can not be less than %d\n",
2053 if (res->value == port->dev_conf.rxmode.max_rx_pkt_len)
2056 port->dev_conf.rxmode.max_rx_pkt_len = res->value;
2057 if (res->value > RTE_ETHER_MAX_LEN)
2058 rx_offloads |= DEV_RX_OFFLOAD_JUMBO_FRAME;
2060 rx_offloads &= ~DEV_RX_OFFLOAD_JUMBO_FRAME;
2061 port->dev_conf.rxmode.offloads = rx_offloads;
2063 printf("Unknown parameter\n");
2070 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2073 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
2074 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
2076 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
2077 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
2079 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
2080 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
2082 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
2083 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
2085 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
2086 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
2089 cmdline_parse_inst_t cmd_config_max_pkt_len = {
2090 .f = cmd_config_max_pkt_len_parsed,
2092 .help_str = "port config all max-pkt-len <value>",
2094 (void *)&cmd_config_max_pkt_len_port,
2095 (void *)&cmd_config_max_pkt_len_keyword,
2096 (void *)&cmd_config_max_pkt_len_all,
2097 (void *)&cmd_config_max_pkt_len_name,
2098 (void *)&cmd_config_max_pkt_len_value,
2103 /* *** config max LRO aggregated packet size *** */
2104 struct cmd_config_max_lro_pkt_size_result {
2105 cmdline_fixed_string_t port;
2106 cmdline_fixed_string_t keyword;
2107 cmdline_fixed_string_t all;
2108 cmdline_fixed_string_t name;
2113 cmd_config_max_lro_pkt_size_parsed(void *parsed_result,
2114 __rte_unused struct cmdline *cl,
2115 __rte_unused void *data)
2117 struct cmd_config_max_lro_pkt_size_result *res = parsed_result;
2120 if (!all_ports_stopped()) {
2121 printf("Please stop all ports first\n");
2125 RTE_ETH_FOREACH_DEV(pid) {
2126 struct rte_port *port = &ports[pid];
2128 if (!strcmp(res->name, "max-lro-pkt-size")) {
2130 port->dev_conf.rxmode.max_lro_pkt_size)
2133 port->dev_conf.rxmode.max_lro_pkt_size = res->value;
2135 printf("Unknown parameter\n");
2142 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2145 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_port =
2146 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2148 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_keyword =
2149 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2151 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_all =
2152 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2154 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_name =
2155 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2156 name, "max-lro-pkt-size");
2157 cmdline_parse_token_num_t cmd_config_max_lro_pkt_size_value =
2158 TOKEN_NUM_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2161 cmdline_parse_inst_t cmd_config_max_lro_pkt_size = {
2162 .f = cmd_config_max_lro_pkt_size_parsed,
2164 .help_str = "port config all max-lro-pkt-size <value>",
2166 (void *)&cmd_config_max_lro_pkt_size_port,
2167 (void *)&cmd_config_max_lro_pkt_size_keyword,
2168 (void *)&cmd_config_max_lro_pkt_size_all,
2169 (void *)&cmd_config_max_lro_pkt_size_name,
2170 (void *)&cmd_config_max_lro_pkt_size_value,
2175 /* *** configure port MTU *** */
2176 struct cmd_config_mtu_result {
2177 cmdline_fixed_string_t port;
2178 cmdline_fixed_string_t keyword;
2179 cmdline_fixed_string_t mtu;
2185 cmd_config_mtu_parsed(void *parsed_result,
2186 __rte_unused struct cmdline *cl,
2187 __rte_unused void *data)
2189 struct cmd_config_mtu_result *res = parsed_result;
2191 if (res->value < RTE_ETHER_MIN_LEN) {
2192 printf("mtu cannot be less than %d\n", RTE_ETHER_MIN_LEN);
2195 port_mtu_set(res->port_id, res->value);
2198 cmdline_parse_token_string_t cmd_config_mtu_port =
2199 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
2201 cmdline_parse_token_string_t cmd_config_mtu_keyword =
2202 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2204 cmdline_parse_token_string_t cmd_config_mtu_mtu =
2205 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2207 cmdline_parse_token_num_t cmd_config_mtu_port_id =
2208 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT16);
2209 cmdline_parse_token_num_t cmd_config_mtu_value =
2210 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
2212 cmdline_parse_inst_t cmd_config_mtu = {
2213 .f = cmd_config_mtu_parsed,
2215 .help_str = "port config mtu <port_id> <value>",
2217 (void *)&cmd_config_mtu_port,
2218 (void *)&cmd_config_mtu_keyword,
2219 (void *)&cmd_config_mtu_mtu,
2220 (void *)&cmd_config_mtu_port_id,
2221 (void *)&cmd_config_mtu_value,
2226 /* *** configure rx mode *** */
2227 struct cmd_config_rx_mode_flag {
2228 cmdline_fixed_string_t port;
2229 cmdline_fixed_string_t keyword;
2230 cmdline_fixed_string_t all;
2231 cmdline_fixed_string_t name;
2232 cmdline_fixed_string_t value;
2236 cmd_config_rx_mode_flag_parsed(void *parsed_result,
2237 __rte_unused struct cmdline *cl,
2238 __rte_unused void *data)
2240 struct cmd_config_rx_mode_flag *res = parsed_result;
2242 if (!all_ports_stopped()) {
2243 printf("Please stop all ports first\n");
2247 if (!strcmp(res->name, "drop-en")) {
2248 if (!strcmp(res->value, "on"))
2250 else if (!strcmp(res->value, "off"))
2253 printf("Unknown parameter\n");
2257 printf("Unknown parameter\n");
2263 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2266 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
2267 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
2268 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
2269 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
2271 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
2272 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
2273 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
2274 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
2276 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
2277 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
2280 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
2281 .f = cmd_config_rx_mode_flag_parsed,
2283 .help_str = "port config all drop-en on|off",
2285 (void *)&cmd_config_rx_mode_flag_port,
2286 (void *)&cmd_config_rx_mode_flag_keyword,
2287 (void *)&cmd_config_rx_mode_flag_all,
2288 (void *)&cmd_config_rx_mode_flag_name,
2289 (void *)&cmd_config_rx_mode_flag_value,
2294 /* *** configure rss *** */
2295 struct cmd_config_rss {
2296 cmdline_fixed_string_t port;
2297 cmdline_fixed_string_t keyword;
2298 cmdline_fixed_string_t all;
2299 cmdline_fixed_string_t name;
2300 cmdline_fixed_string_t value;
2304 cmd_config_rss_parsed(void *parsed_result,
2305 __rte_unused struct cmdline *cl,
2306 __rte_unused void *data)
2308 struct cmd_config_rss *res = parsed_result;
2309 struct rte_eth_rss_conf rss_conf = { .rss_key_len = 0, };
2310 struct rte_eth_dev_info dev_info = { .flow_type_rss_offloads = 0, };
2311 int use_default = 0;
2312 int all_updated = 1;
2317 if (!strcmp(res->value, "all"))
2318 rss_conf.rss_hf = ETH_RSS_ETH | ETH_RSS_VLAN | ETH_RSS_IP |
2319 ETH_RSS_TCP | ETH_RSS_UDP | ETH_RSS_SCTP |
2320 ETH_RSS_L2_PAYLOAD | ETH_RSS_L2TPV3 | ETH_RSS_ESP |
2321 ETH_RSS_AH | ETH_RSS_PFCP | ETH_RSS_GTPU;
2322 else if (!strcmp(res->value, "eth"))
2323 rss_conf.rss_hf = ETH_RSS_ETH;
2324 else if (!strcmp(res->value, "vlan"))
2325 rss_conf.rss_hf = ETH_RSS_VLAN;
2326 else if (!strcmp(res->value, "ip"))
2327 rss_conf.rss_hf = ETH_RSS_IP;
2328 else if (!strcmp(res->value, "udp"))
2329 rss_conf.rss_hf = ETH_RSS_UDP;
2330 else if (!strcmp(res->value, "tcp"))
2331 rss_conf.rss_hf = ETH_RSS_TCP;
2332 else if (!strcmp(res->value, "sctp"))
2333 rss_conf.rss_hf = ETH_RSS_SCTP;
2334 else if (!strcmp(res->value, "ether"))
2335 rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD;
2336 else if (!strcmp(res->value, "port"))
2337 rss_conf.rss_hf = ETH_RSS_PORT;
2338 else if (!strcmp(res->value, "vxlan"))
2339 rss_conf.rss_hf = ETH_RSS_VXLAN;
2340 else if (!strcmp(res->value, "geneve"))
2341 rss_conf.rss_hf = ETH_RSS_GENEVE;
2342 else if (!strcmp(res->value, "nvgre"))
2343 rss_conf.rss_hf = ETH_RSS_NVGRE;
2344 else if (!strcmp(res->value, "l3-pre32"))
2345 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE32;
2346 else if (!strcmp(res->value, "l3-pre40"))
2347 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE40;
2348 else if (!strcmp(res->value, "l3-pre48"))
2349 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE48;
2350 else if (!strcmp(res->value, "l3-pre56"))
2351 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE56;
2352 else if (!strcmp(res->value, "l3-pre64"))
2353 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE64;
2354 else if (!strcmp(res->value, "l3-pre96"))
2355 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE96;
2356 else if (!strcmp(res->value, "l3-src-only"))
2357 rss_conf.rss_hf = ETH_RSS_L3_SRC_ONLY;
2358 else if (!strcmp(res->value, "l3-dst-only"))
2359 rss_conf.rss_hf = ETH_RSS_L3_DST_ONLY;
2360 else if (!strcmp(res->value, "l4-src-only"))
2361 rss_conf.rss_hf = ETH_RSS_L4_SRC_ONLY;
2362 else if (!strcmp(res->value, "l4-dst-only"))
2363 rss_conf.rss_hf = ETH_RSS_L4_DST_ONLY;
2364 else if (!strcmp(res->value, "l2-src-only"))
2365 rss_conf.rss_hf = ETH_RSS_L2_SRC_ONLY;
2366 else if (!strcmp(res->value, "l2-dst-only"))
2367 rss_conf.rss_hf = ETH_RSS_L2_DST_ONLY;
2368 else if (!strcmp(res->value, "l2tpv3"))
2369 rss_conf.rss_hf = ETH_RSS_L2TPV3;
2370 else if (!strcmp(res->value, "esp"))
2371 rss_conf.rss_hf = ETH_RSS_ESP;
2372 else if (!strcmp(res->value, "ah"))
2373 rss_conf.rss_hf = ETH_RSS_AH;
2374 else if (!strcmp(res->value, "pfcp"))
2375 rss_conf.rss_hf = ETH_RSS_PFCP;
2376 else if (!strcmp(res->value, "pppoe"))
2377 rss_conf.rss_hf = ETH_RSS_PPPOE;
2378 else if (!strcmp(res->value, "gtpu"))
2379 rss_conf.rss_hf = ETH_RSS_GTPU;
2380 else if (!strcmp(res->value, "none"))
2381 rss_conf.rss_hf = 0;
2382 else if (!strcmp(res->value, "level-default")) {
2383 rss_hf &= (~ETH_RSS_LEVEL_MASK);
2384 rss_conf.rss_hf = (rss_hf | ETH_RSS_LEVEL_PMD_DEFAULT);
2385 } else if (!strcmp(res->value, "level-outer")) {
2386 rss_hf &= (~ETH_RSS_LEVEL_MASK);
2387 rss_conf.rss_hf = (rss_hf | ETH_RSS_LEVEL_OUTERMOST);
2388 } else if (!strcmp(res->value, "level-inner")) {
2389 rss_hf &= (~ETH_RSS_LEVEL_MASK);
2390 rss_conf.rss_hf = (rss_hf | ETH_RSS_LEVEL_INNERMOST);
2391 } else if (!strcmp(res->value, "default"))
2393 else if (isdigit(res->value[0]) && atoi(res->value) > 0 &&
2394 atoi(res->value) < 64)
2395 rss_conf.rss_hf = 1ULL << atoi(res->value);
2397 printf("Unknown parameter\n");
2400 rss_conf.rss_key = NULL;
2401 /* Update global configuration for RSS types. */
2402 RTE_ETH_FOREACH_DEV(i) {
2403 struct rte_eth_rss_conf local_rss_conf;
2405 ret = eth_dev_info_get_print_err(i, &dev_info);
2410 rss_conf.rss_hf = dev_info.flow_type_rss_offloads;
2412 local_rss_conf = rss_conf;
2413 local_rss_conf.rss_hf = rss_conf.rss_hf &
2414 dev_info.flow_type_rss_offloads;
2415 if (local_rss_conf.rss_hf != rss_conf.rss_hf) {
2416 printf("Port %u modified RSS hash function based on hardware support,"
2417 "requested:%#"PRIx64" configured:%#"PRIx64"\n",
2418 i, rss_conf.rss_hf, local_rss_conf.rss_hf);
2420 diag = rte_eth_dev_rss_hash_update(i, &local_rss_conf);
2423 printf("Configuration of RSS hash at ethernet port %d "
2424 "failed with error (%d): %s.\n",
2425 i, -diag, strerror(-diag));
2428 if (all_updated && !use_default) {
2429 rss_hf = rss_conf.rss_hf;
2430 printf("rss_hf %#"PRIx64"\n", rss_hf);
2434 cmdline_parse_token_string_t cmd_config_rss_port =
2435 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
2436 cmdline_parse_token_string_t cmd_config_rss_keyword =
2437 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
2438 cmdline_parse_token_string_t cmd_config_rss_all =
2439 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
2440 cmdline_parse_token_string_t cmd_config_rss_name =
2441 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
2442 cmdline_parse_token_string_t cmd_config_rss_value =
2443 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, NULL);
2445 cmdline_parse_inst_t cmd_config_rss = {
2446 .f = cmd_config_rss_parsed,
2448 .help_str = "port config all rss "
2449 "all|default|eth|vlan|ip|tcp|udp|sctp|ether|port|vxlan|geneve|"
2450 "nvgre|vxlan-gpe|l2tpv3|esp|ah|pfcp|none|level-default|"
2451 "level-outer|level-inner|<flowtype_id>",
2453 (void *)&cmd_config_rss_port,
2454 (void *)&cmd_config_rss_keyword,
2455 (void *)&cmd_config_rss_all,
2456 (void *)&cmd_config_rss_name,
2457 (void *)&cmd_config_rss_value,
2462 /* *** configure rss hash key *** */
2463 struct cmd_config_rss_hash_key {
2464 cmdline_fixed_string_t port;
2465 cmdline_fixed_string_t config;
2467 cmdline_fixed_string_t rss_hash_key;
2468 cmdline_fixed_string_t rss_type;
2469 cmdline_fixed_string_t key;
2473 hexa_digit_to_value(char hexa_digit)
2475 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
2476 return (uint8_t) (hexa_digit - '0');
2477 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
2478 return (uint8_t) ((hexa_digit - 'a') + 10);
2479 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
2480 return (uint8_t) ((hexa_digit - 'A') + 10);
2481 /* Invalid hexa digit */
2486 parse_and_check_key_hexa_digit(char *key, int idx)
2490 hexa_v = hexa_digit_to_value(key[idx]);
2492 printf("invalid key: character %c at position %d is not a "
2493 "valid hexa digit\n", key[idx], idx);
2498 cmd_config_rss_hash_key_parsed(void *parsed_result,
2499 __rte_unused struct cmdline *cl,
2500 __rte_unused void *data)
2502 struct cmd_config_rss_hash_key *res = parsed_result;
2503 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
2507 struct rte_eth_dev_info dev_info;
2508 uint8_t hash_key_size;
2512 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
2516 if (dev_info.hash_key_size > 0 &&
2517 dev_info.hash_key_size <= sizeof(hash_key))
2518 hash_key_size = dev_info.hash_key_size;
2520 printf("dev_info did not provide a valid hash key size\n");
2523 /* Check the length of the RSS hash key */
2524 key_len = strlen(res->key);
2525 if (key_len != (hash_key_size * 2)) {
2526 printf("key length: %d invalid - key must be a string of %d"
2527 " hexa-decimal numbers\n",
2528 (int) key_len, hash_key_size * 2);
2531 /* Translate RSS hash key into binary representation */
2532 for (i = 0; i < hash_key_size; i++) {
2533 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
2536 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
2539 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
2541 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
2545 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
2546 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
2547 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
2548 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
2550 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
2551 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT16);
2552 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
2553 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
2554 rss_hash_key, "rss-hash-key");
2555 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
2556 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
2557 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2558 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2559 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2560 "ipv6-tcp-ex#ipv6-udp-ex#"
2561 "l3-src-only#l3-dst-only#l4-src-only#l4-dst-only#"
2562 "l2-src-only#l2-dst-only#s-vlan#c-vlan#"
2563 "l2tpv3#esp#ah#pfcp#pppoe#gtpu");
2564 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
2565 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
2567 cmdline_parse_inst_t cmd_config_rss_hash_key = {
2568 .f = cmd_config_rss_hash_key_parsed,
2570 .help_str = "port config <port_id> rss-hash-key "
2571 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2572 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2573 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex|"
2574 "l3-src-only|l3-dst-only|l4-src-only|l4-dst-only|"
2575 "l2-src-only|l2-dst-only|s-vlan|c-vlan|"
2576 "l2tpv3|esp|ah|pfcp|pppoe|gtpu "
2577 "<string of hex digits (variable length, NIC dependent)>",
2579 (void *)&cmd_config_rss_hash_key_port,
2580 (void *)&cmd_config_rss_hash_key_config,
2581 (void *)&cmd_config_rss_hash_key_port_id,
2582 (void *)&cmd_config_rss_hash_key_rss_hash_key,
2583 (void *)&cmd_config_rss_hash_key_rss_type,
2584 (void *)&cmd_config_rss_hash_key_value,
2589 /* *** configure port rxq/txq ring size *** */
2590 struct cmd_config_rxtx_ring_size {
2591 cmdline_fixed_string_t port;
2592 cmdline_fixed_string_t config;
2594 cmdline_fixed_string_t rxtxq;
2596 cmdline_fixed_string_t rsize;
2601 cmd_config_rxtx_ring_size_parsed(void *parsed_result,
2602 __rte_unused struct cmdline *cl,
2603 __rte_unused void *data)
2605 struct cmd_config_rxtx_ring_size *res = parsed_result;
2606 struct rte_port *port;
2609 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2612 if (res->portid == (portid_t)RTE_PORT_ALL) {
2613 printf("Invalid port id\n");
2617 port = &ports[res->portid];
2619 if (!strcmp(res->rxtxq, "rxq"))
2621 else if (!strcmp(res->rxtxq, "txq"))
2624 printf("Unknown parameter\n");
2628 if (isrx && rx_queue_id_is_invalid(res->qid))
2630 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2633 if (isrx && res->size != 0 && res->size <= rx_free_thresh) {
2634 printf("Invalid rx ring_size, must > rx_free_thresh: %d\n",
2640 port->nb_rx_desc[res->qid] = res->size;
2642 port->nb_tx_desc[res->qid] = res->size;
2644 cmd_reconfig_device_queue(res->portid, 0, 1);
2647 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_port =
2648 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2650 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_config =
2651 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2653 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_portid =
2654 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2656 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rxtxq =
2657 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2659 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_qid =
2660 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2662 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rsize =
2663 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2664 rsize, "ring_size");
2665 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_size =
2666 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2669 cmdline_parse_inst_t cmd_config_rxtx_ring_size = {
2670 .f = cmd_config_rxtx_ring_size_parsed,
2672 .help_str = "port config <port_id> rxq|txq <queue_id> ring_size <value>",
2674 (void *)&cmd_config_rxtx_ring_size_port,
2675 (void *)&cmd_config_rxtx_ring_size_config,
2676 (void *)&cmd_config_rxtx_ring_size_portid,
2677 (void *)&cmd_config_rxtx_ring_size_rxtxq,
2678 (void *)&cmd_config_rxtx_ring_size_qid,
2679 (void *)&cmd_config_rxtx_ring_size_rsize,
2680 (void *)&cmd_config_rxtx_ring_size_size,
2685 /* *** configure port rxq/txq start/stop *** */
2686 struct cmd_config_rxtx_queue {
2687 cmdline_fixed_string_t port;
2689 cmdline_fixed_string_t rxtxq;
2691 cmdline_fixed_string_t opname;
2695 cmd_config_rxtx_queue_parsed(void *parsed_result,
2696 __rte_unused struct cmdline *cl,
2697 __rte_unused void *data)
2699 struct cmd_config_rxtx_queue *res = parsed_result;
2704 if (test_done == 0) {
2705 printf("Please stop forwarding first\n");
2709 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2712 if (port_is_started(res->portid) != 1) {
2713 printf("Please start port %u first\n", res->portid);
2717 if (!strcmp(res->rxtxq, "rxq"))
2719 else if (!strcmp(res->rxtxq, "txq"))
2722 printf("Unknown parameter\n");
2726 if (isrx && rx_queue_id_is_invalid(res->qid))
2728 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2731 if (!strcmp(res->opname, "start"))
2733 else if (!strcmp(res->opname, "stop"))
2736 printf("Unknown parameter\n");
2740 if (isstart && isrx)
2741 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
2742 else if (!isstart && isrx)
2743 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
2744 else if (isstart && !isrx)
2745 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
2747 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
2749 if (ret == -ENOTSUP)
2750 printf("Function not supported in PMD driver\n");
2753 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
2754 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
2755 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
2756 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT16);
2757 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
2758 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
2759 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
2760 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
2761 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
2762 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
2765 cmdline_parse_inst_t cmd_config_rxtx_queue = {
2766 .f = cmd_config_rxtx_queue_parsed,
2768 .help_str = "port <port_id> rxq|txq <queue_id> start|stop",
2770 (void *)&cmd_config_rxtx_queue_port,
2771 (void *)&cmd_config_rxtx_queue_portid,
2772 (void *)&cmd_config_rxtx_queue_rxtxq,
2773 (void *)&cmd_config_rxtx_queue_qid,
2774 (void *)&cmd_config_rxtx_queue_opname,
2779 /* *** configure port rxq/txq deferred start on/off *** */
2780 struct cmd_config_deferred_start_rxtx_queue {
2781 cmdline_fixed_string_t port;
2783 cmdline_fixed_string_t rxtxq;
2785 cmdline_fixed_string_t opname;
2786 cmdline_fixed_string_t state;
2790 cmd_config_deferred_start_rxtx_queue_parsed(void *parsed_result,
2791 __rte_unused struct cmdline *cl,
2792 __rte_unused void *data)
2794 struct cmd_config_deferred_start_rxtx_queue *res = parsed_result;
2795 struct rte_port *port;
2798 uint8_t needreconfig = 0;
2800 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
2803 if (port_is_started(res->port_id) != 0) {
2804 printf("Please stop port %u first\n", res->port_id);
2808 port = &ports[res->port_id];
2810 isrx = !strcmp(res->rxtxq, "rxq");
2812 if (isrx && rx_queue_id_is_invalid(res->qid))
2814 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2817 ison = !strcmp(res->state, "on");
2819 if (isrx && port->rx_conf[res->qid].rx_deferred_start != ison) {
2820 port->rx_conf[res->qid].rx_deferred_start = ison;
2822 } else if (!isrx && port->tx_conf[res->qid].tx_deferred_start != ison) {
2823 port->tx_conf[res->qid].tx_deferred_start = ison;
2828 cmd_reconfig_device_queue(res->port_id, 0, 1);
2831 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_port =
2832 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2834 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_port_id =
2835 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2837 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_rxtxq =
2838 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2840 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_qid =
2841 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2843 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_opname =
2844 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2845 opname, "deferred_start");
2846 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_state =
2847 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2850 cmdline_parse_inst_t cmd_config_deferred_start_rxtx_queue = {
2851 .f = cmd_config_deferred_start_rxtx_queue_parsed,
2853 .help_str = "port <port_id> rxq|txq <queue_id> deferred_start on|off",
2855 (void *)&cmd_config_deferred_start_rxtx_queue_port,
2856 (void *)&cmd_config_deferred_start_rxtx_queue_port_id,
2857 (void *)&cmd_config_deferred_start_rxtx_queue_rxtxq,
2858 (void *)&cmd_config_deferred_start_rxtx_queue_qid,
2859 (void *)&cmd_config_deferred_start_rxtx_queue_opname,
2860 (void *)&cmd_config_deferred_start_rxtx_queue_state,
2865 /* *** configure port rxq/txq setup *** */
2866 struct cmd_setup_rxtx_queue {
2867 cmdline_fixed_string_t port;
2869 cmdline_fixed_string_t rxtxq;
2871 cmdline_fixed_string_t setup;
2874 /* Common CLI fields for queue setup */
2875 cmdline_parse_token_string_t cmd_setup_rxtx_queue_port =
2876 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, port, "port");
2877 cmdline_parse_token_num_t cmd_setup_rxtx_queue_portid =
2878 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, portid, UINT16);
2879 cmdline_parse_token_string_t cmd_setup_rxtx_queue_rxtxq =
2880 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, rxtxq, "rxq#txq");
2881 cmdline_parse_token_num_t cmd_setup_rxtx_queue_qid =
2882 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, qid, UINT16);
2883 cmdline_parse_token_string_t cmd_setup_rxtx_queue_setup =
2884 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, setup, "setup");
2887 cmd_setup_rxtx_queue_parsed(
2888 void *parsed_result,
2889 __rte_unused struct cmdline *cl,
2890 __rte_unused void *data)
2892 struct cmd_setup_rxtx_queue *res = parsed_result;
2893 struct rte_port *port;
2894 struct rte_mempool *mp;
2895 unsigned int socket_id;
2899 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2902 if (res->portid == (portid_t)RTE_PORT_ALL) {
2903 printf("Invalid port id\n");
2907 if (!strcmp(res->rxtxq, "rxq"))
2909 else if (!strcmp(res->rxtxq, "txq"))
2912 printf("Unknown parameter\n");
2916 if (isrx && rx_queue_id_is_invalid(res->qid)) {
2917 printf("Invalid rx queue\n");
2919 } else if (!isrx && tx_queue_id_is_invalid(res->qid)) {
2920 printf("Invalid tx queue\n");
2924 port = &ports[res->portid];
2926 socket_id = rxring_numa[res->portid];
2927 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2928 socket_id = port->socket_id;
2930 mp = mbuf_pool_find(socket_id, 0);
2932 printf("Failed to setup RX queue: "
2933 "No mempool allocation"
2934 " on the socket %d\n",
2935 rxring_numa[res->portid]);
2938 ret = rx_queue_setup(res->portid,
2940 port->nb_rx_desc[res->qid],
2942 &port->rx_conf[res->qid],
2945 printf("Failed to setup RX queue\n");
2947 socket_id = txring_numa[res->portid];
2948 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2949 socket_id = port->socket_id;
2951 ret = rte_eth_tx_queue_setup(res->portid,
2953 port->nb_tx_desc[res->qid],
2955 &port->tx_conf[res->qid]);
2957 printf("Failed to setup TX queue\n");
2961 cmdline_parse_inst_t cmd_setup_rxtx_queue = {
2962 .f = cmd_setup_rxtx_queue_parsed,
2964 .help_str = "port <port_id> rxq|txq <queue_idx> setup",
2966 (void *)&cmd_setup_rxtx_queue_port,
2967 (void *)&cmd_setup_rxtx_queue_portid,
2968 (void *)&cmd_setup_rxtx_queue_rxtxq,
2969 (void *)&cmd_setup_rxtx_queue_qid,
2970 (void *)&cmd_setup_rxtx_queue_setup,
2976 /* *** Configure RSS RETA *** */
2977 struct cmd_config_rss_reta {
2978 cmdline_fixed_string_t port;
2979 cmdline_fixed_string_t keyword;
2981 cmdline_fixed_string_t name;
2982 cmdline_fixed_string_t list_name;
2983 cmdline_fixed_string_t list_of_items;
2987 parse_reta_config(const char *str,
2988 struct rte_eth_rss_reta_entry64 *reta_conf,
2989 uint16_t nb_entries)
2993 uint16_t hash_index, idx, shift;
2996 const char *p, *p0 = str;
3003 unsigned long int_fld[_NUM_FLD];
3004 char *str_fld[_NUM_FLD];
3006 while ((p = strchr(p0,'(')) != NULL) {
3008 if((p0 = strchr(p,')')) == NULL)
3012 if(size >= sizeof(s))
3015 snprintf(s, sizeof(s), "%.*s", size, p);
3016 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
3018 for (i = 0; i < _NUM_FLD; i++) {
3020 int_fld[i] = strtoul(str_fld[i], &end, 0);
3021 if (errno != 0 || end == str_fld[i] ||
3026 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
3027 nb_queue = (uint16_t)int_fld[FLD_QUEUE];
3029 if (hash_index >= nb_entries) {
3030 printf("Invalid RETA hash index=%d\n", hash_index);
3034 idx = hash_index / RTE_RETA_GROUP_SIZE;
3035 shift = hash_index % RTE_RETA_GROUP_SIZE;
3036 reta_conf[idx].mask |= (1ULL << shift);
3037 reta_conf[idx].reta[shift] = nb_queue;
3044 cmd_set_rss_reta_parsed(void *parsed_result,
3045 __rte_unused struct cmdline *cl,
3046 __rte_unused void *data)
3049 struct rte_eth_dev_info dev_info;
3050 struct rte_eth_rss_reta_entry64 reta_conf[8];
3051 struct cmd_config_rss_reta *res = parsed_result;
3053 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
3057 if (dev_info.reta_size == 0) {
3058 printf("Redirection table size is 0 which is "
3059 "invalid for RSS\n");
3062 printf("The reta size of port %d is %u\n",
3063 res->port_id, dev_info.reta_size);
3064 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
3065 printf("Currently do not support more than %u entries of "
3066 "redirection table\n", ETH_RSS_RETA_SIZE_512);
3070 memset(reta_conf, 0, sizeof(reta_conf));
3071 if (!strcmp(res->list_name, "reta")) {
3072 if (parse_reta_config(res->list_of_items, reta_conf,
3073 dev_info.reta_size)) {
3074 printf("Invalid RSS Redirection Table "
3075 "config entered\n");
3078 ret = rte_eth_dev_rss_reta_update(res->port_id,
3079 reta_conf, dev_info.reta_size);
3081 printf("Bad redirection table parameter, "
3082 "return code = %d \n", ret);
3086 cmdline_parse_token_string_t cmd_config_rss_reta_port =
3087 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
3088 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
3089 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
3090 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
3091 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT16);
3092 cmdline_parse_token_string_t cmd_config_rss_reta_name =
3093 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
3094 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
3095 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
3096 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
3097 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
3099 cmdline_parse_inst_t cmd_config_rss_reta = {
3100 .f = cmd_set_rss_reta_parsed,
3102 .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
3104 (void *)&cmd_config_rss_reta_port,
3105 (void *)&cmd_config_rss_reta_keyword,
3106 (void *)&cmd_config_rss_reta_port_id,
3107 (void *)&cmd_config_rss_reta_name,
3108 (void *)&cmd_config_rss_reta_list_name,
3109 (void *)&cmd_config_rss_reta_list_of_items,
3114 /* *** SHOW PORT RETA INFO *** */
3115 struct cmd_showport_reta {
3116 cmdline_fixed_string_t show;
3117 cmdline_fixed_string_t port;
3119 cmdline_fixed_string_t rss;
3120 cmdline_fixed_string_t reta;
3122 cmdline_fixed_string_t list_of_items;
3126 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
3127 uint16_t nb_entries,
3131 const char *p, *p0 = str;
3136 uint16_t num = (nb_entries + RTE_RETA_GROUP_SIZE - 1) /
3137 RTE_RETA_GROUP_SIZE;
3140 p = strchr(p0, '(');
3144 p0 = strchr(p, ')');
3148 if (size >= sizeof(s)) {
3149 printf("The string size exceeds the internal buffer size\n");
3152 snprintf(s, sizeof(s), "%.*s", size, p);
3153 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
3154 if (ret <= 0 || ret != num) {
3155 printf("The bits of masks do not match the number of "
3156 "reta entries: %u\n", num);
3159 for (i = 0; i < ret; i++)
3160 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
3166 cmd_showport_reta_parsed(void *parsed_result,
3167 __rte_unused struct cmdline *cl,
3168 __rte_unused void *data)
3170 struct cmd_showport_reta *res = parsed_result;
3171 struct rte_eth_rss_reta_entry64 reta_conf[8];
3172 struct rte_eth_dev_info dev_info;
3173 uint16_t max_reta_size;
3176 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
3180 max_reta_size = RTE_MIN(dev_info.reta_size, ETH_RSS_RETA_SIZE_512);
3181 if (res->size == 0 || res->size > max_reta_size) {
3182 printf("Invalid redirection table size: %u (1-%u)\n",
3183 res->size, max_reta_size);
3187 memset(reta_conf, 0, sizeof(reta_conf));
3188 if (showport_parse_reta_config(reta_conf, res->size,
3189 res->list_of_items) < 0) {
3190 printf("Invalid string: %s for reta masks\n",
3191 res->list_of_items);
3194 port_rss_reta_info(res->port_id, reta_conf, res->size);
3197 cmdline_parse_token_string_t cmd_showport_reta_show =
3198 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
3199 cmdline_parse_token_string_t cmd_showport_reta_port =
3200 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
3201 cmdline_parse_token_num_t cmd_showport_reta_port_id =
3202 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT16);
3203 cmdline_parse_token_string_t cmd_showport_reta_rss =
3204 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
3205 cmdline_parse_token_string_t cmd_showport_reta_reta =
3206 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
3207 cmdline_parse_token_num_t cmd_showport_reta_size =
3208 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16);
3209 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
3210 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
3211 list_of_items, NULL);
3213 cmdline_parse_inst_t cmd_showport_reta = {
3214 .f = cmd_showport_reta_parsed,
3216 .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
3218 (void *)&cmd_showport_reta_show,
3219 (void *)&cmd_showport_reta_port,
3220 (void *)&cmd_showport_reta_port_id,
3221 (void *)&cmd_showport_reta_rss,
3222 (void *)&cmd_showport_reta_reta,
3223 (void *)&cmd_showport_reta_size,
3224 (void *)&cmd_showport_reta_list_of_items,
3229 /* *** Show RSS hash configuration *** */
3230 struct cmd_showport_rss_hash {
3231 cmdline_fixed_string_t show;
3232 cmdline_fixed_string_t port;
3234 cmdline_fixed_string_t rss_hash;
3235 cmdline_fixed_string_t rss_type;
3236 cmdline_fixed_string_t key; /* optional argument */
3239 static void cmd_showport_rss_hash_parsed(void *parsed_result,
3240 __rte_unused struct cmdline *cl,
3243 struct cmd_showport_rss_hash *res = parsed_result;
3245 port_rss_hash_conf_show(res->port_id, show_rss_key != NULL);
3248 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
3249 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
3250 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
3251 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
3252 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
3253 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT16);
3254 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
3255 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
3257 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
3258 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
3260 cmdline_parse_inst_t cmd_showport_rss_hash = {
3261 .f = cmd_showport_rss_hash_parsed,
3263 .help_str = "show port <port_id> rss-hash",
3265 (void *)&cmd_showport_rss_hash_show,
3266 (void *)&cmd_showport_rss_hash_port,
3267 (void *)&cmd_showport_rss_hash_port_id,
3268 (void *)&cmd_showport_rss_hash_rss_hash,
3273 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
3274 .f = cmd_showport_rss_hash_parsed,
3276 .help_str = "show port <port_id> rss-hash key",
3278 (void *)&cmd_showport_rss_hash_show,
3279 (void *)&cmd_showport_rss_hash_port,
3280 (void *)&cmd_showport_rss_hash_port_id,
3281 (void *)&cmd_showport_rss_hash_rss_hash,
3282 (void *)&cmd_showport_rss_hash_rss_key,
3287 /* *** Configure DCB *** */
3288 struct cmd_config_dcb {
3289 cmdline_fixed_string_t port;
3290 cmdline_fixed_string_t config;
3292 cmdline_fixed_string_t dcb;
3293 cmdline_fixed_string_t vt;
3294 cmdline_fixed_string_t vt_en;
3296 cmdline_fixed_string_t pfc;
3297 cmdline_fixed_string_t pfc_en;
3301 cmd_config_dcb_parsed(void *parsed_result,
3302 __rte_unused struct cmdline *cl,
3303 __rte_unused void *data)
3305 struct cmd_config_dcb *res = parsed_result;
3306 portid_t port_id = res->port_id;
3307 struct rte_port *port;
3311 port = &ports[port_id];
3312 /** Check if the port is not started **/
3313 if (port->port_status != RTE_PORT_STOPPED) {
3314 printf("Please stop port %d first\n", port_id);
3318 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
3319 printf("The invalid number of traffic class,"
3320 " only 4 or 8 allowed.\n");
3324 if (nb_fwd_lcores < res->num_tcs) {
3325 printf("nb_cores shouldn't be less than number of TCs.\n");
3328 if (!strncmp(res->pfc_en, "on", 2))
3333 /* DCB in VT mode */
3334 if (!strncmp(res->vt_en, "on", 2))
3335 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
3336 (enum rte_eth_nb_tcs)res->num_tcs,
3339 ret = init_port_dcb_config(port_id, DCB_ENABLED,
3340 (enum rte_eth_nb_tcs)res->num_tcs,
3345 printf("Cannot initialize network ports.\n");
3349 cmd_reconfig_device_queue(port_id, 1, 1);
3352 cmdline_parse_token_string_t cmd_config_dcb_port =
3353 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
3354 cmdline_parse_token_string_t cmd_config_dcb_config =
3355 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
3356 cmdline_parse_token_num_t cmd_config_dcb_port_id =
3357 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT16);
3358 cmdline_parse_token_string_t cmd_config_dcb_dcb =
3359 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
3360 cmdline_parse_token_string_t cmd_config_dcb_vt =
3361 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
3362 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
3363 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
3364 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
3365 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
3366 cmdline_parse_token_string_t cmd_config_dcb_pfc=
3367 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
3368 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
3369 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
3371 cmdline_parse_inst_t cmd_config_dcb = {
3372 .f = cmd_config_dcb_parsed,
3374 .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
3376 (void *)&cmd_config_dcb_port,
3377 (void *)&cmd_config_dcb_config,
3378 (void *)&cmd_config_dcb_port_id,
3379 (void *)&cmd_config_dcb_dcb,
3380 (void *)&cmd_config_dcb_vt,
3381 (void *)&cmd_config_dcb_vt_en,
3382 (void *)&cmd_config_dcb_num_tcs,
3383 (void *)&cmd_config_dcb_pfc,
3384 (void *)&cmd_config_dcb_pfc_en,
3389 /* *** configure number of packets per burst *** */
3390 struct cmd_config_burst {
3391 cmdline_fixed_string_t port;
3392 cmdline_fixed_string_t keyword;
3393 cmdline_fixed_string_t all;
3394 cmdline_fixed_string_t name;
3399 cmd_config_burst_parsed(void *parsed_result,
3400 __rte_unused struct cmdline *cl,
3401 __rte_unused void *data)
3403 struct cmd_config_burst *res = parsed_result;
3404 struct rte_eth_dev_info dev_info;
3405 uint16_t rec_nb_pkts;
3408 if (!all_ports_stopped()) {
3409 printf("Please stop all ports first\n");
3413 if (!strcmp(res->name, "burst")) {
3414 if (res->value == 0) {
3415 /* If user gives a value of zero, query the PMD for
3416 * its recommended Rx burst size. Testpmd uses a single
3417 * size for all ports, so assume all ports are the same
3418 * NIC model and use the values from Port 0.
3420 ret = eth_dev_info_get_print_err(0, &dev_info);
3424 rec_nb_pkts = dev_info.default_rxportconf.burst_size;
3426 if (rec_nb_pkts == 0) {
3427 printf("PMD does not recommend a burst size.\n"
3428 "User provided value must be between"
3429 " 1 and %d\n", MAX_PKT_BURST);
3431 } else if (rec_nb_pkts > MAX_PKT_BURST) {
3432 printf("PMD recommended burst size of %d"
3433 " exceeds maximum value of %d\n",
3434 rec_nb_pkts, MAX_PKT_BURST);
3437 printf("Using PMD-provided burst value of %d\n",
3439 nb_pkt_per_burst = rec_nb_pkts;
3440 } else if (res->value > MAX_PKT_BURST) {
3441 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
3444 nb_pkt_per_burst = res->value;
3446 printf("Unknown parameter\n");
3452 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3455 cmdline_parse_token_string_t cmd_config_burst_port =
3456 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
3457 cmdline_parse_token_string_t cmd_config_burst_keyword =
3458 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
3459 cmdline_parse_token_string_t cmd_config_burst_all =
3460 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
3461 cmdline_parse_token_string_t cmd_config_burst_name =
3462 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
3463 cmdline_parse_token_num_t cmd_config_burst_value =
3464 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
3466 cmdline_parse_inst_t cmd_config_burst = {
3467 .f = cmd_config_burst_parsed,
3469 .help_str = "port config all burst <value>",
3471 (void *)&cmd_config_burst_port,
3472 (void *)&cmd_config_burst_keyword,
3473 (void *)&cmd_config_burst_all,
3474 (void *)&cmd_config_burst_name,
3475 (void *)&cmd_config_burst_value,
3480 /* *** configure rx/tx queues *** */
3481 struct cmd_config_thresh {
3482 cmdline_fixed_string_t port;
3483 cmdline_fixed_string_t keyword;
3484 cmdline_fixed_string_t all;
3485 cmdline_fixed_string_t name;
3490 cmd_config_thresh_parsed(void *parsed_result,
3491 __rte_unused struct cmdline *cl,
3492 __rte_unused void *data)
3494 struct cmd_config_thresh *res = parsed_result;
3496 if (!all_ports_stopped()) {
3497 printf("Please stop all ports first\n");
3501 if (!strcmp(res->name, "txpt"))
3502 tx_pthresh = res->value;
3503 else if(!strcmp(res->name, "txht"))
3504 tx_hthresh = res->value;
3505 else if(!strcmp(res->name, "txwt"))
3506 tx_wthresh = res->value;
3507 else if(!strcmp(res->name, "rxpt"))
3508 rx_pthresh = res->value;
3509 else if(!strcmp(res->name, "rxht"))
3510 rx_hthresh = res->value;
3511 else if(!strcmp(res->name, "rxwt"))
3512 rx_wthresh = res->value;
3514 printf("Unknown parameter\n");
3520 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3523 cmdline_parse_token_string_t cmd_config_thresh_port =
3524 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
3525 cmdline_parse_token_string_t cmd_config_thresh_keyword =
3526 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
3527 cmdline_parse_token_string_t cmd_config_thresh_all =
3528 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
3529 cmdline_parse_token_string_t cmd_config_thresh_name =
3530 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
3531 "txpt#txht#txwt#rxpt#rxht#rxwt");
3532 cmdline_parse_token_num_t cmd_config_thresh_value =
3533 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
3535 cmdline_parse_inst_t cmd_config_thresh = {
3536 .f = cmd_config_thresh_parsed,
3538 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
3540 (void *)&cmd_config_thresh_port,
3541 (void *)&cmd_config_thresh_keyword,
3542 (void *)&cmd_config_thresh_all,
3543 (void *)&cmd_config_thresh_name,
3544 (void *)&cmd_config_thresh_value,
3549 /* *** configure free/rs threshold *** */
3550 struct cmd_config_threshold {
3551 cmdline_fixed_string_t port;
3552 cmdline_fixed_string_t keyword;
3553 cmdline_fixed_string_t all;
3554 cmdline_fixed_string_t name;
3559 cmd_config_threshold_parsed(void *parsed_result,
3560 __rte_unused struct cmdline *cl,
3561 __rte_unused void *data)
3563 struct cmd_config_threshold *res = parsed_result;
3565 if (!all_ports_stopped()) {
3566 printf("Please stop all ports first\n");
3570 if (!strcmp(res->name, "txfreet"))
3571 tx_free_thresh = res->value;
3572 else if (!strcmp(res->name, "txrst"))
3573 tx_rs_thresh = res->value;
3574 else if (!strcmp(res->name, "rxfreet"))
3575 rx_free_thresh = res->value;
3577 printf("Unknown parameter\n");
3583 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3586 cmdline_parse_token_string_t cmd_config_threshold_port =
3587 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
3588 cmdline_parse_token_string_t cmd_config_threshold_keyword =
3589 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
3591 cmdline_parse_token_string_t cmd_config_threshold_all =
3592 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
3593 cmdline_parse_token_string_t cmd_config_threshold_name =
3594 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
3595 "txfreet#txrst#rxfreet");
3596 cmdline_parse_token_num_t cmd_config_threshold_value =
3597 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
3599 cmdline_parse_inst_t cmd_config_threshold = {
3600 .f = cmd_config_threshold_parsed,
3602 .help_str = "port config all txfreet|txrst|rxfreet <value>",
3604 (void *)&cmd_config_threshold_port,
3605 (void *)&cmd_config_threshold_keyword,
3606 (void *)&cmd_config_threshold_all,
3607 (void *)&cmd_config_threshold_name,
3608 (void *)&cmd_config_threshold_value,
3614 struct cmd_stop_result {
3615 cmdline_fixed_string_t stop;
3618 static void cmd_stop_parsed(__rte_unused void *parsed_result,
3619 __rte_unused struct cmdline *cl,
3620 __rte_unused void *data)
3622 stop_packet_forwarding();
3625 cmdline_parse_token_string_t cmd_stop_stop =
3626 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
3628 cmdline_parse_inst_t cmd_stop = {
3629 .f = cmd_stop_parsed,
3631 .help_str = "stop: Stop packet forwarding",
3633 (void *)&cmd_stop_stop,
3638 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
3641 parse_item_list(char* str, const char* item_name, unsigned int max_items,
3642 unsigned int *parsed_items, int check_unique_values)
3644 unsigned int nb_item;
3652 * First parse all items in the list and store their value.
3657 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
3659 if ((c >= '0') && (c <= '9')) {
3660 value = (unsigned int) (value * 10 + (c - '0'));
3665 printf("character %c is not a decimal digit\n", c);
3669 printf("No valid value before comma\n");
3672 if (nb_item < max_items) {
3673 parsed_items[nb_item] = value;
3679 if (nb_item >= max_items) {
3680 printf("Number of %s = %u > %u (maximum items)\n",
3681 item_name, nb_item + 1, max_items);
3684 parsed_items[nb_item++] = value;
3685 if (! check_unique_values)
3689 * Then, check that all values in the list are differents.
3690 * No optimization here...
3692 for (i = 0; i < nb_item; i++) {
3693 for (j = i + 1; j < nb_item; j++) {
3694 if (parsed_items[j] == parsed_items[i]) {
3695 printf("duplicated %s %u at index %u and %u\n",
3696 item_name, parsed_items[i], i, j);
3704 struct cmd_set_list_result {
3705 cmdline_fixed_string_t cmd_keyword;
3706 cmdline_fixed_string_t list_name;
3707 cmdline_fixed_string_t list_of_items;
3710 static void cmd_set_list_parsed(void *parsed_result,
3711 __rte_unused struct cmdline *cl,
3712 __rte_unused void *data)
3714 struct cmd_set_list_result *res;
3716 unsigned int lcorelist[RTE_MAX_LCORE];
3717 unsigned int portlist[RTE_MAX_ETHPORTS];
3719 unsigned int nb_item;
3721 if (test_done == 0) {
3722 printf("Please stop forwarding first\n");
3726 res = parsed_result;
3727 if (!strcmp(res->list_name, "corelist")) {
3728 nb_item = parse_item_list(res->list_of_items, "core",
3730 parsed_items.lcorelist, 1);
3732 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
3737 if (!strcmp(res->list_name, "portlist")) {
3738 nb_item = parse_item_list(res->list_of_items, "port",
3740 parsed_items.portlist, 1);
3742 set_fwd_ports_list(parsed_items.portlist, nb_item);
3748 cmdline_parse_token_string_t cmd_set_list_keyword =
3749 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
3751 cmdline_parse_token_string_t cmd_set_list_name =
3752 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
3753 "corelist#portlist");
3754 cmdline_parse_token_string_t cmd_set_list_of_items =
3755 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
3758 cmdline_parse_inst_t cmd_set_fwd_list = {
3759 .f = cmd_set_list_parsed,
3761 .help_str = "set corelist|portlist <list0[,list1]*>",
3763 (void *)&cmd_set_list_keyword,
3764 (void *)&cmd_set_list_name,
3765 (void *)&cmd_set_list_of_items,
3770 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
3772 struct cmd_setmask_result {
3773 cmdline_fixed_string_t set;
3774 cmdline_fixed_string_t mask;
3778 static void cmd_set_mask_parsed(void *parsed_result,
3779 __rte_unused struct cmdline *cl,
3780 __rte_unused void *data)
3782 struct cmd_setmask_result *res = parsed_result;
3784 if (test_done == 0) {
3785 printf("Please stop forwarding first\n");
3788 if (!strcmp(res->mask, "coremask")) {
3789 set_fwd_lcores_mask(res->hexavalue);
3791 } else if (!strcmp(res->mask, "portmask")) {
3792 set_fwd_ports_mask(res->hexavalue);
3797 cmdline_parse_token_string_t cmd_setmask_set =
3798 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
3799 cmdline_parse_token_string_t cmd_setmask_mask =
3800 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
3801 "coremask#portmask");
3802 cmdline_parse_token_num_t cmd_setmask_value =
3803 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
3805 cmdline_parse_inst_t cmd_set_fwd_mask = {
3806 .f = cmd_set_mask_parsed,
3808 .help_str = "set coremask|portmask <hexadecimal value>",
3810 (void *)&cmd_setmask_set,
3811 (void *)&cmd_setmask_mask,
3812 (void *)&cmd_setmask_value,
3818 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
3820 struct cmd_set_result {
3821 cmdline_fixed_string_t set;
3822 cmdline_fixed_string_t what;
3826 static void cmd_set_parsed(void *parsed_result,
3827 __rte_unused struct cmdline *cl,
3828 __rte_unused void *data)
3830 struct cmd_set_result *res = parsed_result;
3831 if (!strcmp(res->what, "nbport")) {
3832 set_fwd_ports_number(res->value);
3834 } else if (!strcmp(res->what, "nbcore")) {
3835 set_fwd_lcores_number(res->value);
3837 } else if (!strcmp(res->what, "burst"))
3838 set_nb_pkt_per_burst(res->value);
3839 else if (!strcmp(res->what, "verbose"))
3840 set_verbose_level(res->value);
3843 cmdline_parse_token_string_t cmd_set_set =
3844 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
3845 cmdline_parse_token_string_t cmd_set_what =
3846 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
3847 "nbport#nbcore#burst#verbose");
3848 cmdline_parse_token_num_t cmd_set_value =
3849 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
3851 cmdline_parse_inst_t cmd_set_numbers = {
3852 .f = cmd_set_parsed,
3854 .help_str = "set nbport|nbcore|burst|verbose <value>",
3856 (void *)&cmd_set_set,
3857 (void *)&cmd_set_what,
3858 (void *)&cmd_set_value,
3863 /* *** SET LOG LEVEL CONFIGURATION *** */
3865 struct cmd_set_log_result {
3866 cmdline_fixed_string_t set;
3867 cmdline_fixed_string_t log;
3868 cmdline_fixed_string_t type;
3873 cmd_set_log_parsed(void *parsed_result,
3874 __rte_unused struct cmdline *cl,
3875 __rte_unused void *data)
3877 struct cmd_set_log_result *res;
3880 res = parsed_result;
3881 if (!strcmp(res->type, "global"))
3882 rte_log_set_global_level(res->level);
3884 ret = rte_log_set_level_regexp(res->type, res->level);
3886 printf("Unable to set log level\n");
3890 cmdline_parse_token_string_t cmd_set_log_set =
3891 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, set, "set");
3892 cmdline_parse_token_string_t cmd_set_log_log =
3893 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, log, "log");
3894 cmdline_parse_token_string_t cmd_set_log_type =
3895 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, type, NULL);
3896 cmdline_parse_token_num_t cmd_set_log_level =
3897 TOKEN_NUM_INITIALIZER(struct cmd_set_log_result, level, UINT32);
3899 cmdline_parse_inst_t cmd_set_log = {
3900 .f = cmd_set_log_parsed,
3902 .help_str = "set log global|<type> <level>",
3904 (void *)&cmd_set_log_set,
3905 (void *)&cmd_set_log_log,
3906 (void *)&cmd_set_log_type,
3907 (void *)&cmd_set_log_level,
3912 /* *** SET SEGMENT OFFSETS OF RX PACKETS SPLIT *** */
3914 struct cmd_set_rxoffs_result {
3915 cmdline_fixed_string_t cmd_keyword;
3916 cmdline_fixed_string_t rxoffs;
3917 cmdline_fixed_string_t seg_offsets;
3921 cmd_set_rxoffs_parsed(void *parsed_result,
3922 __rte_unused struct cmdline *cl,
3923 __rte_unused void *data)
3925 struct cmd_set_rxoffs_result *res;
3926 unsigned int seg_offsets[MAX_SEGS_BUFFER_SPLIT];
3927 unsigned int nb_segs;
3929 res = parsed_result;
3930 nb_segs = parse_item_list(res->seg_offsets, "segment offsets",
3931 MAX_SEGS_BUFFER_SPLIT, seg_offsets, 0);
3933 set_rx_pkt_offsets(seg_offsets, nb_segs);
3936 cmdline_parse_token_string_t cmd_set_rxoffs_keyword =
3937 TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
3938 cmd_keyword, "set");
3939 cmdline_parse_token_string_t cmd_set_rxoffs_name =
3940 TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
3942 cmdline_parse_token_string_t cmd_set_rxoffs_offsets =
3943 TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
3946 cmdline_parse_inst_t cmd_set_rxoffs = {
3947 .f = cmd_set_rxoffs_parsed,
3949 .help_str = "set rxoffs <len0[,len1]*>",
3951 (void *)&cmd_set_rxoffs_keyword,
3952 (void *)&cmd_set_rxoffs_name,
3953 (void *)&cmd_set_rxoffs_offsets,
3958 /* *** SET SEGMENT LENGTHS OF RX PACKETS SPLIT *** */
3960 struct cmd_set_rxpkts_result {
3961 cmdline_fixed_string_t cmd_keyword;
3962 cmdline_fixed_string_t rxpkts;
3963 cmdline_fixed_string_t seg_lengths;
3967 cmd_set_rxpkts_parsed(void *parsed_result,
3968 __rte_unused struct cmdline *cl,
3969 __rte_unused void *data)
3971 struct cmd_set_rxpkts_result *res;
3972 unsigned int seg_lengths[MAX_SEGS_BUFFER_SPLIT];
3973 unsigned int nb_segs;
3975 res = parsed_result;
3976 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
3977 MAX_SEGS_BUFFER_SPLIT, seg_lengths, 0);
3979 set_rx_pkt_segments(seg_lengths, nb_segs);
3982 cmdline_parse_token_string_t cmd_set_rxpkts_keyword =
3983 TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
3984 cmd_keyword, "set");
3985 cmdline_parse_token_string_t cmd_set_rxpkts_name =
3986 TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
3988 cmdline_parse_token_string_t cmd_set_rxpkts_lengths =
3989 TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
3992 cmdline_parse_inst_t cmd_set_rxpkts = {
3993 .f = cmd_set_rxpkts_parsed,
3995 .help_str = "set rxpkts <len0[,len1]*>",
3997 (void *)&cmd_set_rxpkts_keyword,
3998 (void *)&cmd_set_rxpkts_name,
3999 (void *)&cmd_set_rxpkts_lengths,
4004 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
4006 struct cmd_set_txpkts_result {
4007 cmdline_fixed_string_t cmd_keyword;
4008 cmdline_fixed_string_t txpkts;
4009 cmdline_fixed_string_t seg_lengths;
4013 cmd_set_txpkts_parsed(void *parsed_result,
4014 __rte_unused struct cmdline *cl,
4015 __rte_unused void *data)
4017 struct cmd_set_txpkts_result *res;
4018 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
4019 unsigned int nb_segs;
4021 res = parsed_result;
4022 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
4023 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
4025 set_tx_pkt_segments(seg_lengths, nb_segs);
4028 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
4029 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
4030 cmd_keyword, "set");
4031 cmdline_parse_token_string_t cmd_set_txpkts_name =
4032 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
4034 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
4035 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
4038 cmdline_parse_inst_t cmd_set_txpkts = {
4039 .f = cmd_set_txpkts_parsed,
4041 .help_str = "set txpkts <len0[,len1]*>",
4043 (void *)&cmd_set_txpkts_keyword,
4044 (void *)&cmd_set_txpkts_name,
4045 (void *)&cmd_set_txpkts_lengths,
4050 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
4052 struct cmd_set_txsplit_result {
4053 cmdline_fixed_string_t cmd_keyword;
4054 cmdline_fixed_string_t txsplit;
4055 cmdline_fixed_string_t mode;
4059 cmd_set_txsplit_parsed(void *parsed_result,
4060 __rte_unused struct cmdline *cl,
4061 __rte_unused void *data)
4063 struct cmd_set_txsplit_result *res;
4065 res = parsed_result;
4066 set_tx_pkt_split(res->mode);
4069 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
4070 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
4071 cmd_keyword, "set");
4072 cmdline_parse_token_string_t cmd_set_txsplit_name =
4073 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
4074 txsplit, "txsplit");
4075 cmdline_parse_token_string_t cmd_set_txsplit_mode =
4076 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
4079 cmdline_parse_inst_t cmd_set_txsplit = {
4080 .f = cmd_set_txsplit_parsed,
4082 .help_str = "set txsplit on|off|rand",
4084 (void *)&cmd_set_txsplit_keyword,
4085 (void *)&cmd_set_txsplit_name,
4086 (void *)&cmd_set_txsplit_mode,
4091 /* *** SET TIMES FOR TXONLY PACKETS SCHEDULING ON TIMESTAMPS *** */
4093 struct cmd_set_txtimes_result {
4094 cmdline_fixed_string_t cmd_keyword;
4095 cmdline_fixed_string_t txtimes;
4096 cmdline_fixed_string_t tx_times;
4100 cmd_set_txtimes_parsed(void *parsed_result,
4101 __rte_unused struct cmdline *cl,
4102 __rte_unused void *data)
4104 struct cmd_set_txtimes_result *res;
4105 unsigned int tx_times[2] = {0, 0};
4106 unsigned int n_times;
4108 res = parsed_result;
4109 n_times = parse_item_list(res->tx_times, "tx times",
4112 set_tx_pkt_times(tx_times);
4115 cmdline_parse_token_string_t cmd_set_txtimes_keyword =
4116 TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
4117 cmd_keyword, "set");
4118 cmdline_parse_token_string_t cmd_set_txtimes_name =
4119 TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
4120 txtimes, "txtimes");
4121 cmdline_parse_token_string_t cmd_set_txtimes_value =
4122 TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
4125 cmdline_parse_inst_t cmd_set_txtimes = {
4126 .f = cmd_set_txtimes_parsed,
4128 .help_str = "set txtimes <inter_burst>,<intra_burst>",
4130 (void *)&cmd_set_txtimes_keyword,
4131 (void *)&cmd_set_txtimes_name,
4132 (void *)&cmd_set_txtimes_value,
4137 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
4138 struct cmd_rx_vlan_filter_all_result {
4139 cmdline_fixed_string_t rx_vlan;
4140 cmdline_fixed_string_t what;
4141 cmdline_fixed_string_t all;
4146 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
4147 __rte_unused struct cmdline *cl,
4148 __rte_unused void *data)
4150 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
4152 if (!strcmp(res->what, "add"))
4153 rx_vlan_all_filter_set(res->port_id, 1);
4155 rx_vlan_all_filter_set(res->port_id, 0);
4158 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
4159 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4160 rx_vlan, "rx_vlan");
4161 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
4162 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4164 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
4165 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4167 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
4168 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4171 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
4172 .f = cmd_rx_vlan_filter_all_parsed,
4174 .help_str = "rx_vlan add|rm all <port_id>: "
4175 "Add/Remove all identifiers to/from the set of VLAN "
4176 "identifiers filtered by a port",
4178 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
4179 (void *)&cmd_rx_vlan_filter_all_what,
4180 (void *)&cmd_rx_vlan_filter_all_all,
4181 (void *)&cmd_rx_vlan_filter_all_portid,
4186 /* *** VLAN OFFLOAD SET ON A PORT *** */
4187 struct cmd_vlan_offload_result {
4188 cmdline_fixed_string_t vlan;
4189 cmdline_fixed_string_t set;
4190 cmdline_fixed_string_t vlan_type;
4191 cmdline_fixed_string_t what;
4192 cmdline_fixed_string_t on;
4193 cmdline_fixed_string_t port_id;
4197 cmd_vlan_offload_parsed(void *parsed_result,
4198 __rte_unused struct cmdline *cl,
4199 __rte_unused void *data)
4202 struct cmd_vlan_offload_result *res = parsed_result;
4205 portid_t port_id = 0;
4209 len = strnlen(str, STR_TOKEN_SIZE);
4211 /* Get port_id first */
4219 tmp = strtoul(str, NULL, 0);
4220 /* If port_id greater that what portid_t can represent, return */
4221 if(tmp >= RTE_MAX_ETHPORTS)
4223 port_id = (portid_t)tmp;
4225 if (!strcmp(res->on, "on"))
4230 if (!strcmp(res->what, "strip"))
4231 rx_vlan_strip_set(port_id, on);
4232 else if(!strcmp(res->what, "stripq")){
4233 uint16_t queue_id = 0;
4235 /* No queue_id, return */
4237 printf("must specify (port,queue_id)\n");
4240 tmp = strtoul(str + i + 1, NULL, 0);
4241 /* If queue_id greater that what 16-bits can represent, return */
4245 queue_id = (uint16_t)tmp;
4246 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
4248 else if (!strcmp(res->what, "filter"))
4249 rx_vlan_filter_set(port_id, on);
4250 else if (!strcmp(res->what, "qinq_strip"))
4251 rx_vlan_qinq_strip_set(port_id, on);
4253 vlan_extend_set(port_id, on);
4258 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
4259 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4261 cmdline_parse_token_string_t cmd_vlan_offload_set =
4262 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4264 cmdline_parse_token_string_t cmd_vlan_offload_what =
4265 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4266 what, "strip#filter#qinq_strip#extend#stripq");
4267 cmdline_parse_token_string_t cmd_vlan_offload_on =
4268 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4270 cmdline_parse_token_string_t cmd_vlan_offload_portid =
4271 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4274 cmdline_parse_inst_t cmd_vlan_offload = {
4275 .f = cmd_vlan_offload_parsed,
4277 .help_str = "vlan set strip|filter|qinq_strip|extend|stripq on|off "
4278 "<port_id[,queue_id]>: "
4279 "Strip/Filter/QinQ for rx side Extend for both rx/tx sides",
4281 (void *)&cmd_vlan_offload_vlan,
4282 (void *)&cmd_vlan_offload_set,
4283 (void *)&cmd_vlan_offload_what,
4284 (void *)&cmd_vlan_offload_on,
4285 (void *)&cmd_vlan_offload_portid,
4290 /* *** VLAN TPID SET ON A PORT *** */
4291 struct cmd_vlan_tpid_result {
4292 cmdline_fixed_string_t vlan;
4293 cmdline_fixed_string_t set;
4294 cmdline_fixed_string_t vlan_type;
4295 cmdline_fixed_string_t what;
4301 cmd_vlan_tpid_parsed(void *parsed_result,
4302 __rte_unused struct cmdline *cl,
4303 __rte_unused void *data)
4305 struct cmd_vlan_tpid_result *res = parsed_result;
4306 enum rte_vlan_type vlan_type;
4308 if (!strcmp(res->vlan_type, "inner"))
4309 vlan_type = ETH_VLAN_TYPE_INNER;
4310 else if (!strcmp(res->vlan_type, "outer"))
4311 vlan_type = ETH_VLAN_TYPE_OUTER;
4313 printf("Unknown vlan type\n");
4316 vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
4319 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
4320 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4322 cmdline_parse_token_string_t cmd_vlan_tpid_set =
4323 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4325 cmdline_parse_token_string_t cmd_vlan_type =
4326 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4327 vlan_type, "inner#outer");
4328 cmdline_parse_token_string_t cmd_vlan_tpid_what =
4329 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4331 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
4332 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4334 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
4335 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4338 cmdline_parse_inst_t cmd_vlan_tpid = {
4339 .f = cmd_vlan_tpid_parsed,
4341 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
4342 "Set the VLAN Ether type",
4344 (void *)&cmd_vlan_tpid_vlan,
4345 (void *)&cmd_vlan_tpid_set,
4346 (void *)&cmd_vlan_type,
4347 (void *)&cmd_vlan_tpid_what,
4348 (void *)&cmd_vlan_tpid_tpid,
4349 (void *)&cmd_vlan_tpid_portid,
4354 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
4355 struct cmd_rx_vlan_filter_result {
4356 cmdline_fixed_string_t rx_vlan;
4357 cmdline_fixed_string_t what;
4363 cmd_rx_vlan_filter_parsed(void *parsed_result,
4364 __rte_unused struct cmdline *cl,
4365 __rte_unused void *data)
4367 struct cmd_rx_vlan_filter_result *res = parsed_result;
4369 if (!strcmp(res->what, "add"))
4370 rx_vft_set(res->port_id, res->vlan_id, 1);
4372 rx_vft_set(res->port_id, res->vlan_id, 0);
4375 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
4376 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4377 rx_vlan, "rx_vlan");
4378 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
4379 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4381 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
4382 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4384 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
4385 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4388 cmdline_parse_inst_t cmd_rx_vlan_filter = {
4389 .f = cmd_rx_vlan_filter_parsed,
4391 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
4392 "Add/Remove a VLAN identifier to/from the set of VLAN "
4393 "identifiers filtered by a port",
4395 (void *)&cmd_rx_vlan_filter_rx_vlan,
4396 (void *)&cmd_rx_vlan_filter_what,
4397 (void *)&cmd_rx_vlan_filter_vlanid,
4398 (void *)&cmd_rx_vlan_filter_portid,
4403 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4404 struct cmd_tx_vlan_set_result {
4405 cmdline_fixed_string_t tx_vlan;
4406 cmdline_fixed_string_t set;
4412 cmd_tx_vlan_set_parsed(void *parsed_result,
4413 __rte_unused struct cmdline *cl,
4414 __rte_unused void *data)
4416 struct cmd_tx_vlan_set_result *res = parsed_result;
4418 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4421 if (!port_is_stopped(res->port_id)) {
4422 printf("Please stop port %d first\n", res->port_id);
4426 tx_vlan_set(res->port_id, res->vlan_id);
4428 cmd_reconfig_device_queue(res->port_id, 1, 1);
4431 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
4432 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4433 tx_vlan, "tx_vlan");
4434 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
4435 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4437 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
4438 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4440 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
4441 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4444 cmdline_parse_inst_t cmd_tx_vlan_set = {
4445 .f = cmd_tx_vlan_set_parsed,
4447 .help_str = "tx_vlan set <port_id> <vlan_id>: "
4448 "Enable hardware insertion of a single VLAN header "
4449 "with a given TAG Identifier in packets sent on a port",
4451 (void *)&cmd_tx_vlan_set_tx_vlan,
4452 (void *)&cmd_tx_vlan_set_set,
4453 (void *)&cmd_tx_vlan_set_portid,
4454 (void *)&cmd_tx_vlan_set_vlanid,
4459 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
4460 struct cmd_tx_vlan_set_qinq_result {
4461 cmdline_fixed_string_t tx_vlan;
4462 cmdline_fixed_string_t set;
4465 uint16_t vlan_id_outer;
4469 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
4470 __rte_unused struct cmdline *cl,
4471 __rte_unused void *data)
4473 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
4475 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4478 if (!port_is_stopped(res->port_id)) {
4479 printf("Please stop port %d first\n", res->port_id);
4483 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
4485 cmd_reconfig_device_queue(res->port_id, 1, 1);
4488 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
4489 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4490 tx_vlan, "tx_vlan");
4491 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
4492 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4494 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
4495 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4497 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
4498 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4500 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
4501 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4502 vlan_id_outer, UINT16);
4504 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
4505 .f = cmd_tx_vlan_set_qinq_parsed,
4507 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
4508 "Enable hardware insertion of double VLAN header "
4509 "with given TAG Identifiers in packets sent on a port",
4511 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
4512 (void *)&cmd_tx_vlan_set_qinq_set,
4513 (void *)&cmd_tx_vlan_set_qinq_portid,
4514 (void *)&cmd_tx_vlan_set_qinq_vlanid,
4515 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
4520 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
4521 struct cmd_tx_vlan_set_pvid_result {
4522 cmdline_fixed_string_t tx_vlan;
4523 cmdline_fixed_string_t set;
4524 cmdline_fixed_string_t pvid;
4527 cmdline_fixed_string_t mode;
4531 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
4532 __rte_unused struct cmdline *cl,
4533 __rte_unused void *data)
4535 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
4537 if (strcmp(res->mode, "on") == 0)
4538 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
4540 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
4543 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
4544 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4545 tx_vlan, "tx_vlan");
4546 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
4547 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4549 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
4550 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4552 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
4553 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4555 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
4556 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4558 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
4559 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4562 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
4563 .f = cmd_tx_vlan_set_pvid_parsed,
4565 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
4567 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
4568 (void *)&cmd_tx_vlan_set_pvid_set,
4569 (void *)&cmd_tx_vlan_set_pvid_pvid,
4570 (void *)&cmd_tx_vlan_set_pvid_port_id,
4571 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
4572 (void *)&cmd_tx_vlan_set_pvid_mode,
4577 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4578 struct cmd_tx_vlan_reset_result {
4579 cmdline_fixed_string_t tx_vlan;
4580 cmdline_fixed_string_t reset;
4585 cmd_tx_vlan_reset_parsed(void *parsed_result,
4586 __rte_unused struct cmdline *cl,
4587 __rte_unused void *data)
4589 struct cmd_tx_vlan_reset_result *res = parsed_result;
4591 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4594 if (!port_is_stopped(res->port_id)) {
4595 printf("Please stop port %d first\n", res->port_id);
4599 tx_vlan_reset(res->port_id);
4601 cmd_reconfig_device_queue(res->port_id, 1, 1);
4604 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
4605 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4606 tx_vlan, "tx_vlan");
4607 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
4608 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4610 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
4611 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
4614 cmdline_parse_inst_t cmd_tx_vlan_reset = {
4615 .f = cmd_tx_vlan_reset_parsed,
4617 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
4618 "VLAN header in packets sent on a port",
4620 (void *)&cmd_tx_vlan_reset_tx_vlan,
4621 (void *)&cmd_tx_vlan_reset_reset,
4622 (void *)&cmd_tx_vlan_reset_portid,
4628 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
4629 struct cmd_csum_result {
4630 cmdline_fixed_string_t csum;
4631 cmdline_fixed_string_t mode;
4632 cmdline_fixed_string_t proto;
4633 cmdline_fixed_string_t hwsw;
4638 csum_show(int port_id)
4640 struct rte_eth_dev_info dev_info;
4641 uint64_t tx_offloads;
4644 tx_offloads = ports[port_id].dev_conf.txmode.offloads;
4645 printf("Parse tunnel is %s\n",
4646 (ports[port_id].parse_tunnel) ? "on" : "off");
4647 printf("IP checksum offload is %s\n",
4648 (tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) ? "hw" : "sw");
4649 printf("UDP checksum offload is %s\n",
4650 (tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
4651 printf("TCP checksum offload is %s\n",
4652 (tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
4653 printf("SCTP checksum offload is %s\n",
4654 (tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
4655 printf("Outer-Ip checksum offload is %s\n",
4656 (tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) ? "hw" : "sw");
4657 printf("Outer-Udp checksum offload is %s\n",
4658 (tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) ? "hw" : "sw");
4660 /* display warnings if configuration is not supported by the NIC */
4661 ret = eth_dev_info_get_print_err(port_id, &dev_info);
4665 if ((tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) &&
4666 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
4667 printf("Warning: hardware IP checksum enabled but not "
4668 "supported by port %d\n", port_id);
4670 if ((tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) &&
4671 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
4672 printf("Warning: hardware UDP checksum enabled but not "
4673 "supported by port %d\n", port_id);
4675 if ((tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) &&
4676 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
4677 printf("Warning: hardware TCP checksum enabled but not "
4678 "supported by port %d\n", port_id);
4680 if ((tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) &&
4681 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
4682 printf("Warning: hardware SCTP checksum enabled but not "
4683 "supported by port %d\n", port_id);
4685 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) &&
4686 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
4687 printf("Warning: hardware outer IP checksum enabled but not "
4688 "supported by port %d\n", port_id);
4690 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) &&
4691 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)
4693 printf("Warning: hardware outer UDP checksum enabled but not "
4694 "supported by port %d\n", port_id);
4699 cmd_config_queue_tx_offloads(struct rte_port *port)
4703 /* Apply queue tx offloads configuration */
4704 for (k = 0; k < port->dev_info.max_rx_queues; k++)
4705 port->tx_conf[k].offloads =
4706 port->dev_conf.txmode.offloads;
4710 cmd_csum_parsed(void *parsed_result,
4711 __rte_unused struct cmdline *cl,
4712 __rte_unused void *data)
4714 struct cmd_csum_result *res = parsed_result;
4716 uint64_t csum_offloads = 0;
4717 struct rte_eth_dev_info dev_info;
4720 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
4721 printf("invalid port %d\n", res->port_id);
4724 if (!port_is_stopped(res->port_id)) {
4725 printf("Please stop port %d first\n", res->port_id);
4729 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4733 if (!strcmp(res->mode, "set")) {
4735 if (!strcmp(res->hwsw, "hw"))
4738 if (!strcmp(res->proto, "ip")) {
4739 if (hw == 0 || (dev_info.tx_offload_capa &
4740 DEV_TX_OFFLOAD_IPV4_CKSUM)) {
4741 csum_offloads |= DEV_TX_OFFLOAD_IPV4_CKSUM;
4743 printf("IP checksum offload is not supported "
4744 "by port %u\n", res->port_id);
4746 } else if (!strcmp(res->proto, "udp")) {
4747 if (hw == 0 || (dev_info.tx_offload_capa &
4748 DEV_TX_OFFLOAD_UDP_CKSUM)) {
4749 csum_offloads |= DEV_TX_OFFLOAD_UDP_CKSUM;
4751 printf("UDP checksum offload is not supported "
4752 "by port %u\n", res->port_id);
4754 } else if (!strcmp(res->proto, "tcp")) {
4755 if (hw == 0 || (dev_info.tx_offload_capa &
4756 DEV_TX_OFFLOAD_TCP_CKSUM)) {
4757 csum_offloads |= DEV_TX_OFFLOAD_TCP_CKSUM;
4759 printf("TCP checksum offload is not supported "
4760 "by port %u\n", res->port_id);
4762 } else if (!strcmp(res->proto, "sctp")) {
4763 if (hw == 0 || (dev_info.tx_offload_capa &
4764 DEV_TX_OFFLOAD_SCTP_CKSUM)) {
4765 csum_offloads |= DEV_TX_OFFLOAD_SCTP_CKSUM;
4767 printf("SCTP checksum offload is not supported "
4768 "by port %u\n", res->port_id);
4770 } else if (!strcmp(res->proto, "outer-ip")) {
4771 if (hw == 0 || (dev_info.tx_offload_capa &
4772 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM)) {
4774 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM;
4776 printf("Outer IP checksum offload is not "
4777 "supported by port %u\n", res->port_id);
4779 } else if (!strcmp(res->proto, "outer-udp")) {
4780 if (hw == 0 || (dev_info.tx_offload_capa &
4781 DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)) {
4783 DEV_TX_OFFLOAD_OUTER_UDP_CKSUM;
4785 printf("Outer UDP checksum offload is not "
4786 "supported by port %u\n", res->port_id);
4791 ports[res->port_id].dev_conf.txmode.offloads |=
4794 ports[res->port_id].dev_conf.txmode.offloads &=
4797 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4799 csum_show(res->port_id);
4801 cmd_reconfig_device_queue(res->port_id, 1, 1);
4804 cmdline_parse_token_string_t cmd_csum_csum =
4805 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4807 cmdline_parse_token_string_t cmd_csum_mode =
4808 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4810 cmdline_parse_token_string_t cmd_csum_proto =
4811 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4812 proto, "ip#tcp#udp#sctp#outer-ip#outer-udp");
4813 cmdline_parse_token_string_t cmd_csum_hwsw =
4814 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4816 cmdline_parse_token_num_t cmd_csum_portid =
4817 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
4820 cmdline_parse_inst_t cmd_csum_set = {
4821 .f = cmd_csum_parsed,
4823 .help_str = "csum set ip|tcp|udp|sctp|outer-ip|outer-udp hw|sw <port_id>: "
4824 "Enable/Disable hardware calculation of L3/L4 checksum when "
4825 "using csum forward engine",
4827 (void *)&cmd_csum_csum,
4828 (void *)&cmd_csum_mode,
4829 (void *)&cmd_csum_proto,
4830 (void *)&cmd_csum_hwsw,
4831 (void *)&cmd_csum_portid,
4836 cmdline_parse_token_string_t cmd_csum_mode_show =
4837 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4840 cmdline_parse_inst_t cmd_csum_show = {
4841 .f = cmd_csum_parsed,
4843 .help_str = "csum show <port_id>: Show checksum offload configuration",
4845 (void *)&cmd_csum_csum,
4846 (void *)&cmd_csum_mode_show,
4847 (void *)&cmd_csum_portid,
4852 /* Enable/disable tunnel parsing */
4853 struct cmd_csum_tunnel_result {
4854 cmdline_fixed_string_t csum;
4855 cmdline_fixed_string_t parse;
4856 cmdline_fixed_string_t onoff;
4861 cmd_csum_tunnel_parsed(void *parsed_result,
4862 __rte_unused struct cmdline *cl,
4863 __rte_unused void *data)
4865 struct cmd_csum_tunnel_result *res = parsed_result;
4867 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4870 if (!strcmp(res->onoff, "on"))
4871 ports[res->port_id].parse_tunnel = 1;
4873 ports[res->port_id].parse_tunnel = 0;
4875 csum_show(res->port_id);
4878 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
4879 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4881 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
4882 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4883 parse, "parse-tunnel");
4884 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
4885 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4887 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
4888 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
4891 cmdline_parse_inst_t cmd_csum_tunnel = {
4892 .f = cmd_csum_tunnel_parsed,
4894 .help_str = "csum parse-tunnel on|off <port_id>: "
4895 "Enable/Disable parsing of tunnels for csum engine",
4897 (void *)&cmd_csum_tunnel_csum,
4898 (void *)&cmd_csum_tunnel_parse,
4899 (void *)&cmd_csum_tunnel_onoff,
4900 (void *)&cmd_csum_tunnel_portid,
4905 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
4906 struct cmd_tso_set_result {
4907 cmdline_fixed_string_t tso;
4908 cmdline_fixed_string_t mode;
4914 cmd_tso_set_parsed(void *parsed_result,
4915 __rte_unused struct cmdline *cl,
4916 __rte_unused void *data)
4918 struct cmd_tso_set_result *res = parsed_result;
4919 struct rte_eth_dev_info dev_info;
4922 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4924 if (!port_is_stopped(res->port_id)) {
4925 printf("Please stop port %d first\n", res->port_id);
4929 if (!strcmp(res->mode, "set"))
4930 ports[res->port_id].tso_segsz = res->tso_segsz;
4932 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4936 if ((ports[res->port_id].tso_segsz != 0) &&
4937 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4938 printf("Error: TSO is not supported by port %d\n",
4943 if (ports[res->port_id].tso_segsz == 0) {
4944 ports[res->port_id].dev_conf.txmode.offloads &=
4945 ~DEV_TX_OFFLOAD_TCP_TSO;
4946 printf("TSO for non-tunneled packets is disabled\n");
4948 ports[res->port_id].dev_conf.txmode.offloads |=
4949 DEV_TX_OFFLOAD_TCP_TSO;
4950 printf("TSO segment size for non-tunneled packets is %d\n",
4951 ports[res->port_id].tso_segsz);
4953 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4955 /* display warnings if configuration is not supported by the NIC */
4956 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4960 if ((ports[res->port_id].tso_segsz != 0) &&
4961 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4962 printf("Warning: TSO enabled but not "
4963 "supported by port %d\n", res->port_id);
4966 cmd_reconfig_device_queue(res->port_id, 1, 1);
4969 cmdline_parse_token_string_t cmd_tso_set_tso =
4970 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4972 cmdline_parse_token_string_t cmd_tso_set_mode =
4973 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4975 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
4976 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4978 cmdline_parse_token_num_t cmd_tso_set_portid =
4979 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4982 cmdline_parse_inst_t cmd_tso_set = {
4983 .f = cmd_tso_set_parsed,
4985 .help_str = "tso set <tso_segsz> <port_id>: "
4986 "Set TSO segment size of non-tunneled packets for csum engine "
4989 (void *)&cmd_tso_set_tso,
4990 (void *)&cmd_tso_set_mode,
4991 (void *)&cmd_tso_set_tso_segsz,
4992 (void *)&cmd_tso_set_portid,
4997 cmdline_parse_token_string_t cmd_tso_show_mode =
4998 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
5002 cmdline_parse_inst_t cmd_tso_show = {
5003 .f = cmd_tso_set_parsed,
5005 .help_str = "tso show <port_id>: "
5006 "Show TSO segment size of non-tunneled packets for csum engine",
5008 (void *)&cmd_tso_set_tso,
5009 (void *)&cmd_tso_show_mode,
5010 (void *)&cmd_tso_set_portid,
5015 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
5016 struct cmd_tunnel_tso_set_result {
5017 cmdline_fixed_string_t tso;
5018 cmdline_fixed_string_t mode;
5023 static struct rte_eth_dev_info
5024 check_tunnel_tso_nic_support(portid_t port_id)
5026 struct rte_eth_dev_info dev_info;
5028 if (eth_dev_info_get_print_err(port_id, &dev_info) != 0)
5031 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO))
5032 printf("Warning: VXLAN TUNNEL TSO not supported therefore "
5033 "not enabled for port %d\n", port_id);
5034 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO))
5035 printf("Warning: GRE TUNNEL TSO not supported therefore "
5036 "not enabled for port %d\n", port_id);
5037 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO))
5038 printf("Warning: IPIP TUNNEL TSO not supported therefore "
5039 "not enabled for port %d\n", port_id);
5040 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
5041 printf("Warning: GENEVE TUNNEL TSO not supported therefore "
5042 "not enabled for port %d\n", port_id);
5043 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IP_TNL_TSO))
5044 printf("Warning: IP TUNNEL TSO not supported therefore "
5045 "not enabled for port %d\n", port_id);
5046 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_TNL_TSO))
5047 printf("Warning: UDP TUNNEL TSO not supported therefore "
5048 "not enabled for port %d\n", port_id);
5053 cmd_tunnel_tso_set_parsed(void *parsed_result,
5054 __rte_unused struct cmdline *cl,
5055 __rte_unused void *data)
5057 struct cmd_tunnel_tso_set_result *res = parsed_result;
5058 struct rte_eth_dev_info dev_info;
5060 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
5062 if (!port_is_stopped(res->port_id)) {
5063 printf("Please stop port %d first\n", res->port_id);
5067 if (!strcmp(res->mode, "set"))
5068 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
5070 dev_info = check_tunnel_tso_nic_support(res->port_id);
5071 if (ports[res->port_id].tunnel_tso_segsz == 0) {
5072 ports[res->port_id].dev_conf.txmode.offloads &=
5073 ~(DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
5074 DEV_TX_OFFLOAD_GRE_TNL_TSO |
5075 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
5076 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
5077 DEV_TX_OFFLOAD_IP_TNL_TSO |
5078 DEV_TX_OFFLOAD_UDP_TNL_TSO);
5079 printf("TSO for tunneled packets is disabled\n");
5081 uint64_t tso_offloads = (DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
5082 DEV_TX_OFFLOAD_GRE_TNL_TSO |
5083 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
5084 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
5085 DEV_TX_OFFLOAD_IP_TNL_TSO |
5086 DEV_TX_OFFLOAD_UDP_TNL_TSO);
5088 ports[res->port_id].dev_conf.txmode.offloads |=
5089 (tso_offloads & dev_info.tx_offload_capa);
5090 printf("TSO segment size for tunneled packets is %d\n",
5091 ports[res->port_id].tunnel_tso_segsz);
5093 /* Below conditions are needed to make it work:
5094 * (1) tunnel TSO is supported by the NIC;
5095 * (2) "csum parse_tunnel" must be set so that tunneled pkts
5097 * (3) for tunneled pkts with outer L3 of IPv4,
5098 * "csum set outer-ip" must be set to hw, because after tso,
5099 * total_len of outer IP header is changed, and the checksum
5100 * of outer IP header calculated by sw should be wrong; that
5101 * is not necessary for IPv6 tunneled pkts because there's no
5102 * checksum in IP header anymore.
5105 if (!ports[res->port_id].parse_tunnel)
5106 printf("Warning: csum parse_tunnel must be set "
5107 "so that tunneled packets are recognized\n");
5108 if (!(ports[res->port_id].dev_conf.txmode.offloads &
5109 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM))
5110 printf("Warning: csum set outer-ip must be set to hw "
5111 "if outer L3 is IPv4; not necessary for IPv6\n");
5114 cmd_config_queue_tx_offloads(&ports[res->port_id]);
5115 cmd_reconfig_device_queue(res->port_id, 1, 1);
5118 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
5119 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
5121 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
5122 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
5124 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
5125 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
5127 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
5128 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
5131 cmdline_parse_inst_t cmd_tunnel_tso_set = {
5132 .f = cmd_tunnel_tso_set_parsed,
5134 .help_str = "tunnel_tso set <tso_segsz> <port_id>: "
5135 "Set TSO segment size of tunneled packets for csum engine "
5138 (void *)&cmd_tunnel_tso_set_tso,
5139 (void *)&cmd_tunnel_tso_set_mode,
5140 (void *)&cmd_tunnel_tso_set_tso_segsz,
5141 (void *)&cmd_tunnel_tso_set_portid,
5146 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
5147 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
5151 cmdline_parse_inst_t cmd_tunnel_tso_show = {
5152 .f = cmd_tunnel_tso_set_parsed,
5154 .help_str = "tunnel_tso show <port_id> "
5155 "Show TSO segment size of tunneled packets for csum engine",
5157 (void *)&cmd_tunnel_tso_set_tso,
5158 (void *)&cmd_tunnel_tso_show_mode,
5159 (void *)&cmd_tunnel_tso_set_portid,
5164 /* *** SET GRO FOR A PORT *** */
5165 struct cmd_gro_enable_result {
5166 cmdline_fixed_string_t cmd_set;
5167 cmdline_fixed_string_t cmd_port;
5168 cmdline_fixed_string_t cmd_keyword;
5169 cmdline_fixed_string_t cmd_onoff;
5174 cmd_gro_enable_parsed(void *parsed_result,
5175 __rte_unused struct cmdline *cl,
5176 __rte_unused void *data)
5178 struct cmd_gro_enable_result *res;
5180 res = parsed_result;
5181 if (!strcmp(res->cmd_keyword, "gro"))
5182 setup_gro(res->cmd_onoff, res->cmd_pid);
5185 cmdline_parse_token_string_t cmd_gro_enable_set =
5186 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5188 cmdline_parse_token_string_t cmd_gro_enable_port =
5189 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5190 cmd_keyword, "port");
5191 cmdline_parse_token_num_t cmd_gro_enable_pid =
5192 TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result,
5194 cmdline_parse_token_string_t cmd_gro_enable_keyword =
5195 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5196 cmd_keyword, "gro");
5197 cmdline_parse_token_string_t cmd_gro_enable_onoff =
5198 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5199 cmd_onoff, "on#off");
5201 cmdline_parse_inst_t cmd_gro_enable = {
5202 .f = cmd_gro_enable_parsed,
5204 .help_str = "set port <port_id> gro on|off",
5206 (void *)&cmd_gro_enable_set,
5207 (void *)&cmd_gro_enable_port,
5208 (void *)&cmd_gro_enable_pid,
5209 (void *)&cmd_gro_enable_keyword,
5210 (void *)&cmd_gro_enable_onoff,
5215 /* *** DISPLAY GRO CONFIGURATION *** */
5216 struct cmd_gro_show_result {
5217 cmdline_fixed_string_t cmd_show;
5218 cmdline_fixed_string_t cmd_port;
5219 cmdline_fixed_string_t cmd_keyword;
5224 cmd_gro_show_parsed(void *parsed_result,
5225 __rte_unused struct cmdline *cl,
5226 __rte_unused void *data)
5228 struct cmd_gro_show_result *res;
5230 res = parsed_result;
5231 if (!strcmp(res->cmd_keyword, "gro"))
5232 show_gro(res->cmd_pid);
5235 cmdline_parse_token_string_t cmd_gro_show_show =
5236 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5238 cmdline_parse_token_string_t cmd_gro_show_port =
5239 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5241 cmdline_parse_token_num_t cmd_gro_show_pid =
5242 TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result,
5244 cmdline_parse_token_string_t cmd_gro_show_keyword =
5245 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5246 cmd_keyword, "gro");
5248 cmdline_parse_inst_t cmd_gro_show = {
5249 .f = cmd_gro_show_parsed,
5251 .help_str = "show port <port_id> gro",
5253 (void *)&cmd_gro_show_show,
5254 (void *)&cmd_gro_show_port,
5255 (void *)&cmd_gro_show_pid,
5256 (void *)&cmd_gro_show_keyword,
5261 /* *** SET FLUSH CYCLES FOR GRO *** */
5262 struct cmd_gro_flush_result {
5263 cmdline_fixed_string_t cmd_set;
5264 cmdline_fixed_string_t cmd_keyword;
5265 cmdline_fixed_string_t cmd_flush;
5270 cmd_gro_flush_parsed(void *parsed_result,
5271 __rte_unused struct cmdline *cl,
5272 __rte_unused void *data)
5274 struct cmd_gro_flush_result *res;
5276 res = parsed_result;
5277 if ((!strcmp(res->cmd_keyword, "gro")) &&
5278 (!strcmp(res->cmd_flush, "flush")))
5279 setup_gro_flush_cycles(res->cmd_cycles);
5282 cmdline_parse_token_string_t cmd_gro_flush_set =
5283 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5285 cmdline_parse_token_string_t cmd_gro_flush_keyword =
5286 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5287 cmd_keyword, "gro");
5288 cmdline_parse_token_string_t cmd_gro_flush_flush =
5289 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5290 cmd_flush, "flush");
5291 cmdline_parse_token_num_t cmd_gro_flush_cycles =
5292 TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result,
5295 cmdline_parse_inst_t cmd_gro_flush = {
5296 .f = cmd_gro_flush_parsed,
5298 .help_str = "set gro flush <cycles>",
5300 (void *)&cmd_gro_flush_set,
5301 (void *)&cmd_gro_flush_keyword,
5302 (void *)&cmd_gro_flush_flush,
5303 (void *)&cmd_gro_flush_cycles,
5308 /* *** ENABLE/DISABLE GSO *** */
5309 struct cmd_gso_enable_result {
5310 cmdline_fixed_string_t cmd_set;
5311 cmdline_fixed_string_t cmd_port;
5312 cmdline_fixed_string_t cmd_keyword;
5313 cmdline_fixed_string_t cmd_mode;
5318 cmd_gso_enable_parsed(void *parsed_result,
5319 __rte_unused struct cmdline *cl,
5320 __rte_unused void *data)
5322 struct cmd_gso_enable_result *res;
5324 res = parsed_result;
5325 if (!strcmp(res->cmd_keyword, "gso"))
5326 setup_gso(res->cmd_mode, res->cmd_pid);
5329 cmdline_parse_token_string_t cmd_gso_enable_set =
5330 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5332 cmdline_parse_token_string_t cmd_gso_enable_port =
5333 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5335 cmdline_parse_token_string_t cmd_gso_enable_keyword =
5336 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5337 cmd_keyword, "gso");
5338 cmdline_parse_token_string_t cmd_gso_enable_mode =
5339 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5340 cmd_mode, "on#off");
5341 cmdline_parse_token_num_t cmd_gso_enable_pid =
5342 TOKEN_NUM_INITIALIZER(struct cmd_gso_enable_result,
5345 cmdline_parse_inst_t cmd_gso_enable = {
5346 .f = cmd_gso_enable_parsed,
5348 .help_str = "set port <port_id> gso on|off",
5350 (void *)&cmd_gso_enable_set,
5351 (void *)&cmd_gso_enable_port,
5352 (void *)&cmd_gso_enable_pid,
5353 (void *)&cmd_gso_enable_keyword,
5354 (void *)&cmd_gso_enable_mode,
5359 /* *** SET MAX PACKET LENGTH FOR GSO SEGMENTS *** */
5360 struct cmd_gso_size_result {
5361 cmdline_fixed_string_t cmd_set;
5362 cmdline_fixed_string_t cmd_keyword;
5363 cmdline_fixed_string_t cmd_segsz;
5368 cmd_gso_size_parsed(void *parsed_result,
5369 __rte_unused struct cmdline *cl,
5370 __rte_unused void *data)
5372 struct cmd_gso_size_result *res = parsed_result;
5374 if (test_done == 0) {
5375 printf("Before setting GSO segsz, please first"
5376 " stop forwarding\n");
5380 if (!strcmp(res->cmd_keyword, "gso") &&
5381 !strcmp(res->cmd_segsz, "segsz")) {
5382 if (res->cmd_size < RTE_GSO_SEG_SIZE_MIN)
5383 printf("gso_size should be larger than %zu."
5384 " Please input a legal value\n",
5385 RTE_GSO_SEG_SIZE_MIN);
5387 gso_max_segment_size = res->cmd_size;
5391 cmdline_parse_token_string_t cmd_gso_size_set =
5392 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5394 cmdline_parse_token_string_t cmd_gso_size_keyword =
5395 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5396 cmd_keyword, "gso");
5397 cmdline_parse_token_string_t cmd_gso_size_segsz =
5398 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5399 cmd_segsz, "segsz");
5400 cmdline_parse_token_num_t cmd_gso_size_size =
5401 TOKEN_NUM_INITIALIZER(struct cmd_gso_size_result,
5404 cmdline_parse_inst_t cmd_gso_size = {
5405 .f = cmd_gso_size_parsed,
5407 .help_str = "set gso segsz <length>",
5409 (void *)&cmd_gso_size_set,
5410 (void *)&cmd_gso_size_keyword,
5411 (void *)&cmd_gso_size_segsz,
5412 (void *)&cmd_gso_size_size,
5417 /* *** SHOW GSO CONFIGURATION *** */
5418 struct cmd_gso_show_result {
5419 cmdline_fixed_string_t cmd_show;
5420 cmdline_fixed_string_t cmd_port;
5421 cmdline_fixed_string_t cmd_keyword;
5426 cmd_gso_show_parsed(void *parsed_result,
5427 __rte_unused struct cmdline *cl,
5428 __rte_unused void *data)
5430 struct cmd_gso_show_result *res = parsed_result;
5432 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
5433 printf("invalid port id %u\n", res->cmd_pid);
5436 if (!strcmp(res->cmd_keyword, "gso")) {
5437 if (gso_ports[res->cmd_pid].enable) {
5438 printf("Max GSO'd packet size: %uB\n"
5439 "Supported GSO types: TCP/IPv4, "
5440 "UDP/IPv4, VxLAN with inner "
5441 "TCP/IPv4 packet, GRE with inner "
5442 "TCP/IPv4 packet\n",
5443 gso_max_segment_size);
5445 printf("GSO is not enabled on Port %u\n", res->cmd_pid);
5449 cmdline_parse_token_string_t cmd_gso_show_show =
5450 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5452 cmdline_parse_token_string_t cmd_gso_show_port =
5453 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5455 cmdline_parse_token_string_t cmd_gso_show_keyword =
5456 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5457 cmd_keyword, "gso");
5458 cmdline_parse_token_num_t cmd_gso_show_pid =
5459 TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result,
5462 cmdline_parse_inst_t cmd_gso_show = {
5463 .f = cmd_gso_show_parsed,
5465 .help_str = "show port <port_id> gso",
5467 (void *)&cmd_gso_show_show,
5468 (void *)&cmd_gso_show_port,
5469 (void *)&cmd_gso_show_pid,
5470 (void *)&cmd_gso_show_keyword,
5475 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
5476 struct cmd_set_flush_rx {
5477 cmdline_fixed_string_t set;
5478 cmdline_fixed_string_t flush_rx;
5479 cmdline_fixed_string_t mode;
5483 cmd_set_flush_rx_parsed(void *parsed_result,
5484 __rte_unused struct cmdline *cl,
5485 __rte_unused void *data)
5487 struct cmd_set_flush_rx *res = parsed_result;
5488 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5491 cmdline_parse_token_string_t cmd_setflushrx_set =
5492 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5494 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
5495 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5496 flush_rx, "flush_rx");
5497 cmdline_parse_token_string_t cmd_setflushrx_mode =
5498 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5502 cmdline_parse_inst_t cmd_set_flush_rx = {
5503 .f = cmd_set_flush_rx_parsed,
5504 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
5507 (void *)&cmd_setflushrx_set,
5508 (void *)&cmd_setflushrx_flush_rx,
5509 (void *)&cmd_setflushrx_mode,
5514 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
5515 struct cmd_set_link_check {
5516 cmdline_fixed_string_t set;
5517 cmdline_fixed_string_t link_check;
5518 cmdline_fixed_string_t mode;
5522 cmd_set_link_check_parsed(void *parsed_result,
5523 __rte_unused struct cmdline *cl,
5524 __rte_unused void *data)
5526 struct cmd_set_link_check *res = parsed_result;
5527 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5530 cmdline_parse_token_string_t cmd_setlinkcheck_set =
5531 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5533 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
5534 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5535 link_check, "link_check");
5536 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
5537 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5541 cmdline_parse_inst_t cmd_set_link_check = {
5542 .f = cmd_set_link_check_parsed,
5543 .help_str = "set link_check on|off: Enable/Disable link status check "
5544 "when starting/stopping a port",
5547 (void *)&cmd_setlinkcheck_set,
5548 (void *)&cmd_setlinkcheck_link_check,
5549 (void *)&cmd_setlinkcheck_mode,
5554 /* *** SET NIC BYPASS MODE *** */
5555 struct cmd_set_bypass_mode_result {
5556 cmdline_fixed_string_t set;
5557 cmdline_fixed_string_t bypass;
5558 cmdline_fixed_string_t mode;
5559 cmdline_fixed_string_t value;
5564 cmd_set_bypass_mode_parsed(void *parsed_result,
5565 __rte_unused struct cmdline *cl,
5566 __rte_unused void *data)
5568 struct cmd_set_bypass_mode_result *res = parsed_result;
5569 portid_t port_id = res->port_id;
5570 int32_t rc = -EINVAL;
5572 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5573 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5575 if (!strcmp(res->value, "bypass"))
5576 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5577 else if (!strcmp(res->value, "isolate"))
5578 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5580 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5582 /* Set the bypass mode for the relevant port. */
5583 rc = rte_pmd_ixgbe_bypass_state_set(port_id, &bypass_mode);
5586 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
5589 cmdline_parse_token_string_t cmd_setbypass_mode_set =
5590 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5592 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
5593 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5595 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
5596 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5598 cmdline_parse_token_string_t cmd_setbypass_mode_value =
5599 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5600 value, "normal#bypass#isolate");
5601 cmdline_parse_token_num_t cmd_setbypass_mode_port =
5602 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
5605 cmdline_parse_inst_t cmd_set_bypass_mode = {
5606 .f = cmd_set_bypass_mode_parsed,
5607 .help_str = "set bypass mode normal|bypass|isolate <port_id>: "
5608 "Set the NIC bypass mode for port_id",
5611 (void *)&cmd_setbypass_mode_set,
5612 (void *)&cmd_setbypass_mode_bypass,
5613 (void *)&cmd_setbypass_mode_mode,
5614 (void *)&cmd_setbypass_mode_value,
5615 (void *)&cmd_setbypass_mode_port,
5620 /* *** SET NIC BYPASS EVENT *** */
5621 struct cmd_set_bypass_event_result {
5622 cmdline_fixed_string_t set;
5623 cmdline_fixed_string_t bypass;
5624 cmdline_fixed_string_t event;
5625 cmdline_fixed_string_t event_value;
5626 cmdline_fixed_string_t mode;
5627 cmdline_fixed_string_t mode_value;
5632 cmd_set_bypass_event_parsed(void *parsed_result,
5633 __rte_unused struct cmdline *cl,
5634 __rte_unused void *data)
5636 int32_t rc = -EINVAL;
5637 struct cmd_set_bypass_event_result *res = parsed_result;
5638 portid_t port_id = res->port_id;
5640 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5641 uint32_t bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5642 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5644 if (!strcmp(res->event_value, "timeout"))
5645 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT;
5646 else if (!strcmp(res->event_value, "os_on"))
5647 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_ON;
5648 else if (!strcmp(res->event_value, "os_off"))
5649 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_OFF;
5650 else if (!strcmp(res->event_value, "power_on"))
5651 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_ON;
5652 else if (!strcmp(res->event_value, "power_off"))
5653 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_OFF;
5655 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5657 if (!strcmp(res->mode_value, "bypass"))
5658 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5659 else if (!strcmp(res->mode_value, "isolate"))
5660 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5662 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5664 /* Set the watchdog timeout. */
5665 if (bypass_event == RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT) {
5668 if (RTE_PMD_IXGBE_BYPASS_TMT_VALID(bypass_timeout)) {
5669 rc = rte_pmd_ixgbe_bypass_wd_timeout_store(port_id,
5673 printf("Failed to set timeout value %u "
5674 "for port %d, errto code: %d.\n",
5675 bypass_timeout, port_id, rc);
5679 /* Set the bypass event to transition to bypass mode. */
5680 rc = rte_pmd_ixgbe_bypass_event_store(port_id, bypass_event,
5685 printf("\t Failed to set bypass event for port = %d.\n",
5689 cmdline_parse_token_string_t cmd_setbypass_event_set =
5690 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5692 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
5693 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5695 cmdline_parse_token_string_t cmd_setbypass_event_event =
5696 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5698 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
5699 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5700 event_value, "none#timeout#os_off#os_on#power_on#power_off");
5701 cmdline_parse_token_string_t cmd_setbypass_event_mode =
5702 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5704 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
5705 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5706 mode_value, "normal#bypass#isolate");
5707 cmdline_parse_token_num_t cmd_setbypass_event_port =
5708 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
5711 cmdline_parse_inst_t cmd_set_bypass_event = {
5712 .f = cmd_set_bypass_event_parsed,
5713 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
5714 "power_off mode normal|bypass|isolate <port_id>: "
5715 "Set the NIC bypass event mode for port_id",
5718 (void *)&cmd_setbypass_event_set,
5719 (void *)&cmd_setbypass_event_bypass,
5720 (void *)&cmd_setbypass_event_event,
5721 (void *)&cmd_setbypass_event_event_value,
5722 (void *)&cmd_setbypass_event_mode,
5723 (void *)&cmd_setbypass_event_mode_value,
5724 (void *)&cmd_setbypass_event_port,
5730 /* *** SET NIC BYPASS TIMEOUT *** */
5731 struct cmd_set_bypass_timeout_result {
5732 cmdline_fixed_string_t set;
5733 cmdline_fixed_string_t bypass;
5734 cmdline_fixed_string_t timeout;
5735 cmdline_fixed_string_t value;
5739 cmd_set_bypass_timeout_parsed(void *parsed_result,
5740 __rte_unused struct cmdline *cl,
5741 __rte_unused void *data)
5743 __rte_unused struct cmd_set_bypass_timeout_result *res = parsed_result;
5745 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5746 if (!strcmp(res->value, "1.5"))
5747 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_1_5_SEC;
5748 else if (!strcmp(res->value, "2"))
5749 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_2_SEC;
5750 else if (!strcmp(res->value, "3"))
5751 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_3_SEC;
5752 else if (!strcmp(res->value, "4"))
5753 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_4_SEC;
5754 else if (!strcmp(res->value, "8"))
5755 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_8_SEC;
5756 else if (!strcmp(res->value, "16"))
5757 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_16_SEC;
5758 else if (!strcmp(res->value, "32"))
5759 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_32_SEC;
5761 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5765 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
5766 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5768 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
5769 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5771 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
5772 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5773 timeout, "timeout");
5774 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
5775 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5776 value, "0#1.5#2#3#4#8#16#32");
5778 cmdline_parse_inst_t cmd_set_bypass_timeout = {
5779 .f = cmd_set_bypass_timeout_parsed,
5780 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
5781 "Set the NIC bypass watchdog timeout in seconds",
5784 (void *)&cmd_setbypass_timeout_set,
5785 (void *)&cmd_setbypass_timeout_bypass,
5786 (void *)&cmd_setbypass_timeout_timeout,
5787 (void *)&cmd_setbypass_timeout_value,
5792 /* *** SHOW NIC BYPASS MODE *** */
5793 struct cmd_show_bypass_config_result {
5794 cmdline_fixed_string_t show;
5795 cmdline_fixed_string_t bypass;
5796 cmdline_fixed_string_t config;
5801 cmd_show_bypass_config_parsed(void *parsed_result,
5802 __rte_unused struct cmdline *cl,
5803 __rte_unused void *data)
5805 struct cmd_show_bypass_config_result *res = parsed_result;
5806 portid_t port_id = res->port_id;
5808 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5809 uint32_t event_mode;
5810 uint32_t bypass_mode;
5811 uint32_t timeout = bypass_timeout;
5814 static const char * const timeouts[RTE_PMD_IXGBE_BYPASS_TMT_NUM] =
5815 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
5816 static const char * const modes[RTE_PMD_IXGBE_BYPASS_MODE_NUM] =
5817 {"UNKNOWN", "normal", "bypass", "isolate"};
5818 static const char * const events[RTE_PMD_IXGBE_BYPASS_EVENT_NUM] = {
5826 /* Display the bypass mode.*/
5827 if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) != 0) {
5828 printf("\tFailed to get bypass mode for port = %d\n", port_id);
5832 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(bypass_mode))
5833 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5835 printf("\tbypass mode = %s\n", modes[bypass_mode]);
5838 /* Display the bypass timeout.*/
5839 if (!RTE_PMD_IXGBE_BYPASS_TMT_VALID(timeout))
5840 timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5842 printf("\tbypass timeout = %s\n", timeouts[timeout]);
5844 /* Display the bypass events and associated modes. */
5845 for (i = RTE_PMD_IXGBE_BYPASS_EVENT_START; i < RTE_DIM(events); i++) {
5847 if (rte_pmd_ixgbe_bypass_event_show(port_id, i, &event_mode)) {
5848 printf("\tFailed to get bypass mode for event = %s\n",
5851 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(event_mode))
5852 event_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5854 printf("\tbypass event: %-16s = %s\n", events[i],
5860 printf("\tFailed to get bypass configuration for port = %d\n",
5864 cmdline_parse_token_string_t cmd_showbypass_config_show =
5865 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5867 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
5868 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5870 cmdline_parse_token_string_t cmd_showbypass_config_config =
5871 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5873 cmdline_parse_token_num_t cmd_showbypass_config_port =
5874 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
5877 cmdline_parse_inst_t cmd_show_bypass_config = {
5878 .f = cmd_show_bypass_config_parsed,
5879 .help_str = "show bypass config <port_id>: "
5880 "Show the NIC bypass config for port_id",
5883 (void *)&cmd_showbypass_config_show,
5884 (void *)&cmd_showbypass_config_bypass,
5885 (void *)&cmd_showbypass_config_config,
5886 (void *)&cmd_showbypass_config_port,
5892 /* *** SET BONDING MODE *** */
5893 struct cmd_set_bonding_mode_result {
5894 cmdline_fixed_string_t set;
5895 cmdline_fixed_string_t bonding;
5896 cmdline_fixed_string_t mode;
5901 static void cmd_set_bonding_mode_parsed(void *parsed_result,
5902 __rte_unused struct cmdline *cl,
5903 __rte_unused void *data)
5905 struct cmd_set_bonding_mode_result *res = parsed_result;
5906 portid_t port_id = res->port_id;
5908 /* Set the bonding mode for the relevant port. */
5909 if (0 != rte_eth_bond_mode_set(port_id, res->value))
5910 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
5913 cmdline_parse_token_string_t cmd_setbonding_mode_set =
5914 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5916 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
5917 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5918 bonding, "bonding");
5919 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
5920 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5922 cmdline_parse_token_num_t cmd_setbonding_mode_value =
5923 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5925 cmdline_parse_token_num_t cmd_setbonding_mode_port =
5926 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5929 cmdline_parse_inst_t cmd_set_bonding_mode = {
5930 .f = cmd_set_bonding_mode_parsed,
5931 .help_str = "set bonding mode <mode_value> <port_id>: "
5932 "Set the bonding mode for port_id",
5935 (void *) &cmd_setbonding_mode_set,
5936 (void *) &cmd_setbonding_mode_bonding,
5937 (void *) &cmd_setbonding_mode_mode,
5938 (void *) &cmd_setbonding_mode_value,
5939 (void *) &cmd_setbonding_mode_port,
5944 /* *** SET BONDING SLOW_QUEUE SW/HW *** */
5945 struct cmd_set_bonding_lacp_dedicated_queues_result {
5946 cmdline_fixed_string_t set;
5947 cmdline_fixed_string_t bonding;
5948 cmdline_fixed_string_t lacp;
5949 cmdline_fixed_string_t dedicated_queues;
5951 cmdline_fixed_string_t mode;
5954 static void cmd_set_bonding_lacp_dedicated_queues_parsed(void *parsed_result,
5955 __rte_unused struct cmdline *cl,
5956 __rte_unused void *data)
5958 struct cmd_set_bonding_lacp_dedicated_queues_result *res = parsed_result;
5959 portid_t port_id = res->port_id;
5960 struct rte_port *port;
5962 port = &ports[port_id];
5964 /** Check if the port is not started **/
5965 if (port->port_status != RTE_PORT_STOPPED) {
5966 printf("Please stop port %d first\n", port_id);
5970 if (!strcmp(res->mode, "enable")) {
5971 if (rte_eth_bond_8023ad_dedicated_queues_enable(port_id) == 0)
5972 printf("Dedicate queues for LACP control packets"
5975 printf("Enabling dedicate queues for LACP control "
5976 "packets on port %d failed\n", port_id);
5977 } else if (!strcmp(res->mode, "disable")) {
5978 if (rte_eth_bond_8023ad_dedicated_queues_disable(port_id) == 0)
5979 printf("Dedicated queues for LACP control packets "
5982 printf("Disabling dedicated queues for LACP control "
5983 "traffic on port %d failed\n", port_id);
5987 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_set =
5988 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5990 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_bonding =
5991 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5992 bonding, "bonding");
5993 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_lacp =
5994 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5996 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_dedicated_queues =
5997 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5998 dedicated_queues, "dedicated_queues");
5999 cmdline_parse_token_num_t cmd_setbonding_lacp_dedicated_queues_port_id =
6000 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
6002 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_mode =
6003 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
6004 mode, "enable#disable");
6006 cmdline_parse_inst_t cmd_set_lacp_dedicated_queues = {
6007 .f = cmd_set_bonding_lacp_dedicated_queues_parsed,
6008 .help_str = "set bonding lacp dedicated_queues <port_id> "
6010 "Enable/disable dedicated queues for LACP control traffic for port_id",
6013 (void *)&cmd_setbonding_lacp_dedicated_queues_set,
6014 (void *)&cmd_setbonding_lacp_dedicated_queues_bonding,
6015 (void *)&cmd_setbonding_lacp_dedicated_queues_lacp,
6016 (void *)&cmd_setbonding_lacp_dedicated_queues_dedicated_queues,
6017 (void *)&cmd_setbonding_lacp_dedicated_queues_port_id,
6018 (void *)&cmd_setbonding_lacp_dedicated_queues_mode,
6023 /* *** SET BALANCE XMIT POLICY *** */
6024 struct cmd_set_bonding_balance_xmit_policy_result {
6025 cmdline_fixed_string_t set;
6026 cmdline_fixed_string_t bonding;
6027 cmdline_fixed_string_t balance_xmit_policy;
6029 cmdline_fixed_string_t policy;
6032 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
6033 __rte_unused struct cmdline *cl,
6034 __rte_unused void *data)
6036 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
6037 portid_t port_id = res->port_id;
6040 if (!strcmp(res->policy, "l2")) {
6041 policy = BALANCE_XMIT_POLICY_LAYER2;
6042 } else if (!strcmp(res->policy, "l23")) {
6043 policy = BALANCE_XMIT_POLICY_LAYER23;
6044 } else if (!strcmp(res->policy, "l34")) {
6045 policy = BALANCE_XMIT_POLICY_LAYER34;
6047 printf("\t Invalid xmit policy selection");
6051 /* Set the bonding mode for the relevant port. */
6052 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
6053 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
6058 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
6059 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6061 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
6062 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6063 bonding, "bonding");
6064 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
6065 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6066 balance_xmit_policy, "balance_xmit_policy");
6067 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
6068 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6070 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
6071 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6072 policy, "l2#l23#l34");
6074 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
6075 .f = cmd_set_bonding_balance_xmit_policy_parsed,
6076 .help_str = "set bonding balance_xmit_policy <port_id> "
6078 "Set the bonding balance_xmit_policy for port_id",
6081 (void *)&cmd_setbonding_balance_xmit_policy_set,
6082 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
6083 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
6084 (void *)&cmd_setbonding_balance_xmit_policy_port,
6085 (void *)&cmd_setbonding_balance_xmit_policy_policy,
6090 /* *** SHOW NIC BONDING CONFIGURATION *** */
6091 struct cmd_show_bonding_config_result {
6092 cmdline_fixed_string_t show;
6093 cmdline_fixed_string_t bonding;
6094 cmdline_fixed_string_t config;
6098 static void cmd_show_bonding_config_parsed(void *parsed_result,
6099 __rte_unused struct cmdline *cl,
6100 __rte_unused void *data)
6102 struct cmd_show_bonding_config_result *res = parsed_result;
6103 int bonding_mode, agg_mode;
6104 portid_t slaves[RTE_MAX_ETHPORTS];
6105 int num_slaves, num_active_slaves;
6108 portid_t port_id = res->port_id;
6110 /* Display the bonding mode.*/
6111 bonding_mode = rte_eth_bond_mode_get(port_id);
6112 if (bonding_mode < 0) {
6113 printf("\tFailed to get bonding mode for port = %d\n", port_id);
6116 printf("\tBonding mode: %d\n", bonding_mode);
6118 if (bonding_mode == BONDING_MODE_BALANCE) {
6119 int balance_xmit_policy;
6121 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
6122 if (balance_xmit_policy < 0) {
6123 printf("\tFailed to get balance xmit policy for port = %d\n",
6127 printf("\tBalance Xmit Policy: ");
6129 switch (balance_xmit_policy) {
6130 case BALANCE_XMIT_POLICY_LAYER2:
6131 printf("BALANCE_XMIT_POLICY_LAYER2");
6133 case BALANCE_XMIT_POLICY_LAYER23:
6134 printf("BALANCE_XMIT_POLICY_LAYER23");
6136 case BALANCE_XMIT_POLICY_LAYER34:
6137 printf("BALANCE_XMIT_POLICY_LAYER34");
6144 if (bonding_mode == BONDING_MODE_8023AD) {
6145 agg_mode = rte_eth_bond_8023ad_agg_selection_get(port_id);
6146 printf("\tIEEE802.3AD Aggregator Mode: ");
6149 printf("bandwidth");
6161 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
6163 if (num_slaves < 0) {
6164 printf("\tFailed to get slave list for port = %d\n", port_id);
6167 if (num_slaves > 0) {
6168 printf("\tSlaves (%d): [", num_slaves);
6169 for (i = 0; i < num_slaves - 1; i++)
6170 printf("%d ", slaves[i]);
6172 printf("%d]\n", slaves[num_slaves - 1]);
6174 printf("\tSlaves: []\n");
6178 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
6181 if (num_active_slaves < 0) {
6182 printf("\tFailed to get active slave list for port = %d\n", port_id);
6185 if (num_active_slaves > 0) {
6186 printf("\tActive Slaves (%d): [", num_active_slaves);
6187 for (i = 0; i < num_active_slaves - 1; i++)
6188 printf("%d ", slaves[i]);
6190 printf("%d]\n", slaves[num_active_slaves - 1]);
6193 printf("\tActive Slaves: []\n");
6197 primary_id = rte_eth_bond_primary_get(port_id);
6198 if (primary_id < 0) {
6199 printf("\tFailed to get primary slave for port = %d\n", port_id);
6202 printf("\tPrimary: [%d]\n", primary_id);
6206 cmdline_parse_token_string_t cmd_showbonding_config_show =
6207 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6209 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
6210 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6211 bonding, "bonding");
6212 cmdline_parse_token_string_t cmd_showbonding_config_config =
6213 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6215 cmdline_parse_token_num_t cmd_showbonding_config_port =
6216 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
6219 cmdline_parse_inst_t cmd_show_bonding_config = {
6220 .f = cmd_show_bonding_config_parsed,
6221 .help_str = "show bonding config <port_id>: "
6222 "Show the bonding config for port_id",
6225 (void *)&cmd_showbonding_config_show,
6226 (void *)&cmd_showbonding_config_bonding,
6227 (void *)&cmd_showbonding_config_config,
6228 (void *)&cmd_showbonding_config_port,
6233 /* *** SET BONDING PRIMARY *** */
6234 struct cmd_set_bonding_primary_result {
6235 cmdline_fixed_string_t set;
6236 cmdline_fixed_string_t bonding;
6237 cmdline_fixed_string_t primary;
6242 static void cmd_set_bonding_primary_parsed(void *parsed_result,
6243 __rte_unused struct cmdline *cl,
6244 __rte_unused void *data)
6246 struct cmd_set_bonding_primary_result *res = parsed_result;
6247 portid_t master_port_id = res->port_id;
6248 portid_t slave_port_id = res->slave_id;
6250 /* Set the primary slave for a bonded device. */
6251 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
6252 printf("\t Failed to set primary slave for port = %d.\n",
6259 cmdline_parse_token_string_t cmd_setbonding_primary_set =
6260 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6262 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
6263 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6264 bonding, "bonding");
6265 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
6266 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6267 primary, "primary");
6268 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
6269 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
6271 cmdline_parse_token_num_t cmd_setbonding_primary_port =
6272 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
6275 cmdline_parse_inst_t cmd_set_bonding_primary = {
6276 .f = cmd_set_bonding_primary_parsed,
6277 .help_str = "set bonding primary <slave_id> <port_id>: "
6278 "Set the primary slave for port_id",
6281 (void *)&cmd_setbonding_primary_set,
6282 (void *)&cmd_setbonding_primary_bonding,
6283 (void *)&cmd_setbonding_primary_primary,
6284 (void *)&cmd_setbonding_primary_slave,
6285 (void *)&cmd_setbonding_primary_port,
6290 /* *** ADD SLAVE *** */
6291 struct cmd_add_bonding_slave_result {
6292 cmdline_fixed_string_t add;
6293 cmdline_fixed_string_t bonding;
6294 cmdline_fixed_string_t slave;
6299 static void cmd_add_bonding_slave_parsed(void *parsed_result,
6300 __rte_unused struct cmdline *cl,
6301 __rte_unused void *data)
6303 struct cmd_add_bonding_slave_result *res = parsed_result;
6304 portid_t master_port_id = res->port_id;
6305 portid_t slave_port_id = res->slave_id;
6307 /* add the slave for a bonded device. */
6308 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
6309 printf("\t Failed to add slave %d to master port = %d.\n",
6310 slave_port_id, master_port_id);
6314 set_port_slave_flag(slave_port_id);
6317 cmdline_parse_token_string_t cmd_addbonding_slave_add =
6318 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6320 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
6321 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6322 bonding, "bonding");
6323 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
6324 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6326 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
6327 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
6329 cmdline_parse_token_num_t cmd_addbonding_slave_port =
6330 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
6333 cmdline_parse_inst_t cmd_add_bonding_slave = {
6334 .f = cmd_add_bonding_slave_parsed,
6335 .help_str = "add bonding slave <slave_id> <port_id>: "
6336 "Add a slave device to a bonded device",
6339 (void *)&cmd_addbonding_slave_add,
6340 (void *)&cmd_addbonding_slave_bonding,
6341 (void *)&cmd_addbonding_slave_slave,
6342 (void *)&cmd_addbonding_slave_slaveid,
6343 (void *)&cmd_addbonding_slave_port,
6348 /* *** REMOVE SLAVE *** */
6349 struct cmd_remove_bonding_slave_result {
6350 cmdline_fixed_string_t remove;
6351 cmdline_fixed_string_t bonding;
6352 cmdline_fixed_string_t slave;
6357 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
6358 __rte_unused struct cmdline *cl,
6359 __rte_unused void *data)
6361 struct cmd_remove_bonding_slave_result *res = parsed_result;
6362 portid_t master_port_id = res->port_id;
6363 portid_t slave_port_id = res->slave_id;
6365 /* remove the slave from a bonded device. */
6366 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
6367 printf("\t Failed to remove slave %d from master port = %d.\n",
6368 slave_port_id, master_port_id);
6372 clear_port_slave_flag(slave_port_id);
6375 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
6376 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6378 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
6379 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6380 bonding, "bonding");
6381 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
6382 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6384 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
6385 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6387 cmdline_parse_token_num_t cmd_removebonding_slave_port =
6388 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6391 cmdline_parse_inst_t cmd_remove_bonding_slave = {
6392 .f = cmd_remove_bonding_slave_parsed,
6393 .help_str = "remove bonding slave <slave_id> <port_id>: "
6394 "Remove a slave device from a bonded device",
6397 (void *)&cmd_removebonding_slave_remove,
6398 (void *)&cmd_removebonding_slave_bonding,
6399 (void *)&cmd_removebonding_slave_slave,
6400 (void *)&cmd_removebonding_slave_slaveid,
6401 (void *)&cmd_removebonding_slave_port,
6406 /* *** CREATE BONDED DEVICE *** */
6407 struct cmd_create_bonded_device_result {
6408 cmdline_fixed_string_t create;
6409 cmdline_fixed_string_t bonded;
6410 cmdline_fixed_string_t device;
6415 static int bond_dev_num = 0;
6417 static void cmd_create_bonded_device_parsed(void *parsed_result,
6418 __rte_unused struct cmdline *cl,
6419 __rte_unused void *data)
6421 struct cmd_create_bonded_device_result *res = parsed_result;
6422 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
6426 if (test_done == 0) {
6427 printf("Please stop forwarding first\n");
6431 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bonding_testpmd_%d",
6434 /* Create a new bonded device. */
6435 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
6437 printf("\t Failed to create bonded device.\n");
6440 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
6443 /* Update number of ports */
6444 nb_ports = rte_eth_dev_count_avail();
6445 reconfig(port_id, res->socket);
6446 ret = rte_eth_promiscuous_enable(port_id);
6448 printf("Failed to enable promiscuous mode for port %u: %s - ignore\n",
6449 port_id, rte_strerror(-ret));
6451 ports[port_id].need_setup = 0;
6452 ports[port_id].port_status = RTE_PORT_STOPPED;
6457 cmdline_parse_token_string_t cmd_createbonded_device_create =
6458 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6460 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
6461 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6463 cmdline_parse_token_string_t cmd_createbonded_device_device =
6464 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6466 cmdline_parse_token_num_t cmd_createbonded_device_mode =
6467 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6469 cmdline_parse_token_num_t cmd_createbonded_device_socket =
6470 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6473 cmdline_parse_inst_t cmd_create_bonded_device = {
6474 .f = cmd_create_bonded_device_parsed,
6475 .help_str = "create bonded device <mode> <socket>: "
6476 "Create a new bonded device with specific bonding mode and socket",
6479 (void *)&cmd_createbonded_device_create,
6480 (void *)&cmd_createbonded_device_bonded,
6481 (void *)&cmd_createbonded_device_device,
6482 (void *)&cmd_createbonded_device_mode,
6483 (void *)&cmd_createbonded_device_socket,
6488 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
6489 struct cmd_set_bond_mac_addr_result {
6490 cmdline_fixed_string_t set;
6491 cmdline_fixed_string_t bonding;
6492 cmdline_fixed_string_t mac_addr;
6494 struct rte_ether_addr address;
6497 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
6498 __rte_unused struct cmdline *cl,
6499 __rte_unused void *data)
6501 struct cmd_set_bond_mac_addr_result *res = parsed_result;
6504 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
6507 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
6509 /* check the return value and print it if is < 0 */
6511 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
6514 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
6515 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
6516 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
6517 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
6519 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
6520 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
6522 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
6523 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result,
6525 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
6526 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
6528 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
6529 .f = cmd_set_bond_mac_addr_parsed,
6531 .help_str = "set bonding mac_addr <port_id> <mac_addr>",
6533 (void *)&cmd_set_bond_mac_addr_set,
6534 (void *)&cmd_set_bond_mac_addr_bonding,
6535 (void *)&cmd_set_bond_mac_addr_mac,
6536 (void *)&cmd_set_bond_mac_addr_portnum,
6537 (void *)&cmd_set_bond_mac_addr_addr,
6543 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
6544 struct cmd_set_bond_mon_period_result {
6545 cmdline_fixed_string_t set;
6546 cmdline_fixed_string_t bonding;
6547 cmdline_fixed_string_t mon_period;
6552 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
6553 __rte_unused struct cmdline *cl,
6554 __rte_unused void *data)
6556 struct cmd_set_bond_mon_period_result *res = parsed_result;
6559 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
6561 /* check the return value and print it if is < 0 */
6563 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
6566 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
6567 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6569 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
6570 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6571 bonding, "bonding");
6572 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
6573 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6574 mon_period, "mon_period");
6575 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
6576 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6578 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
6579 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6582 cmdline_parse_inst_t cmd_set_bond_mon_period = {
6583 .f = cmd_set_bond_mon_period_parsed,
6585 .help_str = "set bonding mon_period <port_id> <period_ms>",
6587 (void *)&cmd_set_bond_mon_period_set,
6588 (void *)&cmd_set_bond_mon_period_bonding,
6589 (void *)&cmd_set_bond_mon_period_mon_period,
6590 (void *)&cmd_set_bond_mon_period_portnum,
6591 (void *)&cmd_set_bond_mon_period_period_ms,
6598 struct cmd_set_bonding_agg_mode_policy_result {
6599 cmdline_fixed_string_t set;
6600 cmdline_fixed_string_t bonding;
6601 cmdline_fixed_string_t agg_mode;
6603 cmdline_fixed_string_t policy;
6608 cmd_set_bonding_agg_mode(void *parsed_result,
6609 __rte_unused struct cmdline *cl,
6610 __rte_unused void *data)
6612 struct cmd_set_bonding_agg_mode_policy_result *res = parsed_result;
6613 uint8_t policy = AGG_BANDWIDTH;
6615 if (!strcmp(res->policy, "bandwidth"))
6616 policy = AGG_BANDWIDTH;
6617 else if (!strcmp(res->policy, "stable"))
6618 policy = AGG_STABLE;
6619 else if (!strcmp(res->policy, "count"))
6622 rte_eth_bond_8023ad_agg_selection_set(res->port_num, policy);
6626 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_set =
6627 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6629 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_bonding =
6630 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6631 bonding, "bonding");
6633 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_agg_mode =
6634 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6635 agg_mode, "agg_mode");
6637 cmdline_parse_token_num_t cmd_set_bonding_agg_mode_portnum =
6638 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6641 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_policy_string =
6642 TOKEN_STRING_INITIALIZER(
6643 struct cmd_set_bonding_balance_xmit_policy_result,
6644 policy, "stable#bandwidth#count");
6646 cmdline_parse_inst_t cmd_set_bonding_agg_mode_policy = {
6647 .f = cmd_set_bonding_agg_mode,
6649 .help_str = "set bonding mode IEEE802.3AD aggregator policy <port_id> <agg_name>",
6651 (void *)&cmd_set_bonding_agg_mode_set,
6652 (void *)&cmd_set_bonding_agg_mode_bonding,
6653 (void *)&cmd_set_bonding_agg_mode_agg_mode,
6654 (void *)&cmd_set_bonding_agg_mode_portnum,
6655 (void *)&cmd_set_bonding_agg_mode_policy_string,
6661 #endif /* RTE_NET_BOND */
6663 /* *** SET FORWARDING MODE *** */
6664 struct cmd_set_fwd_mode_result {
6665 cmdline_fixed_string_t set;
6666 cmdline_fixed_string_t fwd;
6667 cmdline_fixed_string_t mode;
6670 static void cmd_set_fwd_mode_parsed(void *parsed_result,
6671 __rte_unused struct cmdline *cl,
6672 __rte_unused void *data)
6674 struct cmd_set_fwd_mode_result *res = parsed_result;
6677 set_pkt_forwarding_mode(res->mode);
6680 cmdline_parse_token_string_t cmd_setfwd_set =
6681 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
6682 cmdline_parse_token_string_t cmd_setfwd_fwd =
6683 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
6684 cmdline_parse_token_string_t cmd_setfwd_mode =
6685 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
6686 "" /* defined at init */);
6688 cmdline_parse_inst_t cmd_set_fwd_mode = {
6689 .f = cmd_set_fwd_mode_parsed,
6691 .help_str = NULL, /* defined at init */
6693 (void *)&cmd_setfwd_set,
6694 (void *)&cmd_setfwd_fwd,
6695 (void *)&cmd_setfwd_mode,
6700 static void cmd_set_fwd_mode_init(void)
6703 static char token[128];
6704 static char help[256];
6705 cmdline_parse_token_string_t *token_struct;
6707 modes = list_pkt_forwarding_modes();
6708 snprintf(help, sizeof(help), "set fwd %s: "
6709 "Set packet forwarding mode", modes);
6710 cmd_set_fwd_mode.help_str = help;
6712 /* string token separator is # */
6713 for (c = token; *modes != '\0'; modes++)
6718 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
6719 token_struct->string_data.str = token;
6722 /* *** SET RETRY FORWARDING MODE *** */
6723 struct cmd_set_fwd_retry_mode_result {
6724 cmdline_fixed_string_t set;
6725 cmdline_fixed_string_t fwd;
6726 cmdline_fixed_string_t mode;
6727 cmdline_fixed_string_t retry;
6730 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
6731 __rte_unused struct cmdline *cl,
6732 __rte_unused void *data)
6734 struct cmd_set_fwd_retry_mode_result *res = parsed_result;
6737 set_pkt_forwarding_mode(res->mode);
6740 cmdline_parse_token_string_t cmd_setfwd_retry_set =
6741 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6743 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
6744 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6746 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
6747 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6749 "" /* defined at init */);
6750 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
6751 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6754 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
6755 .f = cmd_set_fwd_retry_mode_parsed,
6757 .help_str = NULL, /* defined at init */
6759 (void *)&cmd_setfwd_retry_set,
6760 (void *)&cmd_setfwd_retry_fwd,
6761 (void *)&cmd_setfwd_retry_mode,
6762 (void *)&cmd_setfwd_retry_retry,
6767 static void cmd_set_fwd_retry_mode_init(void)
6770 static char token[128];
6771 static char help[256];
6772 cmdline_parse_token_string_t *token_struct;
6774 modes = list_pkt_forwarding_retry_modes();
6775 snprintf(help, sizeof(help), "set fwd %s retry: "
6776 "Set packet forwarding mode with retry", modes);
6777 cmd_set_fwd_retry_mode.help_str = help;
6779 /* string token separator is # */
6780 for (c = token; *modes != '\0'; modes++)
6785 token_struct = (cmdline_parse_token_string_t *)
6786 cmd_set_fwd_retry_mode.tokens[2];
6787 token_struct->string_data.str = token;
6790 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
6791 struct cmd_set_burst_tx_retry_result {
6792 cmdline_fixed_string_t set;
6793 cmdline_fixed_string_t burst;
6794 cmdline_fixed_string_t tx;
6795 cmdline_fixed_string_t delay;
6797 cmdline_fixed_string_t retry;
6801 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
6802 __rte_unused struct cmdline *cl,
6803 __rte_unused void *data)
6805 struct cmd_set_burst_tx_retry_result *res = parsed_result;
6807 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
6808 && !strcmp(res->tx, "tx")) {
6809 if (!strcmp(res->delay, "delay"))
6810 burst_tx_delay_time = res->time;
6811 if (!strcmp(res->retry, "retry"))
6812 burst_tx_retry_num = res->retry_num;
6817 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
6818 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
6819 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
6820 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
6822 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
6823 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
6824 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
6825 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
6826 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
6827 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
6828 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
6829 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
6830 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
6831 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
6833 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
6834 .f = cmd_set_burst_tx_retry_parsed,
6835 .help_str = "set burst tx delay <delay_usec> retry <num_retry>",
6837 (void *)&cmd_set_burst_tx_retry_set,
6838 (void *)&cmd_set_burst_tx_retry_burst,
6839 (void *)&cmd_set_burst_tx_retry_tx,
6840 (void *)&cmd_set_burst_tx_retry_delay,
6841 (void *)&cmd_set_burst_tx_retry_time,
6842 (void *)&cmd_set_burst_tx_retry_retry,
6843 (void *)&cmd_set_burst_tx_retry_retry_num,
6848 /* *** SET PROMISC MODE *** */
6849 struct cmd_set_promisc_mode_result {
6850 cmdline_fixed_string_t set;
6851 cmdline_fixed_string_t promisc;
6852 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6853 uint16_t port_num; /* valid if "allports" argument == 0 */
6854 cmdline_fixed_string_t mode;
6857 static void cmd_set_promisc_mode_parsed(void *parsed_result,
6858 __rte_unused struct cmdline *cl,
6861 struct cmd_set_promisc_mode_result *res = parsed_result;
6865 if (!strcmp(res->mode, "on"))
6872 RTE_ETH_FOREACH_DEV(i)
6873 eth_set_promisc_mode(i, enable);
6875 eth_set_promisc_mode(res->port_num, enable);
6879 cmdline_parse_token_string_t cmd_setpromisc_set =
6880 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
6881 cmdline_parse_token_string_t cmd_setpromisc_promisc =
6882 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
6884 cmdline_parse_token_string_t cmd_setpromisc_portall =
6885 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
6887 cmdline_parse_token_num_t cmd_setpromisc_portnum =
6888 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
6890 cmdline_parse_token_string_t cmd_setpromisc_mode =
6891 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
6894 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
6895 .f = cmd_set_promisc_mode_parsed,
6897 .help_str = "set promisc all on|off: Set promisc mode for all ports",
6899 (void *)&cmd_setpromisc_set,
6900 (void *)&cmd_setpromisc_promisc,
6901 (void *)&cmd_setpromisc_portall,
6902 (void *)&cmd_setpromisc_mode,
6907 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
6908 .f = cmd_set_promisc_mode_parsed,
6910 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
6912 (void *)&cmd_setpromisc_set,
6913 (void *)&cmd_setpromisc_promisc,
6914 (void *)&cmd_setpromisc_portnum,
6915 (void *)&cmd_setpromisc_mode,
6920 /* *** SET ALLMULTI MODE *** */
6921 struct cmd_set_allmulti_mode_result {
6922 cmdline_fixed_string_t set;
6923 cmdline_fixed_string_t allmulti;
6924 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6925 uint16_t port_num; /* valid if "allports" argument == 0 */
6926 cmdline_fixed_string_t mode;
6929 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
6930 __rte_unused struct cmdline *cl,
6933 struct cmd_set_allmulti_mode_result *res = parsed_result;
6937 if (!strcmp(res->mode, "on"))
6944 RTE_ETH_FOREACH_DEV(i) {
6945 eth_set_allmulticast_mode(i, enable);
6949 eth_set_allmulticast_mode(res->port_num, enable);
6953 cmdline_parse_token_string_t cmd_setallmulti_set =
6954 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
6955 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
6956 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
6958 cmdline_parse_token_string_t cmd_setallmulti_portall =
6959 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
6961 cmdline_parse_token_num_t cmd_setallmulti_portnum =
6962 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
6964 cmdline_parse_token_string_t cmd_setallmulti_mode =
6965 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
6968 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
6969 .f = cmd_set_allmulti_mode_parsed,
6971 .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
6973 (void *)&cmd_setallmulti_set,
6974 (void *)&cmd_setallmulti_allmulti,
6975 (void *)&cmd_setallmulti_portall,
6976 (void *)&cmd_setallmulti_mode,
6981 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
6982 .f = cmd_set_allmulti_mode_parsed,
6984 .help_str = "set allmulti <port_id> on|off: "
6985 "Set allmulti mode on port_id",
6987 (void *)&cmd_setallmulti_set,
6988 (void *)&cmd_setallmulti_allmulti,
6989 (void *)&cmd_setallmulti_portnum,
6990 (void *)&cmd_setallmulti_mode,
6995 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
6996 struct cmd_link_flow_ctrl_set_result {
6997 cmdline_fixed_string_t set;
6998 cmdline_fixed_string_t flow_ctrl;
6999 cmdline_fixed_string_t rx;
7000 cmdline_fixed_string_t rx_lfc_mode;
7001 cmdline_fixed_string_t tx;
7002 cmdline_fixed_string_t tx_lfc_mode;
7003 cmdline_fixed_string_t mac_ctrl_frame_fwd;
7004 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
7005 cmdline_fixed_string_t autoneg_str;
7006 cmdline_fixed_string_t autoneg;
7007 cmdline_fixed_string_t hw_str;
7008 uint32_t high_water;
7009 cmdline_fixed_string_t lw_str;
7011 cmdline_fixed_string_t pt_str;
7012 uint16_t pause_time;
7013 cmdline_fixed_string_t xon_str;
7018 cmdline_parse_token_string_t cmd_lfc_set_set =
7019 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7021 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
7022 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7023 flow_ctrl, "flow_ctrl");
7024 cmdline_parse_token_string_t cmd_lfc_set_rx =
7025 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7027 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
7028 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7029 rx_lfc_mode, "on#off");
7030 cmdline_parse_token_string_t cmd_lfc_set_tx =
7031 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7033 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
7034 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7035 tx_lfc_mode, "on#off");
7036 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
7037 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7038 hw_str, "high_water");
7039 cmdline_parse_token_num_t cmd_lfc_set_high_water =
7040 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7041 high_water, UINT32);
7042 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
7043 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7044 lw_str, "low_water");
7045 cmdline_parse_token_num_t cmd_lfc_set_low_water =
7046 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7048 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
7049 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7050 pt_str, "pause_time");
7051 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
7052 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7053 pause_time, UINT16);
7054 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
7055 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7056 xon_str, "send_xon");
7057 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
7058 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7060 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
7061 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7062 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
7063 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
7064 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7065 mac_ctrl_frame_fwd_mode, "on#off");
7066 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
7067 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7068 autoneg_str, "autoneg");
7069 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
7070 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7072 cmdline_parse_token_num_t cmd_lfc_set_portid =
7073 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7076 /* forward declaration */
7078 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
7081 cmdline_parse_inst_t cmd_link_flow_control_set = {
7082 .f = cmd_link_flow_ctrl_set_parsed,
7084 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
7085 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
7086 "autoneg on|off <port_id>: Configure the Ethernet flow control",
7088 (void *)&cmd_lfc_set_set,
7089 (void *)&cmd_lfc_set_flow_ctrl,
7090 (void *)&cmd_lfc_set_rx,
7091 (void *)&cmd_lfc_set_rx_mode,
7092 (void *)&cmd_lfc_set_tx,
7093 (void *)&cmd_lfc_set_tx_mode,
7094 (void *)&cmd_lfc_set_high_water,
7095 (void *)&cmd_lfc_set_low_water,
7096 (void *)&cmd_lfc_set_pause_time,
7097 (void *)&cmd_lfc_set_send_xon,
7098 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
7099 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
7100 (void *)&cmd_lfc_set_autoneg_str,
7101 (void *)&cmd_lfc_set_autoneg,
7102 (void *)&cmd_lfc_set_portid,
7107 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
7108 .f = cmd_link_flow_ctrl_set_parsed,
7109 .data = (void *)&cmd_link_flow_control_set_rx,
7110 .help_str = "set flow_ctrl rx on|off <port_id>: "
7111 "Change rx flow control parameter",
7113 (void *)&cmd_lfc_set_set,
7114 (void *)&cmd_lfc_set_flow_ctrl,
7115 (void *)&cmd_lfc_set_rx,
7116 (void *)&cmd_lfc_set_rx_mode,
7117 (void *)&cmd_lfc_set_portid,
7122 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
7123 .f = cmd_link_flow_ctrl_set_parsed,
7124 .data = (void *)&cmd_link_flow_control_set_tx,
7125 .help_str = "set flow_ctrl tx on|off <port_id>: "
7126 "Change tx flow control parameter",
7128 (void *)&cmd_lfc_set_set,
7129 (void *)&cmd_lfc_set_flow_ctrl,
7130 (void *)&cmd_lfc_set_tx,
7131 (void *)&cmd_lfc_set_tx_mode,
7132 (void *)&cmd_lfc_set_portid,
7137 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
7138 .f = cmd_link_flow_ctrl_set_parsed,
7139 .data = (void *)&cmd_link_flow_control_set_hw,
7140 .help_str = "set flow_ctrl high_water <value> <port_id>: "
7141 "Change high water flow control parameter",
7143 (void *)&cmd_lfc_set_set,
7144 (void *)&cmd_lfc_set_flow_ctrl,
7145 (void *)&cmd_lfc_set_high_water_str,
7146 (void *)&cmd_lfc_set_high_water,
7147 (void *)&cmd_lfc_set_portid,
7152 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
7153 .f = cmd_link_flow_ctrl_set_parsed,
7154 .data = (void *)&cmd_link_flow_control_set_lw,
7155 .help_str = "set flow_ctrl low_water <value> <port_id>: "
7156 "Change low water flow control parameter",
7158 (void *)&cmd_lfc_set_set,
7159 (void *)&cmd_lfc_set_flow_ctrl,
7160 (void *)&cmd_lfc_set_low_water_str,
7161 (void *)&cmd_lfc_set_low_water,
7162 (void *)&cmd_lfc_set_portid,
7167 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
7168 .f = cmd_link_flow_ctrl_set_parsed,
7169 .data = (void *)&cmd_link_flow_control_set_pt,
7170 .help_str = "set flow_ctrl pause_time <value> <port_id>: "
7171 "Change pause time flow control parameter",
7173 (void *)&cmd_lfc_set_set,
7174 (void *)&cmd_lfc_set_flow_ctrl,
7175 (void *)&cmd_lfc_set_pause_time_str,
7176 (void *)&cmd_lfc_set_pause_time,
7177 (void *)&cmd_lfc_set_portid,
7182 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
7183 .f = cmd_link_flow_ctrl_set_parsed,
7184 .data = (void *)&cmd_link_flow_control_set_xon,
7185 .help_str = "set flow_ctrl send_xon <value> <port_id>: "
7186 "Change send_xon flow control parameter",
7188 (void *)&cmd_lfc_set_set,
7189 (void *)&cmd_lfc_set_flow_ctrl,
7190 (void *)&cmd_lfc_set_send_xon_str,
7191 (void *)&cmd_lfc_set_send_xon,
7192 (void *)&cmd_lfc_set_portid,
7197 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
7198 .f = cmd_link_flow_ctrl_set_parsed,
7199 .data = (void *)&cmd_link_flow_control_set_macfwd,
7200 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
7201 "Change mac ctrl fwd flow control parameter",
7203 (void *)&cmd_lfc_set_set,
7204 (void *)&cmd_lfc_set_flow_ctrl,
7205 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
7206 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
7207 (void *)&cmd_lfc_set_portid,
7212 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
7213 .f = cmd_link_flow_ctrl_set_parsed,
7214 .data = (void *)&cmd_link_flow_control_set_autoneg,
7215 .help_str = "set flow_ctrl autoneg on|off <port_id>: "
7216 "Change autoneg flow control parameter",
7218 (void *)&cmd_lfc_set_set,
7219 (void *)&cmd_lfc_set_flow_ctrl,
7220 (void *)&cmd_lfc_set_autoneg_str,
7221 (void *)&cmd_lfc_set_autoneg,
7222 (void *)&cmd_lfc_set_portid,
7228 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
7229 __rte_unused struct cmdline *cl,
7232 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
7233 cmdline_parse_inst_t *cmd = data;
7234 struct rte_eth_fc_conf fc_conf;
7240 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
7241 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
7242 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
7243 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
7245 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
7246 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
7249 /* Partial command line, retrieve current configuration */
7251 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
7253 printf("cannot get current flow ctrl parameters, return"
7254 "code = %d\n", ret);
7258 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
7259 (fc_conf.mode == RTE_FC_FULL))
7261 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
7262 (fc_conf.mode == RTE_FC_FULL))
7266 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
7267 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
7269 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
7270 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
7272 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
7274 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
7275 fc_conf.high_water = res->high_water;
7277 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
7278 fc_conf.low_water = res->low_water;
7280 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
7281 fc_conf.pause_time = res->pause_time;
7283 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
7284 fc_conf.send_xon = res->send_xon;
7286 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
7287 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
7288 fc_conf.mac_ctrl_frame_fwd = 1;
7290 fc_conf.mac_ctrl_frame_fwd = 0;
7293 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
7294 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
7296 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
7298 printf("bad flow contrl parameter, return code = %d \n", ret);
7301 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
7302 struct cmd_priority_flow_ctrl_set_result {
7303 cmdline_fixed_string_t set;
7304 cmdline_fixed_string_t pfc_ctrl;
7305 cmdline_fixed_string_t rx;
7306 cmdline_fixed_string_t rx_pfc_mode;
7307 cmdline_fixed_string_t tx;
7308 cmdline_fixed_string_t tx_pfc_mode;
7309 uint32_t high_water;
7311 uint16_t pause_time;
7317 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
7318 __rte_unused struct cmdline *cl,
7319 __rte_unused void *data)
7321 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
7322 struct rte_eth_pfc_conf pfc_conf;
7323 int rx_fc_enable, tx_fc_enable;
7327 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
7328 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
7329 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
7330 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
7332 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
7333 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
7336 memset(&pfc_conf, 0, sizeof(struct rte_eth_pfc_conf));
7337 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
7338 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
7339 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
7340 pfc_conf.fc.high_water = res->high_water;
7341 pfc_conf.fc.low_water = res->low_water;
7342 pfc_conf.fc.pause_time = res->pause_time;
7343 pfc_conf.priority = res->priority;
7345 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
7347 printf("bad priority flow contrl parameter, return code = %d \n", ret);
7350 cmdline_parse_token_string_t cmd_pfc_set_set =
7351 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7353 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
7354 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7355 pfc_ctrl, "pfc_ctrl");
7356 cmdline_parse_token_string_t cmd_pfc_set_rx =
7357 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7359 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
7360 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7361 rx_pfc_mode, "on#off");
7362 cmdline_parse_token_string_t cmd_pfc_set_tx =
7363 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7365 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
7366 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7367 tx_pfc_mode, "on#off");
7368 cmdline_parse_token_num_t cmd_pfc_set_high_water =
7369 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7370 high_water, UINT32);
7371 cmdline_parse_token_num_t cmd_pfc_set_low_water =
7372 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7374 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
7375 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7376 pause_time, UINT16);
7377 cmdline_parse_token_num_t cmd_pfc_set_priority =
7378 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7380 cmdline_parse_token_num_t cmd_pfc_set_portid =
7381 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7384 cmdline_parse_inst_t cmd_priority_flow_control_set = {
7385 .f = cmd_priority_flow_ctrl_set_parsed,
7387 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
7388 "<pause_time> <priority> <port_id>: "
7389 "Configure the Ethernet priority flow control",
7391 (void *)&cmd_pfc_set_set,
7392 (void *)&cmd_pfc_set_flow_ctrl,
7393 (void *)&cmd_pfc_set_rx,
7394 (void *)&cmd_pfc_set_rx_mode,
7395 (void *)&cmd_pfc_set_tx,
7396 (void *)&cmd_pfc_set_tx_mode,
7397 (void *)&cmd_pfc_set_high_water,
7398 (void *)&cmd_pfc_set_low_water,
7399 (void *)&cmd_pfc_set_pause_time,
7400 (void *)&cmd_pfc_set_priority,
7401 (void *)&cmd_pfc_set_portid,
7406 /* *** RESET CONFIGURATION *** */
7407 struct cmd_reset_result {
7408 cmdline_fixed_string_t reset;
7409 cmdline_fixed_string_t def;
7412 static void cmd_reset_parsed(__rte_unused void *parsed_result,
7414 __rte_unused void *data)
7416 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
7417 set_def_fwd_config();
7420 cmdline_parse_token_string_t cmd_reset_set =
7421 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
7422 cmdline_parse_token_string_t cmd_reset_def =
7423 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
7426 cmdline_parse_inst_t cmd_reset = {
7427 .f = cmd_reset_parsed,
7429 .help_str = "set default: Reset default forwarding configuration",
7431 (void *)&cmd_reset_set,
7432 (void *)&cmd_reset_def,
7437 /* *** START FORWARDING *** */
7438 struct cmd_start_result {
7439 cmdline_fixed_string_t start;
7442 cmdline_parse_token_string_t cmd_start_start =
7443 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
7445 static void cmd_start_parsed(__rte_unused void *parsed_result,
7446 __rte_unused struct cmdline *cl,
7447 __rte_unused void *data)
7449 start_packet_forwarding(0);
7452 cmdline_parse_inst_t cmd_start = {
7453 .f = cmd_start_parsed,
7455 .help_str = "start: Start packet forwarding",
7457 (void *)&cmd_start_start,
7462 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
7463 struct cmd_start_tx_first_result {
7464 cmdline_fixed_string_t start;
7465 cmdline_fixed_string_t tx_first;
7469 cmd_start_tx_first_parsed(__rte_unused void *parsed_result,
7470 __rte_unused struct cmdline *cl,
7471 __rte_unused void *data)
7473 start_packet_forwarding(1);
7476 cmdline_parse_token_string_t cmd_start_tx_first_start =
7477 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
7479 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
7480 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
7481 tx_first, "tx_first");
7483 cmdline_parse_inst_t cmd_start_tx_first = {
7484 .f = cmd_start_tx_first_parsed,
7486 .help_str = "start tx_first: Start packet forwarding, "
7487 "after sending 1 burst of packets",
7489 (void *)&cmd_start_tx_first_start,
7490 (void *)&cmd_start_tx_first_tx_first,
7495 /* *** START FORWARDING WITH N TX BURST FIRST *** */
7496 struct cmd_start_tx_first_n_result {
7497 cmdline_fixed_string_t start;
7498 cmdline_fixed_string_t tx_first;
7503 cmd_start_tx_first_n_parsed(void *parsed_result,
7504 __rte_unused struct cmdline *cl,
7505 __rte_unused void *data)
7507 struct cmd_start_tx_first_n_result *res = parsed_result;
7509 start_packet_forwarding(res->tx_num);
7512 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
7513 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7515 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
7516 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7517 tx_first, "tx_first");
7518 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
7519 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
7522 cmdline_parse_inst_t cmd_start_tx_first_n = {
7523 .f = cmd_start_tx_first_n_parsed,
7525 .help_str = "start tx_first <num>: "
7526 "packet forwarding, after sending <num> bursts of packets",
7528 (void *)&cmd_start_tx_first_n_start,
7529 (void *)&cmd_start_tx_first_n_tx_first,
7530 (void *)&cmd_start_tx_first_n_tx_num,
7535 /* *** SET LINK UP *** */
7536 struct cmd_set_link_up_result {
7537 cmdline_fixed_string_t set;
7538 cmdline_fixed_string_t link_up;
7539 cmdline_fixed_string_t port;
7543 cmdline_parse_token_string_t cmd_set_link_up_set =
7544 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
7545 cmdline_parse_token_string_t cmd_set_link_up_link_up =
7546 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
7548 cmdline_parse_token_string_t cmd_set_link_up_port =
7549 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
7550 cmdline_parse_token_num_t cmd_set_link_up_port_id =
7551 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT16);
7553 static void cmd_set_link_up_parsed(__rte_unused void *parsed_result,
7554 __rte_unused struct cmdline *cl,
7555 __rte_unused void *data)
7557 struct cmd_set_link_up_result *res = parsed_result;
7558 dev_set_link_up(res->port_id);
7561 cmdline_parse_inst_t cmd_set_link_up = {
7562 .f = cmd_set_link_up_parsed,
7564 .help_str = "set link-up port <port id>",
7566 (void *)&cmd_set_link_up_set,
7567 (void *)&cmd_set_link_up_link_up,
7568 (void *)&cmd_set_link_up_port,
7569 (void *)&cmd_set_link_up_port_id,
7574 /* *** SET LINK DOWN *** */
7575 struct cmd_set_link_down_result {
7576 cmdline_fixed_string_t set;
7577 cmdline_fixed_string_t link_down;
7578 cmdline_fixed_string_t port;
7582 cmdline_parse_token_string_t cmd_set_link_down_set =
7583 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
7584 cmdline_parse_token_string_t cmd_set_link_down_link_down =
7585 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
7587 cmdline_parse_token_string_t cmd_set_link_down_port =
7588 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
7589 cmdline_parse_token_num_t cmd_set_link_down_port_id =
7590 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT16);
7592 static void cmd_set_link_down_parsed(
7593 __rte_unused void *parsed_result,
7594 __rte_unused struct cmdline *cl,
7595 __rte_unused void *data)
7597 struct cmd_set_link_down_result *res = parsed_result;
7598 dev_set_link_down(res->port_id);
7601 cmdline_parse_inst_t cmd_set_link_down = {
7602 .f = cmd_set_link_down_parsed,
7604 .help_str = "set link-down port <port id>",
7606 (void *)&cmd_set_link_down_set,
7607 (void *)&cmd_set_link_down_link_down,
7608 (void *)&cmd_set_link_down_port,
7609 (void *)&cmd_set_link_down_port_id,
7614 /* *** SHOW CFG *** */
7615 struct cmd_showcfg_result {
7616 cmdline_fixed_string_t show;
7617 cmdline_fixed_string_t cfg;
7618 cmdline_fixed_string_t what;
7621 static void cmd_showcfg_parsed(void *parsed_result,
7622 __rte_unused struct cmdline *cl,
7623 __rte_unused void *data)
7625 struct cmd_showcfg_result *res = parsed_result;
7626 if (!strcmp(res->what, "rxtx"))
7627 rxtx_config_display();
7628 else if (!strcmp(res->what, "cores"))
7629 fwd_lcores_config_display();
7630 else if (!strcmp(res->what, "fwd"))
7631 pkt_fwd_config_display(&cur_fwd_config);
7632 else if (!strcmp(res->what, "rxoffs"))
7633 show_rx_pkt_offsets();
7634 else if (!strcmp(res->what, "rxpkts"))
7635 show_rx_pkt_segments();
7636 else if (!strcmp(res->what, "txpkts"))
7637 show_tx_pkt_segments();
7638 else if (!strcmp(res->what, "txtimes"))
7639 show_tx_pkt_times();
7642 cmdline_parse_token_string_t cmd_showcfg_show =
7643 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
7644 cmdline_parse_token_string_t cmd_showcfg_port =
7645 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
7646 cmdline_parse_token_string_t cmd_showcfg_what =
7647 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
7648 "rxtx#cores#fwd#rxoffs#rxpkts#txpkts#txtimes");
7650 cmdline_parse_inst_t cmd_showcfg = {
7651 .f = cmd_showcfg_parsed,
7653 .help_str = "show config rxtx|cores|fwd|rxoffs|rxpkts|txpkts|txtimes",
7655 (void *)&cmd_showcfg_show,
7656 (void *)&cmd_showcfg_port,
7657 (void *)&cmd_showcfg_what,
7662 /* *** SHOW ALL PORT INFO *** */
7663 struct cmd_showportall_result {
7664 cmdline_fixed_string_t show;
7665 cmdline_fixed_string_t port;
7666 cmdline_fixed_string_t what;
7667 cmdline_fixed_string_t all;
7670 static void cmd_showportall_parsed(void *parsed_result,
7671 __rte_unused struct cmdline *cl,
7672 __rte_unused void *data)
7676 struct cmd_showportall_result *res = parsed_result;
7677 if (!strcmp(res->show, "clear")) {
7678 if (!strcmp(res->what, "stats"))
7679 RTE_ETH_FOREACH_DEV(i)
7681 else if (!strcmp(res->what, "xstats"))
7682 RTE_ETH_FOREACH_DEV(i)
7683 nic_xstats_clear(i);
7684 } else if (!strcmp(res->what, "info"))
7685 RTE_ETH_FOREACH_DEV(i)
7686 port_infos_display(i);
7687 else if (!strcmp(res->what, "summary")) {
7688 port_summary_header_display();
7689 RTE_ETH_FOREACH_DEV(i)
7690 port_summary_display(i);
7692 else if (!strcmp(res->what, "stats"))
7693 RTE_ETH_FOREACH_DEV(i)
7694 nic_stats_display(i);
7695 else if (!strcmp(res->what, "xstats"))
7696 RTE_ETH_FOREACH_DEV(i)
7697 nic_xstats_display(i);
7698 else if (!strcmp(res->what, "fdir"))
7699 RTE_ETH_FOREACH_DEV(i)
7701 else if (!strcmp(res->what, "stat_qmap"))
7702 RTE_ETH_FOREACH_DEV(i)
7703 nic_stats_mapping_display(i);
7704 else if (!strcmp(res->what, "dcb_tc"))
7705 RTE_ETH_FOREACH_DEV(i)
7706 port_dcb_info_display(i);
7707 else if (!strcmp(res->what, "cap"))
7708 RTE_ETH_FOREACH_DEV(i)
7709 port_offload_cap_display(i);
7712 cmdline_parse_token_string_t cmd_showportall_show =
7713 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
7715 cmdline_parse_token_string_t cmd_showportall_port =
7716 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
7717 cmdline_parse_token_string_t cmd_showportall_what =
7718 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
7719 "info#summary#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
7720 cmdline_parse_token_string_t cmd_showportall_all =
7721 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
7722 cmdline_parse_inst_t cmd_showportall = {
7723 .f = cmd_showportall_parsed,
7725 .help_str = "show|clear port "
7726 "info|summary|stats|xstats|fdir|stat_qmap|dcb_tc|cap all",
7728 (void *)&cmd_showportall_show,
7729 (void *)&cmd_showportall_port,
7730 (void *)&cmd_showportall_what,
7731 (void *)&cmd_showportall_all,
7736 /* *** SHOW PORT INFO *** */
7737 struct cmd_showport_result {
7738 cmdline_fixed_string_t show;
7739 cmdline_fixed_string_t port;
7740 cmdline_fixed_string_t what;
7744 static void cmd_showport_parsed(void *parsed_result,
7745 __rte_unused struct cmdline *cl,
7746 __rte_unused void *data)
7748 struct cmd_showport_result *res = parsed_result;
7749 if (!strcmp(res->show, "clear")) {
7750 if (!strcmp(res->what, "stats"))
7751 nic_stats_clear(res->portnum);
7752 else if (!strcmp(res->what, "xstats"))
7753 nic_xstats_clear(res->portnum);
7754 } else if (!strcmp(res->what, "info"))
7755 port_infos_display(res->portnum);
7756 else if (!strcmp(res->what, "summary")) {
7757 port_summary_header_display();
7758 port_summary_display(res->portnum);
7760 else if (!strcmp(res->what, "stats"))
7761 nic_stats_display(res->portnum);
7762 else if (!strcmp(res->what, "xstats"))
7763 nic_xstats_display(res->portnum);
7764 else if (!strcmp(res->what, "fdir"))
7765 fdir_get_infos(res->portnum);
7766 else if (!strcmp(res->what, "stat_qmap"))
7767 nic_stats_mapping_display(res->portnum);
7768 else if (!strcmp(res->what, "dcb_tc"))
7769 port_dcb_info_display(res->portnum);
7770 else if (!strcmp(res->what, "cap"))
7771 port_offload_cap_display(res->portnum);
7774 cmdline_parse_token_string_t cmd_showport_show =
7775 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
7777 cmdline_parse_token_string_t cmd_showport_port =
7778 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
7779 cmdline_parse_token_string_t cmd_showport_what =
7780 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
7781 "info#summary#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
7782 cmdline_parse_token_num_t cmd_showport_portnum =
7783 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT16);
7785 cmdline_parse_inst_t cmd_showport = {
7786 .f = cmd_showport_parsed,
7788 .help_str = "show|clear port "
7789 "info|summary|stats|xstats|fdir|stat_qmap|dcb_tc|cap "
7792 (void *)&cmd_showport_show,
7793 (void *)&cmd_showport_port,
7794 (void *)&cmd_showport_what,
7795 (void *)&cmd_showport_portnum,
7800 /* *** SHOW DEVICE INFO *** */
7801 struct cmd_showdevice_result {
7802 cmdline_fixed_string_t show;
7803 cmdline_fixed_string_t device;
7804 cmdline_fixed_string_t what;
7805 cmdline_fixed_string_t identifier;
7808 static void cmd_showdevice_parsed(void *parsed_result,
7809 __rte_unused struct cmdline *cl,
7810 __rte_unused void *data)
7812 struct cmd_showdevice_result *res = parsed_result;
7813 if (!strcmp(res->what, "info")) {
7814 if (!strcmp(res->identifier, "all"))
7815 device_infos_display(NULL);
7817 device_infos_display(res->identifier);
7821 cmdline_parse_token_string_t cmd_showdevice_show =
7822 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, show,
7824 cmdline_parse_token_string_t cmd_showdevice_device =
7825 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, device, "device");
7826 cmdline_parse_token_string_t cmd_showdevice_what =
7827 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, what,
7829 cmdline_parse_token_string_t cmd_showdevice_identifier =
7830 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result,
7833 cmdline_parse_inst_t cmd_showdevice = {
7834 .f = cmd_showdevice_parsed,
7836 .help_str = "show device info <identifier>|all",
7838 (void *)&cmd_showdevice_show,
7839 (void *)&cmd_showdevice_device,
7840 (void *)&cmd_showdevice_what,
7841 (void *)&cmd_showdevice_identifier,
7846 /* *** SHOW MODULE EEPROM/EEPROM port INFO *** */
7847 struct cmd_showeeprom_result {
7848 cmdline_fixed_string_t show;
7849 cmdline_fixed_string_t port;
7851 cmdline_fixed_string_t type;
7854 static void cmd_showeeprom_parsed(void *parsed_result,
7855 __rte_unused struct cmdline *cl,
7856 __rte_unused void *data)
7858 struct cmd_showeeprom_result *res = parsed_result;
7860 if (!strcmp(res->type, "eeprom"))
7861 port_eeprom_display(res->portnum);
7862 else if (!strcmp(res->type, "module_eeprom"))
7863 port_module_eeprom_display(res->portnum);
7865 printf("Unknown argument\n");
7868 cmdline_parse_token_string_t cmd_showeeprom_show =
7869 TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, show, "show");
7870 cmdline_parse_token_string_t cmd_showeeprom_port =
7871 TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, port, "port");
7872 cmdline_parse_token_num_t cmd_showeeprom_portnum =
7873 TOKEN_NUM_INITIALIZER(struct cmd_showeeprom_result, portnum, UINT16);
7874 cmdline_parse_token_string_t cmd_showeeprom_type =
7875 TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, type, "module_eeprom#eeprom");
7877 cmdline_parse_inst_t cmd_showeeprom = {
7878 .f = cmd_showeeprom_parsed,
7880 .help_str = "show port <port_id> module_eeprom|eeprom",
7882 (void *)&cmd_showeeprom_show,
7883 (void *)&cmd_showeeprom_port,
7884 (void *)&cmd_showeeprom_portnum,
7885 (void *)&cmd_showeeprom_type,
7890 /* *** SHOW QUEUE INFO *** */
7891 struct cmd_showqueue_result {
7892 cmdline_fixed_string_t show;
7893 cmdline_fixed_string_t type;
7894 cmdline_fixed_string_t what;
7900 cmd_showqueue_parsed(void *parsed_result,
7901 __rte_unused struct cmdline *cl,
7902 __rte_unused void *data)
7904 struct cmd_showqueue_result *res = parsed_result;
7906 if (!strcmp(res->type, "rxq"))
7907 rx_queue_infos_display(res->portnum, res->queuenum);
7908 else if (!strcmp(res->type, "txq"))
7909 tx_queue_infos_display(res->portnum, res->queuenum);
7912 cmdline_parse_token_string_t cmd_showqueue_show =
7913 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
7914 cmdline_parse_token_string_t cmd_showqueue_type =
7915 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
7916 cmdline_parse_token_string_t cmd_showqueue_what =
7917 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
7918 cmdline_parse_token_num_t cmd_showqueue_portnum =
7919 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, UINT16);
7920 cmdline_parse_token_num_t cmd_showqueue_queuenum =
7921 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, UINT16);
7923 cmdline_parse_inst_t cmd_showqueue = {
7924 .f = cmd_showqueue_parsed,
7926 .help_str = "show rxq|txq info <port_id> <queue_id>",
7928 (void *)&cmd_showqueue_show,
7929 (void *)&cmd_showqueue_type,
7930 (void *)&cmd_showqueue_what,
7931 (void *)&cmd_showqueue_portnum,
7932 (void *)&cmd_showqueue_queuenum,
7937 /* show/clear fwd engine statistics */
7939 cmdline_fixed_string_t action;
7940 cmdline_fixed_string_t fwd;
7941 cmdline_fixed_string_t stats;
7942 cmdline_fixed_string_t all;
7945 cmdline_parse_token_string_t cmd_fwd_action =
7946 TOKEN_STRING_INITIALIZER(struct fwd_result, action, "show#clear");
7947 cmdline_parse_token_string_t cmd_fwd_fwd =
7948 TOKEN_STRING_INITIALIZER(struct fwd_result, fwd, "fwd");
7949 cmdline_parse_token_string_t cmd_fwd_stats =
7950 TOKEN_STRING_INITIALIZER(struct fwd_result, stats, "stats");
7951 cmdline_parse_token_string_t cmd_fwd_all =
7952 TOKEN_STRING_INITIALIZER(struct fwd_result, all, "all");
7955 cmd_showfwdall_parsed(void *parsed_result,
7956 __rte_unused struct cmdline *cl,
7957 __rte_unused void *data)
7959 struct fwd_result *res = parsed_result;
7961 if (!strcmp(res->action, "show"))
7962 fwd_stats_display();
7967 static cmdline_parse_inst_t cmd_showfwdall = {
7968 .f = cmd_showfwdall_parsed,
7970 .help_str = "show|clear fwd stats all",
7972 (void *)&cmd_fwd_action,
7973 (void *)&cmd_fwd_fwd,
7974 (void *)&cmd_fwd_stats,
7975 (void *)&cmd_fwd_all,
7980 /* *** READ PORT REGISTER *** */
7981 struct cmd_read_reg_result {
7982 cmdline_fixed_string_t read;
7983 cmdline_fixed_string_t reg;
7989 cmd_read_reg_parsed(void *parsed_result,
7990 __rte_unused struct cmdline *cl,
7991 __rte_unused void *data)
7993 struct cmd_read_reg_result *res = parsed_result;
7994 port_reg_display(res->port_id, res->reg_off);
7997 cmdline_parse_token_string_t cmd_read_reg_read =
7998 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
7999 cmdline_parse_token_string_t cmd_read_reg_reg =
8000 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
8001 cmdline_parse_token_num_t cmd_read_reg_port_id =
8002 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT16);
8003 cmdline_parse_token_num_t cmd_read_reg_reg_off =
8004 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
8006 cmdline_parse_inst_t cmd_read_reg = {
8007 .f = cmd_read_reg_parsed,
8009 .help_str = "read reg <port_id> <reg_off>",
8011 (void *)&cmd_read_reg_read,
8012 (void *)&cmd_read_reg_reg,
8013 (void *)&cmd_read_reg_port_id,
8014 (void *)&cmd_read_reg_reg_off,
8019 /* *** READ PORT REGISTER BIT FIELD *** */
8020 struct cmd_read_reg_bit_field_result {
8021 cmdline_fixed_string_t read;
8022 cmdline_fixed_string_t regfield;
8030 cmd_read_reg_bit_field_parsed(void *parsed_result,
8031 __rte_unused struct cmdline *cl,
8032 __rte_unused void *data)
8034 struct cmd_read_reg_bit_field_result *res = parsed_result;
8035 port_reg_bit_field_display(res->port_id, res->reg_off,
8036 res->bit1_pos, res->bit2_pos);
8039 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
8040 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
8042 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
8043 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
8044 regfield, "regfield");
8045 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
8046 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
8048 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
8049 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
8051 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
8052 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
8054 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
8055 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
8058 cmdline_parse_inst_t cmd_read_reg_bit_field = {
8059 .f = cmd_read_reg_bit_field_parsed,
8061 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
8062 "Read register bit field between bit_x and bit_y included",
8064 (void *)&cmd_read_reg_bit_field_read,
8065 (void *)&cmd_read_reg_bit_field_regfield,
8066 (void *)&cmd_read_reg_bit_field_port_id,
8067 (void *)&cmd_read_reg_bit_field_reg_off,
8068 (void *)&cmd_read_reg_bit_field_bit1_pos,
8069 (void *)&cmd_read_reg_bit_field_bit2_pos,
8074 /* *** READ PORT REGISTER BIT *** */
8075 struct cmd_read_reg_bit_result {
8076 cmdline_fixed_string_t read;
8077 cmdline_fixed_string_t regbit;
8084 cmd_read_reg_bit_parsed(void *parsed_result,
8085 __rte_unused struct cmdline *cl,
8086 __rte_unused void *data)
8088 struct cmd_read_reg_bit_result *res = parsed_result;
8089 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
8092 cmdline_parse_token_string_t cmd_read_reg_bit_read =
8093 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
8094 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
8095 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
8097 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
8098 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT16);
8099 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
8100 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
8101 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
8102 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
8104 cmdline_parse_inst_t cmd_read_reg_bit = {
8105 .f = cmd_read_reg_bit_parsed,
8107 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
8109 (void *)&cmd_read_reg_bit_read,
8110 (void *)&cmd_read_reg_bit_regbit,
8111 (void *)&cmd_read_reg_bit_port_id,
8112 (void *)&cmd_read_reg_bit_reg_off,
8113 (void *)&cmd_read_reg_bit_bit_pos,
8118 /* *** WRITE PORT REGISTER *** */
8119 struct cmd_write_reg_result {
8120 cmdline_fixed_string_t write;
8121 cmdline_fixed_string_t reg;
8128 cmd_write_reg_parsed(void *parsed_result,
8129 __rte_unused struct cmdline *cl,
8130 __rte_unused void *data)
8132 struct cmd_write_reg_result *res = parsed_result;
8133 port_reg_set(res->port_id, res->reg_off, res->value);
8136 cmdline_parse_token_string_t cmd_write_reg_write =
8137 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
8138 cmdline_parse_token_string_t cmd_write_reg_reg =
8139 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
8140 cmdline_parse_token_num_t cmd_write_reg_port_id =
8141 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT16);
8142 cmdline_parse_token_num_t cmd_write_reg_reg_off =
8143 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
8144 cmdline_parse_token_num_t cmd_write_reg_value =
8145 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
8147 cmdline_parse_inst_t cmd_write_reg = {
8148 .f = cmd_write_reg_parsed,
8150 .help_str = "write reg <port_id> <reg_off> <reg_value>",
8152 (void *)&cmd_write_reg_write,
8153 (void *)&cmd_write_reg_reg,
8154 (void *)&cmd_write_reg_port_id,
8155 (void *)&cmd_write_reg_reg_off,
8156 (void *)&cmd_write_reg_value,
8161 /* *** WRITE PORT REGISTER BIT FIELD *** */
8162 struct cmd_write_reg_bit_field_result {
8163 cmdline_fixed_string_t write;
8164 cmdline_fixed_string_t regfield;
8173 cmd_write_reg_bit_field_parsed(void *parsed_result,
8174 __rte_unused struct cmdline *cl,
8175 __rte_unused void *data)
8177 struct cmd_write_reg_bit_field_result *res = parsed_result;
8178 port_reg_bit_field_set(res->port_id, res->reg_off,
8179 res->bit1_pos, res->bit2_pos, res->value);
8182 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
8183 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
8185 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
8186 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
8187 regfield, "regfield");
8188 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
8189 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
8191 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
8192 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
8194 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
8195 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
8197 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
8198 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
8200 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
8201 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
8204 cmdline_parse_inst_t cmd_write_reg_bit_field = {
8205 .f = cmd_write_reg_bit_field_parsed,
8207 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
8209 "Set register bit field between bit_x and bit_y included",
8211 (void *)&cmd_write_reg_bit_field_write,
8212 (void *)&cmd_write_reg_bit_field_regfield,
8213 (void *)&cmd_write_reg_bit_field_port_id,
8214 (void *)&cmd_write_reg_bit_field_reg_off,
8215 (void *)&cmd_write_reg_bit_field_bit1_pos,
8216 (void *)&cmd_write_reg_bit_field_bit2_pos,
8217 (void *)&cmd_write_reg_bit_field_value,
8222 /* *** WRITE PORT REGISTER BIT *** */
8223 struct cmd_write_reg_bit_result {
8224 cmdline_fixed_string_t write;
8225 cmdline_fixed_string_t regbit;
8233 cmd_write_reg_bit_parsed(void *parsed_result,
8234 __rte_unused struct cmdline *cl,
8235 __rte_unused void *data)
8237 struct cmd_write_reg_bit_result *res = parsed_result;
8238 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
8241 cmdline_parse_token_string_t cmd_write_reg_bit_write =
8242 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
8244 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
8245 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
8247 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
8248 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT16);
8249 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
8250 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
8251 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
8252 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
8253 cmdline_parse_token_num_t cmd_write_reg_bit_value =
8254 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
8256 cmdline_parse_inst_t cmd_write_reg_bit = {
8257 .f = cmd_write_reg_bit_parsed,
8259 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
8262 (void *)&cmd_write_reg_bit_write,
8263 (void *)&cmd_write_reg_bit_regbit,
8264 (void *)&cmd_write_reg_bit_port_id,
8265 (void *)&cmd_write_reg_bit_reg_off,
8266 (void *)&cmd_write_reg_bit_bit_pos,
8267 (void *)&cmd_write_reg_bit_value,
8272 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
8273 struct cmd_read_rxd_txd_result {
8274 cmdline_fixed_string_t read;
8275 cmdline_fixed_string_t rxd_txd;
8282 cmd_read_rxd_txd_parsed(void *parsed_result,
8283 __rte_unused struct cmdline *cl,
8284 __rte_unused void *data)
8286 struct cmd_read_rxd_txd_result *res = parsed_result;
8288 if (!strcmp(res->rxd_txd, "rxd"))
8289 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
8290 else if (!strcmp(res->rxd_txd, "txd"))
8291 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
8294 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
8295 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
8296 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
8297 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
8299 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
8300 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT16);
8301 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
8302 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
8303 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
8304 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
8306 cmdline_parse_inst_t cmd_read_rxd_txd = {
8307 .f = cmd_read_rxd_txd_parsed,
8309 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
8311 (void *)&cmd_read_rxd_txd_read,
8312 (void *)&cmd_read_rxd_txd_rxd_txd,
8313 (void *)&cmd_read_rxd_txd_port_id,
8314 (void *)&cmd_read_rxd_txd_queue_id,
8315 (void *)&cmd_read_rxd_txd_desc_id,
8321 struct cmd_quit_result {
8322 cmdline_fixed_string_t quit;
8325 static void cmd_quit_parsed(__rte_unused void *parsed_result,
8327 __rte_unused void *data)
8332 cmdline_parse_token_string_t cmd_quit_quit =
8333 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
8335 cmdline_parse_inst_t cmd_quit = {
8336 .f = cmd_quit_parsed,
8338 .help_str = "quit: Exit application",
8340 (void *)&cmd_quit_quit,
8345 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
8346 struct cmd_mac_addr_result {
8347 cmdline_fixed_string_t mac_addr_cmd;
8348 cmdline_fixed_string_t what;
8350 struct rte_ether_addr address;
8353 static void cmd_mac_addr_parsed(void *parsed_result,
8354 __rte_unused struct cmdline *cl,
8355 __rte_unused void *data)
8357 struct cmd_mac_addr_result *res = parsed_result;
8360 if (strcmp(res->what, "add") == 0)
8361 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
8362 else if (strcmp(res->what, "set") == 0)
8363 ret = rte_eth_dev_default_mac_addr_set(res->port_num,
8366 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
8368 /* check the return value and print it if is < 0 */
8370 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
8374 cmdline_parse_token_string_t cmd_mac_addr_cmd =
8375 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
8377 cmdline_parse_token_string_t cmd_mac_addr_what =
8378 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
8380 cmdline_parse_token_num_t cmd_mac_addr_portnum =
8381 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num,
8383 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
8384 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
8386 cmdline_parse_inst_t cmd_mac_addr = {
8387 .f = cmd_mac_addr_parsed,
8389 .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
8390 "Add/Remove/Set MAC address on port_id",
8392 (void *)&cmd_mac_addr_cmd,
8393 (void *)&cmd_mac_addr_what,
8394 (void *)&cmd_mac_addr_portnum,
8395 (void *)&cmd_mac_addr_addr,
8400 /* *** SET THE PEER ADDRESS FOR CERTAIN PORT *** */
8401 struct cmd_eth_peer_result {
8402 cmdline_fixed_string_t set;
8403 cmdline_fixed_string_t eth_peer;
8405 cmdline_fixed_string_t peer_addr;
8408 static void cmd_set_eth_peer_parsed(void *parsed_result,
8409 __rte_unused struct cmdline *cl,
8410 __rte_unused void *data)
8412 struct cmd_eth_peer_result *res = parsed_result;
8414 if (test_done == 0) {
8415 printf("Please stop forwarding first\n");
8418 if (!strcmp(res->eth_peer, "eth-peer")) {
8419 set_fwd_eth_peer(res->port_id, res->peer_addr);
8423 cmdline_parse_token_string_t cmd_eth_peer_set =
8424 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, set, "set");
8425 cmdline_parse_token_string_t cmd_eth_peer =
8426 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, eth_peer, "eth-peer");
8427 cmdline_parse_token_num_t cmd_eth_peer_port_id =
8428 TOKEN_NUM_INITIALIZER(struct cmd_eth_peer_result, port_id, UINT16);
8429 cmdline_parse_token_string_t cmd_eth_peer_addr =
8430 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, peer_addr, NULL);
8432 cmdline_parse_inst_t cmd_set_fwd_eth_peer = {
8433 .f = cmd_set_eth_peer_parsed,
8435 .help_str = "set eth-peer <port_id> <peer_mac>",
8437 (void *)&cmd_eth_peer_set,
8438 (void *)&cmd_eth_peer,
8439 (void *)&cmd_eth_peer_port_id,
8440 (void *)&cmd_eth_peer_addr,
8445 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
8446 struct cmd_set_qmap_result {
8447 cmdline_fixed_string_t set;
8448 cmdline_fixed_string_t qmap;
8449 cmdline_fixed_string_t what;
8456 cmd_set_qmap_parsed(void *parsed_result,
8457 __rte_unused struct cmdline *cl,
8458 __rte_unused void *data)
8460 struct cmd_set_qmap_result *res = parsed_result;
8461 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
8463 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
8466 cmdline_parse_token_string_t cmd_setqmap_set =
8467 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8469 cmdline_parse_token_string_t cmd_setqmap_qmap =
8470 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8472 cmdline_parse_token_string_t cmd_setqmap_what =
8473 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8475 cmdline_parse_token_num_t cmd_setqmap_portid =
8476 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8478 cmdline_parse_token_num_t cmd_setqmap_queueid =
8479 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8481 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
8482 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8485 cmdline_parse_inst_t cmd_set_qmap = {
8486 .f = cmd_set_qmap_parsed,
8488 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
8489 "Set statistics mapping value on tx|rx queue_id of port_id",
8491 (void *)&cmd_setqmap_set,
8492 (void *)&cmd_setqmap_qmap,
8493 (void *)&cmd_setqmap_what,
8494 (void *)&cmd_setqmap_portid,
8495 (void *)&cmd_setqmap_queueid,
8496 (void *)&cmd_setqmap_mapvalue,
8501 /* *** SET OPTION TO HIDE ZERO VALUES FOR XSTATS DISPLAY *** */
8502 struct cmd_set_xstats_hide_zero_result {
8503 cmdline_fixed_string_t keyword;
8504 cmdline_fixed_string_t name;
8505 cmdline_fixed_string_t on_off;
8509 cmd_set_xstats_hide_zero_parsed(void *parsed_result,
8510 __rte_unused struct cmdline *cl,
8511 __rte_unused void *data)
8513 struct cmd_set_xstats_hide_zero_result *res;
8514 uint16_t on_off = 0;
8516 res = parsed_result;
8517 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8518 set_xstats_hide_zero(on_off);
8521 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_keyword =
8522 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8524 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_name =
8525 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8526 name, "xstats-hide-zero");
8527 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_on_off =
8528 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8531 cmdline_parse_inst_t cmd_set_xstats_hide_zero = {
8532 .f = cmd_set_xstats_hide_zero_parsed,
8534 .help_str = "set xstats-hide-zero on|off",
8536 (void *)&cmd_set_xstats_hide_zero_keyword,
8537 (void *)&cmd_set_xstats_hide_zero_name,
8538 (void *)&cmd_set_xstats_hide_zero_on_off,
8543 /* *** SET OPTION TO ENABLE MEASUREMENT OF CPU CYCLES *** */
8544 struct cmd_set_record_core_cycles_result {
8545 cmdline_fixed_string_t keyword;
8546 cmdline_fixed_string_t name;
8547 cmdline_fixed_string_t on_off;
8551 cmd_set_record_core_cycles_parsed(void *parsed_result,
8552 __rte_unused struct cmdline *cl,
8553 __rte_unused void *data)
8555 struct cmd_set_record_core_cycles_result *res;
8556 uint16_t on_off = 0;
8558 res = parsed_result;
8559 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8560 set_record_core_cycles(on_off);
8563 cmdline_parse_token_string_t cmd_set_record_core_cycles_keyword =
8564 TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
8566 cmdline_parse_token_string_t cmd_set_record_core_cycles_name =
8567 TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
8568 name, "record-core-cycles");
8569 cmdline_parse_token_string_t cmd_set_record_core_cycles_on_off =
8570 TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
8573 cmdline_parse_inst_t cmd_set_record_core_cycles = {
8574 .f = cmd_set_record_core_cycles_parsed,
8576 .help_str = "set record-core-cycles on|off",
8578 (void *)&cmd_set_record_core_cycles_keyword,
8579 (void *)&cmd_set_record_core_cycles_name,
8580 (void *)&cmd_set_record_core_cycles_on_off,
8585 /* *** SET OPTION TO ENABLE DISPLAY OF RX AND TX BURSTS *** */
8586 struct cmd_set_record_burst_stats_result {
8587 cmdline_fixed_string_t keyword;
8588 cmdline_fixed_string_t name;
8589 cmdline_fixed_string_t on_off;
8593 cmd_set_record_burst_stats_parsed(void *parsed_result,
8594 __rte_unused struct cmdline *cl,
8595 __rte_unused void *data)
8597 struct cmd_set_record_burst_stats_result *res;
8598 uint16_t on_off = 0;
8600 res = parsed_result;
8601 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8602 set_record_burst_stats(on_off);
8605 cmdline_parse_token_string_t cmd_set_record_burst_stats_keyword =
8606 TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
8608 cmdline_parse_token_string_t cmd_set_record_burst_stats_name =
8609 TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
8610 name, "record-burst-stats");
8611 cmdline_parse_token_string_t cmd_set_record_burst_stats_on_off =
8612 TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
8615 cmdline_parse_inst_t cmd_set_record_burst_stats = {
8616 .f = cmd_set_record_burst_stats_parsed,
8618 .help_str = "set record-burst-stats on|off",
8620 (void *)&cmd_set_record_burst_stats_keyword,
8621 (void *)&cmd_set_record_burst_stats_name,
8622 (void *)&cmd_set_record_burst_stats_on_off,
8627 /* *** CONFIGURE UNICAST HASH TABLE *** */
8628 struct cmd_set_uc_hash_table {
8629 cmdline_fixed_string_t set;
8630 cmdline_fixed_string_t port;
8632 cmdline_fixed_string_t what;
8633 struct rte_ether_addr address;
8634 cmdline_fixed_string_t mode;
8638 cmd_set_uc_hash_parsed(void *parsed_result,
8639 __rte_unused struct cmdline *cl,
8640 __rte_unused void *data)
8643 struct cmd_set_uc_hash_table *res = parsed_result;
8645 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8647 if (strcmp(res->what, "uta") == 0)
8648 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
8649 &res->address,(uint8_t)is_on);
8651 printf("bad unicast hash table parameter, return code = %d \n", ret);
8655 cmdline_parse_token_string_t cmd_set_uc_hash_set =
8656 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8658 cmdline_parse_token_string_t cmd_set_uc_hash_port =
8659 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8661 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
8662 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
8664 cmdline_parse_token_string_t cmd_set_uc_hash_what =
8665 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8667 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
8668 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
8670 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
8671 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8674 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
8675 .f = cmd_set_uc_hash_parsed,
8677 .help_str = "set port <port_id> uta <mac_addr> on|off)",
8679 (void *)&cmd_set_uc_hash_set,
8680 (void *)&cmd_set_uc_hash_port,
8681 (void *)&cmd_set_uc_hash_portid,
8682 (void *)&cmd_set_uc_hash_what,
8683 (void *)&cmd_set_uc_hash_mac,
8684 (void *)&cmd_set_uc_hash_mode,
8689 struct cmd_set_uc_all_hash_table {
8690 cmdline_fixed_string_t set;
8691 cmdline_fixed_string_t port;
8693 cmdline_fixed_string_t what;
8694 cmdline_fixed_string_t value;
8695 cmdline_fixed_string_t mode;
8699 cmd_set_uc_all_hash_parsed(void *parsed_result,
8700 __rte_unused struct cmdline *cl,
8701 __rte_unused void *data)
8704 struct cmd_set_uc_all_hash_table *res = parsed_result;
8706 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8708 if ((strcmp(res->what, "uta") == 0) &&
8709 (strcmp(res->value, "all") == 0))
8710 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
8712 printf("bad unicast hash table parameter,"
8713 "return code = %d \n", ret);
8716 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
8717 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8719 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
8720 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8722 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
8723 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
8725 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
8726 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8728 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
8729 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8731 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
8732 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8735 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
8736 .f = cmd_set_uc_all_hash_parsed,
8738 .help_str = "set port <port_id> uta all on|off",
8740 (void *)&cmd_set_uc_all_hash_set,
8741 (void *)&cmd_set_uc_all_hash_port,
8742 (void *)&cmd_set_uc_all_hash_portid,
8743 (void *)&cmd_set_uc_all_hash_what,
8744 (void *)&cmd_set_uc_all_hash_value,
8745 (void *)&cmd_set_uc_all_hash_mode,
8750 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
8751 struct cmd_set_vf_traffic {
8752 cmdline_fixed_string_t set;
8753 cmdline_fixed_string_t port;
8755 cmdline_fixed_string_t vf;
8757 cmdline_fixed_string_t what;
8758 cmdline_fixed_string_t mode;
8762 cmd_set_vf_traffic_parsed(void *parsed_result,
8763 __rte_unused struct cmdline *cl,
8764 __rte_unused void *data)
8766 struct cmd_set_vf_traffic *res = parsed_result;
8767 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
8768 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8770 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
8773 cmdline_parse_token_string_t cmd_setvf_traffic_set =
8774 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8776 cmdline_parse_token_string_t cmd_setvf_traffic_port =
8777 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8779 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
8780 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8782 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
8783 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8785 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
8786 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8788 cmdline_parse_token_string_t cmd_setvf_traffic_what =
8789 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8791 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
8792 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8795 cmdline_parse_inst_t cmd_set_vf_traffic = {
8796 .f = cmd_set_vf_traffic_parsed,
8798 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
8800 (void *)&cmd_setvf_traffic_set,
8801 (void *)&cmd_setvf_traffic_port,
8802 (void *)&cmd_setvf_traffic_portid,
8803 (void *)&cmd_setvf_traffic_vf,
8804 (void *)&cmd_setvf_traffic_vfid,
8805 (void *)&cmd_setvf_traffic_what,
8806 (void *)&cmd_setvf_traffic_mode,
8811 /* *** CONFIGURE VF RECEIVE MODE *** */
8812 struct cmd_set_vf_rxmode {
8813 cmdline_fixed_string_t set;
8814 cmdline_fixed_string_t port;
8816 cmdline_fixed_string_t vf;
8818 cmdline_fixed_string_t what;
8819 cmdline_fixed_string_t mode;
8820 cmdline_fixed_string_t on;
8824 cmd_set_vf_rxmode_parsed(void *parsed_result,
8825 __rte_unused struct cmdline *cl,
8826 __rte_unused void *data)
8829 uint16_t vf_rxmode = 0;
8830 struct cmd_set_vf_rxmode *res = parsed_result;
8832 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
8833 if (!strcmp(res->what,"rxmode")) {
8834 if (!strcmp(res->mode, "AUPE"))
8835 vf_rxmode |= ETH_VMDQ_ACCEPT_UNTAG;
8836 else if (!strcmp(res->mode, "ROPE"))
8837 vf_rxmode |= ETH_VMDQ_ACCEPT_HASH_UC;
8838 else if (!strcmp(res->mode, "BAM"))
8839 vf_rxmode |= ETH_VMDQ_ACCEPT_BROADCAST;
8840 else if (!strncmp(res->mode, "MPE",3))
8841 vf_rxmode |= ETH_VMDQ_ACCEPT_MULTICAST;
8844 RTE_SET_USED(is_on);
8846 #ifdef RTE_NET_IXGBE
8847 if (ret == -ENOTSUP)
8848 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id,
8849 vf_rxmode, (uint8_t)is_on);
8852 if (ret == -ENOTSUP)
8853 ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id,
8854 vf_rxmode, (uint8_t)is_on);
8857 printf("bad VF receive mode parameter, return code = %d \n",
8861 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
8862 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8864 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
8865 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8867 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
8868 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8870 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
8871 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8873 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
8874 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8876 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
8877 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8879 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
8880 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8881 mode, "AUPE#ROPE#BAM#MPE");
8882 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
8883 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8886 cmdline_parse_inst_t cmd_set_vf_rxmode = {
8887 .f = cmd_set_vf_rxmode_parsed,
8889 .help_str = "set port <port_id> vf <vf_id> rxmode "
8890 "AUPE|ROPE|BAM|MPE on|off",
8892 (void *)&cmd_set_vf_rxmode_set,
8893 (void *)&cmd_set_vf_rxmode_port,
8894 (void *)&cmd_set_vf_rxmode_portid,
8895 (void *)&cmd_set_vf_rxmode_vf,
8896 (void *)&cmd_set_vf_rxmode_vfid,
8897 (void *)&cmd_set_vf_rxmode_what,
8898 (void *)&cmd_set_vf_rxmode_mode,
8899 (void *)&cmd_set_vf_rxmode_on,
8904 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
8905 struct cmd_vf_mac_addr_result {
8906 cmdline_fixed_string_t mac_addr_cmd;
8907 cmdline_fixed_string_t what;
8908 cmdline_fixed_string_t port;
8910 cmdline_fixed_string_t vf;
8912 struct rte_ether_addr address;
8915 static void cmd_vf_mac_addr_parsed(void *parsed_result,
8916 __rte_unused struct cmdline *cl,
8917 __rte_unused void *data)
8919 struct cmd_vf_mac_addr_result *res = parsed_result;
8922 if (strcmp(res->what, "add") != 0)
8926 if (ret == -ENOTSUP)
8927 ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num,
8931 if (ret == -ENOTSUP)
8932 ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address,
8937 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
8941 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
8942 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8943 mac_addr_cmd,"mac_addr");
8944 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
8945 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8947 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
8948 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8950 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
8951 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8953 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
8954 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8956 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
8957 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8959 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
8960 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
8963 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
8964 .f = cmd_vf_mac_addr_parsed,
8966 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
8967 "Add MAC address filtering for a VF on port_id",
8969 (void *)&cmd_vf_mac_addr_cmd,
8970 (void *)&cmd_vf_mac_addr_what,
8971 (void *)&cmd_vf_mac_addr_port,
8972 (void *)&cmd_vf_mac_addr_portnum,
8973 (void *)&cmd_vf_mac_addr_vf,
8974 (void *)&cmd_vf_mac_addr_vfnum,
8975 (void *)&cmd_vf_mac_addr_addr,
8980 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
8981 struct cmd_vf_rx_vlan_filter {
8982 cmdline_fixed_string_t rx_vlan;
8983 cmdline_fixed_string_t what;
8985 cmdline_fixed_string_t port;
8987 cmdline_fixed_string_t vf;
8992 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
8993 __rte_unused struct cmdline *cl,
8994 __rte_unused void *data)
8996 struct cmd_vf_rx_vlan_filter *res = parsed_result;
8999 __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
9001 #ifdef RTE_NET_IXGBE
9002 if (ret == -ENOTSUP)
9003 ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
9004 res->vlan_id, res->vf_mask, is_add);
9007 if (ret == -ENOTSUP)
9008 ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
9009 res->vlan_id, res->vf_mask, is_add);
9012 if (ret == -ENOTSUP)
9013 ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id,
9014 res->vlan_id, res->vf_mask, is_add);
9021 printf("invalid vlan_id %d or vf_mask %"PRIu64"\n",
9022 res->vlan_id, res->vf_mask);
9025 printf("invalid port_id %d\n", res->port_id);
9028 printf("function not implemented or supported\n");
9031 printf("programming error: (%s)\n", strerror(-ret));
9035 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
9036 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9037 rx_vlan, "rx_vlan");
9038 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
9039 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9041 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
9042 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9044 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
9045 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9047 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
9048 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9050 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
9051 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9053 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
9054 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9057 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
9058 .f = cmd_vf_rx_vlan_filter_parsed,
9060 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
9061 "(vf_mask = hexadecimal VF mask)",
9063 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
9064 (void *)&cmd_vf_rx_vlan_filter_what,
9065 (void *)&cmd_vf_rx_vlan_filter_vlanid,
9066 (void *)&cmd_vf_rx_vlan_filter_port,
9067 (void *)&cmd_vf_rx_vlan_filter_portid,
9068 (void *)&cmd_vf_rx_vlan_filter_vf,
9069 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
9074 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
9075 struct cmd_queue_rate_limit_result {
9076 cmdline_fixed_string_t set;
9077 cmdline_fixed_string_t port;
9079 cmdline_fixed_string_t queue;
9081 cmdline_fixed_string_t rate;
9085 static void cmd_queue_rate_limit_parsed(void *parsed_result,
9086 __rte_unused struct cmdline *cl,
9087 __rte_unused void *data)
9089 struct cmd_queue_rate_limit_result *res = parsed_result;
9092 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
9093 && (strcmp(res->queue, "queue") == 0)
9094 && (strcmp(res->rate, "rate") == 0))
9095 ret = set_queue_rate_limit(res->port_num, res->queue_num,
9098 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
9102 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
9103 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9105 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
9106 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9108 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
9109 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
9111 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
9112 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9114 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
9115 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
9117 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
9118 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9120 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
9121 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
9124 cmdline_parse_inst_t cmd_queue_rate_limit = {
9125 .f = cmd_queue_rate_limit_parsed,
9127 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
9128 "Set rate limit for a queue on port_id",
9130 (void *)&cmd_queue_rate_limit_set,
9131 (void *)&cmd_queue_rate_limit_port,
9132 (void *)&cmd_queue_rate_limit_portnum,
9133 (void *)&cmd_queue_rate_limit_queue,
9134 (void *)&cmd_queue_rate_limit_queuenum,
9135 (void *)&cmd_queue_rate_limit_rate,
9136 (void *)&cmd_queue_rate_limit_ratenum,
9141 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
9142 struct cmd_vf_rate_limit_result {
9143 cmdline_fixed_string_t set;
9144 cmdline_fixed_string_t port;
9146 cmdline_fixed_string_t vf;
9148 cmdline_fixed_string_t rate;
9150 cmdline_fixed_string_t q_msk;
9154 static void cmd_vf_rate_limit_parsed(void *parsed_result,
9155 __rte_unused struct cmdline *cl,
9156 __rte_unused void *data)
9158 struct cmd_vf_rate_limit_result *res = parsed_result;
9161 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
9162 && (strcmp(res->vf, "vf") == 0)
9163 && (strcmp(res->rate, "rate") == 0)
9164 && (strcmp(res->q_msk, "queue_mask") == 0))
9165 ret = set_vf_rate_limit(res->port_num, res->vf_num,
9166 res->rate_num, res->q_msk_val);
9168 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
9172 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
9173 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9175 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
9176 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9178 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
9179 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9181 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
9182 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9184 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
9185 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9187 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
9188 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9190 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
9191 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9193 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
9194 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9195 q_msk, "queue_mask");
9196 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
9197 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9200 cmdline_parse_inst_t cmd_vf_rate_limit = {
9201 .f = cmd_vf_rate_limit_parsed,
9203 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
9204 "queue_mask <queue_mask_value>: "
9205 "Set rate limit for queues of VF on port_id",
9207 (void *)&cmd_vf_rate_limit_set,
9208 (void *)&cmd_vf_rate_limit_port,
9209 (void *)&cmd_vf_rate_limit_portnum,
9210 (void *)&cmd_vf_rate_limit_vf,
9211 (void *)&cmd_vf_rate_limit_vfnum,
9212 (void *)&cmd_vf_rate_limit_rate,
9213 (void *)&cmd_vf_rate_limit_ratenum,
9214 (void *)&cmd_vf_rate_limit_q_msk,
9215 (void *)&cmd_vf_rate_limit_q_msk_val,
9220 /* *** ADD TUNNEL FILTER OF A PORT *** */
9221 struct cmd_tunnel_filter_result {
9222 cmdline_fixed_string_t cmd;
9223 cmdline_fixed_string_t what;
9225 struct rte_ether_addr outer_mac;
9226 struct rte_ether_addr inner_mac;
9227 cmdline_ipaddr_t ip_value;
9228 uint16_t inner_vlan;
9229 cmdline_fixed_string_t tunnel_type;
9230 cmdline_fixed_string_t filter_type;
9236 cmd_tunnel_filter_parsed(void *parsed_result,
9237 __rte_unused struct cmdline *cl,
9238 __rte_unused void *data)
9240 struct cmd_tunnel_filter_result *res = parsed_result;
9241 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
9244 memset(&tunnel_filter_conf, 0, sizeof(tunnel_filter_conf));
9246 rte_ether_addr_copy(&res->outer_mac, &tunnel_filter_conf.outer_mac);
9247 rte_ether_addr_copy(&res->inner_mac, &tunnel_filter_conf.inner_mac);
9248 tunnel_filter_conf.inner_vlan = res->inner_vlan;
9250 if (res->ip_value.family == AF_INET) {
9251 tunnel_filter_conf.ip_addr.ipv4_addr =
9252 res->ip_value.addr.ipv4.s_addr;
9253 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
9255 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
9256 &(res->ip_value.addr.ipv6),
9257 sizeof(struct in6_addr));
9258 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
9261 if (!strcmp(res->filter_type, "imac-ivlan"))
9262 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
9263 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
9264 tunnel_filter_conf.filter_type =
9265 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
9266 else if (!strcmp(res->filter_type, "imac-tenid"))
9267 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
9268 else if (!strcmp(res->filter_type, "imac"))
9269 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
9270 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
9271 tunnel_filter_conf.filter_type =
9272 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
9273 else if (!strcmp(res->filter_type, "oip"))
9274 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_OIP;
9275 else if (!strcmp(res->filter_type, "iip"))
9276 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IIP;
9278 printf("The filter type is not supported");
9282 if (!strcmp(res->tunnel_type, "vxlan"))
9283 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
9284 else if (!strcmp(res->tunnel_type, "vxlan-gpe"))
9285 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN_GPE;
9286 else if (!strcmp(res->tunnel_type, "nvgre"))
9287 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE;
9288 else if (!strcmp(res->tunnel_type, "ipingre"))
9289 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_IP_IN_GRE;
9291 printf("The tunnel type %s not supported.\n", res->tunnel_type);
9295 tunnel_filter_conf.tenant_id = res->tenant_id;
9296 tunnel_filter_conf.queue_id = res->queue_num;
9297 if (!strcmp(res->what, "add"))
9298 ret = rte_eth_dev_filter_ctrl(res->port_id,
9299 RTE_ETH_FILTER_TUNNEL,
9301 &tunnel_filter_conf);
9303 ret = rte_eth_dev_filter_ctrl(res->port_id,
9304 RTE_ETH_FILTER_TUNNEL,
9305 RTE_ETH_FILTER_DELETE,
9306 &tunnel_filter_conf);
9308 printf("cmd_tunnel_filter_parsed error: (%s)\n",
9312 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
9313 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
9314 cmd, "tunnel_filter");
9315 cmdline_parse_token_string_t cmd_tunnel_filter_what =
9316 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
9318 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
9319 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
9321 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
9322 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
9324 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
9325 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
9327 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
9328 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
9329 inner_vlan, UINT16);
9330 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
9331 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
9333 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
9334 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
9335 tunnel_type, "vxlan#nvgre#ipingre#vxlan-gpe");
9337 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
9338 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
9339 filter_type, "oip#iip#imac-ivlan#imac-ivlan-tenid#imac-tenid#"
9340 "imac#omac-imac-tenid");
9341 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
9342 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
9344 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
9345 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
9348 cmdline_parse_inst_t cmd_tunnel_filter = {
9349 .f = cmd_tunnel_filter_parsed,
9351 .help_str = "tunnel_filter add|rm <port_id> <outer_mac> <inner_mac> "
9352 "<ip> <inner_vlan> vxlan|nvgre|ipingre oip|iip|imac-ivlan|"
9353 "imac-ivlan-tenid|imac-tenid|imac|omac-imac-tenid <tenant_id> "
9354 "<queue_id>: Add/Rm tunnel filter of a port",
9356 (void *)&cmd_tunnel_filter_cmd,
9357 (void *)&cmd_tunnel_filter_what,
9358 (void *)&cmd_tunnel_filter_port_id,
9359 (void *)&cmd_tunnel_filter_outer_mac,
9360 (void *)&cmd_tunnel_filter_inner_mac,
9361 (void *)&cmd_tunnel_filter_ip_value,
9362 (void *)&cmd_tunnel_filter_innner_vlan,
9363 (void *)&cmd_tunnel_filter_tunnel_type,
9364 (void *)&cmd_tunnel_filter_filter_type,
9365 (void *)&cmd_tunnel_filter_tenant_id,
9366 (void *)&cmd_tunnel_filter_queue_num,
9371 /* *** CONFIGURE TUNNEL UDP PORT *** */
9372 struct cmd_tunnel_udp_config {
9373 cmdline_fixed_string_t cmd;
9374 cmdline_fixed_string_t what;
9380 cmd_tunnel_udp_config_parsed(void *parsed_result,
9381 __rte_unused struct cmdline *cl,
9382 __rte_unused void *data)
9384 struct cmd_tunnel_udp_config *res = parsed_result;
9385 struct rte_eth_udp_tunnel tunnel_udp;
9388 tunnel_udp.udp_port = res->udp_port;
9390 if (!strcmp(res->cmd, "rx_vxlan_port"))
9391 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
9393 if (!strcmp(res->what, "add"))
9394 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9397 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9401 printf("udp tunneling add error: (%s)\n", strerror(-ret));
9404 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
9405 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9406 cmd, "rx_vxlan_port");
9407 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
9408 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9410 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
9411 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9413 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
9414 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9417 cmdline_parse_inst_t cmd_tunnel_udp_config = {
9418 .f = cmd_tunnel_udp_config_parsed,
9420 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
9421 "Add/Remove a tunneling UDP port filter",
9423 (void *)&cmd_tunnel_udp_config_cmd,
9424 (void *)&cmd_tunnel_udp_config_what,
9425 (void *)&cmd_tunnel_udp_config_udp_port,
9426 (void *)&cmd_tunnel_udp_config_port_id,
9431 struct cmd_config_tunnel_udp_port {
9432 cmdline_fixed_string_t port;
9433 cmdline_fixed_string_t config;
9435 cmdline_fixed_string_t udp_tunnel_port;
9436 cmdline_fixed_string_t action;
9437 cmdline_fixed_string_t tunnel_type;
9442 cmd_cfg_tunnel_udp_port_parsed(void *parsed_result,
9443 __rte_unused struct cmdline *cl,
9444 __rte_unused void *data)
9446 struct cmd_config_tunnel_udp_port *res = parsed_result;
9447 struct rte_eth_udp_tunnel tunnel_udp;
9450 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9453 tunnel_udp.udp_port = res->udp_port;
9455 if (!strcmp(res->tunnel_type, "vxlan")) {
9456 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
9457 } else if (!strcmp(res->tunnel_type, "geneve")) {
9458 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_GENEVE;
9459 } else if (!strcmp(res->tunnel_type, "vxlan-gpe")) {
9460 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN_GPE;
9462 printf("Invalid tunnel type\n");
9466 if (!strcmp(res->action, "add"))
9467 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9470 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9474 printf("udp tunneling port add error: (%s)\n", strerror(-ret));
9477 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_port =
9478 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, port,
9480 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_config =
9481 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, config,
9483 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_port_id =
9484 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, port_id,
9486 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_port =
9487 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port,
9490 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_action =
9491 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, action,
9493 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_type =
9494 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, tunnel_type,
9495 "vxlan#geneve#vxlan-gpe");
9496 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_value =
9497 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, udp_port,
9500 cmdline_parse_inst_t cmd_cfg_tunnel_udp_port = {
9501 .f = cmd_cfg_tunnel_udp_port_parsed,
9503 .help_str = "port config <port_id> udp_tunnel_port add|rm vxlan|geneve|vxlan-gpe <udp_port>",
9505 (void *)&cmd_config_tunnel_udp_port_port,
9506 (void *)&cmd_config_tunnel_udp_port_config,
9507 (void *)&cmd_config_tunnel_udp_port_port_id,
9508 (void *)&cmd_config_tunnel_udp_port_tunnel_port,
9509 (void *)&cmd_config_tunnel_udp_port_action,
9510 (void *)&cmd_config_tunnel_udp_port_tunnel_type,
9511 (void *)&cmd_config_tunnel_udp_port_value,
9516 /* *** GLOBAL CONFIG *** */
9517 struct cmd_global_config_result {
9518 cmdline_fixed_string_t cmd;
9520 cmdline_fixed_string_t cfg_type;
9525 cmd_global_config_parsed(void *parsed_result,
9526 __rte_unused struct cmdline *cl,
9527 __rte_unused void *data)
9529 struct cmd_global_config_result *res = parsed_result;
9530 struct rte_eth_global_cfg conf;
9533 memset(&conf, 0, sizeof(conf));
9534 conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN;
9535 conf.cfg.gre_key_len = res->len;
9536 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE,
9537 RTE_ETH_FILTER_SET, &conf);
9539 if (ret == -ENOTSUP)
9540 ret = rte_pmd_i40e_set_gre_key_len(res->port_id, res->len);
9543 printf("Global config error\n");
9546 cmdline_parse_token_string_t cmd_global_config_cmd =
9547 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd,
9549 cmdline_parse_token_num_t cmd_global_config_port_id =
9550 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id,
9552 cmdline_parse_token_string_t cmd_global_config_type =
9553 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result,
9554 cfg_type, "gre-key-len");
9555 cmdline_parse_token_num_t cmd_global_config_gre_key_len =
9556 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result,
9559 cmdline_parse_inst_t cmd_global_config = {
9560 .f = cmd_global_config_parsed,
9561 .data = (void *)NULL,
9562 .help_str = "global_config <port_id> gre-key-len <key_len>",
9564 (void *)&cmd_global_config_cmd,
9565 (void *)&cmd_global_config_port_id,
9566 (void *)&cmd_global_config_type,
9567 (void *)&cmd_global_config_gre_key_len,
9572 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
9573 struct cmd_set_mirror_mask_result {
9574 cmdline_fixed_string_t set;
9575 cmdline_fixed_string_t port;
9577 cmdline_fixed_string_t mirror;
9579 cmdline_fixed_string_t what;
9580 cmdline_fixed_string_t value;
9581 cmdline_fixed_string_t dstpool;
9583 cmdline_fixed_string_t on;
9586 cmdline_parse_token_string_t cmd_mirror_mask_set =
9587 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9589 cmdline_parse_token_string_t cmd_mirror_mask_port =
9590 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9592 cmdline_parse_token_num_t cmd_mirror_mask_portid =
9593 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9595 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
9596 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9597 mirror, "mirror-rule");
9598 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
9599 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9601 cmdline_parse_token_string_t cmd_mirror_mask_what =
9602 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9603 what, "pool-mirror-up#pool-mirror-down"
9605 cmdline_parse_token_string_t cmd_mirror_mask_value =
9606 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9608 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
9609 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9610 dstpool, "dst-pool");
9611 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
9612 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9614 cmdline_parse_token_string_t cmd_mirror_mask_on =
9615 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9619 cmd_set_mirror_mask_parsed(void *parsed_result,
9620 __rte_unused struct cmdline *cl,
9621 __rte_unused void *data)
9624 struct cmd_set_mirror_mask_result *res = parsed_result;
9625 struct rte_eth_mirror_conf mr_conf;
9627 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
9629 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
9631 mr_conf.dst_pool = res->dstpool_id;
9633 if (!strcmp(res->what, "pool-mirror-up")) {
9634 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
9635 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
9636 } else if (!strcmp(res->what, "pool-mirror-down")) {
9637 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
9638 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
9639 } else if (!strcmp(res->what, "vlan-mirror")) {
9640 mr_conf.rule_type = ETH_MIRROR_VLAN;
9641 nb_item = parse_item_list(res->value, "vlan",
9642 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
9646 for (i = 0; i < nb_item; i++) {
9647 if (vlan_list[i] > RTE_ETHER_MAX_VLAN_ID) {
9648 printf("Invalid vlan_id: must be < 4096\n");
9652 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
9653 mr_conf.vlan.vlan_mask |= 1ULL << i;
9657 if (!strcmp(res->on, "on"))
9658 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9661 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9664 printf("mirror rule add error: (%s)\n", strerror(-ret));
9667 cmdline_parse_inst_t cmd_set_mirror_mask = {
9668 .f = cmd_set_mirror_mask_parsed,
9670 .help_str = "set port <port_id> mirror-rule <rule_id> "
9671 "pool-mirror-up|pool-mirror-down|vlan-mirror "
9672 "<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off",
9674 (void *)&cmd_mirror_mask_set,
9675 (void *)&cmd_mirror_mask_port,
9676 (void *)&cmd_mirror_mask_portid,
9677 (void *)&cmd_mirror_mask_mirror,
9678 (void *)&cmd_mirror_mask_ruleid,
9679 (void *)&cmd_mirror_mask_what,
9680 (void *)&cmd_mirror_mask_value,
9681 (void *)&cmd_mirror_mask_dstpool,
9682 (void *)&cmd_mirror_mask_poolid,
9683 (void *)&cmd_mirror_mask_on,
9688 /* *** CONFIGURE VM MIRROR UPLINK/DOWNLINK RULE *** */
9689 struct cmd_set_mirror_link_result {
9690 cmdline_fixed_string_t set;
9691 cmdline_fixed_string_t port;
9693 cmdline_fixed_string_t mirror;
9695 cmdline_fixed_string_t what;
9696 cmdline_fixed_string_t dstpool;
9698 cmdline_fixed_string_t on;
9701 cmdline_parse_token_string_t cmd_mirror_link_set =
9702 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9704 cmdline_parse_token_string_t cmd_mirror_link_port =
9705 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9707 cmdline_parse_token_num_t cmd_mirror_link_portid =
9708 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9710 cmdline_parse_token_string_t cmd_mirror_link_mirror =
9711 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9712 mirror, "mirror-rule");
9713 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
9714 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9716 cmdline_parse_token_string_t cmd_mirror_link_what =
9717 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9718 what, "uplink-mirror#downlink-mirror");
9719 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
9720 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9721 dstpool, "dst-pool");
9722 cmdline_parse_token_num_t cmd_mirror_link_poolid =
9723 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9725 cmdline_parse_token_string_t cmd_mirror_link_on =
9726 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9730 cmd_set_mirror_link_parsed(void *parsed_result,
9731 __rte_unused struct cmdline *cl,
9732 __rte_unused void *data)
9735 struct cmd_set_mirror_link_result *res = parsed_result;
9736 struct rte_eth_mirror_conf mr_conf;
9738 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
9739 if (!strcmp(res->what, "uplink-mirror"))
9740 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
9742 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
9744 mr_conf.dst_pool = res->dstpool_id;
9746 if (!strcmp(res->on, "on"))
9747 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9750 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9753 /* check the return value and print it if is < 0 */
9755 printf("mirror rule add error: (%s)\n", strerror(-ret));
9759 cmdline_parse_inst_t cmd_set_mirror_link = {
9760 .f = cmd_set_mirror_link_parsed,
9762 .help_str = "set port <port_id> mirror-rule <rule_id> "
9763 "uplink-mirror|downlink-mirror dst-pool <pool_id> on|off",
9765 (void *)&cmd_mirror_link_set,
9766 (void *)&cmd_mirror_link_port,
9767 (void *)&cmd_mirror_link_portid,
9768 (void *)&cmd_mirror_link_mirror,
9769 (void *)&cmd_mirror_link_ruleid,
9770 (void *)&cmd_mirror_link_what,
9771 (void *)&cmd_mirror_link_dstpool,
9772 (void *)&cmd_mirror_link_poolid,
9773 (void *)&cmd_mirror_link_on,
9778 /* *** RESET VM MIRROR RULE *** */
9779 struct cmd_rm_mirror_rule_result {
9780 cmdline_fixed_string_t reset;
9781 cmdline_fixed_string_t port;
9783 cmdline_fixed_string_t mirror;
9787 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
9788 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9790 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
9791 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9793 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
9794 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9796 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
9797 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9798 mirror, "mirror-rule");
9799 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
9800 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9804 cmd_reset_mirror_rule_parsed(void *parsed_result,
9805 __rte_unused struct cmdline *cl,
9806 __rte_unused void *data)
9809 struct cmd_set_mirror_link_result *res = parsed_result;
9811 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
9813 printf("mirror rule remove error: (%s)\n", strerror(-ret));
9816 cmdline_parse_inst_t cmd_reset_mirror_rule = {
9817 .f = cmd_reset_mirror_rule_parsed,
9819 .help_str = "reset port <port_id> mirror-rule <rule_id>",
9821 (void *)&cmd_rm_mirror_rule_reset,
9822 (void *)&cmd_rm_mirror_rule_port,
9823 (void *)&cmd_rm_mirror_rule_portid,
9824 (void *)&cmd_rm_mirror_rule_mirror,
9825 (void *)&cmd_rm_mirror_rule_ruleid,
9830 /* ******************************************************************************** */
9832 struct cmd_dump_result {
9833 cmdline_fixed_string_t dump;
9837 dump_struct_sizes(void)
9839 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
9840 DUMP_SIZE(struct rte_mbuf);
9841 DUMP_SIZE(struct rte_mempool);
9842 DUMP_SIZE(struct rte_ring);
9847 /* Dump the socket memory statistics on console */
9849 dump_socket_mem(FILE *f)
9851 struct rte_malloc_socket_stats socket_stats;
9856 unsigned int n_alloc = 0;
9857 unsigned int n_free = 0;
9858 static size_t last_allocs;
9859 static size_t last_total;
9862 for (i = 0; i < RTE_MAX_NUMA_NODES; i++) {
9863 if (rte_malloc_get_socket_stats(i, &socket_stats) ||
9864 !socket_stats.heap_totalsz_bytes)
9866 total += socket_stats.heap_totalsz_bytes;
9867 alloc += socket_stats.heap_allocsz_bytes;
9868 free += socket_stats.heap_freesz_bytes;
9869 n_alloc += socket_stats.alloc_count;
9870 n_free += socket_stats.free_count;
9872 "Socket %u: size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n",
9874 (double)socket_stats.heap_totalsz_bytes / (1024 * 1024),
9875 (double)socket_stats.heap_allocsz_bytes / (1024 * 1024),
9876 (double)socket_stats.heap_allocsz_bytes * 100 /
9877 (double)socket_stats.heap_totalsz_bytes,
9878 (double)socket_stats.heap_freesz_bytes / (1024 * 1024),
9879 socket_stats.alloc_count,
9880 socket_stats.free_count);
9883 "Total : size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n",
9884 (double)total / (1024 * 1024), (double)alloc / (1024 * 1024),
9885 (double)alloc * 100 / (double)total,
9886 (double)free / (1024 * 1024),
9889 fprintf(stdout, "Memory total change: %.6lf(M), allocation change: %.6lf(M)\n",
9890 ((double)total - (double)last_total) / (1024 * 1024),
9891 (double)(alloc - (double)last_allocs) / 1024 / 1024);
9892 last_allocs = alloc;
9896 static void cmd_dump_parsed(void *parsed_result,
9897 __rte_unused struct cmdline *cl,
9898 __rte_unused void *data)
9900 struct cmd_dump_result *res = parsed_result;
9902 if (!strcmp(res->dump, "dump_physmem"))
9903 rte_dump_physmem_layout(stdout);
9904 else if (!strcmp(res->dump, "dump_socket_mem"))
9905 dump_socket_mem(stdout);
9906 else if (!strcmp(res->dump, "dump_memzone"))
9907 rte_memzone_dump(stdout);
9908 else if (!strcmp(res->dump, "dump_struct_sizes"))
9909 dump_struct_sizes();
9910 else if (!strcmp(res->dump, "dump_ring"))
9911 rte_ring_list_dump(stdout);
9912 else if (!strcmp(res->dump, "dump_mempool"))
9913 rte_mempool_list_dump(stdout);
9914 else if (!strcmp(res->dump, "dump_devargs"))
9915 rte_devargs_dump(stdout);
9916 else if (!strcmp(res->dump, "dump_log_types"))
9917 rte_log_dump(stdout);
9920 cmdline_parse_token_string_t cmd_dump_dump =
9921 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
9925 "dump_struct_sizes#"
9931 cmdline_parse_inst_t cmd_dump = {
9932 .f = cmd_dump_parsed, /* function to call */
9933 .data = NULL, /* 2nd arg of func */
9934 .help_str = "Dump status",
9935 .tokens = { /* token list, NULL terminated */
9936 (void *)&cmd_dump_dump,
9941 /* ******************************************************************************** */
9943 struct cmd_dump_one_result {
9944 cmdline_fixed_string_t dump;
9945 cmdline_fixed_string_t name;
9948 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
9949 __rte_unused void *data)
9951 struct cmd_dump_one_result *res = parsed_result;
9953 if (!strcmp(res->dump, "dump_ring")) {
9955 r = rte_ring_lookup(res->name);
9957 cmdline_printf(cl, "Cannot find ring\n");
9960 rte_ring_dump(stdout, r);
9961 } else if (!strcmp(res->dump, "dump_mempool")) {
9962 struct rte_mempool *mp;
9963 mp = rte_mempool_lookup(res->name);
9965 cmdline_printf(cl, "Cannot find mempool\n");
9968 rte_mempool_dump(stdout, mp);
9972 cmdline_parse_token_string_t cmd_dump_one_dump =
9973 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
9974 "dump_ring#dump_mempool");
9976 cmdline_parse_token_string_t cmd_dump_one_name =
9977 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
9979 cmdline_parse_inst_t cmd_dump_one = {
9980 .f = cmd_dump_one_parsed, /* function to call */
9981 .data = NULL, /* 2nd arg of func */
9982 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
9983 .tokens = { /* token list, NULL terminated */
9984 (void *)&cmd_dump_one_dump,
9985 (void *)&cmd_dump_one_name,
9990 /* *** Add/Del syn filter *** */
9991 struct cmd_syn_filter_result {
9992 cmdline_fixed_string_t filter;
9994 cmdline_fixed_string_t ops;
9995 cmdline_fixed_string_t priority;
9996 cmdline_fixed_string_t high;
9997 cmdline_fixed_string_t queue;
10002 cmd_syn_filter_parsed(void *parsed_result,
10003 __rte_unused struct cmdline *cl,
10004 __rte_unused void *data)
10006 struct cmd_syn_filter_result *res = parsed_result;
10007 struct rte_eth_syn_filter syn_filter;
10010 ret = rte_eth_dev_filter_supported(res->port_id,
10011 RTE_ETH_FILTER_SYN);
10013 printf("syn filter is not supported on port %u.\n",
10018 memset(&syn_filter, 0, sizeof(syn_filter));
10020 if (!strcmp(res->ops, "add")) {
10021 if (!strcmp(res->high, "high"))
10022 syn_filter.hig_pri = 1;
10024 syn_filter.hig_pri = 0;
10026 syn_filter.queue = res->queue_id;
10027 ret = rte_eth_dev_filter_ctrl(res->port_id,
10028 RTE_ETH_FILTER_SYN,
10029 RTE_ETH_FILTER_ADD,
10032 ret = rte_eth_dev_filter_ctrl(res->port_id,
10033 RTE_ETH_FILTER_SYN,
10034 RTE_ETH_FILTER_DELETE,
10038 printf("syn filter programming error: (%s)\n",
10042 cmdline_parse_token_string_t cmd_syn_filter_filter =
10043 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
10044 filter, "syn_filter");
10045 cmdline_parse_token_num_t cmd_syn_filter_port_id =
10046 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
10048 cmdline_parse_token_string_t cmd_syn_filter_ops =
10049 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
10051 cmdline_parse_token_string_t cmd_syn_filter_priority =
10052 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
10053 priority, "priority");
10054 cmdline_parse_token_string_t cmd_syn_filter_high =
10055 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
10057 cmdline_parse_token_string_t cmd_syn_filter_queue =
10058 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
10060 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
10061 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
10064 cmdline_parse_inst_t cmd_syn_filter = {
10065 .f = cmd_syn_filter_parsed,
10067 .help_str = "syn_filter <port_id> add|del priority high|low queue "
10068 "<queue_id>: Add/Delete syn filter",
10070 (void *)&cmd_syn_filter_filter,
10071 (void *)&cmd_syn_filter_port_id,
10072 (void *)&cmd_syn_filter_ops,
10073 (void *)&cmd_syn_filter_priority,
10074 (void *)&cmd_syn_filter_high,
10075 (void *)&cmd_syn_filter_queue,
10076 (void *)&cmd_syn_filter_queue_id,
10081 /* *** queue region set *** */
10082 struct cmd_queue_region_result {
10083 cmdline_fixed_string_t set;
10084 cmdline_fixed_string_t port;
10086 cmdline_fixed_string_t cmd;
10087 cmdline_fixed_string_t region;
10089 cmdline_fixed_string_t queue_start_index;
10091 cmdline_fixed_string_t queue_num;
10092 uint8_t queue_num_value;
10096 cmd_queue_region_parsed(void *parsed_result,
10097 __rte_unused struct cmdline *cl,
10098 __rte_unused void *data)
10100 struct cmd_queue_region_result *res = parsed_result;
10101 int ret = -ENOTSUP;
10102 #ifdef RTE_NET_I40E
10103 struct rte_pmd_i40e_queue_region_conf region_conf;
10104 enum rte_pmd_i40e_queue_region_op op_type;
10107 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10110 #ifdef RTE_NET_I40E
10111 memset(®ion_conf, 0, sizeof(region_conf));
10112 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_SET;
10113 region_conf.region_id = res->region_id;
10114 region_conf.queue_num = res->queue_num_value;
10115 region_conf.queue_start_index = res->queue_id;
10117 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10118 op_type, ®ion_conf);
10125 printf("function not implemented or supported\n");
10128 printf("queue region config error: (%s)\n", strerror(-ret));
10132 cmdline_parse_token_string_t cmd_queue_region_set =
10133 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
10135 cmdline_parse_token_string_t cmd_queue_region_port =
10136 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, port, "port");
10137 cmdline_parse_token_num_t cmd_queue_region_port_id =
10138 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
10140 cmdline_parse_token_string_t cmd_queue_region_cmd =
10141 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
10142 cmd, "queue-region");
10143 cmdline_parse_token_string_t cmd_queue_region_id =
10144 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
10145 region, "region_id");
10146 cmdline_parse_token_num_t cmd_queue_region_index =
10147 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
10149 cmdline_parse_token_string_t cmd_queue_region_queue_start_index =
10150 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
10151 queue_start_index, "queue_start_index");
10152 cmdline_parse_token_num_t cmd_queue_region_queue_id =
10153 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
10155 cmdline_parse_token_string_t cmd_queue_region_queue_num =
10156 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
10157 queue_num, "queue_num");
10158 cmdline_parse_token_num_t cmd_queue_region_queue_num_value =
10159 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
10160 queue_num_value, UINT8);
10162 cmdline_parse_inst_t cmd_queue_region = {
10163 .f = cmd_queue_region_parsed,
10165 .help_str = "set port <port_id> queue-region region_id <value> "
10166 "queue_start_index <value> queue_num <value>: Set a queue region",
10168 (void *)&cmd_queue_region_set,
10169 (void *)&cmd_queue_region_port,
10170 (void *)&cmd_queue_region_port_id,
10171 (void *)&cmd_queue_region_cmd,
10172 (void *)&cmd_queue_region_id,
10173 (void *)&cmd_queue_region_index,
10174 (void *)&cmd_queue_region_queue_start_index,
10175 (void *)&cmd_queue_region_queue_id,
10176 (void *)&cmd_queue_region_queue_num,
10177 (void *)&cmd_queue_region_queue_num_value,
10182 /* *** queue region and flowtype set *** */
10183 struct cmd_region_flowtype_result {
10184 cmdline_fixed_string_t set;
10185 cmdline_fixed_string_t port;
10187 cmdline_fixed_string_t cmd;
10188 cmdline_fixed_string_t region;
10190 cmdline_fixed_string_t flowtype;
10191 uint8_t flowtype_id;
10195 cmd_region_flowtype_parsed(void *parsed_result,
10196 __rte_unused struct cmdline *cl,
10197 __rte_unused void *data)
10199 struct cmd_region_flowtype_result *res = parsed_result;
10200 int ret = -ENOTSUP;
10201 #ifdef RTE_NET_I40E
10202 struct rte_pmd_i40e_queue_region_conf region_conf;
10203 enum rte_pmd_i40e_queue_region_op op_type;
10206 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10209 #ifdef RTE_NET_I40E
10210 memset(®ion_conf, 0, sizeof(region_conf));
10212 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_FLOWTYPE_SET;
10213 region_conf.region_id = res->region_id;
10214 region_conf.hw_flowtype = res->flowtype_id;
10216 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10217 op_type, ®ion_conf);
10224 printf("function not implemented or supported\n");
10227 printf("region flowtype config error: (%s)\n", strerror(-ret));
10231 cmdline_parse_token_string_t cmd_region_flowtype_set =
10232 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10234 cmdline_parse_token_string_t cmd_region_flowtype_port =
10235 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10237 cmdline_parse_token_num_t cmd_region_flowtype_port_index =
10238 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
10240 cmdline_parse_token_string_t cmd_region_flowtype_cmd =
10241 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10242 cmd, "queue-region");
10243 cmdline_parse_token_string_t cmd_region_flowtype_index =
10244 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10245 region, "region_id");
10246 cmdline_parse_token_num_t cmd_region_flowtype_id =
10247 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
10249 cmdline_parse_token_string_t cmd_region_flowtype_flow_index =
10250 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10251 flowtype, "flowtype");
10252 cmdline_parse_token_num_t cmd_region_flowtype_flow_id =
10253 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
10254 flowtype_id, UINT8);
10255 cmdline_parse_inst_t cmd_region_flowtype = {
10256 .f = cmd_region_flowtype_parsed,
10258 .help_str = "set port <port_id> queue-region region_id <value> "
10259 "flowtype <value>: Set a flowtype region index",
10261 (void *)&cmd_region_flowtype_set,
10262 (void *)&cmd_region_flowtype_port,
10263 (void *)&cmd_region_flowtype_port_index,
10264 (void *)&cmd_region_flowtype_cmd,
10265 (void *)&cmd_region_flowtype_index,
10266 (void *)&cmd_region_flowtype_id,
10267 (void *)&cmd_region_flowtype_flow_index,
10268 (void *)&cmd_region_flowtype_flow_id,
10273 /* *** User Priority (UP) to queue region (region_id) set *** */
10274 struct cmd_user_priority_region_result {
10275 cmdline_fixed_string_t set;
10276 cmdline_fixed_string_t port;
10278 cmdline_fixed_string_t cmd;
10279 cmdline_fixed_string_t user_priority;
10280 uint8_t user_priority_id;
10281 cmdline_fixed_string_t region;
10286 cmd_user_priority_region_parsed(void *parsed_result,
10287 __rte_unused struct cmdline *cl,
10288 __rte_unused void *data)
10290 struct cmd_user_priority_region_result *res = parsed_result;
10291 int ret = -ENOTSUP;
10292 #ifdef RTE_NET_I40E
10293 struct rte_pmd_i40e_queue_region_conf region_conf;
10294 enum rte_pmd_i40e_queue_region_op op_type;
10297 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10300 #ifdef RTE_NET_I40E
10301 memset(®ion_conf, 0, sizeof(region_conf));
10302 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_USER_PRIORITY_SET;
10303 region_conf.user_priority = res->user_priority_id;
10304 region_conf.region_id = res->region_id;
10306 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10307 op_type, ®ion_conf);
10314 printf("function not implemented or supported\n");
10317 printf("user_priority region config error: (%s)\n",
10322 cmdline_parse_token_string_t cmd_user_priority_region_set =
10323 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10325 cmdline_parse_token_string_t cmd_user_priority_region_port =
10326 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10328 cmdline_parse_token_num_t cmd_user_priority_region_port_index =
10329 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10331 cmdline_parse_token_string_t cmd_user_priority_region_cmd =
10332 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10333 cmd, "queue-region");
10334 cmdline_parse_token_string_t cmd_user_priority_region_UP =
10335 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10336 user_priority, "UP");
10337 cmdline_parse_token_num_t cmd_user_priority_region_UP_id =
10338 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10339 user_priority_id, UINT8);
10340 cmdline_parse_token_string_t cmd_user_priority_region_region =
10341 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10342 region, "region_id");
10343 cmdline_parse_token_num_t cmd_user_priority_region_region_id =
10344 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10347 cmdline_parse_inst_t cmd_user_priority_region = {
10348 .f = cmd_user_priority_region_parsed,
10350 .help_str = "set port <port_id> queue-region UP <value> "
10351 "region_id <value>: Set the mapping of User Priority (UP) "
10352 "to queue region (region_id) ",
10354 (void *)&cmd_user_priority_region_set,
10355 (void *)&cmd_user_priority_region_port,
10356 (void *)&cmd_user_priority_region_port_index,
10357 (void *)&cmd_user_priority_region_cmd,
10358 (void *)&cmd_user_priority_region_UP,
10359 (void *)&cmd_user_priority_region_UP_id,
10360 (void *)&cmd_user_priority_region_region,
10361 (void *)&cmd_user_priority_region_region_id,
10366 /* *** flush all queue region related configuration *** */
10367 struct cmd_flush_queue_region_result {
10368 cmdline_fixed_string_t set;
10369 cmdline_fixed_string_t port;
10371 cmdline_fixed_string_t cmd;
10372 cmdline_fixed_string_t flush;
10373 cmdline_fixed_string_t what;
10377 cmd_flush_queue_region_parsed(void *parsed_result,
10378 __rte_unused struct cmdline *cl,
10379 __rte_unused void *data)
10381 struct cmd_flush_queue_region_result *res = parsed_result;
10382 int ret = -ENOTSUP;
10383 #ifdef RTE_NET_I40E
10384 struct rte_pmd_i40e_queue_region_conf region_conf;
10385 enum rte_pmd_i40e_queue_region_op op_type;
10388 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10391 #ifdef RTE_NET_I40E
10392 memset(®ion_conf, 0, sizeof(region_conf));
10394 if (strcmp(res->what, "on") == 0)
10395 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_ON;
10397 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_OFF;
10399 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10400 op_type, ®ion_conf);
10407 printf("function not implemented or supported\n");
10410 printf("queue region config flush error: (%s)\n",
10415 cmdline_parse_token_string_t cmd_flush_queue_region_set =
10416 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10418 cmdline_parse_token_string_t cmd_flush_queue_region_port =
10419 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10421 cmdline_parse_token_num_t cmd_flush_queue_region_port_index =
10422 TOKEN_NUM_INITIALIZER(struct cmd_flush_queue_region_result,
10424 cmdline_parse_token_string_t cmd_flush_queue_region_cmd =
10425 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10426 cmd, "queue-region");
10427 cmdline_parse_token_string_t cmd_flush_queue_region_flush =
10428 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10430 cmdline_parse_token_string_t cmd_flush_queue_region_what =
10431 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10434 cmdline_parse_inst_t cmd_flush_queue_region = {
10435 .f = cmd_flush_queue_region_parsed,
10437 .help_str = "set port <port_id> queue-region flush on|off"
10438 ": flush all queue region related configuration",
10440 (void *)&cmd_flush_queue_region_set,
10441 (void *)&cmd_flush_queue_region_port,
10442 (void *)&cmd_flush_queue_region_port_index,
10443 (void *)&cmd_flush_queue_region_cmd,
10444 (void *)&cmd_flush_queue_region_flush,
10445 (void *)&cmd_flush_queue_region_what,
10450 /* *** get all queue region related configuration info *** */
10451 struct cmd_show_queue_region_info {
10452 cmdline_fixed_string_t show;
10453 cmdline_fixed_string_t port;
10455 cmdline_fixed_string_t cmd;
10459 cmd_show_queue_region_info_parsed(void *parsed_result,
10460 __rte_unused struct cmdline *cl,
10461 __rte_unused void *data)
10463 struct cmd_show_queue_region_info *res = parsed_result;
10464 int ret = -ENOTSUP;
10465 #ifdef RTE_NET_I40E
10466 struct rte_pmd_i40e_queue_regions rte_pmd_regions;
10467 enum rte_pmd_i40e_queue_region_op op_type;
10470 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10473 #ifdef RTE_NET_I40E
10474 memset(&rte_pmd_regions, 0, sizeof(rte_pmd_regions));
10476 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_INFO_GET;
10478 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10479 op_type, &rte_pmd_regions);
10481 port_queue_region_info_display(res->port_id, &rte_pmd_regions);
10488 printf("function not implemented or supported\n");
10491 printf("queue region config info show error: (%s)\n",
10496 cmdline_parse_token_string_t cmd_show_queue_region_info_get =
10497 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10499 cmdline_parse_token_string_t cmd_show_queue_region_info_port =
10500 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10502 cmdline_parse_token_num_t cmd_show_queue_region_info_port_index =
10503 TOKEN_NUM_INITIALIZER(struct cmd_show_queue_region_info,
10505 cmdline_parse_token_string_t cmd_show_queue_region_info_cmd =
10506 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10507 cmd, "queue-region");
10509 cmdline_parse_inst_t cmd_show_queue_region_info_all = {
10510 .f = cmd_show_queue_region_info_parsed,
10512 .help_str = "show port <port_id> queue-region"
10513 ": show all queue region related configuration info",
10515 (void *)&cmd_show_queue_region_info_get,
10516 (void *)&cmd_show_queue_region_info_port,
10517 (void *)&cmd_show_queue_region_info_port_index,
10518 (void *)&cmd_show_queue_region_info_cmd,
10523 /* *** ADD/REMOVE A 2tuple FILTER *** */
10524 struct cmd_2tuple_filter_result {
10525 cmdline_fixed_string_t filter;
10527 cmdline_fixed_string_t ops;
10528 cmdline_fixed_string_t dst_port;
10529 uint16_t dst_port_value;
10530 cmdline_fixed_string_t protocol;
10531 uint8_t protocol_value;
10532 cmdline_fixed_string_t mask;
10533 uint8_t mask_value;
10534 cmdline_fixed_string_t tcp_flags;
10535 uint8_t tcp_flags_value;
10536 cmdline_fixed_string_t priority;
10537 uint8_t priority_value;
10538 cmdline_fixed_string_t queue;
10543 cmd_2tuple_filter_parsed(void *parsed_result,
10544 __rte_unused struct cmdline *cl,
10545 __rte_unused void *data)
10547 struct rte_eth_ntuple_filter filter;
10548 struct cmd_2tuple_filter_result *res = parsed_result;
10551 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
10553 printf("ntuple filter is not supported on port %u.\n",
10558 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
10560 filter.flags = RTE_2TUPLE_FLAGS;
10561 filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
10562 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
10563 filter.proto = res->protocol_value;
10564 filter.priority = res->priority_value;
10565 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
10566 printf("nonzero tcp_flags is only meaningful"
10567 " when protocol is TCP.\n");
10570 if (res->tcp_flags_value > RTE_NTUPLE_TCP_FLAGS_MASK) {
10571 printf("invalid TCP flags.\n");
10575 if (res->tcp_flags_value != 0) {
10576 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
10577 filter.tcp_flags = res->tcp_flags_value;
10580 /* need convert to big endian. */
10581 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
10582 filter.queue = res->queue_id;
10584 if (!strcmp(res->ops, "add"))
10585 ret = rte_eth_dev_filter_ctrl(res->port_id,
10586 RTE_ETH_FILTER_NTUPLE,
10587 RTE_ETH_FILTER_ADD,
10590 ret = rte_eth_dev_filter_ctrl(res->port_id,
10591 RTE_ETH_FILTER_NTUPLE,
10592 RTE_ETH_FILTER_DELETE,
10595 printf("2tuple filter programming error: (%s)\n",
10600 cmdline_parse_token_string_t cmd_2tuple_filter_filter =
10601 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10602 filter, "2tuple_filter");
10603 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
10604 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10606 cmdline_parse_token_string_t cmd_2tuple_filter_ops =
10607 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10609 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
10610 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10611 dst_port, "dst_port");
10612 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
10613 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10614 dst_port_value, UINT16);
10615 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
10616 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10617 protocol, "protocol");
10618 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
10619 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10620 protocol_value, UINT8);
10621 cmdline_parse_token_string_t cmd_2tuple_filter_mask =
10622 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10624 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value =
10625 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10627 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags =
10628 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10629 tcp_flags, "tcp_flags");
10630 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value =
10631 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10632 tcp_flags_value, UINT8);
10633 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
10634 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10635 priority, "priority");
10636 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
10637 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10638 priority_value, UINT8);
10639 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
10640 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10642 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
10643 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10646 cmdline_parse_inst_t cmd_2tuple_filter = {
10647 .f = cmd_2tuple_filter_parsed,
10649 .help_str = "2tuple_filter <port_id> add|del dst_port <value> protocol "
10650 "<value> mask <value> tcp_flags <value> priority <value> queue "
10651 "<queue_id>: Add a 2tuple filter",
10653 (void *)&cmd_2tuple_filter_filter,
10654 (void *)&cmd_2tuple_filter_port_id,
10655 (void *)&cmd_2tuple_filter_ops,
10656 (void *)&cmd_2tuple_filter_dst_port,
10657 (void *)&cmd_2tuple_filter_dst_port_value,
10658 (void *)&cmd_2tuple_filter_protocol,
10659 (void *)&cmd_2tuple_filter_protocol_value,
10660 (void *)&cmd_2tuple_filter_mask,
10661 (void *)&cmd_2tuple_filter_mask_value,
10662 (void *)&cmd_2tuple_filter_tcp_flags,
10663 (void *)&cmd_2tuple_filter_tcp_flags_value,
10664 (void *)&cmd_2tuple_filter_priority,
10665 (void *)&cmd_2tuple_filter_priority_value,
10666 (void *)&cmd_2tuple_filter_queue,
10667 (void *)&cmd_2tuple_filter_queue_id,
10672 /* *** ADD/REMOVE A 5tuple FILTER *** */
10673 struct cmd_5tuple_filter_result {
10674 cmdline_fixed_string_t filter;
10676 cmdline_fixed_string_t ops;
10677 cmdline_fixed_string_t dst_ip;
10678 cmdline_ipaddr_t dst_ip_value;
10679 cmdline_fixed_string_t src_ip;
10680 cmdline_ipaddr_t src_ip_value;
10681 cmdline_fixed_string_t dst_port;
10682 uint16_t dst_port_value;
10683 cmdline_fixed_string_t src_port;
10684 uint16_t src_port_value;
10685 cmdline_fixed_string_t protocol;
10686 uint8_t protocol_value;
10687 cmdline_fixed_string_t mask;
10688 uint8_t mask_value;
10689 cmdline_fixed_string_t tcp_flags;
10690 uint8_t tcp_flags_value;
10691 cmdline_fixed_string_t priority;
10692 uint8_t priority_value;
10693 cmdline_fixed_string_t queue;
10698 cmd_5tuple_filter_parsed(void *parsed_result,
10699 __rte_unused struct cmdline *cl,
10700 __rte_unused void *data)
10702 struct rte_eth_ntuple_filter filter;
10703 struct cmd_5tuple_filter_result *res = parsed_result;
10706 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
10708 printf("ntuple filter is not supported on port %u.\n",
10713 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
10715 filter.flags = RTE_5TUPLE_FLAGS;
10716 filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0;
10717 filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0;
10718 filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0;
10719 filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
10720 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
10721 filter.proto = res->protocol_value;
10722 filter.priority = res->priority_value;
10723 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
10724 printf("nonzero tcp_flags is only meaningful"
10725 " when protocol is TCP.\n");
10728 if (res->tcp_flags_value > RTE_NTUPLE_TCP_FLAGS_MASK) {
10729 printf("invalid TCP flags.\n");
10733 if (res->tcp_flags_value != 0) {
10734 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
10735 filter.tcp_flags = res->tcp_flags_value;
10738 if (res->dst_ip_value.family == AF_INET)
10739 /* no need to convert, already big endian. */
10740 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
10742 if (filter.dst_ip_mask == 0) {
10743 printf("can not support ipv6 involved compare.\n");
10749 if (res->src_ip_value.family == AF_INET)
10750 /* no need to convert, already big endian. */
10751 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
10753 if (filter.src_ip_mask == 0) {
10754 printf("can not support ipv6 involved compare.\n");
10759 /* need convert to big endian. */
10760 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
10761 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
10762 filter.queue = res->queue_id;
10764 if (!strcmp(res->ops, "add"))
10765 ret = rte_eth_dev_filter_ctrl(res->port_id,
10766 RTE_ETH_FILTER_NTUPLE,
10767 RTE_ETH_FILTER_ADD,
10770 ret = rte_eth_dev_filter_ctrl(res->port_id,
10771 RTE_ETH_FILTER_NTUPLE,
10772 RTE_ETH_FILTER_DELETE,
10775 printf("5tuple filter programming error: (%s)\n",
10779 cmdline_parse_token_string_t cmd_5tuple_filter_filter =
10780 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10781 filter, "5tuple_filter");
10782 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
10783 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10785 cmdline_parse_token_string_t cmd_5tuple_filter_ops =
10786 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10788 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
10789 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10791 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
10792 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
10794 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
10795 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10797 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
10798 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
10800 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
10801 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10802 dst_port, "dst_port");
10803 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
10804 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10805 dst_port_value, UINT16);
10806 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
10807 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10808 src_port, "src_port");
10809 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
10810 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10811 src_port_value, UINT16);
10812 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
10813 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10814 protocol, "protocol");
10815 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
10816 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10817 protocol_value, UINT8);
10818 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
10819 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10821 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
10822 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10824 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags =
10825 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10826 tcp_flags, "tcp_flags");
10827 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value =
10828 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10829 tcp_flags_value, UINT8);
10830 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
10831 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10832 priority, "priority");
10833 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
10834 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10835 priority_value, UINT8);
10836 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
10837 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10839 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
10840 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10843 cmdline_parse_inst_t cmd_5tuple_filter = {
10844 .f = cmd_5tuple_filter_parsed,
10846 .help_str = "5tuple_filter <port_id> add|del dst_ip <value> "
10847 "src_ip <value> dst_port <value> src_port <value> "
10848 "protocol <value> mask <value> tcp_flags <value> "
10849 "priority <value> queue <queue_id>: Add/Del a 5tuple filter",
10851 (void *)&cmd_5tuple_filter_filter,
10852 (void *)&cmd_5tuple_filter_port_id,
10853 (void *)&cmd_5tuple_filter_ops,
10854 (void *)&cmd_5tuple_filter_dst_ip,
10855 (void *)&cmd_5tuple_filter_dst_ip_value,
10856 (void *)&cmd_5tuple_filter_src_ip,
10857 (void *)&cmd_5tuple_filter_src_ip_value,
10858 (void *)&cmd_5tuple_filter_dst_port,
10859 (void *)&cmd_5tuple_filter_dst_port_value,
10860 (void *)&cmd_5tuple_filter_src_port,
10861 (void *)&cmd_5tuple_filter_src_port_value,
10862 (void *)&cmd_5tuple_filter_protocol,
10863 (void *)&cmd_5tuple_filter_protocol_value,
10864 (void *)&cmd_5tuple_filter_mask,
10865 (void *)&cmd_5tuple_filter_mask_value,
10866 (void *)&cmd_5tuple_filter_tcp_flags,
10867 (void *)&cmd_5tuple_filter_tcp_flags_value,
10868 (void *)&cmd_5tuple_filter_priority,
10869 (void *)&cmd_5tuple_filter_priority_value,
10870 (void *)&cmd_5tuple_filter_queue,
10871 (void *)&cmd_5tuple_filter_queue_id,
10876 /* *** ADD/REMOVE A flex FILTER *** */
10877 struct cmd_flex_filter_result {
10878 cmdline_fixed_string_t filter;
10879 cmdline_fixed_string_t ops;
10881 cmdline_fixed_string_t len;
10883 cmdline_fixed_string_t bytes;
10884 cmdline_fixed_string_t bytes_value;
10885 cmdline_fixed_string_t mask;
10886 cmdline_fixed_string_t mask_value;
10887 cmdline_fixed_string_t priority;
10888 uint8_t priority_value;
10889 cmdline_fixed_string_t queue;
10893 static int xdigit2val(unsigned char c)
10898 else if (isupper(c))
10899 val = c - 'A' + 10;
10901 val = c - 'a' + 10;
10906 cmd_flex_filter_parsed(void *parsed_result,
10907 __rte_unused struct cmdline *cl,
10908 __rte_unused void *data)
10911 struct rte_eth_flex_filter filter;
10912 struct cmd_flex_filter_result *res = parsed_result;
10913 char *bytes_ptr, *mask_ptr;
10914 uint16_t len, i, j = 0;
10919 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) {
10920 printf("the len exceed the max length 128\n");
10923 memset(&filter, 0, sizeof(struct rte_eth_flex_filter));
10924 filter.len = res->len_value;
10925 filter.priority = res->priority_value;
10926 filter.queue = res->queue_id;
10927 bytes_ptr = res->bytes_value;
10928 mask_ptr = res->mask_value;
10930 /* translate bytes string to array. */
10931 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
10932 (bytes_ptr[1] == 'X')))
10934 len = strnlen(bytes_ptr, res->len_value * 2);
10935 if (len == 0 || (len % 8 != 0)) {
10936 printf("please check len and bytes input\n");
10939 for (i = 0; i < len; i++) {
10941 if (isxdigit(c) == 0) {
10942 /* invalid characters. */
10943 printf("invalid input\n");
10946 val = xdigit2val(c);
10949 filter.bytes[j] = byte;
10950 printf("bytes[%d]:%02x ", j, filter.bytes[j]);
10957 /* translate mask string to uint8_t array. */
10958 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
10959 (mask_ptr[1] == 'X')))
10961 len = strnlen(mask_ptr, (res->len_value + 3) / 4);
10963 printf("invalid input\n");
10968 for (i = 0; i < len; i++) {
10970 if (isxdigit(c) == 0) {
10971 /* invalid characters. */
10972 printf("invalid input\n");
10975 val = xdigit2val(c);
10978 filter.mask[j] = byte;
10979 printf("mask[%d]:%02x ", j, filter.mask[j]);
10987 if (!strcmp(res->ops, "add"))
10988 ret = rte_eth_dev_filter_ctrl(res->port_id,
10989 RTE_ETH_FILTER_FLEXIBLE,
10990 RTE_ETH_FILTER_ADD,
10993 ret = rte_eth_dev_filter_ctrl(res->port_id,
10994 RTE_ETH_FILTER_FLEXIBLE,
10995 RTE_ETH_FILTER_DELETE,
10999 printf("flex filter setting error: (%s)\n", strerror(-ret));
11002 cmdline_parse_token_string_t cmd_flex_filter_filter =
11003 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
11004 filter, "flex_filter");
11005 cmdline_parse_token_num_t cmd_flex_filter_port_id =
11006 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
11008 cmdline_parse_token_string_t cmd_flex_filter_ops =
11009 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
11011 cmdline_parse_token_string_t cmd_flex_filter_len =
11012 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
11014 cmdline_parse_token_num_t cmd_flex_filter_len_value =
11015 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
11017 cmdline_parse_token_string_t cmd_flex_filter_bytes =
11018 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
11020 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
11021 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
11022 bytes_value, NULL);
11023 cmdline_parse_token_string_t cmd_flex_filter_mask =
11024 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
11026 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
11027 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
11029 cmdline_parse_token_string_t cmd_flex_filter_priority =
11030 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
11031 priority, "priority");
11032 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
11033 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
11034 priority_value, UINT8);
11035 cmdline_parse_token_string_t cmd_flex_filter_queue =
11036 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
11038 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
11039 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
11041 cmdline_parse_inst_t cmd_flex_filter = {
11042 .f = cmd_flex_filter_parsed,
11044 .help_str = "flex_filter <port_id> add|del len <value> bytes "
11045 "<value> mask <value> priority <value> queue <queue_id>: "
11046 "Add/Del a flex filter",
11048 (void *)&cmd_flex_filter_filter,
11049 (void *)&cmd_flex_filter_port_id,
11050 (void *)&cmd_flex_filter_ops,
11051 (void *)&cmd_flex_filter_len,
11052 (void *)&cmd_flex_filter_len_value,
11053 (void *)&cmd_flex_filter_bytes,
11054 (void *)&cmd_flex_filter_bytes_value,
11055 (void *)&cmd_flex_filter_mask,
11056 (void *)&cmd_flex_filter_mask_value,
11057 (void *)&cmd_flex_filter_priority,
11058 (void *)&cmd_flex_filter_priority_value,
11059 (void *)&cmd_flex_filter_queue,
11060 (void *)&cmd_flex_filter_queue_id,
11065 /* *** Filters Control *** */
11067 /* *** deal with flow director filter *** */
11068 struct cmd_flow_director_result {
11069 cmdline_fixed_string_t flow_director_filter;
11071 cmdline_fixed_string_t mode;
11072 cmdline_fixed_string_t mode_value;
11073 cmdline_fixed_string_t ops;
11074 cmdline_fixed_string_t flow;
11075 cmdline_fixed_string_t flow_type;
11076 cmdline_fixed_string_t ether;
11077 uint16_t ether_type;
11078 cmdline_fixed_string_t src;
11079 cmdline_ipaddr_t ip_src;
11081 cmdline_fixed_string_t dst;
11082 cmdline_ipaddr_t ip_dst;
11084 cmdline_fixed_string_t verify_tag;
11085 uint32_t verify_tag_value;
11086 cmdline_fixed_string_t tos;
11088 cmdline_fixed_string_t proto;
11089 uint8_t proto_value;
11090 cmdline_fixed_string_t ttl;
11092 cmdline_fixed_string_t vlan;
11093 uint16_t vlan_value;
11094 cmdline_fixed_string_t flexbytes;
11095 cmdline_fixed_string_t flexbytes_value;
11096 cmdline_fixed_string_t pf_vf;
11097 cmdline_fixed_string_t drop;
11098 cmdline_fixed_string_t queue;
11100 cmdline_fixed_string_t fd_id;
11101 uint32_t fd_id_value;
11102 cmdline_fixed_string_t mac;
11103 struct rte_ether_addr mac_addr;
11104 cmdline_fixed_string_t tunnel;
11105 cmdline_fixed_string_t tunnel_type;
11106 cmdline_fixed_string_t tunnel_id;
11107 uint32_t tunnel_id_value;
11108 cmdline_fixed_string_t packet;
11113 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
11116 const char *p, *p0 = q_arg;
11118 unsigned long int_fld;
11119 char *str_fld[max_num];
11124 p = strchr(p0, '(');
11128 p0 = strchr(p, ')');
11133 if (size >= sizeof(s))
11136 snprintf(s, sizeof(s), "%.*s", size, p);
11137 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
11138 if (ret < 0 || ret > max_num)
11140 for (i = 0; i < ret; i++) {
11142 int_fld = strtoul(str_fld[i], &end, 0);
11143 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
11145 flexbytes[i] = (uint8_t)int_fld;
11151 str2flowtype(char *string)
11154 static const struct {
11157 } flowtype_str[] = {
11158 {"raw", RTE_ETH_FLOW_RAW},
11159 {"ipv4", RTE_ETH_FLOW_IPV4},
11160 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
11161 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
11162 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
11163 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
11164 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
11165 {"ipv6", RTE_ETH_FLOW_IPV6},
11166 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
11167 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
11168 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
11169 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
11170 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
11171 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
11174 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
11175 if (!strcmp(flowtype_str[i].str, string))
11176 return flowtype_str[i].type;
11179 if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64)
11180 return (uint16_t)atoi(string);
11182 return RTE_ETH_FLOW_UNKNOWN;
11185 static enum rte_eth_fdir_tunnel_type
11186 str2fdir_tunneltype(char *string)
11190 static const struct {
11192 enum rte_eth_fdir_tunnel_type type;
11193 } tunneltype_str[] = {
11194 {"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE},
11195 {"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN},
11198 for (i = 0; i < RTE_DIM(tunneltype_str); i++) {
11199 if (!strcmp(tunneltype_str[i].str, string))
11200 return tunneltype_str[i].type;
11202 return RTE_FDIR_TUNNEL_TYPE_UNKNOWN;
11205 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
11207 if ((ip_addr).family == AF_INET) \
11208 (ip) = (ip_addr).addr.ipv4.s_addr; \
11210 printf("invalid parameter.\n"); \
11215 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
11217 if ((ip_addr).family == AF_INET6) \
11218 rte_memcpy(&(ip), \
11219 &((ip_addr).addr.ipv6), \
11220 sizeof(struct in6_addr)); \
11222 printf("invalid parameter.\n"); \
11228 cmd_flow_director_filter_parsed(void *parsed_result,
11229 __rte_unused struct cmdline *cl,
11230 __rte_unused void *data)
11232 struct cmd_flow_director_result *res = parsed_result;
11233 struct rte_eth_fdir_filter entry;
11234 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
11236 unsigned long vf_id;
11239 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
11241 printf("flow director is not supported on port %u.\n",
11245 memset(flexbytes, 0, sizeof(flexbytes));
11246 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
11248 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
11249 if (strcmp(res->mode_value, "MAC-VLAN")) {
11250 printf("Please set mode to MAC-VLAN.\n");
11253 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
11254 if (strcmp(res->mode_value, "Tunnel")) {
11255 printf("Please set mode to Tunnel.\n");
11259 if (!strcmp(res->mode_value, "raw")) {
11260 #ifdef RTE_NET_I40E
11261 struct rte_pmd_i40e_flow_type_mapping
11262 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
11263 struct rte_pmd_i40e_pkt_template_conf conf;
11264 uint16_t flow_type = str2flowtype(res->flow_type);
11265 uint16_t i, port = res->port_id;
11268 memset(&conf, 0, sizeof(conf));
11270 if (flow_type == RTE_ETH_FLOW_UNKNOWN) {
11271 printf("Invalid flow type specified.\n");
11274 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id,
11278 if (mapping[flow_type].pctype == 0ULL) {
11279 printf("Invalid flow type specified.\n");
11282 for (i = 0; i < RTE_PMD_I40E_PCTYPE_MAX; i++) {
11283 if (mapping[flow_type].pctype & (1ULL << i)) {
11284 conf.input.pctype = i;
11289 conf.input.packet = open_file(res->filepath,
11290 &conf.input.length);
11291 if (!conf.input.packet)
11293 if (!strcmp(res->drop, "drop"))
11294 conf.action.behavior =
11295 RTE_PMD_I40E_PKT_TEMPLATE_REJECT;
11297 conf.action.behavior =
11298 RTE_PMD_I40E_PKT_TEMPLATE_ACCEPT;
11299 conf.action.report_status =
11300 RTE_PMD_I40E_PKT_TEMPLATE_REPORT_ID;
11301 conf.action.rx_queue = res->queue_id;
11302 conf.soft_id = res->fd_id_value;
11303 add = strcmp(res->ops, "del") ? 1 : 0;
11304 ret = rte_pmd_i40e_flow_add_del_packet_template(port,
11308 printf("flow director config error: (%s)\n",
11310 close_file(conf.input.packet);
11313 } else if (strcmp(res->mode_value, "IP")) {
11314 printf("Please set mode to IP or raw.\n");
11317 entry.input.flow_type = str2flowtype(res->flow_type);
11320 ret = parse_flexbytes(res->flexbytes_value,
11322 RTE_ETH_FDIR_MAX_FLEXLEN);
11324 printf("error: Cannot parse flexbytes input.\n");
11328 switch (entry.input.flow_type) {
11329 case RTE_ETH_FLOW_FRAG_IPV4:
11330 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
11331 entry.input.flow.ip4_flow.proto = res->proto_value;
11333 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
11334 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
11335 IPV4_ADDR_TO_UINT(res->ip_dst,
11336 entry.input.flow.ip4_flow.dst_ip);
11337 IPV4_ADDR_TO_UINT(res->ip_src,
11338 entry.input.flow.ip4_flow.src_ip);
11339 entry.input.flow.ip4_flow.tos = res->tos_value;
11340 entry.input.flow.ip4_flow.ttl = res->ttl_value;
11341 /* need convert to big endian. */
11342 entry.input.flow.udp4_flow.dst_port =
11343 rte_cpu_to_be_16(res->port_dst);
11344 entry.input.flow.udp4_flow.src_port =
11345 rte_cpu_to_be_16(res->port_src);
11347 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
11348 IPV4_ADDR_TO_UINT(res->ip_dst,
11349 entry.input.flow.sctp4_flow.ip.dst_ip);
11350 IPV4_ADDR_TO_UINT(res->ip_src,
11351 entry.input.flow.sctp4_flow.ip.src_ip);
11352 entry.input.flow.ip4_flow.tos = res->tos_value;
11353 entry.input.flow.ip4_flow.ttl = res->ttl_value;
11354 /* need convert to big endian. */
11355 entry.input.flow.sctp4_flow.dst_port =
11356 rte_cpu_to_be_16(res->port_dst);
11357 entry.input.flow.sctp4_flow.src_port =
11358 rte_cpu_to_be_16(res->port_src);
11359 entry.input.flow.sctp4_flow.verify_tag =
11360 rte_cpu_to_be_32(res->verify_tag_value);
11362 case RTE_ETH_FLOW_FRAG_IPV6:
11363 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
11364 entry.input.flow.ipv6_flow.proto = res->proto_value;
11366 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
11367 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
11368 IPV6_ADDR_TO_ARRAY(res->ip_dst,
11369 entry.input.flow.ipv6_flow.dst_ip);
11370 IPV6_ADDR_TO_ARRAY(res->ip_src,
11371 entry.input.flow.ipv6_flow.src_ip);
11372 entry.input.flow.ipv6_flow.tc = res->tos_value;
11373 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
11374 /* need convert to big endian. */
11375 entry.input.flow.udp6_flow.dst_port =
11376 rte_cpu_to_be_16(res->port_dst);
11377 entry.input.flow.udp6_flow.src_port =
11378 rte_cpu_to_be_16(res->port_src);
11380 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
11381 IPV6_ADDR_TO_ARRAY(res->ip_dst,
11382 entry.input.flow.sctp6_flow.ip.dst_ip);
11383 IPV6_ADDR_TO_ARRAY(res->ip_src,
11384 entry.input.flow.sctp6_flow.ip.src_ip);
11385 entry.input.flow.ipv6_flow.tc = res->tos_value;
11386 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
11387 /* need convert to big endian. */
11388 entry.input.flow.sctp6_flow.dst_port =
11389 rte_cpu_to_be_16(res->port_dst);
11390 entry.input.flow.sctp6_flow.src_port =
11391 rte_cpu_to_be_16(res->port_src);
11392 entry.input.flow.sctp6_flow.verify_tag =
11393 rte_cpu_to_be_32(res->verify_tag_value);
11395 case RTE_ETH_FLOW_L2_PAYLOAD:
11396 entry.input.flow.l2_flow.ether_type =
11397 rte_cpu_to_be_16(res->ether_type);
11403 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN)
11404 rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr,
11406 sizeof(struct rte_ether_addr));
11408 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
11409 rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr,
11411 sizeof(struct rte_ether_addr));
11412 entry.input.flow.tunnel_flow.tunnel_type =
11413 str2fdir_tunneltype(res->tunnel_type);
11414 entry.input.flow.tunnel_flow.tunnel_id =
11415 rte_cpu_to_be_32(res->tunnel_id_value);
11418 rte_memcpy(entry.input.flow_ext.flexbytes,
11420 RTE_ETH_FDIR_MAX_FLEXLEN);
11422 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
11424 entry.action.flex_off = 0; /*use 0 by default */
11425 if (!strcmp(res->drop, "drop"))
11426 entry.action.behavior = RTE_ETH_FDIR_REJECT;
11428 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
11430 if (fdir_conf.mode != RTE_FDIR_MODE_PERFECT_MAC_VLAN &&
11431 fdir_conf.mode != RTE_FDIR_MODE_PERFECT_TUNNEL) {
11432 if (!strcmp(res->pf_vf, "pf"))
11433 entry.input.flow_ext.is_vf = 0;
11434 else if (!strncmp(res->pf_vf, "vf", 2)) {
11435 struct rte_eth_dev_info dev_info;
11437 ret = eth_dev_info_get_print_err(res->port_id,
11443 vf_id = strtoul(res->pf_vf + 2, &end, 10);
11444 if (errno != 0 || *end != '\0' ||
11445 vf_id >= dev_info.max_vfs) {
11446 printf("invalid parameter %s.\n", res->pf_vf);
11449 entry.input.flow_ext.is_vf = 1;
11450 entry.input.flow_ext.dst_id = (uint16_t)vf_id;
11452 printf("invalid parameter %s.\n", res->pf_vf);
11457 /* set to report FD ID by default */
11458 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
11459 entry.action.rx_queue = res->queue_id;
11460 entry.soft_id = res->fd_id_value;
11461 if (!strcmp(res->ops, "add"))
11462 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11463 RTE_ETH_FILTER_ADD, &entry);
11464 else if (!strcmp(res->ops, "del"))
11465 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11466 RTE_ETH_FILTER_DELETE, &entry);
11468 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11469 RTE_ETH_FILTER_UPDATE, &entry);
11471 printf("flow director programming error: (%s)\n",
11475 cmdline_parse_token_string_t cmd_flow_director_filter =
11476 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11477 flow_director_filter, "flow_director_filter");
11478 cmdline_parse_token_num_t cmd_flow_director_port_id =
11479 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11481 cmdline_parse_token_string_t cmd_flow_director_ops =
11482 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11483 ops, "add#del#update");
11484 cmdline_parse_token_string_t cmd_flow_director_flow =
11485 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11487 cmdline_parse_token_string_t cmd_flow_director_flow_type =
11488 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11490 cmdline_parse_token_string_t cmd_flow_director_ether =
11491 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11493 cmdline_parse_token_num_t cmd_flow_director_ether_type =
11494 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11495 ether_type, UINT16);
11496 cmdline_parse_token_string_t cmd_flow_director_src =
11497 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11499 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
11500 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
11502 cmdline_parse_token_num_t cmd_flow_director_port_src =
11503 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11505 cmdline_parse_token_string_t cmd_flow_director_dst =
11506 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11508 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
11509 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
11511 cmdline_parse_token_num_t cmd_flow_director_port_dst =
11512 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11514 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
11515 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11516 verify_tag, "verify_tag");
11517 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
11518 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11519 verify_tag_value, UINT32);
11520 cmdline_parse_token_string_t cmd_flow_director_tos =
11521 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11523 cmdline_parse_token_num_t cmd_flow_director_tos_value =
11524 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11526 cmdline_parse_token_string_t cmd_flow_director_proto =
11527 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11529 cmdline_parse_token_num_t cmd_flow_director_proto_value =
11530 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11531 proto_value, UINT8);
11532 cmdline_parse_token_string_t cmd_flow_director_ttl =
11533 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11535 cmdline_parse_token_num_t cmd_flow_director_ttl_value =
11536 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11538 cmdline_parse_token_string_t cmd_flow_director_vlan =
11539 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11541 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
11542 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11543 vlan_value, UINT16);
11544 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
11545 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11546 flexbytes, "flexbytes");
11547 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
11548 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11549 flexbytes_value, NULL);
11550 cmdline_parse_token_string_t cmd_flow_director_drop =
11551 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11553 cmdline_parse_token_string_t cmd_flow_director_pf_vf =
11554 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11556 cmdline_parse_token_string_t cmd_flow_director_queue =
11557 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11559 cmdline_parse_token_num_t cmd_flow_director_queue_id =
11560 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11562 cmdline_parse_token_string_t cmd_flow_director_fd_id =
11563 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11565 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
11566 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11567 fd_id_value, UINT32);
11569 cmdline_parse_token_string_t cmd_flow_director_mode =
11570 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11572 cmdline_parse_token_string_t cmd_flow_director_mode_ip =
11573 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11575 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan =
11576 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11577 mode_value, "MAC-VLAN");
11578 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel =
11579 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11580 mode_value, "Tunnel");
11581 cmdline_parse_token_string_t cmd_flow_director_mode_raw =
11582 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11583 mode_value, "raw");
11584 cmdline_parse_token_string_t cmd_flow_director_mac =
11585 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11587 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr =
11588 TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result,
11590 cmdline_parse_token_string_t cmd_flow_director_tunnel =
11591 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11593 cmdline_parse_token_string_t cmd_flow_director_tunnel_type =
11594 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11595 tunnel_type, "NVGRE#VxLAN");
11596 cmdline_parse_token_string_t cmd_flow_director_tunnel_id =
11597 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11598 tunnel_id, "tunnel-id");
11599 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value =
11600 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11601 tunnel_id_value, UINT32);
11602 cmdline_parse_token_string_t cmd_flow_director_packet =
11603 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11605 cmdline_parse_token_string_t cmd_flow_director_filepath =
11606 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11609 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
11610 .f = cmd_flow_director_filter_parsed,
11612 .help_str = "flow_director_filter <port_id> mode IP add|del|update flow"
11613 " ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
11614 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
11615 "l2_payload src <src_ip> dst <dst_ip> tos <tos_value> "
11616 "proto <proto_value> ttl <ttl_value> vlan <vlan_value> "
11617 "flexbytes <flexbyte_values> drop|fw <pf_vf> queue <queue_id> "
11618 "fd_id <fd_id_value>: "
11619 "Add or delete an ip flow director entry on NIC",
11621 (void *)&cmd_flow_director_filter,
11622 (void *)&cmd_flow_director_port_id,
11623 (void *)&cmd_flow_director_mode,
11624 (void *)&cmd_flow_director_mode_ip,
11625 (void *)&cmd_flow_director_ops,
11626 (void *)&cmd_flow_director_flow,
11627 (void *)&cmd_flow_director_flow_type,
11628 (void *)&cmd_flow_director_src,
11629 (void *)&cmd_flow_director_ip_src,
11630 (void *)&cmd_flow_director_dst,
11631 (void *)&cmd_flow_director_ip_dst,
11632 (void *)&cmd_flow_director_tos,
11633 (void *)&cmd_flow_director_tos_value,
11634 (void *)&cmd_flow_director_proto,
11635 (void *)&cmd_flow_director_proto_value,
11636 (void *)&cmd_flow_director_ttl,
11637 (void *)&cmd_flow_director_ttl_value,
11638 (void *)&cmd_flow_director_vlan,
11639 (void *)&cmd_flow_director_vlan_value,
11640 (void *)&cmd_flow_director_flexbytes,
11641 (void *)&cmd_flow_director_flexbytes_value,
11642 (void *)&cmd_flow_director_drop,
11643 (void *)&cmd_flow_director_pf_vf,
11644 (void *)&cmd_flow_director_queue,
11645 (void *)&cmd_flow_director_queue_id,
11646 (void *)&cmd_flow_director_fd_id,
11647 (void *)&cmd_flow_director_fd_id_value,
11652 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
11653 .f = cmd_flow_director_filter_parsed,
11655 .help_str = "flow_director_filter ... : Add or delete an udp/tcp flow "
11656 "director entry on NIC",
11658 (void *)&cmd_flow_director_filter,
11659 (void *)&cmd_flow_director_port_id,
11660 (void *)&cmd_flow_director_mode,
11661 (void *)&cmd_flow_director_mode_ip,
11662 (void *)&cmd_flow_director_ops,
11663 (void *)&cmd_flow_director_flow,
11664 (void *)&cmd_flow_director_flow_type,
11665 (void *)&cmd_flow_director_src,
11666 (void *)&cmd_flow_director_ip_src,
11667 (void *)&cmd_flow_director_port_src,
11668 (void *)&cmd_flow_director_dst,
11669 (void *)&cmd_flow_director_ip_dst,
11670 (void *)&cmd_flow_director_port_dst,
11671 (void *)&cmd_flow_director_tos,
11672 (void *)&cmd_flow_director_tos_value,
11673 (void *)&cmd_flow_director_ttl,
11674 (void *)&cmd_flow_director_ttl_value,
11675 (void *)&cmd_flow_director_vlan,
11676 (void *)&cmd_flow_director_vlan_value,
11677 (void *)&cmd_flow_director_flexbytes,
11678 (void *)&cmd_flow_director_flexbytes_value,
11679 (void *)&cmd_flow_director_drop,
11680 (void *)&cmd_flow_director_pf_vf,
11681 (void *)&cmd_flow_director_queue,
11682 (void *)&cmd_flow_director_queue_id,
11683 (void *)&cmd_flow_director_fd_id,
11684 (void *)&cmd_flow_director_fd_id_value,
11689 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
11690 .f = cmd_flow_director_filter_parsed,
11692 .help_str = "flow_director_filter ... : Add or delete a sctp flow "
11693 "director entry on NIC",
11695 (void *)&cmd_flow_director_filter,
11696 (void *)&cmd_flow_director_port_id,
11697 (void *)&cmd_flow_director_mode,
11698 (void *)&cmd_flow_director_mode_ip,
11699 (void *)&cmd_flow_director_ops,
11700 (void *)&cmd_flow_director_flow,
11701 (void *)&cmd_flow_director_flow_type,
11702 (void *)&cmd_flow_director_src,
11703 (void *)&cmd_flow_director_ip_src,
11704 (void *)&cmd_flow_director_port_src,
11705 (void *)&cmd_flow_director_dst,
11706 (void *)&cmd_flow_director_ip_dst,
11707 (void *)&cmd_flow_director_port_dst,
11708 (void *)&cmd_flow_director_verify_tag,
11709 (void *)&cmd_flow_director_verify_tag_value,
11710 (void *)&cmd_flow_director_tos,
11711 (void *)&cmd_flow_director_tos_value,
11712 (void *)&cmd_flow_director_ttl,
11713 (void *)&cmd_flow_director_ttl_value,
11714 (void *)&cmd_flow_director_vlan,
11715 (void *)&cmd_flow_director_vlan_value,
11716 (void *)&cmd_flow_director_flexbytes,
11717 (void *)&cmd_flow_director_flexbytes_value,
11718 (void *)&cmd_flow_director_drop,
11719 (void *)&cmd_flow_director_pf_vf,
11720 (void *)&cmd_flow_director_queue,
11721 (void *)&cmd_flow_director_queue_id,
11722 (void *)&cmd_flow_director_fd_id,
11723 (void *)&cmd_flow_director_fd_id_value,
11728 cmdline_parse_inst_t cmd_add_del_l2_flow_director = {
11729 .f = cmd_flow_director_filter_parsed,
11731 .help_str = "flow_director_filter ... : Add or delete a L2 flow "
11732 "director entry on NIC",
11734 (void *)&cmd_flow_director_filter,
11735 (void *)&cmd_flow_director_port_id,
11736 (void *)&cmd_flow_director_mode,
11737 (void *)&cmd_flow_director_mode_ip,
11738 (void *)&cmd_flow_director_ops,
11739 (void *)&cmd_flow_director_flow,
11740 (void *)&cmd_flow_director_flow_type,
11741 (void *)&cmd_flow_director_ether,
11742 (void *)&cmd_flow_director_ether_type,
11743 (void *)&cmd_flow_director_flexbytes,
11744 (void *)&cmd_flow_director_flexbytes_value,
11745 (void *)&cmd_flow_director_drop,
11746 (void *)&cmd_flow_director_pf_vf,
11747 (void *)&cmd_flow_director_queue,
11748 (void *)&cmd_flow_director_queue_id,
11749 (void *)&cmd_flow_director_fd_id,
11750 (void *)&cmd_flow_director_fd_id_value,
11755 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = {
11756 .f = cmd_flow_director_filter_parsed,
11758 .help_str = "flow_director_filter ... : Add or delete a MAC VLAN flow "
11759 "director entry on NIC",
11761 (void *)&cmd_flow_director_filter,
11762 (void *)&cmd_flow_director_port_id,
11763 (void *)&cmd_flow_director_mode,
11764 (void *)&cmd_flow_director_mode_mac_vlan,
11765 (void *)&cmd_flow_director_ops,
11766 (void *)&cmd_flow_director_mac,
11767 (void *)&cmd_flow_director_mac_addr,
11768 (void *)&cmd_flow_director_vlan,
11769 (void *)&cmd_flow_director_vlan_value,
11770 (void *)&cmd_flow_director_flexbytes,
11771 (void *)&cmd_flow_director_flexbytes_value,
11772 (void *)&cmd_flow_director_drop,
11773 (void *)&cmd_flow_director_queue,
11774 (void *)&cmd_flow_director_queue_id,
11775 (void *)&cmd_flow_director_fd_id,
11776 (void *)&cmd_flow_director_fd_id_value,
11781 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = {
11782 .f = cmd_flow_director_filter_parsed,
11784 .help_str = "flow_director_filter ... : Add or delete a tunnel flow "
11785 "director entry on NIC",
11787 (void *)&cmd_flow_director_filter,
11788 (void *)&cmd_flow_director_port_id,
11789 (void *)&cmd_flow_director_mode,
11790 (void *)&cmd_flow_director_mode_tunnel,
11791 (void *)&cmd_flow_director_ops,
11792 (void *)&cmd_flow_director_mac,
11793 (void *)&cmd_flow_director_mac_addr,
11794 (void *)&cmd_flow_director_vlan,
11795 (void *)&cmd_flow_director_vlan_value,
11796 (void *)&cmd_flow_director_tunnel,
11797 (void *)&cmd_flow_director_tunnel_type,
11798 (void *)&cmd_flow_director_tunnel_id,
11799 (void *)&cmd_flow_director_tunnel_id_value,
11800 (void *)&cmd_flow_director_flexbytes,
11801 (void *)&cmd_flow_director_flexbytes_value,
11802 (void *)&cmd_flow_director_drop,
11803 (void *)&cmd_flow_director_queue,
11804 (void *)&cmd_flow_director_queue_id,
11805 (void *)&cmd_flow_director_fd_id,
11806 (void *)&cmd_flow_director_fd_id_value,
11811 cmdline_parse_inst_t cmd_add_del_raw_flow_director = {
11812 .f = cmd_flow_director_filter_parsed,
11814 .help_str = "flow_director_filter ... : Add or delete a raw flow "
11815 "director entry on NIC",
11817 (void *)&cmd_flow_director_filter,
11818 (void *)&cmd_flow_director_port_id,
11819 (void *)&cmd_flow_director_mode,
11820 (void *)&cmd_flow_director_mode_raw,
11821 (void *)&cmd_flow_director_ops,
11822 (void *)&cmd_flow_director_flow,
11823 (void *)&cmd_flow_director_flow_type,
11824 (void *)&cmd_flow_director_drop,
11825 (void *)&cmd_flow_director_queue,
11826 (void *)&cmd_flow_director_queue_id,
11827 (void *)&cmd_flow_director_fd_id,
11828 (void *)&cmd_flow_director_fd_id_value,
11829 (void *)&cmd_flow_director_packet,
11830 (void *)&cmd_flow_director_filepath,
11835 struct cmd_flush_flow_director_result {
11836 cmdline_fixed_string_t flush_flow_director;
11840 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
11841 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
11842 flush_flow_director, "flush_flow_director");
11843 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
11844 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
11848 cmd_flush_flow_director_parsed(void *parsed_result,
11849 __rte_unused struct cmdline *cl,
11850 __rte_unused void *data)
11852 struct cmd_flow_director_result *res = parsed_result;
11855 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
11857 printf("flow director is not supported on port %u.\n",
11862 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11863 RTE_ETH_FILTER_FLUSH, NULL);
11865 printf("flow director table flushing error: (%s)\n",
11869 cmdline_parse_inst_t cmd_flush_flow_director = {
11870 .f = cmd_flush_flow_director_parsed,
11872 .help_str = "flush_flow_director <port_id>: "
11873 "Flush all flow director entries of a device on NIC",
11875 (void *)&cmd_flush_flow_director_flush,
11876 (void *)&cmd_flush_flow_director_port_id,
11881 /* *** deal with flow director mask *** */
11882 struct cmd_flow_director_mask_result {
11883 cmdline_fixed_string_t flow_director_mask;
11885 cmdline_fixed_string_t mode;
11886 cmdline_fixed_string_t mode_value;
11887 cmdline_fixed_string_t vlan;
11888 uint16_t vlan_mask;
11889 cmdline_fixed_string_t src_mask;
11890 cmdline_ipaddr_t ipv4_src;
11891 cmdline_ipaddr_t ipv6_src;
11893 cmdline_fixed_string_t dst_mask;
11894 cmdline_ipaddr_t ipv4_dst;
11895 cmdline_ipaddr_t ipv6_dst;
11897 cmdline_fixed_string_t mac;
11898 uint8_t mac_addr_byte_mask;
11899 cmdline_fixed_string_t tunnel_id;
11900 uint32_t tunnel_id_mask;
11901 cmdline_fixed_string_t tunnel_type;
11902 uint8_t tunnel_type_mask;
11906 cmd_flow_director_mask_parsed(void *parsed_result,
11907 __rte_unused struct cmdline *cl,
11908 __rte_unused void *data)
11910 struct cmd_flow_director_mask_result *res = parsed_result;
11911 struct rte_eth_fdir_masks *mask;
11912 struct rte_port *port;
11914 port = &ports[res->port_id];
11915 /** Check if the port is not started **/
11916 if (port->port_status != RTE_PORT_STOPPED) {
11917 printf("Please stop port %d first\n", res->port_id);
11921 mask = &port->dev_conf.fdir_conf.mask;
11923 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
11924 if (strcmp(res->mode_value, "MAC-VLAN")) {
11925 printf("Please set mode to MAC-VLAN.\n");
11929 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11930 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
11931 if (strcmp(res->mode_value, "Tunnel")) {
11932 printf("Please set mode to Tunnel.\n");
11936 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11937 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
11938 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
11939 mask->tunnel_type_mask = res->tunnel_type_mask;
11941 if (strcmp(res->mode_value, "IP")) {
11942 printf("Please set mode to IP.\n");
11946 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11947 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
11948 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
11949 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
11950 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
11951 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
11952 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
11955 cmd_reconfig_device_queue(res->port_id, 1, 1);
11958 cmdline_parse_token_string_t cmd_flow_director_mask =
11959 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11960 flow_director_mask, "flow_director_mask");
11961 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
11962 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11964 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
11965 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11967 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
11968 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11969 vlan_mask, UINT16);
11970 cmdline_parse_token_string_t cmd_flow_director_mask_src =
11971 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11972 src_mask, "src_mask");
11973 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
11974 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11976 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
11977 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11979 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
11980 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11982 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
11983 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11984 dst_mask, "dst_mask");
11985 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
11986 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11988 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
11989 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11991 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
11992 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11995 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
11996 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11998 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
11999 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
12001 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
12002 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
12003 mode_value, "MAC-VLAN");
12004 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
12005 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
12006 mode_value, "Tunnel");
12007 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
12008 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
12010 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
12011 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
12012 mac_addr_byte_mask, UINT8);
12013 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
12014 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
12015 tunnel_type, "tunnel-type");
12016 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
12017 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
12018 tunnel_type_mask, UINT8);
12019 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
12020 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
12021 tunnel_id, "tunnel-id");
12022 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
12023 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
12024 tunnel_id_mask, UINT32);
12026 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
12027 .f = cmd_flow_director_mask_parsed,
12029 .help_str = "flow_director_mask ... : "
12030 "Set IP mode flow director's mask on NIC",
12032 (void *)&cmd_flow_director_mask,
12033 (void *)&cmd_flow_director_mask_port_id,
12034 (void *)&cmd_flow_director_mask_mode,
12035 (void *)&cmd_flow_director_mask_mode_ip,
12036 (void *)&cmd_flow_director_mask_vlan,
12037 (void *)&cmd_flow_director_mask_vlan_value,
12038 (void *)&cmd_flow_director_mask_src,
12039 (void *)&cmd_flow_director_mask_ipv4_src,
12040 (void *)&cmd_flow_director_mask_ipv6_src,
12041 (void *)&cmd_flow_director_mask_port_src,
12042 (void *)&cmd_flow_director_mask_dst,
12043 (void *)&cmd_flow_director_mask_ipv4_dst,
12044 (void *)&cmd_flow_director_mask_ipv6_dst,
12045 (void *)&cmd_flow_director_mask_port_dst,
12050 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
12051 .f = cmd_flow_director_mask_parsed,
12053 .help_str = "flow_director_mask ... : Set MAC VLAN mode "
12054 "flow director's mask on NIC",
12056 (void *)&cmd_flow_director_mask,
12057 (void *)&cmd_flow_director_mask_port_id,
12058 (void *)&cmd_flow_director_mask_mode,
12059 (void *)&cmd_flow_director_mask_mode_mac_vlan,
12060 (void *)&cmd_flow_director_mask_vlan,
12061 (void *)&cmd_flow_director_mask_vlan_value,
12066 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
12067 .f = cmd_flow_director_mask_parsed,
12069 .help_str = "flow_director_mask ... : Set tunnel mode "
12070 "flow director's mask on NIC",
12072 (void *)&cmd_flow_director_mask,
12073 (void *)&cmd_flow_director_mask_port_id,
12074 (void *)&cmd_flow_director_mask_mode,
12075 (void *)&cmd_flow_director_mask_mode_tunnel,
12076 (void *)&cmd_flow_director_mask_vlan,
12077 (void *)&cmd_flow_director_mask_vlan_value,
12078 (void *)&cmd_flow_director_mask_mac,
12079 (void *)&cmd_flow_director_mask_mac_value,
12080 (void *)&cmd_flow_director_mask_tunnel_type,
12081 (void *)&cmd_flow_director_mask_tunnel_type_value,
12082 (void *)&cmd_flow_director_mask_tunnel_id,
12083 (void *)&cmd_flow_director_mask_tunnel_id_value,
12088 /* *** deal with flow director mask on flexible payload *** */
12089 struct cmd_flow_director_flex_mask_result {
12090 cmdline_fixed_string_t flow_director_flexmask;
12092 cmdline_fixed_string_t flow;
12093 cmdline_fixed_string_t flow_type;
12094 cmdline_fixed_string_t mask;
12098 cmd_flow_director_flex_mask_parsed(void *parsed_result,
12099 __rte_unused struct cmdline *cl,
12100 __rte_unused void *data)
12102 struct cmd_flow_director_flex_mask_result *res = parsed_result;
12103 struct rte_eth_fdir_info fdir_info;
12104 struct rte_eth_fdir_flex_mask flex_mask;
12105 struct rte_port *port;
12106 uint64_t flow_type_mask;
12110 port = &ports[res->port_id];
12111 /** Check if the port is not started **/
12112 if (port->port_status != RTE_PORT_STOPPED) {
12113 printf("Please stop port %d first\n", res->port_id);
12117 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
12118 ret = parse_flexbytes(res->mask,
12120 RTE_ETH_FDIR_MAX_FLEXLEN);
12122 printf("error: Cannot parse mask input.\n");
12126 memset(&fdir_info, 0, sizeof(fdir_info));
12127 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
12128 RTE_ETH_FILTER_INFO, &fdir_info);
12130 printf("Cannot get FDir filter info\n");
12134 if (!strcmp(res->flow_type, "none")) {
12135 /* means don't specify the flow type */
12136 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN;
12137 for (i = 0; i < RTE_ETH_FLOW_MAX; i++)
12138 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i],
12139 0, sizeof(struct rte_eth_fdir_flex_mask));
12140 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1;
12141 rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0],
12143 sizeof(struct rte_eth_fdir_flex_mask));
12144 cmd_reconfig_device_queue(res->port_id, 1, 1);
12147 flow_type_mask = fdir_info.flow_types_mask[0];
12148 if (!strcmp(res->flow_type, "all")) {
12149 if (!flow_type_mask) {
12150 printf("No flow type supported\n");
12153 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
12154 if (flow_type_mask & (1ULL << i)) {
12155 flex_mask.flow_type = i;
12156 fdir_set_flex_mask(res->port_id, &flex_mask);
12159 cmd_reconfig_device_queue(res->port_id, 1, 1);
12162 flex_mask.flow_type = str2flowtype(res->flow_type);
12163 if (!(flow_type_mask & (1ULL << flex_mask.flow_type))) {
12164 printf("Flow type %s not supported on port %d\n",
12165 res->flow_type, res->port_id);
12168 fdir_set_flex_mask(res->port_id, &flex_mask);
12169 cmd_reconfig_device_queue(res->port_id, 1, 1);
12172 cmdline_parse_token_string_t cmd_flow_director_flexmask =
12173 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
12174 flow_director_flexmask,
12175 "flow_director_flex_mask");
12176 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
12177 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
12179 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
12180 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
12182 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
12183 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
12184 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
12185 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all");
12186 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
12187 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
12190 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
12191 .f = cmd_flow_director_flex_mask_parsed,
12193 .help_str = "flow_director_flex_mask ... : "
12194 "Set flow director's flex mask on NIC",
12196 (void *)&cmd_flow_director_flexmask,
12197 (void *)&cmd_flow_director_flexmask_port_id,
12198 (void *)&cmd_flow_director_flexmask_flow,
12199 (void *)&cmd_flow_director_flexmask_flow_type,
12200 (void *)&cmd_flow_director_flexmask_mask,
12205 /* *** deal with flow director flexible payload configuration *** */
12206 struct cmd_flow_director_flexpayload_result {
12207 cmdline_fixed_string_t flow_director_flexpayload;
12209 cmdline_fixed_string_t payload_layer;
12210 cmdline_fixed_string_t payload_cfg;
12214 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
12217 const char *p, *p0 = q_arg;
12219 unsigned long int_fld;
12220 char *str_fld[max_num];
12225 p = strchr(p0, '(');
12229 p0 = strchr(p, ')');
12234 if (size >= sizeof(s))
12237 snprintf(s, sizeof(s), "%.*s", size, p);
12238 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
12239 if (ret < 0 || ret > max_num)
12241 for (i = 0; i < ret; i++) {
12243 int_fld = strtoul(str_fld[i], &end, 0);
12244 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
12246 offsets[i] = (uint16_t)int_fld;
12252 cmd_flow_director_flxpld_parsed(void *parsed_result,
12253 __rte_unused struct cmdline *cl,
12254 __rte_unused void *data)
12256 struct cmd_flow_director_flexpayload_result *res = parsed_result;
12257 struct rte_eth_flex_payload_cfg flex_cfg;
12258 struct rte_port *port;
12261 port = &ports[res->port_id];
12262 /** Check if the port is not started **/
12263 if (port->port_status != RTE_PORT_STOPPED) {
12264 printf("Please stop port %d first\n", res->port_id);
12268 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
12270 if (!strcmp(res->payload_layer, "raw"))
12271 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
12272 else if (!strcmp(res->payload_layer, "l2"))
12273 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
12274 else if (!strcmp(res->payload_layer, "l3"))
12275 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
12276 else if (!strcmp(res->payload_layer, "l4"))
12277 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
12279 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
12280 RTE_ETH_FDIR_MAX_FLEXLEN);
12282 printf("error: Cannot parse flex payload input.\n");
12286 fdir_set_flex_payload(res->port_id, &flex_cfg);
12287 cmd_reconfig_device_queue(res->port_id, 1, 1);
12290 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
12291 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
12292 flow_director_flexpayload,
12293 "flow_director_flex_payload");
12294 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
12295 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
12297 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
12298 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
12299 payload_layer, "raw#l2#l3#l4");
12300 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
12301 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
12302 payload_cfg, NULL);
12304 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
12305 .f = cmd_flow_director_flxpld_parsed,
12307 .help_str = "flow_director_flexpayload ... : "
12308 "Set flow director's flex payload on NIC",
12310 (void *)&cmd_flow_director_flexpayload,
12311 (void *)&cmd_flow_director_flexpayload_port_id,
12312 (void *)&cmd_flow_director_flexpayload_payload_layer,
12313 (void *)&cmd_flow_director_flexpayload_payload_cfg,
12318 /* Generic flow interface command. */
12319 extern cmdline_parse_inst_t cmd_flow;
12321 /* *** Classification Filters Control *** */
12322 /* *** Get symmetric hash enable per port *** */
12323 struct cmd_get_sym_hash_ena_per_port_result {
12324 cmdline_fixed_string_t get_sym_hash_ena_per_port;
12329 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
12330 __rte_unused struct cmdline *cl,
12331 __rte_unused void *data)
12333 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
12334 struct rte_eth_hash_filter_info info;
12337 if (rte_eth_dev_filter_supported(res->port_id,
12338 RTE_ETH_FILTER_HASH) < 0) {
12339 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
12344 memset(&info, 0, sizeof(info));
12345 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
12346 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12347 RTE_ETH_FILTER_GET, &info);
12350 printf("Cannot get symmetric hash enable per port "
12351 "on port %u\n", res->port_id);
12355 printf("Symmetric hash is %s on port %u\n", info.info.enable ?
12356 "enabled" : "disabled", res->port_id);
12359 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
12360 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
12361 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
12362 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
12363 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
12366 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
12367 .f = cmd_get_sym_hash_per_port_parsed,
12369 .help_str = "get_sym_hash_ena_per_port <port_id>",
12371 (void *)&cmd_get_sym_hash_ena_per_port_all,
12372 (void *)&cmd_get_sym_hash_ena_per_port_port_id,
12377 /* *** Set symmetric hash enable per port *** */
12378 struct cmd_set_sym_hash_ena_per_port_result {
12379 cmdline_fixed_string_t set_sym_hash_ena_per_port;
12380 cmdline_fixed_string_t enable;
12385 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
12386 __rte_unused struct cmdline *cl,
12387 __rte_unused void *data)
12389 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
12390 struct rte_eth_hash_filter_info info;
12393 if (rte_eth_dev_filter_supported(res->port_id,
12394 RTE_ETH_FILTER_HASH) < 0) {
12395 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
12400 memset(&info, 0, sizeof(info));
12401 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
12402 if (!strcmp(res->enable, "enable"))
12403 info.info.enable = 1;
12404 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12405 RTE_ETH_FILTER_SET, &info);
12407 printf("Cannot set symmetric hash enable per port on "
12408 "port %u\n", res->port_id);
12411 printf("Symmetric hash has been set to %s on port %u\n",
12412 res->enable, res->port_id);
12415 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
12416 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
12417 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
12418 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
12419 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
12421 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
12422 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
12423 enable, "enable#disable");
12425 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
12426 .f = cmd_set_sym_hash_per_port_parsed,
12428 .help_str = "set_sym_hash_ena_per_port <port_id> enable|disable",
12430 (void *)&cmd_set_sym_hash_ena_per_port_all,
12431 (void *)&cmd_set_sym_hash_ena_per_port_port_id,
12432 (void *)&cmd_set_sym_hash_ena_per_port_enable,
12437 /* Get global config of hash function */
12438 struct cmd_get_hash_global_config_result {
12439 cmdline_fixed_string_t get_hash_global_config;
12444 flowtype_to_str(uint16_t ftype)
12450 } ftype_table[] = {
12451 {"ipv4", RTE_ETH_FLOW_IPV4},
12452 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
12453 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
12454 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
12455 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
12456 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
12457 {"ipv6", RTE_ETH_FLOW_IPV6},
12458 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
12459 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
12460 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
12461 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
12462 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
12463 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
12464 {"port", RTE_ETH_FLOW_PORT},
12465 {"vxlan", RTE_ETH_FLOW_VXLAN},
12466 {"geneve", RTE_ETH_FLOW_GENEVE},
12467 {"nvgre", RTE_ETH_FLOW_NVGRE},
12468 {"vxlan-gpe", RTE_ETH_FLOW_VXLAN_GPE},
12471 for (i = 0; i < RTE_DIM(ftype_table); i++) {
12472 if (ftype_table[i].ftype == ftype)
12473 return ftype_table[i].str;
12480 cmd_get_hash_global_config_parsed(void *parsed_result,
12481 __rte_unused struct cmdline *cl,
12482 __rte_unused void *data)
12484 struct cmd_get_hash_global_config_result *res = parsed_result;
12485 struct rte_eth_hash_filter_info info;
12486 uint32_t idx, offset;
12491 if (rte_eth_dev_filter_supported(res->port_id,
12492 RTE_ETH_FILTER_HASH) < 0) {
12493 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
12498 memset(&info, 0, sizeof(info));
12499 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
12500 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12501 RTE_ETH_FILTER_GET, &info);
12503 printf("Cannot get hash global configurations by port %d\n",
12508 switch (info.info.global_conf.hash_func) {
12509 case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
12510 printf("Hash function is Toeplitz\n");
12512 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
12513 printf("Hash function is Simple XOR\n");
12515 case RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ:
12516 printf("Hash function is Symmetric Toeplitz\n");
12519 printf("Unknown hash function\n");
12523 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) {
12524 idx = i / UINT64_BIT;
12525 offset = i % UINT64_BIT;
12526 if (!(info.info.global_conf.valid_bit_mask[idx] &
12529 str = flowtype_to_str(i);
12532 printf("Symmetric hash is %s globally for flow type %s "
12534 ((info.info.global_conf.sym_hash_enable_mask[idx] &
12535 (1ULL << offset)) ? "enabled" : "disabled"), str,
12540 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
12541 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
12542 get_hash_global_config, "get_hash_global_config");
12543 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
12544 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
12547 cmdline_parse_inst_t cmd_get_hash_global_config = {
12548 .f = cmd_get_hash_global_config_parsed,
12550 .help_str = "get_hash_global_config <port_id>",
12552 (void *)&cmd_get_hash_global_config_all,
12553 (void *)&cmd_get_hash_global_config_port_id,
12558 /* Set global config of hash function */
12559 struct cmd_set_hash_global_config_result {
12560 cmdline_fixed_string_t set_hash_global_config;
12562 cmdline_fixed_string_t hash_func;
12563 cmdline_fixed_string_t flow_type;
12564 cmdline_fixed_string_t enable;
12568 cmd_set_hash_global_config_parsed(void *parsed_result,
12569 __rte_unused struct cmdline *cl,
12570 __rte_unused void *data)
12572 struct cmd_set_hash_global_config_result *res = parsed_result;
12573 struct rte_eth_hash_filter_info info;
12574 uint32_t ftype, idx, offset;
12577 if (rte_eth_dev_filter_supported(res->port_id,
12578 RTE_ETH_FILTER_HASH) < 0) {
12579 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
12583 memset(&info, 0, sizeof(info));
12584 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
12585 if (!strcmp(res->hash_func, "toeplitz"))
12586 info.info.global_conf.hash_func =
12587 RTE_ETH_HASH_FUNCTION_TOEPLITZ;
12588 else if (!strcmp(res->hash_func, "simple_xor"))
12589 info.info.global_conf.hash_func =
12590 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
12591 else if (!strcmp(res->hash_func, "symmetric_toeplitz"))
12592 info.info.global_conf.hash_func =
12593 RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ;
12594 else if (!strcmp(res->hash_func, "default"))
12595 info.info.global_conf.hash_func =
12596 RTE_ETH_HASH_FUNCTION_DEFAULT;
12598 ftype = str2flowtype(res->flow_type);
12599 idx = ftype / UINT64_BIT;
12600 offset = ftype % UINT64_BIT;
12601 info.info.global_conf.valid_bit_mask[idx] |= (1ULL << offset);
12602 if (!strcmp(res->enable, "enable"))
12603 info.info.global_conf.sym_hash_enable_mask[idx] |=
12605 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12606 RTE_ETH_FILTER_SET, &info);
12608 printf("Cannot set global hash configurations by port %d\n",
12611 printf("Global hash configurations have been set "
12612 "successfully by port %d\n", res->port_id);
12615 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
12616 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12617 set_hash_global_config, "set_hash_global_config");
12618 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
12619 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
12621 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
12622 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12623 hash_func, "toeplitz#simple_xor#symmetric_toeplitz#default");
12624 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
12625 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12627 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
12628 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
12629 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
12630 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12631 enable, "enable#disable");
12633 cmdline_parse_inst_t cmd_set_hash_global_config = {
12634 .f = cmd_set_hash_global_config_parsed,
12636 .help_str = "set_hash_global_config <port_id> "
12637 "toeplitz|simple_xor|symmetric_toeplitz|default "
12638 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12639 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
12640 "l2_payload enable|disable",
12642 (void *)&cmd_set_hash_global_config_all,
12643 (void *)&cmd_set_hash_global_config_port_id,
12644 (void *)&cmd_set_hash_global_config_hash_func,
12645 (void *)&cmd_set_hash_global_config_flow_type,
12646 (void *)&cmd_set_hash_global_config_enable,
12651 /* Set hash input set */
12652 struct cmd_set_hash_input_set_result {
12653 cmdline_fixed_string_t set_hash_input_set;
12655 cmdline_fixed_string_t flow_type;
12656 cmdline_fixed_string_t inset_field;
12657 cmdline_fixed_string_t select;
12660 static enum rte_eth_input_set_field
12661 str2inset(char *string)
12665 static const struct {
12667 enum rte_eth_input_set_field inset;
12668 } inset_table[] = {
12669 {"ethertype", RTE_ETH_INPUT_SET_L2_ETHERTYPE},
12670 {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN},
12671 {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN},
12672 {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4},
12673 {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4},
12674 {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS},
12675 {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO},
12676 {"ipv4-ttl", RTE_ETH_INPUT_SET_L3_IP4_TTL},
12677 {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6},
12678 {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6},
12679 {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC},
12680 {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER},
12681 {"ipv6-hop-limits", RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS},
12682 {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT},
12683 {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT},
12684 {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT},
12685 {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT},
12686 {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT},
12687 {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT},
12688 {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG},
12689 {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY},
12690 {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY},
12691 {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD},
12692 {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD},
12693 {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD},
12694 {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD},
12695 {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD},
12696 {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD},
12697 {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD},
12698 {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD},
12699 {"none", RTE_ETH_INPUT_SET_NONE},
12702 for (i = 0; i < RTE_DIM(inset_table); i++) {
12703 if (!strcmp(string, inset_table[i].str))
12704 return inset_table[i].inset;
12707 return RTE_ETH_INPUT_SET_UNKNOWN;
12711 cmd_set_hash_input_set_parsed(void *parsed_result,
12712 __rte_unused struct cmdline *cl,
12713 __rte_unused void *data)
12715 struct cmd_set_hash_input_set_result *res = parsed_result;
12716 struct rte_eth_hash_filter_info info;
12718 memset(&info, 0, sizeof(info));
12719 info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT;
12720 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
12721 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
12722 info.info.input_set_conf.inset_size = 1;
12723 if (!strcmp(res->select, "select"))
12724 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
12725 else if (!strcmp(res->select, "add"))
12726 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
12727 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12728 RTE_ETH_FILTER_SET, &info);
12731 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd =
12732 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12733 set_hash_input_set, "set_hash_input_set");
12734 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id =
12735 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result,
12737 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type =
12738 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12740 cmdline_parse_token_string_t cmd_set_hash_input_set_field =
12741 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12743 "ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
12744 "ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#"
12745 "udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#"
12746 "sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#"
12747 "fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#"
12749 cmdline_parse_token_string_t cmd_set_hash_input_set_select =
12750 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12751 select, "select#add");
12753 cmdline_parse_inst_t cmd_set_hash_input_set = {
12754 .f = cmd_set_hash_input_set_parsed,
12756 .help_str = "set_hash_input_set <port_id> "
12757 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12758 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload|<flowtype_id> "
12759 "ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|"
12760 "ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|"
12761 "tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|"
12762 "gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
12763 "fld-7th|fld-8th|none select|add",
12765 (void *)&cmd_set_hash_input_set_cmd,
12766 (void *)&cmd_set_hash_input_set_port_id,
12767 (void *)&cmd_set_hash_input_set_flow_type,
12768 (void *)&cmd_set_hash_input_set_field,
12769 (void *)&cmd_set_hash_input_set_select,
12774 /* Set flow director input set */
12775 struct cmd_set_fdir_input_set_result {
12776 cmdline_fixed_string_t set_fdir_input_set;
12778 cmdline_fixed_string_t flow_type;
12779 cmdline_fixed_string_t inset_field;
12780 cmdline_fixed_string_t select;
12784 cmd_set_fdir_input_set_parsed(void *parsed_result,
12785 __rte_unused struct cmdline *cl,
12786 __rte_unused void *data)
12788 struct cmd_set_fdir_input_set_result *res = parsed_result;
12789 struct rte_eth_fdir_filter_info info;
12791 memset(&info, 0, sizeof(info));
12792 info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT;
12793 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
12794 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
12795 info.info.input_set_conf.inset_size = 1;
12796 if (!strcmp(res->select, "select"))
12797 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
12798 else if (!strcmp(res->select, "add"))
12799 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
12800 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
12801 RTE_ETH_FILTER_SET, &info);
12804 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd =
12805 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12806 set_fdir_input_set, "set_fdir_input_set");
12807 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id =
12808 TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result,
12810 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type =
12811 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12813 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
12814 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
12815 cmdline_parse_token_string_t cmd_set_fdir_input_set_field =
12816 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12818 "ivlan#ethertype#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
12819 "ipv4-tos#ipv4-proto#ipv4-ttl#ipv6-tc#ipv6-next-header#"
12820 "ipv6-hop-limits#udp-src-port#udp-dst-port#"
12821 "tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#"
12822 "sctp-veri-tag#none");
12823 cmdline_parse_token_string_t cmd_set_fdir_input_set_select =
12824 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12825 select, "select#add");
12827 cmdline_parse_inst_t cmd_set_fdir_input_set = {
12828 .f = cmd_set_fdir_input_set_parsed,
12830 .help_str = "set_fdir_input_set <port_id> "
12831 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12832 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
12833 "ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|"
12834 "ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|ipv6-next-header|"
12835 "ipv6-hop-limits|udp-src-port|udp-dst-port|"
12836 "tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|"
12837 "sctp-veri-tag|none select|add",
12839 (void *)&cmd_set_fdir_input_set_cmd,
12840 (void *)&cmd_set_fdir_input_set_port_id,
12841 (void *)&cmd_set_fdir_input_set_flow_type,
12842 (void *)&cmd_set_fdir_input_set_field,
12843 (void *)&cmd_set_fdir_input_set_select,
12848 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
12849 struct cmd_mcast_addr_result {
12850 cmdline_fixed_string_t mcast_addr_cmd;
12851 cmdline_fixed_string_t what;
12853 struct rte_ether_addr mc_addr;
12856 static void cmd_mcast_addr_parsed(void *parsed_result,
12857 __rte_unused struct cmdline *cl,
12858 __rte_unused void *data)
12860 struct cmd_mcast_addr_result *res = parsed_result;
12862 if (!rte_is_multicast_ether_addr(&res->mc_addr)) {
12863 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
12864 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
12865 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
12866 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
12869 if (strcmp(res->what, "add") == 0)
12870 mcast_addr_add(res->port_num, &res->mc_addr);
12872 mcast_addr_remove(res->port_num, &res->mc_addr);
12875 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
12876 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
12877 mcast_addr_cmd, "mcast_addr");
12878 cmdline_parse_token_string_t cmd_mcast_addr_what =
12879 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
12881 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
12882 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT16);
12883 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
12884 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
12886 cmdline_parse_inst_t cmd_mcast_addr = {
12887 .f = cmd_mcast_addr_parsed,
12889 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
12890 "Add/Remove multicast MAC address on port_id",
12892 (void *)&cmd_mcast_addr_cmd,
12893 (void *)&cmd_mcast_addr_what,
12894 (void *)&cmd_mcast_addr_portnum,
12895 (void *)&cmd_mcast_addr_addr,
12900 /* l2 tunnel config
12901 * only support E-tag now.
12904 /* Ether type config */
12905 struct cmd_config_l2_tunnel_eth_type_result {
12906 cmdline_fixed_string_t port;
12907 cmdline_fixed_string_t config;
12908 cmdline_fixed_string_t all;
12910 cmdline_fixed_string_t l2_tunnel;
12911 cmdline_fixed_string_t l2_tunnel_type;
12912 cmdline_fixed_string_t eth_type;
12913 uint16_t eth_type_val;
12916 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port =
12917 TOKEN_STRING_INITIALIZER
12918 (struct cmd_config_l2_tunnel_eth_type_result,
12920 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config =
12921 TOKEN_STRING_INITIALIZER
12922 (struct cmd_config_l2_tunnel_eth_type_result,
12924 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str =
12925 TOKEN_STRING_INITIALIZER
12926 (struct cmd_config_l2_tunnel_eth_type_result,
12928 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id =
12929 TOKEN_NUM_INITIALIZER
12930 (struct cmd_config_l2_tunnel_eth_type_result,
12932 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel =
12933 TOKEN_STRING_INITIALIZER
12934 (struct cmd_config_l2_tunnel_eth_type_result,
12935 l2_tunnel, "l2-tunnel");
12936 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type =
12937 TOKEN_STRING_INITIALIZER
12938 (struct cmd_config_l2_tunnel_eth_type_result,
12939 l2_tunnel_type, "E-tag");
12940 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type =
12941 TOKEN_STRING_INITIALIZER
12942 (struct cmd_config_l2_tunnel_eth_type_result,
12943 eth_type, "ether-type");
12944 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val =
12945 TOKEN_NUM_INITIALIZER
12946 (struct cmd_config_l2_tunnel_eth_type_result,
12947 eth_type_val, UINT16);
12949 static enum rte_eth_tunnel_type
12950 str2fdir_l2_tunnel_type(char *string)
12954 static const struct {
12956 enum rte_eth_tunnel_type type;
12957 } l2_tunnel_type_str[] = {
12958 {"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG},
12961 for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) {
12962 if (!strcmp(l2_tunnel_type_str[i].str, string))
12963 return l2_tunnel_type_str[i].type;
12965 return RTE_TUNNEL_TYPE_NONE;
12968 /* ether type config for all ports */
12970 cmd_config_l2_tunnel_eth_type_all_parsed
12971 (void *parsed_result,
12972 __rte_unused struct cmdline *cl,
12973 __rte_unused void *data)
12975 struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result;
12976 struct rte_eth_l2_tunnel_conf entry;
12979 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12980 entry.ether_type = res->eth_type_val;
12982 RTE_ETH_FOREACH_DEV(pid) {
12983 rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry);
12987 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = {
12988 .f = cmd_config_l2_tunnel_eth_type_all_parsed,
12990 .help_str = "port config all l2-tunnel E-tag ether-type <value>",
12992 (void *)&cmd_config_l2_tunnel_eth_type_port,
12993 (void *)&cmd_config_l2_tunnel_eth_type_config,
12994 (void *)&cmd_config_l2_tunnel_eth_type_all_str,
12995 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
12996 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
12997 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
12998 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
13003 /* ether type config for a specific port */
13005 cmd_config_l2_tunnel_eth_type_specific_parsed(
13006 void *parsed_result,
13007 __rte_unused struct cmdline *cl,
13008 __rte_unused void *data)
13010 struct cmd_config_l2_tunnel_eth_type_result *res =
13012 struct rte_eth_l2_tunnel_conf entry;
13014 if (port_id_is_invalid(res->id, ENABLED_WARN))
13017 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
13018 entry.ether_type = res->eth_type_val;
13020 rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry);
13023 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = {
13024 .f = cmd_config_l2_tunnel_eth_type_specific_parsed,
13026 .help_str = "port config <port_id> l2-tunnel E-tag ether-type <value>",
13028 (void *)&cmd_config_l2_tunnel_eth_type_port,
13029 (void *)&cmd_config_l2_tunnel_eth_type_config,
13030 (void *)&cmd_config_l2_tunnel_eth_type_id,
13031 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
13032 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
13033 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
13034 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
13039 /* Enable/disable l2 tunnel */
13040 struct cmd_config_l2_tunnel_en_dis_result {
13041 cmdline_fixed_string_t port;
13042 cmdline_fixed_string_t config;
13043 cmdline_fixed_string_t all;
13045 cmdline_fixed_string_t l2_tunnel;
13046 cmdline_fixed_string_t l2_tunnel_type;
13047 cmdline_fixed_string_t en_dis;
13050 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port =
13051 TOKEN_STRING_INITIALIZER
13052 (struct cmd_config_l2_tunnel_en_dis_result,
13054 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config =
13055 TOKEN_STRING_INITIALIZER
13056 (struct cmd_config_l2_tunnel_en_dis_result,
13058 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str =
13059 TOKEN_STRING_INITIALIZER
13060 (struct cmd_config_l2_tunnel_en_dis_result,
13062 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id =
13063 TOKEN_NUM_INITIALIZER
13064 (struct cmd_config_l2_tunnel_en_dis_result,
13066 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel =
13067 TOKEN_STRING_INITIALIZER
13068 (struct cmd_config_l2_tunnel_en_dis_result,
13069 l2_tunnel, "l2-tunnel");
13070 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type =
13071 TOKEN_STRING_INITIALIZER
13072 (struct cmd_config_l2_tunnel_en_dis_result,
13073 l2_tunnel_type, "E-tag");
13074 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis =
13075 TOKEN_STRING_INITIALIZER
13076 (struct cmd_config_l2_tunnel_en_dis_result,
13077 en_dis, "enable#disable");
13079 /* enable/disable l2 tunnel for all ports */
13081 cmd_config_l2_tunnel_en_dis_all_parsed(
13082 void *parsed_result,
13083 __rte_unused struct cmdline *cl,
13084 __rte_unused void *data)
13086 struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result;
13087 struct rte_eth_l2_tunnel_conf entry;
13091 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
13093 if (!strcmp("enable", res->en_dis))
13098 RTE_ETH_FOREACH_DEV(pid) {
13099 rte_eth_dev_l2_tunnel_offload_set(pid,
13101 ETH_L2_TUNNEL_ENABLE_MASK,
13106 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = {
13107 .f = cmd_config_l2_tunnel_en_dis_all_parsed,
13109 .help_str = "port config all l2-tunnel E-tag enable|disable",
13111 (void *)&cmd_config_l2_tunnel_en_dis_port,
13112 (void *)&cmd_config_l2_tunnel_en_dis_config,
13113 (void *)&cmd_config_l2_tunnel_en_dis_all_str,
13114 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
13115 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
13116 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
13121 /* enable/disable l2 tunnel for a port */
13123 cmd_config_l2_tunnel_en_dis_specific_parsed(
13124 void *parsed_result,
13125 __rte_unused struct cmdline *cl,
13126 __rte_unused void *data)
13128 struct cmd_config_l2_tunnel_en_dis_result *res =
13130 struct rte_eth_l2_tunnel_conf entry;
13132 if (port_id_is_invalid(res->id, ENABLED_WARN))
13135 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
13137 if (!strcmp("enable", res->en_dis))
13138 rte_eth_dev_l2_tunnel_offload_set(res->id,
13140 ETH_L2_TUNNEL_ENABLE_MASK,
13143 rte_eth_dev_l2_tunnel_offload_set(res->id,
13145 ETH_L2_TUNNEL_ENABLE_MASK,
13149 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = {
13150 .f = cmd_config_l2_tunnel_en_dis_specific_parsed,
13152 .help_str = "port config <port_id> l2-tunnel E-tag enable|disable",
13154 (void *)&cmd_config_l2_tunnel_en_dis_port,
13155 (void *)&cmd_config_l2_tunnel_en_dis_config,
13156 (void *)&cmd_config_l2_tunnel_en_dis_id,
13157 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
13158 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
13159 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
13164 /* E-tag configuration */
13166 /* Common result structure for all E-tag configuration */
13167 struct cmd_config_e_tag_result {
13168 cmdline_fixed_string_t e_tag;
13169 cmdline_fixed_string_t set;
13170 cmdline_fixed_string_t insertion;
13171 cmdline_fixed_string_t stripping;
13172 cmdline_fixed_string_t forwarding;
13173 cmdline_fixed_string_t filter;
13174 cmdline_fixed_string_t add;
13175 cmdline_fixed_string_t del;
13176 cmdline_fixed_string_t on;
13177 cmdline_fixed_string_t off;
13178 cmdline_fixed_string_t on_off;
13179 cmdline_fixed_string_t port_tag_id;
13180 uint32_t port_tag_id_val;
13181 cmdline_fixed_string_t e_tag_id;
13182 uint16_t e_tag_id_val;
13183 cmdline_fixed_string_t dst_pool;
13184 uint8_t dst_pool_val;
13185 cmdline_fixed_string_t port;
13187 cmdline_fixed_string_t vf;
13191 /* Common CLI fields for all E-tag configuration */
13192 cmdline_parse_token_string_t cmd_config_e_tag_e_tag =
13193 TOKEN_STRING_INITIALIZER
13194 (struct cmd_config_e_tag_result,
13196 cmdline_parse_token_string_t cmd_config_e_tag_set =
13197 TOKEN_STRING_INITIALIZER
13198 (struct cmd_config_e_tag_result,
13200 cmdline_parse_token_string_t cmd_config_e_tag_insertion =
13201 TOKEN_STRING_INITIALIZER
13202 (struct cmd_config_e_tag_result,
13203 insertion, "insertion");
13204 cmdline_parse_token_string_t cmd_config_e_tag_stripping =
13205 TOKEN_STRING_INITIALIZER
13206 (struct cmd_config_e_tag_result,
13207 stripping, "stripping");
13208 cmdline_parse_token_string_t cmd_config_e_tag_forwarding =
13209 TOKEN_STRING_INITIALIZER
13210 (struct cmd_config_e_tag_result,
13211 forwarding, "forwarding");
13212 cmdline_parse_token_string_t cmd_config_e_tag_filter =
13213 TOKEN_STRING_INITIALIZER
13214 (struct cmd_config_e_tag_result,
13216 cmdline_parse_token_string_t cmd_config_e_tag_add =
13217 TOKEN_STRING_INITIALIZER
13218 (struct cmd_config_e_tag_result,
13220 cmdline_parse_token_string_t cmd_config_e_tag_del =
13221 TOKEN_STRING_INITIALIZER
13222 (struct cmd_config_e_tag_result,
13224 cmdline_parse_token_string_t cmd_config_e_tag_on =
13225 TOKEN_STRING_INITIALIZER
13226 (struct cmd_config_e_tag_result,
13228 cmdline_parse_token_string_t cmd_config_e_tag_off =
13229 TOKEN_STRING_INITIALIZER
13230 (struct cmd_config_e_tag_result,
13232 cmdline_parse_token_string_t cmd_config_e_tag_on_off =
13233 TOKEN_STRING_INITIALIZER
13234 (struct cmd_config_e_tag_result,
13236 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id =
13237 TOKEN_STRING_INITIALIZER
13238 (struct cmd_config_e_tag_result,
13239 port_tag_id, "port-tag-id");
13240 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val =
13241 TOKEN_NUM_INITIALIZER
13242 (struct cmd_config_e_tag_result,
13243 port_tag_id_val, UINT32);
13244 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id =
13245 TOKEN_STRING_INITIALIZER
13246 (struct cmd_config_e_tag_result,
13247 e_tag_id, "e-tag-id");
13248 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val =
13249 TOKEN_NUM_INITIALIZER
13250 (struct cmd_config_e_tag_result,
13251 e_tag_id_val, UINT16);
13252 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool =
13253 TOKEN_STRING_INITIALIZER
13254 (struct cmd_config_e_tag_result,
13255 dst_pool, "dst-pool");
13256 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val =
13257 TOKEN_NUM_INITIALIZER
13258 (struct cmd_config_e_tag_result,
13259 dst_pool_val, UINT8);
13260 cmdline_parse_token_string_t cmd_config_e_tag_port =
13261 TOKEN_STRING_INITIALIZER
13262 (struct cmd_config_e_tag_result,
13264 cmdline_parse_token_num_t cmd_config_e_tag_port_id =
13265 TOKEN_NUM_INITIALIZER
13266 (struct cmd_config_e_tag_result,
13268 cmdline_parse_token_string_t cmd_config_e_tag_vf =
13269 TOKEN_STRING_INITIALIZER
13270 (struct cmd_config_e_tag_result,
13272 cmdline_parse_token_num_t cmd_config_e_tag_vf_id =
13273 TOKEN_NUM_INITIALIZER
13274 (struct cmd_config_e_tag_result,
13277 /* E-tag insertion configuration */
13279 cmd_config_e_tag_insertion_en_parsed(
13280 void *parsed_result,
13281 __rte_unused struct cmdline *cl,
13282 __rte_unused void *data)
13284 struct cmd_config_e_tag_result *res =
13286 struct rte_eth_l2_tunnel_conf entry;
13288 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13291 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13292 entry.tunnel_id = res->port_tag_id_val;
13293 entry.vf_id = res->vf_id;
13294 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
13296 ETH_L2_TUNNEL_INSERTION_MASK,
13301 cmd_config_e_tag_insertion_dis_parsed(
13302 void *parsed_result,
13303 __rte_unused struct cmdline *cl,
13304 __rte_unused void *data)
13306 struct cmd_config_e_tag_result *res =
13308 struct rte_eth_l2_tunnel_conf entry;
13310 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13313 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13314 entry.vf_id = res->vf_id;
13316 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
13318 ETH_L2_TUNNEL_INSERTION_MASK,
13322 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = {
13323 .f = cmd_config_e_tag_insertion_en_parsed,
13325 .help_str = "E-tag ... : E-tag insertion enable",
13327 (void *)&cmd_config_e_tag_e_tag,
13328 (void *)&cmd_config_e_tag_set,
13329 (void *)&cmd_config_e_tag_insertion,
13330 (void *)&cmd_config_e_tag_on,
13331 (void *)&cmd_config_e_tag_port_tag_id,
13332 (void *)&cmd_config_e_tag_port_tag_id_val,
13333 (void *)&cmd_config_e_tag_port,
13334 (void *)&cmd_config_e_tag_port_id,
13335 (void *)&cmd_config_e_tag_vf,
13336 (void *)&cmd_config_e_tag_vf_id,
13341 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = {
13342 .f = cmd_config_e_tag_insertion_dis_parsed,
13344 .help_str = "E-tag ... : E-tag insertion disable",
13346 (void *)&cmd_config_e_tag_e_tag,
13347 (void *)&cmd_config_e_tag_set,
13348 (void *)&cmd_config_e_tag_insertion,
13349 (void *)&cmd_config_e_tag_off,
13350 (void *)&cmd_config_e_tag_port,
13351 (void *)&cmd_config_e_tag_port_id,
13352 (void *)&cmd_config_e_tag_vf,
13353 (void *)&cmd_config_e_tag_vf_id,
13358 /* E-tag stripping configuration */
13360 cmd_config_e_tag_stripping_parsed(
13361 void *parsed_result,
13362 __rte_unused struct cmdline *cl,
13363 __rte_unused void *data)
13365 struct cmd_config_e_tag_result *res =
13367 struct rte_eth_l2_tunnel_conf entry;
13369 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13372 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13374 if (!strcmp(res->on_off, "on"))
13375 rte_eth_dev_l2_tunnel_offload_set
13378 ETH_L2_TUNNEL_STRIPPING_MASK,
13381 rte_eth_dev_l2_tunnel_offload_set
13384 ETH_L2_TUNNEL_STRIPPING_MASK,
13388 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = {
13389 .f = cmd_config_e_tag_stripping_parsed,
13391 .help_str = "E-tag ... : E-tag stripping enable/disable",
13393 (void *)&cmd_config_e_tag_e_tag,
13394 (void *)&cmd_config_e_tag_set,
13395 (void *)&cmd_config_e_tag_stripping,
13396 (void *)&cmd_config_e_tag_on_off,
13397 (void *)&cmd_config_e_tag_port,
13398 (void *)&cmd_config_e_tag_port_id,
13403 /* E-tag forwarding configuration */
13405 cmd_config_e_tag_forwarding_parsed(
13406 void *parsed_result,
13407 __rte_unused struct cmdline *cl,
13408 __rte_unused void *data)
13410 struct cmd_config_e_tag_result *res = parsed_result;
13411 struct rte_eth_l2_tunnel_conf entry;
13413 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13416 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13418 if (!strcmp(res->on_off, "on"))
13419 rte_eth_dev_l2_tunnel_offload_set
13422 ETH_L2_TUNNEL_FORWARDING_MASK,
13425 rte_eth_dev_l2_tunnel_offload_set
13428 ETH_L2_TUNNEL_FORWARDING_MASK,
13432 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = {
13433 .f = cmd_config_e_tag_forwarding_parsed,
13435 .help_str = "E-tag ... : E-tag forwarding enable/disable",
13437 (void *)&cmd_config_e_tag_e_tag,
13438 (void *)&cmd_config_e_tag_set,
13439 (void *)&cmd_config_e_tag_forwarding,
13440 (void *)&cmd_config_e_tag_on_off,
13441 (void *)&cmd_config_e_tag_port,
13442 (void *)&cmd_config_e_tag_port_id,
13447 /* E-tag filter configuration */
13449 cmd_config_e_tag_filter_add_parsed(
13450 void *parsed_result,
13451 __rte_unused struct cmdline *cl,
13452 __rte_unused void *data)
13454 struct cmd_config_e_tag_result *res = parsed_result;
13455 struct rte_eth_l2_tunnel_conf entry;
13458 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13461 if (res->e_tag_id_val > 0x3fff) {
13462 printf("e-tag-id must be equal or less than 0x3fff.\n");
13466 ret = rte_eth_dev_filter_supported(res->port_id,
13467 RTE_ETH_FILTER_L2_TUNNEL);
13469 printf("E-tag filter is not supported on port %u.\n",
13474 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13475 entry.tunnel_id = res->e_tag_id_val;
13476 entry.pool = res->dst_pool_val;
13478 ret = rte_eth_dev_filter_ctrl(res->port_id,
13479 RTE_ETH_FILTER_L2_TUNNEL,
13480 RTE_ETH_FILTER_ADD,
13483 printf("E-tag filter programming error: (%s)\n",
13487 cmdline_parse_inst_t cmd_config_e_tag_filter_add = {
13488 .f = cmd_config_e_tag_filter_add_parsed,
13490 .help_str = "E-tag ... : E-tag filter add",
13492 (void *)&cmd_config_e_tag_e_tag,
13493 (void *)&cmd_config_e_tag_set,
13494 (void *)&cmd_config_e_tag_filter,
13495 (void *)&cmd_config_e_tag_add,
13496 (void *)&cmd_config_e_tag_e_tag_id,
13497 (void *)&cmd_config_e_tag_e_tag_id_val,
13498 (void *)&cmd_config_e_tag_dst_pool,
13499 (void *)&cmd_config_e_tag_dst_pool_val,
13500 (void *)&cmd_config_e_tag_port,
13501 (void *)&cmd_config_e_tag_port_id,
13507 cmd_config_e_tag_filter_del_parsed(
13508 void *parsed_result,
13509 __rte_unused struct cmdline *cl,
13510 __rte_unused void *data)
13512 struct cmd_config_e_tag_result *res = parsed_result;
13513 struct rte_eth_l2_tunnel_conf entry;
13516 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13519 if (res->e_tag_id_val > 0x3fff) {
13520 printf("e-tag-id must be less than 0x3fff.\n");
13524 ret = rte_eth_dev_filter_supported(res->port_id,
13525 RTE_ETH_FILTER_L2_TUNNEL);
13527 printf("E-tag filter is not supported on port %u.\n",
13532 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13533 entry.tunnel_id = res->e_tag_id_val;
13535 ret = rte_eth_dev_filter_ctrl(res->port_id,
13536 RTE_ETH_FILTER_L2_TUNNEL,
13537 RTE_ETH_FILTER_DELETE,
13540 printf("E-tag filter programming error: (%s)\n",
13544 cmdline_parse_inst_t cmd_config_e_tag_filter_del = {
13545 .f = cmd_config_e_tag_filter_del_parsed,
13547 .help_str = "E-tag ... : E-tag filter delete",
13549 (void *)&cmd_config_e_tag_e_tag,
13550 (void *)&cmd_config_e_tag_set,
13551 (void *)&cmd_config_e_tag_filter,
13552 (void *)&cmd_config_e_tag_del,
13553 (void *)&cmd_config_e_tag_e_tag_id,
13554 (void *)&cmd_config_e_tag_e_tag_id_val,
13555 (void *)&cmd_config_e_tag_port,
13556 (void *)&cmd_config_e_tag_port_id,
13561 /* vf vlan anti spoof configuration */
13563 /* Common result structure for vf vlan anti spoof */
13564 struct cmd_vf_vlan_anti_spoof_result {
13565 cmdline_fixed_string_t set;
13566 cmdline_fixed_string_t vf;
13567 cmdline_fixed_string_t vlan;
13568 cmdline_fixed_string_t antispoof;
13571 cmdline_fixed_string_t on_off;
13574 /* Common CLI fields for vf vlan anti spoof enable disable */
13575 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
13576 TOKEN_STRING_INITIALIZER
13577 (struct cmd_vf_vlan_anti_spoof_result,
13579 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
13580 TOKEN_STRING_INITIALIZER
13581 (struct cmd_vf_vlan_anti_spoof_result,
13583 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
13584 TOKEN_STRING_INITIALIZER
13585 (struct cmd_vf_vlan_anti_spoof_result,
13587 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
13588 TOKEN_STRING_INITIALIZER
13589 (struct cmd_vf_vlan_anti_spoof_result,
13590 antispoof, "antispoof");
13591 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
13592 TOKEN_NUM_INITIALIZER
13593 (struct cmd_vf_vlan_anti_spoof_result,
13595 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
13596 TOKEN_NUM_INITIALIZER
13597 (struct cmd_vf_vlan_anti_spoof_result,
13599 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
13600 TOKEN_STRING_INITIALIZER
13601 (struct cmd_vf_vlan_anti_spoof_result,
13605 cmd_set_vf_vlan_anti_spoof_parsed(
13606 void *parsed_result,
13607 __rte_unused struct cmdline *cl,
13608 __rte_unused void *data)
13610 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
13611 int ret = -ENOTSUP;
13613 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13615 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13618 #ifdef RTE_NET_IXGBE
13619 if (ret == -ENOTSUP)
13620 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
13621 res->vf_id, is_on);
13623 #ifdef RTE_NET_I40E
13624 if (ret == -ENOTSUP)
13625 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
13626 res->vf_id, is_on);
13628 #ifdef RTE_NET_BNXT
13629 if (ret == -ENOTSUP)
13630 ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
13631 res->vf_id, is_on);
13638 printf("invalid vf_id %d\n", res->vf_id);
13641 printf("invalid port_id %d\n", res->port_id);
13644 printf("function not implemented\n");
13647 printf("programming error: (%s)\n", strerror(-ret));
13651 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
13652 .f = cmd_set_vf_vlan_anti_spoof_parsed,
13654 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
13656 (void *)&cmd_vf_vlan_anti_spoof_set,
13657 (void *)&cmd_vf_vlan_anti_spoof_vf,
13658 (void *)&cmd_vf_vlan_anti_spoof_vlan,
13659 (void *)&cmd_vf_vlan_anti_spoof_antispoof,
13660 (void *)&cmd_vf_vlan_anti_spoof_port_id,
13661 (void *)&cmd_vf_vlan_anti_spoof_vf_id,
13662 (void *)&cmd_vf_vlan_anti_spoof_on_off,
13667 /* vf mac anti spoof configuration */
13669 /* Common result structure for vf mac anti spoof */
13670 struct cmd_vf_mac_anti_spoof_result {
13671 cmdline_fixed_string_t set;
13672 cmdline_fixed_string_t vf;
13673 cmdline_fixed_string_t mac;
13674 cmdline_fixed_string_t antispoof;
13677 cmdline_fixed_string_t on_off;
13680 /* Common CLI fields for vf mac anti spoof enable disable */
13681 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
13682 TOKEN_STRING_INITIALIZER
13683 (struct cmd_vf_mac_anti_spoof_result,
13685 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
13686 TOKEN_STRING_INITIALIZER
13687 (struct cmd_vf_mac_anti_spoof_result,
13689 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
13690 TOKEN_STRING_INITIALIZER
13691 (struct cmd_vf_mac_anti_spoof_result,
13693 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
13694 TOKEN_STRING_INITIALIZER
13695 (struct cmd_vf_mac_anti_spoof_result,
13696 antispoof, "antispoof");
13697 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
13698 TOKEN_NUM_INITIALIZER
13699 (struct cmd_vf_mac_anti_spoof_result,
13701 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
13702 TOKEN_NUM_INITIALIZER
13703 (struct cmd_vf_mac_anti_spoof_result,
13705 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
13706 TOKEN_STRING_INITIALIZER
13707 (struct cmd_vf_mac_anti_spoof_result,
13711 cmd_set_vf_mac_anti_spoof_parsed(
13712 void *parsed_result,
13713 __rte_unused struct cmdline *cl,
13714 __rte_unused void *data)
13716 struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
13717 int ret = -ENOTSUP;
13719 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13721 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13724 #ifdef RTE_NET_IXGBE
13725 if (ret == -ENOTSUP)
13726 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
13727 res->vf_id, is_on);
13729 #ifdef RTE_NET_I40E
13730 if (ret == -ENOTSUP)
13731 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
13732 res->vf_id, is_on);
13734 #ifdef RTE_NET_BNXT
13735 if (ret == -ENOTSUP)
13736 ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
13737 res->vf_id, is_on);
13744 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13747 printf("invalid port_id %d\n", res->port_id);
13750 printf("function not implemented\n");
13753 printf("programming error: (%s)\n", strerror(-ret));
13757 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
13758 .f = cmd_set_vf_mac_anti_spoof_parsed,
13760 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
13762 (void *)&cmd_vf_mac_anti_spoof_set,
13763 (void *)&cmd_vf_mac_anti_spoof_vf,
13764 (void *)&cmd_vf_mac_anti_spoof_mac,
13765 (void *)&cmd_vf_mac_anti_spoof_antispoof,
13766 (void *)&cmd_vf_mac_anti_spoof_port_id,
13767 (void *)&cmd_vf_mac_anti_spoof_vf_id,
13768 (void *)&cmd_vf_mac_anti_spoof_on_off,
13773 /* vf vlan strip queue configuration */
13775 /* Common result structure for vf mac anti spoof */
13776 struct cmd_vf_vlan_stripq_result {
13777 cmdline_fixed_string_t set;
13778 cmdline_fixed_string_t vf;
13779 cmdline_fixed_string_t vlan;
13780 cmdline_fixed_string_t stripq;
13783 cmdline_fixed_string_t on_off;
13786 /* Common CLI fields for vf vlan strip enable disable */
13787 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
13788 TOKEN_STRING_INITIALIZER
13789 (struct cmd_vf_vlan_stripq_result,
13791 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
13792 TOKEN_STRING_INITIALIZER
13793 (struct cmd_vf_vlan_stripq_result,
13795 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
13796 TOKEN_STRING_INITIALIZER
13797 (struct cmd_vf_vlan_stripq_result,
13799 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
13800 TOKEN_STRING_INITIALIZER
13801 (struct cmd_vf_vlan_stripq_result,
13803 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
13804 TOKEN_NUM_INITIALIZER
13805 (struct cmd_vf_vlan_stripq_result,
13807 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
13808 TOKEN_NUM_INITIALIZER
13809 (struct cmd_vf_vlan_stripq_result,
13811 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
13812 TOKEN_STRING_INITIALIZER
13813 (struct cmd_vf_vlan_stripq_result,
13817 cmd_set_vf_vlan_stripq_parsed(
13818 void *parsed_result,
13819 __rte_unused struct cmdline *cl,
13820 __rte_unused void *data)
13822 struct cmd_vf_vlan_stripq_result *res = parsed_result;
13823 int ret = -ENOTSUP;
13825 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13827 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13830 #ifdef RTE_NET_IXGBE
13831 if (ret == -ENOTSUP)
13832 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
13833 res->vf_id, is_on);
13835 #ifdef RTE_NET_I40E
13836 if (ret == -ENOTSUP)
13837 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
13838 res->vf_id, is_on);
13840 #ifdef RTE_NET_BNXT
13841 if (ret == -ENOTSUP)
13842 ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
13843 res->vf_id, is_on);
13850 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13853 printf("invalid port_id %d\n", res->port_id);
13856 printf("function not implemented\n");
13859 printf("programming error: (%s)\n", strerror(-ret));
13863 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
13864 .f = cmd_set_vf_vlan_stripq_parsed,
13866 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
13868 (void *)&cmd_vf_vlan_stripq_set,
13869 (void *)&cmd_vf_vlan_stripq_vf,
13870 (void *)&cmd_vf_vlan_stripq_vlan,
13871 (void *)&cmd_vf_vlan_stripq_stripq,
13872 (void *)&cmd_vf_vlan_stripq_port_id,
13873 (void *)&cmd_vf_vlan_stripq_vf_id,
13874 (void *)&cmd_vf_vlan_stripq_on_off,
13879 /* vf vlan insert configuration */
13881 /* Common result structure for vf vlan insert */
13882 struct cmd_vf_vlan_insert_result {
13883 cmdline_fixed_string_t set;
13884 cmdline_fixed_string_t vf;
13885 cmdline_fixed_string_t vlan;
13886 cmdline_fixed_string_t insert;
13892 /* Common CLI fields for vf vlan insert enable disable */
13893 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
13894 TOKEN_STRING_INITIALIZER
13895 (struct cmd_vf_vlan_insert_result,
13897 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
13898 TOKEN_STRING_INITIALIZER
13899 (struct cmd_vf_vlan_insert_result,
13901 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
13902 TOKEN_STRING_INITIALIZER
13903 (struct cmd_vf_vlan_insert_result,
13905 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
13906 TOKEN_STRING_INITIALIZER
13907 (struct cmd_vf_vlan_insert_result,
13909 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
13910 TOKEN_NUM_INITIALIZER
13911 (struct cmd_vf_vlan_insert_result,
13913 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
13914 TOKEN_NUM_INITIALIZER
13915 (struct cmd_vf_vlan_insert_result,
13917 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
13918 TOKEN_NUM_INITIALIZER
13919 (struct cmd_vf_vlan_insert_result,
13923 cmd_set_vf_vlan_insert_parsed(
13924 void *parsed_result,
13925 __rte_unused struct cmdline *cl,
13926 __rte_unused void *data)
13928 struct cmd_vf_vlan_insert_result *res = parsed_result;
13929 int ret = -ENOTSUP;
13931 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13934 #ifdef RTE_NET_IXGBE
13935 if (ret == -ENOTSUP)
13936 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
13939 #ifdef RTE_NET_I40E
13940 if (ret == -ENOTSUP)
13941 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
13944 #ifdef RTE_NET_BNXT
13945 if (ret == -ENOTSUP)
13946 ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
13954 printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id);
13957 printf("invalid port_id %d\n", res->port_id);
13960 printf("function not implemented\n");
13963 printf("programming error: (%s)\n", strerror(-ret));
13967 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
13968 .f = cmd_set_vf_vlan_insert_parsed,
13970 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
13972 (void *)&cmd_vf_vlan_insert_set,
13973 (void *)&cmd_vf_vlan_insert_vf,
13974 (void *)&cmd_vf_vlan_insert_vlan,
13975 (void *)&cmd_vf_vlan_insert_insert,
13976 (void *)&cmd_vf_vlan_insert_port_id,
13977 (void *)&cmd_vf_vlan_insert_vf_id,
13978 (void *)&cmd_vf_vlan_insert_vlan_id,
13983 /* tx loopback configuration */
13985 /* Common result structure for tx loopback */
13986 struct cmd_tx_loopback_result {
13987 cmdline_fixed_string_t set;
13988 cmdline_fixed_string_t tx;
13989 cmdline_fixed_string_t loopback;
13991 cmdline_fixed_string_t on_off;
13994 /* Common CLI fields for tx loopback enable disable */
13995 cmdline_parse_token_string_t cmd_tx_loopback_set =
13996 TOKEN_STRING_INITIALIZER
13997 (struct cmd_tx_loopback_result,
13999 cmdline_parse_token_string_t cmd_tx_loopback_tx =
14000 TOKEN_STRING_INITIALIZER
14001 (struct cmd_tx_loopback_result,
14003 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
14004 TOKEN_STRING_INITIALIZER
14005 (struct cmd_tx_loopback_result,
14006 loopback, "loopback");
14007 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
14008 TOKEN_NUM_INITIALIZER
14009 (struct cmd_tx_loopback_result,
14011 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
14012 TOKEN_STRING_INITIALIZER
14013 (struct cmd_tx_loopback_result,
14017 cmd_set_tx_loopback_parsed(
14018 void *parsed_result,
14019 __rte_unused struct cmdline *cl,
14020 __rte_unused void *data)
14022 struct cmd_tx_loopback_result *res = parsed_result;
14023 int ret = -ENOTSUP;
14025 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14027 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14030 #ifdef RTE_NET_IXGBE
14031 if (ret == -ENOTSUP)
14032 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
14034 #ifdef RTE_NET_I40E
14035 if (ret == -ENOTSUP)
14036 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
14038 #ifdef RTE_NET_BNXT
14039 if (ret == -ENOTSUP)
14040 ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
14042 #if defined RTE_BUS_DPAA && defined RTE_NET_DPAA
14043 if (ret == -ENOTSUP)
14044 ret = rte_pmd_dpaa_set_tx_loopback(res->port_id, is_on);
14051 printf("invalid is_on %d\n", is_on);
14054 printf("invalid port_id %d\n", res->port_id);
14057 printf("function not implemented\n");
14060 printf("programming error: (%s)\n", strerror(-ret));
14064 cmdline_parse_inst_t cmd_set_tx_loopback = {
14065 .f = cmd_set_tx_loopback_parsed,
14067 .help_str = "set tx loopback <port_id> on|off",
14069 (void *)&cmd_tx_loopback_set,
14070 (void *)&cmd_tx_loopback_tx,
14071 (void *)&cmd_tx_loopback_loopback,
14072 (void *)&cmd_tx_loopback_port_id,
14073 (void *)&cmd_tx_loopback_on_off,
14078 /* all queues drop enable configuration */
14080 /* Common result structure for all queues drop enable */
14081 struct cmd_all_queues_drop_en_result {
14082 cmdline_fixed_string_t set;
14083 cmdline_fixed_string_t all;
14084 cmdline_fixed_string_t queues;
14085 cmdline_fixed_string_t drop;
14087 cmdline_fixed_string_t on_off;
14090 /* Common CLI fields for tx loopback enable disable */
14091 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
14092 TOKEN_STRING_INITIALIZER
14093 (struct cmd_all_queues_drop_en_result,
14095 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
14096 TOKEN_STRING_INITIALIZER
14097 (struct cmd_all_queues_drop_en_result,
14099 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
14100 TOKEN_STRING_INITIALIZER
14101 (struct cmd_all_queues_drop_en_result,
14103 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
14104 TOKEN_STRING_INITIALIZER
14105 (struct cmd_all_queues_drop_en_result,
14107 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
14108 TOKEN_NUM_INITIALIZER
14109 (struct cmd_all_queues_drop_en_result,
14111 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
14112 TOKEN_STRING_INITIALIZER
14113 (struct cmd_all_queues_drop_en_result,
14117 cmd_set_all_queues_drop_en_parsed(
14118 void *parsed_result,
14119 __rte_unused struct cmdline *cl,
14120 __rte_unused void *data)
14122 struct cmd_all_queues_drop_en_result *res = parsed_result;
14123 int ret = -ENOTSUP;
14124 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14126 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14129 #ifdef RTE_NET_IXGBE
14130 if (ret == -ENOTSUP)
14131 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
14133 #ifdef RTE_NET_BNXT
14134 if (ret == -ENOTSUP)
14135 ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
14141 printf("invalid is_on %d\n", is_on);
14144 printf("invalid port_id %d\n", res->port_id);
14147 printf("function not implemented\n");
14150 printf("programming error: (%s)\n", strerror(-ret));
14154 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
14155 .f = cmd_set_all_queues_drop_en_parsed,
14157 .help_str = "set all queues drop <port_id> on|off",
14159 (void *)&cmd_all_queues_drop_en_set,
14160 (void *)&cmd_all_queues_drop_en_all,
14161 (void *)&cmd_all_queues_drop_en_queues,
14162 (void *)&cmd_all_queues_drop_en_drop,
14163 (void *)&cmd_all_queues_drop_en_port_id,
14164 (void *)&cmd_all_queues_drop_en_on_off,
14169 /* vf split drop enable configuration */
14171 /* Common result structure for vf split drop enable */
14172 struct cmd_vf_split_drop_en_result {
14173 cmdline_fixed_string_t set;
14174 cmdline_fixed_string_t vf;
14175 cmdline_fixed_string_t split;
14176 cmdline_fixed_string_t drop;
14179 cmdline_fixed_string_t on_off;
14182 /* Common CLI fields for vf split drop enable disable */
14183 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
14184 TOKEN_STRING_INITIALIZER
14185 (struct cmd_vf_split_drop_en_result,
14187 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
14188 TOKEN_STRING_INITIALIZER
14189 (struct cmd_vf_split_drop_en_result,
14191 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
14192 TOKEN_STRING_INITIALIZER
14193 (struct cmd_vf_split_drop_en_result,
14195 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
14196 TOKEN_STRING_INITIALIZER
14197 (struct cmd_vf_split_drop_en_result,
14199 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
14200 TOKEN_NUM_INITIALIZER
14201 (struct cmd_vf_split_drop_en_result,
14203 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
14204 TOKEN_NUM_INITIALIZER
14205 (struct cmd_vf_split_drop_en_result,
14207 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
14208 TOKEN_STRING_INITIALIZER
14209 (struct cmd_vf_split_drop_en_result,
14213 cmd_set_vf_split_drop_en_parsed(
14214 void *parsed_result,
14215 __rte_unused struct cmdline *cl,
14216 __rte_unused void *data)
14218 struct cmd_vf_split_drop_en_result *res = parsed_result;
14219 int ret = -ENOTSUP;
14220 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14222 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14225 #ifdef RTE_NET_IXGBE
14226 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
14233 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
14236 printf("invalid port_id %d\n", res->port_id);
14239 printf("not supported on port %d\n", res->port_id);
14242 printf("programming error: (%s)\n", strerror(-ret));
14246 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
14247 .f = cmd_set_vf_split_drop_en_parsed,
14249 .help_str = "set vf split drop <port_id> <vf_id> on|off",
14251 (void *)&cmd_vf_split_drop_en_set,
14252 (void *)&cmd_vf_split_drop_en_vf,
14253 (void *)&cmd_vf_split_drop_en_split,
14254 (void *)&cmd_vf_split_drop_en_drop,
14255 (void *)&cmd_vf_split_drop_en_port_id,
14256 (void *)&cmd_vf_split_drop_en_vf_id,
14257 (void *)&cmd_vf_split_drop_en_on_off,
14262 /* vf mac address configuration */
14264 /* Common result structure for vf mac address */
14265 struct cmd_set_vf_mac_addr_result {
14266 cmdline_fixed_string_t set;
14267 cmdline_fixed_string_t vf;
14268 cmdline_fixed_string_t mac;
14269 cmdline_fixed_string_t addr;
14272 struct rte_ether_addr mac_addr;
14276 /* Common CLI fields for vf split drop enable disable */
14277 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
14278 TOKEN_STRING_INITIALIZER
14279 (struct cmd_set_vf_mac_addr_result,
14281 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
14282 TOKEN_STRING_INITIALIZER
14283 (struct cmd_set_vf_mac_addr_result,
14285 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
14286 TOKEN_STRING_INITIALIZER
14287 (struct cmd_set_vf_mac_addr_result,
14289 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
14290 TOKEN_STRING_INITIALIZER
14291 (struct cmd_set_vf_mac_addr_result,
14293 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
14294 TOKEN_NUM_INITIALIZER
14295 (struct cmd_set_vf_mac_addr_result,
14297 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
14298 TOKEN_NUM_INITIALIZER
14299 (struct cmd_set_vf_mac_addr_result,
14301 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
14302 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
14306 cmd_set_vf_mac_addr_parsed(
14307 void *parsed_result,
14308 __rte_unused struct cmdline *cl,
14309 __rte_unused void *data)
14311 struct cmd_set_vf_mac_addr_result *res = parsed_result;
14312 int ret = -ENOTSUP;
14314 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14317 #ifdef RTE_NET_IXGBE
14318 if (ret == -ENOTSUP)
14319 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
14322 #ifdef RTE_NET_I40E
14323 if (ret == -ENOTSUP)
14324 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
14327 #ifdef RTE_NET_BNXT
14328 if (ret == -ENOTSUP)
14329 ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
14337 printf("invalid vf_id %d or mac_addr\n", res->vf_id);
14340 printf("invalid port_id %d\n", res->port_id);
14343 printf("function not implemented\n");
14346 printf("programming error: (%s)\n", strerror(-ret));
14350 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
14351 .f = cmd_set_vf_mac_addr_parsed,
14353 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
14355 (void *)&cmd_set_vf_mac_addr_set,
14356 (void *)&cmd_set_vf_mac_addr_vf,
14357 (void *)&cmd_set_vf_mac_addr_mac,
14358 (void *)&cmd_set_vf_mac_addr_addr,
14359 (void *)&cmd_set_vf_mac_addr_port_id,
14360 (void *)&cmd_set_vf_mac_addr_vf_id,
14361 (void *)&cmd_set_vf_mac_addr_mac_addr,
14366 /* MACsec configuration */
14368 /* Common result structure for MACsec offload enable */
14369 struct cmd_macsec_offload_on_result {
14370 cmdline_fixed_string_t set;
14371 cmdline_fixed_string_t macsec;
14372 cmdline_fixed_string_t offload;
14374 cmdline_fixed_string_t on;
14375 cmdline_fixed_string_t encrypt;
14376 cmdline_fixed_string_t en_on_off;
14377 cmdline_fixed_string_t replay_protect;
14378 cmdline_fixed_string_t rp_on_off;
14381 /* Common CLI fields for MACsec offload disable */
14382 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
14383 TOKEN_STRING_INITIALIZER
14384 (struct cmd_macsec_offload_on_result,
14386 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
14387 TOKEN_STRING_INITIALIZER
14388 (struct cmd_macsec_offload_on_result,
14390 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
14391 TOKEN_STRING_INITIALIZER
14392 (struct cmd_macsec_offload_on_result,
14393 offload, "offload");
14394 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
14395 TOKEN_NUM_INITIALIZER
14396 (struct cmd_macsec_offload_on_result,
14398 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
14399 TOKEN_STRING_INITIALIZER
14400 (struct cmd_macsec_offload_on_result,
14402 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
14403 TOKEN_STRING_INITIALIZER
14404 (struct cmd_macsec_offload_on_result,
14405 encrypt, "encrypt");
14406 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
14407 TOKEN_STRING_INITIALIZER
14408 (struct cmd_macsec_offload_on_result,
14409 en_on_off, "on#off");
14410 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
14411 TOKEN_STRING_INITIALIZER
14412 (struct cmd_macsec_offload_on_result,
14413 replay_protect, "replay-protect");
14414 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
14415 TOKEN_STRING_INITIALIZER
14416 (struct cmd_macsec_offload_on_result,
14417 rp_on_off, "on#off");
14420 cmd_set_macsec_offload_on_parsed(
14421 void *parsed_result,
14422 __rte_unused struct cmdline *cl,
14423 __rte_unused void *data)
14425 struct cmd_macsec_offload_on_result *res = parsed_result;
14426 int ret = -ENOTSUP;
14427 portid_t port_id = res->port_id;
14428 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
14429 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
14430 struct rte_eth_dev_info dev_info;
14432 if (port_id_is_invalid(port_id, ENABLED_WARN))
14434 if (!port_is_stopped(port_id)) {
14435 printf("Please stop port %d first\n", port_id);
14439 ret = eth_dev_info_get_print_err(port_id, &dev_info);
14443 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
14444 #ifdef RTE_NET_IXGBE
14445 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
14453 ports[port_id].dev_conf.txmode.offloads |=
14454 DEV_TX_OFFLOAD_MACSEC_INSERT;
14455 cmd_reconfig_device_queue(port_id, 1, 1);
14458 printf("invalid port_id %d\n", port_id);
14461 printf("not supported on port %d\n", port_id);
14464 printf("programming error: (%s)\n", strerror(-ret));
14468 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
14469 .f = cmd_set_macsec_offload_on_parsed,
14471 .help_str = "set macsec offload <port_id> on "
14472 "encrypt on|off replay-protect on|off",
14474 (void *)&cmd_macsec_offload_on_set,
14475 (void *)&cmd_macsec_offload_on_macsec,
14476 (void *)&cmd_macsec_offload_on_offload,
14477 (void *)&cmd_macsec_offload_on_port_id,
14478 (void *)&cmd_macsec_offload_on_on,
14479 (void *)&cmd_macsec_offload_on_encrypt,
14480 (void *)&cmd_macsec_offload_on_en_on_off,
14481 (void *)&cmd_macsec_offload_on_replay_protect,
14482 (void *)&cmd_macsec_offload_on_rp_on_off,
14487 /* Common result structure for MACsec offload disable */
14488 struct cmd_macsec_offload_off_result {
14489 cmdline_fixed_string_t set;
14490 cmdline_fixed_string_t macsec;
14491 cmdline_fixed_string_t offload;
14493 cmdline_fixed_string_t off;
14496 /* Common CLI fields for MACsec offload disable */
14497 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
14498 TOKEN_STRING_INITIALIZER
14499 (struct cmd_macsec_offload_off_result,
14501 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
14502 TOKEN_STRING_INITIALIZER
14503 (struct cmd_macsec_offload_off_result,
14505 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
14506 TOKEN_STRING_INITIALIZER
14507 (struct cmd_macsec_offload_off_result,
14508 offload, "offload");
14509 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
14510 TOKEN_NUM_INITIALIZER
14511 (struct cmd_macsec_offload_off_result,
14513 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
14514 TOKEN_STRING_INITIALIZER
14515 (struct cmd_macsec_offload_off_result,
14519 cmd_set_macsec_offload_off_parsed(
14520 void *parsed_result,
14521 __rte_unused struct cmdline *cl,
14522 __rte_unused void *data)
14524 struct cmd_macsec_offload_off_result *res = parsed_result;
14525 int ret = -ENOTSUP;
14526 struct rte_eth_dev_info dev_info;
14527 portid_t port_id = res->port_id;
14529 if (port_id_is_invalid(port_id, ENABLED_WARN))
14531 if (!port_is_stopped(port_id)) {
14532 printf("Please stop port %d first\n", port_id);
14536 ret = eth_dev_info_get_print_err(port_id, &dev_info);
14540 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
14541 #ifdef RTE_NET_IXGBE
14542 ret = rte_pmd_ixgbe_macsec_disable(port_id);
14547 ports[port_id].dev_conf.txmode.offloads &=
14548 ~DEV_TX_OFFLOAD_MACSEC_INSERT;
14549 cmd_reconfig_device_queue(port_id, 1, 1);
14552 printf("invalid port_id %d\n", port_id);
14555 printf("not supported on port %d\n", port_id);
14558 printf("programming error: (%s)\n", strerror(-ret));
14562 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
14563 .f = cmd_set_macsec_offload_off_parsed,
14565 .help_str = "set macsec offload <port_id> off",
14567 (void *)&cmd_macsec_offload_off_set,
14568 (void *)&cmd_macsec_offload_off_macsec,
14569 (void *)&cmd_macsec_offload_off_offload,
14570 (void *)&cmd_macsec_offload_off_port_id,
14571 (void *)&cmd_macsec_offload_off_off,
14576 /* Common result structure for MACsec secure connection configure */
14577 struct cmd_macsec_sc_result {
14578 cmdline_fixed_string_t set;
14579 cmdline_fixed_string_t macsec;
14580 cmdline_fixed_string_t sc;
14581 cmdline_fixed_string_t tx_rx;
14583 struct rte_ether_addr mac;
14587 /* Common CLI fields for MACsec secure connection configure */
14588 cmdline_parse_token_string_t cmd_macsec_sc_set =
14589 TOKEN_STRING_INITIALIZER
14590 (struct cmd_macsec_sc_result,
14592 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
14593 TOKEN_STRING_INITIALIZER
14594 (struct cmd_macsec_sc_result,
14596 cmdline_parse_token_string_t cmd_macsec_sc_sc =
14597 TOKEN_STRING_INITIALIZER
14598 (struct cmd_macsec_sc_result,
14600 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
14601 TOKEN_STRING_INITIALIZER
14602 (struct cmd_macsec_sc_result,
14604 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
14605 TOKEN_NUM_INITIALIZER
14606 (struct cmd_macsec_sc_result,
14608 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
14609 TOKEN_ETHERADDR_INITIALIZER
14610 (struct cmd_macsec_sc_result,
14612 cmdline_parse_token_num_t cmd_macsec_sc_pi =
14613 TOKEN_NUM_INITIALIZER
14614 (struct cmd_macsec_sc_result,
14618 cmd_set_macsec_sc_parsed(
14619 void *parsed_result,
14620 __rte_unused struct cmdline *cl,
14621 __rte_unused void *data)
14623 struct cmd_macsec_sc_result *res = parsed_result;
14624 int ret = -ENOTSUP;
14625 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
14627 #ifdef RTE_NET_IXGBE
14629 rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
14630 res->mac.addr_bytes) :
14631 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
14632 res->mac.addr_bytes, res->pi);
14634 RTE_SET_USED(is_tx);
14640 printf("invalid port_id %d\n", res->port_id);
14643 printf("not supported on port %d\n", res->port_id);
14646 printf("programming error: (%s)\n", strerror(-ret));
14650 cmdline_parse_inst_t cmd_set_macsec_sc = {
14651 .f = cmd_set_macsec_sc_parsed,
14653 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
14655 (void *)&cmd_macsec_sc_set,
14656 (void *)&cmd_macsec_sc_macsec,
14657 (void *)&cmd_macsec_sc_sc,
14658 (void *)&cmd_macsec_sc_tx_rx,
14659 (void *)&cmd_macsec_sc_port_id,
14660 (void *)&cmd_macsec_sc_mac,
14661 (void *)&cmd_macsec_sc_pi,
14666 /* Common result structure for MACsec secure connection configure */
14667 struct cmd_macsec_sa_result {
14668 cmdline_fixed_string_t set;
14669 cmdline_fixed_string_t macsec;
14670 cmdline_fixed_string_t sa;
14671 cmdline_fixed_string_t tx_rx;
14676 cmdline_fixed_string_t key;
14679 /* Common CLI fields for MACsec secure connection configure */
14680 cmdline_parse_token_string_t cmd_macsec_sa_set =
14681 TOKEN_STRING_INITIALIZER
14682 (struct cmd_macsec_sa_result,
14684 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
14685 TOKEN_STRING_INITIALIZER
14686 (struct cmd_macsec_sa_result,
14688 cmdline_parse_token_string_t cmd_macsec_sa_sa =
14689 TOKEN_STRING_INITIALIZER
14690 (struct cmd_macsec_sa_result,
14692 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
14693 TOKEN_STRING_INITIALIZER
14694 (struct cmd_macsec_sa_result,
14696 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
14697 TOKEN_NUM_INITIALIZER
14698 (struct cmd_macsec_sa_result,
14700 cmdline_parse_token_num_t cmd_macsec_sa_idx =
14701 TOKEN_NUM_INITIALIZER
14702 (struct cmd_macsec_sa_result,
14704 cmdline_parse_token_num_t cmd_macsec_sa_an =
14705 TOKEN_NUM_INITIALIZER
14706 (struct cmd_macsec_sa_result,
14708 cmdline_parse_token_num_t cmd_macsec_sa_pn =
14709 TOKEN_NUM_INITIALIZER
14710 (struct cmd_macsec_sa_result,
14712 cmdline_parse_token_string_t cmd_macsec_sa_key =
14713 TOKEN_STRING_INITIALIZER
14714 (struct cmd_macsec_sa_result,
14718 cmd_set_macsec_sa_parsed(
14719 void *parsed_result,
14720 __rte_unused struct cmdline *cl,
14721 __rte_unused void *data)
14723 struct cmd_macsec_sa_result *res = parsed_result;
14724 int ret = -ENOTSUP;
14725 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
14726 uint8_t key[16] = { 0 };
14732 key_len = strlen(res->key) / 2;
14736 for (i = 0; i < key_len; i++) {
14737 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
14740 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
14743 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
14746 #ifdef RTE_NET_IXGBE
14748 rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
14749 res->idx, res->an, res->pn, key) :
14750 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
14751 res->idx, res->an, res->pn, key);
14753 RTE_SET_USED(is_tx);
14760 printf("invalid idx %d or an %d\n", res->idx, res->an);
14763 printf("invalid port_id %d\n", res->port_id);
14766 printf("not supported on port %d\n", res->port_id);
14769 printf("programming error: (%s)\n", strerror(-ret));
14773 cmdline_parse_inst_t cmd_set_macsec_sa = {
14774 .f = cmd_set_macsec_sa_parsed,
14776 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
14778 (void *)&cmd_macsec_sa_set,
14779 (void *)&cmd_macsec_sa_macsec,
14780 (void *)&cmd_macsec_sa_sa,
14781 (void *)&cmd_macsec_sa_tx_rx,
14782 (void *)&cmd_macsec_sa_port_id,
14783 (void *)&cmd_macsec_sa_idx,
14784 (void *)&cmd_macsec_sa_an,
14785 (void *)&cmd_macsec_sa_pn,
14786 (void *)&cmd_macsec_sa_key,
14791 /* VF unicast promiscuous mode configuration */
14793 /* Common result structure for VF unicast promiscuous mode */
14794 struct cmd_vf_promisc_result {
14795 cmdline_fixed_string_t set;
14796 cmdline_fixed_string_t vf;
14797 cmdline_fixed_string_t promisc;
14800 cmdline_fixed_string_t on_off;
14803 /* Common CLI fields for VF unicast promiscuous mode enable disable */
14804 cmdline_parse_token_string_t cmd_vf_promisc_set =
14805 TOKEN_STRING_INITIALIZER
14806 (struct cmd_vf_promisc_result,
14808 cmdline_parse_token_string_t cmd_vf_promisc_vf =
14809 TOKEN_STRING_INITIALIZER
14810 (struct cmd_vf_promisc_result,
14812 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
14813 TOKEN_STRING_INITIALIZER
14814 (struct cmd_vf_promisc_result,
14815 promisc, "promisc");
14816 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
14817 TOKEN_NUM_INITIALIZER
14818 (struct cmd_vf_promisc_result,
14820 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
14821 TOKEN_NUM_INITIALIZER
14822 (struct cmd_vf_promisc_result,
14824 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
14825 TOKEN_STRING_INITIALIZER
14826 (struct cmd_vf_promisc_result,
14830 cmd_set_vf_promisc_parsed(
14831 void *parsed_result,
14832 __rte_unused struct cmdline *cl,
14833 __rte_unused void *data)
14835 struct cmd_vf_promisc_result *res = parsed_result;
14836 int ret = -ENOTSUP;
14838 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14840 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14843 #ifdef RTE_NET_I40E
14844 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
14845 res->vf_id, is_on);
14852 printf("invalid vf_id %d\n", res->vf_id);
14855 printf("invalid port_id %d\n", res->port_id);
14858 printf("function not implemented\n");
14861 printf("programming error: (%s)\n", strerror(-ret));
14865 cmdline_parse_inst_t cmd_set_vf_promisc = {
14866 .f = cmd_set_vf_promisc_parsed,
14868 .help_str = "set vf promisc <port_id> <vf_id> on|off: "
14869 "Set unicast promiscuous mode for a VF from the PF",
14871 (void *)&cmd_vf_promisc_set,
14872 (void *)&cmd_vf_promisc_vf,
14873 (void *)&cmd_vf_promisc_promisc,
14874 (void *)&cmd_vf_promisc_port_id,
14875 (void *)&cmd_vf_promisc_vf_id,
14876 (void *)&cmd_vf_promisc_on_off,
14881 /* VF multicast promiscuous mode configuration */
14883 /* Common result structure for VF multicast promiscuous mode */
14884 struct cmd_vf_allmulti_result {
14885 cmdline_fixed_string_t set;
14886 cmdline_fixed_string_t vf;
14887 cmdline_fixed_string_t allmulti;
14890 cmdline_fixed_string_t on_off;
14893 /* Common CLI fields for VF multicast promiscuous mode enable disable */
14894 cmdline_parse_token_string_t cmd_vf_allmulti_set =
14895 TOKEN_STRING_INITIALIZER
14896 (struct cmd_vf_allmulti_result,
14898 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
14899 TOKEN_STRING_INITIALIZER
14900 (struct cmd_vf_allmulti_result,
14902 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
14903 TOKEN_STRING_INITIALIZER
14904 (struct cmd_vf_allmulti_result,
14905 allmulti, "allmulti");
14906 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
14907 TOKEN_NUM_INITIALIZER
14908 (struct cmd_vf_allmulti_result,
14910 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
14911 TOKEN_NUM_INITIALIZER
14912 (struct cmd_vf_allmulti_result,
14914 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
14915 TOKEN_STRING_INITIALIZER
14916 (struct cmd_vf_allmulti_result,
14920 cmd_set_vf_allmulti_parsed(
14921 void *parsed_result,
14922 __rte_unused struct cmdline *cl,
14923 __rte_unused void *data)
14925 struct cmd_vf_allmulti_result *res = parsed_result;
14926 int ret = -ENOTSUP;
14928 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14930 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14933 #ifdef RTE_NET_I40E
14934 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
14935 res->vf_id, is_on);
14942 printf("invalid vf_id %d\n", res->vf_id);
14945 printf("invalid port_id %d\n", res->port_id);
14948 printf("function not implemented\n");
14951 printf("programming error: (%s)\n", strerror(-ret));
14955 cmdline_parse_inst_t cmd_set_vf_allmulti = {
14956 .f = cmd_set_vf_allmulti_parsed,
14958 .help_str = "set vf allmulti <port_id> <vf_id> on|off: "
14959 "Set multicast promiscuous mode for a VF from the PF",
14961 (void *)&cmd_vf_allmulti_set,
14962 (void *)&cmd_vf_allmulti_vf,
14963 (void *)&cmd_vf_allmulti_allmulti,
14964 (void *)&cmd_vf_allmulti_port_id,
14965 (void *)&cmd_vf_allmulti_vf_id,
14966 (void *)&cmd_vf_allmulti_on_off,
14971 /* vf broadcast mode configuration */
14973 /* Common result structure for vf broadcast */
14974 struct cmd_set_vf_broadcast_result {
14975 cmdline_fixed_string_t set;
14976 cmdline_fixed_string_t vf;
14977 cmdline_fixed_string_t broadcast;
14980 cmdline_fixed_string_t on_off;
14983 /* Common CLI fields for vf broadcast enable disable */
14984 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
14985 TOKEN_STRING_INITIALIZER
14986 (struct cmd_set_vf_broadcast_result,
14988 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
14989 TOKEN_STRING_INITIALIZER
14990 (struct cmd_set_vf_broadcast_result,
14992 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
14993 TOKEN_STRING_INITIALIZER
14994 (struct cmd_set_vf_broadcast_result,
14995 broadcast, "broadcast");
14996 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
14997 TOKEN_NUM_INITIALIZER
14998 (struct cmd_set_vf_broadcast_result,
15000 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
15001 TOKEN_NUM_INITIALIZER
15002 (struct cmd_set_vf_broadcast_result,
15004 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
15005 TOKEN_STRING_INITIALIZER
15006 (struct cmd_set_vf_broadcast_result,
15010 cmd_set_vf_broadcast_parsed(
15011 void *parsed_result,
15012 __rte_unused struct cmdline *cl,
15013 __rte_unused void *data)
15015 struct cmd_set_vf_broadcast_result *res = parsed_result;
15016 int ret = -ENOTSUP;
15018 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
15020 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15023 #ifdef RTE_NET_I40E
15024 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
15025 res->vf_id, is_on);
15032 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
15035 printf("invalid port_id %d\n", res->port_id);
15038 printf("function not implemented\n");
15041 printf("programming error: (%s)\n", strerror(-ret));
15045 cmdline_parse_inst_t cmd_set_vf_broadcast = {
15046 .f = cmd_set_vf_broadcast_parsed,
15048 .help_str = "set vf broadcast <port_id> <vf_id> on|off",
15050 (void *)&cmd_set_vf_broadcast_set,
15051 (void *)&cmd_set_vf_broadcast_vf,
15052 (void *)&cmd_set_vf_broadcast_broadcast,
15053 (void *)&cmd_set_vf_broadcast_port_id,
15054 (void *)&cmd_set_vf_broadcast_vf_id,
15055 (void *)&cmd_set_vf_broadcast_on_off,
15060 /* vf vlan tag configuration */
15062 /* Common result structure for vf vlan tag */
15063 struct cmd_set_vf_vlan_tag_result {
15064 cmdline_fixed_string_t set;
15065 cmdline_fixed_string_t vf;
15066 cmdline_fixed_string_t vlan;
15067 cmdline_fixed_string_t tag;
15070 cmdline_fixed_string_t on_off;
15073 /* Common CLI fields for vf vlan tag enable disable */
15074 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
15075 TOKEN_STRING_INITIALIZER
15076 (struct cmd_set_vf_vlan_tag_result,
15078 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
15079 TOKEN_STRING_INITIALIZER
15080 (struct cmd_set_vf_vlan_tag_result,
15082 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
15083 TOKEN_STRING_INITIALIZER
15084 (struct cmd_set_vf_vlan_tag_result,
15086 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
15087 TOKEN_STRING_INITIALIZER
15088 (struct cmd_set_vf_vlan_tag_result,
15090 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
15091 TOKEN_NUM_INITIALIZER
15092 (struct cmd_set_vf_vlan_tag_result,
15094 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
15095 TOKEN_NUM_INITIALIZER
15096 (struct cmd_set_vf_vlan_tag_result,
15098 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
15099 TOKEN_STRING_INITIALIZER
15100 (struct cmd_set_vf_vlan_tag_result,
15104 cmd_set_vf_vlan_tag_parsed(
15105 void *parsed_result,
15106 __rte_unused struct cmdline *cl,
15107 __rte_unused void *data)
15109 struct cmd_set_vf_vlan_tag_result *res = parsed_result;
15110 int ret = -ENOTSUP;
15112 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
15114 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15117 #ifdef RTE_NET_I40E
15118 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
15119 res->vf_id, is_on);
15126 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
15129 printf("invalid port_id %d\n", res->port_id);
15132 printf("function not implemented\n");
15135 printf("programming error: (%s)\n", strerror(-ret));
15139 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
15140 .f = cmd_set_vf_vlan_tag_parsed,
15142 .help_str = "set vf vlan tag <port_id> <vf_id> on|off",
15144 (void *)&cmd_set_vf_vlan_tag_set,
15145 (void *)&cmd_set_vf_vlan_tag_vf,
15146 (void *)&cmd_set_vf_vlan_tag_vlan,
15147 (void *)&cmd_set_vf_vlan_tag_tag,
15148 (void *)&cmd_set_vf_vlan_tag_port_id,
15149 (void *)&cmd_set_vf_vlan_tag_vf_id,
15150 (void *)&cmd_set_vf_vlan_tag_on_off,
15155 /* Common definition of VF and TC TX bandwidth configuration */
15156 struct cmd_vf_tc_bw_result {
15157 cmdline_fixed_string_t set;
15158 cmdline_fixed_string_t vf;
15159 cmdline_fixed_string_t tc;
15160 cmdline_fixed_string_t tx;
15161 cmdline_fixed_string_t min_bw;
15162 cmdline_fixed_string_t max_bw;
15163 cmdline_fixed_string_t strict_link_prio;
15168 cmdline_fixed_string_t bw_list;
15172 cmdline_parse_token_string_t cmd_vf_tc_bw_set =
15173 TOKEN_STRING_INITIALIZER
15174 (struct cmd_vf_tc_bw_result,
15176 cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
15177 TOKEN_STRING_INITIALIZER
15178 (struct cmd_vf_tc_bw_result,
15180 cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
15181 TOKEN_STRING_INITIALIZER
15182 (struct cmd_vf_tc_bw_result,
15184 cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
15185 TOKEN_STRING_INITIALIZER
15186 (struct cmd_vf_tc_bw_result,
15188 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio =
15189 TOKEN_STRING_INITIALIZER
15190 (struct cmd_vf_tc_bw_result,
15191 strict_link_prio, "strict-link-priority");
15192 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw =
15193 TOKEN_STRING_INITIALIZER
15194 (struct cmd_vf_tc_bw_result,
15195 min_bw, "min-bandwidth");
15196 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
15197 TOKEN_STRING_INITIALIZER
15198 (struct cmd_vf_tc_bw_result,
15199 max_bw, "max-bandwidth");
15200 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
15201 TOKEN_NUM_INITIALIZER
15202 (struct cmd_vf_tc_bw_result,
15204 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
15205 TOKEN_NUM_INITIALIZER
15206 (struct cmd_vf_tc_bw_result,
15208 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no =
15209 TOKEN_NUM_INITIALIZER
15210 (struct cmd_vf_tc_bw_result,
15212 cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
15213 TOKEN_NUM_INITIALIZER
15214 (struct cmd_vf_tc_bw_result,
15216 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
15217 TOKEN_STRING_INITIALIZER
15218 (struct cmd_vf_tc_bw_result,
15220 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map =
15221 TOKEN_NUM_INITIALIZER
15222 (struct cmd_vf_tc_bw_result,
15225 /* VF max bandwidth setting */
15227 cmd_vf_max_bw_parsed(
15228 void *parsed_result,
15229 __rte_unused struct cmdline *cl,
15230 __rte_unused void *data)
15232 struct cmd_vf_tc_bw_result *res = parsed_result;
15233 int ret = -ENOTSUP;
15235 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15238 #ifdef RTE_NET_I40E
15239 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id,
15240 res->vf_id, res->bw);
15247 printf("invalid vf_id %d or bandwidth %d\n",
15248 res->vf_id, res->bw);
15251 printf("invalid port_id %d\n", res->port_id);
15254 printf("function not implemented\n");
15257 printf("programming error: (%s)\n", strerror(-ret));
15261 cmdline_parse_inst_t cmd_vf_max_bw = {
15262 .f = cmd_vf_max_bw_parsed,
15264 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
15266 (void *)&cmd_vf_tc_bw_set,
15267 (void *)&cmd_vf_tc_bw_vf,
15268 (void *)&cmd_vf_tc_bw_tx,
15269 (void *)&cmd_vf_tc_bw_max_bw,
15270 (void *)&cmd_vf_tc_bw_port_id,
15271 (void *)&cmd_vf_tc_bw_vf_id,
15272 (void *)&cmd_vf_tc_bw_bw,
15278 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
15283 const char *p, *p0 = str;
15290 p = strchr(p0, '(');
15292 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
15296 p0 = strchr(p, ')');
15298 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
15302 if (size >= sizeof(s)) {
15303 printf("The string size exceeds the internal buffer size\n");
15306 snprintf(s, sizeof(s), "%.*s", size, p);
15307 ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
15309 printf("Failed to get the bandwidth list. ");
15313 for (i = 0; i < ret; i++)
15314 bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
15319 /* TC min bandwidth setting */
15321 cmd_vf_tc_min_bw_parsed(
15322 void *parsed_result,
15323 __rte_unused struct cmdline *cl,
15324 __rte_unused void *data)
15326 struct cmd_vf_tc_bw_result *res = parsed_result;
15329 int ret = -ENOTSUP;
15331 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15334 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
15338 #ifdef RTE_NET_I40E
15339 ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
15347 printf("invalid vf_id %d or bandwidth\n", res->vf_id);
15350 printf("invalid port_id %d\n", res->port_id);
15353 printf("function not implemented\n");
15356 printf("programming error: (%s)\n", strerror(-ret));
15360 cmdline_parse_inst_t cmd_vf_tc_min_bw = {
15361 .f = cmd_vf_tc_min_bw_parsed,
15363 .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
15364 " <bw1, bw2, ...>",
15366 (void *)&cmd_vf_tc_bw_set,
15367 (void *)&cmd_vf_tc_bw_vf,
15368 (void *)&cmd_vf_tc_bw_tc,
15369 (void *)&cmd_vf_tc_bw_tx,
15370 (void *)&cmd_vf_tc_bw_min_bw,
15371 (void *)&cmd_vf_tc_bw_port_id,
15372 (void *)&cmd_vf_tc_bw_vf_id,
15373 (void *)&cmd_vf_tc_bw_bw_list,
15379 cmd_tc_min_bw_parsed(
15380 void *parsed_result,
15381 __rte_unused struct cmdline *cl,
15382 __rte_unused void *data)
15384 struct cmd_vf_tc_bw_result *res = parsed_result;
15385 struct rte_port *port;
15388 int ret = -ENOTSUP;
15390 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15393 port = &ports[res->port_id];
15394 /** Check if the port is not started **/
15395 if (port->port_status != RTE_PORT_STOPPED) {
15396 printf("Please stop port %d first\n", res->port_id);
15400 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
15404 #ifdef RTE_NET_IXGBE
15405 ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw);
15412 printf("invalid bandwidth\n");
15415 printf("invalid port_id %d\n", res->port_id);
15418 printf("function not implemented\n");
15421 printf("programming error: (%s)\n", strerror(-ret));
15425 cmdline_parse_inst_t cmd_tc_min_bw = {
15426 .f = cmd_tc_min_bw_parsed,
15428 .help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>",
15430 (void *)&cmd_vf_tc_bw_set,
15431 (void *)&cmd_vf_tc_bw_tc,
15432 (void *)&cmd_vf_tc_bw_tx,
15433 (void *)&cmd_vf_tc_bw_min_bw,
15434 (void *)&cmd_vf_tc_bw_port_id,
15435 (void *)&cmd_vf_tc_bw_bw_list,
15440 /* TC max bandwidth setting */
15442 cmd_vf_tc_max_bw_parsed(
15443 void *parsed_result,
15444 __rte_unused struct cmdline *cl,
15445 __rte_unused void *data)
15447 struct cmd_vf_tc_bw_result *res = parsed_result;
15448 int ret = -ENOTSUP;
15450 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15453 #ifdef RTE_NET_I40E
15454 ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id,
15455 res->tc_no, res->bw);
15462 printf("invalid vf_id %d, tc_no %d or bandwidth %d\n",
15463 res->vf_id, res->tc_no, res->bw);
15466 printf("invalid port_id %d\n", res->port_id);
15469 printf("function not implemented\n");
15472 printf("programming error: (%s)\n", strerror(-ret));
15476 cmdline_parse_inst_t cmd_vf_tc_max_bw = {
15477 .f = cmd_vf_tc_max_bw_parsed,
15479 .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>"
15482 (void *)&cmd_vf_tc_bw_set,
15483 (void *)&cmd_vf_tc_bw_vf,
15484 (void *)&cmd_vf_tc_bw_tc,
15485 (void *)&cmd_vf_tc_bw_tx,
15486 (void *)&cmd_vf_tc_bw_max_bw,
15487 (void *)&cmd_vf_tc_bw_port_id,
15488 (void *)&cmd_vf_tc_bw_vf_id,
15489 (void *)&cmd_vf_tc_bw_tc_no,
15490 (void *)&cmd_vf_tc_bw_bw,
15495 /** Set VXLAN encapsulation details */
15496 struct cmd_set_vxlan_result {
15497 cmdline_fixed_string_t set;
15498 cmdline_fixed_string_t vxlan;
15499 cmdline_fixed_string_t pos_token;
15500 cmdline_fixed_string_t ip_version;
15501 uint32_t vlan_present:1;
15505 cmdline_ipaddr_t ip_src;
15506 cmdline_ipaddr_t ip_dst;
15510 struct rte_ether_addr eth_src;
15511 struct rte_ether_addr eth_dst;
15514 cmdline_parse_token_string_t cmd_set_vxlan_set =
15515 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, set, "set");
15516 cmdline_parse_token_string_t cmd_set_vxlan_vxlan =
15517 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan, "vxlan");
15518 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_tos_ttl =
15519 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
15521 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_with_vlan =
15522 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
15523 "vxlan-with-vlan");
15524 cmdline_parse_token_string_t cmd_set_vxlan_ip_version =
15525 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15527 cmdline_parse_token_string_t cmd_set_vxlan_ip_version_value =
15528 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, ip_version,
15530 cmdline_parse_token_string_t cmd_set_vxlan_vni =
15531 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15533 cmdline_parse_token_num_t cmd_set_vxlan_vni_value =
15534 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, vni, UINT32);
15535 cmdline_parse_token_string_t cmd_set_vxlan_udp_src =
15536 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15538 cmdline_parse_token_num_t cmd_set_vxlan_udp_src_value =
15539 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_src, UINT16);
15540 cmdline_parse_token_string_t cmd_set_vxlan_udp_dst =
15541 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15543 cmdline_parse_token_num_t cmd_set_vxlan_udp_dst_value =
15544 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_dst, UINT16);
15545 cmdline_parse_token_string_t cmd_set_vxlan_ip_tos =
15546 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15548 cmdline_parse_token_num_t cmd_set_vxlan_ip_tos_value =
15549 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tos, UINT8);
15550 cmdline_parse_token_string_t cmd_set_vxlan_ip_ttl =
15551 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15553 cmdline_parse_token_num_t cmd_set_vxlan_ip_ttl_value =
15554 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, ttl, UINT8);
15555 cmdline_parse_token_string_t cmd_set_vxlan_ip_src =
15556 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15558 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_src_value =
15559 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_src);
15560 cmdline_parse_token_string_t cmd_set_vxlan_ip_dst =
15561 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15563 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_dst_value =
15564 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_dst);
15565 cmdline_parse_token_string_t cmd_set_vxlan_vlan =
15566 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15568 cmdline_parse_token_num_t cmd_set_vxlan_vlan_value =
15569 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tci, UINT16);
15570 cmdline_parse_token_string_t cmd_set_vxlan_eth_src =
15571 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15573 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_src_value =
15574 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_src);
15575 cmdline_parse_token_string_t cmd_set_vxlan_eth_dst =
15576 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15578 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_dst_value =
15579 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_dst);
15581 static void cmd_set_vxlan_parsed(void *parsed_result,
15582 __rte_unused struct cmdline *cl,
15583 __rte_unused void *data)
15585 struct cmd_set_vxlan_result *res = parsed_result;
15590 .vxlan_id = rte_cpu_to_be_32(res->vni) & RTE_BE32(0x00ffffff),
15593 vxlan_encap_conf.select_tos_ttl = 0;
15594 if (strcmp(res->vxlan, "vxlan") == 0)
15595 vxlan_encap_conf.select_vlan = 0;
15596 else if (strcmp(res->vxlan, "vxlan-with-vlan") == 0)
15597 vxlan_encap_conf.select_vlan = 1;
15598 else if (strcmp(res->vxlan, "vxlan-tos-ttl") == 0) {
15599 vxlan_encap_conf.select_vlan = 0;
15600 vxlan_encap_conf.select_tos_ttl = 1;
15602 if (strcmp(res->ip_version, "ipv4") == 0)
15603 vxlan_encap_conf.select_ipv4 = 1;
15604 else if (strcmp(res->ip_version, "ipv6") == 0)
15605 vxlan_encap_conf.select_ipv4 = 0;
15608 rte_memcpy(vxlan_encap_conf.vni, &id.vni[1], 3);
15609 vxlan_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
15610 vxlan_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
15611 vxlan_encap_conf.ip_tos = res->tos;
15612 vxlan_encap_conf.ip_ttl = res->ttl;
15613 if (vxlan_encap_conf.select_ipv4) {
15614 IPV4_ADDR_TO_UINT(res->ip_src, vxlan_encap_conf.ipv4_src);
15615 IPV4_ADDR_TO_UINT(res->ip_dst, vxlan_encap_conf.ipv4_dst);
15617 IPV6_ADDR_TO_ARRAY(res->ip_src, vxlan_encap_conf.ipv6_src);
15618 IPV6_ADDR_TO_ARRAY(res->ip_dst, vxlan_encap_conf.ipv6_dst);
15620 if (vxlan_encap_conf.select_vlan)
15621 vxlan_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15622 rte_memcpy(vxlan_encap_conf.eth_src, res->eth_src.addr_bytes,
15623 RTE_ETHER_ADDR_LEN);
15624 rte_memcpy(vxlan_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15625 RTE_ETHER_ADDR_LEN);
15628 cmdline_parse_inst_t cmd_set_vxlan = {
15629 .f = cmd_set_vxlan_parsed,
15631 .help_str = "set vxlan ip-version ipv4|ipv6 vni <vni> udp-src"
15632 " <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst <ip-dst>"
15633 " eth-src <eth-src> eth-dst <eth-dst>",
15635 (void *)&cmd_set_vxlan_set,
15636 (void *)&cmd_set_vxlan_vxlan,
15637 (void *)&cmd_set_vxlan_ip_version,
15638 (void *)&cmd_set_vxlan_ip_version_value,
15639 (void *)&cmd_set_vxlan_vni,
15640 (void *)&cmd_set_vxlan_vni_value,
15641 (void *)&cmd_set_vxlan_udp_src,
15642 (void *)&cmd_set_vxlan_udp_src_value,
15643 (void *)&cmd_set_vxlan_udp_dst,
15644 (void *)&cmd_set_vxlan_udp_dst_value,
15645 (void *)&cmd_set_vxlan_ip_src,
15646 (void *)&cmd_set_vxlan_ip_src_value,
15647 (void *)&cmd_set_vxlan_ip_dst,
15648 (void *)&cmd_set_vxlan_ip_dst_value,
15649 (void *)&cmd_set_vxlan_eth_src,
15650 (void *)&cmd_set_vxlan_eth_src_value,
15651 (void *)&cmd_set_vxlan_eth_dst,
15652 (void *)&cmd_set_vxlan_eth_dst_value,
15657 cmdline_parse_inst_t cmd_set_vxlan_tos_ttl = {
15658 .f = cmd_set_vxlan_parsed,
15660 .help_str = "set vxlan-tos-ttl ip-version ipv4|ipv6 vni <vni> udp-src"
15661 " <udp-src> udp-dst <udp-dst> ip-tos <ip-tos> ip-ttl <ip-ttl>"
15662 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
15663 " eth-dst <eth-dst>",
15665 (void *)&cmd_set_vxlan_set,
15666 (void *)&cmd_set_vxlan_vxlan_tos_ttl,
15667 (void *)&cmd_set_vxlan_ip_version,
15668 (void *)&cmd_set_vxlan_ip_version_value,
15669 (void *)&cmd_set_vxlan_vni,
15670 (void *)&cmd_set_vxlan_vni_value,
15671 (void *)&cmd_set_vxlan_udp_src,
15672 (void *)&cmd_set_vxlan_udp_src_value,
15673 (void *)&cmd_set_vxlan_udp_dst,
15674 (void *)&cmd_set_vxlan_udp_dst_value,
15675 (void *)&cmd_set_vxlan_ip_tos,
15676 (void *)&cmd_set_vxlan_ip_tos_value,
15677 (void *)&cmd_set_vxlan_ip_ttl,
15678 (void *)&cmd_set_vxlan_ip_ttl_value,
15679 (void *)&cmd_set_vxlan_ip_src,
15680 (void *)&cmd_set_vxlan_ip_src_value,
15681 (void *)&cmd_set_vxlan_ip_dst,
15682 (void *)&cmd_set_vxlan_ip_dst_value,
15683 (void *)&cmd_set_vxlan_eth_src,
15684 (void *)&cmd_set_vxlan_eth_src_value,
15685 (void *)&cmd_set_vxlan_eth_dst,
15686 (void *)&cmd_set_vxlan_eth_dst_value,
15691 cmdline_parse_inst_t cmd_set_vxlan_with_vlan = {
15692 .f = cmd_set_vxlan_parsed,
15694 .help_str = "set vxlan-with-vlan ip-version ipv4|ipv6 vni <vni>"
15695 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst"
15696 " <ip-dst> vlan-tci <vlan-tci> eth-src <eth-src> eth-dst"
15699 (void *)&cmd_set_vxlan_set,
15700 (void *)&cmd_set_vxlan_vxlan_with_vlan,
15701 (void *)&cmd_set_vxlan_ip_version,
15702 (void *)&cmd_set_vxlan_ip_version_value,
15703 (void *)&cmd_set_vxlan_vni,
15704 (void *)&cmd_set_vxlan_vni_value,
15705 (void *)&cmd_set_vxlan_udp_src,
15706 (void *)&cmd_set_vxlan_udp_src_value,
15707 (void *)&cmd_set_vxlan_udp_dst,
15708 (void *)&cmd_set_vxlan_udp_dst_value,
15709 (void *)&cmd_set_vxlan_ip_src,
15710 (void *)&cmd_set_vxlan_ip_src_value,
15711 (void *)&cmd_set_vxlan_ip_dst,
15712 (void *)&cmd_set_vxlan_ip_dst_value,
15713 (void *)&cmd_set_vxlan_vlan,
15714 (void *)&cmd_set_vxlan_vlan_value,
15715 (void *)&cmd_set_vxlan_eth_src,
15716 (void *)&cmd_set_vxlan_eth_src_value,
15717 (void *)&cmd_set_vxlan_eth_dst,
15718 (void *)&cmd_set_vxlan_eth_dst_value,
15723 /** Set NVGRE encapsulation details */
15724 struct cmd_set_nvgre_result {
15725 cmdline_fixed_string_t set;
15726 cmdline_fixed_string_t nvgre;
15727 cmdline_fixed_string_t pos_token;
15728 cmdline_fixed_string_t ip_version;
15730 cmdline_ipaddr_t ip_src;
15731 cmdline_ipaddr_t ip_dst;
15733 struct rte_ether_addr eth_src;
15734 struct rte_ether_addr eth_dst;
15737 cmdline_parse_token_string_t cmd_set_nvgre_set =
15738 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, set, "set");
15739 cmdline_parse_token_string_t cmd_set_nvgre_nvgre =
15740 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre, "nvgre");
15741 cmdline_parse_token_string_t cmd_set_nvgre_nvgre_with_vlan =
15742 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre,
15743 "nvgre-with-vlan");
15744 cmdline_parse_token_string_t cmd_set_nvgre_ip_version =
15745 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15747 cmdline_parse_token_string_t cmd_set_nvgre_ip_version_value =
15748 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, ip_version,
15750 cmdline_parse_token_string_t cmd_set_nvgre_tni =
15751 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15753 cmdline_parse_token_num_t cmd_set_nvgre_tni_value =
15754 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tni, UINT32);
15755 cmdline_parse_token_string_t cmd_set_nvgre_ip_src =
15756 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15758 cmdline_parse_token_num_t cmd_set_nvgre_ip_src_value =
15759 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_src);
15760 cmdline_parse_token_string_t cmd_set_nvgre_ip_dst =
15761 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15763 cmdline_parse_token_ipaddr_t cmd_set_nvgre_ip_dst_value =
15764 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_dst);
15765 cmdline_parse_token_string_t cmd_set_nvgre_vlan =
15766 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15768 cmdline_parse_token_num_t cmd_set_nvgre_vlan_value =
15769 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tci, UINT16);
15770 cmdline_parse_token_string_t cmd_set_nvgre_eth_src =
15771 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15773 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_src_value =
15774 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_src);
15775 cmdline_parse_token_string_t cmd_set_nvgre_eth_dst =
15776 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15778 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_dst_value =
15779 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_dst);
15781 static void cmd_set_nvgre_parsed(void *parsed_result,
15782 __rte_unused struct cmdline *cl,
15783 __rte_unused void *data)
15785 struct cmd_set_nvgre_result *res = parsed_result;
15787 uint32_t nvgre_tni;
15790 .nvgre_tni = rte_cpu_to_be_32(res->tni) & RTE_BE32(0x00ffffff),
15793 if (strcmp(res->nvgre, "nvgre") == 0)
15794 nvgre_encap_conf.select_vlan = 0;
15795 else if (strcmp(res->nvgre, "nvgre-with-vlan") == 0)
15796 nvgre_encap_conf.select_vlan = 1;
15797 if (strcmp(res->ip_version, "ipv4") == 0)
15798 nvgre_encap_conf.select_ipv4 = 1;
15799 else if (strcmp(res->ip_version, "ipv6") == 0)
15800 nvgre_encap_conf.select_ipv4 = 0;
15803 rte_memcpy(nvgre_encap_conf.tni, &id.tni[1], 3);
15804 if (nvgre_encap_conf.select_ipv4) {
15805 IPV4_ADDR_TO_UINT(res->ip_src, nvgre_encap_conf.ipv4_src);
15806 IPV4_ADDR_TO_UINT(res->ip_dst, nvgre_encap_conf.ipv4_dst);
15808 IPV6_ADDR_TO_ARRAY(res->ip_src, nvgre_encap_conf.ipv6_src);
15809 IPV6_ADDR_TO_ARRAY(res->ip_dst, nvgre_encap_conf.ipv6_dst);
15811 if (nvgre_encap_conf.select_vlan)
15812 nvgre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15813 rte_memcpy(nvgre_encap_conf.eth_src, res->eth_src.addr_bytes,
15814 RTE_ETHER_ADDR_LEN);
15815 rte_memcpy(nvgre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15816 RTE_ETHER_ADDR_LEN);
15819 cmdline_parse_inst_t cmd_set_nvgre = {
15820 .f = cmd_set_nvgre_parsed,
15822 .help_str = "set nvgre ip-version <ipv4|ipv6> tni <tni> ip-src"
15823 " <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
15824 " eth-dst <eth-dst>",
15826 (void *)&cmd_set_nvgre_set,
15827 (void *)&cmd_set_nvgre_nvgre,
15828 (void *)&cmd_set_nvgre_ip_version,
15829 (void *)&cmd_set_nvgre_ip_version_value,
15830 (void *)&cmd_set_nvgre_tni,
15831 (void *)&cmd_set_nvgre_tni_value,
15832 (void *)&cmd_set_nvgre_ip_src,
15833 (void *)&cmd_set_nvgre_ip_src_value,
15834 (void *)&cmd_set_nvgre_ip_dst,
15835 (void *)&cmd_set_nvgre_ip_dst_value,
15836 (void *)&cmd_set_nvgre_eth_src,
15837 (void *)&cmd_set_nvgre_eth_src_value,
15838 (void *)&cmd_set_nvgre_eth_dst,
15839 (void *)&cmd_set_nvgre_eth_dst_value,
15844 cmdline_parse_inst_t cmd_set_nvgre_with_vlan = {
15845 .f = cmd_set_nvgre_parsed,
15847 .help_str = "set nvgre-with-vlan ip-version <ipv4|ipv6> tni <tni>"
15848 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
15849 " eth-src <eth-src> eth-dst <eth-dst>",
15851 (void *)&cmd_set_nvgre_set,
15852 (void *)&cmd_set_nvgre_nvgre_with_vlan,
15853 (void *)&cmd_set_nvgre_ip_version,
15854 (void *)&cmd_set_nvgre_ip_version_value,
15855 (void *)&cmd_set_nvgre_tni,
15856 (void *)&cmd_set_nvgre_tni_value,
15857 (void *)&cmd_set_nvgre_ip_src,
15858 (void *)&cmd_set_nvgre_ip_src_value,
15859 (void *)&cmd_set_nvgre_ip_dst,
15860 (void *)&cmd_set_nvgre_ip_dst_value,
15861 (void *)&cmd_set_nvgre_vlan,
15862 (void *)&cmd_set_nvgre_vlan_value,
15863 (void *)&cmd_set_nvgre_eth_src,
15864 (void *)&cmd_set_nvgre_eth_src_value,
15865 (void *)&cmd_set_nvgre_eth_dst,
15866 (void *)&cmd_set_nvgre_eth_dst_value,
15871 /** Set L2 encapsulation details */
15872 struct cmd_set_l2_encap_result {
15873 cmdline_fixed_string_t set;
15874 cmdline_fixed_string_t l2_encap;
15875 cmdline_fixed_string_t pos_token;
15876 cmdline_fixed_string_t ip_version;
15877 uint32_t vlan_present:1;
15879 struct rte_ether_addr eth_src;
15880 struct rte_ether_addr eth_dst;
15883 cmdline_parse_token_string_t cmd_set_l2_encap_set =
15884 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, set, "set");
15885 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap =
15886 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap, "l2_encap");
15887 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap_with_vlan =
15888 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap,
15889 "l2_encap-with-vlan");
15890 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version =
15891 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15893 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version_value =
15894 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, ip_version,
15896 cmdline_parse_token_string_t cmd_set_l2_encap_vlan =
15897 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15899 cmdline_parse_token_num_t cmd_set_l2_encap_vlan_value =
15900 TOKEN_NUM_INITIALIZER(struct cmd_set_l2_encap_result, tci, UINT16);
15901 cmdline_parse_token_string_t cmd_set_l2_encap_eth_src =
15902 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15904 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_src_value =
15905 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_src);
15906 cmdline_parse_token_string_t cmd_set_l2_encap_eth_dst =
15907 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15909 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_dst_value =
15910 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_dst);
15912 static void cmd_set_l2_encap_parsed(void *parsed_result,
15913 __rte_unused struct cmdline *cl,
15914 __rte_unused void *data)
15916 struct cmd_set_l2_encap_result *res = parsed_result;
15918 if (strcmp(res->l2_encap, "l2_encap") == 0)
15919 l2_encap_conf.select_vlan = 0;
15920 else if (strcmp(res->l2_encap, "l2_encap-with-vlan") == 0)
15921 l2_encap_conf.select_vlan = 1;
15922 if (strcmp(res->ip_version, "ipv4") == 0)
15923 l2_encap_conf.select_ipv4 = 1;
15924 else if (strcmp(res->ip_version, "ipv6") == 0)
15925 l2_encap_conf.select_ipv4 = 0;
15928 if (l2_encap_conf.select_vlan)
15929 l2_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15930 rte_memcpy(l2_encap_conf.eth_src, res->eth_src.addr_bytes,
15931 RTE_ETHER_ADDR_LEN);
15932 rte_memcpy(l2_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15933 RTE_ETHER_ADDR_LEN);
15936 cmdline_parse_inst_t cmd_set_l2_encap = {
15937 .f = cmd_set_l2_encap_parsed,
15939 .help_str = "set l2_encap ip-version ipv4|ipv6"
15940 " eth-src <eth-src> eth-dst <eth-dst>",
15942 (void *)&cmd_set_l2_encap_set,
15943 (void *)&cmd_set_l2_encap_l2_encap,
15944 (void *)&cmd_set_l2_encap_ip_version,
15945 (void *)&cmd_set_l2_encap_ip_version_value,
15946 (void *)&cmd_set_l2_encap_eth_src,
15947 (void *)&cmd_set_l2_encap_eth_src_value,
15948 (void *)&cmd_set_l2_encap_eth_dst,
15949 (void *)&cmd_set_l2_encap_eth_dst_value,
15954 cmdline_parse_inst_t cmd_set_l2_encap_with_vlan = {
15955 .f = cmd_set_l2_encap_parsed,
15957 .help_str = "set l2_encap-with-vlan ip-version ipv4|ipv6"
15958 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
15960 (void *)&cmd_set_l2_encap_set,
15961 (void *)&cmd_set_l2_encap_l2_encap_with_vlan,
15962 (void *)&cmd_set_l2_encap_ip_version,
15963 (void *)&cmd_set_l2_encap_ip_version_value,
15964 (void *)&cmd_set_l2_encap_vlan,
15965 (void *)&cmd_set_l2_encap_vlan_value,
15966 (void *)&cmd_set_l2_encap_eth_src,
15967 (void *)&cmd_set_l2_encap_eth_src_value,
15968 (void *)&cmd_set_l2_encap_eth_dst,
15969 (void *)&cmd_set_l2_encap_eth_dst_value,
15974 /** Set L2 decapsulation details */
15975 struct cmd_set_l2_decap_result {
15976 cmdline_fixed_string_t set;
15977 cmdline_fixed_string_t l2_decap;
15978 cmdline_fixed_string_t pos_token;
15979 uint32_t vlan_present:1;
15982 cmdline_parse_token_string_t cmd_set_l2_decap_set =
15983 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, set, "set");
15984 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap =
15985 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
15987 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap_with_vlan =
15988 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
15989 "l2_decap-with-vlan");
15991 static void cmd_set_l2_decap_parsed(void *parsed_result,
15992 __rte_unused struct cmdline *cl,
15993 __rte_unused void *data)
15995 struct cmd_set_l2_decap_result *res = parsed_result;
15997 if (strcmp(res->l2_decap, "l2_decap") == 0)
15998 l2_decap_conf.select_vlan = 0;
15999 else if (strcmp(res->l2_decap, "l2_decap-with-vlan") == 0)
16000 l2_decap_conf.select_vlan = 1;
16003 cmdline_parse_inst_t cmd_set_l2_decap = {
16004 .f = cmd_set_l2_decap_parsed,
16006 .help_str = "set l2_decap",
16008 (void *)&cmd_set_l2_decap_set,
16009 (void *)&cmd_set_l2_decap_l2_decap,
16014 cmdline_parse_inst_t cmd_set_l2_decap_with_vlan = {
16015 .f = cmd_set_l2_decap_parsed,
16017 .help_str = "set l2_decap-with-vlan",
16019 (void *)&cmd_set_l2_decap_set,
16020 (void *)&cmd_set_l2_decap_l2_decap_with_vlan,
16025 /** Set MPLSoGRE encapsulation details */
16026 struct cmd_set_mplsogre_encap_result {
16027 cmdline_fixed_string_t set;
16028 cmdline_fixed_string_t mplsogre;
16029 cmdline_fixed_string_t pos_token;
16030 cmdline_fixed_string_t ip_version;
16031 uint32_t vlan_present:1;
16033 cmdline_ipaddr_t ip_src;
16034 cmdline_ipaddr_t ip_dst;
16036 struct rte_ether_addr eth_src;
16037 struct rte_ether_addr eth_dst;
16040 cmdline_parse_token_string_t cmd_set_mplsogre_encap_set =
16041 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, set,
16043 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap =
16044 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, mplsogre,
16046 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap_with_vlan =
16047 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
16048 mplsogre, "mplsogre_encap-with-vlan");
16049 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version =
16050 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
16051 pos_token, "ip-version");
16052 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version_value =
16053 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
16054 ip_version, "ipv4#ipv6");
16055 cmdline_parse_token_string_t cmd_set_mplsogre_encap_label =
16056 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
16057 pos_token, "label");
16058 cmdline_parse_token_num_t cmd_set_mplsogre_encap_label_value =
16059 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, label,
16061 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_src =
16062 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
16063 pos_token, "ip-src");
16064 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_src_value =
16065 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_src);
16066 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_dst =
16067 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
16068 pos_token, "ip-dst");
16069 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_dst_value =
16070 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_dst);
16071 cmdline_parse_token_string_t cmd_set_mplsogre_encap_vlan =
16072 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
16073 pos_token, "vlan-tci");
16074 cmdline_parse_token_num_t cmd_set_mplsogre_encap_vlan_value =
16075 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, tci,
16077 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_src =
16078 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
16079 pos_token, "eth-src");
16080 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_src_value =
16081 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
16083 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_dst =
16084 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
16085 pos_token, "eth-dst");
16086 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_dst_value =
16087 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
16090 static void cmd_set_mplsogre_encap_parsed(void *parsed_result,
16091 __rte_unused struct cmdline *cl,
16092 __rte_unused void *data)
16094 struct cmd_set_mplsogre_encap_result *res = parsed_result;
16096 uint32_t mplsogre_label;
16099 .mplsogre_label = rte_cpu_to_be_32(res->label<<12),
16102 if (strcmp(res->mplsogre, "mplsogre_encap") == 0)
16103 mplsogre_encap_conf.select_vlan = 0;
16104 else if (strcmp(res->mplsogre, "mplsogre_encap-with-vlan") == 0)
16105 mplsogre_encap_conf.select_vlan = 1;
16106 if (strcmp(res->ip_version, "ipv4") == 0)
16107 mplsogre_encap_conf.select_ipv4 = 1;
16108 else if (strcmp(res->ip_version, "ipv6") == 0)
16109 mplsogre_encap_conf.select_ipv4 = 0;
16112 rte_memcpy(mplsogre_encap_conf.label, &id.label, 3);
16113 if (mplsogre_encap_conf.select_ipv4) {
16114 IPV4_ADDR_TO_UINT(res->ip_src, mplsogre_encap_conf.ipv4_src);
16115 IPV4_ADDR_TO_UINT(res->ip_dst, mplsogre_encap_conf.ipv4_dst);
16117 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsogre_encap_conf.ipv6_src);
16118 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsogre_encap_conf.ipv6_dst);
16120 if (mplsogre_encap_conf.select_vlan)
16121 mplsogre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
16122 rte_memcpy(mplsogre_encap_conf.eth_src, res->eth_src.addr_bytes,
16123 RTE_ETHER_ADDR_LEN);
16124 rte_memcpy(mplsogre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
16125 RTE_ETHER_ADDR_LEN);
16128 cmdline_parse_inst_t cmd_set_mplsogre_encap = {
16129 .f = cmd_set_mplsogre_encap_parsed,
16131 .help_str = "set mplsogre_encap ip-version ipv4|ipv6 label <label>"
16132 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
16133 " eth-dst <eth-dst>",
16135 (void *)&cmd_set_mplsogre_encap_set,
16136 (void *)&cmd_set_mplsogre_encap_mplsogre_encap,
16137 (void *)&cmd_set_mplsogre_encap_ip_version,
16138 (void *)&cmd_set_mplsogre_encap_ip_version_value,
16139 (void *)&cmd_set_mplsogre_encap_label,
16140 (void *)&cmd_set_mplsogre_encap_label_value,
16141 (void *)&cmd_set_mplsogre_encap_ip_src,
16142 (void *)&cmd_set_mplsogre_encap_ip_src_value,
16143 (void *)&cmd_set_mplsogre_encap_ip_dst,
16144 (void *)&cmd_set_mplsogre_encap_ip_dst_value,
16145 (void *)&cmd_set_mplsogre_encap_eth_src,
16146 (void *)&cmd_set_mplsogre_encap_eth_src_value,
16147 (void *)&cmd_set_mplsogre_encap_eth_dst,
16148 (void *)&cmd_set_mplsogre_encap_eth_dst_value,
16153 cmdline_parse_inst_t cmd_set_mplsogre_encap_with_vlan = {
16154 .f = cmd_set_mplsogre_encap_parsed,
16156 .help_str = "set mplsogre_encap-with-vlan ip-version ipv4|ipv6"
16157 " label <label> ip-src <ip-src> ip-dst <ip-dst>"
16158 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
16160 (void *)&cmd_set_mplsogre_encap_set,
16161 (void *)&cmd_set_mplsogre_encap_mplsogre_encap_with_vlan,
16162 (void *)&cmd_set_mplsogre_encap_ip_version,
16163 (void *)&cmd_set_mplsogre_encap_ip_version_value,
16164 (void *)&cmd_set_mplsogre_encap_label,
16165 (void *)&cmd_set_mplsogre_encap_label_value,
16166 (void *)&cmd_set_mplsogre_encap_ip_src,
16167 (void *)&cmd_set_mplsogre_encap_ip_src_value,
16168 (void *)&cmd_set_mplsogre_encap_ip_dst,
16169 (void *)&cmd_set_mplsogre_encap_ip_dst_value,
16170 (void *)&cmd_set_mplsogre_encap_vlan,
16171 (void *)&cmd_set_mplsogre_encap_vlan_value,
16172 (void *)&cmd_set_mplsogre_encap_eth_src,
16173 (void *)&cmd_set_mplsogre_encap_eth_src_value,
16174 (void *)&cmd_set_mplsogre_encap_eth_dst,
16175 (void *)&cmd_set_mplsogre_encap_eth_dst_value,
16180 /** Set MPLSoGRE decapsulation details */
16181 struct cmd_set_mplsogre_decap_result {
16182 cmdline_fixed_string_t set;
16183 cmdline_fixed_string_t mplsogre;
16184 cmdline_fixed_string_t pos_token;
16185 cmdline_fixed_string_t ip_version;
16186 uint32_t vlan_present:1;
16189 cmdline_parse_token_string_t cmd_set_mplsogre_decap_set =
16190 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, set,
16192 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap =
16193 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, mplsogre,
16195 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap_with_vlan =
16196 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
16197 mplsogre, "mplsogre_decap-with-vlan");
16198 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version =
16199 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
16200 pos_token, "ip-version");
16201 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version_value =
16202 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
16203 ip_version, "ipv4#ipv6");
16205 static void cmd_set_mplsogre_decap_parsed(void *parsed_result,
16206 __rte_unused struct cmdline *cl,
16207 __rte_unused void *data)
16209 struct cmd_set_mplsogre_decap_result *res = parsed_result;
16211 if (strcmp(res->mplsogre, "mplsogre_decap") == 0)
16212 mplsogre_decap_conf.select_vlan = 0;
16213 else if (strcmp(res->mplsogre, "mplsogre_decap-with-vlan") == 0)
16214 mplsogre_decap_conf.select_vlan = 1;
16215 if (strcmp(res->ip_version, "ipv4") == 0)
16216 mplsogre_decap_conf.select_ipv4 = 1;
16217 else if (strcmp(res->ip_version, "ipv6") == 0)
16218 mplsogre_decap_conf.select_ipv4 = 0;
16221 cmdline_parse_inst_t cmd_set_mplsogre_decap = {
16222 .f = cmd_set_mplsogre_decap_parsed,
16224 .help_str = "set mplsogre_decap ip-version ipv4|ipv6",
16226 (void *)&cmd_set_mplsogre_decap_set,
16227 (void *)&cmd_set_mplsogre_decap_mplsogre_decap,
16228 (void *)&cmd_set_mplsogre_decap_ip_version,
16229 (void *)&cmd_set_mplsogre_decap_ip_version_value,
16234 cmdline_parse_inst_t cmd_set_mplsogre_decap_with_vlan = {
16235 .f = cmd_set_mplsogre_decap_parsed,
16237 .help_str = "set mplsogre_decap-with-vlan ip-version ipv4|ipv6",
16239 (void *)&cmd_set_mplsogre_decap_set,
16240 (void *)&cmd_set_mplsogre_decap_mplsogre_decap_with_vlan,
16241 (void *)&cmd_set_mplsogre_decap_ip_version,
16242 (void *)&cmd_set_mplsogre_decap_ip_version_value,
16247 /** Set MPLSoUDP encapsulation details */
16248 struct cmd_set_mplsoudp_encap_result {
16249 cmdline_fixed_string_t set;
16250 cmdline_fixed_string_t mplsoudp;
16251 cmdline_fixed_string_t pos_token;
16252 cmdline_fixed_string_t ip_version;
16253 uint32_t vlan_present:1;
16257 cmdline_ipaddr_t ip_src;
16258 cmdline_ipaddr_t ip_dst;
16260 struct rte_ether_addr eth_src;
16261 struct rte_ether_addr eth_dst;
16264 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_set =
16265 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, set,
16267 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap =
16268 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, mplsoudp,
16270 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan =
16271 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16272 mplsoudp, "mplsoudp_encap-with-vlan");
16273 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version =
16274 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16275 pos_token, "ip-version");
16276 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version_value =
16277 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16278 ip_version, "ipv4#ipv6");
16279 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_label =
16280 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16281 pos_token, "label");
16282 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_label_value =
16283 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, label,
16285 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_src =
16286 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16287 pos_token, "udp-src");
16288 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_src_value =
16289 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_src,
16291 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_dst =
16292 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16293 pos_token, "udp-dst");
16294 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_dst_value =
16295 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_dst,
16297 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_src =
16298 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16299 pos_token, "ip-src");
16300 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_src_value =
16301 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_src);
16302 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_dst =
16303 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16304 pos_token, "ip-dst");
16305 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_dst_value =
16306 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_dst);
16307 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_vlan =
16308 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16309 pos_token, "vlan-tci");
16310 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_vlan_value =
16311 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, tci,
16313 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_src =
16314 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16315 pos_token, "eth-src");
16316 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_src_value =
16317 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16319 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_dst =
16320 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16321 pos_token, "eth-dst");
16322 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_dst_value =
16323 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16326 static void cmd_set_mplsoudp_encap_parsed(void *parsed_result,
16327 __rte_unused struct cmdline *cl,
16328 __rte_unused void *data)
16330 struct cmd_set_mplsoudp_encap_result *res = parsed_result;
16332 uint32_t mplsoudp_label;
16335 .mplsoudp_label = rte_cpu_to_be_32(res->label<<12),
16338 if (strcmp(res->mplsoudp, "mplsoudp_encap") == 0)
16339 mplsoudp_encap_conf.select_vlan = 0;
16340 else if (strcmp(res->mplsoudp, "mplsoudp_encap-with-vlan") == 0)
16341 mplsoudp_encap_conf.select_vlan = 1;
16342 if (strcmp(res->ip_version, "ipv4") == 0)
16343 mplsoudp_encap_conf.select_ipv4 = 1;
16344 else if (strcmp(res->ip_version, "ipv6") == 0)
16345 mplsoudp_encap_conf.select_ipv4 = 0;
16348 rte_memcpy(mplsoudp_encap_conf.label, &id.label, 3);
16349 mplsoudp_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
16350 mplsoudp_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
16351 if (mplsoudp_encap_conf.select_ipv4) {
16352 IPV4_ADDR_TO_UINT(res->ip_src, mplsoudp_encap_conf.ipv4_src);
16353 IPV4_ADDR_TO_UINT(res->ip_dst, mplsoudp_encap_conf.ipv4_dst);
16355 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsoudp_encap_conf.ipv6_src);
16356 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsoudp_encap_conf.ipv6_dst);
16358 if (mplsoudp_encap_conf.select_vlan)
16359 mplsoudp_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
16360 rte_memcpy(mplsoudp_encap_conf.eth_src, res->eth_src.addr_bytes,
16361 RTE_ETHER_ADDR_LEN);
16362 rte_memcpy(mplsoudp_encap_conf.eth_dst, res->eth_dst.addr_bytes,
16363 RTE_ETHER_ADDR_LEN);
16366 cmdline_parse_inst_t cmd_set_mplsoudp_encap = {
16367 .f = cmd_set_mplsoudp_encap_parsed,
16369 .help_str = "set mplsoudp_encap ip-version ipv4|ipv6 label <label>"
16370 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src>"
16371 " ip-dst <ip-dst> eth-src <eth-src> eth-dst <eth-dst>",
16373 (void *)&cmd_set_mplsoudp_encap_set,
16374 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap,
16375 (void *)&cmd_set_mplsoudp_encap_ip_version,
16376 (void *)&cmd_set_mplsoudp_encap_ip_version_value,
16377 (void *)&cmd_set_mplsoudp_encap_label,
16378 (void *)&cmd_set_mplsoudp_encap_label_value,
16379 (void *)&cmd_set_mplsoudp_encap_udp_src,
16380 (void *)&cmd_set_mplsoudp_encap_udp_src_value,
16381 (void *)&cmd_set_mplsoudp_encap_udp_dst,
16382 (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
16383 (void *)&cmd_set_mplsoudp_encap_ip_src,
16384 (void *)&cmd_set_mplsoudp_encap_ip_src_value,
16385 (void *)&cmd_set_mplsoudp_encap_ip_dst,
16386 (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
16387 (void *)&cmd_set_mplsoudp_encap_eth_src,
16388 (void *)&cmd_set_mplsoudp_encap_eth_src_value,
16389 (void *)&cmd_set_mplsoudp_encap_eth_dst,
16390 (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
16395 cmdline_parse_inst_t cmd_set_mplsoudp_encap_with_vlan = {
16396 .f = cmd_set_mplsoudp_encap_parsed,
16398 .help_str = "set mplsoudp_encap-with-vlan ip-version ipv4|ipv6"
16399 " label <label> udp-src <udp-src> udp-dst <udp-dst>"
16400 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
16401 " eth-src <eth-src> eth-dst <eth-dst>",
16403 (void *)&cmd_set_mplsoudp_encap_set,
16404 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan,
16405 (void *)&cmd_set_mplsoudp_encap_ip_version,
16406 (void *)&cmd_set_mplsoudp_encap_ip_version_value,
16407 (void *)&cmd_set_mplsoudp_encap_label,
16408 (void *)&cmd_set_mplsoudp_encap_label_value,
16409 (void *)&cmd_set_mplsoudp_encap_udp_src,
16410 (void *)&cmd_set_mplsoudp_encap_udp_src_value,
16411 (void *)&cmd_set_mplsoudp_encap_udp_dst,
16412 (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
16413 (void *)&cmd_set_mplsoudp_encap_ip_src,
16414 (void *)&cmd_set_mplsoudp_encap_ip_src_value,
16415 (void *)&cmd_set_mplsoudp_encap_ip_dst,
16416 (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
16417 (void *)&cmd_set_mplsoudp_encap_vlan,
16418 (void *)&cmd_set_mplsoudp_encap_vlan_value,
16419 (void *)&cmd_set_mplsoudp_encap_eth_src,
16420 (void *)&cmd_set_mplsoudp_encap_eth_src_value,
16421 (void *)&cmd_set_mplsoudp_encap_eth_dst,
16422 (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
16427 /** Set MPLSoUDP decapsulation details */
16428 struct cmd_set_mplsoudp_decap_result {
16429 cmdline_fixed_string_t set;
16430 cmdline_fixed_string_t mplsoudp;
16431 cmdline_fixed_string_t pos_token;
16432 cmdline_fixed_string_t ip_version;
16433 uint32_t vlan_present:1;
16436 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_set =
16437 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, set,
16439 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap =
16440 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, mplsoudp,
16442 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan =
16443 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
16444 mplsoudp, "mplsoudp_decap-with-vlan");
16445 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version =
16446 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
16447 pos_token, "ip-version");
16448 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version_value =
16449 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
16450 ip_version, "ipv4#ipv6");
16452 static void cmd_set_mplsoudp_decap_parsed(void *parsed_result,
16453 __rte_unused struct cmdline *cl,
16454 __rte_unused void *data)
16456 struct cmd_set_mplsoudp_decap_result *res = parsed_result;
16458 if (strcmp(res->mplsoudp, "mplsoudp_decap") == 0)
16459 mplsoudp_decap_conf.select_vlan = 0;
16460 else if (strcmp(res->mplsoudp, "mplsoudp_decap-with-vlan") == 0)
16461 mplsoudp_decap_conf.select_vlan = 1;
16462 if (strcmp(res->ip_version, "ipv4") == 0)
16463 mplsoudp_decap_conf.select_ipv4 = 1;
16464 else if (strcmp(res->ip_version, "ipv6") == 0)
16465 mplsoudp_decap_conf.select_ipv4 = 0;
16468 cmdline_parse_inst_t cmd_set_mplsoudp_decap = {
16469 .f = cmd_set_mplsoudp_decap_parsed,
16471 .help_str = "set mplsoudp_decap ip-version ipv4|ipv6",
16473 (void *)&cmd_set_mplsoudp_decap_set,
16474 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap,
16475 (void *)&cmd_set_mplsoudp_decap_ip_version,
16476 (void *)&cmd_set_mplsoudp_decap_ip_version_value,
16481 cmdline_parse_inst_t cmd_set_mplsoudp_decap_with_vlan = {
16482 .f = cmd_set_mplsoudp_decap_parsed,
16484 .help_str = "set mplsoudp_decap-with-vlan ip-version ipv4|ipv6",
16486 (void *)&cmd_set_mplsoudp_decap_set,
16487 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan,
16488 (void *)&cmd_set_mplsoudp_decap_ip_version,
16489 (void *)&cmd_set_mplsoudp_decap_ip_version_value,
16494 /* Strict link priority scheduling mode setting */
16496 cmd_strict_link_prio_parsed(
16497 void *parsed_result,
16498 __rte_unused struct cmdline *cl,
16499 __rte_unused void *data)
16501 struct cmd_vf_tc_bw_result *res = parsed_result;
16502 int ret = -ENOTSUP;
16504 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16507 #ifdef RTE_NET_I40E
16508 ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map);
16515 printf("invalid tc_bitmap 0x%x\n", res->tc_map);
16518 printf("invalid port_id %d\n", res->port_id);
16521 printf("function not implemented\n");
16524 printf("programming error: (%s)\n", strerror(-ret));
16528 cmdline_parse_inst_t cmd_strict_link_prio = {
16529 .f = cmd_strict_link_prio_parsed,
16531 .help_str = "set tx strict-link-priority <port_id> <tc_bitmap>",
16533 (void *)&cmd_vf_tc_bw_set,
16534 (void *)&cmd_vf_tc_bw_tx,
16535 (void *)&cmd_vf_tc_bw_strict_link_prio,
16536 (void *)&cmd_vf_tc_bw_port_id,
16537 (void *)&cmd_vf_tc_bw_tc_map,
16542 /* Load dynamic device personalization*/
16543 struct cmd_ddp_add_result {
16544 cmdline_fixed_string_t ddp;
16545 cmdline_fixed_string_t add;
16550 cmdline_parse_token_string_t cmd_ddp_add_ddp =
16551 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp");
16552 cmdline_parse_token_string_t cmd_ddp_add_add =
16553 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add");
16554 cmdline_parse_token_num_t cmd_ddp_add_port_id =
16555 TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id, UINT16);
16556 cmdline_parse_token_string_t cmd_ddp_add_filepath =
16557 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL);
16560 cmd_ddp_add_parsed(
16561 void *parsed_result,
16562 __rte_unused struct cmdline *cl,
16563 __rte_unused void *data)
16565 struct cmd_ddp_add_result *res = parsed_result;
16571 int ret = -ENOTSUP;
16573 if (!all_ports_stopped()) {
16574 printf("Please stop all ports first\n");
16578 filepath = strdup(res->filepath);
16579 if (filepath == NULL) {
16580 printf("Failed to allocate memory\n");
16583 file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ',');
16585 buff = open_file(file_fld[0], &size);
16587 free((void *)filepath);
16591 #ifdef RTE_NET_I40E
16592 if (ret == -ENOTSUP)
16593 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
16595 RTE_PMD_I40E_PKG_OP_WR_ADD);
16598 if (ret == -EEXIST)
16599 printf("Profile has already existed.\n");
16601 printf("Failed to load profile.\n");
16602 else if (file_num == 2)
16603 save_file(file_fld[1], buff, size);
16606 free((void *)filepath);
16609 cmdline_parse_inst_t cmd_ddp_add = {
16610 .f = cmd_ddp_add_parsed,
16612 .help_str = "ddp add <port_id> <profile_path[,backup_profile_path]>",
16614 (void *)&cmd_ddp_add_ddp,
16615 (void *)&cmd_ddp_add_add,
16616 (void *)&cmd_ddp_add_port_id,
16617 (void *)&cmd_ddp_add_filepath,
16622 /* Delete dynamic device personalization*/
16623 struct cmd_ddp_del_result {
16624 cmdline_fixed_string_t ddp;
16625 cmdline_fixed_string_t del;
16630 cmdline_parse_token_string_t cmd_ddp_del_ddp =
16631 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp");
16632 cmdline_parse_token_string_t cmd_ddp_del_del =
16633 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del");
16634 cmdline_parse_token_num_t cmd_ddp_del_port_id =
16635 TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, UINT16);
16636 cmdline_parse_token_string_t cmd_ddp_del_filepath =
16637 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL);
16640 cmd_ddp_del_parsed(
16641 void *parsed_result,
16642 __rte_unused struct cmdline *cl,
16643 __rte_unused void *data)
16645 struct cmd_ddp_del_result *res = parsed_result;
16648 int ret = -ENOTSUP;
16650 if (!all_ports_stopped()) {
16651 printf("Please stop all ports first\n");
16655 buff = open_file(res->filepath, &size);
16659 #ifdef RTE_NET_I40E
16660 if (ret == -ENOTSUP)
16661 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
16663 RTE_PMD_I40E_PKG_OP_WR_DEL);
16666 if (ret == -EACCES)
16667 printf("Profile does not exist.\n");
16669 printf("Failed to delete profile.\n");
16674 cmdline_parse_inst_t cmd_ddp_del = {
16675 .f = cmd_ddp_del_parsed,
16677 .help_str = "ddp del <port_id> <backup_profile_path>",
16679 (void *)&cmd_ddp_del_ddp,
16680 (void *)&cmd_ddp_del_del,
16681 (void *)&cmd_ddp_del_port_id,
16682 (void *)&cmd_ddp_del_filepath,
16687 /* Get dynamic device personalization profile info */
16688 struct cmd_ddp_info_result {
16689 cmdline_fixed_string_t ddp;
16690 cmdline_fixed_string_t get;
16691 cmdline_fixed_string_t info;
16695 cmdline_parse_token_string_t cmd_ddp_info_ddp =
16696 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp");
16697 cmdline_parse_token_string_t cmd_ddp_info_get =
16698 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get");
16699 cmdline_parse_token_string_t cmd_ddp_info_info =
16700 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info");
16701 cmdline_parse_token_string_t cmd_ddp_info_filepath =
16702 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL);
16705 cmd_ddp_info_parsed(
16706 void *parsed_result,
16707 __rte_unused struct cmdline *cl,
16708 __rte_unused void *data)
16710 struct cmd_ddp_info_result *res = parsed_result;
16713 int ret = -ENOTSUP;
16714 #ifdef RTE_NET_I40E
16717 uint32_t buff_size = 0;
16718 struct rte_pmd_i40e_profile_info info;
16719 uint32_t dev_num = 0;
16720 struct rte_pmd_i40e_ddp_device_id *devs;
16721 uint32_t proto_num = 0;
16722 struct rte_pmd_i40e_proto_info *proto = NULL;
16723 uint32_t pctype_num = 0;
16724 struct rte_pmd_i40e_ptype_info *pctype;
16725 uint32_t ptype_num = 0;
16726 struct rte_pmd_i40e_ptype_info *ptype;
16731 pkg = open_file(res->filepath, &pkg_size);
16735 #ifdef RTE_NET_I40E
16736 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16737 (uint8_t *)&info, sizeof(info),
16738 RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER);
16740 printf("Global Track id: 0x%x\n", info.track_id);
16741 printf("Global Version: %d.%d.%d.%d\n",
16742 info.version.major,
16743 info.version.minor,
16744 info.version.update,
16745 info.version.draft);
16746 printf("Global Package name: %s\n\n", info.name);
16749 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16750 (uint8_t *)&info, sizeof(info),
16751 RTE_PMD_I40E_PKG_INFO_HEADER);
16753 printf("i40e Profile Track id: 0x%x\n", info.track_id);
16754 printf("i40e Profile Version: %d.%d.%d.%d\n",
16755 info.version.major,
16756 info.version.minor,
16757 info.version.update,
16758 info.version.draft);
16759 printf("i40e Profile name: %s\n\n", info.name);
16762 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16763 (uint8_t *)&buff_size, sizeof(buff_size),
16764 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE);
16765 if (!ret && buff_size) {
16766 buff = (uint8_t *)malloc(buff_size);
16768 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16770 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES);
16772 printf("Package Notes:\n%s\n\n", buff);
16777 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16778 (uint8_t *)&dev_num, sizeof(dev_num),
16779 RTE_PMD_I40E_PKG_INFO_DEVID_NUM);
16780 if (!ret && dev_num) {
16781 buff_size = dev_num * sizeof(struct rte_pmd_i40e_ddp_device_id);
16782 devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(buff_size);
16784 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16785 (uint8_t *)devs, buff_size,
16786 RTE_PMD_I40E_PKG_INFO_DEVID_LIST);
16788 printf("List of supported devices:\n");
16789 for (i = 0; i < dev_num; i++) {
16790 printf(" %04X:%04X %04X:%04X\n",
16791 devs[i].vendor_dev_id >> 16,
16792 devs[i].vendor_dev_id & 0xFFFF,
16793 devs[i].sub_vendor_dev_id >> 16,
16794 devs[i].sub_vendor_dev_id & 0xFFFF);
16802 /* get information about protocols and packet types */
16803 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16804 (uint8_t *)&proto_num, sizeof(proto_num),
16805 RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM);
16806 if (ret || !proto_num)
16807 goto no_print_return;
16809 buff_size = proto_num * sizeof(struct rte_pmd_i40e_proto_info);
16810 proto = (struct rte_pmd_i40e_proto_info *)malloc(buff_size);
16812 goto no_print_return;
16814 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)proto,
16816 RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST);
16818 printf("List of used protocols:\n");
16819 for (i = 0; i < proto_num; i++)
16820 printf(" %2u: %s\n", proto[i].proto_id,
16824 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16825 (uint8_t *)&pctype_num, sizeof(pctype_num),
16826 RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM);
16827 if (ret || !pctype_num)
16828 goto no_print_pctypes;
16830 buff_size = pctype_num * sizeof(struct rte_pmd_i40e_ptype_info);
16831 pctype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
16833 goto no_print_pctypes;
16835 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)pctype,
16837 RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST);
16840 goto no_print_pctypes;
16843 printf("List of defined packet classification types:\n");
16844 for (i = 0; i < pctype_num; i++) {
16845 printf(" %2u:", pctype[i].ptype_id);
16846 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
16847 proto_id = pctype[i].protocols[j];
16848 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
16849 for (n = 0; n < proto_num; n++) {
16850 if (proto[n].proto_id == proto_id) {
16851 printf(" %s", proto[n].name);
16864 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)&ptype_num,
16866 RTE_PMD_I40E_PKG_INFO_PTYPE_NUM);
16867 if (ret || !ptype_num)
16868 goto no_print_return;
16870 buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_info);
16871 ptype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
16873 goto no_print_return;
16875 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)ptype,
16877 RTE_PMD_I40E_PKG_INFO_PTYPE_LIST);
16880 goto no_print_return;
16882 printf("List of defined packet types:\n");
16883 for (i = 0; i < ptype_num; i++) {
16884 printf(" %2u:", ptype[i].ptype_id);
16885 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
16886 proto_id = ptype[i].protocols[j];
16887 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
16888 for (n = 0; n < proto_num; n++) {
16889 if (proto[n].proto_id == proto_id) {
16890 printf(" %s", proto[n].name);
16906 if (ret == -ENOTSUP)
16907 printf("Function not supported in PMD driver\n");
16911 cmdline_parse_inst_t cmd_ddp_get_info = {
16912 .f = cmd_ddp_info_parsed,
16914 .help_str = "ddp get info <profile_path>",
16916 (void *)&cmd_ddp_info_ddp,
16917 (void *)&cmd_ddp_info_get,
16918 (void *)&cmd_ddp_info_info,
16919 (void *)&cmd_ddp_info_filepath,
16924 /* Get dynamic device personalization profile info list*/
16925 #define PROFILE_INFO_SIZE 48
16926 #define MAX_PROFILE_NUM 16
16928 struct cmd_ddp_get_list_result {
16929 cmdline_fixed_string_t ddp;
16930 cmdline_fixed_string_t get;
16931 cmdline_fixed_string_t list;
16935 cmdline_parse_token_string_t cmd_ddp_get_list_ddp =
16936 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp");
16937 cmdline_parse_token_string_t cmd_ddp_get_list_get =
16938 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get");
16939 cmdline_parse_token_string_t cmd_ddp_get_list_list =
16940 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list");
16941 cmdline_parse_token_num_t cmd_ddp_get_list_port_id =
16942 TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id, UINT16);
16945 cmd_ddp_get_list_parsed(
16946 __rte_unused void *parsed_result,
16947 __rte_unused struct cmdline *cl,
16948 __rte_unused void *data)
16950 #ifdef RTE_NET_I40E
16951 struct cmd_ddp_get_list_result *res = parsed_result;
16952 struct rte_pmd_i40e_profile_list *p_list;
16953 struct rte_pmd_i40e_profile_info *p_info;
16958 int ret = -ENOTSUP;
16960 #ifdef RTE_NET_I40E
16961 size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4;
16962 p_list = (struct rte_pmd_i40e_profile_list *)malloc(size);
16964 printf("%s: Failed to malloc buffer\n", __func__);
16968 if (ret == -ENOTSUP)
16969 ret = rte_pmd_i40e_get_ddp_list(res->port_id,
16970 (uint8_t *)p_list, size);
16973 p_num = p_list->p_count;
16974 printf("Profile number is: %d\n\n", p_num);
16976 for (i = 0; i < p_num; i++) {
16977 p_info = &p_list->p_info[i];
16978 printf("Profile %d:\n", i);
16979 printf("Track id: 0x%x\n", p_info->track_id);
16980 printf("Version: %d.%d.%d.%d\n",
16981 p_info->version.major,
16982 p_info->version.minor,
16983 p_info->version.update,
16984 p_info->version.draft);
16985 printf("Profile name: %s\n\n", p_info->name);
16993 printf("Failed to get ddp list\n");
16996 cmdline_parse_inst_t cmd_ddp_get_list = {
16997 .f = cmd_ddp_get_list_parsed,
16999 .help_str = "ddp get list <port_id>",
17001 (void *)&cmd_ddp_get_list_ddp,
17002 (void *)&cmd_ddp_get_list_get,
17003 (void *)&cmd_ddp_get_list_list,
17004 (void *)&cmd_ddp_get_list_port_id,
17009 /* Configure input set */
17010 struct cmd_cfg_input_set_result {
17011 cmdline_fixed_string_t port;
17012 cmdline_fixed_string_t cfg;
17014 cmdline_fixed_string_t pctype;
17016 cmdline_fixed_string_t inset_type;
17017 cmdline_fixed_string_t opt;
17018 cmdline_fixed_string_t field;
17023 cmd_cfg_input_set_parsed(
17024 __rte_unused void *parsed_result,
17025 __rte_unused struct cmdline *cl,
17026 __rte_unused void *data)
17028 #ifdef RTE_NET_I40E
17029 struct cmd_cfg_input_set_result *res = parsed_result;
17030 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
17031 struct rte_pmd_i40e_inset inset;
17033 int ret = -ENOTSUP;
17035 if (!all_ports_stopped()) {
17036 printf("Please stop all ports first\n");
17040 #ifdef RTE_NET_I40E
17041 if (!strcmp(res->inset_type, "hash_inset"))
17042 inset_type = INSET_HASH;
17043 else if (!strcmp(res->inset_type, "fdir_inset"))
17044 inset_type = INSET_FDIR;
17045 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
17046 inset_type = INSET_FDIR_FLX;
17047 ret = rte_pmd_i40e_inset_get(res->port_id, res->pctype_id,
17048 &inset, inset_type);
17050 printf("Failed to get input set.\n");
17054 if (!strcmp(res->opt, "get")) {
17055 ret = rte_pmd_i40e_inset_field_get(inset.inset,
17058 printf("Field index %d is enabled.\n", res->field_idx);
17060 printf("Field index %d is disabled.\n", res->field_idx);
17062 } else if (!strcmp(res->opt, "set"))
17063 ret = rte_pmd_i40e_inset_field_set(&inset.inset,
17065 else if (!strcmp(res->opt, "clear"))
17066 ret = rte_pmd_i40e_inset_field_clear(&inset.inset,
17069 printf("Failed to configure input set field.\n");
17073 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
17074 &inset, inset_type);
17076 printf("Failed to set input set.\n");
17081 if (ret == -ENOTSUP)
17082 printf("Function not supported\n");
17085 cmdline_parse_token_string_t cmd_cfg_input_set_port =
17086 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
17088 cmdline_parse_token_string_t cmd_cfg_input_set_cfg =
17089 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
17091 cmdline_parse_token_num_t cmd_cfg_input_set_port_id =
17092 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
17094 cmdline_parse_token_string_t cmd_cfg_input_set_pctype =
17095 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
17097 cmdline_parse_token_num_t cmd_cfg_input_set_pctype_id =
17098 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
17100 cmdline_parse_token_string_t cmd_cfg_input_set_inset_type =
17101 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
17103 "hash_inset#fdir_inset#fdir_flx_inset");
17104 cmdline_parse_token_string_t cmd_cfg_input_set_opt =
17105 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
17106 opt, "get#set#clear");
17107 cmdline_parse_token_string_t cmd_cfg_input_set_field =
17108 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
17110 cmdline_parse_token_num_t cmd_cfg_input_set_field_idx =
17111 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
17114 cmdline_parse_inst_t cmd_cfg_input_set = {
17115 .f = cmd_cfg_input_set_parsed,
17117 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
17118 "fdir_inset|fdir_flx_inset get|set|clear field <field_idx>",
17120 (void *)&cmd_cfg_input_set_port,
17121 (void *)&cmd_cfg_input_set_cfg,
17122 (void *)&cmd_cfg_input_set_port_id,
17123 (void *)&cmd_cfg_input_set_pctype,
17124 (void *)&cmd_cfg_input_set_pctype_id,
17125 (void *)&cmd_cfg_input_set_inset_type,
17126 (void *)&cmd_cfg_input_set_opt,
17127 (void *)&cmd_cfg_input_set_field,
17128 (void *)&cmd_cfg_input_set_field_idx,
17133 /* Clear input set */
17134 struct cmd_clear_input_set_result {
17135 cmdline_fixed_string_t port;
17136 cmdline_fixed_string_t cfg;
17138 cmdline_fixed_string_t pctype;
17140 cmdline_fixed_string_t inset_type;
17141 cmdline_fixed_string_t clear;
17142 cmdline_fixed_string_t all;
17146 cmd_clear_input_set_parsed(
17147 __rte_unused void *parsed_result,
17148 __rte_unused struct cmdline *cl,
17149 __rte_unused void *data)
17151 #ifdef RTE_NET_I40E
17152 struct cmd_clear_input_set_result *res = parsed_result;
17153 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
17154 struct rte_pmd_i40e_inset inset;
17156 int ret = -ENOTSUP;
17158 if (!all_ports_stopped()) {
17159 printf("Please stop all ports first\n");
17163 #ifdef RTE_NET_I40E
17164 if (!strcmp(res->inset_type, "hash_inset"))
17165 inset_type = INSET_HASH;
17166 else if (!strcmp(res->inset_type, "fdir_inset"))
17167 inset_type = INSET_FDIR;
17168 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
17169 inset_type = INSET_FDIR_FLX;
17171 memset(&inset, 0, sizeof(inset));
17173 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
17174 &inset, inset_type);
17176 printf("Failed to clear input set.\n");
17182 if (ret == -ENOTSUP)
17183 printf("Function not supported\n");
17186 cmdline_parse_token_string_t cmd_clear_input_set_port =
17187 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17189 cmdline_parse_token_string_t cmd_clear_input_set_cfg =
17190 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17192 cmdline_parse_token_num_t cmd_clear_input_set_port_id =
17193 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
17195 cmdline_parse_token_string_t cmd_clear_input_set_pctype =
17196 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17198 cmdline_parse_token_num_t cmd_clear_input_set_pctype_id =
17199 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
17201 cmdline_parse_token_string_t cmd_clear_input_set_inset_type =
17202 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17204 "hash_inset#fdir_inset#fdir_flx_inset");
17205 cmdline_parse_token_string_t cmd_clear_input_set_clear =
17206 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17208 cmdline_parse_token_string_t cmd_clear_input_set_all =
17209 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17212 cmdline_parse_inst_t cmd_clear_input_set = {
17213 .f = cmd_clear_input_set_parsed,
17215 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
17216 "fdir_inset|fdir_flx_inset clear all",
17218 (void *)&cmd_clear_input_set_port,
17219 (void *)&cmd_clear_input_set_cfg,
17220 (void *)&cmd_clear_input_set_port_id,
17221 (void *)&cmd_clear_input_set_pctype,
17222 (void *)&cmd_clear_input_set_pctype_id,
17223 (void *)&cmd_clear_input_set_inset_type,
17224 (void *)&cmd_clear_input_set_clear,
17225 (void *)&cmd_clear_input_set_all,
17230 /* show vf stats */
17232 /* Common result structure for show vf stats */
17233 struct cmd_show_vf_stats_result {
17234 cmdline_fixed_string_t show;
17235 cmdline_fixed_string_t vf;
17236 cmdline_fixed_string_t stats;
17241 /* Common CLI fields show vf stats*/
17242 cmdline_parse_token_string_t cmd_show_vf_stats_show =
17243 TOKEN_STRING_INITIALIZER
17244 (struct cmd_show_vf_stats_result,
17246 cmdline_parse_token_string_t cmd_show_vf_stats_vf =
17247 TOKEN_STRING_INITIALIZER
17248 (struct cmd_show_vf_stats_result,
17250 cmdline_parse_token_string_t cmd_show_vf_stats_stats =
17251 TOKEN_STRING_INITIALIZER
17252 (struct cmd_show_vf_stats_result,
17254 cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
17255 TOKEN_NUM_INITIALIZER
17256 (struct cmd_show_vf_stats_result,
17258 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
17259 TOKEN_NUM_INITIALIZER
17260 (struct cmd_show_vf_stats_result,
17264 cmd_show_vf_stats_parsed(
17265 void *parsed_result,
17266 __rte_unused struct cmdline *cl,
17267 __rte_unused void *data)
17269 struct cmd_show_vf_stats_result *res = parsed_result;
17270 struct rte_eth_stats stats;
17271 int ret = -ENOTSUP;
17272 static const char *nic_stats_border = "########################";
17274 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17277 memset(&stats, 0, sizeof(stats));
17279 #ifdef RTE_NET_I40E
17280 if (ret == -ENOTSUP)
17281 ret = rte_pmd_i40e_get_vf_stats(res->port_id,
17285 #ifdef RTE_NET_BNXT
17286 if (ret == -ENOTSUP)
17287 ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
17296 printf("invalid vf_id %d\n", res->vf_id);
17299 printf("invalid port_id %d\n", res->port_id);
17302 printf("function not implemented\n");
17305 printf("programming error: (%s)\n", strerror(-ret));
17308 printf("\n %s NIC statistics for port %-2d vf %-2d %s\n",
17309 nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
17311 printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: "
17313 stats.ipackets, stats.imissed, stats.ibytes);
17314 printf(" RX-errors: %-"PRIu64"\n", stats.ierrors);
17315 printf(" RX-nombuf: %-10"PRIu64"\n",
17317 printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: "
17319 stats.opackets, stats.oerrors, stats.obytes);
17321 printf(" %s############################%s\n",
17322 nic_stats_border, nic_stats_border);
17325 cmdline_parse_inst_t cmd_show_vf_stats = {
17326 .f = cmd_show_vf_stats_parsed,
17328 .help_str = "show vf stats <port_id> <vf_id>",
17330 (void *)&cmd_show_vf_stats_show,
17331 (void *)&cmd_show_vf_stats_vf,
17332 (void *)&cmd_show_vf_stats_stats,
17333 (void *)&cmd_show_vf_stats_port_id,
17334 (void *)&cmd_show_vf_stats_vf_id,
17339 /* clear vf stats */
17341 /* Common result structure for clear vf stats */
17342 struct cmd_clear_vf_stats_result {
17343 cmdline_fixed_string_t clear;
17344 cmdline_fixed_string_t vf;
17345 cmdline_fixed_string_t stats;
17350 /* Common CLI fields clear vf stats*/
17351 cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
17352 TOKEN_STRING_INITIALIZER
17353 (struct cmd_clear_vf_stats_result,
17355 cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
17356 TOKEN_STRING_INITIALIZER
17357 (struct cmd_clear_vf_stats_result,
17359 cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
17360 TOKEN_STRING_INITIALIZER
17361 (struct cmd_clear_vf_stats_result,
17363 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
17364 TOKEN_NUM_INITIALIZER
17365 (struct cmd_clear_vf_stats_result,
17367 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
17368 TOKEN_NUM_INITIALIZER
17369 (struct cmd_clear_vf_stats_result,
17373 cmd_clear_vf_stats_parsed(
17374 void *parsed_result,
17375 __rte_unused struct cmdline *cl,
17376 __rte_unused void *data)
17378 struct cmd_clear_vf_stats_result *res = parsed_result;
17379 int ret = -ENOTSUP;
17381 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17384 #ifdef RTE_NET_I40E
17385 if (ret == -ENOTSUP)
17386 ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
17389 #ifdef RTE_NET_BNXT
17390 if (ret == -ENOTSUP)
17391 ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
17399 printf("invalid vf_id %d\n", res->vf_id);
17402 printf("invalid port_id %d\n", res->port_id);
17405 printf("function not implemented\n");
17408 printf("programming error: (%s)\n", strerror(-ret));
17412 cmdline_parse_inst_t cmd_clear_vf_stats = {
17413 .f = cmd_clear_vf_stats_parsed,
17415 .help_str = "clear vf stats <port_id> <vf_id>",
17417 (void *)&cmd_clear_vf_stats_clear,
17418 (void *)&cmd_clear_vf_stats_vf,
17419 (void *)&cmd_clear_vf_stats_stats,
17420 (void *)&cmd_clear_vf_stats_port_id,
17421 (void *)&cmd_clear_vf_stats_vf_id,
17426 /* port config pctype mapping reset */
17428 /* Common result structure for port config pctype mapping reset */
17429 struct cmd_pctype_mapping_reset_result {
17430 cmdline_fixed_string_t port;
17431 cmdline_fixed_string_t config;
17433 cmdline_fixed_string_t pctype;
17434 cmdline_fixed_string_t mapping;
17435 cmdline_fixed_string_t reset;
17438 /* Common CLI fields for port config pctype mapping reset*/
17439 cmdline_parse_token_string_t cmd_pctype_mapping_reset_port =
17440 TOKEN_STRING_INITIALIZER
17441 (struct cmd_pctype_mapping_reset_result,
17443 cmdline_parse_token_string_t cmd_pctype_mapping_reset_config =
17444 TOKEN_STRING_INITIALIZER
17445 (struct cmd_pctype_mapping_reset_result,
17447 cmdline_parse_token_num_t cmd_pctype_mapping_reset_port_id =
17448 TOKEN_NUM_INITIALIZER
17449 (struct cmd_pctype_mapping_reset_result,
17451 cmdline_parse_token_string_t cmd_pctype_mapping_reset_pctype =
17452 TOKEN_STRING_INITIALIZER
17453 (struct cmd_pctype_mapping_reset_result,
17455 cmdline_parse_token_string_t cmd_pctype_mapping_reset_mapping =
17456 TOKEN_STRING_INITIALIZER
17457 (struct cmd_pctype_mapping_reset_result,
17458 mapping, "mapping");
17459 cmdline_parse_token_string_t cmd_pctype_mapping_reset_reset =
17460 TOKEN_STRING_INITIALIZER
17461 (struct cmd_pctype_mapping_reset_result,
17465 cmd_pctype_mapping_reset_parsed(
17466 void *parsed_result,
17467 __rte_unused struct cmdline *cl,
17468 __rte_unused void *data)
17470 struct cmd_pctype_mapping_reset_result *res = parsed_result;
17471 int ret = -ENOTSUP;
17473 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17476 #ifdef RTE_NET_I40E
17477 ret = rte_pmd_i40e_flow_type_mapping_reset(res->port_id);
17484 printf("invalid port_id %d\n", res->port_id);
17487 printf("function not implemented\n");
17490 printf("programming error: (%s)\n", strerror(-ret));
17494 cmdline_parse_inst_t cmd_pctype_mapping_reset = {
17495 .f = cmd_pctype_mapping_reset_parsed,
17497 .help_str = "port config <port_id> pctype mapping reset",
17499 (void *)&cmd_pctype_mapping_reset_port,
17500 (void *)&cmd_pctype_mapping_reset_config,
17501 (void *)&cmd_pctype_mapping_reset_port_id,
17502 (void *)&cmd_pctype_mapping_reset_pctype,
17503 (void *)&cmd_pctype_mapping_reset_mapping,
17504 (void *)&cmd_pctype_mapping_reset_reset,
17509 /* show port pctype mapping */
17511 /* Common result structure for show port pctype mapping */
17512 struct cmd_pctype_mapping_get_result {
17513 cmdline_fixed_string_t show;
17514 cmdline_fixed_string_t port;
17516 cmdline_fixed_string_t pctype;
17517 cmdline_fixed_string_t mapping;
17520 /* Common CLI fields for pctype mapping get */
17521 cmdline_parse_token_string_t cmd_pctype_mapping_get_show =
17522 TOKEN_STRING_INITIALIZER
17523 (struct cmd_pctype_mapping_get_result,
17525 cmdline_parse_token_string_t cmd_pctype_mapping_get_port =
17526 TOKEN_STRING_INITIALIZER
17527 (struct cmd_pctype_mapping_get_result,
17529 cmdline_parse_token_num_t cmd_pctype_mapping_get_port_id =
17530 TOKEN_NUM_INITIALIZER
17531 (struct cmd_pctype_mapping_get_result,
17533 cmdline_parse_token_string_t cmd_pctype_mapping_get_pctype =
17534 TOKEN_STRING_INITIALIZER
17535 (struct cmd_pctype_mapping_get_result,
17537 cmdline_parse_token_string_t cmd_pctype_mapping_get_mapping =
17538 TOKEN_STRING_INITIALIZER
17539 (struct cmd_pctype_mapping_get_result,
17540 mapping, "mapping");
17543 cmd_pctype_mapping_get_parsed(
17544 void *parsed_result,
17545 __rte_unused struct cmdline *cl,
17546 __rte_unused void *data)
17548 struct cmd_pctype_mapping_get_result *res = parsed_result;
17549 int ret = -ENOTSUP;
17550 #ifdef RTE_NET_I40E
17551 struct rte_pmd_i40e_flow_type_mapping
17552 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
17553 int i, j, first_pctype;
17556 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17559 #ifdef RTE_NET_I40E
17560 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, mapping);
17567 printf("invalid port_id %d\n", res->port_id);
17570 printf("function not implemented\n");
17573 printf("programming error: (%s)\n", strerror(-ret));
17577 #ifdef RTE_NET_I40E
17578 for (i = 0; i < RTE_PMD_I40E_FLOW_TYPE_MAX; i++) {
17579 if (mapping[i].pctype != 0ULL) {
17582 printf("pctype: ");
17583 for (j = 0; j < RTE_PMD_I40E_PCTYPE_MAX; j++) {
17584 if (mapping[i].pctype & (1ULL << j)) {
17585 printf(first_pctype ?
17586 "%02d" : ",%02d", j);
17590 printf(" -> flowtype: %02d\n", mapping[i].flow_type);
17596 cmdline_parse_inst_t cmd_pctype_mapping_get = {
17597 .f = cmd_pctype_mapping_get_parsed,
17599 .help_str = "show port <port_id> pctype mapping",
17601 (void *)&cmd_pctype_mapping_get_show,
17602 (void *)&cmd_pctype_mapping_get_port,
17603 (void *)&cmd_pctype_mapping_get_port_id,
17604 (void *)&cmd_pctype_mapping_get_pctype,
17605 (void *)&cmd_pctype_mapping_get_mapping,
17610 /* port config pctype mapping update */
17612 /* Common result structure for port config pctype mapping update */
17613 struct cmd_pctype_mapping_update_result {
17614 cmdline_fixed_string_t port;
17615 cmdline_fixed_string_t config;
17617 cmdline_fixed_string_t pctype;
17618 cmdline_fixed_string_t mapping;
17619 cmdline_fixed_string_t update;
17620 cmdline_fixed_string_t pctype_list;
17621 uint16_t flow_type;
17624 /* Common CLI fields for pctype mapping update*/
17625 cmdline_parse_token_string_t cmd_pctype_mapping_update_port =
17626 TOKEN_STRING_INITIALIZER
17627 (struct cmd_pctype_mapping_update_result,
17629 cmdline_parse_token_string_t cmd_pctype_mapping_update_config =
17630 TOKEN_STRING_INITIALIZER
17631 (struct cmd_pctype_mapping_update_result,
17633 cmdline_parse_token_num_t cmd_pctype_mapping_update_port_id =
17634 TOKEN_NUM_INITIALIZER
17635 (struct cmd_pctype_mapping_update_result,
17637 cmdline_parse_token_string_t cmd_pctype_mapping_update_pctype =
17638 TOKEN_STRING_INITIALIZER
17639 (struct cmd_pctype_mapping_update_result,
17641 cmdline_parse_token_string_t cmd_pctype_mapping_update_mapping =
17642 TOKEN_STRING_INITIALIZER
17643 (struct cmd_pctype_mapping_update_result,
17644 mapping, "mapping");
17645 cmdline_parse_token_string_t cmd_pctype_mapping_update_update =
17646 TOKEN_STRING_INITIALIZER
17647 (struct cmd_pctype_mapping_update_result,
17649 cmdline_parse_token_string_t cmd_pctype_mapping_update_pc_type =
17650 TOKEN_STRING_INITIALIZER
17651 (struct cmd_pctype_mapping_update_result,
17652 pctype_list, NULL);
17653 cmdline_parse_token_num_t cmd_pctype_mapping_update_flow_type =
17654 TOKEN_NUM_INITIALIZER
17655 (struct cmd_pctype_mapping_update_result,
17656 flow_type, UINT16);
17659 cmd_pctype_mapping_update_parsed(
17660 void *parsed_result,
17661 __rte_unused struct cmdline *cl,
17662 __rte_unused void *data)
17664 struct cmd_pctype_mapping_update_result *res = parsed_result;
17665 int ret = -ENOTSUP;
17666 #ifdef RTE_NET_I40E
17667 struct rte_pmd_i40e_flow_type_mapping mapping;
17669 unsigned int nb_item;
17670 unsigned int pctype_list[RTE_PMD_I40E_PCTYPE_MAX];
17673 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17676 #ifdef RTE_NET_I40E
17677 nb_item = parse_item_list(res->pctype_list, "pctypes",
17678 RTE_PMD_I40E_PCTYPE_MAX, pctype_list, 1);
17679 mapping.flow_type = res->flow_type;
17680 for (i = 0, mapping.pctype = 0ULL; i < nb_item; i++)
17681 mapping.pctype |= (1ULL << pctype_list[i]);
17682 ret = rte_pmd_i40e_flow_type_mapping_update(res->port_id,
17692 printf("invalid pctype or flow type\n");
17695 printf("invalid port_id %d\n", res->port_id);
17698 printf("function not implemented\n");
17701 printf("programming error: (%s)\n", strerror(-ret));
17705 cmdline_parse_inst_t cmd_pctype_mapping_update = {
17706 .f = cmd_pctype_mapping_update_parsed,
17708 .help_str = "port config <port_id> pctype mapping update"
17709 " <pctype_id_0,[pctype_id_1]*> <flowtype_id>",
17711 (void *)&cmd_pctype_mapping_update_port,
17712 (void *)&cmd_pctype_mapping_update_config,
17713 (void *)&cmd_pctype_mapping_update_port_id,
17714 (void *)&cmd_pctype_mapping_update_pctype,
17715 (void *)&cmd_pctype_mapping_update_mapping,
17716 (void *)&cmd_pctype_mapping_update_update,
17717 (void *)&cmd_pctype_mapping_update_pc_type,
17718 (void *)&cmd_pctype_mapping_update_flow_type,
17723 /* ptype mapping get */
17725 /* Common result structure for ptype mapping get */
17726 struct cmd_ptype_mapping_get_result {
17727 cmdline_fixed_string_t ptype;
17728 cmdline_fixed_string_t mapping;
17729 cmdline_fixed_string_t get;
17731 uint8_t valid_only;
17734 /* Common CLI fields for ptype mapping get */
17735 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype =
17736 TOKEN_STRING_INITIALIZER
17737 (struct cmd_ptype_mapping_get_result,
17739 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping =
17740 TOKEN_STRING_INITIALIZER
17741 (struct cmd_ptype_mapping_get_result,
17742 mapping, "mapping");
17743 cmdline_parse_token_string_t cmd_ptype_mapping_get_get =
17744 TOKEN_STRING_INITIALIZER
17745 (struct cmd_ptype_mapping_get_result,
17747 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id =
17748 TOKEN_NUM_INITIALIZER
17749 (struct cmd_ptype_mapping_get_result,
17751 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only =
17752 TOKEN_NUM_INITIALIZER
17753 (struct cmd_ptype_mapping_get_result,
17754 valid_only, UINT8);
17757 cmd_ptype_mapping_get_parsed(
17758 void *parsed_result,
17759 __rte_unused struct cmdline *cl,
17760 __rte_unused void *data)
17762 struct cmd_ptype_mapping_get_result *res = parsed_result;
17763 int ret = -ENOTSUP;
17764 #ifdef RTE_NET_I40E
17765 int max_ptype_num = 256;
17766 struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num];
17771 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17774 #ifdef RTE_NET_I40E
17775 ret = rte_pmd_i40e_ptype_mapping_get(res->port_id,
17786 printf("invalid port_id %d\n", res->port_id);
17789 printf("function not implemented\n");
17792 printf("programming error: (%s)\n", strerror(-ret));
17795 #ifdef RTE_NET_I40E
17797 for (i = 0; i < count; i++)
17798 printf("%3d\t0x%08x\n",
17799 mapping[i].hw_ptype, mapping[i].sw_ptype);
17804 cmdline_parse_inst_t cmd_ptype_mapping_get = {
17805 .f = cmd_ptype_mapping_get_parsed,
17807 .help_str = "ptype mapping get <port_id> <valid_only>",
17809 (void *)&cmd_ptype_mapping_get_ptype,
17810 (void *)&cmd_ptype_mapping_get_mapping,
17811 (void *)&cmd_ptype_mapping_get_get,
17812 (void *)&cmd_ptype_mapping_get_port_id,
17813 (void *)&cmd_ptype_mapping_get_valid_only,
17818 /* ptype mapping replace */
17820 /* Common result structure for ptype mapping replace */
17821 struct cmd_ptype_mapping_replace_result {
17822 cmdline_fixed_string_t ptype;
17823 cmdline_fixed_string_t mapping;
17824 cmdline_fixed_string_t replace;
17831 /* Common CLI fields for ptype mapping replace */
17832 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype =
17833 TOKEN_STRING_INITIALIZER
17834 (struct cmd_ptype_mapping_replace_result,
17836 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping =
17837 TOKEN_STRING_INITIALIZER
17838 (struct cmd_ptype_mapping_replace_result,
17839 mapping, "mapping");
17840 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace =
17841 TOKEN_STRING_INITIALIZER
17842 (struct cmd_ptype_mapping_replace_result,
17843 replace, "replace");
17844 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id =
17845 TOKEN_NUM_INITIALIZER
17846 (struct cmd_ptype_mapping_replace_result,
17848 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target =
17849 TOKEN_NUM_INITIALIZER
17850 (struct cmd_ptype_mapping_replace_result,
17852 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask =
17853 TOKEN_NUM_INITIALIZER
17854 (struct cmd_ptype_mapping_replace_result,
17856 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type =
17857 TOKEN_NUM_INITIALIZER
17858 (struct cmd_ptype_mapping_replace_result,
17862 cmd_ptype_mapping_replace_parsed(
17863 void *parsed_result,
17864 __rte_unused struct cmdline *cl,
17865 __rte_unused void *data)
17867 struct cmd_ptype_mapping_replace_result *res = parsed_result;
17868 int ret = -ENOTSUP;
17870 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17873 #ifdef RTE_NET_I40E
17874 ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id,
17884 printf("invalid ptype 0x%8x or 0x%8x\n",
17885 res->target, res->pkt_type);
17888 printf("invalid port_id %d\n", res->port_id);
17891 printf("function not implemented\n");
17894 printf("programming error: (%s)\n", strerror(-ret));
17898 cmdline_parse_inst_t cmd_ptype_mapping_replace = {
17899 .f = cmd_ptype_mapping_replace_parsed,
17902 "ptype mapping replace <port_id> <target> <mask> <pkt_type>",
17904 (void *)&cmd_ptype_mapping_replace_ptype,
17905 (void *)&cmd_ptype_mapping_replace_mapping,
17906 (void *)&cmd_ptype_mapping_replace_replace,
17907 (void *)&cmd_ptype_mapping_replace_port_id,
17908 (void *)&cmd_ptype_mapping_replace_target,
17909 (void *)&cmd_ptype_mapping_replace_mask,
17910 (void *)&cmd_ptype_mapping_replace_pkt_type,
17915 /* ptype mapping reset */
17917 /* Common result structure for ptype mapping reset */
17918 struct cmd_ptype_mapping_reset_result {
17919 cmdline_fixed_string_t ptype;
17920 cmdline_fixed_string_t mapping;
17921 cmdline_fixed_string_t reset;
17925 /* Common CLI fields for ptype mapping reset*/
17926 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype =
17927 TOKEN_STRING_INITIALIZER
17928 (struct cmd_ptype_mapping_reset_result,
17930 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping =
17931 TOKEN_STRING_INITIALIZER
17932 (struct cmd_ptype_mapping_reset_result,
17933 mapping, "mapping");
17934 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset =
17935 TOKEN_STRING_INITIALIZER
17936 (struct cmd_ptype_mapping_reset_result,
17938 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id =
17939 TOKEN_NUM_INITIALIZER
17940 (struct cmd_ptype_mapping_reset_result,
17944 cmd_ptype_mapping_reset_parsed(
17945 void *parsed_result,
17946 __rte_unused struct cmdline *cl,
17947 __rte_unused void *data)
17949 struct cmd_ptype_mapping_reset_result *res = parsed_result;
17950 int ret = -ENOTSUP;
17952 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17955 #ifdef RTE_NET_I40E
17956 ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id);
17963 printf("invalid port_id %d\n", res->port_id);
17966 printf("function not implemented\n");
17969 printf("programming error: (%s)\n", strerror(-ret));
17973 cmdline_parse_inst_t cmd_ptype_mapping_reset = {
17974 .f = cmd_ptype_mapping_reset_parsed,
17976 .help_str = "ptype mapping reset <port_id>",
17978 (void *)&cmd_ptype_mapping_reset_ptype,
17979 (void *)&cmd_ptype_mapping_reset_mapping,
17980 (void *)&cmd_ptype_mapping_reset_reset,
17981 (void *)&cmd_ptype_mapping_reset_port_id,
17986 /* ptype mapping update */
17988 /* Common result structure for ptype mapping update */
17989 struct cmd_ptype_mapping_update_result {
17990 cmdline_fixed_string_t ptype;
17991 cmdline_fixed_string_t mapping;
17992 cmdline_fixed_string_t reset;
17998 /* Common CLI fields for ptype mapping update*/
17999 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype =
18000 TOKEN_STRING_INITIALIZER
18001 (struct cmd_ptype_mapping_update_result,
18003 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping =
18004 TOKEN_STRING_INITIALIZER
18005 (struct cmd_ptype_mapping_update_result,
18006 mapping, "mapping");
18007 cmdline_parse_token_string_t cmd_ptype_mapping_update_update =
18008 TOKEN_STRING_INITIALIZER
18009 (struct cmd_ptype_mapping_update_result,
18011 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id =
18012 TOKEN_NUM_INITIALIZER
18013 (struct cmd_ptype_mapping_update_result,
18015 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype =
18016 TOKEN_NUM_INITIALIZER
18017 (struct cmd_ptype_mapping_update_result,
18019 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype =
18020 TOKEN_NUM_INITIALIZER
18021 (struct cmd_ptype_mapping_update_result,
18025 cmd_ptype_mapping_update_parsed(
18026 void *parsed_result,
18027 __rte_unused struct cmdline *cl,
18028 __rte_unused void *data)
18030 struct cmd_ptype_mapping_update_result *res = parsed_result;
18031 int ret = -ENOTSUP;
18032 #ifdef RTE_NET_I40E
18033 struct rte_pmd_i40e_ptype_mapping mapping;
18035 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
18038 #ifdef RTE_NET_I40E
18039 mapping.hw_ptype = res->hw_ptype;
18040 mapping.sw_ptype = res->sw_ptype;
18041 ret = rte_pmd_i40e_ptype_mapping_update(res->port_id,
18051 printf("invalid ptype 0x%8x\n", res->sw_ptype);
18054 printf("invalid port_id %d\n", res->port_id);
18057 printf("function not implemented\n");
18060 printf("programming error: (%s)\n", strerror(-ret));
18064 cmdline_parse_inst_t cmd_ptype_mapping_update = {
18065 .f = cmd_ptype_mapping_update_parsed,
18067 .help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>",
18069 (void *)&cmd_ptype_mapping_update_ptype,
18070 (void *)&cmd_ptype_mapping_update_mapping,
18071 (void *)&cmd_ptype_mapping_update_update,
18072 (void *)&cmd_ptype_mapping_update_port_id,
18073 (void *)&cmd_ptype_mapping_update_hw_ptype,
18074 (void *)&cmd_ptype_mapping_update_sw_ptype,
18079 /* Common result structure for file commands */
18080 struct cmd_cmdfile_result {
18081 cmdline_fixed_string_t load;
18082 cmdline_fixed_string_t filename;
18085 /* Common CLI fields for file commands */
18086 cmdline_parse_token_string_t cmd_load_cmdfile =
18087 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
18088 cmdline_parse_token_string_t cmd_load_cmdfile_filename =
18089 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
18092 cmd_load_from_file_parsed(
18093 void *parsed_result,
18094 __rte_unused struct cmdline *cl,
18095 __rte_unused void *data)
18097 struct cmd_cmdfile_result *res = parsed_result;
18099 cmdline_read_from_file(res->filename);
18102 cmdline_parse_inst_t cmd_load_from_file = {
18103 .f = cmd_load_from_file_parsed,
18105 .help_str = "load <filename>",
18107 (void *)&cmd_load_cmdfile,
18108 (void *)&cmd_load_cmdfile_filename,
18113 /* Get Rx offloads capabilities */
18114 struct cmd_rx_offload_get_capa_result {
18115 cmdline_fixed_string_t show;
18116 cmdline_fixed_string_t port;
18118 cmdline_fixed_string_t rx_offload;
18119 cmdline_fixed_string_t capabilities;
18122 cmdline_parse_token_string_t cmd_rx_offload_get_capa_show =
18123 TOKEN_STRING_INITIALIZER
18124 (struct cmd_rx_offload_get_capa_result,
18126 cmdline_parse_token_string_t cmd_rx_offload_get_capa_port =
18127 TOKEN_STRING_INITIALIZER
18128 (struct cmd_rx_offload_get_capa_result,
18130 cmdline_parse_token_num_t cmd_rx_offload_get_capa_port_id =
18131 TOKEN_NUM_INITIALIZER
18132 (struct cmd_rx_offload_get_capa_result,
18134 cmdline_parse_token_string_t cmd_rx_offload_get_capa_rx_offload =
18135 TOKEN_STRING_INITIALIZER
18136 (struct cmd_rx_offload_get_capa_result,
18137 rx_offload, "rx_offload");
18138 cmdline_parse_token_string_t cmd_rx_offload_get_capa_capabilities =
18139 TOKEN_STRING_INITIALIZER
18140 (struct cmd_rx_offload_get_capa_result,
18141 capabilities, "capabilities");
18144 print_rx_offloads(uint64_t offloads)
18146 uint64_t single_offload;
18154 begin = __builtin_ctzll(offloads);
18155 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
18157 single_offload = 1ULL << begin;
18158 for (bit = begin; bit < end; bit++) {
18159 if (offloads & single_offload)
18161 rte_eth_dev_rx_offload_name(single_offload));
18162 single_offload <<= 1;
18167 cmd_rx_offload_get_capa_parsed(
18168 void *parsed_result,
18169 __rte_unused struct cmdline *cl,
18170 __rte_unused void *data)
18172 struct cmd_rx_offload_get_capa_result *res = parsed_result;
18173 struct rte_eth_dev_info dev_info;
18174 portid_t port_id = res->port_id;
18175 uint64_t queue_offloads;
18176 uint64_t port_offloads;
18179 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18183 queue_offloads = dev_info.rx_queue_offload_capa;
18184 port_offloads = dev_info.rx_offload_capa ^ queue_offloads;
18186 printf("Rx Offloading Capabilities of port %d :\n", port_id);
18187 printf(" Per Queue :");
18188 print_rx_offloads(queue_offloads);
18191 printf(" Per Port :");
18192 print_rx_offloads(port_offloads);
18196 cmdline_parse_inst_t cmd_rx_offload_get_capa = {
18197 .f = cmd_rx_offload_get_capa_parsed,
18199 .help_str = "show port <port_id> rx_offload capabilities",
18201 (void *)&cmd_rx_offload_get_capa_show,
18202 (void *)&cmd_rx_offload_get_capa_port,
18203 (void *)&cmd_rx_offload_get_capa_port_id,
18204 (void *)&cmd_rx_offload_get_capa_rx_offload,
18205 (void *)&cmd_rx_offload_get_capa_capabilities,
18210 /* Get Rx offloads configuration */
18211 struct cmd_rx_offload_get_configuration_result {
18212 cmdline_fixed_string_t show;
18213 cmdline_fixed_string_t port;
18215 cmdline_fixed_string_t rx_offload;
18216 cmdline_fixed_string_t configuration;
18219 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_show =
18220 TOKEN_STRING_INITIALIZER
18221 (struct cmd_rx_offload_get_configuration_result,
18223 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_port =
18224 TOKEN_STRING_INITIALIZER
18225 (struct cmd_rx_offload_get_configuration_result,
18227 cmdline_parse_token_num_t cmd_rx_offload_get_configuration_port_id =
18228 TOKEN_NUM_INITIALIZER
18229 (struct cmd_rx_offload_get_configuration_result,
18231 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_rx_offload =
18232 TOKEN_STRING_INITIALIZER
18233 (struct cmd_rx_offload_get_configuration_result,
18234 rx_offload, "rx_offload");
18235 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_configuration =
18236 TOKEN_STRING_INITIALIZER
18237 (struct cmd_rx_offload_get_configuration_result,
18238 configuration, "configuration");
18241 cmd_rx_offload_get_configuration_parsed(
18242 void *parsed_result,
18243 __rte_unused struct cmdline *cl,
18244 __rte_unused void *data)
18246 struct cmd_rx_offload_get_configuration_result *res = parsed_result;
18247 struct rte_eth_dev_info dev_info;
18248 portid_t port_id = res->port_id;
18249 struct rte_port *port = &ports[port_id];
18250 uint64_t port_offloads;
18251 uint64_t queue_offloads;
18252 uint16_t nb_rx_queues;
18256 printf("Rx Offloading Configuration of port %d :\n", port_id);
18258 port_offloads = port->dev_conf.rxmode.offloads;
18260 print_rx_offloads(port_offloads);
18263 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18267 nb_rx_queues = dev_info.nb_rx_queues;
18268 for (q = 0; q < nb_rx_queues; q++) {
18269 queue_offloads = port->rx_conf[q].offloads;
18270 printf(" Queue[%2d] :", q);
18271 print_rx_offloads(queue_offloads);
18277 cmdline_parse_inst_t cmd_rx_offload_get_configuration = {
18278 .f = cmd_rx_offload_get_configuration_parsed,
18280 .help_str = "show port <port_id> rx_offload configuration",
18282 (void *)&cmd_rx_offload_get_configuration_show,
18283 (void *)&cmd_rx_offload_get_configuration_port,
18284 (void *)&cmd_rx_offload_get_configuration_port_id,
18285 (void *)&cmd_rx_offload_get_configuration_rx_offload,
18286 (void *)&cmd_rx_offload_get_configuration_configuration,
18291 /* Enable/Disable a per port offloading */
18292 struct cmd_config_per_port_rx_offload_result {
18293 cmdline_fixed_string_t port;
18294 cmdline_fixed_string_t config;
18296 cmdline_fixed_string_t rx_offload;
18297 cmdline_fixed_string_t offload;
18298 cmdline_fixed_string_t on_off;
18301 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_port =
18302 TOKEN_STRING_INITIALIZER
18303 (struct cmd_config_per_port_rx_offload_result,
18305 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_config =
18306 TOKEN_STRING_INITIALIZER
18307 (struct cmd_config_per_port_rx_offload_result,
18309 cmdline_parse_token_num_t cmd_config_per_port_rx_offload_result_port_id =
18310 TOKEN_NUM_INITIALIZER
18311 (struct cmd_config_per_port_rx_offload_result,
18313 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_rx_offload =
18314 TOKEN_STRING_INITIALIZER
18315 (struct cmd_config_per_port_rx_offload_result,
18316 rx_offload, "rx_offload");
18317 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_offload =
18318 TOKEN_STRING_INITIALIZER
18319 (struct cmd_config_per_port_rx_offload_result,
18320 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
18321 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
18322 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
18323 "scatter#buffer_split#timestamp#security#"
18324 "keep_crc#rss_hash");
18325 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_on_off =
18326 TOKEN_STRING_INITIALIZER
18327 (struct cmd_config_per_port_rx_offload_result,
18331 search_rx_offload(const char *name)
18333 uint64_t single_offload;
18334 const char *single_name;
18338 single_offload = 1;
18339 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
18340 single_name = rte_eth_dev_rx_offload_name(single_offload);
18341 if (!strcasecmp(single_name, name)) {
18345 single_offload <<= 1;
18349 return single_offload;
18355 cmd_config_per_port_rx_offload_parsed(void *parsed_result,
18356 __rte_unused struct cmdline *cl,
18357 __rte_unused void *data)
18359 struct cmd_config_per_port_rx_offload_result *res = parsed_result;
18360 portid_t port_id = res->port_id;
18361 struct rte_eth_dev_info dev_info;
18362 struct rte_port *port = &ports[port_id];
18363 uint64_t single_offload;
18364 uint16_t nb_rx_queues;
18368 if (port->port_status != RTE_PORT_STOPPED) {
18369 printf("Error: Can't config offload when Port %d "
18370 "is not stopped\n", port_id);
18374 single_offload = search_rx_offload(res->offload);
18375 if (single_offload == 0) {
18376 printf("Unknown offload name: %s\n", res->offload);
18380 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18384 nb_rx_queues = dev_info.nb_rx_queues;
18385 if (!strcmp(res->on_off, "on")) {
18386 port->dev_conf.rxmode.offloads |= single_offload;
18387 for (q = 0; q < nb_rx_queues; q++)
18388 port->rx_conf[q].offloads |= single_offload;
18390 port->dev_conf.rxmode.offloads &= ~single_offload;
18391 for (q = 0; q < nb_rx_queues; q++)
18392 port->rx_conf[q].offloads &= ~single_offload;
18395 cmd_reconfig_device_queue(port_id, 1, 1);
18398 cmdline_parse_inst_t cmd_config_per_port_rx_offload = {
18399 .f = cmd_config_per_port_rx_offload_parsed,
18401 .help_str = "port config <port_id> rx_offload vlan_strip|ipv4_cksum|"
18402 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
18403 "macsec_strip|header_split|vlan_filter|vlan_extend|"
18404 "jumbo_frame|scatter|buffer_split|timestamp|security|"
18405 "keep_crc|rss_hash on|off",
18407 (void *)&cmd_config_per_port_rx_offload_result_port,
18408 (void *)&cmd_config_per_port_rx_offload_result_config,
18409 (void *)&cmd_config_per_port_rx_offload_result_port_id,
18410 (void *)&cmd_config_per_port_rx_offload_result_rx_offload,
18411 (void *)&cmd_config_per_port_rx_offload_result_offload,
18412 (void *)&cmd_config_per_port_rx_offload_result_on_off,
18417 /* Enable/Disable a per queue offloading */
18418 struct cmd_config_per_queue_rx_offload_result {
18419 cmdline_fixed_string_t port;
18421 cmdline_fixed_string_t rxq;
18423 cmdline_fixed_string_t rx_offload;
18424 cmdline_fixed_string_t offload;
18425 cmdline_fixed_string_t on_off;
18428 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_port =
18429 TOKEN_STRING_INITIALIZER
18430 (struct cmd_config_per_queue_rx_offload_result,
18432 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_port_id =
18433 TOKEN_NUM_INITIALIZER
18434 (struct cmd_config_per_queue_rx_offload_result,
18436 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxq =
18437 TOKEN_STRING_INITIALIZER
18438 (struct cmd_config_per_queue_rx_offload_result,
18440 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_queue_id =
18441 TOKEN_NUM_INITIALIZER
18442 (struct cmd_config_per_queue_rx_offload_result,
18444 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxoffload =
18445 TOKEN_STRING_INITIALIZER
18446 (struct cmd_config_per_queue_rx_offload_result,
18447 rx_offload, "rx_offload");
18448 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_offload =
18449 TOKEN_STRING_INITIALIZER
18450 (struct cmd_config_per_queue_rx_offload_result,
18451 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
18452 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
18453 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
18454 "scatter#buffer_split#timestamp#security#keep_crc");
18455 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_on_off =
18456 TOKEN_STRING_INITIALIZER
18457 (struct cmd_config_per_queue_rx_offload_result,
18461 cmd_config_per_queue_rx_offload_parsed(void *parsed_result,
18462 __rte_unused struct cmdline *cl,
18463 __rte_unused void *data)
18465 struct cmd_config_per_queue_rx_offload_result *res = parsed_result;
18466 struct rte_eth_dev_info dev_info;
18467 portid_t port_id = res->port_id;
18468 uint16_t queue_id = res->queue_id;
18469 struct rte_port *port = &ports[port_id];
18470 uint64_t single_offload;
18473 if (port->port_status != RTE_PORT_STOPPED) {
18474 printf("Error: Can't config offload when Port %d "
18475 "is not stopped\n", port_id);
18479 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18483 if (queue_id >= dev_info.nb_rx_queues) {
18484 printf("Error: input queue_id should be 0 ... "
18485 "%d\n", dev_info.nb_rx_queues - 1);
18489 single_offload = search_rx_offload(res->offload);
18490 if (single_offload == 0) {
18491 printf("Unknown offload name: %s\n", res->offload);
18495 if (!strcmp(res->on_off, "on"))
18496 port->rx_conf[queue_id].offloads |= single_offload;
18498 port->rx_conf[queue_id].offloads &= ~single_offload;
18500 cmd_reconfig_device_queue(port_id, 1, 1);
18503 cmdline_parse_inst_t cmd_config_per_queue_rx_offload = {
18504 .f = cmd_config_per_queue_rx_offload_parsed,
18506 .help_str = "port <port_id> rxq <queue_id> rx_offload "
18507 "vlan_strip|ipv4_cksum|"
18508 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
18509 "macsec_strip|header_split|vlan_filter|vlan_extend|"
18510 "jumbo_frame|scatter|buffer_split|timestamp|security|"
18513 (void *)&cmd_config_per_queue_rx_offload_result_port,
18514 (void *)&cmd_config_per_queue_rx_offload_result_port_id,
18515 (void *)&cmd_config_per_queue_rx_offload_result_rxq,
18516 (void *)&cmd_config_per_queue_rx_offload_result_queue_id,
18517 (void *)&cmd_config_per_queue_rx_offload_result_rxoffload,
18518 (void *)&cmd_config_per_queue_rx_offload_result_offload,
18519 (void *)&cmd_config_per_queue_rx_offload_result_on_off,
18524 /* Get Tx offloads capabilities */
18525 struct cmd_tx_offload_get_capa_result {
18526 cmdline_fixed_string_t show;
18527 cmdline_fixed_string_t port;
18529 cmdline_fixed_string_t tx_offload;
18530 cmdline_fixed_string_t capabilities;
18533 cmdline_parse_token_string_t cmd_tx_offload_get_capa_show =
18534 TOKEN_STRING_INITIALIZER
18535 (struct cmd_tx_offload_get_capa_result,
18537 cmdline_parse_token_string_t cmd_tx_offload_get_capa_port =
18538 TOKEN_STRING_INITIALIZER
18539 (struct cmd_tx_offload_get_capa_result,
18541 cmdline_parse_token_num_t cmd_tx_offload_get_capa_port_id =
18542 TOKEN_NUM_INITIALIZER
18543 (struct cmd_tx_offload_get_capa_result,
18545 cmdline_parse_token_string_t cmd_tx_offload_get_capa_tx_offload =
18546 TOKEN_STRING_INITIALIZER
18547 (struct cmd_tx_offload_get_capa_result,
18548 tx_offload, "tx_offload");
18549 cmdline_parse_token_string_t cmd_tx_offload_get_capa_capabilities =
18550 TOKEN_STRING_INITIALIZER
18551 (struct cmd_tx_offload_get_capa_result,
18552 capabilities, "capabilities");
18555 print_tx_offloads(uint64_t offloads)
18557 uint64_t single_offload;
18565 begin = __builtin_ctzll(offloads);
18566 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
18568 single_offload = 1ULL << begin;
18569 for (bit = begin; bit < end; bit++) {
18570 if (offloads & single_offload)
18572 rte_eth_dev_tx_offload_name(single_offload));
18573 single_offload <<= 1;
18578 cmd_tx_offload_get_capa_parsed(
18579 void *parsed_result,
18580 __rte_unused struct cmdline *cl,
18581 __rte_unused void *data)
18583 struct cmd_tx_offload_get_capa_result *res = parsed_result;
18584 struct rte_eth_dev_info dev_info;
18585 portid_t port_id = res->port_id;
18586 uint64_t queue_offloads;
18587 uint64_t port_offloads;
18590 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18594 queue_offloads = dev_info.tx_queue_offload_capa;
18595 port_offloads = dev_info.tx_offload_capa ^ queue_offloads;
18597 printf("Tx Offloading Capabilities of port %d :\n", port_id);
18598 printf(" Per Queue :");
18599 print_tx_offloads(queue_offloads);
18602 printf(" Per Port :");
18603 print_tx_offloads(port_offloads);
18607 cmdline_parse_inst_t cmd_tx_offload_get_capa = {
18608 .f = cmd_tx_offload_get_capa_parsed,
18610 .help_str = "show port <port_id> tx_offload capabilities",
18612 (void *)&cmd_tx_offload_get_capa_show,
18613 (void *)&cmd_tx_offload_get_capa_port,
18614 (void *)&cmd_tx_offload_get_capa_port_id,
18615 (void *)&cmd_tx_offload_get_capa_tx_offload,
18616 (void *)&cmd_tx_offload_get_capa_capabilities,
18621 /* Get Tx offloads configuration */
18622 struct cmd_tx_offload_get_configuration_result {
18623 cmdline_fixed_string_t show;
18624 cmdline_fixed_string_t port;
18626 cmdline_fixed_string_t tx_offload;
18627 cmdline_fixed_string_t configuration;
18630 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_show =
18631 TOKEN_STRING_INITIALIZER
18632 (struct cmd_tx_offload_get_configuration_result,
18634 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_port =
18635 TOKEN_STRING_INITIALIZER
18636 (struct cmd_tx_offload_get_configuration_result,
18638 cmdline_parse_token_num_t cmd_tx_offload_get_configuration_port_id =
18639 TOKEN_NUM_INITIALIZER
18640 (struct cmd_tx_offload_get_configuration_result,
18642 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_tx_offload =
18643 TOKEN_STRING_INITIALIZER
18644 (struct cmd_tx_offload_get_configuration_result,
18645 tx_offload, "tx_offload");
18646 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_configuration =
18647 TOKEN_STRING_INITIALIZER
18648 (struct cmd_tx_offload_get_configuration_result,
18649 configuration, "configuration");
18652 cmd_tx_offload_get_configuration_parsed(
18653 void *parsed_result,
18654 __rte_unused struct cmdline *cl,
18655 __rte_unused void *data)
18657 struct cmd_tx_offload_get_configuration_result *res = parsed_result;
18658 struct rte_eth_dev_info dev_info;
18659 portid_t port_id = res->port_id;
18660 struct rte_port *port = &ports[port_id];
18661 uint64_t port_offloads;
18662 uint64_t queue_offloads;
18663 uint16_t nb_tx_queues;
18667 printf("Tx Offloading Configuration of port %d :\n", port_id);
18669 port_offloads = port->dev_conf.txmode.offloads;
18671 print_tx_offloads(port_offloads);
18674 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18678 nb_tx_queues = dev_info.nb_tx_queues;
18679 for (q = 0; q < nb_tx_queues; q++) {
18680 queue_offloads = port->tx_conf[q].offloads;
18681 printf(" Queue[%2d] :", q);
18682 print_tx_offloads(queue_offloads);
18688 cmdline_parse_inst_t cmd_tx_offload_get_configuration = {
18689 .f = cmd_tx_offload_get_configuration_parsed,
18691 .help_str = "show port <port_id> tx_offload configuration",
18693 (void *)&cmd_tx_offload_get_configuration_show,
18694 (void *)&cmd_tx_offload_get_configuration_port,
18695 (void *)&cmd_tx_offload_get_configuration_port_id,
18696 (void *)&cmd_tx_offload_get_configuration_tx_offload,
18697 (void *)&cmd_tx_offload_get_configuration_configuration,
18702 /* Enable/Disable a per port offloading */
18703 struct cmd_config_per_port_tx_offload_result {
18704 cmdline_fixed_string_t port;
18705 cmdline_fixed_string_t config;
18707 cmdline_fixed_string_t tx_offload;
18708 cmdline_fixed_string_t offload;
18709 cmdline_fixed_string_t on_off;
18712 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_port =
18713 TOKEN_STRING_INITIALIZER
18714 (struct cmd_config_per_port_tx_offload_result,
18716 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_config =
18717 TOKEN_STRING_INITIALIZER
18718 (struct cmd_config_per_port_tx_offload_result,
18720 cmdline_parse_token_num_t cmd_config_per_port_tx_offload_result_port_id =
18721 TOKEN_NUM_INITIALIZER
18722 (struct cmd_config_per_port_tx_offload_result,
18724 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_tx_offload =
18725 TOKEN_STRING_INITIALIZER
18726 (struct cmd_config_per_port_tx_offload_result,
18727 tx_offload, "tx_offload");
18728 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_offload =
18729 TOKEN_STRING_INITIALIZER
18730 (struct cmd_config_per_port_tx_offload_result,
18731 offload, "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#"
18736 "send_on_timestamp");
18737 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_on_off =
18738 TOKEN_STRING_INITIALIZER
18739 (struct cmd_config_per_port_tx_offload_result,
18743 search_tx_offload(const char *name)
18745 uint64_t single_offload;
18746 const char *single_name;
18750 single_offload = 1;
18751 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
18752 single_name = rte_eth_dev_tx_offload_name(single_offload);
18753 if (single_name == NULL)
18755 if (!strcasecmp(single_name, name)) {
18758 } else if (!strcasecmp(single_name, "UNKNOWN"))
18760 single_offload <<= 1;
18764 return single_offload;
18770 cmd_config_per_port_tx_offload_parsed(void *parsed_result,
18771 __rte_unused struct cmdline *cl,
18772 __rte_unused void *data)
18774 struct cmd_config_per_port_tx_offload_result *res = parsed_result;
18775 portid_t port_id = res->port_id;
18776 struct rte_eth_dev_info dev_info;
18777 struct rte_port *port = &ports[port_id];
18778 uint64_t single_offload;
18779 uint16_t nb_tx_queues;
18783 if (port->port_status != RTE_PORT_STOPPED) {
18784 printf("Error: Can't config offload when Port %d "
18785 "is not stopped\n", port_id);
18789 single_offload = search_tx_offload(res->offload);
18790 if (single_offload == 0) {
18791 printf("Unknown offload name: %s\n", res->offload);
18795 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18799 nb_tx_queues = dev_info.nb_tx_queues;
18800 if (!strcmp(res->on_off, "on")) {
18801 port->dev_conf.txmode.offloads |= single_offload;
18802 for (q = 0; q < nb_tx_queues; q++)
18803 port->tx_conf[q].offloads |= single_offload;
18805 port->dev_conf.txmode.offloads &= ~single_offload;
18806 for (q = 0; q < nb_tx_queues; q++)
18807 port->tx_conf[q].offloads &= ~single_offload;
18810 cmd_reconfig_device_queue(port_id, 1, 1);
18813 cmdline_parse_inst_t cmd_config_per_port_tx_offload = {
18814 .f = cmd_config_per_port_tx_offload_parsed,
18816 .help_str = "port config <port_id> tx_offload "
18817 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
18818 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
18819 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
18820 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
18821 "mt_lockfree|multi_segs|mbuf_fast_free|security|"
18822 "send_on_timestamp on|off",
18824 (void *)&cmd_config_per_port_tx_offload_result_port,
18825 (void *)&cmd_config_per_port_tx_offload_result_config,
18826 (void *)&cmd_config_per_port_tx_offload_result_port_id,
18827 (void *)&cmd_config_per_port_tx_offload_result_tx_offload,
18828 (void *)&cmd_config_per_port_tx_offload_result_offload,
18829 (void *)&cmd_config_per_port_tx_offload_result_on_off,
18834 /* Enable/Disable a per queue offloading */
18835 struct cmd_config_per_queue_tx_offload_result {
18836 cmdline_fixed_string_t port;
18838 cmdline_fixed_string_t txq;
18840 cmdline_fixed_string_t tx_offload;
18841 cmdline_fixed_string_t offload;
18842 cmdline_fixed_string_t on_off;
18845 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_port =
18846 TOKEN_STRING_INITIALIZER
18847 (struct cmd_config_per_queue_tx_offload_result,
18849 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_port_id =
18850 TOKEN_NUM_INITIALIZER
18851 (struct cmd_config_per_queue_tx_offload_result,
18853 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txq =
18854 TOKEN_STRING_INITIALIZER
18855 (struct cmd_config_per_queue_tx_offload_result,
18857 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_queue_id =
18858 TOKEN_NUM_INITIALIZER
18859 (struct cmd_config_per_queue_tx_offload_result,
18861 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txoffload =
18862 TOKEN_STRING_INITIALIZER
18863 (struct cmd_config_per_queue_tx_offload_result,
18864 tx_offload, "tx_offload");
18865 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_offload =
18866 TOKEN_STRING_INITIALIZER
18867 (struct cmd_config_per_queue_tx_offload_result,
18868 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
18869 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
18870 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
18871 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
18872 "mt_lockfree#multi_segs#mbuf_fast_free#security");
18873 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_on_off =
18874 TOKEN_STRING_INITIALIZER
18875 (struct cmd_config_per_queue_tx_offload_result,
18879 cmd_config_per_queue_tx_offload_parsed(void *parsed_result,
18880 __rte_unused struct cmdline *cl,
18881 __rte_unused void *data)
18883 struct cmd_config_per_queue_tx_offload_result *res = parsed_result;
18884 struct rte_eth_dev_info dev_info;
18885 portid_t port_id = res->port_id;
18886 uint16_t queue_id = res->queue_id;
18887 struct rte_port *port = &ports[port_id];
18888 uint64_t single_offload;
18891 if (port->port_status != RTE_PORT_STOPPED) {
18892 printf("Error: Can't config offload when Port %d "
18893 "is not stopped\n", port_id);
18897 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18901 if (queue_id >= dev_info.nb_tx_queues) {
18902 printf("Error: input queue_id should be 0 ... "
18903 "%d\n", dev_info.nb_tx_queues - 1);
18907 single_offload = search_tx_offload(res->offload);
18908 if (single_offload == 0) {
18909 printf("Unknown offload name: %s\n", res->offload);
18913 if (!strcmp(res->on_off, "on"))
18914 port->tx_conf[queue_id].offloads |= single_offload;
18916 port->tx_conf[queue_id].offloads &= ~single_offload;
18918 cmd_reconfig_device_queue(port_id, 1, 1);
18921 cmdline_parse_inst_t cmd_config_per_queue_tx_offload = {
18922 .f = cmd_config_per_queue_tx_offload_parsed,
18924 .help_str = "port <port_id> txq <queue_id> tx_offload "
18925 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
18926 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
18927 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
18928 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
18929 "mt_lockfree|multi_segs|mbuf_fast_free|security "
18932 (void *)&cmd_config_per_queue_tx_offload_result_port,
18933 (void *)&cmd_config_per_queue_tx_offload_result_port_id,
18934 (void *)&cmd_config_per_queue_tx_offload_result_txq,
18935 (void *)&cmd_config_per_queue_tx_offload_result_queue_id,
18936 (void *)&cmd_config_per_queue_tx_offload_result_txoffload,
18937 (void *)&cmd_config_per_queue_tx_offload_result_offload,
18938 (void *)&cmd_config_per_queue_tx_offload_result_on_off,
18943 /* *** configure tx_metadata for specific port *** */
18944 struct cmd_config_tx_metadata_specific_result {
18945 cmdline_fixed_string_t port;
18946 cmdline_fixed_string_t keyword;
18948 cmdline_fixed_string_t item;
18953 cmd_config_tx_metadata_specific_parsed(void *parsed_result,
18954 __rte_unused struct cmdline *cl,
18955 __rte_unused void *data)
18957 struct cmd_config_tx_metadata_specific_result *res = parsed_result;
18959 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
18961 ports[res->port_id].tx_metadata = res->value;
18962 /* Add/remove callback to insert valid metadata in every Tx packet. */
18963 if (ports[res->port_id].tx_metadata)
18964 add_tx_md_callback(res->port_id);
18966 remove_tx_md_callback(res->port_id);
18967 rte_flow_dynf_metadata_register();
18970 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_port =
18971 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18973 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_keyword =
18974 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18975 keyword, "config");
18976 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_id =
18977 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18979 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_item =
18980 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18981 item, "tx_metadata");
18982 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_value =
18983 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18986 cmdline_parse_inst_t cmd_config_tx_metadata_specific = {
18987 .f = cmd_config_tx_metadata_specific_parsed,
18989 .help_str = "port config <port_id> tx_metadata <value>",
18991 (void *)&cmd_config_tx_metadata_specific_port,
18992 (void *)&cmd_config_tx_metadata_specific_keyword,
18993 (void *)&cmd_config_tx_metadata_specific_id,
18994 (void *)&cmd_config_tx_metadata_specific_item,
18995 (void *)&cmd_config_tx_metadata_specific_value,
19000 /* *** set dynf *** */
19001 struct cmd_config_tx_dynf_specific_result {
19002 cmdline_fixed_string_t port;
19003 cmdline_fixed_string_t keyword;
19005 cmdline_fixed_string_t item;
19006 cmdline_fixed_string_t name;
19007 cmdline_fixed_string_t value;
19011 cmd_config_dynf_specific_parsed(void *parsed_result,
19012 __rte_unused struct cmdline *cl,
19013 __rte_unused void *data)
19015 struct cmd_config_tx_dynf_specific_result *res = parsed_result;
19016 struct rte_mbuf_dynflag desc_flag;
19018 uint64_t old_port_flags;
19020 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
19022 flag = rte_mbuf_dynflag_lookup(res->name, NULL);
19024 if (strlcpy(desc_flag.name, res->name,
19025 RTE_MBUF_DYN_NAMESIZE) >= RTE_MBUF_DYN_NAMESIZE) {
19026 printf("Flag name too long\n");
19029 desc_flag.flags = 0;
19030 flag = rte_mbuf_dynflag_register(&desc_flag);
19032 printf("Can't register flag\n");
19035 strcpy(dynf_names[flag], desc_flag.name);
19037 old_port_flags = ports[res->port_id].mbuf_dynf;
19038 if (!strcmp(res->value, "set")) {
19039 ports[res->port_id].mbuf_dynf |= 1UL << flag;
19040 if (old_port_flags == 0)
19041 add_tx_dynf_callback(res->port_id);
19043 ports[res->port_id].mbuf_dynf &= ~(1UL << flag);
19044 if (ports[res->port_id].mbuf_dynf == 0)
19045 remove_tx_dynf_callback(res->port_id);
19049 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_port =
19050 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
19052 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_keyword =
19053 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
19054 keyword, "config");
19055 cmdline_parse_token_num_t cmd_config_tx_dynf_specific_port_id =
19056 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
19058 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_item =
19059 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
19061 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_name =
19062 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
19064 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_value =
19065 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
19066 value, "set#clear");
19068 cmdline_parse_inst_t cmd_config_tx_dynf_specific = {
19069 .f = cmd_config_dynf_specific_parsed,
19071 .help_str = "port config <port id> dynf <name> set|clear",
19073 (void *)&cmd_config_tx_dynf_specific_port,
19074 (void *)&cmd_config_tx_dynf_specific_keyword,
19075 (void *)&cmd_config_tx_dynf_specific_port_id,
19076 (void *)&cmd_config_tx_dynf_specific_item,
19077 (void *)&cmd_config_tx_dynf_specific_name,
19078 (void *)&cmd_config_tx_dynf_specific_value,
19083 /* *** display tx_metadata per port configuration *** */
19084 struct cmd_show_tx_metadata_result {
19085 cmdline_fixed_string_t cmd_show;
19086 cmdline_fixed_string_t cmd_port;
19087 cmdline_fixed_string_t cmd_keyword;
19092 cmd_show_tx_metadata_parsed(void *parsed_result,
19093 __rte_unused struct cmdline *cl,
19094 __rte_unused void *data)
19096 struct cmd_show_tx_metadata_result *res = parsed_result;
19098 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
19099 printf("invalid port id %u\n", res->cmd_pid);
19102 if (!strcmp(res->cmd_keyword, "tx_metadata")) {
19103 printf("Port %u tx_metadata: %u\n", res->cmd_pid,
19104 ports[res->cmd_pid].tx_metadata);
19108 cmdline_parse_token_string_t cmd_show_tx_metadata_show =
19109 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
19111 cmdline_parse_token_string_t cmd_show_tx_metadata_port =
19112 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
19114 cmdline_parse_token_num_t cmd_show_tx_metadata_pid =
19115 TOKEN_NUM_INITIALIZER(struct cmd_show_tx_metadata_result,
19117 cmdline_parse_token_string_t cmd_show_tx_metadata_keyword =
19118 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
19119 cmd_keyword, "tx_metadata");
19121 cmdline_parse_inst_t cmd_show_tx_metadata = {
19122 .f = cmd_show_tx_metadata_parsed,
19124 .help_str = "show port <port_id> tx_metadata",
19126 (void *)&cmd_show_tx_metadata_show,
19127 (void *)&cmd_show_tx_metadata_port,
19128 (void *)&cmd_show_tx_metadata_pid,
19129 (void *)&cmd_show_tx_metadata_keyword,
19134 /* *** show fec capability per port configuration *** */
19135 struct cmd_show_fec_capability_result {
19136 cmdline_fixed_string_t cmd_show;
19137 cmdline_fixed_string_t cmd_port;
19138 cmdline_fixed_string_t cmd_fec;
19139 cmdline_fixed_string_t cmd_keyword;
19144 cmd_show_fec_capability_parsed(void *parsed_result,
19145 __rte_unused struct cmdline *cl,
19146 __rte_unused void *data)
19148 #define FEC_CAP_NUM 2
19149 struct cmd_show_fec_capability_result *res = parsed_result;
19150 struct rte_eth_fec_capa speed_fec_capa[FEC_CAP_NUM];
19151 unsigned int num = FEC_CAP_NUM;
19152 unsigned int ret_num;
19155 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
19156 printf("Invalid port id %u\n", res->cmd_pid);
19160 ret = rte_eth_fec_get_capability(res->cmd_pid, speed_fec_capa, num);
19161 if (ret == -ENOTSUP) {
19162 printf("Function not implemented\n");
19164 } else if (ret < 0) {
19165 printf("Get FEC capability failed\n");
19169 ret_num = (unsigned int)ret;
19170 show_fec_capability(ret_num, speed_fec_capa);
19173 cmdline_parse_token_string_t cmd_show_fec_capability_show =
19174 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
19176 cmdline_parse_token_string_t cmd_show_fec_capability_port =
19177 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
19179 cmdline_parse_token_num_t cmd_show_fec_capability_pid =
19180 TOKEN_NUM_INITIALIZER(struct cmd_show_fec_capability_result,
19182 cmdline_parse_token_string_t cmd_show_fec_capability_fec =
19183 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
19185 cmdline_parse_token_string_t cmd_show_fec_capability_keyword =
19186 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
19187 cmd_keyword, "capabilities");
19189 cmdline_parse_inst_t cmd_show_capability = {
19190 .f = cmd_show_fec_capability_parsed,
19192 .help_str = "show port <port_id> fec capabilities",
19194 (void *)&cmd_show_fec_capability_show,
19195 (void *)&cmd_show_fec_capability_port,
19196 (void *)&cmd_show_fec_capability_pid,
19197 (void *)&cmd_show_fec_capability_fec,
19198 (void *)&cmd_show_fec_capability_keyword,
19203 /* *** show fec mode per port configuration *** */
19204 struct cmd_show_fec_metadata_result {
19205 cmdline_fixed_string_t cmd_show;
19206 cmdline_fixed_string_t cmd_port;
19207 cmdline_fixed_string_t cmd_keyword;
19212 cmd_show_fec_mode_parsed(void *parsed_result,
19213 __rte_unused struct cmdline *cl,
19214 __rte_unused void *data)
19216 #define FEC_NAME_SIZE 16
19217 struct cmd_show_fec_metadata_result *res = parsed_result;
19219 char buf[FEC_NAME_SIZE];
19222 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
19223 printf("Invalid port id %u\n", res->cmd_pid);
19226 ret = rte_eth_fec_get(res->cmd_pid, &mode);
19227 if (ret == -ENOTSUP) {
19228 printf("Function not implemented\n");
19230 } else if (ret < 0) {
19231 printf("Get FEC mode failed\n");
19236 case RTE_ETH_FEC_MODE_CAPA_MASK(NOFEC):
19237 strlcpy(buf, "off", sizeof(buf));
19239 case RTE_ETH_FEC_MODE_CAPA_MASK(AUTO):
19240 strlcpy(buf, "auto", sizeof(buf));
19242 case RTE_ETH_FEC_MODE_CAPA_MASK(BASER):
19243 strlcpy(buf, "baser", sizeof(buf));
19245 case RTE_ETH_FEC_MODE_CAPA_MASK(RS):
19246 strlcpy(buf, "rs", sizeof(buf));
19252 printf("%s\n", buf);
19255 cmdline_parse_token_string_t cmd_show_fec_mode_show =
19256 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
19258 cmdline_parse_token_string_t cmd_show_fec_mode_port =
19259 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
19261 cmdline_parse_token_num_t cmd_show_fec_mode_pid =
19262 TOKEN_NUM_INITIALIZER(struct cmd_show_fec_metadata_result,
19264 cmdline_parse_token_string_t cmd_show_fec_mode_keyword =
19265 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
19266 cmd_keyword, "fec_mode");
19268 cmdline_parse_inst_t cmd_show_fec_mode = {
19269 .f = cmd_show_fec_mode_parsed,
19271 .help_str = "show port <port_id> fec_mode",
19273 (void *)&cmd_show_fec_mode_show,
19274 (void *)&cmd_show_fec_mode_port,
19275 (void *)&cmd_show_fec_mode_pid,
19276 (void *)&cmd_show_fec_mode_keyword,
19281 /* *** set fec mode per port configuration *** */
19282 struct cmd_set_port_fec_mode {
19283 cmdline_fixed_string_t set;
19284 cmdline_fixed_string_t port;
19286 cmdline_fixed_string_t fec_mode;
19287 cmdline_fixed_string_t fec_value;
19290 /* Common CLI fields for set fec mode */
19291 cmdline_parse_token_string_t cmd_set_port_fec_mode_set =
19292 TOKEN_STRING_INITIALIZER
19293 (struct cmd_set_port_fec_mode,
19295 cmdline_parse_token_string_t cmd_set_port_fec_mode_port =
19296 TOKEN_STRING_INITIALIZER
19297 (struct cmd_set_port_fec_mode,
19299 cmdline_parse_token_num_t cmd_set_port_fec_mode_port_id =
19300 TOKEN_NUM_INITIALIZER
19301 (struct cmd_set_port_fec_mode,
19303 cmdline_parse_token_string_t cmd_set_port_fec_mode_str =
19304 TOKEN_STRING_INITIALIZER
19305 (struct cmd_set_port_fec_mode,
19306 fec_mode, "fec_mode");
19307 cmdline_parse_token_string_t cmd_set_port_fec_mode_value =
19308 TOKEN_STRING_INITIALIZER
19309 (struct cmd_set_port_fec_mode,
19313 cmd_set_port_fec_mode_parsed(
19314 void *parsed_result,
19315 __rte_unused struct cmdline *cl,
19316 __rte_unused void *data)
19318 struct cmd_set_port_fec_mode *res = parsed_result;
19319 uint16_t port_id = res->port_id;
19323 ret = parse_fec_mode(res->fec_value, &mode);
19325 printf("Unknown fec mode: %s for Port %d\n", res->fec_value,
19330 ret = rte_eth_fec_set(port_id, mode);
19331 if (ret == -ENOTSUP) {
19332 printf("Function not implemented\n");
19334 } else if (ret < 0) {
19335 printf("Set FEC mode failed\n");
19340 cmdline_parse_inst_t cmd_set_fec_mode = {
19341 .f = cmd_set_port_fec_mode_parsed,
19343 .help_str = "set port <port_id> fec_mode auto|off|rs|baser",
19345 (void *)&cmd_set_port_fec_mode_set,
19346 (void *)&cmd_set_port_fec_mode_port,
19347 (void *)&cmd_set_port_fec_mode_port_id,
19348 (void *)&cmd_set_port_fec_mode_str,
19349 (void *)&cmd_set_port_fec_mode_value,
19354 /* show port supported ptypes */
19356 /* Common result structure for show port ptypes */
19357 struct cmd_show_port_supported_ptypes_result {
19358 cmdline_fixed_string_t show;
19359 cmdline_fixed_string_t port;
19361 cmdline_fixed_string_t ptypes;
19364 /* Common CLI fields for show port ptypes */
19365 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_show =
19366 TOKEN_STRING_INITIALIZER
19367 (struct cmd_show_port_supported_ptypes_result,
19369 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_port =
19370 TOKEN_STRING_INITIALIZER
19371 (struct cmd_show_port_supported_ptypes_result,
19373 cmdline_parse_token_num_t cmd_show_port_supported_ptypes_port_id =
19374 TOKEN_NUM_INITIALIZER
19375 (struct cmd_show_port_supported_ptypes_result,
19377 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_ptypes =
19378 TOKEN_STRING_INITIALIZER
19379 (struct cmd_show_port_supported_ptypes_result,
19383 cmd_show_port_supported_ptypes_parsed(
19384 void *parsed_result,
19385 __rte_unused struct cmdline *cl,
19386 __rte_unused void *data)
19388 #define RSVD_PTYPE_MASK 0xf0000000
19389 #define MAX_PTYPES_PER_LAYER 16
19390 #define LTYPE_NAMESIZE 32
19391 #define PTYPE_NAMESIZE 256
19392 struct cmd_show_port_supported_ptypes_result *res = parsed_result;
19393 char buf[PTYPE_NAMESIZE], ltype[LTYPE_NAMESIZE];
19394 uint32_t ptype_mask = RTE_PTYPE_L2_MASK;
19395 uint32_t ptypes[MAX_PTYPES_PER_LAYER];
19396 uint16_t port_id = res->port_id;
19399 ret = rte_eth_dev_get_supported_ptypes(port_id, ptype_mask, NULL, 0);
19403 while (ptype_mask != RSVD_PTYPE_MASK) {
19405 switch (ptype_mask) {
19406 case RTE_PTYPE_L2_MASK:
19407 strlcpy(ltype, "L2", sizeof(ltype));
19409 case RTE_PTYPE_L3_MASK:
19410 strlcpy(ltype, "L3", sizeof(ltype));
19412 case RTE_PTYPE_L4_MASK:
19413 strlcpy(ltype, "L4", sizeof(ltype));
19415 case RTE_PTYPE_TUNNEL_MASK:
19416 strlcpy(ltype, "Tunnel", sizeof(ltype));
19418 case RTE_PTYPE_INNER_L2_MASK:
19419 strlcpy(ltype, "Inner L2", sizeof(ltype));
19421 case RTE_PTYPE_INNER_L3_MASK:
19422 strlcpy(ltype, "Inner L3", sizeof(ltype));
19424 case RTE_PTYPE_INNER_L4_MASK:
19425 strlcpy(ltype, "Inner L4", sizeof(ltype));
19431 ret = rte_eth_dev_get_supported_ptypes(res->port_id,
19432 ptype_mask, ptypes,
19433 MAX_PTYPES_PER_LAYER);
19436 printf("Supported %s ptypes:\n", ltype);
19438 printf("%s ptypes unsupported\n", ltype);
19440 for (i = 0; i < ret; ++i) {
19441 rte_get_ptype_name(ptypes[i], buf, sizeof(buf));
19442 printf("%s\n", buf);
19449 cmdline_parse_inst_t cmd_show_port_supported_ptypes = {
19450 .f = cmd_show_port_supported_ptypes_parsed,
19452 .help_str = "show port <port_id> ptypes",
19454 (void *)&cmd_show_port_supported_ptypes_show,
19455 (void *)&cmd_show_port_supported_ptypes_port,
19456 (void *)&cmd_show_port_supported_ptypes_port_id,
19457 (void *)&cmd_show_port_supported_ptypes_ptypes,
19462 /* *** display rx/tx descriptor status *** */
19463 struct cmd_show_rx_tx_desc_status_result {
19464 cmdline_fixed_string_t cmd_show;
19465 cmdline_fixed_string_t cmd_port;
19466 cmdline_fixed_string_t cmd_keyword;
19467 cmdline_fixed_string_t cmd_desc;
19468 cmdline_fixed_string_t cmd_status;
19475 cmd_show_rx_tx_desc_status_parsed(void *parsed_result,
19476 __rte_unused struct cmdline *cl,
19477 __rte_unused void *data)
19479 struct cmd_show_rx_tx_desc_status_result *res = parsed_result;
19482 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
19483 printf("invalid port id %u\n", res->cmd_pid);
19487 if (!strcmp(res->cmd_keyword, "rxq")) {
19488 rc = rte_eth_rx_descriptor_status(res->cmd_pid, res->cmd_qid,
19491 printf("Invalid queueid = %d\n", res->cmd_qid);
19494 if (rc == RTE_ETH_RX_DESC_AVAIL)
19495 printf("Desc status = AVAILABLE\n");
19496 else if (rc == RTE_ETH_RX_DESC_DONE)
19497 printf("Desc status = DONE\n");
19499 printf("Desc status = UNAVAILABLE\n");
19500 } else if (!strcmp(res->cmd_keyword, "txq")) {
19501 rc = rte_eth_tx_descriptor_status(res->cmd_pid, res->cmd_qid,
19504 printf("Invalid queueid = %d\n", res->cmd_qid);
19507 if (rc == RTE_ETH_TX_DESC_FULL)
19508 printf("Desc status = FULL\n");
19509 else if (rc == RTE_ETH_TX_DESC_DONE)
19510 printf("Desc status = DONE\n");
19512 printf("Desc status = UNAVAILABLE\n");
19516 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_show =
19517 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19519 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_port =
19520 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19522 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_pid =
19523 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19525 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_keyword =
19526 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19527 cmd_keyword, "rxq#txq");
19528 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_qid =
19529 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19531 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_desc =
19532 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19534 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_did =
19535 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19537 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_status =
19538 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19539 cmd_status, "status");
19540 cmdline_parse_inst_t cmd_show_rx_tx_desc_status = {
19541 .f = cmd_show_rx_tx_desc_status_parsed,
19543 .help_str = "show port <port_id> rxq|txq <queue_id> desc <desc_id> "
19546 (void *)&cmd_show_rx_tx_desc_status_show,
19547 (void *)&cmd_show_rx_tx_desc_status_port,
19548 (void *)&cmd_show_rx_tx_desc_status_pid,
19549 (void *)&cmd_show_rx_tx_desc_status_keyword,
19550 (void *)&cmd_show_rx_tx_desc_status_qid,
19551 (void *)&cmd_show_rx_tx_desc_status_desc,
19552 (void *)&cmd_show_rx_tx_desc_status_did,
19553 (void *)&cmd_show_rx_tx_desc_status_status,
19558 /* Common result structure for set port ptypes */
19559 struct cmd_set_port_ptypes_result {
19560 cmdline_fixed_string_t set;
19561 cmdline_fixed_string_t port;
19563 cmdline_fixed_string_t ptype_mask;
19567 /* Common CLI fields for set port ptypes */
19568 cmdline_parse_token_string_t cmd_set_port_ptypes_set =
19569 TOKEN_STRING_INITIALIZER
19570 (struct cmd_set_port_ptypes_result,
19572 cmdline_parse_token_string_t cmd_set_port_ptypes_port =
19573 TOKEN_STRING_INITIALIZER
19574 (struct cmd_set_port_ptypes_result,
19576 cmdline_parse_token_num_t cmd_set_port_ptypes_port_id =
19577 TOKEN_NUM_INITIALIZER
19578 (struct cmd_set_port_ptypes_result,
19580 cmdline_parse_token_string_t cmd_set_port_ptypes_mask_str =
19581 TOKEN_STRING_INITIALIZER
19582 (struct cmd_set_port_ptypes_result,
19583 ptype_mask, "ptype_mask");
19584 cmdline_parse_token_num_t cmd_set_port_ptypes_mask_u32 =
19585 TOKEN_NUM_INITIALIZER
19586 (struct cmd_set_port_ptypes_result,
19590 cmd_set_port_ptypes_parsed(
19591 void *parsed_result,
19592 __rte_unused struct cmdline *cl,
19593 __rte_unused void *data)
19595 struct cmd_set_port_ptypes_result *res = parsed_result;
19596 #define PTYPE_NAMESIZE 256
19597 char ptype_name[PTYPE_NAMESIZE];
19598 uint16_t port_id = res->port_id;
19599 uint32_t ptype_mask = res->mask;
19602 ret = rte_eth_dev_get_supported_ptypes(port_id, RTE_PTYPE_ALL_MASK,
19605 printf("Port %d doesn't support any ptypes.\n", port_id);
19609 uint32_t ptypes[ret];
19611 ret = rte_eth_dev_set_ptypes(port_id, ptype_mask, ptypes, ret);
19613 printf("Unable to set requested ptypes for Port %d\n", port_id);
19617 printf("Successfully set following ptypes for Port %d\n", port_id);
19618 for (i = 0; i < ret && ptypes[i] != RTE_PTYPE_UNKNOWN; i++) {
19619 rte_get_ptype_name(ptypes[i], ptype_name, sizeof(ptype_name));
19620 printf("%s\n", ptype_name);
19623 clear_ptypes = false;
19626 cmdline_parse_inst_t cmd_set_port_ptypes = {
19627 .f = cmd_set_port_ptypes_parsed,
19629 .help_str = "set port <port_id> ptype_mask <mask>",
19631 (void *)&cmd_set_port_ptypes_set,
19632 (void *)&cmd_set_port_ptypes_port,
19633 (void *)&cmd_set_port_ptypes_port_id,
19634 (void *)&cmd_set_port_ptypes_mask_str,
19635 (void *)&cmd_set_port_ptypes_mask_u32,
19640 /* *** display mac addresses added to a port *** */
19641 struct cmd_showport_macs_result {
19642 cmdline_fixed_string_t cmd_show;
19643 cmdline_fixed_string_t cmd_port;
19644 cmdline_fixed_string_t cmd_keyword;
19649 cmd_showport_macs_parsed(void *parsed_result,
19650 __rte_unused struct cmdline *cl,
19651 __rte_unused void *data)
19653 struct cmd_showport_macs_result *res = parsed_result;
19655 if (port_id_is_invalid(res->cmd_pid, ENABLED_WARN))
19658 if (!strcmp(res->cmd_keyword, "macs"))
19659 show_macs(res->cmd_pid);
19660 else if (!strcmp(res->cmd_keyword, "mcast_macs"))
19661 show_mcast_macs(res->cmd_pid);
19664 cmdline_parse_token_string_t cmd_showport_macs_show =
19665 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
19667 cmdline_parse_token_string_t cmd_showport_macs_port =
19668 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
19670 cmdline_parse_token_num_t cmd_showport_macs_pid =
19671 TOKEN_NUM_INITIALIZER(struct cmd_showport_macs_result,
19673 cmdline_parse_token_string_t cmd_showport_macs_keyword =
19674 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
19675 cmd_keyword, "macs#mcast_macs");
19677 cmdline_parse_inst_t cmd_showport_macs = {
19678 .f = cmd_showport_macs_parsed,
19680 .help_str = "show port <port_id> macs|mcast_macs",
19682 (void *)&cmd_showport_macs_show,
19683 (void *)&cmd_showport_macs_port,
19684 (void *)&cmd_showport_macs_pid,
19685 (void *)&cmd_showport_macs_keyword,
19690 /* ******************************************************************************** */
19692 /* list of instructions */
19693 cmdline_parse_ctx_t main_ctx[] = {
19694 (cmdline_parse_inst_t *)&cmd_help_brief,
19695 (cmdline_parse_inst_t *)&cmd_help_long,
19696 (cmdline_parse_inst_t *)&cmd_quit,
19697 (cmdline_parse_inst_t *)&cmd_load_from_file,
19698 (cmdline_parse_inst_t *)&cmd_showport,
19699 (cmdline_parse_inst_t *)&cmd_showqueue,
19700 (cmdline_parse_inst_t *)&cmd_showeeprom,
19701 (cmdline_parse_inst_t *)&cmd_showportall,
19702 (cmdline_parse_inst_t *)&cmd_showdevice,
19703 (cmdline_parse_inst_t *)&cmd_showcfg,
19704 (cmdline_parse_inst_t *)&cmd_showfwdall,
19705 (cmdline_parse_inst_t *)&cmd_start,
19706 (cmdline_parse_inst_t *)&cmd_start_tx_first,
19707 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
19708 (cmdline_parse_inst_t *)&cmd_set_link_up,
19709 (cmdline_parse_inst_t *)&cmd_set_link_down,
19710 (cmdline_parse_inst_t *)&cmd_reset,
19711 (cmdline_parse_inst_t *)&cmd_set_numbers,
19712 (cmdline_parse_inst_t *)&cmd_set_log,
19713 (cmdline_parse_inst_t *)&cmd_set_rxoffs,
19714 (cmdline_parse_inst_t *)&cmd_set_rxpkts,
19715 (cmdline_parse_inst_t *)&cmd_set_txpkts,
19716 (cmdline_parse_inst_t *)&cmd_set_txsplit,
19717 (cmdline_parse_inst_t *)&cmd_set_txtimes,
19718 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
19719 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
19720 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
19721 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
19722 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
19723 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
19724 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
19725 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
19726 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
19727 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
19728 (cmdline_parse_inst_t *)&cmd_set_link_check,
19729 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
19730 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
19731 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
19732 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
19733 #ifdef RTE_NET_BOND
19734 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
19735 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
19736 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
19737 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
19738 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
19739 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
19740 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
19741 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
19742 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
19743 (cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues,
19744 (cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy,
19746 (cmdline_parse_inst_t *)&cmd_vlan_offload,
19747 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
19748 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
19749 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
19750 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
19751 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
19752 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
19753 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
19754 (cmdline_parse_inst_t *)&cmd_csum_set,
19755 (cmdline_parse_inst_t *)&cmd_csum_show,
19756 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
19757 (cmdline_parse_inst_t *)&cmd_tso_set,
19758 (cmdline_parse_inst_t *)&cmd_tso_show,
19759 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
19760 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
19761 (cmdline_parse_inst_t *)&cmd_gro_enable,
19762 (cmdline_parse_inst_t *)&cmd_gro_flush,
19763 (cmdline_parse_inst_t *)&cmd_gro_show,
19764 (cmdline_parse_inst_t *)&cmd_gso_enable,
19765 (cmdline_parse_inst_t *)&cmd_gso_size,
19766 (cmdline_parse_inst_t *)&cmd_gso_show,
19767 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
19768 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
19769 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
19770 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
19771 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
19772 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
19773 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
19774 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
19775 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
19776 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
19777 (cmdline_parse_inst_t *)&cmd_config_dcb,
19778 (cmdline_parse_inst_t *)&cmd_read_reg,
19779 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
19780 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
19781 (cmdline_parse_inst_t *)&cmd_write_reg,
19782 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
19783 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
19784 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
19785 (cmdline_parse_inst_t *)&cmd_stop,
19786 (cmdline_parse_inst_t *)&cmd_mac_addr,
19787 (cmdline_parse_inst_t *)&cmd_set_fwd_eth_peer,
19788 (cmdline_parse_inst_t *)&cmd_set_qmap,
19789 (cmdline_parse_inst_t *)&cmd_set_xstats_hide_zero,
19790 (cmdline_parse_inst_t *)&cmd_set_record_core_cycles,
19791 (cmdline_parse_inst_t *)&cmd_set_record_burst_stats,
19792 (cmdline_parse_inst_t *)&cmd_operate_port,
19793 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
19794 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
19795 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
19796 (cmdline_parse_inst_t *)&cmd_operate_detach_device,
19797 (cmdline_parse_inst_t *)&cmd_set_port_setup_on,
19798 (cmdline_parse_inst_t *)&cmd_config_speed_all,
19799 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
19800 (cmdline_parse_inst_t *)&cmd_config_loopback_all,
19801 (cmdline_parse_inst_t *)&cmd_config_loopback_specific,
19802 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
19803 (cmdline_parse_inst_t *)&cmd_config_mtu,
19804 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
19805 (cmdline_parse_inst_t *)&cmd_config_max_lro_pkt_size,
19806 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
19807 (cmdline_parse_inst_t *)&cmd_config_rss,
19808 (cmdline_parse_inst_t *)&cmd_config_rxtx_ring_size,
19809 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
19810 (cmdline_parse_inst_t *)&cmd_config_deferred_start_rxtx_queue,
19811 (cmdline_parse_inst_t *)&cmd_setup_rxtx_queue,
19812 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
19813 (cmdline_parse_inst_t *)&cmd_showport_reta,
19814 (cmdline_parse_inst_t *)&cmd_showport_macs,
19815 (cmdline_parse_inst_t *)&cmd_config_burst,
19816 (cmdline_parse_inst_t *)&cmd_config_thresh,
19817 (cmdline_parse_inst_t *)&cmd_config_threshold,
19818 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
19819 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
19820 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
19821 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
19822 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
19823 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
19824 (cmdline_parse_inst_t *)&cmd_global_config,
19825 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
19826 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
19827 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
19828 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
19829 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
19830 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
19831 (cmdline_parse_inst_t *)&cmd_dump,
19832 (cmdline_parse_inst_t *)&cmd_dump_one,
19833 (cmdline_parse_inst_t *)&cmd_syn_filter,
19834 (cmdline_parse_inst_t *)&cmd_2tuple_filter,
19835 (cmdline_parse_inst_t *)&cmd_5tuple_filter,
19836 (cmdline_parse_inst_t *)&cmd_flex_filter,
19837 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
19838 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
19839 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
19840 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director,
19841 (cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director,
19842 (cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director,
19843 (cmdline_parse_inst_t *)&cmd_add_del_raw_flow_director,
19844 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
19845 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
19846 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
19847 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
19848 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
19849 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
19850 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
19851 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
19852 (cmdline_parse_inst_t *)&cmd_get_hash_global_config,
19853 (cmdline_parse_inst_t *)&cmd_set_hash_global_config,
19854 (cmdline_parse_inst_t *)&cmd_set_hash_input_set,
19855 (cmdline_parse_inst_t *)&cmd_set_fdir_input_set,
19856 (cmdline_parse_inst_t *)&cmd_flow,
19857 (cmdline_parse_inst_t *)&cmd_show_port_meter_cap,
19858 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm,
19859 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm,
19860 (cmdline_parse_inst_t *)&cmd_del_port_meter_profile,
19861 (cmdline_parse_inst_t *)&cmd_create_port_meter,
19862 (cmdline_parse_inst_t *)&cmd_enable_port_meter,
19863 (cmdline_parse_inst_t *)&cmd_disable_port_meter,
19864 (cmdline_parse_inst_t *)&cmd_del_port_meter,
19865 (cmdline_parse_inst_t *)&cmd_set_port_meter_profile,
19866 (cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table,
19867 (cmdline_parse_inst_t *)&cmd_set_port_meter_policer_action,
19868 (cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask,
19869 (cmdline_parse_inst_t *)&cmd_show_port_meter_stats,
19870 (cmdline_parse_inst_t *)&cmd_mcast_addr,
19871 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all,
19872 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific,
19873 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all,
19874 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific,
19875 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_en,
19876 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_dis,
19877 (cmdline_parse_inst_t *)&cmd_config_e_tag_stripping_en_dis,
19878 (cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis,
19879 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_add,
19880 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_del,
19881 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
19882 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
19883 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
19884 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
19885 (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
19886 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
19887 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
19888 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
19889 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
19890 (cmdline_parse_inst_t *)&cmd_set_macsec_sc,
19891 (cmdline_parse_inst_t *)&cmd_set_macsec_sa,
19892 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
19893 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
19894 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
19895 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
19896 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
19897 (cmdline_parse_inst_t *)&cmd_set_vf_promisc,
19898 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
19899 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
19900 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
19901 (cmdline_parse_inst_t *)&cmd_vf_max_bw,
19902 (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
19903 (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
19904 (cmdline_parse_inst_t *)&cmd_strict_link_prio,
19905 (cmdline_parse_inst_t *)&cmd_tc_min_bw,
19906 (cmdline_parse_inst_t *)&cmd_set_vxlan,
19907 (cmdline_parse_inst_t *)&cmd_set_vxlan_tos_ttl,
19908 (cmdline_parse_inst_t *)&cmd_set_vxlan_with_vlan,
19909 (cmdline_parse_inst_t *)&cmd_set_nvgre,
19910 (cmdline_parse_inst_t *)&cmd_set_nvgre_with_vlan,
19911 (cmdline_parse_inst_t *)&cmd_set_l2_encap,
19912 (cmdline_parse_inst_t *)&cmd_set_l2_encap_with_vlan,
19913 (cmdline_parse_inst_t *)&cmd_set_l2_decap,
19914 (cmdline_parse_inst_t *)&cmd_set_l2_decap_with_vlan,
19915 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap,
19916 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap_with_vlan,
19917 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap,
19918 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap_with_vlan,
19919 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap,
19920 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap_with_vlan,
19921 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap,
19922 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap_with_vlan,
19923 (cmdline_parse_inst_t *)&cmd_ddp_add,
19924 (cmdline_parse_inst_t *)&cmd_ddp_del,
19925 (cmdline_parse_inst_t *)&cmd_ddp_get_list,
19926 (cmdline_parse_inst_t *)&cmd_ddp_get_info,
19927 (cmdline_parse_inst_t *)&cmd_cfg_input_set,
19928 (cmdline_parse_inst_t *)&cmd_clear_input_set,
19929 (cmdline_parse_inst_t *)&cmd_show_vf_stats,
19930 (cmdline_parse_inst_t *)&cmd_clear_vf_stats,
19931 (cmdline_parse_inst_t *)&cmd_show_port_supported_ptypes,
19932 (cmdline_parse_inst_t *)&cmd_set_port_ptypes,
19933 (cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
19934 (cmdline_parse_inst_t *)&cmd_ptype_mapping_replace,
19935 (cmdline_parse_inst_t *)&cmd_ptype_mapping_reset,
19936 (cmdline_parse_inst_t *)&cmd_ptype_mapping_update,
19938 (cmdline_parse_inst_t *)&cmd_pctype_mapping_get,
19939 (cmdline_parse_inst_t *)&cmd_pctype_mapping_reset,
19940 (cmdline_parse_inst_t *)&cmd_pctype_mapping_update,
19941 (cmdline_parse_inst_t *)&cmd_queue_region,
19942 (cmdline_parse_inst_t *)&cmd_region_flowtype,
19943 (cmdline_parse_inst_t *)&cmd_user_priority_region,
19944 (cmdline_parse_inst_t *)&cmd_flush_queue_region,
19945 (cmdline_parse_inst_t *)&cmd_show_queue_region_info_all,
19946 (cmdline_parse_inst_t *)&cmd_show_port_tm_cap,
19947 (cmdline_parse_inst_t *)&cmd_show_port_tm_level_cap,
19948 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_cap,
19949 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_type,
19950 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_stats,
19951 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shaper_profile,
19952 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shaper_profile,
19953 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shared_shaper,
19954 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shared_shaper,
19955 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_wred_profile,
19956 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_wred_profile,
19957 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_shaper_profile,
19958 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node,
19959 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node_pmode,
19960 (cmdline_parse_inst_t *)&cmd_add_port_tm_leaf_node,
19961 (cmdline_parse_inst_t *)&cmd_del_port_tm_node,
19962 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_parent,
19963 (cmdline_parse_inst_t *)&cmd_suspend_port_tm_node,
19964 (cmdline_parse_inst_t *)&cmd_resume_port_tm_node,
19965 (cmdline_parse_inst_t *)&cmd_port_tm_hierarchy_commit,
19966 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_ecn,
19967 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_dscp,
19968 (cmdline_parse_inst_t *)&cmd_port_tm_mark_vlan_dei,
19969 (cmdline_parse_inst_t *)&cmd_cfg_tunnel_udp_port,
19970 (cmdline_parse_inst_t *)&cmd_rx_offload_get_capa,
19971 (cmdline_parse_inst_t *)&cmd_rx_offload_get_configuration,
19972 (cmdline_parse_inst_t *)&cmd_config_per_port_rx_offload,
19973 (cmdline_parse_inst_t *)&cmd_config_per_queue_rx_offload,
19974 (cmdline_parse_inst_t *)&cmd_tx_offload_get_capa,
19975 (cmdline_parse_inst_t *)&cmd_tx_offload_get_configuration,
19976 (cmdline_parse_inst_t *)&cmd_config_per_port_tx_offload,
19977 (cmdline_parse_inst_t *)&cmd_config_per_queue_tx_offload,
19979 (cmdline_parse_inst_t *)&cmd_operate_bpf_ld_parse,
19980 (cmdline_parse_inst_t *)&cmd_operate_bpf_unld_parse,
19982 (cmdline_parse_inst_t *)&cmd_config_tx_metadata_specific,
19983 (cmdline_parse_inst_t *)&cmd_show_tx_metadata,
19984 (cmdline_parse_inst_t *)&cmd_show_rx_tx_desc_status,
19985 (cmdline_parse_inst_t *)&cmd_set_raw,
19986 (cmdline_parse_inst_t *)&cmd_show_set_raw,
19987 (cmdline_parse_inst_t *)&cmd_show_set_raw_all,
19988 (cmdline_parse_inst_t *)&cmd_config_tx_dynf_specific,
19989 (cmdline_parse_inst_t *)&cmd_show_fec_mode,
19990 (cmdline_parse_inst_t *)&cmd_set_fec_mode,
19991 (cmdline_parse_inst_t *)&cmd_show_capability,
19995 /* read cmdline commands from file */
19997 cmdline_read_from_file(const char *filename)
19999 struct cmdline *cl;
20001 cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
20003 printf("Failed to create file based cmdline context: %s\n",
20008 cmdline_interact(cl);
20013 printf("Read CLI commands from %s\n", filename);
20016 /* prompt function, called from main on MAIN lcore */
20020 /* initialize non-constant commands */
20021 cmd_set_fwd_mode_init();
20022 cmd_set_fwd_retry_mode_init();
20024 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
20025 if (testpmd_cl == NULL)
20027 cmdline_interact(testpmd_cl);
20028 cmdline_stdin_exit(testpmd_cl);
20034 if (testpmd_cl != NULL)
20035 cmdline_quit(testpmd_cl);
20039 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
20041 if (id == (portid_t)RTE_PORT_ALL) {
20044 RTE_ETH_FOREACH_DEV(pid) {
20045 /* check if need_reconfig has been set to 1 */
20046 if (ports[pid].need_reconfig == 0)
20047 ports[pid].need_reconfig = dev;
20048 /* check if need_reconfig_queues has been set to 1 */
20049 if (ports[pid].need_reconfig_queues == 0)
20050 ports[pid].need_reconfig_queues = queue;
20052 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
20053 /* check if need_reconfig has been set to 1 */
20054 if (ports[id].need_reconfig == 0)
20055 ports[id].need_reconfig = dev;
20056 /* check if need_reconfig_queues has been set to 1 */
20057 if (ports[id].need_reconfig_queues == 0)
20058 ports[id].need_reconfig_queues = queue;