4 * Copyright(c) 2010-2016 Intel Corporation. All rights reserved.
5 * Copyright(c) 2014 6WIND S.A.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
12 * * Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * * Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in
16 * the documentation and/or other materials provided with the
18 * * Neither the name of Intel Corporation nor the names of its
19 * contributors may be used to endorse or promote products derived
20 * from this software without specific prior written permission.
22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
26 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
28 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
45 #include <net/socket.h>
47 #include <sys/socket.h>
50 #include <netinet/in.h>
52 #include <sys/queue.h>
54 #include <rte_common.h>
55 #include <rte_byteorder.h>
57 #include <rte_debug.h>
58 #include <rte_cycles.h>
59 #include <rte_memory.h>
60 #include <rte_memzone.h>
61 #include <rte_malloc.h>
62 #include <rte_launch.h>
64 #include <rte_per_lcore.h>
65 #include <rte_lcore.h>
66 #include <rte_atomic.h>
67 #include <rte_branch_prediction.h>
69 #include <rte_mempool.h>
70 #include <rte_interrupts.h>
72 #include <rte_ether.h>
73 #include <rte_ethdev.h>
74 #include <rte_string_fns.h>
75 #include <rte_devargs.h>
76 #include <rte_eth_ctrl.h>
80 #include <cmdline_rdline.h>
81 #include <cmdline_parse.h>
82 #include <cmdline_parse_num.h>
83 #include <cmdline_parse_string.h>
84 #include <cmdline_parse_ipaddr.h>
85 #include <cmdline_parse_etheraddr.h>
86 #include <cmdline_socket.h>
88 #ifdef RTE_LIBRTE_PMD_BOND
89 #include <rte_eth_bond.h>
90 #include <rte_eth_bond_8023ad.h>
92 #ifdef RTE_LIBRTE_IXGBE_PMD
93 #include <rte_pmd_ixgbe.h>
95 #ifdef RTE_LIBRTE_I40E_PMD
96 #include <rte_pmd_i40e.h>
98 #ifdef RTE_LIBRTE_BNXT_PMD
99 #include <rte_pmd_bnxt.h>
102 #include "cmdline_mtr.h"
103 #include "cmdline_tm.h"
105 static struct cmdline *testpmd_cl;
107 static void cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue);
109 /* *** Help command with introduction. *** */
110 struct cmd_help_brief_result {
111 cmdline_fixed_string_t help;
114 static void cmd_help_brief_parsed(__attribute__((unused)) void *parsed_result,
116 __attribute__((unused)) void *data)
121 "Help is available for the following sections:\n\n"
122 " help control : Start and stop forwarding.\n"
123 " help display : Displaying port, stats and config "
125 " help config : Configuration information.\n"
126 " help ports : Configuring ports.\n"
127 " help registers : Reading and setting port registers.\n"
128 " help filters : Filters configuration help.\n"
129 " help all : All of the above sections.\n\n"
134 cmdline_parse_token_string_t cmd_help_brief_help =
135 TOKEN_STRING_INITIALIZER(struct cmd_help_brief_result, help, "help");
137 cmdline_parse_inst_t cmd_help_brief = {
138 .f = cmd_help_brief_parsed,
140 .help_str = "help: Show help",
142 (void *)&cmd_help_brief_help,
147 /* *** Help command with help sections. *** */
148 struct cmd_help_long_result {
149 cmdline_fixed_string_t help;
150 cmdline_fixed_string_t section;
153 static void cmd_help_long_parsed(void *parsed_result,
155 __attribute__((unused)) void *data)
158 struct cmd_help_long_result *res = parsed_result;
160 if (!strcmp(res->section, "all"))
163 if (show_all || !strcmp(res->section, "control")) {
168 "Control forwarding:\n"
169 "-------------------\n\n"
172 " Start packet forwarding with current configuration.\n\n"
175 " Start packet forwarding with current config"
176 " after sending one burst of packets.\n\n"
179 " Stop packet forwarding, and display accumulated"
183 " Quit to prompt.\n\n"
187 if (show_all || !strcmp(res->section, "display")) {
195 "show port (info|stats|xstats|fdir|stat_qmap|dcb_tc|cap) (port_id|all)\n"
196 " Display information for port_id, or all.\n\n"
198 "show port X rss reta (size) (mask0,mask1,...)\n"
199 " Display the rss redirection table entry indicated"
200 " by masks on port X. size is used to indicate the"
201 " hardware supported reta size\n\n"
203 "show port rss-hash ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|"
204 "ipv4-sctp|ipv4-other|ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
205 "ipv6-other|l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex [key]\n"
206 " Display the RSS hash functions and RSS hash key"
209 "clear port (info|stats|xstats|fdir|stat_qmap) (port_id|all)\n"
210 " Clear information for port_id, or all.\n\n"
212 "show (rxq|txq) info (port_id) (queue_id)\n"
213 " Display information for configured RX/TX queue.\n\n"
215 "show config (rxtx|cores|fwd|txpkts)\n"
216 " Display the given configuration.\n\n"
218 "read rxd (port_id) (queue_id) (rxd_id)\n"
219 " Display an RX descriptor of a port RX queue.\n\n"
221 "read txd (port_id) (queue_id) (txd_id)\n"
222 " Display a TX descriptor of a port TX queue.\n\n"
224 "ddp get list (port_id)\n"
225 " Get ddp profile info list\n\n"
227 "ddp get info (profile_path)\n"
228 " Get ddp profile information.\n\n"
230 "show vf stats (port_id) (vf_id)\n"
231 " Display a VF's statistics.\n\n"
233 "clear vf stats (port_id) (vf_id)\n"
234 " Reset a VF's statistics.\n\n"
236 "show port (port_id) pctype mapping\n"
237 " Get flow ptype to pctype mapping on a port\n\n"
239 "show port meter stats (port_id) (meter_id) (clear)\n"
240 " Get meter stats on a port\n\n"
241 "show port tm cap (port_id)\n"
242 " Display the port TM capability.\n\n"
244 "show port tm level cap (port_id) (level_id)\n"
245 " Display the port TM hierarchical level capability.\n\n"
247 "show port tm node cap (port_id) (node_id)\n"
248 " Display the port TM node capability.\n\n"
250 "show port tm node type (port_id) (node_id)\n"
251 " Display the port TM node type.\n\n"
253 "show port tm node stats (port_id) (node_id) (clear)\n"
254 " Display the port TM node stats.\n\n"
259 if (show_all || !strcmp(res->section, "config")) {
265 "Configuration changes only become active when"
266 " forwarding is started/restarted.\n\n"
269 " Reset forwarding to the default configuration.\n\n"
271 "set verbose (level)\n"
272 " Set the debug verbosity level X.\n\n"
275 " Set number of ports.\n\n"
278 " Set number of cores.\n\n"
280 "set coremask (mask)\n"
281 " Set the forwarding cores hexadecimal mask.\n\n"
283 "set portmask (mask)\n"
284 " Set the forwarding ports hexadecimal mask.\n\n"
287 " Set number of packets per burst.\n\n"
289 "set burst tx delay (microseconds) retry (num)\n"
290 " Set the transmit delay time and number of retries,"
291 " effective when retry is enabled.\n\n"
293 "set txpkts (x[,y]*)\n"
294 " Set the length of each segment of TXONLY"
295 " and optionally CSUM packets.\n\n"
297 "set txsplit (off|on|rand)\n"
298 " Set the split policy for the TX packets."
299 " Right now only applicable for CSUM and TXONLY"
302 "set corelist (x[,y]*)\n"
303 " Set the list of forwarding cores.\n\n"
305 "set portlist (x[,y]*)\n"
306 " Set the list of forwarding ports.\n\n"
308 "set tx loopback (port_id) (on|off)\n"
309 " Enable or disable tx loopback.\n\n"
311 "set all queues drop (port_id) (on|off)\n"
312 " Set drop enable bit for all queues.\n\n"
314 "set vf split drop (port_id) (vf_id) (on|off)\n"
315 " Set split drop enable bit for a VF from the PF.\n\n"
317 "set vf mac antispoof (port_id) (vf_id) (on|off).\n"
318 " Set MAC antispoof for a VF from the PF.\n\n"
320 "set macsec offload (port_id) on encrypt (on|off) replay-protect (on|off)\n"
321 " Enable MACsec offload.\n\n"
323 "set macsec offload (port_id) off\n"
324 " Disable MACsec offload.\n\n"
326 "set macsec sc (tx|rx) (port_id) (mac) (pi)\n"
327 " Configure MACsec secure connection (SC).\n\n"
329 "set macsec sa (tx|rx) (port_id) (idx) (an) (pn) (key)\n"
330 " Configure MACsec secure association (SA).\n\n"
332 "set vf broadcast (port_id) (vf_id) (on|off)\n"
333 " Set VF broadcast for a VF from the PF.\n\n"
335 "vlan set strip (on|off) (port_id)\n"
336 " Set the VLAN strip on a port.\n\n"
338 "vlan set stripq (on|off) (port_id,queue_id)\n"
339 " Set the VLAN strip for a queue on a port.\n\n"
341 "set vf vlan stripq (port_id) (vf_id) (on|off)\n"
342 " Set the VLAN strip for all queues in a pool for a VF from the PF.\n\n"
344 "set vf vlan insert (port_id) (vf_id) (vlan_id)\n"
345 " Set VLAN insert for a VF from the PF.\n\n"
347 "set vf vlan antispoof (port_id) (vf_id) (on|off)\n"
348 " Set VLAN antispoof for a VF from the PF.\n\n"
350 "set vf vlan tag (port_id) (vf_id) (on|off)\n"
351 " Set VLAN tag for a VF from the PF.\n\n"
353 "set vf tx max-bandwidth (port_id) (vf_id) (bandwidth)\n"
354 " Set a VF's max bandwidth(Mbps).\n\n"
356 "set vf tc tx min-bandwidth (port_id) (vf_id) (bw1, bw2, ...)\n"
357 " Set all TCs' min bandwidth(%%) on a VF.\n\n"
359 "set vf tc tx max-bandwidth (port_id) (vf_id) (tc_no) (bandwidth)\n"
360 " Set a TC's max bandwidth(Mbps) on a VF.\n\n"
362 "set tx strict-link-priority (port_id) (tc_bitmap)\n"
363 " Set some TCs' strict link priority mode on a physical port.\n\n"
365 "set tc tx min-bandwidth (port_id) (bw1, bw2, ...)\n"
366 " Set all TCs' min bandwidth(%%) for all PF and VFs.\n\n"
368 "vlan set filter (on|off) (port_id)\n"
369 " Set the VLAN filter on a port.\n\n"
371 "vlan set qinq (on|off) (port_id)\n"
372 " Set the VLAN QinQ (extended queue in queue)"
375 "vlan set (inner|outer) tpid (value) (port_id)\n"
376 " Set the VLAN TPID for Packet Filtering on"
379 "rx_vlan add (vlan_id|all) (port_id)\n"
380 " Add a vlan_id, or all identifiers, to the set"
381 " of VLAN identifiers filtered by port_id.\n\n"
383 "rx_vlan rm (vlan_id|all) (port_id)\n"
384 " Remove a vlan_id, or all identifiers, from the set"
385 " of VLAN identifiers filtered by port_id.\n\n"
387 "rx_vlan add (vlan_id) port (port_id) vf (vf_mask)\n"
388 " Add a vlan_id, to the set of VLAN identifiers"
389 "filtered for VF(s) from port_id.\n\n"
391 "rx_vlan rm (vlan_id) port (port_id) vf (vf_mask)\n"
392 " Remove a vlan_id, to the set of VLAN identifiers"
393 "filtered for VF(s) from port_id.\n\n"
395 "tunnel_filter add (port_id) (outer_mac) (inner_mac) (ip_addr) "
396 "(inner_vlan) (vxlan|nvgre|ipingre) (imac-ivlan|imac-ivlan-tenid|"
397 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n"
398 " add a tunnel filter of a port.\n\n"
400 "tunnel_filter rm (port_id) (outer_mac) (inner_mac) (ip_addr) "
401 "(inner_vlan) (vxlan|nvgre|ipingre) (imac-ivlan|imac-ivlan-tenid|"
402 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n"
403 " remove a tunnel filter of a port.\n\n"
405 "rx_vxlan_port add (udp_port) (port_id)\n"
406 " Add an UDP port for VXLAN packet filter on a port\n\n"
408 "rx_vxlan_port rm (udp_port) (port_id)\n"
409 " Remove an UDP port for VXLAN packet filter on a port\n\n"
411 "tx_vlan set (port_id) vlan_id[, vlan_id_outer]\n"
412 " Set hardware insertion of VLAN IDs (single or double VLAN "
413 "depends on the number of VLAN IDs) in packets sent on a port.\n\n"
415 "tx_vlan set pvid port_id vlan_id (on|off)\n"
416 " Set port based TX VLAN insertion.\n\n"
418 "tx_vlan reset (port_id)\n"
419 " Disable hardware insertion of a VLAN header in"
420 " packets sent on a port.\n\n"
422 "csum set (ip|udp|tcp|sctp|outer-ip) (hw|sw) (port_id)\n"
423 " Select hardware or software calculation of the"
424 " checksum when transmitting a packet using the"
425 " csum forward engine.\n"
426 " ip|udp|tcp|sctp always concern the inner layer.\n"
427 " outer-ip concerns the outer IP layer in"
428 " case the packet is recognized as a tunnel packet by"
429 " the forward engine (vxlan, gre and ipip are supported)\n"
430 " Please check the NIC datasheet for HW limits.\n\n"
432 "csum parse-tunnel (on|off) (tx_port_id)\n"
433 " If disabled, treat tunnel packets as non-tunneled"
434 " packets (treat inner headers as payload). The port\n"
435 " argument is the port used for TX in csum forward"
438 "csum show (port_id)\n"
439 " Display tx checksum offload configuration\n\n"
441 "tso set (segsize) (portid)\n"
442 " Enable TCP Segmentation Offload in csum forward"
444 " Please check the NIC datasheet for HW limits.\n\n"
447 " Display the status of TCP Segmentation Offload.\n\n"
449 "set port (port_id) gro on|off\n"
450 " Enable or disable Generic Receive Offload in"
451 " csum forwarding engine.\n\n"
453 "show port (port_id) gro\n"
454 " Display GRO configuration.\n\n"
456 "set gro flush (cycles)\n"
457 " Set the cycle to flush GROed packets from"
458 " reassembly tables.\n\n"
460 "set port (port_id) gso (on|off)"
461 " Enable or disable Generic Segmentation Offload in"
462 " csum forwarding engine.\n\n"
464 "set gso segsz (length)\n"
465 " Set max packet length for output GSO segments,"
466 " including packet header and payload.\n\n"
468 "show port (port_id) gso\n"
469 " Show GSO configuration.\n\n"
472 " Set packet forwarding mode.\n\n"
474 "mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n"
475 " Add a MAC address on port_id.\n\n"
477 "mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n"
478 " Remove a MAC address from port_id.\n\n"
480 "mac_addr set (port_id) (XX:XX:XX:XX:XX:XX)\n"
481 " Set the default MAC address for port_id.\n\n"
483 "mac_addr add port (port_id) vf (vf_id) (mac_address)\n"
484 " Add a MAC address for a VF on the port.\n\n"
486 "set vf mac addr (port_id) (vf_id) (XX:XX:XX:XX:XX:XX)\n"
487 " Set the MAC address for a VF from the PF.\n\n"
489 "set port (port_id) uta (mac_address|all) (on|off)\n"
490 " Add/Remove a or all unicast hash filter(s)"
493 "set promisc (port_id|all) (on|off)\n"
494 " Set the promiscuous mode on port_id, or all.\n\n"
496 "set allmulti (port_id|all) (on|off)\n"
497 " Set the allmulti mode on port_id, or all.\n\n"
499 "set vf promisc (port_id) (vf_id) (on|off)\n"
500 " Set unicast promiscuous mode for a VF from the PF.\n\n"
502 "set vf allmulti (port_id) (vf_id) (on|off)\n"
503 " Set multicast promiscuous mode for a VF from the PF.\n\n"
505 "set flow_ctrl rx (on|off) tx (on|off) (high_water)"
506 " (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd"
507 " (on|off) autoneg (on|off) (port_id)\n"
508 "set flow_ctrl rx (on|off) (portid)\n"
509 "set flow_ctrl tx (on|off) (portid)\n"
510 "set flow_ctrl high_water (high_water) (portid)\n"
511 "set flow_ctrl low_water (low_water) (portid)\n"
512 "set flow_ctrl pause_time (pause_time) (portid)\n"
513 "set flow_ctrl send_xon (send_xon) (portid)\n"
514 "set flow_ctrl mac_ctrl_frame_fwd (on|off) (portid)\n"
515 "set flow_ctrl autoneg (on|off) (port_id)\n"
516 " Set the link flow control parameter on a port.\n\n"
518 "set pfc_ctrl rx (on|off) tx (on|off) (high_water)"
519 " (low_water) (pause_time) (priority) (port_id)\n"
520 " Set the priority flow control parameter on a"
523 "set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n"
524 " Set statistics mapping (qmapping 0..15) for RX/TX"
526 " e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2"
527 " on port 0 to mapping 5.\n\n"
529 "set xstats-hide-zero on|off\n"
530 " Set the option to hide the zero values"
531 " for xstats display.\n"
533 "set port (port_id) vf (vf_id) rx|tx on|off\n"
534 " Enable/Disable a VF receive/tranmit from a port\n\n"
536 "set port (port_id) vf (vf_id) (mac_addr)"
537 " (exact-mac#exact-mac-vlan#hashmac|hashmac-vlan) on|off\n"
538 " Add/Remove unicast or multicast MAC addr filter"
541 "set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM"
543 " AUPE:accepts untagged VLAN;"
544 "ROPE:accept unicast hash\n\n"
545 " BAM:accepts broadcast packets;"
546 "MPE:accepts all multicast packets\n\n"
547 " Enable/Disable a VF receive mode of a port\n\n"
549 "set port (port_id) queue (queue_id) rate (rate_num)\n"
550 " Set rate limit for a queue of a port\n\n"
552 "set port (port_id) vf (vf_id) rate (rate_num) "
553 "queue_mask (queue_mask_value)\n"
554 " Set rate limit for queues in VF of a port\n\n"
556 "set port (port_id) mirror-rule (rule_id)"
557 " (pool-mirror-up|pool-mirror-down|vlan-mirror)"
558 " (poolmask|vlanid[,vlanid]*) dst-pool (pool_id) (on|off)\n"
559 " Set pool or vlan type mirror rule on a port.\n"
560 " e.g., 'set port 0 mirror-rule 0 vlan-mirror 0,1"
561 " dst-pool 0 on' enable mirror traffic with vlan 0,1"
564 "set port (port_id) mirror-rule (rule_id)"
565 " (uplink-mirror|downlink-mirror) dst-pool"
566 " (pool_id) (on|off)\n"
567 " Set uplink or downlink type mirror rule on a port.\n"
568 " e.g., 'set port 0 mirror-rule 0 uplink-mirror dst-pool"
569 " 0 on' enable mirror income traffic to pool 0.\n\n"
571 "reset port (port_id) mirror-rule (rule_id)\n"
572 " Reset a mirror rule.\n\n"
574 "set flush_rx (on|off)\n"
575 " Flush (default) or don't flush RX streams before"
576 " forwarding. Mainly used with PCAP drivers.\n\n"
578 "set bypass mode (normal|bypass|isolate) (port_id)\n"
579 " Set the bypass mode for the lowest port on bypass enabled"
582 "set bypass event (timeout|os_on|os_off|power_on|power_off) "
583 "mode (normal|bypass|isolate) (port_id)\n"
584 " Set the event required to initiate specified bypass mode for"
585 " the lowest port on a bypass enabled NIC where:\n"
586 " timeout = enable bypass after watchdog timeout.\n"
587 " os_on = enable bypass when OS/board is powered on.\n"
588 " os_off = enable bypass when OS/board is powered off.\n"
589 " power_on = enable bypass when power supply is turned on.\n"
590 " power_off = enable bypass when power supply is turned off."
593 "set bypass timeout (0|1.5|2|3|4|8|16|32)\n"
594 " Set the bypass watchdog timeout to 'n' seconds"
595 " where 0 = instant.\n\n"
597 "show bypass config (port_id)\n"
598 " Show the bypass configuration for a bypass enabled NIC"
599 " using the lowest port on the NIC.\n\n"
601 #ifdef RTE_LIBRTE_PMD_BOND
602 "create bonded device (mode) (socket)\n"
603 " Create a new bonded device with specific bonding mode and socket.\n\n"
605 "add bonding slave (slave_id) (port_id)\n"
606 " Add a slave device to a bonded device.\n\n"
608 "remove bonding slave (slave_id) (port_id)\n"
609 " Remove a slave device from a bonded device.\n\n"
611 "set bonding mode (value) (port_id)\n"
612 " Set the bonding mode on a bonded device.\n\n"
614 "set bonding primary (slave_id) (port_id)\n"
615 " Set the primary slave for a bonded device.\n\n"
617 "show bonding config (port_id)\n"
618 " Show the bonding config for port_id.\n\n"
620 "set bonding mac_addr (port_id) (address)\n"
621 " Set the MAC address of a bonded device.\n\n"
623 "set bonding mode IEEE802.3AD aggregator policy (port_id) (agg_name)"
624 " Set Aggregation mode for IEEE802.3AD (mode 4)"
626 "set bonding xmit_balance_policy (port_id) (l2|l23|l34)\n"
627 " Set the transmit balance policy for bonded device running in balance mode.\n\n"
629 "set bonding mon_period (port_id) (value)\n"
630 " Set the bonding link status monitoring polling period in ms.\n\n"
632 "set bonding lacp dedicated_queues <port_id> (enable|disable)\n"
633 " Enable/disable dedicated queues for LACP control traffic.\n\n"
636 "set link-up port (port_id)\n"
637 " Set link up for a port.\n\n"
639 "set link-down port (port_id)\n"
640 " Set link down for a port.\n\n"
642 "E-tag set insertion on port-tag-id (value)"
643 " port (port_id) vf (vf_id)\n"
644 " Enable E-tag insertion for a VF on a port\n\n"
646 "E-tag set insertion off port (port_id) vf (vf_id)\n"
647 " Disable E-tag insertion for a VF on a port\n\n"
649 "E-tag set stripping (on|off) port (port_id)\n"
650 " Enable/disable E-tag stripping on a port\n\n"
652 "E-tag set forwarding (on|off) port (port_id)\n"
653 " Enable/disable E-tag based forwarding"
656 "E-tag set filter add e-tag-id (value) dst-pool"
657 " (pool_id) port (port_id)\n"
658 " Add an E-tag forwarding filter on a port\n\n"
660 "E-tag set filter del e-tag-id (value) port (port_id)\n"
661 " Delete an E-tag forwarding filter on a port\n\n"
663 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
664 "set port tm hierarchy default (port_id)\n"
665 " Set default traffic Management hierarchy on a port\n\n"
668 "ddp add (port_id) (profile_path[,output_path])\n"
669 " Load a profile package on a port\n\n"
671 "ddp del (port_id) (profile_path)\n"
672 " Delete a profile package from a port\n\n"
674 "ptype mapping get (port_id) (valid_only)\n"
675 " Get ptype mapping on a port\n\n"
677 "ptype mapping replace (port_id) (target) (mask) (pky_type)\n"
678 " Replace target with the pkt_type in ptype mapping\n\n"
680 "ptype mapping reset (port_id)\n"
681 " Reset ptype mapping on a port\n\n"
683 "ptype mapping update (port_id) (hw_ptype) (sw_ptype)\n"
684 " Update a ptype mapping item on a port\n\n"
686 "set port (port_id) queue-region region_id (value) "
687 "queue_start_index (value) queue_num (value)\n"
688 " Set a queue region on a port\n\n"
690 "set port (port_id) queue-region region_id (value) "
692 " Set a flowtype region index on a port\n\n"
694 "set port (port_id) queue-region UP (value) region_id (value)\n"
695 " Set the mapping of User Priority to "
696 "queue region on a port\n\n"
698 "set port (port_id) queue-region flush (on|off)\n"
699 " flush all queue region related configuration\n\n"
701 "show port meter cap (port_id)\n"
702 " Show port meter capability information\n\n"
704 "add port meter profile srtcm_rfc2697 (port_id) (profile_id) (cir) (cbs) (ebs)\n"
705 " meter profile add - srtcm rfc 2697\n\n"
707 "add port meter profile trtcm_rfc2698 (port_id) (profile_id) (cir) (pir) (cbs) (pbs)\n"
708 " meter profile add - trtcm rfc 2698\n\n"
710 "add port meter profile trtcm_rfc4115 (port_id) (profile_id) (cir) (eir) (cbs) (ebs)\n"
711 " meter profile add - trtcm rfc 4115\n\n"
713 "del port meter profile (port_id) (profile_id)\n"
714 " meter profile delete\n\n"
716 "create port meter (port_id) (mtr_id) (profile_id) (meter_enable)\n"
717 "(g_action) (y_action) (r_action) (stats_mask) (shared)\n"
718 "(use_pre_meter_color) [(dscp_tbl_entry0) (dscp_tbl_entry1)...\n"
719 "(dscp_tbl_entry63)]\n"
722 "enable port meter (port_id) (mtr_id)\n"
725 "disable port meter (port_id) (mtr_id)\n"
728 "del port meter (port_id) (mtr_id)\n"
731 "set port meter profile (port_id) (mtr_id) (profile_id)\n"
732 " meter update meter profile\n\n"
734 "set port meter dscp table (port_id) (mtr_id) [(dscp_tbl_entry0)\n"
735 "(dscp_tbl_entry1)...(dscp_tbl_entry63)]\n"
736 " update meter dscp table entries\n\n"
738 "set port meter policer action (port_id) (mtr_id) (action_mask)\n"
739 "(action0) [(action1) (action2)]\n"
740 " meter update policer action\n\n"
742 "set port meter stats mask (port_id) (mtr_id) (stats_mask)\n"
743 " meter update stats\n\n"
745 "show port (port_id) queue-region\n"
746 " show all queue region related configuration info\n\n"
748 "add port tm node shaper profile (port_id) (shaper_profile_id)"
749 " (tb_rate) (tb_size) (packet_length_adjust)\n"
750 " Add port tm node private shaper profile.\n\n"
752 "del port tm node shaper profile (port_id) (shaper_profile_id)\n"
753 " Delete port tm node private shaper profile.\n\n"
755 "add port tm node shared shaper (port_id) (shared_shaper_id)"
756 " (shaper_profile_id)\n"
757 " Add/update port tm node shared shaper.\n\n"
759 "del port tm node shared shaper (port_id) (shared_shaper_id)\n"
760 " Delete port tm node shared shaper.\n\n"
762 "set port tm node shaper profile (port_id) (node_id)"
763 " (shaper_profile_id)\n"
764 " Set port tm node shaper profile.\n\n"
766 "add port tm node wred profile (port_id) (wred_profile_id)"
767 " (color_g) (min_th_g) (max_th_g) (maxp_inv_g) (wq_log2_g)"
768 " (color_y) (min_th_y) (max_th_y) (maxp_inv_y) (wq_log2_y)"
769 " (color_r) (min_th_r) (max_th_r) (maxp_inv_r) (wq_log2_r)\n"
770 " Add port tm node wred profile.\n\n"
772 "del port tm node wred profile (port_id) (wred_profile_id)\n"
773 " Delete port tm node wred profile.\n\n"
775 "add port tm nonleaf node (port_id) (node_id) (parent_node_id)"
776 " (priority) (weight) (level_id) (shaper_profile_id)"
777 " (n_sp_priorities) (stats_mask) (n_shared_shapers)"
778 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
779 " Add port tm nonleaf node.\n\n"
781 "add port tm leaf node (port_id) (node_id) (parent_node_id)"
782 " (priority) (weight) (level_id) (shaper_profile_id)"
783 " (cman_mode) (wred_profile_id) (stats_mask) (n_shared_shapers)"
784 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
785 " Add port tm leaf node.\n\n"
787 "del port tm node (port_id) (node_id)\n"
788 " Delete port tm node.\n\n"
790 "set port tm node parent (port_id) (node_id) (parent_node_id)"
791 " (priority) (weight)\n"
792 " Set port tm node parent.\n\n"
794 "port tm hierarchy commit (port_id) (clean_on_fail)\n"
795 " Commit tm hierarchy.\n\n"
797 , list_pkt_forwarding_modes()
801 if (show_all || !strcmp(res->section, "ports")) {
807 "----------------\n\n"
809 "port start (port_id|all)\n"
810 " Start all ports or port_id.\n\n"
812 "port stop (port_id|all)\n"
813 " Stop all ports or port_id.\n\n"
815 "port close (port_id|all)\n"
816 " Close all ports or port_id.\n\n"
818 "port attach (ident)\n"
819 " Attach physical or virtual dev by pci address or virtual device name\n\n"
821 "port detach (port_id)\n"
822 " Detach physical or virtual dev by port_id\n\n"
824 "port config (port_id|all)"
825 " speed (10|100|1000|10000|25000|40000|50000|100000|auto)"
826 " duplex (half|full|auto)\n"
827 " Set speed and duplex for all ports or port_id\n\n"
829 "port config all (rxq|txq|rxd|txd) (value)\n"
830 " Set number for rxq/txq/rxd/txd.\n\n"
832 "port config all max-pkt-len (value)\n"
833 " Set the max packet length.\n\n"
835 "port config all (crc-strip|scatter|rx-cksum|rx-timestamp|hw-vlan|hw-vlan-filter|"
836 "hw-vlan-strip|hw-vlan-extend|drop-en)"
838 " Set crc-strip/scatter/rx-checksum/hardware-vlan/drop_en"
841 "port config all rss (all|ip|tcp|udp|sctp|ether|port|vxlan|"
842 "geneve|nvgre|none|<flowtype_id>)\n"
843 " Set the RSS mode.\n\n"
845 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
846 " Set the RSS redirection table.\n\n"
848 "port config (port_id) dcb vt (on|off) (traffic_class)"
850 " Set the DCB mode.\n\n"
852 "port config all burst (value)\n"
853 " Set the number of packets per burst.\n\n"
855 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
857 " Set the ring prefetch/host/writeback threshold"
858 " for tx/rx queue.\n\n"
860 "port config all (txfreet|txrst|rxfreet) (value)\n"
861 " Set free threshold for rx/tx, or set"
862 " tx rs bit threshold.\n\n"
863 "port config mtu X value\n"
864 " Set the MTU of port X to a given value\n\n"
866 "port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
867 " Start/stop a rx/tx queue of port X. Only take effect"
868 " when port X is started\n\n"
870 "port config (port_id|all) l2-tunnel E-tag ether-type"
872 " Set the value of E-tag ether-type.\n\n"
874 "port config (port_id|all) l2-tunnel E-tag"
875 " (enable|disable)\n"
876 " Enable/disable the E-tag support.\n\n"
878 "port config (port_id) pctype mapping reset\n"
879 " Reset flow type to pctype mapping on a port\n\n"
881 "port config (port_id) pctype mapping update"
882 " (pctype_id_0[,pctype_id_1]*) (flow_type_id)\n"
883 " Update a flow type to pctype mapping item on a port\n\n"
887 if (show_all || !strcmp(res->section, "registers")) {
895 "read reg (port_id) (address)\n"
896 " Display value of a port register.\n\n"
898 "read regfield (port_id) (address) (bit_x) (bit_y)\n"
899 " Display a port register bit field.\n\n"
901 "read regbit (port_id) (address) (bit_x)\n"
902 " Display a single port register bit.\n\n"
904 "write reg (port_id) (address) (value)\n"
905 " Set value of a port register.\n\n"
907 "write regfield (port_id) (address) (bit_x) (bit_y)"
909 " Set bit field of a port register.\n\n"
911 "write regbit (port_id) (address) (bit_x) (value)\n"
912 " Set single bit value of a port register.\n\n"
915 if (show_all || !strcmp(res->section, "filters")) {
923 "ethertype_filter (port_id) (add|del)"
924 " (mac_addr|mac_ignr) (mac_address) ethertype"
925 " (ether_type) (drop|fwd) queue (queue_id)\n"
926 " Add/Del an ethertype filter.\n\n"
928 "2tuple_filter (port_id) (add|del)"
929 " dst_port (dst_port_value) protocol (protocol_value)"
930 " mask (mask_value) tcp_flags (tcp_flags_value)"
931 " priority (prio_value) queue (queue_id)\n"
932 " Add/Del a 2tuple filter.\n\n"
934 "5tuple_filter (port_id) (add|del)"
935 " dst_ip (dst_address) src_ip (src_address)"
936 " dst_port (dst_port_value) src_port (src_port_value)"
937 " protocol (protocol_value)"
938 " mask (mask_value) tcp_flags (tcp_flags_value)"
939 " priority (prio_value) queue (queue_id)\n"
940 " Add/Del a 5tuple filter.\n\n"
942 "syn_filter (port_id) (add|del) priority (high|low) queue (queue_id)"
943 " Add/Del syn filter.\n\n"
945 "flex_filter (port_id) (add|del) len (len_value)"
946 " bytes (bytes_value) mask (mask_value)"
947 " priority (prio_value) queue (queue_id)\n"
948 " Add/Del a flex filter.\n\n"
950 "flow_director_filter (port_id) mode IP (add|del|update)"
951 " flow (ipv4-other|ipv4-frag|ipv6-other|ipv6-frag)"
952 " src (src_ip_address) dst (dst_ip_address)"
953 " tos (tos_value) proto (proto_value) ttl (ttl_value)"
954 " vlan (vlan_value) flexbytes (flexbytes_value)"
955 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
956 " fd_id (fd_id_value)\n"
957 " Add/Del an IP type flow director filter.\n\n"
959 "flow_director_filter (port_id) mode IP (add|del|update)"
960 " flow (ipv4-tcp|ipv4-udp|ipv6-tcp|ipv6-udp)"
961 " src (src_ip_address) (src_port)"
962 " dst (dst_ip_address) (dst_port)"
963 " tos (tos_value) ttl (ttl_value)"
964 " vlan (vlan_value) flexbytes (flexbytes_value)"
965 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
966 " fd_id (fd_id_value)\n"
967 " Add/Del an UDP/TCP type flow director filter.\n\n"
969 "flow_director_filter (port_id) mode IP (add|del|update)"
970 " flow (ipv4-sctp|ipv6-sctp)"
971 " src (src_ip_address) (src_port)"
972 " dst (dst_ip_address) (dst_port)"
973 " tag (verification_tag) "
974 " tos (tos_value) ttl (ttl_value)"
976 " flexbytes (flexbytes_value) (drop|fwd)"
977 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
978 " Add/Del a SCTP type flow director filter.\n\n"
980 "flow_director_filter (port_id) mode IP (add|del|update)"
981 " flow l2_payload ether (ethertype)"
982 " flexbytes (flexbytes_value) (drop|fwd)"
983 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
984 " Add/Del a l2 payload type flow director filter.\n\n"
986 "flow_director_filter (port_id) mode MAC-VLAN (add|del|update)"
987 " mac (mac_address) vlan (vlan_value)"
988 " flexbytes (flexbytes_value) (drop|fwd)"
989 " queue (queue_id) fd_id (fd_id_value)\n"
990 " Add/Del a MAC-VLAN flow director filter.\n\n"
992 "flow_director_filter (port_id) mode Tunnel (add|del|update)"
993 " mac (mac_address) vlan (vlan_value)"
994 " tunnel (NVGRE|VxLAN) tunnel-id (tunnel_id_value)"
995 " flexbytes (flexbytes_value) (drop|fwd)"
996 " queue (queue_id) fd_id (fd_id_value)\n"
997 " Add/Del a Tunnel flow director filter.\n\n"
999 "flush_flow_director (port_id)\n"
1000 " Flush all flow director entries of a device.\n\n"
1002 "flow_director_mask (port_id) mode IP vlan (vlan_value)"
1003 " src_mask (ipv4_src) (ipv6_src) (src_port)"
1004 " dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n"
1005 " Set flow director IP mask.\n\n"
1007 "flow_director_mask (port_id) mode MAC-VLAN"
1008 " vlan (vlan_value)\n"
1009 " Set flow director MAC-VLAN mask.\n\n"
1011 "flow_director_mask (port_id) mode Tunnel"
1012 " vlan (vlan_value) mac (mac_value)"
1013 " tunnel-type (tunnel_type_value)"
1014 " tunnel-id (tunnel_id_value)\n"
1015 " Set flow director Tunnel mask.\n\n"
1017 "flow_director_flex_mask (port_id)"
1018 " flow (none|ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
1019 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|l2_payload|all)"
1021 " Configure mask of flex payload.\n\n"
1023 "flow_director_flex_payload (port_id)"
1024 " (raw|l2|l3|l4) (config)\n"
1025 " Configure flex payload selection.\n\n"
1027 "get_sym_hash_ena_per_port (port_id)\n"
1028 " get symmetric hash enable configuration per port.\n\n"
1030 "set_sym_hash_ena_per_port (port_id) (enable|disable)\n"
1031 " set symmetric hash enable configuration per port"
1032 " to enable or disable.\n\n"
1034 "get_hash_global_config (port_id)\n"
1035 " Get the global configurations of hash filters.\n\n"
1037 "set_hash_global_config (port_id) (toeplitz|simple_xor|default)"
1038 " (ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
1039 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload)"
1040 " (enable|disable)\n"
1041 " Set the global configurations of hash filters.\n\n"
1043 "set_hash_input_set (port_id) (ipv4|ipv4-frag|"
1044 "ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
1045 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1046 "l2_payload|<flowtype_id>) (ovlan|ivlan|src-ipv4|dst-ipv4|"
1047 "src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|ipv6-tc|"
1048 "ipv6-next-header|udp-src-port|udp-dst-port|"
1049 "tcp-src-port|tcp-dst-port|sctp-src-port|"
1050 "sctp-dst-port|sctp-veri-tag|udp-key|gre-key|fld-1st|"
1051 "fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|fld-7th|"
1052 "fld-8th|none) (select|add)\n"
1053 " Set the input set for hash.\n\n"
1055 "set_fdir_input_set (port_id) "
1056 "(ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
1057 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1058 "l2_payload) (ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|"
1059 "dst-ipv6|ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|"
1060 "ipv6-next-header|ipv6-hop-limits|udp-src-port|"
1061 "udp-dst-port|tcp-src-port|tcp-dst-port|"
1062 "sctp-src-port|sctp-dst-port|sctp-veri-tag|none)"
1064 " Set the input set for FDir.\n\n"
1066 "flow validate {port_id}"
1067 " [group {group_id}] [priority {level}]"
1068 " [ingress] [egress]"
1069 " pattern {item} [/ {item} [...]] / end"
1070 " actions {action} [/ {action} [...]] / end\n"
1071 " Check whether a flow rule can be created.\n\n"
1073 "flow create {port_id}"
1074 " [group {group_id}] [priority {level}]"
1075 " [ingress] [egress]"
1076 " pattern {item} [/ {item} [...]] / end"
1077 " actions {action} [/ {action} [...]] / end\n"
1078 " Create a flow rule.\n\n"
1080 "flow destroy {port_id} rule {rule_id} [...]\n"
1081 " Destroy specific flow rules.\n\n"
1083 "flow flush {port_id}\n"
1084 " Destroy all flow rules.\n\n"
1086 "flow query {port_id} {rule_id} {action}\n"
1087 " Query an existing flow rule.\n\n"
1089 "flow list {port_id} [group {group_id}] [...]\n"
1090 " List existing flow rules sorted by priority,"
1091 " filtered by group identifiers.\n\n"
1093 "flow isolate {port_id} {boolean}\n"
1094 " Restrict ingress traffic to the defined"
1100 cmdline_parse_token_string_t cmd_help_long_help =
1101 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
1103 cmdline_parse_token_string_t cmd_help_long_section =
1104 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
1105 "all#control#display#config#"
1106 "ports#registers#filters");
1108 cmdline_parse_inst_t cmd_help_long = {
1109 .f = cmd_help_long_parsed,
1111 .help_str = "help all|control|display|config|ports|register|filters: "
1114 (void *)&cmd_help_long_help,
1115 (void *)&cmd_help_long_section,
1121 /* *** start/stop/close all ports *** */
1122 struct cmd_operate_port_result {
1123 cmdline_fixed_string_t keyword;
1124 cmdline_fixed_string_t name;
1125 cmdline_fixed_string_t value;
1128 static void cmd_operate_port_parsed(void *parsed_result,
1129 __attribute__((unused)) struct cmdline *cl,
1130 __attribute__((unused)) void *data)
1132 struct cmd_operate_port_result *res = parsed_result;
1134 if (!strcmp(res->name, "start"))
1135 start_port(RTE_PORT_ALL);
1136 else if (!strcmp(res->name, "stop"))
1137 stop_port(RTE_PORT_ALL);
1138 else if (!strcmp(res->name, "close"))
1139 close_port(RTE_PORT_ALL);
1140 else if (!strcmp(res->name, "reset"))
1141 reset_port(RTE_PORT_ALL);
1143 printf("Unknown parameter\n");
1146 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
1147 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
1149 cmdline_parse_token_string_t cmd_operate_port_all_port =
1150 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
1151 "start#stop#close#reset");
1152 cmdline_parse_token_string_t cmd_operate_port_all_all =
1153 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
1155 cmdline_parse_inst_t cmd_operate_port = {
1156 .f = cmd_operate_port_parsed,
1158 .help_str = "port start|stop|close all: Start/Stop/Close/Reset all ports",
1160 (void *)&cmd_operate_port_all_cmd,
1161 (void *)&cmd_operate_port_all_port,
1162 (void *)&cmd_operate_port_all_all,
1167 /* *** start/stop/close specific port *** */
1168 struct cmd_operate_specific_port_result {
1169 cmdline_fixed_string_t keyword;
1170 cmdline_fixed_string_t name;
1174 static void cmd_operate_specific_port_parsed(void *parsed_result,
1175 __attribute__((unused)) struct cmdline *cl,
1176 __attribute__((unused)) void *data)
1178 struct cmd_operate_specific_port_result *res = parsed_result;
1180 if (!strcmp(res->name, "start"))
1181 start_port(res->value);
1182 else if (!strcmp(res->name, "stop"))
1183 stop_port(res->value);
1184 else if (!strcmp(res->name, "close"))
1185 close_port(res->value);
1186 else if (!strcmp(res->name, "reset"))
1187 reset_port(res->value);
1189 printf("Unknown parameter\n");
1192 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
1193 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1195 cmdline_parse_token_string_t cmd_operate_specific_port_port =
1196 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1197 name, "start#stop#close#reset");
1198 cmdline_parse_token_num_t cmd_operate_specific_port_id =
1199 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
1202 cmdline_parse_inst_t cmd_operate_specific_port = {
1203 .f = cmd_operate_specific_port_parsed,
1205 .help_str = "port start|stop|close <port_id>: Start/Stop/Close/Reset port_id",
1207 (void *)&cmd_operate_specific_port_cmd,
1208 (void *)&cmd_operate_specific_port_port,
1209 (void *)&cmd_operate_specific_port_id,
1214 /* *** attach a specified port *** */
1215 struct cmd_operate_attach_port_result {
1216 cmdline_fixed_string_t port;
1217 cmdline_fixed_string_t keyword;
1218 cmdline_fixed_string_t identifier;
1221 static void cmd_operate_attach_port_parsed(void *parsed_result,
1222 __attribute__((unused)) struct cmdline *cl,
1223 __attribute__((unused)) void *data)
1225 struct cmd_operate_attach_port_result *res = parsed_result;
1227 if (!strcmp(res->keyword, "attach"))
1228 attach_port(res->identifier);
1230 printf("Unknown parameter\n");
1233 cmdline_parse_token_string_t cmd_operate_attach_port_port =
1234 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1236 cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
1237 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1239 cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
1240 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1243 cmdline_parse_inst_t cmd_operate_attach_port = {
1244 .f = cmd_operate_attach_port_parsed,
1246 .help_str = "port attach <identifier>: "
1247 "(identifier: pci address or virtual dev name)",
1249 (void *)&cmd_operate_attach_port_port,
1250 (void *)&cmd_operate_attach_port_keyword,
1251 (void *)&cmd_operate_attach_port_identifier,
1256 /* *** detach a specified port *** */
1257 struct cmd_operate_detach_port_result {
1258 cmdline_fixed_string_t port;
1259 cmdline_fixed_string_t keyword;
1263 static void cmd_operate_detach_port_parsed(void *parsed_result,
1264 __attribute__((unused)) struct cmdline *cl,
1265 __attribute__((unused)) void *data)
1267 struct cmd_operate_detach_port_result *res = parsed_result;
1269 if (!strcmp(res->keyword, "detach"))
1270 detach_port(res->port_id);
1272 printf("Unknown parameter\n");
1275 cmdline_parse_token_string_t cmd_operate_detach_port_port =
1276 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1278 cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
1279 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1281 cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
1282 TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
1285 cmdline_parse_inst_t cmd_operate_detach_port = {
1286 .f = cmd_operate_detach_port_parsed,
1288 .help_str = "port detach <port_id>",
1290 (void *)&cmd_operate_detach_port_port,
1291 (void *)&cmd_operate_detach_port_keyword,
1292 (void *)&cmd_operate_detach_port_port_id,
1297 /* *** configure speed for all ports *** */
1298 struct cmd_config_speed_all {
1299 cmdline_fixed_string_t port;
1300 cmdline_fixed_string_t keyword;
1301 cmdline_fixed_string_t all;
1302 cmdline_fixed_string_t item1;
1303 cmdline_fixed_string_t item2;
1304 cmdline_fixed_string_t value1;
1305 cmdline_fixed_string_t value2;
1309 parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed)
1314 if (!strcmp(duplexstr, "half")) {
1315 duplex = ETH_LINK_HALF_DUPLEX;
1316 } else if (!strcmp(duplexstr, "full")) {
1317 duplex = ETH_LINK_FULL_DUPLEX;
1318 } else if (!strcmp(duplexstr, "auto")) {
1319 duplex = ETH_LINK_FULL_DUPLEX;
1321 printf("Unknown duplex parameter\n");
1325 if (!strcmp(speedstr, "10")) {
1326 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1327 ETH_LINK_SPEED_10M_HD : ETH_LINK_SPEED_10M;
1328 } else if (!strcmp(speedstr, "100")) {
1329 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1330 ETH_LINK_SPEED_100M_HD : ETH_LINK_SPEED_100M;
1332 if (duplex != ETH_LINK_FULL_DUPLEX) {
1333 printf("Invalid speed/duplex parameters\n");
1336 if (!strcmp(speedstr, "1000")) {
1337 *speed = ETH_LINK_SPEED_1G;
1338 } else if (!strcmp(speedstr, "10000")) {
1339 *speed = ETH_LINK_SPEED_10G;
1340 } else if (!strcmp(speedstr, "25000")) {
1341 *speed = ETH_LINK_SPEED_25G;
1342 } else if (!strcmp(speedstr, "40000")) {
1343 *speed = ETH_LINK_SPEED_40G;
1344 } else if (!strcmp(speedstr, "50000")) {
1345 *speed = ETH_LINK_SPEED_50G;
1346 } else if (!strcmp(speedstr, "100000")) {
1347 *speed = ETH_LINK_SPEED_100G;
1348 } else if (!strcmp(speedstr, "auto")) {
1349 *speed = ETH_LINK_SPEED_AUTONEG;
1351 printf("Unknown speed parameter\n");
1360 cmd_config_speed_all_parsed(void *parsed_result,
1361 __attribute__((unused)) struct cmdline *cl,
1362 __attribute__((unused)) void *data)
1364 struct cmd_config_speed_all *res = parsed_result;
1365 uint32_t link_speed;
1368 if (!all_ports_stopped()) {
1369 printf("Please stop all ports first\n");
1373 if (parse_and_check_speed_duplex(res->value1, res->value2,
1377 RTE_ETH_FOREACH_DEV(pid) {
1378 ports[pid].dev_conf.link_speeds = link_speed;
1381 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1384 cmdline_parse_token_string_t cmd_config_speed_all_port =
1385 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1386 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1387 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1389 cmdline_parse_token_string_t cmd_config_speed_all_all =
1390 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1391 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1392 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1393 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1394 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1395 "10#100#1000#10000#25000#40000#50000#100000#auto");
1396 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1397 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1398 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1399 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1402 cmdline_parse_inst_t cmd_config_speed_all = {
1403 .f = cmd_config_speed_all_parsed,
1405 .help_str = "port config all speed "
1406 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1409 (void *)&cmd_config_speed_all_port,
1410 (void *)&cmd_config_speed_all_keyword,
1411 (void *)&cmd_config_speed_all_all,
1412 (void *)&cmd_config_speed_all_item1,
1413 (void *)&cmd_config_speed_all_value1,
1414 (void *)&cmd_config_speed_all_item2,
1415 (void *)&cmd_config_speed_all_value2,
1420 /* *** configure speed for specific port *** */
1421 struct cmd_config_speed_specific {
1422 cmdline_fixed_string_t port;
1423 cmdline_fixed_string_t keyword;
1425 cmdline_fixed_string_t item1;
1426 cmdline_fixed_string_t item2;
1427 cmdline_fixed_string_t value1;
1428 cmdline_fixed_string_t value2;
1432 cmd_config_speed_specific_parsed(void *parsed_result,
1433 __attribute__((unused)) struct cmdline *cl,
1434 __attribute__((unused)) void *data)
1436 struct cmd_config_speed_specific *res = parsed_result;
1437 uint32_t link_speed;
1439 if (!all_ports_stopped()) {
1440 printf("Please stop all ports first\n");
1444 if (port_id_is_invalid(res->id, ENABLED_WARN))
1447 if (parse_and_check_speed_duplex(res->value1, res->value2,
1451 ports[res->id].dev_conf.link_speeds = link_speed;
1453 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1457 cmdline_parse_token_string_t cmd_config_speed_specific_port =
1458 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1460 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1461 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1463 cmdline_parse_token_num_t cmd_config_speed_specific_id =
1464 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT8);
1465 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1466 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1468 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1469 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1470 "10#100#1000#10000#25000#40000#50000#100000#auto");
1471 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1472 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1474 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1475 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1478 cmdline_parse_inst_t cmd_config_speed_specific = {
1479 .f = cmd_config_speed_specific_parsed,
1481 .help_str = "port config <port_id> speed "
1482 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1485 (void *)&cmd_config_speed_specific_port,
1486 (void *)&cmd_config_speed_specific_keyword,
1487 (void *)&cmd_config_speed_specific_id,
1488 (void *)&cmd_config_speed_specific_item1,
1489 (void *)&cmd_config_speed_specific_value1,
1490 (void *)&cmd_config_speed_specific_item2,
1491 (void *)&cmd_config_speed_specific_value2,
1496 /* *** configure txq/rxq, txd/rxd *** */
1497 struct cmd_config_rx_tx {
1498 cmdline_fixed_string_t port;
1499 cmdline_fixed_string_t keyword;
1500 cmdline_fixed_string_t all;
1501 cmdline_fixed_string_t name;
1506 cmd_config_rx_tx_parsed(void *parsed_result,
1507 __attribute__((unused)) struct cmdline *cl,
1508 __attribute__((unused)) void *data)
1510 struct cmd_config_rx_tx *res = parsed_result;
1512 if (!all_ports_stopped()) {
1513 printf("Please stop all ports first\n");
1516 if (!strcmp(res->name, "rxq")) {
1517 if (!res->value && !nb_txq) {
1518 printf("Warning: Either rx or tx queues should be non zero\n");
1521 nb_rxq = res->value;
1523 else if (!strcmp(res->name, "txq")) {
1524 if (!res->value && !nb_rxq) {
1525 printf("Warning: Either rx or tx queues should be non zero\n");
1528 nb_txq = res->value;
1530 else if (!strcmp(res->name, "rxd")) {
1531 if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) {
1532 printf("rxd %d invalid - must be > 0 && <= %d\n",
1533 res->value, RTE_TEST_RX_DESC_MAX);
1536 nb_rxd = res->value;
1537 } else if (!strcmp(res->name, "txd")) {
1538 if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) {
1539 printf("txd %d invalid - must be > 0 && <= %d\n",
1540 res->value, RTE_TEST_TX_DESC_MAX);
1543 nb_txd = res->value;
1545 printf("Unknown parameter\n");
1553 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1556 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1557 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1558 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1559 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1560 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1561 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1562 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1563 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1565 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1566 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
1568 cmdline_parse_inst_t cmd_config_rx_tx = {
1569 .f = cmd_config_rx_tx_parsed,
1571 .help_str = "port config all rxq|txq|rxd|txd <value>",
1573 (void *)&cmd_config_rx_tx_port,
1574 (void *)&cmd_config_rx_tx_keyword,
1575 (void *)&cmd_config_rx_tx_all,
1576 (void *)&cmd_config_rx_tx_name,
1577 (void *)&cmd_config_rx_tx_value,
1582 /* *** config max packet length *** */
1583 struct cmd_config_max_pkt_len_result {
1584 cmdline_fixed_string_t port;
1585 cmdline_fixed_string_t keyword;
1586 cmdline_fixed_string_t all;
1587 cmdline_fixed_string_t name;
1592 cmd_config_max_pkt_len_parsed(void *parsed_result,
1593 __attribute__((unused)) struct cmdline *cl,
1594 __attribute__((unused)) void *data)
1596 struct cmd_config_max_pkt_len_result *res = parsed_result;
1597 uint64_t rx_offloads = rx_mode.offloads;
1599 if (!all_ports_stopped()) {
1600 printf("Please stop all ports first\n");
1604 if (!strcmp(res->name, "max-pkt-len")) {
1605 if (res->value < ETHER_MIN_LEN) {
1606 printf("max-pkt-len can not be less than %d\n",
1610 if (res->value == rx_mode.max_rx_pkt_len)
1613 rx_mode.max_rx_pkt_len = res->value;
1614 if (res->value > ETHER_MAX_LEN)
1615 rx_offloads |= DEV_RX_OFFLOAD_JUMBO_FRAME;
1617 rx_offloads &= ~DEV_RX_OFFLOAD_JUMBO_FRAME;
1619 printf("Unknown parameter\n");
1623 rx_mode.offloads = rx_offloads;
1627 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1630 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
1631 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
1633 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
1634 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
1636 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
1637 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
1639 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
1640 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
1642 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1643 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1646 cmdline_parse_inst_t cmd_config_max_pkt_len = {
1647 .f = cmd_config_max_pkt_len_parsed,
1649 .help_str = "port config all max-pkt-len <value>",
1651 (void *)&cmd_config_max_pkt_len_port,
1652 (void *)&cmd_config_max_pkt_len_keyword,
1653 (void *)&cmd_config_max_pkt_len_all,
1654 (void *)&cmd_config_max_pkt_len_name,
1655 (void *)&cmd_config_max_pkt_len_value,
1660 /* *** configure port MTU *** */
1661 struct cmd_config_mtu_result {
1662 cmdline_fixed_string_t port;
1663 cmdline_fixed_string_t keyword;
1664 cmdline_fixed_string_t mtu;
1670 cmd_config_mtu_parsed(void *parsed_result,
1671 __attribute__((unused)) struct cmdline *cl,
1672 __attribute__((unused)) void *data)
1674 struct cmd_config_mtu_result *res = parsed_result;
1676 if (res->value < ETHER_MIN_LEN) {
1677 printf("mtu cannot be less than %d\n", ETHER_MIN_LEN);
1680 port_mtu_set(res->port_id, res->value);
1683 cmdline_parse_token_string_t cmd_config_mtu_port =
1684 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
1686 cmdline_parse_token_string_t cmd_config_mtu_keyword =
1687 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1689 cmdline_parse_token_string_t cmd_config_mtu_mtu =
1690 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1692 cmdline_parse_token_num_t cmd_config_mtu_port_id =
1693 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT16);
1694 cmdline_parse_token_num_t cmd_config_mtu_value =
1695 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
1697 cmdline_parse_inst_t cmd_config_mtu = {
1698 .f = cmd_config_mtu_parsed,
1700 .help_str = "port config mtu <port_id> <value>",
1702 (void *)&cmd_config_mtu_port,
1703 (void *)&cmd_config_mtu_keyword,
1704 (void *)&cmd_config_mtu_mtu,
1705 (void *)&cmd_config_mtu_port_id,
1706 (void *)&cmd_config_mtu_value,
1711 /* *** configure rx mode *** */
1712 struct cmd_config_rx_mode_flag {
1713 cmdline_fixed_string_t port;
1714 cmdline_fixed_string_t keyword;
1715 cmdline_fixed_string_t all;
1716 cmdline_fixed_string_t name;
1717 cmdline_fixed_string_t value;
1721 cmd_config_rx_mode_flag_parsed(void *parsed_result,
1722 __attribute__((unused)) struct cmdline *cl,
1723 __attribute__((unused)) void *data)
1725 struct cmd_config_rx_mode_flag *res = parsed_result;
1726 uint64_t rx_offloads = rx_mode.offloads;
1728 if (!all_ports_stopped()) {
1729 printf("Please stop all ports first\n");
1733 if (!strcmp(res->name, "crc-strip")) {
1734 if (!strcmp(res->value, "on"))
1735 rx_offloads |= DEV_RX_OFFLOAD_CRC_STRIP;
1736 else if (!strcmp(res->value, "off"))
1737 rx_offloads &= ~DEV_RX_OFFLOAD_CRC_STRIP;
1739 printf("Unknown parameter\n");
1742 } else if (!strcmp(res->name, "scatter")) {
1743 if (!strcmp(res->value, "on")) {
1744 rx_offloads |= DEV_RX_OFFLOAD_SCATTER;
1745 } else if (!strcmp(res->value, "off")) {
1746 rx_offloads &= ~DEV_RX_OFFLOAD_SCATTER;
1748 printf("Unknown parameter\n");
1751 } else if (!strcmp(res->name, "rx-cksum")) {
1752 if (!strcmp(res->value, "on"))
1753 rx_offloads |= DEV_RX_OFFLOAD_CHECKSUM;
1754 else if (!strcmp(res->value, "off"))
1755 rx_offloads &= ~DEV_RX_OFFLOAD_CHECKSUM;
1757 printf("Unknown parameter\n");
1760 } else if (!strcmp(res->name, "rx-timestamp")) {
1761 if (!strcmp(res->value, "on"))
1762 rx_offloads |= DEV_RX_OFFLOAD_TIMESTAMP;
1763 else if (!strcmp(res->value, "off"))
1764 rx_offloads &= ~DEV_RX_OFFLOAD_TIMESTAMP;
1766 printf("Unknown parameter\n");
1769 } else if (!strcmp(res->name, "hw-vlan")) {
1770 if (!strcmp(res->value, "on")) {
1771 rx_offloads |= (DEV_RX_OFFLOAD_VLAN_FILTER |
1772 DEV_RX_OFFLOAD_VLAN_STRIP);
1774 else if (!strcmp(res->value, "off")) {
1775 rx_offloads &= ~(DEV_RX_OFFLOAD_VLAN_FILTER |
1776 DEV_RX_OFFLOAD_VLAN_STRIP);
1779 printf("Unknown parameter\n");
1782 } else if (!strcmp(res->name, "hw-vlan-filter")) {
1783 if (!strcmp(res->value, "on"))
1784 rx_offloads |= DEV_RX_OFFLOAD_VLAN_FILTER;
1785 else if (!strcmp(res->value, "off"))
1786 rx_offloads &= ~DEV_RX_OFFLOAD_VLAN_FILTER;
1788 printf("Unknown parameter\n");
1791 } else if (!strcmp(res->name, "hw-vlan-strip")) {
1792 if (!strcmp(res->value, "on"))
1793 rx_offloads |= DEV_RX_OFFLOAD_VLAN_STRIP;
1794 else if (!strcmp(res->value, "off"))
1795 rx_offloads &= ~DEV_RX_OFFLOAD_VLAN_STRIP;
1797 printf("Unknown parameter\n");
1800 } else if (!strcmp(res->name, "hw-vlan-extend")) {
1801 if (!strcmp(res->value, "on"))
1802 rx_offloads |= DEV_RX_OFFLOAD_VLAN_EXTEND;
1803 else if (!strcmp(res->value, "off"))
1804 rx_offloads &= ~DEV_RX_OFFLOAD_VLAN_EXTEND;
1806 printf("Unknown parameter\n");
1809 } else if (!strcmp(res->name, "drop-en")) {
1810 if (!strcmp(res->value, "on"))
1812 else if (!strcmp(res->value, "off"))
1815 printf("Unknown parameter\n");
1819 printf("Unknown parameter\n");
1822 rx_mode.offloads = rx_offloads;
1826 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1829 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
1830 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
1831 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
1832 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
1834 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
1835 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
1836 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
1837 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
1838 "crc-strip#scatter#rx-cksum#rx-timestamp#hw-vlan#"
1839 "hw-vlan-filter#hw-vlan-strip#hw-vlan-extend");
1840 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
1841 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
1844 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
1845 .f = cmd_config_rx_mode_flag_parsed,
1847 .help_str = "port config all crc-strip|scatter|rx-cksum|rx-timestamp|hw-vlan|"
1848 "hw-vlan-filter|hw-vlan-strip|hw-vlan-extend on|off",
1850 (void *)&cmd_config_rx_mode_flag_port,
1851 (void *)&cmd_config_rx_mode_flag_keyword,
1852 (void *)&cmd_config_rx_mode_flag_all,
1853 (void *)&cmd_config_rx_mode_flag_name,
1854 (void *)&cmd_config_rx_mode_flag_value,
1859 /* *** configure rss *** */
1860 struct cmd_config_rss {
1861 cmdline_fixed_string_t port;
1862 cmdline_fixed_string_t keyword;
1863 cmdline_fixed_string_t all;
1864 cmdline_fixed_string_t name;
1865 cmdline_fixed_string_t value;
1869 cmd_config_rss_parsed(void *parsed_result,
1870 __attribute__((unused)) struct cmdline *cl,
1871 __attribute__((unused)) void *data)
1873 struct cmd_config_rss *res = parsed_result;
1874 struct rte_eth_rss_conf rss_conf = { .rss_key_len = 0, };
1878 if (!strcmp(res->value, "all"))
1879 rss_conf.rss_hf = ETH_RSS_IP | ETH_RSS_TCP |
1880 ETH_RSS_UDP | ETH_RSS_SCTP |
1882 else if (!strcmp(res->value, "ip"))
1883 rss_conf.rss_hf = ETH_RSS_IP;
1884 else if (!strcmp(res->value, "udp"))
1885 rss_conf.rss_hf = ETH_RSS_UDP;
1886 else if (!strcmp(res->value, "tcp"))
1887 rss_conf.rss_hf = ETH_RSS_TCP;
1888 else if (!strcmp(res->value, "sctp"))
1889 rss_conf.rss_hf = ETH_RSS_SCTP;
1890 else if (!strcmp(res->value, "ether"))
1891 rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD;
1892 else if (!strcmp(res->value, "port"))
1893 rss_conf.rss_hf = ETH_RSS_PORT;
1894 else if (!strcmp(res->value, "vxlan"))
1895 rss_conf.rss_hf = ETH_RSS_VXLAN;
1896 else if (!strcmp(res->value, "geneve"))
1897 rss_conf.rss_hf = ETH_RSS_GENEVE;
1898 else if (!strcmp(res->value, "nvgre"))
1899 rss_conf.rss_hf = ETH_RSS_NVGRE;
1900 else if (!strcmp(res->value, "none"))
1901 rss_conf.rss_hf = 0;
1902 else if (isdigit(res->value[0]) && atoi(res->value) > 0 &&
1903 atoi(res->value) < 64)
1904 rss_conf.rss_hf = 1ULL << atoi(res->value);
1906 printf("Unknown parameter\n");
1909 rss_conf.rss_key = NULL;
1910 for (i = 0; i < rte_eth_dev_count(); i++) {
1911 diag = rte_eth_dev_rss_hash_update(i, &rss_conf);
1913 printf("Configuration of RSS hash at ethernet port %d "
1914 "failed with error (%d): %s.\n",
1915 i, -diag, strerror(-diag));
1919 cmdline_parse_token_string_t cmd_config_rss_port =
1920 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
1921 cmdline_parse_token_string_t cmd_config_rss_keyword =
1922 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
1923 cmdline_parse_token_string_t cmd_config_rss_all =
1924 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
1925 cmdline_parse_token_string_t cmd_config_rss_name =
1926 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
1927 cmdline_parse_token_string_t cmd_config_rss_value =
1928 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, NULL);
1930 cmdline_parse_inst_t cmd_config_rss = {
1931 .f = cmd_config_rss_parsed,
1933 .help_str = "port config all rss "
1934 "all|ip|tcp|udp|sctp|ether|port|vxlan|geneve|nvgre|none|<flowtype_id>",
1936 (void *)&cmd_config_rss_port,
1937 (void *)&cmd_config_rss_keyword,
1938 (void *)&cmd_config_rss_all,
1939 (void *)&cmd_config_rss_name,
1940 (void *)&cmd_config_rss_value,
1945 /* *** configure rss hash key *** */
1946 struct cmd_config_rss_hash_key {
1947 cmdline_fixed_string_t port;
1948 cmdline_fixed_string_t config;
1950 cmdline_fixed_string_t rss_hash_key;
1951 cmdline_fixed_string_t rss_type;
1952 cmdline_fixed_string_t key;
1956 hexa_digit_to_value(char hexa_digit)
1958 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
1959 return (uint8_t) (hexa_digit - '0');
1960 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
1961 return (uint8_t) ((hexa_digit - 'a') + 10);
1962 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
1963 return (uint8_t) ((hexa_digit - 'A') + 10);
1964 /* Invalid hexa digit */
1969 parse_and_check_key_hexa_digit(char *key, int idx)
1973 hexa_v = hexa_digit_to_value(key[idx]);
1975 printf("invalid key: character %c at position %d is not a "
1976 "valid hexa digit\n", key[idx], idx);
1981 cmd_config_rss_hash_key_parsed(void *parsed_result,
1982 __attribute__((unused)) struct cmdline *cl,
1983 __attribute__((unused)) void *data)
1985 struct cmd_config_rss_hash_key *res = parsed_result;
1986 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
1990 struct rte_eth_dev_info dev_info;
1991 uint8_t hash_key_size;
1994 memset(&dev_info, 0, sizeof(dev_info));
1995 rte_eth_dev_info_get(res->port_id, &dev_info);
1996 if (dev_info.hash_key_size > 0 &&
1997 dev_info.hash_key_size <= sizeof(hash_key))
1998 hash_key_size = dev_info.hash_key_size;
2000 printf("dev_info did not provide a valid hash key size\n");
2003 /* Check the length of the RSS hash key */
2004 key_len = strlen(res->key);
2005 if (key_len != (hash_key_size * 2)) {
2006 printf("key length: %d invalid - key must be a string of %d"
2007 " hexa-decimal numbers\n",
2008 (int) key_len, hash_key_size * 2);
2011 /* Translate RSS hash key into binary representation */
2012 for (i = 0; i < hash_key_size; i++) {
2013 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
2016 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
2019 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
2021 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
2025 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
2026 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
2027 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
2028 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
2030 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
2031 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT16);
2032 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
2033 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
2034 rss_hash_key, "rss-hash-key");
2035 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
2036 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
2037 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2038 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2039 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2040 "ipv6-tcp-ex#ipv6-udp-ex");
2041 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
2042 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
2044 cmdline_parse_inst_t cmd_config_rss_hash_key = {
2045 .f = cmd_config_rss_hash_key_parsed,
2047 .help_str = "port config <port_id> rss-hash-key "
2048 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2049 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2050 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex "
2051 "<string of hex digits (variable length, NIC dependent)>",
2053 (void *)&cmd_config_rss_hash_key_port,
2054 (void *)&cmd_config_rss_hash_key_config,
2055 (void *)&cmd_config_rss_hash_key_port_id,
2056 (void *)&cmd_config_rss_hash_key_rss_hash_key,
2057 (void *)&cmd_config_rss_hash_key_rss_type,
2058 (void *)&cmd_config_rss_hash_key_value,
2063 /* *** configure port rxq/txq start/stop *** */
2064 struct cmd_config_rxtx_queue {
2065 cmdline_fixed_string_t port;
2067 cmdline_fixed_string_t rxtxq;
2069 cmdline_fixed_string_t opname;
2073 cmd_config_rxtx_queue_parsed(void *parsed_result,
2074 __attribute__((unused)) struct cmdline *cl,
2075 __attribute__((unused)) void *data)
2077 struct cmd_config_rxtx_queue *res = parsed_result;
2082 if (test_done == 0) {
2083 printf("Please stop forwarding first\n");
2087 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2090 if (port_is_started(res->portid) != 1) {
2091 printf("Please start port %u first\n", res->portid);
2095 if (!strcmp(res->rxtxq, "rxq"))
2097 else if (!strcmp(res->rxtxq, "txq"))
2100 printf("Unknown parameter\n");
2104 if (isrx && rx_queue_id_is_invalid(res->qid))
2106 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2109 if (!strcmp(res->opname, "start"))
2111 else if (!strcmp(res->opname, "stop"))
2114 printf("Unknown parameter\n");
2118 if (isstart && isrx)
2119 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
2120 else if (!isstart && isrx)
2121 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
2122 else if (isstart && !isrx)
2123 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
2125 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
2127 if (ret == -ENOTSUP)
2128 printf("Function not supported in PMD driver\n");
2131 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
2132 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
2133 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
2134 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT16);
2135 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
2136 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
2137 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
2138 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
2139 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
2140 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
2143 cmdline_parse_inst_t cmd_config_rxtx_queue = {
2144 .f = cmd_config_rxtx_queue_parsed,
2146 .help_str = "port <port_id> rxq|txq <queue_id> start|stop",
2148 (void *)&cmd_config_speed_all_port,
2149 (void *)&cmd_config_rxtx_queue_portid,
2150 (void *)&cmd_config_rxtx_queue_rxtxq,
2151 (void *)&cmd_config_rxtx_queue_qid,
2152 (void *)&cmd_config_rxtx_queue_opname,
2157 /* *** Configure RSS RETA *** */
2158 struct cmd_config_rss_reta {
2159 cmdline_fixed_string_t port;
2160 cmdline_fixed_string_t keyword;
2162 cmdline_fixed_string_t name;
2163 cmdline_fixed_string_t list_name;
2164 cmdline_fixed_string_t list_of_items;
2168 parse_reta_config(const char *str,
2169 struct rte_eth_rss_reta_entry64 *reta_conf,
2170 uint16_t nb_entries)
2174 uint16_t hash_index, idx, shift;
2177 const char *p, *p0 = str;
2184 unsigned long int_fld[_NUM_FLD];
2185 char *str_fld[_NUM_FLD];
2187 while ((p = strchr(p0,'(')) != NULL) {
2189 if((p0 = strchr(p,')')) == NULL)
2193 if(size >= sizeof(s))
2196 snprintf(s, sizeof(s), "%.*s", size, p);
2197 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
2199 for (i = 0; i < _NUM_FLD; i++) {
2201 int_fld[i] = strtoul(str_fld[i], &end, 0);
2202 if (errno != 0 || end == str_fld[i] ||
2207 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
2208 nb_queue = (uint16_t)int_fld[FLD_QUEUE];
2210 if (hash_index >= nb_entries) {
2211 printf("Invalid RETA hash index=%d\n", hash_index);
2215 idx = hash_index / RTE_RETA_GROUP_SIZE;
2216 shift = hash_index % RTE_RETA_GROUP_SIZE;
2217 reta_conf[idx].mask |= (1ULL << shift);
2218 reta_conf[idx].reta[shift] = nb_queue;
2225 cmd_set_rss_reta_parsed(void *parsed_result,
2226 __attribute__((unused)) struct cmdline *cl,
2227 __attribute__((unused)) void *data)
2230 struct rte_eth_dev_info dev_info;
2231 struct rte_eth_rss_reta_entry64 reta_conf[8];
2232 struct cmd_config_rss_reta *res = parsed_result;
2234 memset(&dev_info, 0, sizeof(dev_info));
2235 rte_eth_dev_info_get(res->port_id, &dev_info);
2236 if (dev_info.reta_size == 0) {
2237 printf("Redirection table size is 0 which is "
2238 "invalid for RSS\n");
2241 printf("The reta size of port %d is %u\n",
2242 res->port_id, dev_info.reta_size);
2243 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
2244 printf("Currently do not support more than %u entries of "
2245 "redirection table\n", ETH_RSS_RETA_SIZE_512);
2249 memset(reta_conf, 0, sizeof(reta_conf));
2250 if (!strcmp(res->list_name, "reta")) {
2251 if (parse_reta_config(res->list_of_items, reta_conf,
2252 dev_info.reta_size)) {
2253 printf("Invalid RSS Redirection Table "
2254 "config entered\n");
2257 ret = rte_eth_dev_rss_reta_update(res->port_id,
2258 reta_conf, dev_info.reta_size);
2260 printf("Bad redirection table parameter, "
2261 "return code = %d \n", ret);
2265 cmdline_parse_token_string_t cmd_config_rss_reta_port =
2266 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
2267 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
2268 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
2269 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
2270 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT16);
2271 cmdline_parse_token_string_t cmd_config_rss_reta_name =
2272 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
2273 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
2274 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
2275 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
2276 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
2278 cmdline_parse_inst_t cmd_config_rss_reta = {
2279 .f = cmd_set_rss_reta_parsed,
2281 .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
2283 (void *)&cmd_config_rss_reta_port,
2284 (void *)&cmd_config_rss_reta_keyword,
2285 (void *)&cmd_config_rss_reta_port_id,
2286 (void *)&cmd_config_rss_reta_name,
2287 (void *)&cmd_config_rss_reta_list_name,
2288 (void *)&cmd_config_rss_reta_list_of_items,
2293 /* *** SHOW PORT RETA INFO *** */
2294 struct cmd_showport_reta {
2295 cmdline_fixed_string_t show;
2296 cmdline_fixed_string_t port;
2298 cmdline_fixed_string_t rss;
2299 cmdline_fixed_string_t reta;
2301 cmdline_fixed_string_t list_of_items;
2305 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
2306 uint16_t nb_entries,
2310 const char *p, *p0 = str;
2315 uint16_t num = (nb_entries + RTE_RETA_GROUP_SIZE - 1) /
2316 RTE_RETA_GROUP_SIZE;
2319 p = strchr(p0, '(');
2323 p0 = strchr(p, ')');
2327 if (size >= sizeof(s)) {
2328 printf("The string size exceeds the internal buffer size\n");
2331 snprintf(s, sizeof(s), "%.*s", size, p);
2332 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
2333 if (ret <= 0 || ret != num) {
2334 printf("The bits of masks do not match the number of "
2335 "reta entries: %u\n", num);
2338 for (i = 0; i < ret; i++)
2339 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
2345 cmd_showport_reta_parsed(void *parsed_result,
2346 __attribute__((unused)) struct cmdline *cl,
2347 __attribute__((unused)) void *data)
2349 struct cmd_showport_reta *res = parsed_result;
2350 struct rte_eth_rss_reta_entry64 reta_conf[8];
2351 struct rte_eth_dev_info dev_info;
2352 uint16_t max_reta_size;
2354 memset(&dev_info, 0, sizeof(dev_info));
2355 rte_eth_dev_info_get(res->port_id, &dev_info);
2356 max_reta_size = RTE_MIN(dev_info.reta_size, ETH_RSS_RETA_SIZE_512);
2357 if (res->size == 0 || res->size > max_reta_size) {
2358 printf("Invalid redirection table size: %u (1-%u)\n",
2359 res->size, max_reta_size);
2363 memset(reta_conf, 0, sizeof(reta_conf));
2364 if (showport_parse_reta_config(reta_conf, res->size,
2365 res->list_of_items) < 0) {
2366 printf("Invalid string: %s for reta masks\n",
2367 res->list_of_items);
2370 port_rss_reta_info(res->port_id, reta_conf, res->size);
2373 cmdline_parse_token_string_t cmd_showport_reta_show =
2374 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
2375 cmdline_parse_token_string_t cmd_showport_reta_port =
2376 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
2377 cmdline_parse_token_num_t cmd_showport_reta_port_id =
2378 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT16);
2379 cmdline_parse_token_string_t cmd_showport_reta_rss =
2380 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
2381 cmdline_parse_token_string_t cmd_showport_reta_reta =
2382 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
2383 cmdline_parse_token_num_t cmd_showport_reta_size =
2384 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16);
2385 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
2386 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
2387 list_of_items, NULL);
2389 cmdline_parse_inst_t cmd_showport_reta = {
2390 .f = cmd_showport_reta_parsed,
2392 .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
2394 (void *)&cmd_showport_reta_show,
2395 (void *)&cmd_showport_reta_port,
2396 (void *)&cmd_showport_reta_port_id,
2397 (void *)&cmd_showport_reta_rss,
2398 (void *)&cmd_showport_reta_reta,
2399 (void *)&cmd_showport_reta_size,
2400 (void *)&cmd_showport_reta_list_of_items,
2405 /* *** Show RSS hash configuration *** */
2406 struct cmd_showport_rss_hash {
2407 cmdline_fixed_string_t show;
2408 cmdline_fixed_string_t port;
2410 cmdline_fixed_string_t rss_hash;
2411 cmdline_fixed_string_t rss_type;
2412 cmdline_fixed_string_t key; /* optional argument */
2415 static void cmd_showport_rss_hash_parsed(void *parsed_result,
2416 __attribute__((unused)) struct cmdline *cl,
2419 struct cmd_showport_rss_hash *res = parsed_result;
2421 port_rss_hash_conf_show(res->port_id, res->rss_type,
2422 show_rss_key != NULL);
2425 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
2426 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
2427 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
2428 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
2429 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
2430 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT16);
2431 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
2432 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
2434 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash_info =
2435 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_type,
2436 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2437 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2438 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2439 "ipv6-tcp-ex#ipv6-udp-ex");
2440 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
2441 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
2443 cmdline_parse_inst_t cmd_showport_rss_hash = {
2444 .f = cmd_showport_rss_hash_parsed,
2446 .help_str = "show port <port_id> rss-hash "
2447 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2448 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2449 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex",
2451 (void *)&cmd_showport_rss_hash_show,
2452 (void *)&cmd_showport_rss_hash_port,
2453 (void *)&cmd_showport_rss_hash_port_id,
2454 (void *)&cmd_showport_rss_hash_rss_hash,
2455 (void *)&cmd_showport_rss_hash_rss_hash_info,
2460 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
2461 .f = cmd_showport_rss_hash_parsed,
2463 .help_str = "show port <port_id> rss-hash "
2464 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2465 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2466 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex key",
2468 (void *)&cmd_showport_rss_hash_show,
2469 (void *)&cmd_showport_rss_hash_port,
2470 (void *)&cmd_showport_rss_hash_port_id,
2471 (void *)&cmd_showport_rss_hash_rss_hash,
2472 (void *)&cmd_showport_rss_hash_rss_hash_info,
2473 (void *)&cmd_showport_rss_hash_rss_key,
2478 /* *** Configure DCB *** */
2479 struct cmd_config_dcb {
2480 cmdline_fixed_string_t port;
2481 cmdline_fixed_string_t config;
2483 cmdline_fixed_string_t dcb;
2484 cmdline_fixed_string_t vt;
2485 cmdline_fixed_string_t vt_en;
2487 cmdline_fixed_string_t pfc;
2488 cmdline_fixed_string_t pfc_en;
2492 cmd_config_dcb_parsed(void *parsed_result,
2493 __attribute__((unused)) struct cmdline *cl,
2494 __attribute__((unused)) void *data)
2496 struct cmd_config_dcb *res = parsed_result;
2497 portid_t port_id = res->port_id;
2498 struct rte_port *port;
2502 port = &ports[port_id];
2503 /** Check if the port is not started **/
2504 if (port->port_status != RTE_PORT_STOPPED) {
2505 printf("Please stop port %d first\n", port_id);
2509 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
2510 printf("The invalid number of traffic class,"
2511 " only 4 or 8 allowed.\n");
2515 if (nb_fwd_lcores < res->num_tcs) {
2516 printf("nb_cores shouldn't be less than number of TCs.\n");
2519 if (!strncmp(res->pfc_en, "on", 2))
2524 /* DCB in VT mode */
2525 if (!strncmp(res->vt_en, "on", 2))
2526 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
2527 (enum rte_eth_nb_tcs)res->num_tcs,
2530 ret = init_port_dcb_config(port_id, DCB_ENABLED,
2531 (enum rte_eth_nb_tcs)res->num_tcs,
2536 printf("Cannot initialize network ports.\n");
2540 cmd_reconfig_device_queue(port_id, 1, 1);
2543 cmdline_parse_token_string_t cmd_config_dcb_port =
2544 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
2545 cmdline_parse_token_string_t cmd_config_dcb_config =
2546 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
2547 cmdline_parse_token_num_t cmd_config_dcb_port_id =
2548 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT16);
2549 cmdline_parse_token_string_t cmd_config_dcb_dcb =
2550 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
2551 cmdline_parse_token_string_t cmd_config_dcb_vt =
2552 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
2553 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
2554 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
2555 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
2556 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
2557 cmdline_parse_token_string_t cmd_config_dcb_pfc=
2558 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
2559 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
2560 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
2562 cmdline_parse_inst_t cmd_config_dcb = {
2563 .f = cmd_config_dcb_parsed,
2565 .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
2567 (void *)&cmd_config_dcb_port,
2568 (void *)&cmd_config_dcb_config,
2569 (void *)&cmd_config_dcb_port_id,
2570 (void *)&cmd_config_dcb_dcb,
2571 (void *)&cmd_config_dcb_vt,
2572 (void *)&cmd_config_dcb_vt_en,
2573 (void *)&cmd_config_dcb_num_tcs,
2574 (void *)&cmd_config_dcb_pfc,
2575 (void *)&cmd_config_dcb_pfc_en,
2580 /* *** configure number of packets per burst *** */
2581 struct cmd_config_burst {
2582 cmdline_fixed_string_t port;
2583 cmdline_fixed_string_t keyword;
2584 cmdline_fixed_string_t all;
2585 cmdline_fixed_string_t name;
2590 cmd_config_burst_parsed(void *parsed_result,
2591 __attribute__((unused)) struct cmdline *cl,
2592 __attribute__((unused)) void *data)
2594 struct cmd_config_burst *res = parsed_result;
2596 if (!all_ports_stopped()) {
2597 printf("Please stop all ports first\n");
2601 if (!strcmp(res->name, "burst")) {
2602 if (res->value < 1 || res->value > MAX_PKT_BURST) {
2603 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
2606 nb_pkt_per_burst = res->value;
2608 printf("Unknown parameter\n");
2614 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2617 cmdline_parse_token_string_t cmd_config_burst_port =
2618 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
2619 cmdline_parse_token_string_t cmd_config_burst_keyword =
2620 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
2621 cmdline_parse_token_string_t cmd_config_burst_all =
2622 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
2623 cmdline_parse_token_string_t cmd_config_burst_name =
2624 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
2625 cmdline_parse_token_num_t cmd_config_burst_value =
2626 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
2628 cmdline_parse_inst_t cmd_config_burst = {
2629 .f = cmd_config_burst_parsed,
2631 .help_str = "port config all burst <value>",
2633 (void *)&cmd_config_burst_port,
2634 (void *)&cmd_config_burst_keyword,
2635 (void *)&cmd_config_burst_all,
2636 (void *)&cmd_config_burst_name,
2637 (void *)&cmd_config_burst_value,
2642 /* *** configure rx/tx queues *** */
2643 struct cmd_config_thresh {
2644 cmdline_fixed_string_t port;
2645 cmdline_fixed_string_t keyword;
2646 cmdline_fixed_string_t all;
2647 cmdline_fixed_string_t name;
2652 cmd_config_thresh_parsed(void *parsed_result,
2653 __attribute__((unused)) struct cmdline *cl,
2654 __attribute__((unused)) void *data)
2656 struct cmd_config_thresh *res = parsed_result;
2658 if (!all_ports_stopped()) {
2659 printf("Please stop all ports first\n");
2663 if (!strcmp(res->name, "txpt"))
2664 tx_pthresh = res->value;
2665 else if(!strcmp(res->name, "txht"))
2666 tx_hthresh = res->value;
2667 else if(!strcmp(res->name, "txwt"))
2668 tx_wthresh = res->value;
2669 else if(!strcmp(res->name, "rxpt"))
2670 rx_pthresh = res->value;
2671 else if(!strcmp(res->name, "rxht"))
2672 rx_hthresh = res->value;
2673 else if(!strcmp(res->name, "rxwt"))
2674 rx_wthresh = res->value;
2676 printf("Unknown parameter\n");
2682 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2685 cmdline_parse_token_string_t cmd_config_thresh_port =
2686 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
2687 cmdline_parse_token_string_t cmd_config_thresh_keyword =
2688 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
2689 cmdline_parse_token_string_t cmd_config_thresh_all =
2690 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
2691 cmdline_parse_token_string_t cmd_config_thresh_name =
2692 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
2693 "txpt#txht#txwt#rxpt#rxht#rxwt");
2694 cmdline_parse_token_num_t cmd_config_thresh_value =
2695 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
2697 cmdline_parse_inst_t cmd_config_thresh = {
2698 .f = cmd_config_thresh_parsed,
2700 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
2702 (void *)&cmd_config_thresh_port,
2703 (void *)&cmd_config_thresh_keyword,
2704 (void *)&cmd_config_thresh_all,
2705 (void *)&cmd_config_thresh_name,
2706 (void *)&cmd_config_thresh_value,
2711 /* *** configure free/rs threshold *** */
2712 struct cmd_config_threshold {
2713 cmdline_fixed_string_t port;
2714 cmdline_fixed_string_t keyword;
2715 cmdline_fixed_string_t all;
2716 cmdline_fixed_string_t name;
2721 cmd_config_threshold_parsed(void *parsed_result,
2722 __attribute__((unused)) struct cmdline *cl,
2723 __attribute__((unused)) void *data)
2725 struct cmd_config_threshold *res = parsed_result;
2727 if (!all_ports_stopped()) {
2728 printf("Please stop all ports first\n");
2732 if (!strcmp(res->name, "txfreet"))
2733 tx_free_thresh = res->value;
2734 else if (!strcmp(res->name, "txrst"))
2735 tx_rs_thresh = res->value;
2736 else if (!strcmp(res->name, "rxfreet"))
2737 rx_free_thresh = res->value;
2739 printf("Unknown parameter\n");
2745 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2748 cmdline_parse_token_string_t cmd_config_threshold_port =
2749 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
2750 cmdline_parse_token_string_t cmd_config_threshold_keyword =
2751 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
2753 cmdline_parse_token_string_t cmd_config_threshold_all =
2754 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
2755 cmdline_parse_token_string_t cmd_config_threshold_name =
2756 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
2757 "txfreet#txrst#rxfreet");
2758 cmdline_parse_token_num_t cmd_config_threshold_value =
2759 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
2761 cmdline_parse_inst_t cmd_config_threshold = {
2762 .f = cmd_config_threshold_parsed,
2764 .help_str = "port config all txfreet|txrst|rxfreet <value>",
2766 (void *)&cmd_config_threshold_port,
2767 (void *)&cmd_config_threshold_keyword,
2768 (void *)&cmd_config_threshold_all,
2769 (void *)&cmd_config_threshold_name,
2770 (void *)&cmd_config_threshold_value,
2776 struct cmd_stop_result {
2777 cmdline_fixed_string_t stop;
2780 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
2781 __attribute__((unused)) struct cmdline *cl,
2782 __attribute__((unused)) void *data)
2784 stop_packet_forwarding();
2787 cmdline_parse_token_string_t cmd_stop_stop =
2788 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
2790 cmdline_parse_inst_t cmd_stop = {
2791 .f = cmd_stop_parsed,
2793 .help_str = "stop: Stop packet forwarding",
2795 (void *)&cmd_stop_stop,
2800 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
2803 parse_item_list(char* str, const char* item_name, unsigned int max_items,
2804 unsigned int *parsed_items, int check_unique_values)
2806 unsigned int nb_item;
2814 * First parse all items in the list and store their value.
2819 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
2821 if ((c >= '0') && (c <= '9')) {
2822 value = (unsigned int) (value * 10 + (c - '0'));
2827 printf("character %c is not a decimal digit\n", c);
2831 printf("No valid value before comma\n");
2834 if (nb_item < max_items) {
2835 parsed_items[nb_item] = value;
2841 if (nb_item >= max_items) {
2842 printf("Number of %s = %u > %u (maximum items)\n",
2843 item_name, nb_item + 1, max_items);
2846 parsed_items[nb_item++] = value;
2847 if (! check_unique_values)
2851 * Then, check that all values in the list are differents.
2852 * No optimization here...
2854 for (i = 0; i < nb_item; i++) {
2855 for (j = i + 1; j < nb_item; j++) {
2856 if (parsed_items[j] == parsed_items[i]) {
2857 printf("duplicated %s %u at index %u and %u\n",
2858 item_name, parsed_items[i], i, j);
2866 struct cmd_set_list_result {
2867 cmdline_fixed_string_t cmd_keyword;
2868 cmdline_fixed_string_t list_name;
2869 cmdline_fixed_string_t list_of_items;
2872 static void cmd_set_list_parsed(void *parsed_result,
2873 __attribute__((unused)) struct cmdline *cl,
2874 __attribute__((unused)) void *data)
2876 struct cmd_set_list_result *res;
2878 unsigned int lcorelist[RTE_MAX_LCORE];
2879 unsigned int portlist[RTE_MAX_ETHPORTS];
2881 unsigned int nb_item;
2883 if (test_done == 0) {
2884 printf("Please stop forwarding first\n");
2888 res = parsed_result;
2889 if (!strcmp(res->list_name, "corelist")) {
2890 nb_item = parse_item_list(res->list_of_items, "core",
2892 parsed_items.lcorelist, 1);
2894 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
2899 if (!strcmp(res->list_name, "portlist")) {
2900 nb_item = parse_item_list(res->list_of_items, "port",
2902 parsed_items.portlist, 1);
2904 set_fwd_ports_list(parsed_items.portlist, nb_item);
2910 cmdline_parse_token_string_t cmd_set_list_keyword =
2911 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
2913 cmdline_parse_token_string_t cmd_set_list_name =
2914 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
2915 "corelist#portlist");
2916 cmdline_parse_token_string_t cmd_set_list_of_items =
2917 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
2920 cmdline_parse_inst_t cmd_set_fwd_list = {
2921 .f = cmd_set_list_parsed,
2923 .help_str = "set corelist|portlist <list0[,list1]*>",
2925 (void *)&cmd_set_list_keyword,
2926 (void *)&cmd_set_list_name,
2927 (void *)&cmd_set_list_of_items,
2932 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
2934 struct cmd_setmask_result {
2935 cmdline_fixed_string_t set;
2936 cmdline_fixed_string_t mask;
2940 static void cmd_set_mask_parsed(void *parsed_result,
2941 __attribute__((unused)) struct cmdline *cl,
2942 __attribute__((unused)) void *data)
2944 struct cmd_setmask_result *res = parsed_result;
2946 if (test_done == 0) {
2947 printf("Please stop forwarding first\n");
2950 if (!strcmp(res->mask, "coremask")) {
2951 set_fwd_lcores_mask(res->hexavalue);
2953 } else if (!strcmp(res->mask, "portmask")) {
2954 set_fwd_ports_mask(res->hexavalue);
2959 cmdline_parse_token_string_t cmd_setmask_set =
2960 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
2961 cmdline_parse_token_string_t cmd_setmask_mask =
2962 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
2963 "coremask#portmask");
2964 cmdline_parse_token_num_t cmd_setmask_value =
2965 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
2967 cmdline_parse_inst_t cmd_set_fwd_mask = {
2968 .f = cmd_set_mask_parsed,
2970 .help_str = "set coremask|portmask <hexadecimal value>",
2972 (void *)&cmd_setmask_set,
2973 (void *)&cmd_setmask_mask,
2974 (void *)&cmd_setmask_value,
2980 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
2982 struct cmd_set_result {
2983 cmdline_fixed_string_t set;
2984 cmdline_fixed_string_t what;
2988 static void cmd_set_parsed(void *parsed_result,
2989 __attribute__((unused)) struct cmdline *cl,
2990 __attribute__((unused)) void *data)
2992 struct cmd_set_result *res = parsed_result;
2993 if (!strcmp(res->what, "nbport")) {
2994 set_fwd_ports_number(res->value);
2996 } else if (!strcmp(res->what, "nbcore")) {
2997 set_fwd_lcores_number(res->value);
2999 } else if (!strcmp(res->what, "burst"))
3000 set_nb_pkt_per_burst(res->value);
3001 else if (!strcmp(res->what, "verbose"))
3002 set_verbose_level(res->value);
3005 cmdline_parse_token_string_t cmd_set_set =
3006 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
3007 cmdline_parse_token_string_t cmd_set_what =
3008 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
3009 "nbport#nbcore#burst#verbose");
3010 cmdline_parse_token_num_t cmd_set_value =
3011 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
3013 cmdline_parse_inst_t cmd_set_numbers = {
3014 .f = cmd_set_parsed,
3016 .help_str = "set nbport|nbcore|burst|verbose <value>",
3018 (void *)&cmd_set_set,
3019 (void *)&cmd_set_what,
3020 (void *)&cmd_set_value,
3025 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
3027 struct cmd_set_txpkts_result {
3028 cmdline_fixed_string_t cmd_keyword;
3029 cmdline_fixed_string_t txpkts;
3030 cmdline_fixed_string_t seg_lengths;
3034 cmd_set_txpkts_parsed(void *parsed_result,
3035 __attribute__((unused)) struct cmdline *cl,
3036 __attribute__((unused)) void *data)
3038 struct cmd_set_txpkts_result *res;
3039 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
3040 unsigned int nb_segs;
3042 res = parsed_result;
3043 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
3044 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
3046 set_tx_pkt_segments(seg_lengths, nb_segs);
3049 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
3050 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3051 cmd_keyword, "set");
3052 cmdline_parse_token_string_t cmd_set_txpkts_name =
3053 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3055 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
3056 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3059 cmdline_parse_inst_t cmd_set_txpkts = {
3060 .f = cmd_set_txpkts_parsed,
3062 .help_str = "set txpkts <len0[,len1]*>",
3064 (void *)&cmd_set_txpkts_keyword,
3065 (void *)&cmd_set_txpkts_name,
3066 (void *)&cmd_set_txpkts_lengths,
3071 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
3073 struct cmd_set_txsplit_result {
3074 cmdline_fixed_string_t cmd_keyword;
3075 cmdline_fixed_string_t txsplit;
3076 cmdline_fixed_string_t mode;
3080 cmd_set_txsplit_parsed(void *parsed_result,
3081 __attribute__((unused)) struct cmdline *cl,
3082 __attribute__((unused)) void *data)
3084 struct cmd_set_txsplit_result *res;
3086 res = parsed_result;
3087 set_tx_pkt_split(res->mode);
3090 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
3091 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3092 cmd_keyword, "set");
3093 cmdline_parse_token_string_t cmd_set_txsplit_name =
3094 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3095 txsplit, "txsplit");
3096 cmdline_parse_token_string_t cmd_set_txsplit_mode =
3097 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3100 cmdline_parse_inst_t cmd_set_txsplit = {
3101 .f = cmd_set_txsplit_parsed,
3103 .help_str = "set txsplit on|off|rand",
3105 (void *)&cmd_set_txsplit_keyword,
3106 (void *)&cmd_set_txsplit_name,
3107 (void *)&cmd_set_txsplit_mode,
3112 /* *** CONFIG TX QUEUE FLAGS *** */
3114 struct cmd_config_txqflags_result {
3115 cmdline_fixed_string_t port;
3116 cmdline_fixed_string_t config;
3117 cmdline_fixed_string_t all;
3118 cmdline_fixed_string_t what;
3122 static void cmd_config_txqflags_parsed(void *parsed_result,
3123 __attribute__((unused)) struct cmdline *cl,
3124 __attribute__((unused)) void *data)
3126 struct cmd_config_txqflags_result *res = parsed_result;
3128 if (!all_ports_stopped()) {
3129 printf("Please stop all ports first\n");
3133 if (strcmp(res->what, "txqflags")) {
3134 printf("Unknown parameter\n");
3138 if (res->hexvalue >= 0) {
3139 txq_flags = res->hexvalue;
3141 printf("txqflags must be >= 0\n");
3147 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3150 cmdline_parse_token_string_t cmd_config_txqflags_port =
3151 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, port,
3153 cmdline_parse_token_string_t cmd_config_txqflags_config =
3154 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, config,
3156 cmdline_parse_token_string_t cmd_config_txqflags_all =
3157 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, all,
3159 cmdline_parse_token_string_t cmd_config_txqflags_what =
3160 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, what,
3162 cmdline_parse_token_num_t cmd_config_txqflags_value =
3163 TOKEN_NUM_INITIALIZER(struct cmd_config_txqflags_result,
3166 cmdline_parse_inst_t cmd_config_txqflags = {
3167 .f = cmd_config_txqflags_parsed,
3169 .help_str = "port config all txqflags <value>",
3171 (void *)&cmd_config_txqflags_port,
3172 (void *)&cmd_config_txqflags_config,
3173 (void *)&cmd_config_txqflags_all,
3174 (void *)&cmd_config_txqflags_what,
3175 (void *)&cmd_config_txqflags_value,
3180 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
3181 struct cmd_rx_vlan_filter_all_result {
3182 cmdline_fixed_string_t rx_vlan;
3183 cmdline_fixed_string_t what;
3184 cmdline_fixed_string_t all;
3189 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
3190 __attribute__((unused)) struct cmdline *cl,
3191 __attribute__((unused)) void *data)
3193 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
3195 if (!strcmp(res->what, "add"))
3196 rx_vlan_all_filter_set(res->port_id, 1);
3198 rx_vlan_all_filter_set(res->port_id, 0);
3201 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
3202 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3203 rx_vlan, "rx_vlan");
3204 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
3205 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3207 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
3208 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3210 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
3211 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3214 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
3215 .f = cmd_rx_vlan_filter_all_parsed,
3217 .help_str = "rx_vlan add|rm all <port_id>: "
3218 "Add/Remove all identifiers to/from the set of VLAN "
3219 "identifiers filtered by a port",
3221 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
3222 (void *)&cmd_rx_vlan_filter_all_what,
3223 (void *)&cmd_rx_vlan_filter_all_all,
3224 (void *)&cmd_rx_vlan_filter_all_portid,
3229 /* *** VLAN OFFLOAD SET ON A PORT *** */
3230 struct cmd_vlan_offload_result {
3231 cmdline_fixed_string_t vlan;
3232 cmdline_fixed_string_t set;
3233 cmdline_fixed_string_t vlan_type;
3234 cmdline_fixed_string_t what;
3235 cmdline_fixed_string_t on;
3236 cmdline_fixed_string_t port_id;
3240 cmd_vlan_offload_parsed(void *parsed_result,
3241 __attribute__((unused)) struct cmdline *cl,
3242 __attribute__((unused)) void *data)
3245 struct cmd_vlan_offload_result *res = parsed_result;
3248 portid_t port_id = 0;
3252 len = strnlen(str, STR_TOKEN_SIZE);
3254 /* Get port_id first */
3262 tmp = strtoul(str, NULL, 0);
3263 /* If port_id greater that what portid_t can represent, return */
3264 if(tmp >= RTE_MAX_ETHPORTS)
3266 port_id = (portid_t)tmp;
3268 if (!strcmp(res->on, "on"))
3273 if (!strcmp(res->what, "strip"))
3274 rx_vlan_strip_set(port_id, on);
3275 else if(!strcmp(res->what, "stripq")){
3276 uint16_t queue_id = 0;
3278 /* No queue_id, return */
3280 printf("must specify (port,queue_id)\n");
3283 tmp = strtoul(str + i + 1, NULL, 0);
3284 /* If queue_id greater that what 16-bits can represent, return */
3288 queue_id = (uint16_t)tmp;
3289 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
3291 else if (!strcmp(res->what, "filter"))
3292 rx_vlan_filter_set(port_id, on);
3294 vlan_extend_set(port_id, on);
3299 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
3300 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3302 cmdline_parse_token_string_t cmd_vlan_offload_set =
3303 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3305 cmdline_parse_token_string_t cmd_vlan_offload_what =
3306 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3307 what, "strip#filter#qinq#stripq");
3308 cmdline_parse_token_string_t cmd_vlan_offload_on =
3309 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3311 cmdline_parse_token_string_t cmd_vlan_offload_portid =
3312 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3315 cmdline_parse_inst_t cmd_vlan_offload = {
3316 .f = cmd_vlan_offload_parsed,
3318 .help_str = "vlan set strip|filter|qinq|stripq on|off "
3319 "<port_id[,queue_id]>: "
3320 "Filter/Strip for rx side qinq(extended) for both rx/tx sides",
3322 (void *)&cmd_vlan_offload_vlan,
3323 (void *)&cmd_vlan_offload_set,
3324 (void *)&cmd_vlan_offload_what,
3325 (void *)&cmd_vlan_offload_on,
3326 (void *)&cmd_vlan_offload_portid,
3331 /* *** VLAN TPID SET ON A PORT *** */
3332 struct cmd_vlan_tpid_result {
3333 cmdline_fixed_string_t vlan;
3334 cmdline_fixed_string_t set;
3335 cmdline_fixed_string_t vlan_type;
3336 cmdline_fixed_string_t what;
3342 cmd_vlan_tpid_parsed(void *parsed_result,
3343 __attribute__((unused)) struct cmdline *cl,
3344 __attribute__((unused)) void *data)
3346 struct cmd_vlan_tpid_result *res = parsed_result;
3347 enum rte_vlan_type vlan_type;
3349 if (!strcmp(res->vlan_type, "inner"))
3350 vlan_type = ETH_VLAN_TYPE_INNER;
3351 else if (!strcmp(res->vlan_type, "outer"))
3352 vlan_type = ETH_VLAN_TYPE_OUTER;
3354 printf("Unknown vlan type\n");
3357 vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
3360 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
3361 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3363 cmdline_parse_token_string_t cmd_vlan_tpid_set =
3364 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3366 cmdline_parse_token_string_t cmd_vlan_type =
3367 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3368 vlan_type, "inner#outer");
3369 cmdline_parse_token_string_t cmd_vlan_tpid_what =
3370 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3372 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
3373 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3375 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
3376 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3379 cmdline_parse_inst_t cmd_vlan_tpid = {
3380 .f = cmd_vlan_tpid_parsed,
3382 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
3383 "Set the VLAN Ether type",
3385 (void *)&cmd_vlan_tpid_vlan,
3386 (void *)&cmd_vlan_tpid_set,
3387 (void *)&cmd_vlan_type,
3388 (void *)&cmd_vlan_tpid_what,
3389 (void *)&cmd_vlan_tpid_tpid,
3390 (void *)&cmd_vlan_tpid_portid,
3395 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
3396 struct cmd_rx_vlan_filter_result {
3397 cmdline_fixed_string_t rx_vlan;
3398 cmdline_fixed_string_t what;
3404 cmd_rx_vlan_filter_parsed(void *parsed_result,
3405 __attribute__((unused)) struct cmdline *cl,
3406 __attribute__((unused)) void *data)
3408 struct cmd_rx_vlan_filter_result *res = parsed_result;
3410 if (!strcmp(res->what, "add"))
3411 rx_vft_set(res->port_id, res->vlan_id, 1);
3413 rx_vft_set(res->port_id, res->vlan_id, 0);
3416 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
3417 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3418 rx_vlan, "rx_vlan");
3419 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
3420 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3422 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
3423 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3425 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
3426 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3429 cmdline_parse_inst_t cmd_rx_vlan_filter = {
3430 .f = cmd_rx_vlan_filter_parsed,
3432 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
3433 "Add/Remove a VLAN identifier to/from the set of VLAN "
3434 "identifiers filtered by a port",
3436 (void *)&cmd_rx_vlan_filter_rx_vlan,
3437 (void *)&cmd_rx_vlan_filter_what,
3438 (void *)&cmd_rx_vlan_filter_vlanid,
3439 (void *)&cmd_rx_vlan_filter_portid,
3444 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3445 struct cmd_tx_vlan_set_result {
3446 cmdline_fixed_string_t tx_vlan;
3447 cmdline_fixed_string_t set;
3453 cmd_tx_vlan_set_parsed(void *parsed_result,
3454 __attribute__((unused)) struct cmdline *cl,
3455 __attribute__((unused)) void *data)
3457 struct cmd_tx_vlan_set_result *res = parsed_result;
3459 tx_vlan_set(res->port_id, res->vlan_id);
3462 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
3463 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3464 tx_vlan, "tx_vlan");
3465 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
3466 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3468 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
3469 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3471 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
3472 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3475 cmdline_parse_inst_t cmd_tx_vlan_set = {
3476 .f = cmd_tx_vlan_set_parsed,
3478 .help_str = "tx_vlan set <port_id> <vlan_id>: "
3479 "Enable hardware insertion of a single VLAN header "
3480 "with a given TAG Identifier in packets sent on a port",
3482 (void *)&cmd_tx_vlan_set_tx_vlan,
3483 (void *)&cmd_tx_vlan_set_set,
3484 (void *)&cmd_tx_vlan_set_portid,
3485 (void *)&cmd_tx_vlan_set_vlanid,
3490 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
3491 struct cmd_tx_vlan_set_qinq_result {
3492 cmdline_fixed_string_t tx_vlan;
3493 cmdline_fixed_string_t set;
3496 uint16_t vlan_id_outer;
3500 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
3501 __attribute__((unused)) struct cmdline *cl,
3502 __attribute__((unused)) void *data)
3504 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
3506 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
3509 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
3510 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3511 tx_vlan, "tx_vlan");
3512 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
3513 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3515 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
3516 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3518 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
3519 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3521 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
3522 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3523 vlan_id_outer, UINT16);
3525 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
3526 .f = cmd_tx_vlan_set_qinq_parsed,
3528 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
3529 "Enable hardware insertion of double VLAN header "
3530 "with given TAG Identifiers in packets sent on a port",
3532 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
3533 (void *)&cmd_tx_vlan_set_qinq_set,
3534 (void *)&cmd_tx_vlan_set_qinq_portid,
3535 (void *)&cmd_tx_vlan_set_qinq_vlanid,
3536 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
3541 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
3542 struct cmd_tx_vlan_set_pvid_result {
3543 cmdline_fixed_string_t tx_vlan;
3544 cmdline_fixed_string_t set;
3545 cmdline_fixed_string_t pvid;
3548 cmdline_fixed_string_t mode;
3552 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
3553 __attribute__((unused)) struct cmdline *cl,
3554 __attribute__((unused)) void *data)
3556 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
3558 if (strcmp(res->mode, "on") == 0)
3559 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
3561 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
3564 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
3565 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3566 tx_vlan, "tx_vlan");
3567 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
3568 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3570 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
3571 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3573 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
3574 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3576 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
3577 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3579 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
3580 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3583 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
3584 .f = cmd_tx_vlan_set_pvid_parsed,
3586 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
3588 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
3589 (void *)&cmd_tx_vlan_set_pvid_set,
3590 (void *)&cmd_tx_vlan_set_pvid_pvid,
3591 (void *)&cmd_tx_vlan_set_pvid_port_id,
3592 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
3593 (void *)&cmd_tx_vlan_set_pvid_mode,
3598 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3599 struct cmd_tx_vlan_reset_result {
3600 cmdline_fixed_string_t tx_vlan;
3601 cmdline_fixed_string_t reset;
3606 cmd_tx_vlan_reset_parsed(void *parsed_result,
3607 __attribute__((unused)) struct cmdline *cl,
3608 __attribute__((unused)) void *data)
3610 struct cmd_tx_vlan_reset_result *res = parsed_result;
3612 tx_vlan_reset(res->port_id);
3615 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
3616 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
3617 tx_vlan, "tx_vlan");
3618 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
3619 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
3621 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
3622 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
3625 cmdline_parse_inst_t cmd_tx_vlan_reset = {
3626 .f = cmd_tx_vlan_reset_parsed,
3628 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
3629 "VLAN header in packets sent on a port",
3631 (void *)&cmd_tx_vlan_reset_tx_vlan,
3632 (void *)&cmd_tx_vlan_reset_reset,
3633 (void *)&cmd_tx_vlan_reset_portid,
3639 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
3640 struct cmd_csum_result {
3641 cmdline_fixed_string_t csum;
3642 cmdline_fixed_string_t mode;
3643 cmdline_fixed_string_t proto;
3644 cmdline_fixed_string_t hwsw;
3649 csum_show(int port_id)
3651 struct rte_eth_dev_info dev_info;
3654 ol_flags = ports[port_id].tx_ol_flags;
3655 printf("Parse tunnel is %s\n",
3656 (ol_flags & TESTPMD_TX_OFFLOAD_PARSE_TUNNEL) ? "on" : "off");
3657 printf("IP checksum offload is %s\n",
3658 (ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) ? "hw" : "sw");
3659 printf("UDP checksum offload is %s\n",
3660 (ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
3661 printf("TCP checksum offload is %s\n",
3662 (ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
3663 printf("SCTP checksum offload is %s\n",
3664 (ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
3665 printf("Outer-Ip checksum offload is %s\n",
3666 (ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) ? "hw" : "sw");
3668 /* display warnings if configuration is not supported by the NIC */
3669 rte_eth_dev_info_get(port_id, &dev_info);
3670 if ((ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) &&
3671 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
3672 printf("Warning: hardware IP checksum enabled but not "
3673 "supported by port %d\n", port_id);
3675 if ((ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) &&
3676 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
3677 printf("Warning: hardware UDP checksum enabled but not "
3678 "supported by port %d\n", port_id);
3680 if ((ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) &&
3681 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
3682 printf("Warning: hardware TCP checksum enabled but not "
3683 "supported by port %d\n", port_id);
3685 if ((ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) &&
3686 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
3687 printf("Warning: hardware SCTP checksum enabled but not "
3688 "supported by port %d\n", port_id);
3690 if ((ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) &&
3691 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
3692 printf("Warning: hardware outer IP checksum enabled but not "
3693 "supported by port %d\n", port_id);
3698 cmd_csum_parsed(void *parsed_result,
3699 __attribute__((unused)) struct cmdline *cl,
3700 __attribute__((unused)) void *data)
3702 struct cmd_csum_result *res = parsed_result;
3706 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
3707 printf("invalid port %d\n", res->port_id);
3711 if (!strcmp(res->mode, "set")) {
3713 if (!strcmp(res->hwsw, "hw"))
3716 if (!strcmp(res->proto, "ip")) {
3717 mask = TESTPMD_TX_OFFLOAD_IP_CKSUM;
3718 } else if (!strcmp(res->proto, "udp")) {
3719 mask = TESTPMD_TX_OFFLOAD_UDP_CKSUM;
3720 } else if (!strcmp(res->proto, "tcp")) {
3721 mask = TESTPMD_TX_OFFLOAD_TCP_CKSUM;
3722 } else if (!strcmp(res->proto, "sctp")) {
3723 mask = TESTPMD_TX_OFFLOAD_SCTP_CKSUM;
3724 } else if (!strcmp(res->proto, "outer-ip")) {
3725 mask = TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM;
3729 ports[res->port_id].tx_ol_flags |= mask;
3731 ports[res->port_id].tx_ol_flags &= (~mask);
3733 csum_show(res->port_id);
3736 cmdline_parse_token_string_t cmd_csum_csum =
3737 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3739 cmdline_parse_token_string_t cmd_csum_mode =
3740 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3742 cmdline_parse_token_string_t cmd_csum_proto =
3743 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3744 proto, "ip#tcp#udp#sctp#outer-ip");
3745 cmdline_parse_token_string_t cmd_csum_hwsw =
3746 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3748 cmdline_parse_token_num_t cmd_csum_portid =
3749 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
3752 cmdline_parse_inst_t cmd_csum_set = {
3753 .f = cmd_csum_parsed,
3755 .help_str = "csum set ip|tcp|udp|sctp|outer-ip hw|sw <port_id>: "
3756 "Enable/Disable hardware calculation of L3/L4 checksum when "
3757 "using csum forward engine",
3759 (void *)&cmd_csum_csum,
3760 (void *)&cmd_csum_mode,
3761 (void *)&cmd_csum_proto,
3762 (void *)&cmd_csum_hwsw,
3763 (void *)&cmd_csum_portid,
3768 cmdline_parse_token_string_t cmd_csum_mode_show =
3769 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3772 cmdline_parse_inst_t cmd_csum_show = {
3773 .f = cmd_csum_parsed,
3775 .help_str = "csum show <port_id>: Show checksum offload configuration",
3777 (void *)&cmd_csum_csum,
3778 (void *)&cmd_csum_mode_show,
3779 (void *)&cmd_csum_portid,
3784 /* Enable/disable tunnel parsing */
3785 struct cmd_csum_tunnel_result {
3786 cmdline_fixed_string_t csum;
3787 cmdline_fixed_string_t parse;
3788 cmdline_fixed_string_t onoff;
3793 cmd_csum_tunnel_parsed(void *parsed_result,
3794 __attribute__((unused)) struct cmdline *cl,
3795 __attribute__((unused)) void *data)
3797 struct cmd_csum_tunnel_result *res = parsed_result;
3799 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3802 if (!strcmp(res->onoff, "on"))
3803 ports[res->port_id].tx_ol_flags |=
3804 TESTPMD_TX_OFFLOAD_PARSE_TUNNEL;
3806 ports[res->port_id].tx_ol_flags &=
3807 (~TESTPMD_TX_OFFLOAD_PARSE_TUNNEL);
3809 csum_show(res->port_id);
3812 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
3813 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3815 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
3816 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3817 parse, "parse_tunnel");
3818 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
3819 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3821 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
3822 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
3825 cmdline_parse_inst_t cmd_csum_tunnel = {
3826 .f = cmd_csum_tunnel_parsed,
3828 .help_str = "csum parse_tunnel on|off <port_id>: "
3829 "Enable/Disable parsing of tunnels for csum engine",
3831 (void *)&cmd_csum_tunnel_csum,
3832 (void *)&cmd_csum_tunnel_parse,
3833 (void *)&cmd_csum_tunnel_onoff,
3834 (void *)&cmd_csum_tunnel_portid,
3839 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
3840 struct cmd_tso_set_result {
3841 cmdline_fixed_string_t tso;
3842 cmdline_fixed_string_t mode;
3848 cmd_tso_set_parsed(void *parsed_result,
3849 __attribute__((unused)) struct cmdline *cl,
3850 __attribute__((unused)) void *data)
3852 struct cmd_tso_set_result *res = parsed_result;
3853 struct rte_eth_dev_info dev_info;
3855 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3858 if (!strcmp(res->mode, "set"))
3859 ports[res->port_id].tso_segsz = res->tso_segsz;
3861 if (ports[res->port_id].tso_segsz == 0)
3862 printf("TSO for non-tunneled packets is disabled\n");
3864 printf("TSO segment size for non-tunneled packets is %d\n",
3865 ports[res->port_id].tso_segsz);
3867 /* display warnings if configuration is not supported by the NIC */
3868 rte_eth_dev_info_get(res->port_id, &dev_info);
3869 if ((ports[res->port_id].tso_segsz != 0) &&
3870 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
3871 printf("Warning: TSO enabled but not "
3872 "supported by port %d\n", res->port_id);
3876 cmdline_parse_token_string_t cmd_tso_set_tso =
3877 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3879 cmdline_parse_token_string_t cmd_tso_set_mode =
3880 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3882 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
3883 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3885 cmdline_parse_token_num_t cmd_tso_set_portid =
3886 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3889 cmdline_parse_inst_t cmd_tso_set = {
3890 .f = cmd_tso_set_parsed,
3892 .help_str = "tso set <tso_segsz> <port_id>: "
3893 "Set TSO segment size of non-tunneled packets for csum engine "
3896 (void *)&cmd_tso_set_tso,
3897 (void *)&cmd_tso_set_mode,
3898 (void *)&cmd_tso_set_tso_segsz,
3899 (void *)&cmd_tso_set_portid,
3904 cmdline_parse_token_string_t cmd_tso_show_mode =
3905 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3909 cmdline_parse_inst_t cmd_tso_show = {
3910 .f = cmd_tso_set_parsed,
3912 .help_str = "tso show <port_id>: "
3913 "Show TSO segment size of non-tunneled packets for csum engine",
3915 (void *)&cmd_tso_set_tso,
3916 (void *)&cmd_tso_show_mode,
3917 (void *)&cmd_tso_set_portid,
3922 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
3923 struct cmd_tunnel_tso_set_result {
3924 cmdline_fixed_string_t tso;
3925 cmdline_fixed_string_t mode;
3931 check_tunnel_tso_nic_support(portid_t port_id)
3933 struct rte_eth_dev_info dev_info;
3935 rte_eth_dev_info_get(port_id, &dev_info);
3936 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO))
3937 printf("Warning: TSO enabled but VXLAN TUNNEL TSO not "
3938 "supported by port %d\n", port_id);
3939 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO))
3940 printf("Warning: TSO enabled but GRE TUNNEL TSO not "
3941 "supported by port %d\n", port_id);
3942 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO))
3943 printf("Warning: TSO enabled but IPIP TUNNEL TSO not "
3944 "supported by port %d\n", port_id);
3945 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
3946 printf("Warning: TSO enabled but GENEVE TUNNEL TSO not "
3947 "supported by port %d\n", port_id);
3951 cmd_tunnel_tso_set_parsed(void *parsed_result,
3952 __attribute__((unused)) struct cmdline *cl,
3953 __attribute__((unused)) void *data)
3955 struct cmd_tunnel_tso_set_result *res = parsed_result;
3957 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3960 if (!strcmp(res->mode, "set"))
3961 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
3963 if (ports[res->port_id].tunnel_tso_segsz == 0)
3964 printf("TSO for tunneled packets is disabled\n");
3966 printf("TSO segment size for tunneled packets is %d\n",
3967 ports[res->port_id].tunnel_tso_segsz);
3969 /* Below conditions are needed to make it work:
3970 * (1) tunnel TSO is supported by the NIC;
3971 * (2) "csum parse_tunnel" must be set so that tunneled pkts
3973 * (3) for tunneled pkts with outer L3 of IPv4,
3974 * "csum set outer-ip" must be set to hw, because after tso,
3975 * total_len of outer IP header is changed, and the checksum
3976 * of outer IP header calculated by sw should be wrong; that
3977 * is not necessary for IPv6 tunneled pkts because there's no
3978 * checksum in IP header anymore.
3980 check_tunnel_tso_nic_support(res->port_id);
3982 if (!(ports[res->port_id].tx_ol_flags &
3983 TESTPMD_TX_OFFLOAD_PARSE_TUNNEL))
3984 printf("Warning: csum parse_tunnel must be set "
3985 "so that tunneled packets are recognized\n");
3986 if (!(ports[res->port_id].tx_ol_flags &
3987 TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM))
3988 printf("Warning: csum set outer-ip must be set to hw "
3989 "if outer L3 is IPv4; not necessary for IPv6\n");
3993 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
3994 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
3996 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
3997 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
3999 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
4000 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4002 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
4003 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4006 cmdline_parse_inst_t cmd_tunnel_tso_set = {
4007 .f = cmd_tunnel_tso_set_parsed,
4009 .help_str = "tunnel_tso set <tso_segsz> <port_id>: "
4010 "Set TSO segment size of tunneled packets for csum engine "
4013 (void *)&cmd_tunnel_tso_set_tso,
4014 (void *)&cmd_tunnel_tso_set_mode,
4015 (void *)&cmd_tunnel_tso_set_tso_segsz,
4016 (void *)&cmd_tunnel_tso_set_portid,
4021 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
4022 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4026 cmdline_parse_inst_t cmd_tunnel_tso_show = {
4027 .f = cmd_tunnel_tso_set_parsed,
4029 .help_str = "tunnel_tso show <port_id> "
4030 "Show TSO segment size of tunneled packets for csum engine",
4032 (void *)&cmd_tunnel_tso_set_tso,
4033 (void *)&cmd_tunnel_tso_show_mode,
4034 (void *)&cmd_tunnel_tso_set_portid,
4039 /* *** SET GRO FOR A PORT *** */
4040 struct cmd_gro_enable_result {
4041 cmdline_fixed_string_t cmd_set;
4042 cmdline_fixed_string_t cmd_port;
4043 cmdline_fixed_string_t cmd_keyword;
4044 cmdline_fixed_string_t cmd_onoff;
4049 cmd_gro_enable_parsed(void *parsed_result,
4050 __attribute__((unused)) struct cmdline *cl,
4051 __attribute__((unused)) void *data)
4053 struct cmd_gro_enable_result *res;
4055 res = parsed_result;
4056 if (!strcmp(res->cmd_keyword, "gro"))
4057 setup_gro(res->cmd_onoff, res->cmd_pid);
4060 cmdline_parse_token_string_t cmd_gro_enable_set =
4061 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4063 cmdline_parse_token_string_t cmd_gro_enable_port =
4064 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4065 cmd_keyword, "port");
4066 cmdline_parse_token_num_t cmd_gro_enable_pid =
4067 TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result,
4069 cmdline_parse_token_string_t cmd_gro_enable_keyword =
4070 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4071 cmd_keyword, "gro");
4072 cmdline_parse_token_string_t cmd_gro_enable_onoff =
4073 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4074 cmd_onoff, "on#off");
4076 cmdline_parse_inst_t cmd_gro_enable = {
4077 .f = cmd_gro_enable_parsed,
4079 .help_str = "set port <port_id> gro on|off",
4081 (void *)&cmd_gro_enable_set,
4082 (void *)&cmd_gro_enable_port,
4083 (void *)&cmd_gro_enable_pid,
4084 (void *)&cmd_gro_enable_keyword,
4085 (void *)&cmd_gro_enable_onoff,
4090 /* *** DISPLAY GRO CONFIGURATION *** */
4091 struct cmd_gro_show_result {
4092 cmdline_fixed_string_t cmd_show;
4093 cmdline_fixed_string_t cmd_port;
4094 cmdline_fixed_string_t cmd_keyword;
4099 cmd_gro_show_parsed(void *parsed_result,
4100 __attribute__((unused)) struct cmdline *cl,
4101 __attribute__((unused)) void *data)
4103 struct cmd_gro_show_result *res;
4105 res = parsed_result;
4106 if (!strcmp(res->cmd_keyword, "gro"))
4107 show_gro(res->cmd_pid);
4110 cmdline_parse_token_string_t cmd_gro_show_show =
4111 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4113 cmdline_parse_token_string_t cmd_gro_show_port =
4114 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4116 cmdline_parse_token_num_t cmd_gro_show_pid =
4117 TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result,
4119 cmdline_parse_token_string_t cmd_gro_show_keyword =
4120 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4121 cmd_keyword, "gro");
4123 cmdline_parse_inst_t cmd_gro_show = {
4124 .f = cmd_gro_show_parsed,
4126 .help_str = "show port <port_id> gro",
4128 (void *)&cmd_gro_show_show,
4129 (void *)&cmd_gro_show_port,
4130 (void *)&cmd_gro_show_pid,
4131 (void *)&cmd_gro_show_keyword,
4136 /* *** SET FLUSH CYCLES FOR GRO *** */
4137 struct cmd_gro_flush_result {
4138 cmdline_fixed_string_t cmd_set;
4139 cmdline_fixed_string_t cmd_keyword;
4140 cmdline_fixed_string_t cmd_flush;
4145 cmd_gro_flush_parsed(void *parsed_result,
4146 __attribute__((unused)) struct cmdline *cl,
4147 __attribute__((unused)) void *data)
4149 struct cmd_gro_flush_result *res;
4151 res = parsed_result;
4152 if ((!strcmp(res->cmd_keyword, "gro")) &&
4153 (!strcmp(res->cmd_flush, "flush")))
4154 setup_gro_flush_cycles(res->cmd_cycles);
4157 cmdline_parse_token_string_t cmd_gro_flush_set =
4158 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4160 cmdline_parse_token_string_t cmd_gro_flush_keyword =
4161 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4162 cmd_keyword, "gro");
4163 cmdline_parse_token_string_t cmd_gro_flush_flush =
4164 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4165 cmd_flush, "flush");
4166 cmdline_parse_token_num_t cmd_gro_flush_cycles =
4167 TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result,
4170 cmdline_parse_inst_t cmd_gro_flush = {
4171 .f = cmd_gro_flush_parsed,
4173 .help_str = "set gro flush <cycles>",
4175 (void *)&cmd_gro_flush_set,
4176 (void *)&cmd_gro_flush_keyword,
4177 (void *)&cmd_gro_flush_flush,
4178 (void *)&cmd_gro_flush_cycles,
4183 /* *** ENABLE/DISABLE GSO *** */
4184 struct cmd_gso_enable_result {
4185 cmdline_fixed_string_t cmd_set;
4186 cmdline_fixed_string_t cmd_port;
4187 cmdline_fixed_string_t cmd_keyword;
4188 cmdline_fixed_string_t cmd_mode;
4193 cmd_gso_enable_parsed(void *parsed_result,
4194 __attribute__((unused)) struct cmdline *cl,
4195 __attribute__((unused)) void *data)
4197 struct cmd_gso_enable_result *res;
4199 res = parsed_result;
4200 if (!strcmp(res->cmd_keyword, "gso"))
4201 setup_gso(res->cmd_mode, res->cmd_pid);
4204 cmdline_parse_token_string_t cmd_gso_enable_set =
4205 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4207 cmdline_parse_token_string_t cmd_gso_enable_port =
4208 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4210 cmdline_parse_token_string_t cmd_gso_enable_keyword =
4211 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4212 cmd_keyword, "gso");
4213 cmdline_parse_token_string_t cmd_gso_enable_mode =
4214 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4215 cmd_mode, "on#off");
4216 cmdline_parse_token_num_t cmd_gso_enable_pid =
4217 TOKEN_NUM_INITIALIZER(struct cmd_gso_enable_result,
4220 cmdline_parse_inst_t cmd_gso_enable = {
4221 .f = cmd_gso_enable_parsed,
4223 .help_str = "set port <port_id> gso on|off",
4225 (void *)&cmd_gso_enable_set,
4226 (void *)&cmd_gso_enable_port,
4227 (void *)&cmd_gso_enable_pid,
4228 (void *)&cmd_gso_enable_keyword,
4229 (void *)&cmd_gso_enable_mode,
4234 /* *** SET MAX PACKET LENGTH FOR GSO SEGMENTS *** */
4235 struct cmd_gso_size_result {
4236 cmdline_fixed_string_t cmd_set;
4237 cmdline_fixed_string_t cmd_keyword;
4238 cmdline_fixed_string_t cmd_segsz;
4243 cmd_gso_size_parsed(void *parsed_result,
4244 __attribute__((unused)) struct cmdline *cl,
4245 __attribute__((unused)) void *data)
4247 struct cmd_gso_size_result *res = parsed_result;
4249 if (test_done == 0) {
4250 printf("Before setting GSO segsz, please first"
4251 " stop fowarding\n");
4255 if (!strcmp(res->cmd_keyword, "gso") &&
4256 !strcmp(res->cmd_segsz, "segsz")) {
4257 if (res->cmd_size < RTE_GSO_SEG_SIZE_MIN)
4258 printf("gso_size should be larger than %zu."
4259 " Please input a legal value\n",
4260 RTE_GSO_SEG_SIZE_MIN);
4262 gso_max_segment_size = res->cmd_size;
4266 cmdline_parse_token_string_t cmd_gso_size_set =
4267 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
4269 cmdline_parse_token_string_t cmd_gso_size_keyword =
4270 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
4271 cmd_keyword, "gso");
4272 cmdline_parse_token_string_t cmd_gso_size_segsz =
4273 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
4274 cmd_segsz, "segsz");
4275 cmdline_parse_token_num_t cmd_gso_size_size =
4276 TOKEN_NUM_INITIALIZER(struct cmd_gso_size_result,
4279 cmdline_parse_inst_t cmd_gso_size = {
4280 .f = cmd_gso_size_parsed,
4282 .help_str = "set gso segsz <length>",
4284 (void *)&cmd_gso_size_set,
4285 (void *)&cmd_gso_size_keyword,
4286 (void *)&cmd_gso_size_segsz,
4287 (void *)&cmd_gso_size_size,
4292 /* *** SHOW GSO CONFIGURATION *** */
4293 struct cmd_gso_show_result {
4294 cmdline_fixed_string_t cmd_show;
4295 cmdline_fixed_string_t cmd_port;
4296 cmdline_fixed_string_t cmd_keyword;
4301 cmd_gso_show_parsed(void *parsed_result,
4302 __attribute__((unused)) struct cmdline *cl,
4303 __attribute__((unused)) void *data)
4305 struct cmd_gso_show_result *res = parsed_result;
4307 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
4308 printf("invalid port id %u\n", res->cmd_pid);
4311 if (!strcmp(res->cmd_keyword, "gso")) {
4312 if (gso_ports[res->cmd_pid].enable) {
4313 printf("Max GSO'd packet size: %uB\n"
4314 "Supported GSO types: TCP/IPv4, "
4315 "VxLAN with inner TCP/IPv4 packet, "
4316 "GRE with inner TCP/IPv4 packet\n",
4317 gso_max_segment_size);
4319 printf("GSO is not enabled on Port %u\n", res->cmd_pid);
4323 cmdline_parse_token_string_t cmd_gso_show_show =
4324 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
4326 cmdline_parse_token_string_t cmd_gso_show_port =
4327 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
4329 cmdline_parse_token_string_t cmd_gso_show_keyword =
4330 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
4331 cmd_keyword, "gso");
4332 cmdline_parse_token_num_t cmd_gso_show_pid =
4333 TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result,
4336 cmdline_parse_inst_t cmd_gso_show = {
4337 .f = cmd_gso_show_parsed,
4339 .help_str = "show port <port_id> gso",
4341 (void *)&cmd_gso_show_show,
4342 (void *)&cmd_gso_show_port,
4343 (void *)&cmd_gso_show_pid,
4344 (void *)&cmd_gso_show_keyword,
4349 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
4350 struct cmd_set_flush_rx {
4351 cmdline_fixed_string_t set;
4352 cmdline_fixed_string_t flush_rx;
4353 cmdline_fixed_string_t mode;
4357 cmd_set_flush_rx_parsed(void *parsed_result,
4358 __attribute__((unused)) struct cmdline *cl,
4359 __attribute__((unused)) void *data)
4361 struct cmd_set_flush_rx *res = parsed_result;
4362 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
4365 cmdline_parse_token_string_t cmd_setflushrx_set =
4366 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
4368 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
4369 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
4370 flush_rx, "flush_rx");
4371 cmdline_parse_token_string_t cmd_setflushrx_mode =
4372 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
4376 cmdline_parse_inst_t cmd_set_flush_rx = {
4377 .f = cmd_set_flush_rx_parsed,
4378 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
4381 (void *)&cmd_setflushrx_set,
4382 (void *)&cmd_setflushrx_flush_rx,
4383 (void *)&cmd_setflushrx_mode,
4388 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
4389 struct cmd_set_link_check {
4390 cmdline_fixed_string_t set;
4391 cmdline_fixed_string_t link_check;
4392 cmdline_fixed_string_t mode;
4396 cmd_set_link_check_parsed(void *parsed_result,
4397 __attribute__((unused)) struct cmdline *cl,
4398 __attribute__((unused)) void *data)
4400 struct cmd_set_link_check *res = parsed_result;
4401 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
4404 cmdline_parse_token_string_t cmd_setlinkcheck_set =
4405 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
4407 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
4408 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
4409 link_check, "link_check");
4410 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
4411 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
4415 cmdline_parse_inst_t cmd_set_link_check = {
4416 .f = cmd_set_link_check_parsed,
4417 .help_str = "set link_check on|off: Enable/Disable link status check "
4418 "when starting/stopping a port",
4421 (void *)&cmd_setlinkcheck_set,
4422 (void *)&cmd_setlinkcheck_link_check,
4423 (void *)&cmd_setlinkcheck_mode,
4428 /* *** SET NIC BYPASS MODE *** */
4429 struct cmd_set_bypass_mode_result {
4430 cmdline_fixed_string_t set;
4431 cmdline_fixed_string_t bypass;
4432 cmdline_fixed_string_t mode;
4433 cmdline_fixed_string_t value;
4438 cmd_set_bypass_mode_parsed(void *parsed_result,
4439 __attribute__((unused)) struct cmdline *cl,
4440 __attribute__((unused)) void *data)
4442 struct cmd_set_bypass_mode_result *res = parsed_result;
4443 portid_t port_id = res->port_id;
4444 int32_t rc = -EINVAL;
4446 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4447 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4449 if (!strcmp(res->value, "bypass"))
4450 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
4451 else if (!strcmp(res->value, "isolate"))
4452 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
4454 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4456 /* Set the bypass mode for the relevant port. */
4457 rc = rte_pmd_ixgbe_bypass_state_set(port_id, &bypass_mode);
4460 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
4463 cmdline_parse_token_string_t cmd_setbypass_mode_set =
4464 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4466 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
4467 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4469 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
4470 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4472 cmdline_parse_token_string_t cmd_setbypass_mode_value =
4473 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4474 value, "normal#bypass#isolate");
4475 cmdline_parse_token_num_t cmd_setbypass_mode_port =
4476 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
4479 cmdline_parse_inst_t cmd_set_bypass_mode = {
4480 .f = cmd_set_bypass_mode_parsed,
4481 .help_str = "set bypass mode normal|bypass|isolate <port_id>: "
4482 "Set the NIC bypass mode for port_id",
4485 (void *)&cmd_setbypass_mode_set,
4486 (void *)&cmd_setbypass_mode_bypass,
4487 (void *)&cmd_setbypass_mode_mode,
4488 (void *)&cmd_setbypass_mode_value,
4489 (void *)&cmd_setbypass_mode_port,
4494 /* *** SET NIC BYPASS EVENT *** */
4495 struct cmd_set_bypass_event_result {
4496 cmdline_fixed_string_t set;
4497 cmdline_fixed_string_t bypass;
4498 cmdline_fixed_string_t event;
4499 cmdline_fixed_string_t event_value;
4500 cmdline_fixed_string_t mode;
4501 cmdline_fixed_string_t mode_value;
4506 cmd_set_bypass_event_parsed(void *parsed_result,
4507 __attribute__((unused)) struct cmdline *cl,
4508 __attribute__((unused)) void *data)
4510 int32_t rc = -EINVAL;
4511 struct cmd_set_bypass_event_result *res = parsed_result;
4512 portid_t port_id = res->port_id;
4514 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4515 uint32_t bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
4516 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4518 if (!strcmp(res->event_value, "timeout"))
4519 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT;
4520 else if (!strcmp(res->event_value, "os_on"))
4521 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_ON;
4522 else if (!strcmp(res->event_value, "os_off"))
4523 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_OFF;
4524 else if (!strcmp(res->event_value, "power_on"))
4525 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_ON;
4526 else if (!strcmp(res->event_value, "power_off"))
4527 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_OFF;
4529 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
4531 if (!strcmp(res->mode_value, "bypass"))
4532 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
4533 else if (!strcmp(res->mode_value, "isolate"))
4534 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
4536 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4538 /* Set the watchdog timeout. */
4539 if (bypass_event == RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT) {
4542 if (RTE_PMD_IXGBE_BYPASS_TMT_VALID(bypass_timeout)) {
4543 rc = rte_pmd_ixgbe_bypass_wd_timeout_store(port_id,
4547 printf("Failed to set timeout value %u "
4548 "for port %d, errto code: %d.\n",
4549 bypass_timeout, port_id, rc);
4553 /* Set the bypass event to transition to bypass mode. */
4554 rc = rte_pmd_ixgbe_bypass_event_store(port_id, bypass_event,
4559 printf("\t Failed to set bypass event for port = %d.\n",
4563 cmdline_parse_token_string_t cmd_setbypass_event_set =
4564 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4566 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
4567 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4569 cmdline_parse_token_string_t cmd_setbypass_event_event =
4570 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4572 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
4573 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4574 event_value, "none#timeout#os_off#os_on#power_on#power_off");
4575 cmdline_parse_token_string_t cmd_setbypass_event_mode =
4576 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4578 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
4579 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4580 mode_value, "normal#bypass#isolate");
4581 cmdline_parse_token_num_t cmd_setbypass_event_port =
4582 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
4585 cmdline_parse_inst_t cmd_set_bypass_event = {
4586 .f = cmd_set_bypass_event_parsed,
4587 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
4588 "power_off mode normal|bypass|isolate <port_id>: "
4589 "Set the NIC bypass event mode for port_id",
4592 (void *)&cmd_setbypass_event_set,
4593 (void *)&cmd_setbypass_event_bypass,
4594 (void *)&cmd_setbypass_event_event,
4595 (void *)&cmd_setbypass_event_event_value,
4596 (void *)&cmd_setbypass_event_mode,
4597 (void *)&cmd_setbypass_event_mode_value,
4598 (void *)&cmd_setbypass_event_port,
4604 /* *** SET NIC BYPASS TIMEOUT *** */
4605 struct cmd_set_bypass_timeout_result {
4606 cmdline_fixed_string_t set;
4607 cmdline_fixed_string_t bypass;
4608 cmdline_fixed_string_t timeout;
4609 cmdline_fixed_string_t value;
4613 cmd_set_bypass_timeout_parsed(void *parsed_result,
4614 __attribute__((unused)) struct cmdline *cl,
4615 __attribute__((unused)) void *data)
4617 __rte_unused struct cmd_set_bypass_timeout_result *res = parsed_result;
4619 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4620 if (!strcmp(res->value, "1.5"))
4621 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_1_5_SEC;
4622 else if (!strcmp(res->value, "2"))
4623 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_2_SEC;
4624 else if (!strcmp(res->value, "3"))
4625 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_3_SEC;
4626 else if (!strcmp(res->value, "4"))
4627 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_4_SEC;
4628 else if (!strcmp(res->value, "8"))
4629 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_8_SEC;
4630 else if (!strcmp(res->value, "16"))
4631 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_16_SEC;
4632 else if (!strcmp(res->value, "32"))
4633 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_32_SEC;
4635 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
4639 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
4640 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4642 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
4643 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4645 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
4646 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4647 timeout, "timeout");
4648 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
4649 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4650 value, "0#1.5#2#3#4#8#16#32");
4652 cmdline_parse_inst_t cmd_set_bypass_timeout = {
4653 .f = cmd_set_bypass_timeout_parsed,
4654 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
4655 "Set the NIC bypass watchdog timeout in seconds",
4658 (void *)&cmd_setbypass_timeout_set,
4659 (void *)&cmd_setbypass_timeout_bypass,
4660 (void *)&cmd_setbypass_timeout_timeout,
4661 (void *)&cmd_setbypass_timeout_value,
4666 /* *** SHOW NIC BYPASS MODE *** */
4667 struct cmd_show_bypass_config_result {
4668 cmdline_fixed_string_t show;
4669 cmdline_fixed_string_t bypass;
4670 cmdline_fixed_string_t config;
4675 cmd_show_bypass_config_parsed(void *parsed_result,
4676 __attribute__((unused)) struct cmdline *cl,
4677 __attribute__((unused)) void *data)
4679 struct cmd_show_bypass_config_result *res = parsed_result;
4680 portid_t port_id = res->port_id;
4682 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4683 uint32_t event_mode;
4684 uint32_t bypass_mode;
4685 uint32_t timeout = bypass_timeout;
4688 static const char * const timeouts[RTE_PMD_IXGBE_BYPASS_TMT_NUM] =
4689 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
4690 static const char * const modes[RTE_PMD_IXGBE_BYPASS_MODE_NUM] =
4691 {"UNKNOWN", "normal", "bypass", "isolate"};
4692 static const char * const events[RTE_PMD_IXGBE_BYPASS_EVENT_NUM] = {
4699 int num_events = (sizeof events) / (sizeof events[0]);
4701 /* Display the bypass mode.*/
4702 if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) != 0) {
4703 printf("\tFailed to get bypass mode for port = %d\n", port_id);
4707 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(bypass_mode))
4708 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
4710 printf("\tbypass mode = %s\n", modes[bypass_mode]);
4713 /* Display the bypass timeout.*/
4714 if (!RTE_PMD_IXGBE_BYPASS_TMT_VALID(timeout))
4715 timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
4717 printf("\tbypass timeout = %s\n", timeouts[timeout]);
4719 /* Display the bypass events and associated modes. */
4720 for (i = RTE_PMD_IXGBE_BYPASS_EVENT_START; i < num_events; i++) {
4722 if (rte_pmd_ixgbe_bypass_event_show(port_id, i, &event_mode)) {
4723 printf("\tFailed to get bypass mode for event = %s\n",
4726 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(event_mode))
4727 event_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
4729 printf("\tbypass event: %-16s = %s\n", events[i],
4735 printf("\tFailed to get bypass configuration for port = %d\n",
4739 cmdline_parse_token_string_t cmd_showbypass_config_show =
4740 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4742 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
4743 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4745 cmdline_parse_token_string_t cmd_showbypass_config_config =
4746 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4748 cmdline_parse_token_num_t cmd_showbypass_config_port =
4749 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
4752 cmdline_parse_inst_t cmd_show_bypass_config = {
4753 .f = cmd_show_bypass_config_parsed,
4754 .help_str = "show bypass config <port_id>: "
4755 "Show the NIC bypass config for port_id",
4758 (void *)&cmd_showbypass_config_show,
4759 (void *)&cmd_showbypass_config_bypass,
4760 (void *)&cmd_showbypass_config_config,
4761 (void *)&cmd_showbypass_config_port,
4766 #ifdef RTE_LIBRTE_PMD_BOND
4767 /* *** SET BONDING MODE *** */
4768 struct cmd_set_bonding_mode_result {
4769 cmdline_fixed_string_t set;
4770 cmdline_fixed_string_t bonding;
4771 cmdline_fixed_string_t mode;
4776 static void cmd_set_bonding_mode_parsed(void *parsed_result,
4777 __attribute__((unused)) struct cmdline *cl,
4778 __attribute__((unused)) void *data)
4780 struct cmd_set_bonding_mode_result *res = parsed_result;
4781 portid_t port_id = res->port_id;
4783 /* Set the bonding mode for the relevant port. */
4784 if (0 != rte_eth_bond_mode_set(port_id, res->value))
4785 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
4788 cmdline_parse_token_string_t cmd_setbonding_mode_set =
4789 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4791 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
4792 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4793 bonding, "bonding");
4794 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
4795 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4797 cmdline_parse_token_num_t cmd_setbonding_mode_value =
4798 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
4800 cmdline_parse_token_num_t cmd_setbonding_mode_port =
4801 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
4804 cmdline_parse_inst_t cmd_set_bonding_mode = {
4805 .f = cmd_set_bonding_mode_parsed,
4806 .help_str = "set bonding mode <mode_value> <port_id>: "
4807 "Set the bonding mode for port_id",
4810 (void *) &cmd_setbonding_mode_set,
4811 (void *) &cmd_setbonding_mode_bonding,
4812 (void *) &cmd_setbonding_mode_mode,
4813 (void *) &cmd_setbonding_mode_value,
4814 (void *) &cmd_setbonding_mode_port,
4819 /* *** SET BONDING SLOW_QUEUE SW/HW *** */
4820 struct cmd_set_bonding_lacp_dedicated_queues_result {
4821 cmdline_fixed_string_t set;
4822 cmdline_fixed_string_t bonding;
4823 cmdline_fixed_string_t lacp;
4824 cmdline_fixed_string_t dedicated_queues;
4826 cmdline_fixed_string_t mode;
4829 static void cmd_set_bonding_lacp_dedicated_queues_parsed(void *parsed_result,
4830 __attribute__((unused)) struct cmdline *cl,
4831 __attribute__((unused)) void *data)
4833 struct cmd_set_bonding_lacp_dedicated_queues_result *res = parsed_result;
4834 portid_t port_id = res->port_id;
4835 struct rte_port *port;
4837 port = &ports[port_id];
4839 /** Check if the port is not started **/
4840 if (port->port_status != RTE_PORT_STOPPED) {
4841 printf("Please stop port %d first\n", port_id);
4845 if (!strcmp(res->mode, "enable")) {
4846 if (rte_eth_bond_8023ad_dedicated_queues_enable(port_id) == 0)
4847 printf("Dedicate queues for LACP control packets"
4850 printf("Enabling dedicate queues for LACP control "
4851 "packets on port %d failed\n", port_id);
4852 } else if (!strcmp(res->mode, "disable")) {
4853 if (rte_eth_bond_8023ad_dedicated_queues_disable(port_id) == 0)
4854 printf("Dedicated queues for LACP control packets "
4857 printf("Disabling dedicated queues for LACP control "
4858 "traffic on port %d failed\n", port_id);
4862 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_set =
4863 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4865 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_bonding =
4866 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4867 bonding, "bonding");
4868 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_lacp =
4869 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4871 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_dedicated_queues =
4872 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4873 dedicated_queues, "dedicated_queues");
4874 cmdline_parse_token_num_t cmd_setbonding_lacp_dedicated_queues_port_id =
4875 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4877 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_mode =
4878 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4879 mode, "enable#disable");
4881 cmdline_parse_inst_t cmd_set_lacp_dedicated_queues = {
4882 .f = cmd_set_bonding_lacp_dedicated_queues_parsed,
4883 .help_str = "set bonding lacp dedicated_queues <port_id> "
4885 "Enable/disable dedicated queues for LACP control traffic for port_id",
4888 (void *)&cmd_setbonding_lacp_dedicated_queues_set,
4889 (void *)&cmd_setbonding_lacp_dedicated_queues_bonding,
4890 (void *)&cmd_setbonding_lacp_dedicated_queues_lacp,
4891 (void *)&cmd_setbonding_lacp_dedicated_queues_dedicated_queues,
4892 (void *)&cmd_setbonding_lacp_dedicated_queues_port_id,
4893 (void *)&cmd_setbonding_lacp_dedicated_queues_mode,
4898 /* *** SET BALANCE XMIT POLICY *** */
4899 struct cmd_set_bonding_balance_xmit_policy_result {
4900 cmdline_fixed_string_t set;
4901 cmdline_fixed_string_t bonding;
4902 cmdline_fixed_string_t balance_xmit_policy;
4904 cmdline_fixed_string_t policy;
4907 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
4908 __attribute__((unused)) struct cmdline *cl,
4909 __attribute__((unused)) void *data)
4911 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
4912 portid_t port_id = res->port_id;
4915 if (!strcmp(res->policy, "l2")) {
4916 policy = BALANCE_XMIT_POLICY_LAYER2;
4917 } else if (!strcmp(res->policy, "l23")) {
4918 policy = BALANCE_XMIT_POLICY_LAYER23;
4919 } else if (!strcmp(res->policy, "l34")) {
4920 policy = BALANCE_XMIT_POLICY_LAYER34;
4922 printf("\t Invalid xmit policy selection");
4926 /* Set the bonding mode for the relevant port. */
4927 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
4928 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
4933 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
4934 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4936 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
4937 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4938 bonding, "bonding");
4939 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
4940 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4941 balance_xmit_policy, "balance_xmit_policy");
4942 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
4943 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4945 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
4946 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4947 policy, "l2#l23#l34");
4949 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
4950 .f = cmd_set_bonding_balance_xmit_policy_parsed,
4951 .help_str = "set bonding balance_xmit_policy <port_id> "
4953 "Set the bonding balance_xmit_policy for port_id",
4956 (void *)&cmd_setbonding_balance_xmit_policy_set,
4957 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
4958 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
4959 (void *)&cmd_setbonding_balance_xmit_policy_port,
4960 (void *)&cmd_setbonding_balance_xmit_policy_policy,
4965 /* *** SHOW NIC BONDING CONFIGURATION *** */
4966 struct cmd_show_bonding_config_result {
4967 cmdline_fixed_string_t show;
4968 cmdline_fixed_string_t bonding;
4969 cmdline_fixed_string_t config;
4973 static void cmd_show_bonding_config_parsed(void *parsed_result,
4974 __attribute__((unused)) struct cmdline *cl,
4975 __attribute__((unused)) void *data)
4977 struct cmd_show_bonding_config_result *res = parsed_result;
4978 int bonding_mode, agg_mode;
4979 portid_t slaves[RTE_MAX_ETHPORTS];
4980 int num_slaves, num_active_slaves;
4983 portid_t port_id = res->port_id;
4985 /* Display the bonding mode.*/
4986 bonding_mode = rte_eth_bond_mode_get(port_id);
4987 if (bonding_mode < 0) {
4988 printf("\tFailed to get bonding mode for port = %d\n", port_id);
4991 printf("\tBonding mode: %d\n", bonding_mode);
4993 if (bonding_mode == BONDING_MODE_BALANCE) {
4994 int balance_xmit_policy;
4996 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
4997 if (balance_xmit_policy < 0) {
4998 printf("\tFailed to get balance xmit policy for port = %d\n",
5002 printf("\tBalance Xmit Policy: ");
5004 switch (balance_xmit_policy) {
5005 case BALANCE_XMIT_POLICY_LAYER2:
5006 printf("BALANCE_XMIT_POLICY_LAYER2");
5008 case BALANCE_XMIT_POLICY_LAYER23:
5009 printf("BALANCE_XMIT_POLICY_LAYER23");
5011 case BALANCE_XMIT_POLICY_LAYER34:
5012 printf("BALANCE_XMIT_POLICY_LAYER34");
5019 if (bonding_mode == BONDING_MODE_8023AD) {
5020 agg_mode = rte_eth_bond_8023ad_agg_selection_get(port_id);
5021 printf("\tIEEE802.3AD Aggregator Mode: ");
5024 printf("bandwidth");
5036 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
5038 if (num_slaves < 0) {
5039 printf("\tFailed to get slave list for port = %d\n", port_id);
5042 if (num_slaves > 0) {
5043 printf("\tSlaves (%d): [", num_slaves);
5044 for (i = 0; i < num_slaves - 1; i++)
5045 printf("%d ", slaves[i]);
5047 printf("%d]\n", slaves[num_slaves - 1]);
5049 printf("\tSlaves: []\n");
5053 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
5056 if (num_active_slaves < 0) {
5057 printf("\tFailed to get active slave list for port = %d\n", port_id);
5060 if (num_active_slaves > 0) {
5061 printf("\tActive Slaves (%d): [", num_active_slaves);
5062 for (i = 0; i < num_active_slaves - 1; i++)
5063 printf("%d ", slaves[i]);
5065 printf("%d]\n", slaves[num_active_slaves - 1]);
5068 printf("\tActive Slaves: []\n");
5072 primary_id = rte_eth_bond_primary_get(port_id);
5073 if (primary_id < 0) {
5074 printf("\tFailed to get primary slave for port = %d\n", port_id);
5077 printf("\tPrimary: [%d]\n", primary_id);
5081 cmdline_parse_token_string_t cmd_showbonding_config_show =
5082 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5084 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
5085 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5086 bonding, "bonding");
5087 cmdline_parse_token_string_t cmd_showbonding_config_config =
5088 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5090 cmdline_parse_token_num_t cmd_showbonding_config_port =
5091 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
5094 cmdline_parse_inst_t cmd_show_bonding_config = {
5095 .f = cmd_show_bonding_config_parsed,
5096 .help_str = "show bonding config <port_id>: "
5097 "Show the bonding config for port_id",
5100 (void *)&cmd_showbonding_config_show,
5101 (void *)&cmd_showbonding_config_bonding,
5102 (void *)&cmd_showbonding_config_config,
5103 (void *)&cmd_showbonding_config_port,
5108 /* *** SET BONDING PRIMARY *** */
5109 struct cmd_set_bonding_primary_result {
5110 cmdline_fixed_string_t set;
5111 cmdline_fixed_string_t bonding;
5112 cmdline_fixed_string_t primary;
5117 static void cmd_set_bonding_primary_parsed(void *parsed_result,
5118 __attribute__((unused)) struct cmdline *cl,
5119 __attribute__((unused)) void *data)
5121 struct cmd_set_bonding_primary_result *res = parsed_result;
5122 portid_t master_port_id = res->port_id;
5123 portid_t slave_port_id = res->slave_id;
5125 /* Set the primary slave for a bonded device. */
5126 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
5127 printf("\t Failed to set primary slave for port = %d.\n",
5134 cmdline_parse_token_string_t cmd_setbonding_primary_set =
5135 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5137 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
5138 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5139 bonding, "bonding");
5140 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
5141 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5142 primary, "primary");
5143 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
5144 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
5146 cmdline_parse_token_num_t cmd_setbonding_primary_port =
5147 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
5150 cmdline_parse_inst_t cmd_set_bonding_primary = {
5151 .f = cmd_set_bonding_primary_parsed,
5152 .help_str = "set bonding primary <slave_id> <port_id>: "
5153 "Set the primary slave for port_id",
5156 (void *)&cmd_setbonding_primary_set,
5157 (void *)&cmd_setbonding_primary_bonding,
5158 (void *)&cmd_setbonding_primary_primary,
5159 (void *)&cmd_setbonding_primary_slave,
5160 (void *)&cmd_setbonding_primary_port,
5165 /* *** ADD SLAVE *** */
5166 struct cmd_add_bonding_slave_result {
5167 cmdline_fixed_string_t add;
5168 cmdline_fixed_string_t bonding;
5169 cmdline_fixed_string_t slave;
5174 static void cmd_add_bonding_slave_parsed(void *parsed_result,
5175 __attribute__((unused)) struct cmdline *cl,
5176 __attribute__((unused)) void *data)
5178 struct cmd_add_bonding_slave_result *res = parsed_result;
5179 portid_t master_port_id = res->port_id;
5180 portid_t slave_port_id = res->slave_id;
5182 /* add the slave for a bonded device. */
5183 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
5184 printf("\t Failed to add slave %d to master port = %d.\n",
5185 slave_port_id, master_port_id);
5189 set_port_slave_flag(slave_port_id);
5192 cmdline_parse_token_string_t cmd_addbonding_slave_add =
5193 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5195 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
5196 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5197 bonding, "bonding");
5198 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
5199 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5201 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
5202 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
5204 cmdline_parse_token_num_t cmd_addbonding_slave_port =
5205 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
5208 cmdline_parse_inst_t cmd_add_bonding_slave = {
5209 .f = cmd_add_bonding_slave_parsed,
5210 .help_str = "add bonding slave <slave_id> <port_id>: "
5211 "Add a slave device to a bonded device",
5214 (void *)&cmd_addbonding_slave_add,
5215 (void *)&cmd_addbonding_slave_bonding,
5216 (void *)&cmd_addbonding_slave_slave,
5217 (void *)&cmd_addbonding_slave_slaveid,
5218 (void *)&cmd_addbonding_slave_port,
5223 /* *** REMOVE SLAVE *** */
5224 struct cmd_remove_bonding_slave_result {
5225 cmdline_fixed_string_t remove;
5226 cmdline_fixed_string_t bonding;
5227 cmdline_fixed_string_t slave;
5232 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
5233 __attribute__((unused)) struct cmdline *cl,
5234 __attribute__((unused)) void *data)
5236 struct cmd_remove_bonding_slave_result *res = parsed_result;
5237 portid_t master_port_id = res->port_id;
5238 portid_t slave_port_id = res->slave_id;
5240 /* remove the slave from a bonded device. */
5241 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
5242 printf("\t Failed to remove slave %d from master port = %d.\n",
5243 slave_port_id, master_port_id);
5247 clear_port_slave_flag(slave_port_id);
5250 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
5251 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
5253 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
5254 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
5255 bonding, "bonding");
5256 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
5257 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
5259 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
5260 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
5262 cmdline_parse_token_num_t cmd_removebonding_slave_port =
5263 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
5266 cmdline_parse_inst_t cmd_remove_bonding_slave = {
5267 .f = cmd_remove_bonding_slave_parsed,
5268 .help_str = "remove bonding slave <slave_id> <port_id>: "
5269 "Remove a slave device from a bonded device",
5272 (void *)&cmd_removebonding_slave_remove,
5273 (void *)&cmd_removebonding_slave_bonding,
5274 (void *)&cmd_removebonding_slave_slave,
5275 (void *)&cmd_removebonding_slave_slaveid,
5276 (void *)&cmd_removebonding_slave_port,
5281 /* *** CREATE BONDED DEVICE *** */
5282 struct cmd_create_bonded_device_result {
5283 cmdline_fixed_string_t create;
5284 cmdline_fixed_string_t bonded;
5285 cmdline_fixed_string_t device;
5290 static int bond_dev_num = 0;
5292 static void cmd_create_bonded_device_parsed(void *parsed_result,
5293 __attribute__((unused)) struct cmdline *cl,
5294 __attribute__((unused)) void *data)
5296 struct cmd_create_bonded_device_result *res = parsed_result;
5297 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
5300 if (test_done == 0) {
5301 printf("Please stop forwarding first\n");
5305 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bonding_testpmd_%d",
5308 /* Create a new bonded device. */
5309 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
5311 printf("\t Failed to create bonded device.\n");
5314 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
5317 /* Update number of ports */
5318 nb_ports = rte_eth_dev_count();
5319 reconfig(port_id, res->socket);
5320 rte_eth_promiscuous_enable(port_id);
5325 cmdline_parse_token_string_t cmd_createbonded_device_create =
5326 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
5328 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
5329 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
5331 cmdline_parse_token_string_t cmd_createbonded_device_device =
5332 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
5334 cmdline_parse_token_num_t cmd_createbonded_device_mode =
5335 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
5337 cmdline_parse_token_num_t cmd_createbonded_device_socket =
5338 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
5341 cmdline_parse_inst_t cmd_create_bonded_device = {
5342 .f = cmd_create_bonded_device_parsed,
5343 .help_str = "create bonded device <mode> <socket>: "
5344 "Create a new bonded device with specific bonding mode and socket",
5347 (void *)&cmd_createbonded_device_create,
5348 (void *)&cmd_createbonded_device_bonded,
5349 (void *)&cmd_createbonded_device_device,
5350 (void *)&cmd_createbonded_device_mode,
5351 (void *)&cmd_createbonded_device_socket,
5356 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
5357 struct cmd_set_bond_mac_addr_result {
5358 cmdline_fixed_string_t set;
5359 cmdline_fixed_string_t bonding;
5360 cmdline_fixed_string_t mac_addr;
5362 struct ether_addr address;
5365 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
5366 __attribute__((unused)) struct cmdline *cl,
5367 __attribute__((unused)) void *data)
5369 struct cmd_set_bond_mac_addr_result *res = parsed_result;
5372 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
5375 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
5377 /* check the return value and print it if is < 0 */
5379 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
5382 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
5383 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
5384 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
5385 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
5387 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
5388 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
5390 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
5391 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result,
5393 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
5394 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
5396 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
5397 .f = cmd_set_bond_mac_addr_parsed,
5399 .help_str = "set bonding mac_addr <port_id> <mac_addr>",
5401 (void *)&cmd_set_bond_mac_addr_set,
5402 (void *)&cmd_set_bond_mac_addr_bonding,
5403 (void *)&cmd_set_bond_mac_addr_mac,
5404 (void *)&cmd_set_bond_mac_addr_portnum,
5405 (void *)&cmd_set_bond_mac_addr_addr,
5411 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
5412 struct cmd_set_bond_mon_period_result {
5413 cmdline_fixed_string_t set;
5414 cmdline_fixed_string_t bonding;
5415 cmdline_fixed_string_t mon_period;
5420 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
5421 __attribute__((unused)) struct cmdline *cl,
5422 __attribute__((unused)) void *data)
5424 struct cmd_set_bond_mon_period_result *res = parsed_result;
5427 if (res->port_num >= nb_ports) {
5428 printf("Port id %d must be less than %d\n", res->port_num, nb_ports);
5432 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
5434 /* check the return value and print it if is < 0 */
5436 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
5439 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
5440 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
5442 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
5443 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
5444 bonding, "bonding");
5445 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
5446 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
5447 mon_period, "mon_period");
5448 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
5449 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
5451 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
5452 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
5455 cmdline_parse_inst_t cmd_set_bond_mon_period = {
5456 .f = cmd_set_bond_mon_period_parsed,
5458 .help_str = "set bonding mon_period <port_id> <period_ms>",
5460 (void *)&cmd_set_bond_mon_period_set,
5461 (void *)&cmd_set_bond_mon_period_bonding,
5462 (void *)&cmd_set_bond_mon_period_mon_period,
5463 (void *)&cmd_set_bond_mon_period_portnum,
5464 (void *)&cmd_set_bond_mon_period_period_ms,
5471 struct cmd_set_bonding_agg_mode_policy_result {
5472 cmdline_fixed_string_t set;
5473 cmdline_fixed_string_t bonding;
5474 cmdline_fixed_string_t agg_mode;
5476 cmdline_fixed_string_t policy;
5481 cmd_set_bonding_agg_mode(void *parsed_result,
5482 __attribute__((unused)) struct cmdline *cl,
5483 __attribute__((unused)) void *data)
5485 struct cmd_set_bonding_agg_mode_policy_result *res = parsed_result;
5486 uint8_t policy = AGG_BANDWIDTH;
5488 if (res->port_num >= nb_ports) {
5489 printf("Port id %d must be less than %d\n",
5490 res->port_num, nb_ports);
5494 if (!strcmp(res->policy, "bandwidth"))
5495 policy = AGG_BANDWIDTH;
5496 else if (!strcmp(res->policy, "stable"))
5497 policy = AGG_STABLE;
5498 else if (!strcmp(res->policy, "count"))
5501 rte_eth_bond_8023ad_agg_selection_set(res->port_num, policy);
5505 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_set =
5506 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5508 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_bonding =
5509 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5510 bonding, "bonding");
5512 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_agg_mode =
5513 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5514 agg_mode, "agg_mode");
5516 cmdline_parse_token_num_t cmd_set_bonding_agg_mode_portnum =
5517 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5520 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_policy_string =
5521 TOKEN_STRING_INITIALIZER(
5522 struct cmd_set_bonding_balance_xmit_policy_result,
5523 policy, "stable#bandwidth#count");
5525 cmdline_parse_inst_t cmd_set_bonding_agg_mode_policy = {
5526 .f = cmd_set_bonding_agg_mode,
5528 .help_str = "set bonding mode IEEE802.3AD aggregator policy <port_id> <agg_name>",
5530 (void *)&cmd_set_bonding_agg_mode_set,
5531 (void *)&cmd_set_bonding_agg_mode_bonding,
5532 (void *)&cmd_set_bonding_agg_mode_agg_mode,
5533 (void *)&cmd_set_bonding_agg_mode_portnum,
5534 (void *)&cmd_set_bonding_agg_mode_policy_string,
5540 #endif /* RTE_LIBRTE_PMD_BOND */
5542 /* *** SET FORWARDING MODE *** */
5543 struct cmd_set_fwd_mode_result {
5544 cmdline_fixed_string_t set;
5545 cmdline_fixed_string_t fwd;
5546 cmdline_fixed_string_t mode;
5549 static void cmd_set_fwd_mode_parsed(void *parsed_result,
5550 __attribute__((unused)) struct cmdline *cl,
5551 __attribute__((unused)) void *data)
5553 struct cmd_set_fwd_mode_result *res = parsed_result;
5556 set_pkt_forwarding_mode(res->mode);
5559 cmdline_parse_token_string_t cmd_setfwd_set =
5560 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
5561 cmdline_parse_token_string_t cmd_setfwd_fwd =
5562 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
5563 cmdline_parse_token_string_t cmd_setfwd_mode =
5564 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
5565 "" /* defined at init */);
5567 cmdline_parse_inst_t cmd_set_fwd_mode = {
5568 .f = cmd_set_fwd_mode_parsed,
5570 .help_str = NULL, /* defined at init */
5572 (void *)&cmd_setfwd_set,
5573 (void *)&cmd_setfwd_fwd,
5574 (void *)&cmd_setfwd_mode,
5579 static void cmd_set_fwd_mode_init(void)
5582 static char token[128];
5583 static char help[256];
5584 cmdline_parse_token_string_t *token_struct;
5586 modes = list_pkt_forwarding_modes();
5587 snprintf(help, sizeof(help), "set fwd %s: "
5588 "Set packet forwarding mode", modes);
5589 cmd_set_fwd_mode.help_str = help;
5591 /* string token separator is # */
5592 for (c = token; *modes != '\0'; modes++)
5597 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
5598 token_struct->string_data.str = token;
5601 /* *** SET RETRY FORWARDING MODE *** */
5602 struct cmd_set_fwd_retry_mode_result {
5603 cmdline_fixed_string_t set;
5604 cmdline_fixed_string_t fwd;
5605 cmdline_fixed_string_t mode;
5606 cmdline_fixed_string_t retry;
5609 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
5610 __attribute__((unused)) struct cmdline *cl,
5611 __attribute__((unused)) void *data)
5613 struct cmd_set_fwd_retry_mode_result *res = parsed_result;
5616 set_pkt_forwarding_mode(res->mode);
5619 cmdline_parse_token_string_t cmd_setfwd_retry_set =
5620 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
5622 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
5623 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
5625 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
5626 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
5628 "" /* defined at init */);
5629 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
5630 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
5633 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
5634 .f = cmd_set_fwd_retry_mode_parsed,
5636 .help_str = NULL, /* defined at init */
5638 (void *)&cmd_setfwd_retry_set,
5639 (void *)&cmd_setfwd_retry_fwd,
5640 (void *)&cmd_setfwd_retry_mode,
5641 (void *)&cmd_setfwd_retry_retry,
5646 static void cmd_set_fwd_retry_mode_init(void)
5649 static char token[128];
5650 static char help[256];
5651 cmdline_parse_token_string_t *token_struct;
5653 modes = list_pkt_forwarding_retry_modes();
5654 snprintf(help, sizeof(help), "set fwd %s retry: "
5655 "Set packet forwarding mode with retry", modes);
5656 cmd_set_fwd_retry_mode.help_str = help;
5658 /* string token separator is # */
5659 for (c = token; *modes != '\0'; modes++)
5664 token_struct = (cmdline_parse_token_string_t *)
5665 cmd_set_fwd_retry_mode.tokens[2];
5666 token_struct->string_data.str = token;
5669 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
5670 struct cmd_set_burst_tx_retry_result {
5671 cmdline_fixed_string_t set;
5672 cmdline_fixed_string_t burst;
5673 cmdline_fixed_string_t tx;
5674 cmdline_fixed_string_t delay;
5676 cmdline_fixed_string_t retry;
5680 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
5681 __attribute__((unused)) struct cmdline *cl,
5682 __attribute__((unused)) void *data)
5684 struct cmd_set_burst_tx_retry_result *res = parsed_result;
5686 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
5687 && !strcmp(res->tx, "tx")) {
5688 if (!strcmp(res->delay, "delay"))
5689 burst_tx_delay_time = res->time;
5690 if (!strcmp(res->retry, "retry"))
5691 burst_tx_retry_num = res->retry_num;
5696 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
5697 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
5698 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
5699 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
5701 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
5702 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
5703 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
5704 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
5705 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
5706 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
5707 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
5708 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
5709 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
5710 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
5712 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
5713 .f = cmd_set_burst_tx_retry_parsed,
5714 .help_str = "set burst tx delay <delay_usec> retry <num_retry>",
5716 (void *)&cmd_set_burst_tx_retry_set,
5717 (void *)&cmd_set_burst_tx_retry_burst,
5718 (void *)&cmd_set_burst_tx_retry_tx,
5719 (void *)&cmd_set_burst_tx_retry_delay,
5720 (void *)&cmd_set_burst_tx_retry_time,
5721 (void *)&cmd_set_burst_tx_retry_retry,
5722 (void *)&cmd_set_burst_tx_retry_retry_num,
5727 /* *** SET PROMISC MODE *** */
5728 struct cmd_set_promisc_mode_result {
5729 cmdline_fixed_string_t set;
5730 cmdline_fixed_string_t promisc;
5731 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
5732 uint16_t port_num; /* valid if "allports" argument == 0 */
5733 cmdline_fixed_string_t mode;
5736 static void cmd_set_promisc_mode_parsed(void *parsed_result,
5737 __attribute__((unused)) struct cmdline *cl,
5740 struct cmd_set_promisc_mode_result *res = parsed_result;
5744 if (!strcmp(res->mode, "on"))
5751 RTE_ETH_FOREACH_DEV(i) {
5753 rte_eth_promiscuous_enable(i);
5755 rte_eth_promiscuous_disable(i);
5760 rte_eth_promiscuous_enable(res->port_num);
5762 rte_eth_promiscuous_disable(res->port_num);
5766 cmdline_parse_token_string_t cmd_setpromisc_set =
5767 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
5768 cmdline_parse_token_string_t cmd_setpromisc_promisc =
5769 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
5771 cmdline_parse_token_string_t cmd_setpromisc_portall =
5772 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
5774 cmdline_parse_token_num_t cmd_setpromisc_portnum =
5775 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
5777 cmdline_parse_token_string_t cmd_setpromisc_mode =
5778 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
5781 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
5782 .f = cmd_set_promisc_mode_parsed,
5784 .help_str = "set promisc all on|off: Set promisc mode for all ports",
5786 (void *)&cmd_setpromisc_set,
5787 (void *)&cmd_setpromisc_promisc,
5788 (void *)&cmd_setpromisc_portall,
5789 (void *)&cmd_setpromisc_mode,
5794 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
5795 .f = cmd_set_promisc_mode_parsed,
5797 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
5799 (void *)&cmd_setpromisc_set,
5800 (void *)&cmd_setpromisc_promisc,
5801 (void *)&cmd_setpromisc_portnum,
5802 (void *)&cmd_setpromisc_mode,
5807 /* *** SET ALLMULTI MODE *** */
5808 struct cmd_set_allmulti_mode_result {
5809 cmdline_fixed_string_t set;
5810 cmdline_fixed_string_t allmulti;
5811 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
5812 uint16_t port_num; /* valid if "allports" argument == 0 */
5813 cmdline_fixed_string_t mode;
5816 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
5817 __attribute__((unused)) struct cmdline *cl,
5820 struct cmd_set_allmulti_mode_result *res = parsed_result;
5824 if (!strcmp(res->mode, "on"))
5831 RTE_ETH_FOREACH_DEV(i) {
5833 rte_eth_allmulticast_enable(i);
5835 rte_eth_allmulticast_disable(i);
5840 rte_eth_allmulticast_enable(res->port_num);
5842 rte_eth_allmulticast_disable(res->port_num);
5846 cmdline_parse_token_string_t cmd_setallmulti_set =
5847 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
5848 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
5849 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
5851 cmdline_parse_token_string_t cmd_setallmulti_portall =
5852 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
5854 cmdline_parse_token_num_t cmd_setallmulti_portnum =
5855 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
5857 cmdline_parse_token_string_t cmd_setallmulti_mode =
5858 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
5861 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
5862 .f = cmd_set_allmulti_mode_parsed,
5864 .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
5866 (void *)&cmd_setallmulti_set,
5867 (void *)&cmd_setallmulti_allmulti,
5868 (void *)&cmd_setallmulti_portall,
5869 (void *)&cmd_setallmulti_mode,
5874 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
5875 .f = cmd_set_allmulti_mode_parsed,
5877 .help_str = "set allmulti <port_id> on|off: "
5878 "Set allmulti mode on port_id",
5880 (void *)&cmd_setallmulti_set,
5881 (void *)&cmd_setallmulti_allmulti,
5882 (void *)&cmd_setallmulti_portnum,
5883 (void *)&cmd_setallmulti_mode,
5888 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
5889 struct cmd_link_flow_ctrl_set_result {
5890 cmdline_fixed_string_t set;
5891 cmdline_fixed_string_t flow_ctrl;
5892 cmdline_fixed_string_t rx;
5893 cmdline_fixed_string_t rx_lfc_mode;
5894 cmdline_fixed_string_t tx;
5895 cmdline_fixed_string_t tx_lfc_mode;
5896 cmdline_fixed_string_t mac_ctrl_frame_fwd;
5897 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
5898 cmdline_fixed_string_t autoneg_str;
5899 cmdline_fixed_string_t autoneg;
5900 cmdline_fixed_string_t hw_str;
5901 uint32_t high_water;
5902 cmdline_fixed_string_t lw_str;
5904 cmdline_fixed_string_t pt_str;
5905 uint16_t pause_time;
5906 cmdline_fixed_string_t xon_str;
5911 cmdline_parse_token_string_t cmd_lfc_set_set =
5912 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5914 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
5915 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5916 flow_ctrl, "flow_ctrl");
5917 cmdline_parse_token_string_t cmd_lfc_set_rx =
5918 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5920 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
5921 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5922 rx_lfc_mode, "on#off");
5923 cmdline_parse_token_string_t cmd_lfc_set_tx =
5924 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5926 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
5927 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5928 tx_lfc_mode, "on#off");
5929 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
5930 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5931 hw_str, "high_water");
5932 cmdline_parse_token_num_t cmd_lfc_set_high_water =
5933 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5934 high_water, UINT32);
5935 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
5936 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5937 lw_str, "low_water");
5938 cmdline_parse_token_num_t cmd_lfc_set_low_water =
5939 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5941 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
5942 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5943 pt_str, "pause_time");
5944 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
5945 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5946 pause_time, UINT16);
5947 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
5948 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5949 xon_str, "send_xon");
5950 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
5951 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5953 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
5954 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5955 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
5956 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
5957 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5958 mac_ctrl_frame_fwd_mode, "on#off");
5959 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
5960 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5961 autoneg_str, "autoneg");
5962 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
5963 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5965 cmdline_parse_token_num_t cmd_lfc_set_portid =
5966 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5969 /* forward declaration */
5971 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
5974 cmdline_parse_inst_t cmd_link_flow_control_set = {
5975 .f = cmd_link_flow_ctrl_set_parsed,
5977 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
5978 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
5979 "autoneg on|off <port_id>: Configure the Ethernet flow control",
5981 (void *)&cmd_lfc_set_set,
5982 (void *)&cmd_lfc_set_flow_ctrl,
5983 (void *)&cmd_lfc_set_rx,
5984 (void *)&cmd_lfc_set_rx_mode,
5985 (void *)&cmd_lfc_set_tx,
5986 (void *)&cmd_lfc_set_tx_mode,
5987 (void *)&cmd_lfc_set_high_water,
5988 (void *)&cmd_lfc_set_low_water,
5989 (void *)&cmd_lfc_set_pause_time,
5990 (void *)&cmd_lfc_set_send_xon,
5991 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
5992 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
5993 (void *)&cmd_lfc_set_autoneg_str,
5994 (void *)&cmd_lfc_set_autoneg,
5995 (void *)&cmd_lfc_set_portid,
6000 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
6001 .f = cmd_link_flow_ctrl_set_parsed,
6002 .data = (void *)&cmd_link_flow_control_set_rx,
6003 .help_str = "set flow_ctrl rx on|off <port_id>: "
6004 "Change rx flow control parameter",
6006 (void *)&cmd_lfc_set_set,
6007 (void *)&cmd_lfc_set_flow_ctrl,
6008 (void *)&cmd_lfc_set_rx,
6009 (void *)&cmd_lfc_set_rx_mode,
6010 (void *)&cmd_lfc_set_portid,
6015 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
6016 .f = cmd_link_flow_ctrl_set_parsed,
6017 .data = (void *)&cmd_link_flow_control_set_tx,
6018 .help_str = "set flow_ctrl tx on|off <port_id>: "
6019 "Change tx flow control parameter",
6021 (void *)&cmd_lfc_set_set,
6022 (void *)&cmd_lfc_set_flow_ctrl,
6023 (void *)&cmd_lfc_set_tx,
6024 (void *)&cmd_lfc_set_tx_mode,
6025 (void *)&cmd_lfc_set_portid,
6030 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
6031 .f = cmd_link_flow_ctrl_set_parsed,
6032 .data = (void *)&cmd_link_flow_control_set_hw,
6033 .help_str = "set flow_ctrl high_water <value> <port_id>: "
6034 "Change high water flow control parameter",
6036 (void *)&cmd_lfc_set_set,
6037 (void *)&cmd_lfc_set_flow_ctrl,
6038 (void *)&cmd_lfc_set_high_water_str,
6039 (void *)&cmd_lfc_set_high_water,
6040 (void *)&cmd_lfc_set_portid,
6045 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
6046 .f = cmd_link_flow_ctrl_set_parsed,
6047 .data = (void *)&cmd_link_flow_control_set_lw,
6048 .help_str = "set flow_ctrl low_water <value> <port_id>: "
6049 "Change low water flow control parameter",
6051 (void *)&cmd_lfc_set_set,
6052 (void *)&cmd_lfc_set_flow_ctrl,
6053 (void *)&cmd_lfc_set_low_water_str,
6054 (void *)&cmd_lfc_set_low_water,
6055 (void *)&cmd_lfc_set_portid,
6060 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
6061 .f = cmd_link_flow_ctrl_set_parsed,
6062 .data = (void *)&cmd_link_flow_control_set_pt,
6063 .help_str = "set flow_ctrl pause_time <value> <port_id>: "
6064 "Change pause time flow control parameter",
6066 (void *)&cmd_lfc_set_set,
6067 (void *)&cmd_lfc_set_flow_ctrl,
6068 (void *)&cmd_lfc_set_pause_time_str,
6069 (void *)&cmd_lfc_set_pause_time,
6070 (void *)&cmd_lfc_set_portid,
6075 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
6076 .f = cmd_link_flow_ctrl_set_parsed,
6077 .data = (void *)&cmd_link_flow_control_set_xon,
6078 .help_str = "set flow_ctrl send_xon <value> <port_id>: "
6079 "Change send_xon flow control parameter",
6081 (void *)&cmd_lfc_set_set,
6082 (void *)&cmd_lfc_set_flow_ctrl,
6083 (void *)&cmd_lfc_set_send_xon_str,
6084 (void *)&cmd_lfc_set_send_xon,
6085 (void *)&cmd_lfc_set_portid,
6090 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
6091 .f = cmd_link_flow_ctrl_set_parsed,
6092 .data = (void *)&cmd_link_flow_control_set_macfwd,
6093 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
6094 "Change mac ctrl fwd flow control parameter",
6096 (void *)&cmd_lfc_set_set,
6097 (void *)&cmd_lfc_set_flow_ctrl,
6098 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6099 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6100 (void *)&cmd_lfc_set_portid,
6105 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
6106 .f = cmd_link_flow_ctrl_set_parsed,
6107 .data = (void *)&cmd_link_flow_control_set_autoneg,
6108 .help_str = "set flow_ctrl autoneg on|off <port_id>: "
6109 "Change autoneg flow control parameter",
6111 (void *)&cmd_lfc_set_set,
6112 (void *)&cmd_lfc_set_flow_ctrl,
6113 (void *)&cmd_lfc_set_autoneg_str,
6114 (void *)&cmd_lfc_set_autoneg,
6115 (void *)&cmd_lfc_set_portid,
6121 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
6122 __attribute__((unused)) struct cmdline *cl,
6125 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
6126 cmdline_parse_inst_t *cmd = data;
6127 struct rte_eth_fc_conf fc_conf;
6133 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
6134 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
6135 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
6136 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
6138 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
6139 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
6142 /* Partial command line, retrieve current configuration */
6144 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
6146 printf("cannot get current flow ctrl parameters, return"
6147 "code = %d\n", ret);
6151 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
6152 (fc_conf.mode == RTE_FC_FULL))
6154 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
6155 (fc_conf.mode == RTE_FC_FULL))
6159 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
6160 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
6162 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
6163 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
6165 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
6167 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
6168 fc_conf.high_water = res->high_water;
6170 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
6171 fc_conf.low_water = res->low_water;
6173 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
6174 fc_conf.pause_time = res->pause_time;
6176 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
6177 fc_conf.send_xon = res->send_xon;
6179 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
6180 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
6181 fc_conf.mac_ctrl_frame_fwd = 1;
6183 fc_conf.mac_ctrl_frame_fwd = 0;
6186 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
6187 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
6189 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
6191 printf("bad flow contrl parameter, return code = %d \n", ret);
6194 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
6195 struct cmd_priority_flow_ctrl_set_result {
6196 cmdline_fixed_string_t set;
6197 cmdline_fixed_string_t pfc_ctrl;
6198 cmdline_fixed_string_t rx;
6199 cmdline_fixed_string_t rx_pfc_mode;
6200 cmdline_fixed_string_t tx;
6201 cmdline_fixed_string_t tx_pfc_mode;
6202 uint32_t high_water;
6204 uint16_t pause_time;
6210 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
6211 __attribute__((unused)) struct cmdline *cl,
6212 __attribute__((unused)) void *data)
6214 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
6215 struct rte_eth_pfc_conf pfc_conf;
6216 int rx_fc_enable, tx_fc_enable;
6220 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
6221 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
6222 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
6223 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
6225 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
6226 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
6229 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
6230 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
6231 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
6232 pfc_conf.fc.high_water = res->high_water;
6233 pfc_conf.fc.low_water = res->low_water;
6234 pfc_conf.fc.pause_time = res->pause_time;
6235 pfc_conf.priority = res->priority;
6237 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
6239 printf("bad priority flow contrl parameter, return code = %d \n", ret);
6242 cmdline_parse_token_string_t cmd_pfc_set_set =
6243 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6245 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
6246 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6247 pfc_ctrl, "pfc_ctrl");
6248 cmdline_parse_token_string_t cmd_pfc_set_rx =
6249 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6251 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
6252 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6253 rx_pfc_mode, "on#off");
6254 cmdline_parse_token_string_t cmd_pfc_set_tx =
6255 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6257 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
6258 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6259 tx_pfc_mode, "on#off");
6260 cmdline_parse_token_num_t cmd_pfc_set_high_water =
6261 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6262 high_water, UINT32);
6263 cmdline_parse_token_num_t cmd_pfc_set_low_water =
6264 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6266 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
6267 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6268 pause_time, UINT16);
6269 cmdline_parse_token_num_t cmd_pfc_set_priority =
6270 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6272 cmdline_parse_token_num_t cmd_pfc_set_portid =
6273 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6276 cmdline_parse_inst_t cmd_priority_flow_control_set = {
6277 .f = cmd_priority_flow_ctrl_set_parsed,
6279 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
6280 "<pause_time> <priority> <port_id>: "
6281 "Configure the Ethernet priority flow control",
6283 (void *)&cmd_pfc_set_set,
6284 (void *)&cmd_pfc_set_flow_ctrl,
6285 (void *)&cmd_pfc_set_rx,
6286 (void *)&cmd_pfc_set_rx_mode,
6287 (void *)&cmd_pfc_set_tx,
6288 (void *)&cmd_pfc_set_tx_mode,
6289 (void *)&cmd_pfc_set_high_water,
6290 (void *)&cmd_pfc_set_low_water,
6291 (void *)&cmd_pfc_set_pause_time,
6292 (void *)&cmd_pfc_set_priority,
6293 (void *)&cmd_pfc_set_portid,
6298 /* *** RESET CONFIGURATION *** */
6299 struct cmd_reset_result {
6300 cmdline_fixed_string_t reset;
6301 cmdline_fixed_string_t def;
6304 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
6306 __attribute__((unused)) void *data)
6308 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
6309 set_def_fwd_config();
6312 cmdline_parse_token_string_t cmd_reset_set =
6313 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
6314 cmdline_parse_token_string_t cmd_reset_def =
6315 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
6318 cmdline_parse_inst_t cmd_reset = {
6319 .f = cmd_reset_parsed,
6321 .help_str = "set default: Reset default forwarding configuration",
6323 (void *)&cmd_reset_set,
6324 (void *)&cmd_reset_def,
6329 /* *** START FORWARDING *** */
6330 struct cmd_start_result {
6331 cmdline_fixed_string_t start;
6334 cmdline_parse_token_string_t cmd_start_start =
6335 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
6337 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
6338 __attribute__((unused)) struct cmdline *cl,
6339 __attribute__((unused)) void *data)
6341 start_packet_forwarding(0);
6344 cmdline_parse_inst_t cmd_start = {
6345 .f = cmd_start_parsed,
6347 .help_str = "start: Start packet forwarding",
6349 (void *)&cmd_start_start,
6354 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
6355 struct cmd_start_tx_first_result {
6356 cmdline_fixed_string_t start;
6357 cmdline_fixed_string_t tx_first;
6361 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
6362 __attribute__((unused)) struct cmdline *cl,
6363 __attribute__((unused)) void *data)
6365 start_packet_forwarding(1);
6368 cmdline_parse_token_string_t cmd_start_tx_first_start =
6369 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
6371 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
6372 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
6373 tx_first, "tx_first");
6375 cmdline_parse_inst_t cmd_start_tx_first = {
6376 .f = cmd_start_tx_first_parsed,
6378 .help_str = "start tx_first: Start packet forwarding, "
6379 "after sending 1 burst of packets",
6381 (void *)&cmd_start_tx_first_start,
6382 (void *)&cmd_start_tx_first_tx_first,
6387 /* *** START FORWARDING WITH N TX BURST FIRST *** */
6388 struct cmd_start_tx_first_n_result {
6389 cmdline_fixed_string_t start;
6390 cmdline_fixed_string_t tx_first;
6395 cmd_start_tx_first_n_parsed(void *parsed_result,
6396 __attribute__((unused)) struct cmdline *cl,
6397 __attribute__((unused)) void *data)
6399 struct cmd_start_tx_first_n_result *res = parsed_result;
6401 start_packet_forwarding(res->tx_num);
6404 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
6405 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
6407 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
6408 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
6409 tx_first, "tx_first");
6410 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
6411 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
6414 cmdline_parse_inst_t cmd_start_tx_first_n = {
6415 .f = cmd_start_tx_first_n_parsed,
6417 .help_str = "start tx_first <num>: "
6418 "packet forwarding, after sending <num> bursts of packets",
6420 (void *)&cmd_start_tx_first_n_start,
6421 (void *)&cmd_start_tx_first_n_tx_first,
6422 (void *)&cmd_start_tx_first_n_tx_num,
6427 /* *** SET LINK UP *** */
6428 struct cmd_set_link_up_result {
6429 cmdline_fixed_string_t set;
6430 cmdline_fixed_string_t link_up;
6431 cmdline_fixed_string_t port;
6435 cmdline_parse_token_string_t cmd_set_link_up_set =
6436 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
6437 cmdline_parse_token_string_t cmd_set_link_up_link_up =
6438 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
6440 cmdline_parse_token_string_t cmd_set_link_up_port =
6441 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
6442 cmdline_parse_token_num_t cmd_set_link_up_port_id =
6443 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT16);
6445 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result,
6446 __attribute__((unused)) struct cmdline *cl,
6447 __attribute__((unused)) void *data)
6449 struct cmd_set_link_up_result *res = parsed_result;
6450 dev_set_link_up(res->port_id);
6453 cmdline_parse_inst_t cmd_set_link_up = {
6454 .f = cmd_set_link_up_parsed,
6456 .help_str = "set link-up port <port id>",
6458 (void *)&cmd_set_link_up_set,
6459 (void *)&cmd_set_link_up_link_up,
6460 (void *)&cmd_set_link_up_port,
6461 (void *)&cmd_set_link_up_port_id,
6466 /* *** SET LINK DOWN *** */
6467 struct cmd_set_link_down_result {
6468 cmdline_fixed_string_t set;
6469 cmdline_fixed_string_t link_down;
6470 cmdline_fixed_string_t port;
6474 cmdline_parse_token_string_t cmd_set_link_down_set =
6475 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
6476 cmdline_parse_token_string_t cmd_set_link_down_link_down =
6477 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
6479 cmdline_parse_token_string_t cmd_set_link_down_port =
6480 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
6481 cmdline_parse_token_num_t cmd_set_link_down_port_id =
6482 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT16);
6484 static void cmd_set_link_down_parsed(
6485 __attribute__((unused)) void *parsed_result,
6486 __attribute__((unused)) struct cmdline *cl,
6487 __attribute__((unused)) void *data)
6489 struct cmd_set_link_down_result *res = parsed_result;
6490 dev_set_link_down(res->port_id);
6493 cmdline_parse_inst_t cmd_set_link_down = {
6494 .f = cmd_set_link_down_parsed,
6496 .help_str = "set link-down port <port id>",
6498 (void *)&cmd_set_link_down_set,
6499 (void *)&cmd_set_link_down_link_down,
6500 (void *)&cmd_set_link_down_port,
6501 (void *)&cmd_set_link_down_port_id,
6506 /* *** SHOW CFG *** */
6507 struct cmd_showcfg_result {
6508 cmdline_fixed_string_t show;
6509 cmdline_fixed_string_t cfg;
6510 cmdline_fixed_string_t what;
6513 static void cmd_showcfg_parsed(void *parsed_result,
6514 __attribute__((unused)) struct cmdline *cl,
6515 __attribute__((unused)) void *data)
6517 struct cmd_showcfg_result *res = parsed_result;
6518 if (!strcmp(res->what, "rxtx"))
6519 rxtx_config_display();
6520 else if (!strcmp(res->what, "cores"))
6521 fwd_lcores_config_display();
6522 else if (!strcmp(res->what, "fwd"))
6523 pkt_fwd_config_display(&cur_fwd_config);
6524 else if (!strcmp(res->what, "txpkts"))
6525 show_tx_pkt_segments();
6528 cmdline_parse_token_string_t cmd_showcfg_show =
6529 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
6530 cmdline_parse_token_string_t cmd_showcfg_port =
6531 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
6532 cmdline_parse_token_string_t cmd_showcfg_what =
6533 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
6534 "rxtx#cores#fwd#txpkts");
6536 cmdline_parse_inst_t cmd_showcfg = {
6537 .f = cmd_showcfg_parsed,
6539 .help_str = "show config rxtx|cores|fwd|txpkts",
6541 (void *)&cmd_showcfg_show,
6542 (void *)&cmd_showcfg_port,
6543 (void *)&cmd_showcfg_what,
6548 /* *** SHOW ALL PORT INFO *** */
6549 struct cmd_showportall_result {
6550 cmdline_fixed_string_t show;
6551 cmdline_fixed_string_t port;
6552 cmdline_fixed_string_t what;
6553 cmdline_fixed_string_t all;
6556 static void cmd_showportall_parsed(void *parsed_result,
6557 __attribute__((unused)) struct cmdline *cl,
6558 __attribute__((unused)) void *data)
6562 struct cmd_showportall_result *res = parsed_result;
6563 if (!strcmp(res->show, "clear")) {
6564 if (!strcmp(res->what, "stats"))
6565 RTE_ETH_FOREACH_DEV(i)
6567 else if (!strcmp(res->what, "xstats"))
6568 RTE_ETH_FOREACH_DEV(i)
6569 nic_xstats_clear(i);
6570 } else if (!strcmp(res->what, "info"))
6571 RTE_ETH_FOREACH_DEV(i)
6572 port_infos_display(i);
6573 else if (!strcmp(res->what, "stats"))
6574 RTE_ETH_FOREACH_DEV(i)
6575 nic_stats_display(i);
6576 else if (!strcmp(res->what, "xstats"))
6577 RTE_ETH_FOREACH_DEV(i)
6578 nic_xstats_display(i);
6579 else if (!strcmp(res->what, "fdir"))
6580 RTE_ETH_FOREACH_DEV(i)
6582 else if (!strcmp(res->what, "stat_qmap"))
6583 RTE_ETH_FOREACH_DEV(i)
6584 nic_stats_mapping_display(i);
6585 else if (!strcmp(res->what, "dcb_tc"))
6586 RTE_ETH_FOREACH_DEV(i)
6587 port_dcb_info_display(i);
6588 else if (!strcmp(res->what, "cap"))
6589 RTE_ETH_FOREACH_DEV(i)
6590 port_offload_cap_display(i);
6593 cmdline_parse_token_string_t cmd_showportall_show =
6594 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
6596 cmdline_parse_token_string_t cmd_showportall_port =
6597 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
6598 cmdline_parse_token_string_t cmd_showportall_what =
6599 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
6600 "info#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
6601 cmdline_parse_token_string_t cmd_showportall_all =
6602 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
6603 cmdline_parse_inst_t cmd_showportall = {
6604 .f = cmd_showportall_parsed,
6606 .help_str = "show|clear port "
6607 "info|stats|xstats|fdir|stat_qmap|dcb_tc|cap all",
6609 (void *)&cmd_showportall_show,
6610 (void *)&cmd_showportall_port,
6611 (void *)&cmd_showportall_what,
6612 (void *)&cmd_showportall_all,
6617 /* *** SHOW PORT INFO *** */
6618 struct cmd_showport_result {
6619 cmdline_fixed_string_t show;
6620 cmdline_fixed_string_t port;
6621 cmdline_fixed_string_t what;
6625 static void cmd_showport_parsed(void *parsed_result,
6626 __attribute__((unused)) struct cmdline *cl,
6627 __attribute__((unused)) void *data)
6629 struct cmd_showport_result *res = parsed_result;
6630 if (!strcmp(res->show, "clear")) {
6631 if (!strcmp(res->what, "stats"))
6632 nic_stats_clear(res->portnum);
6633 else if (!strcmp(res->what, "xstats"))
6634 nic_xstats_clear(res->portnum);
6635 } else if (!strcmp(res->what, "info"))
6636 port_infos_display(res->portnum);
6637 else if (!strcmp(res->what, "stats"))
6638 nic_stats_display(res->portnum);
6639 else if (!strcmp(res->what, "xstats"))
6640 nic_xstats_display(res->portnum);
6641 else if (!strcmp(res->what, "fdir"))
6642 fdir_get_infos(res->portnum);
6643 else if (!strcmp(res->what, "stat_qmap"))
6644 nic_stats_mapping_display(res->portnum);
6645 else if (!strcmp(res->what, "dcb_tc"))
6646 port_dcb_info_display(res->portnum);
6647 else if (!strcmp(res->what, "cap"))
6648 port_offload_cap_display(res->portnum);
6651 cmdline_parse_token_string_t cmd_showport_show =
6652 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
6654 cmdline_parse_token_string_t cmd_showport_port =
6655 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
6656 cmdline_parse_token_string_t cmd_showport_what =
6657 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
6658 "info#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
6659 cmdline_parse_token_num_t cmd_showport_portnum =
6660 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT16);
6662 cmdline_parse_inst_t cmd_showport = {
6663 .f = cmd_showport_parsed,
6665 .help_str = "show|clear port "
6666 "info|stats|xstats|fdir|stat_qmap|dcb_tc|cap "
6669 (void *)&cmd_showport_show,
6670 (void *)&cmd_showport_port,
6671 (void *)&cmd_showport_what,
6672 (void *)&cmd_showport_portnum,
6677 /* *** SHOW QUEUE INFO *** */
6678 struct cmd_showqueue_result {
6679 cmdline_fixed_string_t show;
6680 cmdline_fixed_string_t type;
6681 cmdline_fixed_string_t what;
6687 cmd_showqueue_parsed(void *parsed_result,
6688 __attribute__((unused)) struct cmdline *cl,
6689 __attribute__((unused)) void *data)
6691 struct cmd_showqueue_result *res = parsed_result;
6693 if (!strcmp(res->type, "rxq"))
6694 rx_queue_infos_display(res->portnum, res->queuenum);
6695 else if (!strcmp(res->type, "txq"))
6696 tx_queue_infos_display(res->portnum, res->queuenum);
6699 cmdline_parse_token_string_t cmd_showqueue_show =
6700 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
6701 cmdline_parse_token_string_t cmd_showqueue_type =
6702 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
6703 cmdline_parse_token_string_t cmd_showqueue_what =
6704 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
6705 cmdline_parse_token_num_t cmd_showqueue_portnum =
6706 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, UINT16);
6707 cmdline_parse_token_num_t cmd_showqueue_queuenum =
6708 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, UINT16);
6710 cmdline_parse_inst_t cmd_showqueue = {
6711 .f = cmd_showqueue_parsed,
6713 .help_str = "show rxq|txq info <port_id> <queue_id>",
6715 (void *)&cmd_showqueue_show,
6716 (void *)&cmd_showqueue_type,
6717 (void *)&cmd_showqueue_what,
6718 (void *)&cmd_showqueue_portnum,
6719 (void *)&cmd_showqueue_queuenum,
6724 /* *** READ PORT REGISTER *** */
6725 struct cmd_read_reg_result {
6726 cmdline_fixed_string_t read;
6727 cmdline_fixed_string_t reg;
6733 cmd_read_reg_parsed(void *parsed_result,
6734 __attribute__((unused)) struct cmdline *cl,
6735 __attribute__((unused)) void *data)
6737 struct cmd_read_reg_result *res = parsed_result;
6738 port_reg_display(res->port_id, res->reg_off);
6741 cmdline_parse_token_string_t cmd_read_reg_read =
6742 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
6743 cmdline_parse_token_string_t cmd_read_reg_reg =
6744 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
6745 cmdline_parse_token_num_t cmd_read_reg_port_id =
6746 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT16);
6747 cmdline_parse_token_num_t cmd_read_reg_reg_off =
6748 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
6750 cmdline_parse_inst_t cmd_read_reg = {
6751 .f = cmd_read_reg_parsed,
6753 .help_str = "read reg <port_id> <reg_off>",
6755 (void *)&cmd_read_reg_read,
6756 (void *)&cmd_read_reg_reg,
6757 (void *)&cmd_read_reg_port_id,
6758 (void *)&cmd_read_reg_reg_off,
6763 /* *** READ PORT REGISTER BIT FIELD *** */
6764 struct cmd_read_reg_bit_field_result {
6765 cmdline_fixed_string_t read;
6766 cmdline_fixed_string_t regfield;
6774 cmd_read_reg_bit_field_parsed(void *parsed_result,
6775 __attribute__((unused)) struct cmdline *cl,
6776 __attribute__((unused)) void *data)
6778 struct cmd_read_reg_bit_field_result *res = parsed_result;
6779 port_reg_bit_field_display(res->port_id, res->reg_off,
6780 res->bit1_pos, res->bit2_pos);
6783 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
6784 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
6786 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
6787 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
6788 regfield, "regfield");
6789 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
6790 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
6792 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
6793 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
6795 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
6796 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
6798 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
6799 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
6802 cmdline_parse_inst_t cmd_read_reg_bit_field = {
6803 .f = cmd_read_reg_bit_field_parsed,
6805 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
6806 "Read register bit field between bit_x and bit_y included",
6808 (void *)&cmd_read_reg_bit_field_read,
6809 (void *)&cmd_read_reg_bit_field_regfield,
6810 (void *)&cmd_read_reg_bit_field_port_id,
6811 (void *)&cmd_read_reg_bit_field_reg_off,
6812 (void *)&cmd_read_reg_bit_field_bit1_pos,
6813 (void *)&cmd_read_reg_bit_field_bit2_pos,
6818 /* *** READ PORT REGISTER BIT *** */
6819 struct cmd_read_reg_bit_result {
6820 cmdline_fixed_string_t read;
6821 cmdline_fixed_string_t regbit;
6828 cmd_read_reg_bit_parsed(void *parsed_result,
6829 __attribute__((unused)) struct cmdline *cl,
6830 __attribute__((unused)) void *data)
6832 struct cmd_read_reg_bit_result *res = parsed_result;
6833 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
6836 cmdline_parse_token_string_t cmd_read_reg_bit_read =
6837 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
6838 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
6839 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
6841 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
6842 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT16);
6843 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
6844 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
6845 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
6846 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
6848 cmdline_parse_inst_t cmd_read_reg_bit = {
6849 .f = cmd_read_reg_bit_parsed,
6851 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
6853 (void *)&cmd_read_reg_bit_read,
6854 (void *)&cmd_read_reg_bit_regbit,
6855 (void *)&cmd_read_reg_bit_port_id,
6856 (void *)&cmd_read_reg_bit_reg_off,
6857 (void *)&cmd_read_reg_bit_bit_pos,
6862 /* *** WRITE PORT REGISTER *** */
6863 struct cmd_write_reg_result {
6864 cmdline_fixed_string_t write;
6865 cmdline_fixed_string_t reg;
6872 cmd_write_reg_parsed(void *parsed_result,
6873 __attribute__((unused)) struct cmdline *cl,
6874 __attribute__((unused)) void *data)
6876 struct cmd_write_reg_result *res = parsed_result;
6877 port_reg_set(res->port_id, res->reg_off, res->value);
6880 cmdline_parse_token_string_t cmd_write_reg_write =
6881 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
6882 cmdline_parse_token_string_t cmd_write_reg_reg =
6883 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
6884 cmdline_parse_token_num_t cmd_write_reg_port_id =
6885 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT16);
6886 cmdline_parse_token_num_t cmd_write_reg_reg_off =
6887 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
6888 cmdline_parse_token_num_t cmd_write_reg_value =
6889 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
6891 cmdline_parse_inst_t cmd_write_reg = {
6892 .f = cmd_write_reg_parsed,
6894 .help_str = "write reg <port_id> <reg_off> <reg_value>",
6896 (void *)&cmd_write_reg_write,
6897 (void *)&cmd_write_reg_reg,
6898 (void *)&cmd_write_reg_port_id,
6899 (void *)&cmd_write_reg_reg_off,
6900 (void *)&cmd_write_reg_value,
6905 /* *** WRITE PORT REGISTER BIT FIELD *** */
6906 struct cmd_write_reg_bit_field_result {
6907 cmdline_fixed_string_t write;
6908 cmdline_fixed_string_t regfield;
6917 cmd_write_reg_bit_field_parsed(void *parsed_result,
6918 __attribute__((unused)) struct cmdline *cl,
6919 __attribute__((unused)) void *data)
6921 struct cmd_write_reg_bit_field_result *res = parsed_result;
6922 port_reg_bit_field_set(res->port_id, res->reg_off,
6923 res->bit1_pos, res->bit2_pos, res->value);
6926 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
6927 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
6929 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
6930 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
6931 regfield, "regfield");
6932 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
6933 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
6935 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
6936 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
6938 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
6939 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
6941 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
6942 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
6944 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
6945 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
6948 cmdline_parse_inst_t cmd_write_reg_bit_field = {
6949 .f = cmd_write_reg_bit_field_parsed,
6951 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
6953 "Set register bit field between bit_x and bit_y included",
6955 (void *)&cmd_write_reg_bit_field_write,
6956 (void *)&cmd_write_reg_bit_field_regfield,
6957 (void *)&cmd_write_reg_bit_field_port_id,
6958 (void *)&cmd_write_reg_bit_field_reg_off,
6959 (void *)&cmd_write_reg_bit_field_bit1_pos,
6960 (void *)&cmd_write_reg_bit_field_bit2_pos,
6961 (void *)&cmd_write_reg_bit_field_value,
6966 /* *** WRITE PORT REGISTER BIT *** */
6967 struct cmd_write_reg_bit_result {
6968 cmdline_fixed_string_t write;
6969 cmdline_fixed_string_t regbit;
6977 cmd_write_reg_bit_parsed(void *parsed_result,
6978 __attribute__((unused)) struct cmdline *cl,
6979 __attribute__((unused)) void *data)
6981 struct cmd_write_reg_bit_result *res = parsed_result;
6982 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
6985 cmdline_parse_token_string_t cmd_write_reg_bit_write =
6986 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
6988 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
6989 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
6991 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
6992 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT16);
6993 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
6994 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
6995 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
6996 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
6997 cmdline_parse_token_num_t cmd_write_reg_bit_value =
6998 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
7000 cmdline_parse_inst_t cmd_write_reg_bit = {
7001 .f = cmd_write_reg_bit_parsed,
7003 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
7006 (void *)&cmd_write_reg_bit_write,
7007 (void *)&cmd_write_reg_bit_regbit,
7008 (void *)&cmd_write_reg_bit_port_id,
7009 (void *)&cmd_write_reg_bit_reg_off,
7010 (void *)&cmd_write_reg_bit_bit_pos,
7011 (void *)&cmd_write_reg_bit_value,
7016 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
7017 struct cmd_read_rxd_txd_result {
7018 cmdline_fixed_string_t read;
7019 cmdline_fixed_string_t rxd_txd;
7026 cmd_read_rxd_txd_parsed(void *parsed_result,
7027 __attribute__((unused)) struct cmdline *cl,
7028 __attribute__((unused)) void *data)
7030 struct cmd_read_rxd_txd_result *res = parsed_result;
7032 if (!strcmp(res->rxd_txd, "rxd"))
7033 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
7034 else if (!strcmp(res->rxd_txd, "txd"))
7035 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
7038 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
7039 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
7040 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
7041 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
7043 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
7044 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT16);
7045 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
7046 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
7047 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
7048 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
7050 cmdline_parse_inst_t cmd_read_rxd_txd = {
7051 .f = cmd_read_rxd_txd_parsed,
7053 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
7055 (void *)&cmd_read_rxd_txd_read,
7056 (void *)&cmd_read_rxd_txd_rxd_txd,
7057 (void *)&cmd_read_rxd_txd_port_id,
7058 (void *)&cmd_read_rxd_txd_queue_id,
7059 (void *)&cmd_read_rxd_txd_desc_id,
7065 struct cmd_quit_result {
7066 cmdline_fixed_string_t quit;
7069 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
7071 __attribute__((unused)) void *data)
7077 cmdline_parse_token_string_t cmd_quit_quit =
7078 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
7080 cmdline_parse_inst_t cmd_quit = {
7081 .f = cmd_quit_parsed,
7083 .help_str = "quit: Exit application",
7085 (void *)&cmd_quit_quit,
7090 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
7091 struct cmd_mac_addr_result {
7092 cmdline_fixed_string_t mac_addr_cmd;
7093 cmdline_fixed_string_t what;
7095 struct ether_addr address;
7098 static void cmd_mac_addr_parsed(void *parsed_result,
7099 __attribute__((unused)) struct cmdline *cl,
7100 __attribute__((unused)) void *data)
7102 struct cmd_mac_addr_result *res = parsed_result;
7105 if (strcmp(res->what, "add") == 0)
7106 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
7107 else if (strcmp(res->what, "set") == 0)
7108 ret = rte_eth_dev_default_mac_addr_set(res->port_num,
7111 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
7113 /* check the return value and print it if is < 0 */
7115 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
7119 cmdline_parse_token_string_t cmd_mac_addr_cmd =
7120 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
7122 cmdline_parse_token_string_t cmd_mac_addr_what =
7123 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
7125 cmdline_parse_token_num_t cmd_mac_addr_portnum =
7126 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num,
7128 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
7129 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
7131 cmdline_parse_inst_t cmd_mac_addr = {
7132 .f = cmd_mac_addr_parsed,
7134 .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
7135 "Add/Remove/Set MAC address on port_id",
7137 (void *)&cmd_mac_addr_cmd,
7138 (void *)&cmd_mac_addr_what,
7139 (void *)&cmd_mac_addr_portnum,
7140 (void *)&cmd_mac_addr_addr,
7146 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
7147 struct cmd_set_qmap_result {
7148 cmdline_fixed_string_t set;
7149 cmdline_fixed_string_t qmap;
7150 cmdline_fixed_string_t what;
7157 cmd_set_qmap_parsed(void *parsed_result,
7158 __attribute__((unused)) struct cmdline *cl,
7159 __attribute__((unused)) void *data)
7161 struct cmd_set_qmap_result *res = parsed_result;
7162 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
7164 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
7167 cmdline_parse_token_string_t cmd_setqmap_set =
7168 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7170 cmdline_parse_token_string_t cmd_setqmap_qmap =
7171 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7173 cmdline_parse_token_string_t cmd_setqmap_what =
7174 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7176 cmdline_parse_token_num_t cmd_setqmap_portid =
7177 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7179 cmdline_parse_token_num_t cmd_setqmap_queueid =
7180 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7182 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
7183 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7186 cmdline_parse_inst_t cmd_set_qmap = {
7187 .f = cmd_set_qmap_parsed,
7189 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
7190 "Set statistics mapping value on tx|rx queue_id of port_id",
7192 (void *)&cmd_setqmap_set,
7193 (void *)&cmd_setqmap_qmap,
7194 (void *)&cmd_setqmap_what,
7195 (void *)&cmd_setqmap_portid,
7196 (void *)&cmd_setqmap_queueid,
7197 (void *)&cmd_setqmap_mapvalue,
7202 /* *** SET OPTION TO HIDE ZERO VALUES FOR XSTATS DISPLAY *** */
7203 struct cmd_set_xstats_hide_zero_result {
7204 cmdline_fixed_string_t keyword;
7205 cmdline_fixed_string_t name;
7206 cmdline_fixed_string_t on_off;
7210 cmd_set_xstats_hide_zero_parsed(void *parsed_result,
7211 __attribute__((unused)) struct cmdline *cl,
7212 __attribute__((unused)) void *data)
7214 struct cmd_set_xstats_hide_zero_result *res;
7215 uint16_t on_off = 0;
7217 res = parsed_result;
7218 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
7219 set_xstats_hide_zero(on_off);
7222 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_keyword =
7223 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
7225 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_name =
7226 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
7227 name, "xstats-hide-zero");
7228 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_on_off =
7229 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
7232 cmdline_parse_inst_t cmd_set_xstats_hide_zero = {
7233 .f = cmd_set_xstats_hide_zero_parsed,
7235 .help_str = "set xstats-hide-zero on|off",
7237 (void *)&cmd_set_xstats_hide_zero_keyword,
7238 (void *)&cmd_set_xstats_hide_zero_name,
7239 (void *)&cmd_set_xstats_hide_zero_on_off,
7244 /* *** CONFIGURE UNICAST HASH TABLE *** */
7245 struct cmd_set_uc_hash_table {
7246 cmdline_fixed_string_t set;
7247 cmdline_fixed_string_t port;
7249 cmdline_fixed_string_t what;
7250 struct ether_addr address;
7251 cmdline_fixed_string_t mode;
7255 cmd_set_uc_hash_parsed(void *parsed_result,
7256 __attribute__((unused)) struct cmdline *cl,
7257 __attribute__((unused)) void *data)
7260 struct cmd_set_uc_hash_table *res = parsed_result;
7262 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7264 if (strcmp(res->what, "uta") == 0)
7265 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
7266 &res->address,(uint8_t)is_on);
7268 printf("bad unicast hash table parameter, return code = %d \n", ret);
7272 cmdline_parse_token_string_t cmd_set_uc_hash_set =
7273 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7275 cmdline_parse_token_string_t cmd_set_uc_hash_port =
7276 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7278 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
7279 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
7281 cmdline_parse_token_string_t cmd_set_uc_hash_what =
7282 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7284 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
7285 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
7287 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
7288 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7291 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
7292 .f = cmd_set_uc_hash_parsed,
7294 .help_str = "set port <port_id> uta <mac_addr> on|off)",
7296 (void *)&cmd_set_uc_hash_set,
7297 (void *)&cmd_set_uc_hash_port,
7298 (void *)&cmd_set_uc_hash_portid,
7299 (void *)&cmd_set_uc_hash_what,
7300 (void *)&cmd_set_uc_hash_mac,
7301 (void *)&cmd_set_uc_hash_mode,
7306 struct cmd_set_uc_all_hash_table {
7307 cmdline_fixed_string_t set;
7308 cmdline_fixed_string_t port;
7310 cmdline_fixed_string_t what;
7311 cmdline_fixed_string_t value;
7312 cmdline_fixed_string_t mode;
7316 cmd_set_uc_all_hash_parsed(void *parsed_result,
7317 __attribute__((unused)) struct cmdline *cl,
7318 __attribute__((unused)) void *data)
7321 struct cmd_set_uc_all_hash_table *res = parsed_result;
7323 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7325 if ((strcmp(res->what, "uta") == 0) &&
7326 (strcmp(res->value, "all") == 0))
7327 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
7329 printf("bad unicast hash table parameter,"
7330 "return code = %d \n", ret);
7333 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
7334 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7336 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
7337 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7339 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
7340 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
7342 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
7343 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7345 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
7346 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7348 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
7349 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7352 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
7353 .f = cmd_set_uc_all_hash_parsed,
7355 .help_str = "set port <port_id> uta all on|off",
7357 (void *)&cmd_set_uc_all_hash_set,
7358 (void *)&cmd_set_uc_all_hash_port,
7359 (void *)&cmd_set_uc_all_hash_portid,
7360 (void *)&cmd_set_uc_all_hash_what,
7361 (void *)&cmd_set_uc_all_hash_value,
7362 (void *)&cmd_set_uc_all_hash_mode,
7367 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
7368 struct cmd_set_vf_macvlan_filter {
7369 cmdline_fixed_string_t set;
7370 cmdline_fixed_string_t port;
7372 cmdline_fixed_string_t vf;
7374 struct ether_addr address;
7375 cmdline_fixed_string_t filter_type;
7376 cmdline_fixed_string_t mode;
7380 cmd_set_vf_macvlan_parsed(void *parsed_result,
7381 __attribute__((unused)) struct cmdline *cl,
7382 __attribute__((unused)) void *data)
7385 struct cmd_set_vf_macvlan_filter *res = parsed_result;
7386 struct rte_eth_mac_filter filter;
7388 memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
7390 rte_memcpy(&filter.mac_addr, &res->address, ETHER_ADDR_LEN);
7392 /* set VF MAC filter */
7396 filter.dst_id = res->vf_id;
7398 if (!strcmp(res->filter_type, "exact-mac"))
7399 filter.filter_type = RTE_MAC_PERFECT_MATCH;
7400 else if (!strcmp(res->filter_type, "exact-mac-vlan"))
7401 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
7402 else if (!strcmp(res->filter_type, "hashmac"))
7403 filter.filter_type = RTE_MAC_HASH_MATCH;
7404 else if (!strcmp(res->filter_type, "hashmac-vlan"))
7405 filter.filter_type = RTE_MACVLAN_HASH_MATCH;
7407 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7410 ret = rte_eth_dev_filter_ctrl(res->port_id,
7411 RTE_ETH_FILTER_MACVLAN,
7415 ret = rte_eth_dev_filter_ctrl(res->port_id,
7416 RTE_ETH_FILTER_MACVLAN,
7417 RTE_ETH_FILTER_DELETE,
7421 printf("bad set MAC hash parameter, return code = %d\n", ret);
7425 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
7426 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7428 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
7429 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7431 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
7432 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7434 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
7435 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7437 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
7438 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7440 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
7441 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7443 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
7444 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7445 filter_type, "exact-mac#exact-mac-vlan"
7446 "#hashmac#hashmac-vlan");
7447 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
7448 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7451 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
7452 .f = cmd_set_vf_macvlan_parsed,
7454 .help_str = "set port <port_id> vf <vf_id> <mac_addr> "
7455 "exact-mac|exact-mac-vlan|hashmac|hashmac-vlan on|off: "
7456 "Exact match rule: exact match of MAC or MAC and VLAN; "
7457 "hash match rule: hash match of MAC and exact match of VLAN",
7459 (void *)&cmd_set_vf_macvlan_set,
7460 (void *)&cmd_set_vf_macvlan_port,
7461 (void *)&cmd_set_vf_macvlan_portid,
7462 (void *)&cmd_set_vf_macvlan_vf,
7463 (void *)&cmd_set_vf_macvlan_vf_id,
7464 (void *)&cmd_set_vf_macvlan_mac,
7465 (void *)&cmd_set_vf_macvlan_filter_type,
7466 (void *)&cmd_set_vf_macvlan_mode,
7471 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
7472 struct cmd_set_vf_traffic {
7473 cmdline_fixed_string_t set;
7474 cmdline_fixed_string_t port;
7476 cmdline_fixed_string_t vf;
7478 cmdline_fixed_string_t what;
7479 cmdline_fixed_string_t mode;
7483 cmd_set_vf_traffic_parsed(void *parsed_result,
7484 __attribute__((unused)) struct cmdline *cl,
7485 __attribute__((unused)) void *data)
7487 struct cmd_set_vf_traffic *res = parsed_result;
7488 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
7489 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7491 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
7494 cmdline_parse_token_string_t cmd_setvf_traffic_set =
7495 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7497 cmdline_parse_token_string_t cmd_setvf_traffic_port =
7498 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7500 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
7501 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
7503 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
7504 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7506 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
7507 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
7509 cmdline_parse_token_string_t cmd_setvf_traffic_what =
7510 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7512 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
7513 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7516 cmdline_parse_inst_t cmd_set_vf_traffic = {
7517 .f = cmd_set_vf_traffic_parsed,
7519 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
7521 (void *)&cmd_setvf_traffic_set,
7522 (void *)&cmd_setvf_traffic_port,
7523 (void *)&cmd_setvf_traffic_portid,
7524 (void *)&cmd_setvf_traffic_vf,
7525 (void *)&cmd_setvf_traffic_vfid,
7526 (void *)&cmd_setvf_traffic_what,
7527 (void *)&cmd_setvf_traffic_mode,
7532 /* *** CONFIGURE VF RECEIVE MODE *** */
7533 struct cmd_set_vf_rxmode {
7534 cmdline_fixed_string_t set;
7535 cmdline_fixed_string_t port;
7537 cmdline_fixed_string_t vf;
7539 cmdline_fixed_string_t what;
7540 cmdline_fixed_string_t mode;
7541 cmdline_fixed_string_t on;
7545 cmd_set_vf_rxmode_parsed(void *parsed_result,
7546 __attribute__((unused)) struct cmdline *cl,
7547 __attribute__((unused)) void *data)
7550 uint16_t rx_mode = 0;
7551 struct cmd_set_vf_rxmode *res = parsed_result;
7553 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
7554 if (!strcmp(res->what,"rxmode")) {
7555 if (!strcmp(res->mode, "AUPE"))
7556 rx_mode |= ETH_VMDQ_ACCEPT_UNTAG;
7557 else if (!strcmp(res->mode, "ROPE"))
7558 rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC;
7559 else if (!strcmp(res->mode, "BAM"))
7560 rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST;
7561 else if (!strncmp(res->mode, "MPE",3))
7562 rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST;
7565 RTE_SET_USED(is_on);
7567 #ifdef RTE_LIBRTE_IXGBE_PMD
7568 if (ret == -ENOTSUP)
7569 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id,
7570 rx_mode, (uint8_t)is_on);
7572 #ifdef RTE_LIBRTE_BNXT_PMD
7573 if (ret == -ENOTSUP)
7574 ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id,
7575 rx_mode, (uint8_t)is_on);
7578 printf("bad VF receive mode parameter, return code = %d \n",
7582 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
7583 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7585 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
7586 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7588 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
7589 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
7591 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
7592 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7594 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
7595 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
7597 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
7598 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7600 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
7601 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7602 mode, "AUPE#ROPE#BAM#MPE");
7603 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
7604 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7607 cmdline_parse_inst_t cmd_set_vf_rxmode = {
7608 .f = cmd_set_vf_rxmode_parsed,
7610 .help_str = "set port <port_id> vf <vf_id> rxmode "
7611 "AUPE|ROPE|BAM|MPE on|off",
7613 (void *)&cmd_set_vf_rxmode_set,
7614 (void *)&cmd_set_vf_rxmode_port,
7615 (void *)&cmd_set_vf_rxmode_portid,
7616 (void *)&cmd_set_vf_rxmode_vf,
7617 (void *)&cmd_set_vf_rxmode_vfid,
7618 (void *)&cmd_set_vf_rxmode_what,
7619 (void *)&cmd_set_vf_rxmode_mode,
7620 (void *)&cmd_set_vf_rxmode_on,
7625 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
7626 struct cmd_vf_mac_addr_result {
7627 cmdline_fixed_string_t mac_addr_cmd;
7628 cmdline_fixed_string_t what;
7629 cmdline_fixed_string_t port;
7631 cmdline_fixed_string_t vf;
7633 struct ether_addr address;
7636 static void cmd_vf_mac_addr_parsed(void *parsed_result,
7637 __attribute__((unused)) struct cmdline *cl,
7638 __attribute__((unused)) void *data)
7640 struct cmd_vf_mac_addr_result *res = parsed_result;
7643 if (strcmp(res->what, "add") != 0)
7646 #ifdef RTE_LIBRTE_I40E_PMD
7647 if (ret == -ENOTSUP)
7648 ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num,
7651 #ifdef RTE_LIBRTE_BNXT_PMD
7652 if (ret == -ENOTSUP)
7653 ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address,
7658 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
7662 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
7663 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7664 mac_addr_cmd,"mac_addr");
7665 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
7666 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7668 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
7669 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7671 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
7672 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
7674 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
7675 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7677 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
7678 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
7680 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
7681 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
7684 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
7685 .f = cmd_vf_mac_addr_parsed,
7687 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
7688 "Add MAC address filtering for a VF on port_id",
7690 (void *)&cmd_vf_mac_addr_cmd,
7691 (void *)&cmd_vf_mac_addr_what,
7692 (void *)&cmd_vf_mac_addr_port,
7693 (void *)&cmd_vf_mac_addr_portnum,
7694 (void *)&cmd_vf_mac_addr_vf,
7695 (void *)&cmd_vf_mac_addr_vfnum,
7696 (void *)&cmd_vf_mac_addr_addr,
7701 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
7702 struct cmd_vf_rx_vlan_filter {
7703 cmdline_fixed_string_t rx_vlan;
7704 cmdline_fixed_string_t what;
7706 cmdline_fixed_string_t port;
7708 cmdline_fixed_string_t vf;
7713 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
7714 __attribute__((unused)) struct cmdline *cl,
7715 __attribute__((unused)) void *data)
7717 struct cmd_vf_rx_vlan_filter *res = parsed_result;
7720 __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
7722 #ifdef RTE_LIBRTE_IXGBE_PMD
7723 if (ret == -ENOTSUP)
7724 ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
7725 res->vlan_id, res->vf_mask, is_add);
7727 #ifdef RTE_LIBRTE_I40E_PMD
7728 if (ret == -ENOTSUP)
7729 ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
7730 res->vlan_id, res->vf_mask, is_add);
7732 #ifdef RTE_LIBRTE_BNXT_PMD
7733 if (ret == -ENOTSUP)
7734 ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id,
7735 res->vlan_id, res->vf_mask, is_add);
7742 printf("invalid vlan_id %d or vf_mask %"PRIu64"\n",
7743 res->vlan_id, res->vf_mask);
7746 printf("invalid port_id %d\n", res->port_id);
7749 printf("function not implemented or supported\n");
7752 printf("programming error: (%s)\n", strerror(-ret));
7756 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
7757 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7758 rx_vlan, "rx_vlan");
7759 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
7760 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7762 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
7763 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7765 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
7766 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7768 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
7769 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7771 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
7772 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7774 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
7775 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7778 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
7779 .f = cmd_vf_rx_vlan_filter_parsed,
7781 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
7782 "(vf_mask = hexadecimal VF mask)",
7784 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
7785 (void *)&cmd_vf_rx_vlan_filter_what,
7786 (void *)&cmd_vf_rx_vlan_filter_vlanid,
7787 (void *)&cmd_vf_rx_vlan_filter_port,
7788 (void *)&cmd_vf_rx_vlan_filter_portid,
7789 (void *)&cmd_vf_rx_vlan_filter_vf,
7790 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
7795 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
7796 struct cmd_queue_rate_limit_result {
7797 cmdline_fixed_string_t set;
7798 cmdline_fixed_string_t port;
7800 cmdline_fixed_string_t queue;
7802 cmdline_fixed_string_t rate;
7806 static void cmd_queue_rate_limit_parsed(void *parsed_result,
7807 __attribute__((unused)) struct cmdline *cl,
7808 __attribute__((unused)) void *data)
7810 struct cmd_queue_rate_limit_result *res = parsed_result;
7813 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
7814 && (strcmp(res->queue, "queue") == 0)
7815 && (strcmp(res->rate, "rate") == 0))
7816 ret = set_queue_rate_limit(res->port_num, res->queue_num,
7819 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
7823 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
7824 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7826 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
7827 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7829 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
7830 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
7832 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
7833 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7835 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
7836 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
7838 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
7839 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7841 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
7842 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
7845 cmdline_parse_inst_t cmd_queue_rate_limit = {
7846 .f = cmd_queue_rate_limit_parsed,
7848 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
7849 "Set rate limit for a queue on port_id",
7851 (void *)&cmd_queue_rate_limit_set,
7852 (void *)&cmd_queue_rate_limit_port,
7853 (void *)&cmd_queue_rate_limit_portnum,
7854 (void *)&cmd_queue_rate_limit_queue,
7855 (void *)&cmd_queue_rate_limit_queuenum,
7856 (void *)&cmd_queue_rate_limit_rate,
7857 (void *)&cmd_queue_rate_limit_ratenum,
7862 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
7863 struct cmd_vf_rate_limit_result {
7864 cmdline_fixed_string_t set;
7865 cmdline_fixed_string_t port;
7867 cmdline_fixed_string_t vf;
7869 cmdline_fixed_string_t rate;
7871 cmdline_fixed_string_t q_msk;
7875 static void cmd_vf_rate_limit_parsed(void *parsed_result,
7876 __attribute__((unused)) struct cmdline *cl,
7877 __attribute__((unused)) void *data)
7879 struct cmd_vf_rate_limit_result *res = parsed_result;
7882 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
7883 && (strcmp(res->vf, "vf") == 0)
7884 && (strcmp(res->rate, "rate") == 0)
7885 && (strcmp(res->q_msk, "queue_mask") == 0))
7886 ret = set_vf_rate_limit(res->port_num, res->vf_num,
7887 res->rate_num, res->q_msk_val);
7889 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
7893 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
7894 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7896 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
7897 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7899 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
7900 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7902 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
7903 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7905 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
7906 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7908 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
7909 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7911 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
7912 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7914 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
7915 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7916 q_msk, "queue_mask");
7917 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
7918 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7921 cmdline_parse_inst_t cmd_vf_rate_limit = {
7922 .f = cmd_vf_rate_limit_parsed,
7924 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
7925 "queue_mask <queue_mask_value>: "
7926 "Set rate limit for queues of VF on port_id",
7928 (void *)&cmd_vf_rate_limit_set,
7929 (void *)&cmd_vf_rate_limit_port,
7930 (void *)&cmd_vf_rate_limit_portnum,
7931 (void *)&cmd_vf_rate_limit_vf,
7932 (void *)&cmd_vf_rate_limit_vfnum,
7933 (void *)&cmd_vf_rate_limit_rate,
7934 (void *)&cmd_vf_rate_limit_ratenum,
7935 (void *)&cmd_vf_rate_limit_q_msk,
7936 (void *)&cmd_vf_rate_limit_q_msk_val,
7941 /* *** ADD TUNNEL FILTER OF A PORT *** */
7942 struct cmd_tunnel_filter_result {
7943 cmdline_fixed_string_t cmd;
7944 cmdline_fixed_string_t what;
7946 struct ether_addr outer_mac;
7947 struct ether_addr inner_mac;
7948 cmdline_ipaddr_t ip_value;
7949 uint16_t inner_vlan;
7950 cmdline_fixed_string_t tunnel_type;
7951 cmdline_fixed_string_t filter_type;
7957 cmd_tunnel_filter_parsed(void *parsed_result,
7958 __attribute__((unused)) struct cmdline *cl,
7959 __attribute__((unused)) void *data)
7961 struct cmd_tunnel_filter_result *res = parsed_result;
7962 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
7965 memset(&tunnel_filter_conf, 0, sizeof(tunnel_filter_conf));
7967 ether_addr_copy(&res->outer_mac, &tunnel_filter_conf.outer_mac);
7968 ether_addr_copy(&res->inner_mac, &tunnel_filter_conf.inner_mac);
7969 tunnel_filter_conf.inner_vlan = res->inner_vlan;
7971 if (res->ip_value.family == AF_INET) {
7972 tunnel_filter_conf.ip_addr.ipv4_addr =
7973 res->ip_value.addr.ipv4.s_addr;
7974 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
7976 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
7977 &(res->ip_value.addr.ipv6),
7978 sizeof(struct in6_addr));
7979 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
7982 if (!strcmp(res->filter_type, "imac-ivlan"))
7983 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
7984 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
7985 tunnel_filter_conf.filter_type =
7986 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
7987 else if (!strcmp(res->filter_type, "imac-tenid"))
7988 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
7989 else if (!strcmp(res->filter_type, "imac"))
7990 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
7991 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
7992 tunnel_filter_conf.filter_type =
7993 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
7994 else if (!strcmp(res->filter_type, "oip"))
7995 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_OIP;
7996 else if (!strcmp(res->filter_type, "iip"))
7997 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IIP;
7999 printf("The filter type is not supported");
8003 if (!strcmp(res->tunnel_type, "vxlan"))
8004 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
8005 else if (!strcmp(res->tunnel_type, "nvgre"))
8006 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE;
8007 else if (!strcmp(res->tunnel_type, "ipingre"))
8008 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_IP_IN_GRE;
8010 printf("The tunnel type %s not supported.\n", res->tunnel_type);
8014 tunnel_filter_conf.tenant_id = res->tenant_id;
8015 tunnel_filter_conf.queue_id = res->queue_num;
8016 if (!strcmp(res->what, "add"))
8017 ret = rte_eth_dev_filter_ctrl(res->port_id,
8018 RTE_ETH_FILTER_TUNNEL,
8020 &tunnel_filter_conf);
8022 ret = rte_eth_dev_filter_ctrl(res->port_id,
8023 RTE_ETH_FILTER_TUNNEL,
8024 RTE_ETH_FILTER_DELETE,
8025 &tunnel_filter_conf);
8027 printf("cmd_tunnel_filter_parsed error: (%s)\n",
8031 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
8032 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8033 cmd, "tunnel_filter");
8034 cmdline_parse_token_string_t cmd_tunnel_filter_what =
8035 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8037 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
8038 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8040 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
8041 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8043 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
8044 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8046 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
8047 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8048 inner_vlan, UINT16);
8049 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
8050 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8052 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
8053 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8054 tunnel_type, "vxlan#nvgre#ipingre");
8056 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
8057 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8058 filter_type, "oip#iip#imac-ivlan#imac-ivlan-tenid#imac-tenid#"
8059 "imac#omac-imac-tenid");
8060 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
8061 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8063 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
8064 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8067 cmdline_parse_inst_t cmd_tunnel_filter = {
8068 .f = cmd_tunnel_filter_parsed,
8070 .help_str = "tunnel_filter add|rm <port_id> <outer_mac> <inner_mac> "
8071 "<ip> <inner_vlan> vxlan|nvgre|ipingre oip|iip|imac-ivlan|"
8072 "imac-ivlan-tenid|imac-tenid|imac|omac-imac-tenid <tenant_id> "
8073 "<queue_id>: Add/Rm tunnel filter of a port",
8075 (void *)&cmd_tunnel_filter_cmd,
8076 (void *)&cmd_tunnel_filter_what,
8077 (void *)&cmd_tunnel_filter_port_id,
8078 (void *)&cmd_tunnel_filter_outer_mac,
8079 (void *)&cmd_tunnel_filter_inner_mac,
8080 (void *)&cmd_tunnel_filter_ip_value,
8081 (void *)&cmd_tunnel_filter_innner_vlan,
8082 (void *)&cmd_tunnel_filter_tunnel_type,
8083 (void *)&cmd_tunnel_filter_filter_type,
8084 (void *)&cmd_tunnel_filter_tenant_id,
8085 (void *)&cmd_tunnel_filter_queue_num,
8090 /* *** CONFIGURE TUNNEL UDP PORT *** */
8091 struct cmd_tunnel_udp_config {
8092 cmdline_fixed_string_t cmd;
8093 cmdline_fixed_string_t what;
8099 cmd_tunnel_udp_config_parsed(void *parsed_result,
8100 __attribute__((unused)) struct cmdline *cl,
8101 __attribute__((unused)) void *data)
8103 struct cmd_tunnel_udp_config *res = parsed_result;
8104 struct rte_eth_udp_tunnel tunnel_udp;
8107 tunnel_udp.udp_port = res->udp_port;
8109 if (!strcmp(res->cmd, "rx_vxlan_port"))
8110 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
8112 if (!strcmp(res->what, "add"))
8113 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
8116 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
8120 printf("udp tunneling add error: (%s)\n", strerror(-ret));
8123 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
8124 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
8125 cmd, "rx_vxlan_port");
8126 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
8127 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
8129 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
8130 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
8132 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
8133 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
8136 cmdline_parse_inst_t cmd_tunnel_udp_config = {
8137 .f = cmd_tunnel_udp_config_parsed,
8139 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
8140 "Add/Remove a tunneling UDP port filter",
8142 (void *)&cmd_tunnel_udp_config_cmd,
8143 (void *)&cmd_tunnel_udp_config_what,
8144 (void *)&cmd_tunnel_udp_config_udp_port,
8145 (void *)&cmd_tunnel_udp_config_port_id,
8150 /* *** GLOBAL CONFIG *** */
8151 struct cmd_global_config_result {
8152 cmdline_fixed_string_t cmd;
8154 cmdline_fixed_string_t cfg_type;
8159 cmd_global_config_parsed(void *parsed_result,
8160 __attribute__((unused)) struct cmdline *cl,
8161 __attribute__((unused)) void *data)
8163 struct cmd_global_config_result *res = parsed_result;
8164 struct rte_eth_global_cfg conf;
8167 memset(&conf, 0, sizeof(conf));
8168 conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN;
8169 conf.cfg.gre_key_len = res->len;
8170 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE,
8171 RTE_ETH_FILTER_SET, &conf);
8173 printf("Global config error\n");
8176 cmdline_parse_token_string_t cmd_global_config_cmd =
8177 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd,
8179 cmdline_parse_token_num_t cmd_global_config_port_id =
8180 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id,
8182 cmdline_parse_token_string_t cmd_global_config_type =
8183 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result,
8184 cfg_type, "gre-key-len");
8185 cmdline_parse_token_num_t cmd_global_config_gre_key_len =
8186 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result,
8189 cmdline_parse_inst_t cmd_global_config = {
8190 .f = cmd_global_config_parsed,
8191 .data = (void *)NULL,
8192 .help_str = "global_config <port_id> gre-key-len <key_len>",
8194 (void *)&cmd_global_config_cmd,
8195 (void *)&cmd_global_config_port_id,
8196 (void *)&cmd_global_config_type,
8197 (void *)&cmd_global_config_gre_key_len,
8202 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
8203 struct cmd_set_mirror_mask_result {
8204 cmdline_fixed_string_t set;
8205 cmdline_fixed_string_t port;
8207 cmdline_fixed_string_t mirror;
8209 cmdline_fixed_string_t what;
8210 cmdline_fixed_string_t value;
8211 cmdline_fixed_string_t dstpool;
8213 cmdline_fixed_string_t on;
8216 cmdline_parse_token_string_t cmd_mirror_mask_set =
8217 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8219 cmdline_parse_token_string_t cmd_mirror_mask_port =
8220 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8222 cmdline_parse_token_num_t cmd_mirror_mask_portid =
8223 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
8225 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
8226 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8227 mirror, "mirror-rule");
8228 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
8229 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
8231 cmdline_parse_token_string_t cmd_mirror_mask_what =
8232 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8233 what, "pool-mirror-up#pool-mirror-down"
8235 cmdline_parse_token_string_t cmd_mirror_mask_value =
8236 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8238 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
8239 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8240 dstpool, "dst-pool");
8241 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
8242 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
8244 cmdline_parse_token_string_t cmd_mirror_mask_on =
8245 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8249 cmd_set_mirror_mask_parsed(void *parsed_result,
8250 __attribute__((unused)) struct cmdline *cl,
8251 __attribute__((unused)) void *data)
8254 struct cmd_set_mirror_mask_result *res = parsed_result;
8255 struct rte_eth_mirror_conf mr_conf;
8257 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
8259 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
8261 mr_conf.dst_pool = res->dstpool_id;
8263 if (!strcmp(res->what, "pool-mirror-up")) {
8264 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
8265 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
8266 } else if (!strcmp(res->what, "pool-mirror-down")) {
8267 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
8268 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
8269 } else if (!strcmp(res->what, "vlan-mirror")) {
8270 mr_conf.rule_type = ETH_MIRROR_VLAN;
8271 nb_item = parse_item_list(res->value, "vlan",
8272 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
8276 for (i = 0; i < nb_item; i++) {
8277 if (vlan_list[i] > ETHER_MAX_VLAN_ID) {
8278 printf("Invalid vlan_id: must be < 4096\n");
8282 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
8283 mr_conf.vlan.vlan_mask |= 1ULL << i;
8287 if (!strcmp(res->on, "on"))
8288 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8291 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8294 printf("mirror rule add error: (%s)\n", strerror(-ret));
8297 cmdline_parse_inst_t cmd_set_mirror_mask = {
8298 .f = cmd_set_mirror_mask_parsed,
8300 .help_str = "set port <port_id> mirror-rule <rule_id> "
8301 "pool-mirror-up|pool-mirror-down|vlan-mirror "
8302 "<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off",
8304 (void *)&cmd_mirror_mask_set,
8305 (void *)&cmd_mirror_mask_port,
8306 (void *)&cmd_mirror_mask_portid,
8307 (void *)&cmd_mirror_mask_mirror,
8308 (void *)&cmd_mirror_mask_ruleid,
8309 (void *)&cmd_mirror_mask_what,
8310 (void *)&cmd_mirror_mask_value,
8311 (void *)&cmd_mirror_mask_dstpool,
8312 (void *)&cmd_mirror_mask_poolid,
8313 (void *)&cmd_mirror_mask_on,
8318 /* *** CONFIGURE VM MIRROR UPLINK/DOWNLINK RULE *** */
8319 struct cmd_set_mirror_link_result {
8320 cmdline_fixed_string_t set;
8321 cmdline_fixed_string_t port;
8323 cmdline_fixed_string_t mirror;
8325 cmdline_fixed_string_t what;
8326 cmdline_fixed_string_t dstpool;
8328 cmdline_fixed_string_t on;
8331 cmdline_parse_token_string_t cmd_mirror_link_set =
8332 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8334 cmdline_parse_token_string_t cmd_mirror_link_port =
8335 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8337 cmdline_parse_token_num_t cmd_mirror_link_portid =
8338 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
8340 cmdline_parse_token_string_t cmd_mirror_link_mirror =
8341 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8342 mirror, "mirror-rule");
8343 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
8344 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
8346 cmdline_parse_token_string_t cmd_mirror_link_what =
8347 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8348 what, "uplink-mirror#downlink-mirror");
8349 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
8350 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8351 dstpool, "dst-pool");
8352 cmdline_parse_token_num_t cmd_mirror_link_poolid =
8353 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
8355 cmdline_parse_token_string_t cmd_mirror_link_on =
8356 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8360 cmd_set_mirror_link_parsed(void *parsed_result,
8361 __attribute__((unused)) struct cmdline *cl,
8362 __attribute__((unused)) void *data)
8365 struct cmd_set_mirror_link_result *res = parsed_result;
8366 struct rte_eth_mirror_conf mr_conf;
8368 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
8369 if (!strcmp(res->what, "uplink-mirror"))
8370 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
8372 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
8374 mr_conf.dst_pool = res->dstpool_id;
8376 if (!strcmp(res->on, "on"))
8377 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8380 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8383 /* check the return value and print it if is < 0 */
8385 printf("mirror rule add error: (%s)\n", strerror(-ret));
8389 cmdline_parse_inst_t cmd_set_mirror_link = {
8390 .f = cmd_set_mirror_link_parsed,
8392 .help_str = "set port <port_id> mirror-rule <rule_id> "
8393 "uplink-mirror|downlink-mirror dst-pool <pool_id> on|off",
8395 (void *)&cmd_mirror_link_set,
8396 (void *)&cmd_mirror_link_port,
8397 (void *)&cmd_mirror_link_portid,
8398 (void *)&cmd_mirror_link_mirror,
8399 (void *)&cmd_mirror_link_ruleid,
8400 (void *)&cmd_mirror_link_what,
8401 (void *)&cmd_mirror_link_dstpool,
8402 (void *)&cmd_mirror_link_poolid,
8403 (void *)&cmd_mirror_link_on,
8408 /* *** RESET VM MIRROR RULE *** */
8409 struct cmd_rm_mirror_rule_result {
8410 cmdline_fixed_string_t reset;
8411 cmdline_fixed_string_t port;
8413 cmdline_fixed_string_t mirror;
8417 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
8418 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
8420 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
8421 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
8423 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
8424 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
8426 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
8427 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
8428 mirror, "mirror-rule");
8429 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
8430 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
8434 cmd_reset_mirror_rule_parsed(void *parsed_result,
8435 __attribute__((unused)) struct cmdline *cl,
8436 __attribute__((unused)) void *data)
8439 struct cmd_set_mirror_link_result *res = parsed_result;
8441 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
8443 printf("mirror rule remove error: (%s)\n", strerror(-ret));
8446 cmdline_parse_inst_t cmd_reset_mirror_rule = {
8447 .f = cmd_reset_mirror_rule_parsed,
8449 .help_str = "reset port <port_id> mirror-rule <rule_id>",
8451 (void *)&cmd_rm_mirror_rule_reset,
8452 (void *)&cmd_rm_mirror_rule_port,
8453 (void *)&cmd_rm_mirror_rule_portid,
8454 (void *)&cmd_rm_mirror_rule_mirror,
8455 (void *)&cmd_rm_mirror_rule_ruleid,
8460 /* ******************************************************************************** */
8462 struct cmd_dump_result {
8463 cmdline_fixed_string_t dump;
8467 dump_struct_sizes(void)
8469 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
8470 DUMP_SIZE(struct rte_mbuf);
8471 DUMP_SIZE(struct rte_mempool);
8472 DUMP_SIZE(struct rte_ring);
8476 static void cmd_dump_parsed(void *parsed_result,
8477 __attribute__((unused)) struct cmdline *cl,
8478 __attribute__((unused)) void *data)
8480 struct cmd_dump_result *res = parsed_result;
8482 if (!strcmp(res->dump, "dump_physmem"))
8483 rte_dump_physmem_layout(stdout);
8484 else if (!strcmp(res->dump, "dump_memzone"))
8485 rte_memzone_dump(stdout);
8486 else if (!strcmp(res->dump, "dump_struct_sizes"))
8487 dump_struct_sizes();
8488 else if (!strcmp(res->dump, "dump_ring"))
8489 rte_ring_list_dump(stdout);
8490 else if (!strcmp(res->dump, "dump_mempool"))
8491 rte_mempool_list_dump(stdout);
8492 else if (!strcmp(res->dump, "dump_devargs"))
8493 rte_eal_devargs_dump(stdout);
8494 else if (!strcmp(res->dump, "dump_log_types"))
8495 rte_log_dump(stdout);
8498 cmdline_parse_token_string_t cmd_dump_dump =
8499 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
8502 "dump_struct_sizes#"
8508 cmdline_parse_inst_t cmd_dump = {
8509 .f = cmd_dump_parsed, /* function to call */
8510 .data = NULL, /* 2nd arg of func */
8511 .help_str = "Dump status",
8512 .tokens = { /* token list, NULL terminated */
8513 (void *)&cmd_dump_dump,
8518 /* ******************************************************************************** */
8520 struct cmd_dump_one_result {
8521 cmdline_fixed_string_t dump;
8522 cmdline_fixed_string_t name;
8525 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
8526 __attribute__((unused)) void *data)
8528 struct cmd_dump_one_result *res = parsed_result;
8530 if (!strcmp(res->dump, "dump_ring")) {
8532 r = rte_ring_lookup(res->name);
8534 cmdline_printf(cl, "Cannot find ring\n");
8537 rte_ring_dump(stdout, r);
8538 } else if (!strcmp(res->dump, "dump_mempool")) {
8539 struct rte_mempool *mp;
8540 mp = rte_mempool_lookup(res->name);
8542 cmdline_printf(cl, "Cannot find mempool\n");
8545 rte_mempool_dump(stdout, mp);
8549 cmdline_parse_token_string_t cmd_dump_one_dump =
8550 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
8551 "dump_ring#dump_mempool");
8553 cmdline_parse_token_string_t cmd_dump_one_name =
8554 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
8556 cmdline_parse_inst_t cmd_dump_one = {
8557 .f = cmd_dump_one_parsed, /* function to call */
8558 .data = NULL, /* 2nd arg of func */
8559 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
8560 .tokens = { /* token list, NULL terminated */
8561 (void *)&cmd_dump_one_dump,
8562 (void *)&cmd_dump_one_name,
8567 /* *** Add/Del syn filter *** */
8568 struct cmd_syn_filter_result {
8569 cmdline_fixed_string_t filter;
8571 cmdline_fixed_string_t ops;
8572 cmdline_fixed_string_t priority;
8573 cmdline_fixed_string_t high;
8574 cmdline_fixed_string_t queue;
8579 cmd_syn_filter_parsed(void *parsed_result,
8580 __attribute__((unused)) struct cmdline *cl,
8581 __attribute__((unused)) void *data)
8583 struct cmd_syn_filter_result *res = parsed_result;
8584 struct rte_eth_syn_filter syn_filter;
8587 ret = rte_eth_dev_filter_supported(res->port_id,
8588 RTE_ETH_FILTER_SYN);
8590 printf("syn filter is not supported on port %u.\n",
8595 memset(&syn_filter, 0, sizeof(syn_filter));
8597 if (!strcmp(res->ops, "add")) {
8598 if (!strcmp(res->high, "high"))
8599 syn_filter.hig_pri = 1;
8601 syn_filter.hig_pri = 0;
8603 syn_filter.queue = res->queue_id;
8604 ret = rte_eth_dev_filter_ctrl(res->port_id,
8609 ret = rte_eth_dev_filter_ctrl(res->port_id,
8611 RTE_ETH_FILTER_DELETE,
8615 printf("syn filter programming error: (%s)\n",
8619 cmdline_parse_token_string_t cmd_syn_filter_filter =
8620 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8621 filter, "syn_filter");
8622 cmdline_parse_token_num_t cmd_syn_filter_port_id =
8623 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
8625 cmdline_parse_token_string_t cmd_syn_filter_ops =
8626 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8628 cmdline_parse_token_string_t cmd_syn_filter_priority =
8629 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8630 priority, "priority");
8631 cmdline_parse_token_string_t cmd_syn_filter_high =
8632 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8634 cmdline_parse_token_string_t cmd_syn_filter_queue =
8635 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8637 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
8638 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
8641 cmdline_parse_inst_t cmd_syn_filter = {
8642 .f = cmd_syn_filter_parsed,
8644 .help_str = "syn_filter <port_id> add|del priority high|low queue "
8645 "<queue_id>: Add/Delete syn filter",
8647 (void *)&cmd_syn_filter_filter,
8648 (void *)&cmd_syn_filter_port_id,
8649 (void *)&cmd_syn_filter_ops,
8650 (void *)&cmd_syn_filter_priority,
8651 (void *)&cmd_syn_filter_high,
8652 (void *)&cmd_syn_filter_queue,
8653 (void *)&cmd_syn_filter_queue_id,
8658 /* *** queue region set *** */
8659 struct cmd_queue_region_result {
8660 cmdline_fixed_string_t set;
8661 cmdline_fixed_string_t port;
8663 cmdline_fixed_string_t cmd;
8664 cmdline_fixed_string_t region;
8666 cmdline_fixed_string_t queue_start_index;
8668 cmdline_fixed_string_t queue_num;
8669 uint8_t queue_num_value;
8673 cmd_queue_region_parsed(void *parsed_result,
8674 __attribute__((unused)) struct cmdline *cl,
8675 __attribute__((unused)) void *data)
8677 struct cmd_queue_region_result *res = parsed_result;
8679 #ifdef RTE_LIBRTE_I40E_PMD
8680 struct rte_pmd_i40e_queue_region_conf region_conf;
8681 enum rte_pmd_i40e_queue_region_op op_type;
8684 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
8687 #ifdef RTE_LIBRTE_I40E_PMD
8688 memset(®ion_conf, 0, sizeof(region_conf));
8689 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_SET;
8690 region_conf.region_id = res->region_id;
8691 region_conf.queue_num = res->queue_num_value;
8692 region_conf.queue_start_index = res->queue_id;
8694 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
8695 op_type, ®ion_conf);
8702 printf("function not implemented or supported\n");
8705 printf("queue region config error: (%s)\n", strerror(-ret));
8709 cmdline_parse_token_string_t cmd_queue_region_set =
8710 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
8712 cmdline_parse_token_string_t cmd_queue_region_port =
8713 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, port, "port");
8714 cmdline_parse_token_num_t cmd_queue_region_port_id =
8715 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
8717 cmdline_parse_token_string_t cmd_queue_region_cmd =
8718 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
8719 cmd, "queue-region");
8720 cmdline_parse_token_string_t cmd_queue_region_id =
8721 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
8722 region, "region_id");
8723 cmdline_parse_token_num_t cmd_queue_region_index =
8724 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
8726 cmdline_parse_token_string_t cmd_queue_region_queue_start_index =
8727 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
8728 queue_start_index, "queue_start_index");
8729 cmdline_parse_token_num_t cmd_queue_region_queue_id =
8730 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
8732 cmdline_parse_token_string_t cmd_queue_region_queue_num =
8733 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
8734 queue_num, "queue_num");
8735 cmdline_parse_token_num_t cmd_queue_region_queue_num_value =
8736 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
8737 queue_num_value, UINT8);
8739 cmdline_parse_inst_t cmd_queue_region = {
8740 .f = cmd_queue_region_parsed,
8742 .help_str = "set port <port_id> queue-region region_id <value> "
8743 "queue_start_index <value> queue_num <value>: Set a queue region",
8745 (void *)&cmd_queue_region_set,
8746 (void *)&cmd_queue_region_port,
8747 (void *)&cmd_queue_region_port_id,
8748 (void *)&cmd_queue_region_cmd,
8749 (void *)&cmd_queue_region_id,
8750 (void *)&cmd_queue_region_index,
8751 (void *)&cmd_queue_region_queue_start_index,
8752 (void *)&cmd_queue_region_queue_id,
8753 (void *)&cmd_queue_region_queue_num,
8754 (void *)&cmd_queue_region_queue_num_value,
8759 /* *** queue region and flowtype set *** */
8760 struct cmd_region_flowtype_result {
8761 cmdline_fixed_string_t set;
8762 cmdline_fixed_string_t port;
8764 cmdline_fixed_string_t cmd;
8765 cmdline_fixed_string_t region;
8767 cmdline_fixed_string_t flowtype;
8768 uint8_t flowtype_id;
8772 cmd_region_flowtype_parsed(void *parsed_result,
8773 __attribute__((unused)) struct cmdline *cl,
8774 __attribute__((unused)) void *data)
8776 struct cmd_region_flowtype_result *res = parsed_result;
8778 #ifdef RTE_LIBRTE_I40E_PMD
8779 struct rte_pmd_i40e_queue_region_conf region_conf;
8780 enum rte_pmd_i40e_queue_region_op op_type;
8783 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
8786 #ifdef RTE_LIBRTE_I40E_PMD
8787 memset(®ion_conf, 0, sizeof(region_conf));
8789 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_FLOWTYPE_SET;
8790 region_conf.region_id = res->region_id;
8791 region_conf.hw_flowtype = res->flowtype_id;
8793 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
8794 op_type, ®ion_conf);
8801 printf("function not implemented or supported\n");
8804 printf("region flowtype config error: (%s)\n", strerror(-ret));
8808 cmdline_parse_token_string_t cmd_region_flowtype_set =
8809 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
8811 cmdline_parse_token_string_t cmd_region_flowtype_port =
8812 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
8814 cmdline_parse_token_num_t cmd_region_flowtype_port_index =
8815 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
8817 cmdline_parse_token_string_t cmd_region_flowtype_cmd =
8818 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
8819 cmd, "queue-region");
8820 cmdline_parse_token_string_t cmd_region_flowtype_index =
8821 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
8822 region, "region_id");
8823 cmdline_parse_token_num_t cmd_region_flowtype_id =
8824 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
8826 cmdline_parse_token_string_t cmd_region_flowtype_flow_index =
8827 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
8828 flowtype, "flowtype");
8829 cmdline_parse_token_num_t cmd_region_flowtype_flow_id =
8830 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
8831 flowtype_id, UINT8);
8832 cmdline_parse_inst_t cmd_region_flowtype = {
8833 .f = cmd_region_flowtype_parsed,
8835 .help_str = "set port <port_id> queue-region region_id <value> "
8836 "flowtype <value>: Set a flowtype region index",
8838 (void *)&cmd_region_flowtype_set,
8839 (void *)&cmd_region_flowtype_port,
8840 (void *)&cmd_region_flowtype_port_index,
8841 (void *)&cmd_region_flowtype_cmd,
8842 (void *)&cmd_region_flowtype_index,
8843 (void *)&cmd_region_flowtype_id,
8844 (void *)&cmd_region_flowtype_flow_index,
8845 (void *)&cmd_region_flowtype_flow_id,
8850 /* *** User Priority (UP) to queue region (region_id) set *** */
8851 struct cmd_user_priority_region_result {
8852 cmdline_fixed_string_t set;
8853 cmdline_fixed_string_t port;
8855 cmdline_fixed_string_t cmd;
8856 cmdline_fixed_string_t user_priority;
8857 uint8_t user_priority_id;
8858 cmdline_fixed_string_t region;
8863 cmd_user_priority_region_parsed(void *parsed_result,
8864 __attribute__((unused)) struct cmdline *cl,
8865 __attribute__((unused)) void *data)
8867 struct cmd_user_priority_region_result *res = parsed_result;
8869 #ifdef RTE_LIBRTE_I40E_PMD
8870 struct rte_pmd_i40e_queue_region_conf region_conf;
8871 enum rte_pmd_i40e_queue_region_op op_type;
8874 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
8877 #ifdef RTE_LIBRTE_I40E_PMD
8878 memset(®ion_conf, 0, sizeof(region_conf));
8879 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_USER_PRIORITY_SET;
8880 region_conf.user_priority = res->user_priority_id;
8881 region_conf.region_id = res->region_id;
8883 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
8884 op_type, ®ion_conf);
8891 printf("function not implemented or supported\n");
8894 printf("user_priority region config error: (%s)\n",
8899 cmdline_parse_token_string_t cmd_user_priority_region_set =
8900 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
8902 cmdline_parse_token_string_t cmd_user_priority_region_port =
8903 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
8905 cmdline_parse_token_num_t cmd_user_priority_region_port_index =
8906 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
8908 cmdline_parse_token_string_t cmd_user_priority_region_cmd =
8909 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
8910 cmd, "queue-region");
8911 cmdline_parse_token_string_t cmd_user_priority_region_UP =
8912 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
8913 user_priority, "UP");
8914 cmdline_parse_token_num_t cmd_user_priority_region_UP_id =
8915 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
8916 user_priority_id, UINT8);
8917 cmdline_parse_token_string_t cmd_user_priority_region_region =
8918 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
8919 region, "region_id");
8920 cmdline_parse_token_num_t cmd_user_priority_region_region_id =
8921 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
8924 cmdline_parse_inst_t cmd_user_priority_region = {
8925 .f = cmd_user_priority_region_parsed,
8927 .help_str = "set port <port_id> queue-region UP <value> "
8928 "region_id <value>: Set the mapping of User Priority (UP) "
8929 "to queue region (region_id) ",
8931 (void *)&cmd_user_priority_region_set,
8932 (void *)&cmd_user_priority_region_port,
8933 (void *)&cmd_user_priority_region_port_index,
8934 (void *)&cmd_user_priority_region_cmd,
8935 (void *)&cmd_user_priority_region_UP,
8936 (void *)&cmd_user_priority_region_UP_id,
8937 (void *)&cmd_user_priority_region_region,
8938 (void *)&cmd_user_priority_region_region_id,
8943 /* *** flush all queue region related configuration *** */
8944 struct cmd_flush_queue_region_result {
8945 cmdline_fixed_string_t set;
8946 cmdline_fixed_string_t port;
8948 cmdline_fixed_string_t cmd;
8949 cmdline_fixed_string_t flush;
8950 cmdline_fixed_string_t what;
8954 cmd_flush_queue_region_parsed(void *parsed_result,
8955 __attribute__((unused)) struct cmdline *cl,
8956 __attribute__((unused)) void *data)
8958 struct cmd_flush_queue_region_result *res = parsed_result;
8960 #ifdef RTE_LIBRTE_I40E_PMD
8961 struct rte_pmd_i40e_queue_region_conf region_conf;
8962 enum rte_pmd_i40e_queue_region_op op_type;
8965 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
8968 #ifdef RTE_LIBRTE_I40E_PMD
8969 memset(®ion_conf, 0, sizeof(region_conf));
8971 if (strcmp(res->what, "on") == 0)
8972 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_ON;
8974 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_OFF;
8976 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
8977 op_type, ®ion_conf);
8984 printf("function not implemented or supported\n");
8987 printf("queue region config flush error: (%s)\n",
8992 cmdline_parse_token_string_t cmd_flush_queue_region_set =
8993 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
8995 cmdline_parse_token_string_t cmd_flush_queue_region_port =
8996 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
8998 cmdline_parse_token_num_t cmd_flush_queue_region_port_index =
8999 TOKEN_NUM_INITIALIZER(struct cmd_flush_queue_region_result,
9001 cmdline_parse_token_string_t cmd_flush_queue_region_cmd =
9002 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9003 cmd, "queue-region");
9004 cmdline_parse_token_string_t cmd_flush_queue_region_flush =
9005 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9007 cmdline_parse_token_string_t cmd_flush_queue_region_what =
9008 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9011 cmdline_parse_inst_t cmd_flush_queue_region = {
9012 .f = cmd_flush_queue_region_parsed,
9014 .help_str = "set port <port_id> queue-region flush on|off"
9015 ": flush all queue region related configuration",
9017 (void *)&cmd_flush_queue_region_set,
9018 (void *)&cmd_flush_queue_region_port,
9019 (void *)&cmd_flush_queue_region_port_index,
9020 (void *)&cmd_flush_queue_region_cmd,
9021 (void *)&cmd_flush_queue_region_flush,
9022 (void *)&cmd_flush_queue_region_what,
9027 /* *** get all queue region related configuration info *** */
9028 struct cmd_show_queue_region_info {
9029 cmdline_fixed_string_t show;
9030 cmdline_fixed_string_t port;
9032 cmdline_fixed_string_t cmd;
9036 cmd_show_queue_region_info_parsed(void *parsed_result,
9037 __attribute__((unused)) struct cmdline *cl,
9038 __attribute__((unused)) void *data)
9040 struct cmd_show_queue_region_info *res = parsed_result;
9042 #ifdef RTE_LIBRTE_I40E_PMD
9043 struct rte_pmd_i40e_queue_regions rte_pmd_regions;
9044 enum rte_pmd_i40e_queue_region_op op_type;
9047 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9050 #ifdef RTE_LIBRTE_I40E_PMD
9051 memset(&rte_pmd_regions, 0, sizeof(rte_pmd_regions));
9053 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_INFO_GET;
9055 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9056 op_type, &rte_pmd_regions);
9058 port_queue_region_info_display(res->port_id, &rte_pmd_regions);
9065 printf("function not implemented or supported\n");
9068 printf("queue region config info show error: (%s)\n",
9073 cmdline_parse_token_string_t cmd_show_queue_region_info_get =
9074 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
9076 cmdline_parse_token_string_t cmd_show_queue_region_info_port =
9077 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
9079 cmdline_parse_token_num_t cmd_show_queue_region_info_port_index =
9080 TOKEN_NUM_INITIALIZER(struct cmd_show_queue_region_info,
9082 cmdline_parse_token_string_t cmd_show_queue_region_info_cmd =
9083 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
9084 cmd, "queue-region");
9086 cmdline_parse_inst_t cmd_show_queue_region_info_all = {
9087 .f = cmd_show_queue_region_info_parsed,
9089 .help_str = "show port <port_id> queue-region"
9090 ": show all queue region related configuration info",
9092 (void *)&cmd_show_queue_region_info_get,
9093 (void *)&cmd_show_queue_region_info_port,
9094 (void *)&cmd_show_queue_region_info_port_index,
9095 (void *)&cmd_show_queue_region_info_cmd,
9100 /* *** ADD/REMOVE A 2tuple FILTER *** */
9101 struct cmd_2tuple_filter_result {
9102 cmdline_fixed_string_t filter;
9104 cmdline_fixed_string_t ops;
9105 cmdline_fixed_string_t dst_port;
9106 uint16_t dst_port_value;
9107 cmdline_fixed_string_t protocol;
9108 uint8_t protocol_value;
9109 cmdline_fixed_string_t mask;
9111 cmdline_fixed_string_t tcp_flags;
9112 uint8_t tcp_flags_value;
9113 cmdline_fixed_string_t priority;
9114 uint8_t priority_value;
9115 cmdline_fixed_string_t queue;
9120 cmd_2tuple_filter_parsed(void *parsed_result,
9121 __attribute__((unused)) struct cmdline *cl,
9122 __attribute__((unused)) void *data)
9124 struct rte_eth_ntuple_filter filter;
9125 struct cmd_2tuple_filter_result *res = parsed_result;
9128 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
9130 printf("ntuple filter is not supported on port %u.\n",
9135 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
9137 filter.flags = RTE_2TUPLE_FLAGS;
9138 filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
9139 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
9140 filter.proto = res->protocol_value;
9141 filter.priority = res->priority_value;
9142 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
9143 printf("nonzero tcp_flags is only meaningful"
9144 " when protocol is TCP.\n");
9147 if (res->tcp_flags_value > TCP_FLAG_ALL) {
9148 printf("invalid TCP flags.\n");
9152 if (res->tcp_flags_value != 0) {
9153 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
9154 filter.tcp_flags = res->tcp_flags_value;
9157 /* need convert to big endian. */
9158 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
9159 filter.queue = res->queue_id;
9161 if (!strcmp(res->ops, "add"))
9162 ret = rte_eth_dev_filter_ctrl(res->port_id,
9163 RTE_ETH_FILTER_NTUPLE,
9167 ret = rte_eth_dev_filter_ctrl(res->port_id,
9168 RTE_ETH_FILTER_NTUPLE,
9169 RTE_ETH_FILTER_DELETE,
9172 printf("2tuple filter programming error: (%s)\n",
9177 cmdline_parse_token_string_t cmd_2tuple_filter_filter =
9178 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9179 filter, "2tuple_filter");
9180 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
9181 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9183 cmdline_parse_token_string_t cmd_2tuple_filter_ops =
9184 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9186 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
9187 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9188 dst_port, "dst_port");
9189 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
9190 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9191 dst_port_value, UINT16);
9192 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
9193 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9194 protocol, "protocol");
9195 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
9196 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9197 protocol_value, UINT8);
9198 cmdline_parse_token_string_t cmd_2tuple_filter_mask =
9199 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9201 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value =
9202 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9204 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags =
9205 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9206 tcp_flags, "tcp_flags");
9207 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value =
9208 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9209 tcp_flags_value, UINT8);
9210 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
9211 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9212 priority, "priority");
9213 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
9214 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9215 priority_value, UINT8);
9216 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
9217 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9219 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
9220 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9223 cmdline_parse_inst_t cmd_2tuple_filter = {
9224 .f = cmd_2tuple_filter_parsed,
9226 .help_str = "2tuple_filter <port_id> add|del dst_port <value> protocol "
9227 "<value> mask <value> tcp_flags <value> priority <value> queue "
9228 "<queue_id>: Add a 2tuple filter",
9230 (void *)&cmd_2tuple_filter_filter,
9231 (void *)&cmd_2tuple_filter_port_id,
9232 (void *)&cmd_2tuple_filter_ops,
9233 (void *)&cmd_2tuple_filter_dst_port,
9234 (void *)&cmd_2tuple_filter_dst_port_value,
9235 (void *)&cmd_2tuple_filter_protocol,
9236 (void *)&cmd_2tuple_filter_protocol_value,
9237 (void *)&cmd_2tuple_filter_mask,
9238 (void *)&cmd_2tuple_filter_mask_value,
9239 (void *)&cmd_2tuple_filter_tcp_flags,
9240 (void *)&cmd_2tuple_filter_tcp_flags_value,
9241 (void *)&cmd_2tuple_filter_priority,
9242 (void *)&cmd_2tuple_filter_priority_value,
9243 (void *)&cmd_2tuple_filter_queue,
9244 (void *)&cmd_2tuple_filter_queue_id,
9249 /* *** ADD/REMOVE A 5tuple FILTER *** */
9250 struct cmd_5tuple_filter_result {
9251 cmdline_fixed_string_t filter;
9253 cmdline_fixed_string_t ops;
9254 cmdline_fixed_string_t dst_ip;
9255 cmdline_ipaddr_t dst_ip_value;
9256 cmdline_fixed_string_t src_ip;
9257 cmdline_ipaddr_t src_ip_value;
9258 cmdline_fixed_string_t dst_port;
9259 uint16_t dst_port_value;
9260 cmdline_fixed_string_t src_port;
9261 uint16_t src_port_value;
9262 cmdline_fixed_string_t protocol;
9263 uint8_t protocol_value;
9264 cmdline_fixed_string_t mask;
9266 cmdline_fixed_string_t tcp_flags;
9267 uint8_t tcp_flags_value;
9268 cmdline_fixed_string_t priority;
9269 uint8_t priority_value;
9270 cmdline_fixed_string_t queue;
9275 cmd_5tuple_filter_parsed(void *parsed_result,
9276 __attribute__((unused)) struct cmdline *cl,
9277 __attribute__((unused)) void *data)
9279 struct rte_eth_ntuple_filter filter;
9280 struct cmd_5tuple_filter_result *res = parsed_result;
9283 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
9285 printf("ntuple filter is not supported on port %u.\n",
9290 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
9292 filter.flags = RTE_5TUPLE_FLAGS;
9293 filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0;
9294 filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0;
9295 filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0;
9296 filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
9297 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
9298 filter.proto = res->protocol_value;
9299 filter.priority = res->priority_value;
9300 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
9301 printf("nonzero tcp_flags is only meaningful"
9302 " when protocol is TCP.\n");
9305 if (res->tcp_flags_value > TCP_FLAG_ALL) {
9306 printf("invalid TCP flags.\n");
9310 if (res->tcp_flags_value != 0) {
9311 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
9312 filter.tcp_flags = res->tcp_flags_value;
9315 if (res->dst_ip_value.family == AF_INET)
9316 /* no need to convert, already big endian. */
9317 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
9319 if (filter.dst_ip_mask == 0) {
9320 printf("can not support ipv6 involved compare.\n");
9326 if (res->src_ip_value.family == AF_INET)
9327 /* no need to convert, already big endian. */
9328 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
9330 if (filter.src_ip_mask == 0) {
9331 printf("can not support ipv6 involved compare.\n");
9336 /* need convert to big endian. */
9337 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
9338 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
9339 filter.queue = res->queue_id;
9341 if (!strcmp(res->ops, "add"))
9342 ret = rte_eth_dev_filter_ctrl(res->port_id,
9343 RTE_ETH_FILTER_NTUPLE,
9347 ret = rte_eth_dev_filter_ctrl(res->port_id,
9348 RTE_ETH_FILTER_NTUPLE,
9349 RTE_ETH_FILTER_DELETE,
9352 printf("5tuple filter programming error: (%s)\n",
9356 cmdline_parse_token_string_t cmd_5tuple_filter_filter =
9357 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9358 filter, "5tuple_filter");
9359 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
9360 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9362 cmdline_parse_token_string_t cmd_5tuple_filter_ops =
9363 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9365 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
9366 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9368 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
9369 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
9371 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
9372 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9374 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
9375 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
9377 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
9378 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9379 dst_port, "dst_port");
9380 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
9381 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9382 dst_port_value, UINT16);
9383 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
9384 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9385 src_port, "src_port");
9386 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
9387 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9388 src_port_value, UINT16);
9389 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
9390 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9391 protocol, "protocol");
9392 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
9393 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9394 protocol_value, UINT8);
9395 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
9396 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9398 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
9399 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9401 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags =
9402 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9403 tcp_flags, "tcp_flags");
9404 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value =
9405 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9406 tcp_flags_value, UINT8);
9407 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
9408 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9409 priority, "priority");
9410 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
9411 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9412 priority_value, UINT8);
9413 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
9414 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9416 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
9417 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9420 cmdline_parse_inst_t cmd_5tuple_filter = {
9421 .f = cmd_5tuple_filter_parsed,
9423 .help_str = "5tuple_filter <port_id> add|del dst_ip <value> "
9424 "src_ip <value> dst_port <value> src_port <value> "
9425 "protocol <value> mask <value> tcp_flags <value> "
9426 "priority <value> queue <queue_id>: Add/Del a 5tuple filter",
9428 (void *)&cmd_5tuple_filter_filter,
9429 (void *)&cmd_5tuple_filter_port_id,
9430 (void *)&cmd_5tuple_filter_ops,
9431 (void *)&cmd_5tuple_filter_dst_ip,
9432 (void *)&cmd_5tuple_filter_dst_ip_value,
9433 (void *)&cmd_5tuple_filter_src_ip,
9434 (void *)&cmd_5tuple_filter_src_ip_value,
9435 (void *)&cmd_5tuple_filter_dst_port,
9436 (void *)&cmd_5tuple_filter_dst_port_value,
9437 (void *)&cmd_5tuple_filter_src_port,
9438 (void *)&cmd_5tuple_filter_src_port_value,
9439 (void *)&cmd_5tuple_filter_protocol,
9440 (void *)&cmd_5tuple_filter_protocol_value,
9441 (void *)&cmd_5tuple_filter_mask,
9442 (void *)&cmd_5tuple_filter_mask_value,
9443 (void *)&cmd_5tuple_filter_tcp_flags,
9444 (void *)&cmd_5tuple_filter_tcp_flags_value,
9445 (void *)&cmd_5tuple_filter_priority,
9446 (void *)&cmd_5tuple_filter_priority_value,
9447 (void *)&cmd_5tuple_filter_queue,
9448 (void *)&cmd_5tuple_filter_queue_id,
9453 /* *** ADD/REMOVE A flex FILTER *** */
9454 struct cmd_flex_filter_result {
9455 cmdline_fixed_string_t filter;
9456 cmdline_fixed_string_t ops;
9458 cmdline_fixed_string_t len;
9460 cmdline_fixed_string_t bytes;
9461 cmdline_fixed_string_t bytes_value;
9462 cmdline_fixed_string_t mask;
9463 cmdline_fixed_string_t mask_value;
9464 cmdline_fixed_string_t priority;
9465 uint8_t priority_value;
9466 cmdline_fixed_string_t queue;
9470 static int xdigit2val(unsigned char c)
9475 else if (isupper(c))
9483 cmd_flex_filter_parsed(void *parsed_result,
9484 __attribute__((unused)) struct cmdline *cl,
9485 __attribute__((unused)) void *data)
9488 struct rte_eth_flex_filter filter;
9489 struct cmd_flex_filter_result *res = parsed_result;
9490 char *bytes_ptr, *mask_ptr;
9491 uint16_t len, i, j = 0;
9496 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) {
9497 printf("the len exceed the max length 128\n");
9500 memset(&filter, 0, sizeof(struct rte_eth_flex_filter));
9501 filter.len = res->len_value;
9502 filter.priority = res->priority_value;
9503 filter.queue = res->queue_id;
9504 bytes_ptr = res->bytes_value;
9505 mask_ptr = res->mask_value;
9507 /* translate bytes string to array. */
9508 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
9509 (bytes_ptr[1] == 'X')))
9511 len = strnlen(bytes_ptr, res->len_value * 2);
9512 if (len == 0 || (len % 8 != 0)) {
9513 printf("please check len and bytes input\n");
9516 for (i = 0; i < len; i++) {
9518 if (isxdigit(c) == 0) {
9519 /* invalid characters. */
9520 printf("invalid input\n");
9523 val = xdigit2val(c);
9526 filter.bytes[j] = byte;
9527 printf("bytes[%d]:%02x ", j, filter.bytes[j]);
9534 /* translate mask string to uint8_t array. */
9535 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
9536 (mask_ptr[1] == 'X')))
9538 len = strnlen(mask_ptr, (res->len_value + 3) / 4);
9540 printf("invalid input\n");
9545 for (i = 0; i < len; i++) {
9547 if (isxdigit(c) == 0) {
9548 /* invalid characters. */
9549 printf("invalid input\n");
9552 val = xdigit2val(c);
9555 filter.mask[j] = byte;
9556 printf("mask[%d]:%02x ", j, filter.mask[j]);
9564 if (!strcmp(res->ops, "add"))
9565 ret = rte_eth_dev_filter_ctrl(res->port_id,
9566 RTE_ETH_FILTER_FLEXIBLE,
9570 ret = rte_eth_dev_filter_ctrl(res->port_id,
9571 RTE_ETH_FILTER_FLEXIBLE,
9572 RTE_ETH_FILTER_DELETE,
9576 printf("flex filter setting error: (%s)\n", strerror(-ret));
9579 cmdline_parse_token_string_t cmd_flex_filter_filter =
9580 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9581 filter, "flex_filter");
9582 cmdline_parse_token_num_t cmd_flex_filter_port_id =
9583 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
9585 cmdline_parse_token_string_t cmd_flex_filter_ops =
9586 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9588 cmdline_parse_token_string_t cmd_flex_filter_len =
9589 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9591 cmdline_parse_token_num_t cmd_flex_filter_len_value =
9592 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
9594 cmdline_parse_token_string_t cmd_flex_filter_bytes =
9595 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9597 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
9598 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9600 cmdline_parse_token_string_t cmd_flex_filter_mask =
9601 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9603 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
9604 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9606 cmdline_parse_token_string_t cmd_flex_filter_priority =
9607 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9608 priority, "priority");
9609 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
9610 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
9611 priority_value, UINT8);
9612 cmdline_parse_token_string_t cmd_flex_filter_queue =
9613 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9615 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
9616 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
9618 cmdline_parse_inst_t cmd_flex_filter = {
9619 .f = cmd_flex_filter_parsed,
9621 .help_str = "flex_filter <port_id> add|del len <value> bytes "
9622 "<value> mask <value> priority <value> queue <queue_id>: "
9623 "Add/Del a flex filter",
9625 (void *)&cmd_flex_filter_filter,
9626 (void *)&cmd_flex_filter_port_id,
9627 (void *)&cmd_flex_filter_ops,
9628 (void *)&cmd_flex_filter_len,
9629 (void *)&cmd_flex_filter_len_value,
9630 (void *)&cmd_flex_filter_bytes,
9631 (void *)&cmd_flex_filter_bytes_value,
9632 (void *)&cmd_flex_filter_mask,
9633 (void *)&cmd_flex_filter_mask_value,
9634 (void *)&cmd_flex_filter_priority,
9635 (void *)&cmd_flex_filter_priority_value,
9636 (void *)&cmd_flex_filter_queue,
9637 (void *)&cmd_flex_filter_queue_id,
9642 /* *** Filters Control *** */
9644 /* *** deal with ethertype filter *** */
9645 struct cmd_ethertype_filter_result {
9646 cmdline_fixed_string_t filter;
9648 cmdline_fixed_string_t ops;
9649 cmdline_fixed_string_t mac;
9650 struct ether_addr mac_addr;
9651 cmdline_fixed_string_t ethertype;
9652 uint16_t ethertype_value;
9653 cmdline_fixed_string_t drop;
9654 cmdline_fixed_string_t queue;
9658 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
9659 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9660 filter, "ethertype_filter");
9661 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
9662 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
9664 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
9665 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9667 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
9668 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9669 mac, "mac_addr#mac_ignr");
9670 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
9671 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
9673 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
9674 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9675 ethertype, "ethertype");
9676 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
9677 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
9678 ethertype_value, UINT16);
9679 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
9680 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9682 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
9683 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9685 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
9686 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
9690 cmd_ethertype_filter_parsed(void *parsed_result,
9691 __attribute__((unused)) struct cmdline *cl,
9692 __attribute__((unused)) void *data)
9694 struct cmd_ethertype_filter_result *res = parsed_result;
9695 struct rte_eth_ethertype_filter filter;
9698 ret = rte_eth_dev_filter_supported(res->port_id,
9699 RTE_ETH_FILTER_ETHERTYPE);
9701 printf("ethertype filter is not supported on port %u.\n",
9706 memset(&filter, 0, sizeof(filter));
9707 if (!strcmp(res->mac, "mac_addr")) {
9708 filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
9709 rte_memcpy(&filter.mac_addr, &res->mac_addr,
9710 sizeof(struct ether_addr));
9712 if (!strcmp(res->drop, "drop"))
9713 filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
9714 filter.ether_type = res->ethertype_value;
9715 filter.queue = res->queue_id;
9717 if (!strcmp(res->ops, "add"))
9718 ret = rte_eth_dev_filter_ctrl(res->port_id,
9719 RTE_ETH_FILTER_ETHERTYPE,
9723 ret = rte_eth_dev_filter_ctrl(res->port_id,
9724 RTE_ETH_FILTER_ETHERTYPE,
9725 RTE_ETH_FILTER_DELETE,
9728 printf("ethertype filter programming error: (%s)\n",
9732 cmdline_parse_inst_t cmd_ethertype_filter = {
9733 .f = cmd_ethertype_filter_parsed,
9735 .help_str = "ethertype_filter <port_id> add|del mac_addr|mac_ignr "
9736 "<mac_addr> ethertype <value> drop|fw queue <queue_id>: "
9737 "Add or delete an ethertype filter entry",
9739 (void *)&cmd_ethertype_filter_filter,
9740 (void *)&cmd_ethertype_filter_port_id,
9741 (void *)&cmd_ethertype_filter_ops,
9742 (void *)&cmd_ethertype_filter_mac,
9743 (void *)&cmd_ethertype_filter_mac_addr,
9744 (void *)&cmd_ethertype_filter_ethertype,
9745 (void *)&cmd_ethertype_filter_ethertype_value,
9746 (void *)&cmd_ethertype_filter_drop,
9747 (void *)&cmd_ethertype_filter_queue,
9748 (void *)&cmd_ethertype_filter_queue_id,
9753 /* *** deal with flow director filter *** */
9754 struct cmd_flow_director_result {
9755 cmdline_fixed_string_t flow_director_filter;
9757 cmdline_fixed_string_t mode;
9758 cmdline_fixed_string_t mode_value;
9759 cmdline_fixed_string_t ops;
9760 cmdline_fixed_string_t flow;
9761 cmdline_fixed_string_t flow_type;
9762 cmdline_fixed_string_t ether;
9763 uint16_t ether_type;
9764 cmdline_fixed_string_t src;
9765 cmdline_ipaddr_t ip_src;
9767 cmdline_fixed_string_t dst;
9768 cmdline_ipaddr_t ip_dst;
9770 cmdline_fixed_string_t verify_tag;
9771 uint32_t verify_tag_value;
9772 cmdline_ipaddr_t tos;
9774 cmdline_ipaddr_t proto;
9775 uint8_t proto_value;
9776 cmdline_ipaddr_t ttl;
9778 cmdline_fixed_string_t vlan;
9779 uint16_t vlan_value;
9780 cmdline_fixed_string_t flexbytes;
9781 cmdline_fixed_string_t flexbytes_value;
9782 cmdline_fixed_string_t pf_vf;
9783 cmdline_fixed_string_t drop;
9784 cmdline_fixed_string_t queue;
9786 cmdline_fixed_string_t fd_id;
9787 uint32_t fd_id_value;
9788 cmdline_fixed_string_t mac;
9789 struct ether_addr mac_addr;
9790 cmdline_fixed_string_t tunnel;
9791 cmdline_fixed_string_t tunnel_type;
9792 cmdline_fixed_string_t tunnel_id;
9793 uint32_t tunnel_id_value;
9797 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
9800 const char *p, *p0 = q_arg;
9802 unsigned long int_fld;
9803 char *str_fld[max_num];
9808 p = strchr(p0, '(');
9812 p0 = strchr(p, ')');
9817 if (size >= sizeof(s))
9820 snprintf(s, sizeof(s), "%.*s", size, p);
9821 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
9822 if (ret < 0 || ret > max_num)
9824 for (i = 0; i < ret; i++) {
9826 int_fld = strtoul(str_fld[i], &end, 0);
9827 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
9829 flexbytes[i] = (uint8_t)int_fld;
9835 str2flowtype(char *string)
9838 static const struct {
9841 } flowtype_str[] = {
9842 {"raw", RTE_ETH_FLOW_RAW},
9843 {"ipv4", RTE_ETH_FLOW_IPV4},
9844 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
9845 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
9846 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
9847 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
9848 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
9849 {"ipv6", RTE_ETH_FLOW_IPV6},
9850 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
9851 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
9852 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
9853 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
9854 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
9855 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
9858 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
9859 if (!strcmp(flowtype_str[i].str, string))
9860 return flowtype_str[i].type;
9863 if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64)
9864 return (uint16_t)atoi(string);
9866 return RTE_ETH_FLOW_UNKNOWN;
9869 static enum rte_eth_fdir_tunnel_type
9870 str2fdir_tunneltype(char *string)
9874 static const struct {
9876 enum rte_eth_fdir_tunnel_type type;
9877 } tunneltype_str[] = {
9878 {"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE},
9879 {"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN},
9882 for (i = 0; i < RTE_DIM(tunneltype_str); i++) {
9883 if (!strcmp(tunneltype_str[i].str, string))
9884 return tunneltype_str[i].type;
9886 return RTE_FDIR_TUNNEL_TYPE_UNKNOWN;
9889 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
9891 if ((ip_addr).family == AF_INET) \
9892 (ip) = (ip_addr).addr.ipv4.s_addr; \
9894 printf("invalid parameter.\n"); \
9899 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
9901 if ((ip_addr).family == AF_INET6) \
9903 &((ip_addr).addr.ipv6), \
9904 sizeof(struct in6_addr)); \
9906 printf("invalid parameter.\n"); \
9912 cmd_flow_director_filter_parsed(void *parsed_result,
9913 __attribute__((unused)) struct cmdline *cl,
9914 __attribute__((unused)) void *data)
9916 struct cmd_flow_director_result *res = parsed_result;
9917 struct rte_eth_fdir_filter entry;
9918 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
9920 unsigned long vf_id;
9923 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
9925 printf("flow director is not supported on port %u.\n",
9929 memset(flexbytes, 0, sizeof(flexbytes));
9930 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
9932 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
9933 if (strcmp(res->mode_value, "MAC-VLAN")) {
9934 printf("Please set mode to MAC-VLAN.\n");
9937 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
9938 if (strcmp(res->mode_value, "Tunnel")) {
9939 printf("Please set mode to Tunnel.\n");
9943 if (strcmp(res->mode_value, "IP")) {
9944 printf("Please set mode to IP.\n");
9947 entry.input.flow_type = str2flowtype(res->flow_type);
9950 ret = parse_flexbytes(res->flexbytes_value,
9952 RTE_ETH_FDIR_MAX_FLEXLEN);
9954 printf("error: Cannot parse flexbytes input.\n");
9958 switch (entry.input.flow_type) {
9959 case RTE_ETH_FLOW_FRAG_IPV4:
9960 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
9961 entry.input.flow.ip4_flow.proto = res->proto_value;
9963 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
9964 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
9965 IPV4_ADDR_TO_UINT(res->ip_dst,
9966 entry.input.flow.ip4_flow.dst_ip);
9967 IPV4_ADDR_TO_UINT(res->ip_src,
9968 entry.input.flow.ip4_flow.src_ip);
9969 entry.input.flow.ip4_flow.tos = res->tos_value;
9970 entry.input.flow.ip4_flow.ttl = res->ttl_value;
9971 /* need convert to big endian. */
9972 entry.input.flow.udp4_flow.dst_port =
9973 rte_cpu_to_be_16(res->port_dst);
9974 entry.input.flow.udp4_flow.src_port =
9975 rte_cpu_to_be_16(res->port_src);
9977 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
9978 IPV4_ADDR_TO_UINT(res->ip_dst,
9979 entry.input.flow.sctp4_flow.ip.dst_ip);
9980 IPV4_ADDR_TO_UINT(res->ip_src,
9981 entry.input.flow.sctp4_flow.ip.src_ip);
9982 entry.input.flow.ip4_flow.tos = res->tos_value;
9983 entry.input.flow.ip4_flow.ttl = res->ttl_value;
9984 /* need convert to big endian. */
9985 entry.input.flow.sctp4_flow.dst_port =
9986 rte_cpu_to_be_16(res->port_dst);
9987 entry.input.flow.sctp4_flow.src_port =
9988 rte_cpu_to_be_16(res->port_src);
9989 entry.input.flow.sctp4_flow.verify_tag =
9990 rte_cpu_to_be_32(res->verify_tag_value);
9992 case RTE_ETH_FLOW_FRAG_IPV6:
9993 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
9994 entry.input.flow.ipv6_flow.proto = res->proto_value;
9996 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
9997 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
9998 IPV6_ADDR_TO_ARRAY(res->ip_dst,
9999 entry.input.flow.ipv6_flow.dst_ip);
10000 IPV6_ADDR_TO_ARRAY(res->ip_src,
10001 entry.input.flow.ipv6_flow.src_ip);
10002 entry.input.flow.ipv6_flow.tc = res->tos_value;
10003 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
10004 /* need convert to big endian. */
10005 entry.input.flow.udp6_flow.dst_port =
10006 rte_cpu_to_be_16(res->port_dst);
10007 entry.input.flow.udp6_flow.src_port =
10008 rte_cpu_to_be_16(res->port_src);
10010 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
10011 IPV6_ADDR_TO_ARRAY(res->ip_dst,
10012 entry.input.flow.sctp6_flow.ip.dst_ip);
10013 IPV6_ADDR_TO_ARRAY(res->ip_src,
10014 entry.input.flow.sctp6_flow.ip.src_ip);
10015 entry.input.flow.ipv6_flow.tc = res->tos_value;
10016 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
10017 /* need convert to big endian. */
10018 entry.input.flow.sctp6_flow.dst_port =
10019 rte_cpu_to_be_16(res->port_dst);
10020 entry.input.flow.sctp6_flow.src_port =
10021 rte_cpu_to_be_16(res->port_src);
10022 entry.input.flow.sctp6_flow.verify_tag =
10023 rte_cpu_to_be_32(res->verify_tag_value);
10025 case RTE_ETH_FLOW_L2_PAYLOAD:
10026 entry.input.flow.l2_flow.ether_type =
10027 rte_cpu_to_be_16(res->ether_type);
10033 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN)
10034 rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr,
10036 sizeof(struct ether_addr));
10038 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
10039 rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr,
10041 sizeof(struct ether_addr));
10042 entry.input.flow.tunnel_flow.tunnel_type =
10043 str2fdir_tunneltype(res->tunnel_type);
10044 entry.input.flow.tunnel_flow.tunnel_id =
10045 rte_cpu_to_be_32(res->tunnel_id_value);
10048 rte_memcpy(entry.input.flow_ext.flexbytes,
10050 RTE_ETH_FDIR_MAX_FLEXLEN);
10052 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
10054 entry.action.flex_off = 0; /*use 0 by default */
10055 if (!strcmp(res->drop, "drop"))
10056 entry.action.behavior = RTE_ETH_FDIR_REJECT;
10058 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
10060 if (fdir_conf.mode != RTE_FDIR_MODE_PERFECT_MAC_VLAN &&
10061 fdir_conf.mode != RTE_FDIR_MODE_PERFECT_TUNNEL) {
10062 if (!strcmp(res->pf_vf, "pf"))
10063 entry.input.flow_ext.is_vf = 0;
10064 else if (!strncmp(res->pf_vf, "vf", 2)) {
10065 struct rte_eth_dev_info dev_info;
10067 memset(&dev_info, 0, sizeof(dev_info));
10068 rte_eth_dev_info_get(res->port_id, &dev_info);
10070 vf_id = strtoul(res->pf_vf + 2, &end, 10);
10071 if (errno != 0 || *end != '\0' ||
10072 vf_id >= dev_info.max_vfs) {
10073 printf("invalid parameter %s.\n", res->pf_vf);
10076 entry.input.flow_ext.is_vf = 1;
10077 entry.input.flow_ext.dst_id = (uint16_t)vf_id;
10079 printf("invalid parameter %s.\n", res->pf_vf);
10084 /* set to report FD ID by default */
10085 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
10086 entry.action.rx_queue = res->queue_id;
10087 entry.soft_id = res->fd_id_value;
10088 if (!strcmp(res->ops, "add"))
10089 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10090 RTE_ETH_FILTER_ADD, &entry);
10091 else if (!strcmp(res->ops, "del"))
10092 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10093 RTE_ETH_FILTER_DELETE, &entry);
10095 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10096 RTE_ETH_FILTER_UPDATE, &entry);
10098 printf("flow director programming error: (%s)\n",
10102 cmdline_parse_token_string_t cmd_flow_director_filter =
10103 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10104 flow_director_filter, "flow_director_filter");
10105 cmdline_parse_token_num_t cmd_flow_director_port_id =
10106 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10108 cmdline_parse_token_string_t cmd_flow_director_ops =
10109 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10110 ops, "add#del#update");
10111 cmdline_parse_token_string_t cmd_flow_director_flow =
10112 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10114 cmdline_parse_token_string_t cmd_flow_director_flow_type =
10115 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10116 flow_type, "ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
10117 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload");
10118 cmdline_parse_token_string_t cmd_flow_director_ether =
10119 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10121 cmdline_parse_token_num_t cmd_flow_director_ether_type =
10122 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10123 ether_type, UINT16);
10124 cmdline_parse_token_string_t cmd_flow_director_src =
10125 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10127 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
10128 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
10130 cmdline_parse_token_num_t cmd_flow_director_port_src =
10131 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10133 cmdline_parse_token_string_t cmd_flow_director_dst =
10134 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10136 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
10137 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
10139 cmdline_parse_token_num_t cmd_flow_director_port_dst =
10140 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10142 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
10143 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10144 verify_tag, "verify_tag");
10145 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
10146 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10147 verify_tag_value, UINT32);
10148 cmdline_parse_token_string_t cmd_flow_director_tos =
10149 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10151 cmdline_parse_token_num_t cmd_flow_director_tos_value =
10152 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10154 cmdline_parse_token_string_t cmd_flow_director_proto =
10155 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10157 cmdline_parse_token_num_t cmd_flow_director_proto_value =
10158 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10159 proto_value, UINT8);
10160 cmdline_parse_token_string_t cmd_flow_director_ttl =
10161 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10163 cmdline_parse_token_num_t cmd_flow_director_ttl_value =
10164 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10166 cmdline_parse_token_string_t cmd_flow_director_vlan =
10167 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10169 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
10170 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10171 vlan_value, UINT16);
10172 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
10173 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10174 flexbytes, "flexbytes");
10175 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
10176 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10177 flexbytes_value, NULL);
10178 cmdline_parse_token_string_t cmd_flow_director_drop =
10179 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10181 cmdline_parse_token_string_t cmd_flow_director_pf_vf =
10182 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10184 cmdline_parse_token_string_t cmd_flow_director_queue =
10185 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10187 cmdline_parse_token_num_t cmd_flow_director_queue_id =
10188 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10190 cmdline_parse_token_string_t cmd_flow_director_fd_id =
10191 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10193 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
10194 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10195 fd_id_value, UINT32);
10197 cmdline_parse_token_string_t cmd_flow_director_mode =
10198 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10200 cmdline_parse_token_string_t cmd_flow_director_mode_ip =
10201 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10203 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan =
10204 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10205 mode_value, "MAC-VLAN");
10206 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel =
10207 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10208 mode_value, "Tunnel");
10209 cmdline_parse_token_string_t cmd_flow_director_mac =
10210 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10212 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr =
10213 TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result,
10215 cmdline_parse_token_string_t cmd_flow_director_tunnel =
10216 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10218 cmdline_parse_token_string_t cmd_flow_director_tunnel_type =
10219 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10220 tunnel_type, "NVGRE#VxLAN");
10221 cmdline_parse_token_string_t cmd_flow_director_tunnel_id =
10222 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10223 tunnel_id, "tunnel-id");
10224 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value =
10225 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10226 tunnel_id_value, UINT32);
10228 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
10229 .f = cmd_flow_director_filter_parsed,
10231 .help_str = "flow_director_filter <port_id> mode IP add|del|update flow"
10232 " ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
10233 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
10234 "l2_payload src <src_ip> dst <dst_ip> tos <tos_value> "
10235 "proto <proto_value> ttl <ttl_value> vlan <vlan_value> "
10236 "flexbytes <flexbyte_values> drop|fw <pf_vf> queue <queue_id> "
10237 "fd_id <fd_id_value>: "
10238 "Add or delete an ip flow director entry on NIC",
10240 (void *)&cmd_flow_director_filter,
10241 (void *)&cmd_flow_director_port_id,
10242 (void *)&cmd_flow_director_mode,
10243 (void *)&cmd_flow_director_mode_ip,
10244 (void *)&cmd_flow_director_ops,
10245 (void *)&cmd_flow_director_flow,
10246 (void *)&cmd_flow_director_flow_type,
10247 (void *)&cmd_flow_director_src,
10248 (void *)&cmd_flow_director_ip_src,
10249 (void *)&cmd_flow_director_dst,
10250 (void *)&cmd_flow_director_ip_dst,
10251 (void *)&cmd_flow_director_tos,
10252 (void *)&cmd_flow_director_tos_value,
10253 (void *)&cmd_flow_director_proto,
10254 (void *)&cmd_flow_director_proto_value,
10255 (void *)&cmd_flow_director_ttl,
10256 (void *)&cmd_flow_director_ttl_value,
10257 (void *)&cmd_flow_director_vlan,
10258 (void *)&cmd_flow_director_vlan_value,
10259 (void *)&cmd_flow_director_flexbytes,
10260 (void *)&cmd_flow_director_flexbytes_value,
10261 (void *)&cmd_flow_director_drop,
10262 (void *)&cmd_flow_director_pf_vf,
10263 (void *)&cmd_flow_director_queue,
10264 (void *)&cmd_flow_director_queue_id,
10265 (void *)&cmd_flow_director_fd_id,
10266 (void *)&cmd_flow_director_fd_id_value,
10271 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
10272 .f = cmd_flow_director_filter_parsed,
10274 .help_str = "flow_director_filter ... : Add or delete an udp/tcp flow "
10275 "director entry on NIC",
10277 (void *)&cmd_flow_director_filter,
10278 (void *)&cmd_flow_director_port_id,
10279 (void *)&cmd_flow_director_mode,
10280 (void *)&cmd_flow_director_mode_ip,
10281 (void *)&cmd_flow_director_ops,
10282 (void *)&cmd_flow_director_flow,
10283 (void *)&cmd_flow_director_flow_type,
10284 (void *)&cmd_flow_director_src,
10285 (void *)&cmd_flow_director_ip_src,
10286 (void *)&cmd_flow_director_port_src,
10287 (void *)&cmd_flow_director_dst,
10288 (void *)&cmd_flow_director_ip_dst,
10289 (void *)&cmd_flow_director_port_dst,
10290 (void *)&cmd_flow_director_tos,
10291 (void *)&cmd_flow_director_tos_value,
10292 (void *)&cmd_flow_director_ttl,
10293 (void *)&cmd_flow_director_ttl_value,
10294 (void *)&cmd_flow_director_vlan,
10295 (void *)&cmd_flow_director_vlan_value,
10296 (void *)&cmd_flow_director_flexbytes,
10297 (void *)&cmd_flow_director_flexbytes_value,
10298 (void *)&cmd_flow_director_drop,
10299 (void *)&cmd_flow_director_pf_vf,
10300 (void *)&cmd_flow_director_queue,
10301 (void *)&cmd_flow_director_queue_id,
10302 (void *)&cmd_flow_director_fd_id,
10303 (void *)&cmd_flow_director_fd_id_value,
10308 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
10309 .f = cmd_flow_director_filter_parsed,
10311 .help_str = "flow_director_filter ... : Add or delete a sctp flow "
10312 "director entry on NIC",
10314 (void *)&cmd_flow_director_filter,
10315 (void *)&cmd_flow_director_port_id,
10316 (void *)&cmd_flow_director_mode,
10317 (void *)&cmd_flow_director_mode_ip,
10318 (void *)&cmd_flow_director_ops,
10319 (void *)&cmd_flow_director_flow,
10320 (void *)&cmd_flow_director_flow_type,
10321 (void *)&cmd_flow_director_src,
10322 (void *)&cmd_flow_director_ip_src,
10323 (void *)&cmd_flow_director_port_dst,
10324 (void *)&cmd_flow_director_dst,
10325 (void *)&cmd_flow_director_ip_dst,
10326 (void *)&cmd_flow_director_port_dst,
10327 (void *)&cmd_flow_director_verify_tag,
10328 (void *)&cmd_flow_director_verify_tag_value,
10329 (void *)&cmd_flow_director_tos,
10330 (void *)&cmd_flow_director_tos_value,
10331 (void *)&cmd_flow_director_ttl,
10332 (void *)&cmd_flow_director_ttl_value,
10333 (void *)&cmd_flow_director_vlan,
10334 (void *)&cmd_flow_director_vlan_value,
10335 (void *)&cmd_flow_director_flexbytes,
10336 (void *)&cmd_flow_director_flexbytes_value,
10337 (void *)&cmd_flow_director_drop,
10338 (void *)&cmd_flow_director_pf_vf,
10339 (void *)&cmd_flow_director_queue,
10340 (void *)&cmd_flow_director_queue_id,
10341 (void *)&cmd_flow_director_fd_id,
10342 (void *)&cmd_flow_director_fd_id_value,
10347 cmdline_parse_inst_t cmd_add_del_l2_flow_director = {
10348 .f = cmd_flow_director_filter_parsed,
10350 .help_str = "flow_director_filter ... : Add or delete a L2 flow "
10351 "director entry on NIC",
10353 (void *)&cmd_flow_director_filter,
10354 (void *)&cmd_flow_director_port_id,
10355 (void *)&cmd_flow_director_mode,
10356 (void *)&cmd_flow_director_mode_ip,
10357 (void *)&cmd_flow_director_ops,
10358 (void *)&cmd_flow_director_flow,
10359 (void *)&cmd_flow_director_flow_type,
10360 (void *)&cmd_flow_director_ether,
10361 (void *)&cmd_flow_director_ether_type,
10362 (void *)&cmd_flow_director_flexbytes,
10363 (void *)&cmd_flow_director_flexbytes_value,
10364 (void *)&cmd_flow_director_drop,
10365 (void *)&cmd_flow_director_pf_vf,
10366 (void *)&cmd_flow_director_queue,
10367 (void *)&cmd_flow_director_queue_id,
10368 (void *)&cmd_flow_director_fd_id,
10369 (void *)&cmd_flow_director_fd_id_value,
10374 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = {
10375 .f = cmd_flow_director_filter_parsed,
10377 .help_str = "flow_director_filter ... : Add or delete a MAC VLAN flow "
10378 "director entry on NIC",
10380 (void *)&cmd_flow_director_filter,
10381 (void *)&cmd_flow_director_port_id,
10382 (void *)&cmd_flow_director_mode,
10383 (void *)&cmd_flow_director_mode_mac_vlan,
10384 (void *)&cmd_flow_director_ops,
10385 (void *)&cmd_flow_director_mac,
10386 (void *)&cmd_flow_director_mac_addr,
10387 (void *)&cmd_flow_director_vlan,
10388 (void *)&cmd_flow_director_vlan_value,
10389 (void *)&cmd_flow_director_flexbytes,
10390 (void *)&cmd_flow_director_flexbytes_value,
10391 (void *)&cmd_flow_director_drop,
10392 (void *)&cmd_flow_director_queue,
10393 (void *)&cmd_flow_director_queue_id,
10394 (void *)&cmd_flow_director_fd_id,
10395 (void *)&cmd_flow_director_fd_id_value,
10400 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = {
10401 .f = cmd_flow_director_filter_parsed,
10403 .help_str = "flow_director_filter ... : Add or delete a tunnel flow "
10404 "director entry on NIC",
10406 (void *)&cmd_flow_director_filter,
10407 (void *)&cmd_flow_director_port_id,
10408 (void *)&cmd_flow_director_mode,
10409 (void *)&cmd_flow_director_mode_tunnel,
10410 (void *)&cmd_flow_director_ops,
10411 (void *)&cmd_flow_director_mac,
10412 (void *)&cmd_flow_director_mac_addr,
10413 (void *)&cmd_flow_director_vlan,
10414 (void *)&cmd_flow_director_vlan_value,
10415 (void *)&cmd_flow_director_tunnel,
10416 (void *)&cmd_flow_director_tunnel_type,
10417 (void *)&cmd_flow_director_tunnel_id,
10418 (void *)&cmd_flow_director_tunnel_id_value,
10419 (void *)&cmd_flow_director_flexbytes,
10420 (void *)&cmd_flow_director_flexbytes_value,
10421 (void *)&cmd_flow_director_drop,
10422 (void *)&cmd_flow_director_queue,
10423 (void *)&cmd_flow_director_queue_id,
10424 (void *)&cmd_flow_director_fd_id,
10425 (void *)&cmd_flow_director_fd_id_value,
10430 struct cmd_flush_flow_director_result {
10431 cmdline_fixed_string_t flush_flow_director;
10435 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
10436 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
10437 flush_flow_director, "flush_flow_director");
10438 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
10439 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
10443 cmd_flush_flow_director_parsed(void *parsed_result,
10444 __attribute__((unused)) struct cmdline *cl,
10445 __attribute__((unused)) void *data)
10447 struct cmd_flow_director_result *res = parsed_result;
10450 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
10452 printf("flow director is not supported on port %u.\n",
10457 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10458 RTE_ETH_FILTER_FLUSH, NULL);
10460 printf("flow director table flushing error: (%s)\n",
10464 cmdline_parse_inst_t cmd_flush_flow_director = {
10465 .f = cmd_flush_flow_director_parsed,
10467 .help_str = "flush_flow_director <port_id>: "
10468 "Flush all flow director entries of a device on NIC",
10470 (void *)&cmd_flush_flow_director_flush,
10471 (void *)&cmd_flush_flow_director_port_id,
10476 /* *** deal with flow director mask *** */
10477 struct cmd_flow_director_mask_result {
10478 cmdline_fixed_string_t flow_director_mask;
10480 cmdline_fixed_string_t mode;
10481 cmdline_fixed_string_t mode_value;
10482 cmdline_fixed_string_t vlan;
10483 uint16_t vlan_mask;
10484 cmdline_fixed_string_t src_mask;
10485 cmdline_ipaddr_t ipv4_src;
10486 cmdline_ipaddr_t ipv6_src;
10488 cmdline_fixed_string_t dst_mask;
10489 cmdline_ipaddr_t ipv4_dst;
10490 cmdline_ipaddr_t ipv6_dst;
10492 cmdline_fixed_string_t mac;
10493 uint8_t mac_addr_byte_mask;
10494 cmdline_fixed_string_t tunnel_id;
10495 uint32_t tunnel_id_mask;
10496 cmdline_fixed_string_t tunnel_type;
10497 uint8_t tunnel_type_mask;
10501 cmd_flow_director_mask_parsed(void *parsed_result,
10502 __attribute__((unused)) struct cmdline *cl,
10503 __attribute__((unused)) void *data)
10505 struct cmd_flow_director_mask_result *res = parsed_result;
10506 struct rte_eth_fdir_masks *mask;
10507 struct rte_port *port;
10509 if (res->port_id > nb_ports) {
10510 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
10514 port = &ports[res->port_id];
10515 /** Check if the port is not started **/
10516 if (port->port_status != RTE_PORT_STOPPED) {
10517 printf("Please stop port %d first\n", res->port_id);
10521 mask = &port->dev_conf.fdir_conf.mask;
10523 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
10524 if (strcmp(res->mode_value, "MAC-VLAN")) {
10525 printf("Please set mode to MAC-VLAN.\n");
10529 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10530 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
10531 if (strcmp(res->mode_value, "Tunnel")) {
10532 printf("Please set mode to Tunnel.\n");
10536 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10537 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
10538 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
10539 mask->tunnel_type_mask = res->tunnel_type_mask;
10541 if (strcmp(res->mode_value, "IP")) {
10542 printf("Please set mode to IP.\n");
10546 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10547 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
10548 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
10549 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
10550 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
10551 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
10552 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
10555 cmd_reconfig_device_queue(res->port_id, 1, 1);
10558 cmdline_parse_token_string_t cmd_flow_director_mask =
10559 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10560 flow_director_mask, "flow_director_mask");
10561 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
10562 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10564 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
10565 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10567 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
10568 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10569 vlan_mask, UINT16);
10570 cmdline_parse_token_string_t cmd_flow_director_mask_src =
10571 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10572 src_mask, "src_mask");
10573 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
10574 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10576 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
10577 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10579 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
10580 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10582 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
10583 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10584 dst_mask, "dst_mask");
10585 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
10586 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10588 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
10589 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10591 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
10592 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10595 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
10596 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10598 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
10599 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10601 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
10602 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10603 mode_value, "MAC-VLAN");
10604 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
10605 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10606 mode_value, "Tunnel");
10607 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
10608 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10610 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
10611 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10612 mac_addr_byte_mask, UINT8);
10613 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
10614 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10615 tunnel_type, "tunnel-type");
10616 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
10617 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10618 tunnel_type_mask, UINT8);
10619 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
10620 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10621 tunnel_id, "tunnel-id");
10622 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
10623 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10624 tunnel_id_mask, UINT32);
10626 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
10627 .f = cmd_flow_director_mask_parsed,
10629 .help_str = "flow_director_mask ... : "
10630 "Set IP mode flow director's mask on NIC",
10632 (void *)&cmd_flow_director_mask,
10633 (void *)&cmd_flow_director_mask_port_id,
10634 (void *)&cmd_flow_director_mask_mode,
10635 (void *)&cmd_flow_director_mask_mode_ip,
10636 (void *)&cmd_flow_director_mask_vlan,
10637 (void *)&cmd_flow_director_mask_vlan_value,
10638 (void *)&cmd_flow_director_mask_src,
10639 (void *)&cmd_flow_director_mask_ipv4_src,
10640 (void *)&cmd_flow_director_mask_ipv6_src,
10641 (void *)&cmd_flow_director_mask_port_src,
10642 (void *)&cmd_flow_director_mask_dst,
10643 (void *)&cmd_flow_director_mask_ipv4_dst,
10644 (void *)&cmd_flow_director_mask_ipv6_dst,
10645 (void *)&cmd_flow_director_mask_port_dst,
10650 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
10651 .f = cmd_flow_director_mask_parsed,
10653 .help_str = "flow_director_mask ... : Set MAC VLAN mode "
10654 "flow director's mask on NIC",
10656 (void *)&cmd_flow_director_mask,
10657 (void *)&cmd_flow_director_mask_port_id,
10658 (void *)&cmd_flow_director_mask_mode,
10659 (void *)&cmd_flow_director_mask_mode_mac_vlan,
10660 (void *)&cmd_flow_director_mask_vlan,
10661 (void *)&cmd_flow_director_mask_vlan_value,
10666 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
10667 .f = cmd_flow_director_mask_parsed,
10669 .help_str = "flow_director_mask ... : Set tunnel mode "
10670 "flow director's mask on NIC",
10672 (void *)&cmd_flow_director_mask,
10673 (void *)&cmd_flow_director_mask_port_id,
10674 (void *)&cmd_flow_director_mask_mode,
10675 (void *)&cmd_flow_director_mask_mode_tunnel,
10676 (void *)&cmd_flow_director_mask_vlan,
10677 (void *)&cmd_flow_director_mask_vlan_value,
10678 (void *)&cmd_flow_director_mask_mac,
10679 (void *)&cmd_flow_director_mask_mac_value,
10680 (void *)&cmd_flow_director_mask_tunnel_type,
10681 (void *)&cmd_flow_director_mask_tunnel_type_value,
10682 (void *)&cmd_flow_director_mask_tunnel_id,
10683 (void *)&cmd_flow_director_mask_tunnel_id_value,
10688 /* *** deal with flow director mask on flexible payload *** */
10689 struct cmd_flow_director_flex_mask_result {
10690 cmdline_fixed_string_t flow_director_flexmask;
10692 cmdline_fixed_string_t flow;
10693 cmdline_fixed_string_t flow_type;
10694 cmdline_fixed_string_t mask;
10698 cmd_flow_director_flex_mask_parsed(void *parsed_result,
10699 __attribute__((unused)) struct cmdline *cl,
10700 __attribute__((unused)) void *data)
10702 struct cmd_flow_director_flex_mask_result *res = parsed_result;
10703 struct rte_eth_fdir_info fdir_info;
10704 struct rte_eth_fdir_flex_mask flex_mask;
10705 struct rte_port *port;
10706 uint32_t flow_type_mask;
10710 if (res->port_id > nb_ports) {
10711 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
10715 port = &ports[res->port_id];
10716 /** Check if the port is not started **/
10717 if (port->port_status != RTE_PORT_STOPPED) {
10718 printf("Please stop port %d first\n", res->port_id);
10722 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
10723 ret = parse_flexbytes(res->mask,
10725 RTE_ETH_FDIR_MAX_FLEXLEN);
10727 printf("error: Cannot parse mask input.\n");
10731 memset(&fdir_info, 0, sizeof(fdir_info));
10732 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10733 RTE_ETH_FILTER_INFO, &fdir_info);
10735 printf("Cannot get FDir filter info\n");
10739 if (!strcmp(res->flow_type, "none")) {
10740 /* means don't specify the flow type */
10741 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN;
10742 for (i = 0; i < RTE_ETH_FLOW_MAX; i++)
10743 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i],
10744 0, sizeof(struct rte_eth_fdir_flex_mask));
10745 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1;
10746 rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0],
10748 sizeof(struct rte_eth_fdir_flex_mask));
10749 cmd_reconfig_device_queue(res->port_id, 1, 1);
10752 flow_type_mask = fdir_info.flow_types_mask[0];
10753 if (!strcmp(res->flow_type, "all")) {
10754 if (!flow_type_mask) {
10755 printf("No flow type supported\n");
10758 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
10759 if (flow_type_mask & (1 << i)) {
10760 flex_mask.flow_type = i;
10761 fdir_set_flex_mask(res->port_id, &flex_mask);
10764 cmd_reconfig_device_queue(res->port_id, 1, 1);
10767 flex_mask.flow_type = str2flowtype(res->flow_type);
10768 if (!(flow_type_mask & (1 << flex_mask.flow_type))) {
10769 printf("Flow type %s not supported on port %d\n",
10770 res->flow_type, res->port_id);
10773 fdir_set_flex_mask(res->port_id, &flex_mask);
10774 cmd_reconfig_device_queue(res->port_id, 1, 1);
10777 cmdline_parse_token_string_t cmd_flow_director_flexmask =
10778 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
10779 flow_director_flexmask,
10780 "flow_director_flex_mask");
10781 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
10782 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
10784 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
10785 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
10787 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
10788 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
10789 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
10790 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all");
10791 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
10792 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
10795 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
10796 .f = cmd_flow_director_flex_mask_parsed,
10798 .help_str = "flow_director_flex_mask ... : "
10799 "Set flow director's flex mask on NIC",
10801 (void *)&cmd_flow_director_flexmask,
10802 (void *)&cmd_flow_director_flexmask_port_id,
10803 (void *)&cmd_flow_director_flexmask_flow,
10804 (void *)&cmd_flow_director_flexmask_flow_type,
10805 (void *)&cmd_flow_director_flexmask_mask,
10810 /* *** deal with flow director flexible payload configuration *** */
10811 struct cmd_flow_director_flexpayload_result {
10812 cmdline_fixed_string_t flow_director_flexpayload;
10814 cmdline_fixed_string_t payload_layer;
10815 cmdline_fixed_string_t payload_cfg;
10819 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
10822 const char *p, *p0 = q_arg;
10824 unsigned long int_fld;
10825 char *str_fld[max_num];
10830 p = strchr(p0, '(');
10834 p0 = strchr(p, ')');
10839 if (size >= sizeof(s))
10842 snprintf(s, sizeof(s), "%.*s", size, p);
10843 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
10844 if (ret < 0 || ret > max_num)
10846 for (i = 0; i < ret; i++) {
10848 int_fld = strtoul(str_fld[i], &end, 0);
10849 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
10851 offsets[i] = (uint16_t)int_fld;
10857 cmd_flow_director_flxpld_parsed(void *parsed_result,
10858 __attribute__((unused)) struct cmdline *cl,
10859 __attribute__((unused)) void *data)
10861 struct cmd_flow_director_flexpayload_result *res = parsed_result;
10862 struct rte_eth_flex_payload_cfg flex_cfg;
10863 struct rte_port *port;
10866 if (res->port_id > nb_ports) {
10867 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
10871 port = &ports[res->port_id];
10872 /** Check if the port is not started **/
10873 if (port->port_status != RTE_PORT_STOPPED) {
10874 printf("Please stop port %d first\n", res->port_id);
10878 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
10880 if (!strcmp(res->payload_layer, "raw"))
10881 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
10882 else if (!strcmp(res->payload_layer, "l2"))
10883 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
10884 else if (!strcmp(res->payload_layer, "l3"))
10885 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
10886 else if (!strcmp(res->payload_layer, "l4"))
10887 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
10889 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
10890 RTE_ETH_FDIR_MAX_FLEXLEN);
10892 printf("error: Cannot parse flex payload input.\n");
10896 fdir_set_flex_payload(res->port_id, &flex_cfg);
10897 cmd_reconfig_device_queue(res->port_id, 1, 1);
10900 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
10901 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10902 flow_director_flexpayload,
10903 "flow_director_flex_payload");
10904 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
10905 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10907 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
10908 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10909 payload_layer, "raw#l2#l3#l4");
10910 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
10911 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10912 payload_cfg, NULL);
10914 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
10915 .f = cmd_flow_director_flxpld_parsed,
10917 .help_str = "flow_director_flexpayload ... : "
10918 "Set flow director's flex payload on NIC",
10920 (void *)&cmd_flow_director_flexpayload,
10921 (void *)&cmd_flow_director_flexpayload_port_id,
10922 (void *)&cmd_flow_director_flexpayload_payload_layer,
10923 (void *)&cmd_flow_director_flexpayload_payload_cfg,
10928 /* Generic flow interface command. */
10929 extern cmdline_parse_inst_t cmd_flow;
10931 /* *** Classification Filters Control *** */
10932 /* *** Get symmetric hash enable per port *** */
10933 struct cmd_get_sym_hash_ena_per_port_result {
10934 cmdline_fixed_string_t get_sym_hash_ena_per_port;
10939 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
10940 __rte_unused struct cmdline *cl,
10941 __rte_unused void *data)
10943 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
10944 struct rte_eth_hash_filter_info info;
10947 if (rte_eth_dev_filter_supported(res->port_id,
10948 RTE_ETH_FILTER_HASH) < 0) {
10949 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
10954 memset(&info, 0, sizeof(info));
10955 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
10956 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
10957 RTE_ETH_FILTER_GET, &info);
10960 printf("Cannot get symmetric hash enable per port "
10961 "on port %u\n", res->port_id);
10965 printf("Symmetric hash is %s on port %u\n", info.info.enable ?
10966 "enabled" : "disabled", res->port_id);
10969 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
10970 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
10971 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
10972 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
10973 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
10976 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
10977 .f = cmd_get_sym_hash_per_port_parsed,
10979 .help_str = "get_sym_hash_ena_per_port <port_id>",
10981 (void *)&cmd_get_sym_hash_ena_per_port_all,
10982 (void *)&cmd_get_sym_hash_ena_per_port_port_id,
10987 /* *** Set symmetric hash enable per port *** */
10988 struct cmd_set_sym_hash_ena_per_port_result {
10989 cmdline_fixed_string_t set_sym_hash_ena_per_port;
10990 cmdline_fixed_string_t enable;
10995 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
10996 __rte_unused struct cmdline *cl,
10997 __rte_unused void *data)
10999 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
11000 struct rte_eth_hash_filter_info info;
11003 if (rte_eth_dev_filter_supported(res->port_id,
11004 RTE_ETH_FILTER_HASH) < 0) {
11005 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
11010 memset(&info, 0, sizeof(info));
11011 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
11012 if (!strcmp(res->enable, "enable"))
11013 info.info.enable = 1;
11014 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11015 RTE_ETH_FILTER_SET, &info);
11017 printf("Cannot set symmetric hash enable per port on "
11018 "port %u\n", res->port_id);
11021 printf("Symmetric hash has been set to %s on port %u\n",
11022 res->enable, res->port_id);
11025 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
11026 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
11027 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
11028 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
11029 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
11031 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
11032 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
11033 enable, "enable#disable");
11035 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
11036 .f = cmd_set_sym_hash_per_port_parsed,
11038 .help_str = "set_sym_hash_ena_per_port <port_id> enable|disable",
11040 (void *)&cmd_set_sym_hash_ena_per_port_all,
11041 (void *)&cmd_set_sym_hash_ena_per_port_port_id,
11042 (void *)&cmd_set_sym_hash_ena_per_port_enable,
11047 /* Get global config of hash function */
11048 struct cmd_get_hash_global_config_result {
11049 cmdline_fixed_string_t get_hash_global_config;
11054 flowtype_to_str(uint16_t ftype)
11060 } ftype_table[] = {
11061 {"ipv4", RTE_ETH_FLOW_IPV4},
11062 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
11063 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
11064 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
11065 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
11066 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
11067 {"ipv6", RTE_ETH_FLOW_IPV6},
11068 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
11069 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
11070 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
11071 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
11072 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
11073 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
11074 {"port", RTE_ETH_FLOW_PORT},
11075 {"vxlan", RTE_ETH_FLOW_VXLAN},
11076 {"geneve", RTE_ETH_FLOW_GENEVE},
11077 {"nvgre", RTE_ETH_FLOW_NVGRE},
11080 for (i = 0; i < RTE_DIM(ftype_table); i++) {
11081 if (ftype_table[i].ftype == ftype)
11082 return ftype_table[i].str;
11089 cmd_get_hash_global_config_parsed(void *parsed_result,
11090 __rte_unused struct cmdline *cl,
11091 __rte_unused void *data)
11093 struct cmd_get_hash_global_config_result *res = parsed_result;
11094 struct rte_eth_hash_filter_info info;
11095 uint32_t idx, offset;
11100 if (rte_eth_dev_filter_supported(res->port_id,
11101 RTE_ETH_FILTER_HASH) < 0) {
11102 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
11107 memset(&info, 0, sizeof(info));
11108 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
11109 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11110 RTE_ETH_FILTER_GET, &info);
11112 printf("Cannot get hash global configurations by port %d\n",
11117 switch (info.info.global_conf.hash_func) {
11118 case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
11119 printf("Hash function is Toeplitz\n");
11121 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
11122 printf("Hash function is Simple XOR\n");
11125 printf("Unknown hash function\n");
11129 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) {
11130 idx = i / UINT32_BIT;
11131 offset = i % UINT32_BIT;
11132 if (!(info.info.global_conf.valid_bit_mask[idx] &
11135 str = flowtype_to_str(i);
11138 printf("Symmetric hash is %s globally for flow type %s "
11140 ((info.info.global_conf.sym_hash_enable_mask[idx] &
11141 (1UL << offset)) ? "enabled" : "disabled"), str,
11146 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
11147 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
11148 get_hash_global_config, "get_hash_global_config");
11149 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
11150 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
11153 cmdline_parse_inst_t cmd_get_hash_global_config = {
11154 .f = cmd_get_hash_global_config_parsed,
11156 .help_str = "get_hash_global_config <port_id>",
11158 (void *)&cmd_get_hash_global_config_all,
11159 (void *)&cmd_get_hash_global_config_port_id,
11164 /* Set global config of hash function */
11165 struct cmd_set_hash_global_config_result {
11166 cmdline_fixed_string_t set_hash_global_config;
11168 cmdline_fixed_string_t hash_func;
11169 cmdline_fixed_string_t flow_type;
11170 cmdline_fixed_string_t enable;
11174 cmd_set_hash_global_config_parsed(void *parsed_result,
11175 __rte_unused struct cmdline *cl,
11176 __rte_unused void *data)
11178 struct cmd_set_hash_global_config_result *res = parsed_result;
11179 struct rte_eth_hash_filter_info info;
11180 uint32_t ftype, idx, offset;
11183 if (rte_eth_dev_filter_supported(res->port_id,
11184 RTE_ETH_FILTER_HASH) < 0) {
11185 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
11189 memset(&info, 0, sizeof(info));
11190 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
11191 if (!strcmp(res->hash_func, "toeplitz"))
11192 info.info.global_conf.hash_func =
11193 RTE_ETH_HASH_FUNCTION_TOEPLITZ;
11194 else if (!strcmp(res->hash_func, "simple_xor"))
11195 info.info.global_conf.hash_func =
11196 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
11197 else if (!strcmp(res->hash_func, "default"))
11198 info.info.global_conf.hash_func =
11199 RTE_ETH_HASH_FUNCTION_DEFAULT;
11201 ftype = str2flowtype(res->flow_type);
11202 idx = ftype / (CHAR_BIT * sizeof(uint32_t));
11203 offset = ftype % (CHAR_BIT * sizeof(uint32_t));
11204 info.info.global_conf.valid_bit_mask[idx] |= (1UL << offset);
11205 if (!strcmp(res->enable, "enable"))
11206 info.info.global_conf.sym_hash_enable_mask[idx] |=
11208 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11209 RTE_ETH_FILTER_SET, &info);
11211 printf("Cannot set global hash configurations by port %d\n",
11214 printf("Global hash configurations have been set "
11215 "succcessfully by port %d\n", res->port_id);
11218 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
11219 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11220 set_hash_global_config, "set_hash_global_config");
11221 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
11222 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
11224 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
11225 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11226 hash_func, "toeplitz#simple_xor#default");
11227 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
11228 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11230 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
11231 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
11232 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
11233 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11234 enable, "enable#disable");
11236 cmdline_parse_inst_t cmd_set_hash_global_config = {
11237 .f = cmd_set_hash_global_config_parsed,
11239 .help_str = "set_hash_global_config <port_id> "
11240 "toeplitz|simple_xor|default "
11241 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
11242 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
11243 "l2_payload enable|disable",
11245 (void *)&cmd_set_hash_global_config_all,
11246 (void *)&cmd_set_hash_global_config_port_id,
11247 (void *)&cmd_set_hash_global_config_hash_func,
11248 (void *)&cmd_set_hash_global_config_flow_type,
11249 (void *)&cmd_set_hash_global_config_enable,
11254 /* Set hash input set */
11255 struct cmd_set_hash_input_set_result {
11256 cmdline_fixed_string_t set_hash_input_set;
11258 cmdline_fixed_string_t flow_type;
11259 cmdline_fixed_string_t inset_field;
11260 cmdline_fixed_string_t select;
11263 static enum rte_eth_input_set_field
11264 str2inset(char *string)
11268 static const struct {
11270 enum rte_eth_input_set_field inset;
11271 } inset_table[] = {
11272 {"ethertype", RTE_ETH_INPUT_SET_L2_ETHERTYPE},
11273 {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN},
11274 {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN},
11275 {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4},
11276 {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4},
11277 {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS},
11278 {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO},
11279 {"ipv4-ttl", RTE_ETH_INPUT_SET_L3_IP4_TTL},
11280 {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6},
11281 {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6},
11282 {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC},
11283 {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER},
11284 {"ipv6-hop-limits", RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS},
11285 {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT},
11286 {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT},
11287 {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT},
11288 {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT},
11289 {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT},
11290 {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT},
11291 {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG},
11292 {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY},
11293 {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY},
11294 {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD},
11295 {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD},
11296 {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD},
11297 {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD},
11298 {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD},
11299 {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD},
11300 {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD},
11301 {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD},
11302 {"none", RTE_ETH_INPUT_SET_NONE},
11305 for (i = 0; i < RTE_DIM(inset_table); i++) {
11306 if (!strcmp(string, inset_table[i].str))
11307 return inset_table[i].inset;
11310 return RTE_ETH_INPUT_SET_UNKNOWN;
11314 cmd_set_hash_input_set_parsed(void *parsed_result,
11315 __rte_unused struct cmdline *cl,
11316 __rte_unused void *data)
11318 struct cmd_set_hash_input_set_result *res = parsed_result;
11319 struct rte_eth_hash_filter_info info;
11321 memset(&info, 0, sizeof(info));
11322 info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT;
11323 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
11324 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
11325 info.info.input_set_conf.inset_size = 1;
11326 if (!strcmp(res->select, "select"))
11327 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
11328 else if (!strcmp(res->select, "add"))
11329 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
11330 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11331 RTE_ETH_FILTER_SET, &info);
11334 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd =
11335 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
11336 set_hash_input_set, "set_hash_input_set");
11337 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id =
11338 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result,
11340 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type =
11341 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
11343 cmdline_parse_token_string_t cmd_set_hash_input_set_field =
11344 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
11346 "ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
11347 "ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#"
11348 "udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#"
11349 "sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#"
11350 "fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#"
11352 cmdline_parse_token_string_t cmd_set_hash_input_set_select =
11353 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
11354 select, "select#add");
11356 cmdline_parse_inst_t cmd_set_hash_input_set = {
11357 .f = cmd_set_hash_input_set_parsed,
11359 .help_str = "set_hash_input_set <port_id> "
11360 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
11361 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload|<flowtype_id> "
11362 "ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|"
11363 "ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|"
11364 "tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|"
11365 "gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
11366 "fld-7th|fld-8th|none select|add",
11368 (void *)&cmd_set_hash_input_set_cmd,
11369 (void *)&cmd_set_hash_input_set_port_id,
11370 (void *)&cmd_set_hash_input_set_flow_type,
11371 (void *)&cmd_set_hash_input_set_field,
11372 (void *)&cmd_set_hash_input_set_select,
11377 /* Set flow director input set */
11378 struct cmd_set_fdir_input_set_result {
11379 cmdline_fixed_string_t set_fdir_input_set;
11381 cmdline_fixed_string_t flow_type;
11382 cmdline_fixed_string_t inset_field;
11383 cmdline_fixed_string_t select;
11387 cmd_set_fdir_input_set_parsed(void *parsed_result,
11388 __rte_unused struct cmdline *cl,
11389 __rte_unused void *data)
11391 struct cmd_set_fdir_input_set_result *res = parsed_result;
11392 struct rte_eth_fdir_filter_info info;
11394 memset(&info, 0, sizeof(info));
11395 info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT;
11396 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
11397 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
11398 info.info.input_set_conf.inset_size = 1;
11399 if (!strcmp(res->select, "select"))
11400 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
11401 else if (!strcmp(res->select, "add"))
11402 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
11403 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11404 RTE_ETH_FILTER_SET, &info);
11407 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd =
11408 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
11409 set_fdir_input_set, "set_fdir_input_set");
11410 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id =
11411 TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result,
11413 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type =
11414 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
11416 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
11417 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
11418 cmdline_parse_token_string_t cmd_set_fdir_input_set_field =
11419 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
11421 "ivlan#ethertype#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
11422 "ipv4-tos#ipv4-proto#ipv4-ttl#ipv6-tc#ipv6-next-header#"
11423 "ipv6-hop-limits#udp-src-port#udp-dst-port#"
11424 "tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#"
11425 "sctp-veri-tag#none");
11426 cmdline_parse_token_string_t cmd_set_fdir_input_set_select =
11427 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
11428 select, "select#add");
11430 cmdline_parse_inst_t cmd_set_fdir_input_set = {
11431 .f = cmd_set_fdir_input_set_parsed,
11433 .help_str = "set_fdir_input_set <port_id> "
11434 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
11435 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
11436 "ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|"
11437 "ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|ipv6-next-header|"
11438 "ipv6-hop-limits|udp-src-port|udp-dst-port|"
11439 "tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|"
11440 "sctp-veri-tag|none select|add",
11442 (void *)&cmd_set_fdir_input_set_cmd,
11443 (void *)&cmd_set_fdir_input_set_port_id,
11444 (void *)&cmd_set_fdir_input_set_flow_type,
11445 (void *)&cmd_set_fdir_input_set_field,
11446 (void *)&cmd_set_fdir_input_set_select,
11451 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
11452 struct cmd_mcast_addr_result {
11453 cmdline_fixed_string_t mcast_addr_cmd;
11454 cmdline_fixed_string_t what;
11456 struct ether_addr mc_addr;
11459 static void cmd_mcast_addr_parsed(void *parsed_result,
11460 __attribute__((unused)) struct cmdline *cl,
11461 __attribute__((unused)) void *data)
11463 struct cmd_mcast_addr_result *res = parsed_result;
11465 if (!is_multicast_ether_addr(&res->mc_addr)) {
11466 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
11467 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
11468 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
11469 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
11472 if (strcmp(res->what, "add") == 0)
11473 mcast_addr_add(res->port_num, &res->mc_addr);
11475 mcast_addr_remove(res->port_num, &res->mc_addr);
11478 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
11479 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
11480 mcast_addr_cmd, "mcast_addr");
11481 cmdline_parse_token_string_t cmd_mcast_addr_what =
11482 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
11484 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
11485 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT16);
11486 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
11487 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
11489 cmdline_parse_inst_t cmd_mcast_addr = {
11490 .f = cmd_mcast_addr_parsed,
11492 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
11493 "Add/Remove multicast MAC address on port_id",
11495 (void *)&cmd_mcast_addr_cmd,
11496 (void *)&cmd_mcast_addr_what,
11497 (void *)&cmd_mcast_addr_portnum,
11498 (void *)&cmd_mcast_addr_addr,
11503 /* l2 tunnel config
11504 * only support E-tag now.
11507 /* Ether type config */
11508 struct cmd_config_l2_tunnel_eth_type_result {
11509 cmdline_fixed_string_t port;
11510 cmdline_fixed_string_t config;
11511 cmdline_fixed_string_t all;
11513 cmdline_fixed_string_t l2_tunnel;
11514 cmdline_fixed_string_t l2_tunnel_type;
11515 cmdline_fixed_string_t eth_type;
11516 uint16_t eth_type_val;
11519 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port =
11520 TOKEN_STRING_INITIALIZER
11521 (struct cmd_config_l2_tunnel_eth_type_result,
11523 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config =
11524 TOKEN_STRING_INITIALIZER
11525 (struct cmd_config_l2_tunnel_eth_type_result,
11527 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str =
11528 TOKEN_STRING_INITIALIZER
11529 (struct cmd_config_l2_tunnel_eth_type_result,
11531 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id =
11532 TOKEN_NUM_INITIALIZER
11533 (struct cmd_config_l2_tunnel_eth_type_result,
11535 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel =
11536 TOKEN_STRING_INITIALIZER
11537 (struct cmd_config_l2_tunnel_eth_type_result,
11538 l2_tunnel, "l2-tunnel");
11539 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type =
11540 TOKEN_STRING_INITIALIZER
11541 (struct cmd_config_l2_tunnel_eth_type_result,
11542 l2_tunnel_type, "E-tag");
11543 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type =
11544 TOKEN_STRING_INITIALIZER
11545 (struct cmd_config_l2_tunnel_eth_type_result,
11546 eth_type, "ether-type");
11547 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val =
11548 TOKEN_NUM_INITIALIZER
11549 (struct cmd_config_l2_tunnel_eth_type_result,
11550 eth_type_val, UINT16);
11552 static enum rte_eth_tunnel_type
11553 str2fdir_l2_tunnel_type(char *string)
11557 static const struct {
11559 enum rte_eth_tunnel_type type;
11560 } l2_tunnel_type_str[] = {
11561 {"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG},
11564 for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) {
11565 if (!strcmp(l2_tunnel_type_str[i].str, string))
11566 return l2_tunnel_type_str[i].type;
11568 return RTE_TUNNEL_TYPE_NONE;
11571 /* ether type config for all ports */
11573 cmd_config_l2_tunnel_eth_type_all_parsed
11574 (void *parsed_result,
11575 __attribute__((unused)) struct cmdline *cl,
11576 __attribute__((unused)) void *data)
11578 struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result;
11579 struct rte_eth_l2_tunnel_conf entry;
11582 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
11583 entry.ether_type = res->eth_type_val;
11585 RTE_ETH_FOREACH_DEV(pid) {
11586 rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry);
11590 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = {
11591 .f = cmd_config_l2_tunnel_eth_type_all_parsed,
11593 .help_str = "port config all l2-tunnel E-tag ether-type <value>",
11595 (void *)&cmd_config_l2_tunnel_eth_type_port,
11596 (void *)&cmd_config_l2_tunnel_eth_type_config,
11597 (void *)&cmd_config_l2_tunnel_eth_type_all_str,
11598 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
11599 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
11600 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
11601 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
11606 /* ether type config for a specific port */
11608 cmd_config_l2_tunnel_eth_type_specific_parsed(
11609 void *parsed_result,
11610 __attribute__((unused)) struct cmdline *cl,
11611 __attribute__((unused)) void *data)
11613 struct cmd_config_l2_tunnel_eth_type_result *res =
11615 struct rte_eth_l2_tunnel_conf entry;
11617 if (port_id_is_invalid(res->id, ENABLED_WARN))
11620 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
11621 entry.ether_type = res->eth_type_val;
11623 rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry);
11626 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = {
11627 .f = cmd_config_l2_tunnel_eth_type_specific_parsed,
11629 .help_str = "port config <port_id> l2-tunnel E-tag ether-type <value>",
11631 (void *)&cmd_config_l2_tunnel_eth_type_port,
11632 (void *)&cmd_config_l2_tunnel_eth_type_config,
11633 (void *)&cmd_config_l2_tunnel_eth_type_id,
11634 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
11635 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
11636 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
11637 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
11642 /* Enable/disable l2 tunnel */
11643 struct cmd_config_l2_tunnel_en_dis_result {
11644 cmdline_fixed_string_t port;
11645 cmdline_fixed_string_t config;
11646 cmdline_fixed_string_t all;
11648 cmdline_fixed_string_t l2_tunnel;
11649 cmdline_fixed_string_t l2_tunnel_type;
11650 cmdline_fixed_string_t en_dis;
11653 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port =
11654 TOKEN_STRING_INITIALIZER
11655 (struct cmd_config_l2_tunnel_en_dis_result,
11657 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config =
11658 TOKEN_STRING_INITIALIZER
11659 (struct cmd_config_l2_tunnel_en_dis_result,
11661 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str =
11662 TOKEN_STRING_INITIALIZER
11663 (struct cmd_config_l2_tunnel_en_dis_result,
11665 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id =
11666 TOKEN_NUM_INITIALIZER
11667 (struct cmd_config_l2_tunnel_en_dis_result,
11669 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel =
11670 TOKEN_STRING_INITIALIZER
11671 (struct cmd_config_l2_tunnel_en_dis_result,
11672 l2_tunnel, "l2-tunnel");
11673 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type =
11674 TOKEN_STRING_INITIALIZER
11675 (struct cmd_config_l2_tunnel_en_dis_result,
11676 l2_tunnel_type, "E-tag");
11677 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis =
11678 TOKEN_STRING_INITIALIZER
11679 (struct cmd_config_l2_tunnel_en_dis_result,
11680 en_dis, "enable#disable");
11682 /* enable/disable l2 tunnel for all ports */
11684 cmd_config_l2_tunnel_en_dis_all_parsed(
11685 void *parsed_result,
11686 __attribute__((unused)) struct cmdline *cl,
11687 __attribute__((unused)) void *data)
11689 struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result;
11690 struct rte_eth_l2_tunnel_conf entry;
11694 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
11696 if (!strcmp("enable", res->en_dis))
11701 RTE_ETH_FOREACH_DEV(pid) {
11702 rte_eth_dev_l2_tunnel_offload_set(pid,
11704 ETH_L2_TUNNEL_ENABLE_MASK,
11709 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = {
11710 .f = cmd_config_l2_tunnel_en_dis_all_parsed,
11712 .help_str = "port config all l2-tunnel E-tag enable|disable",
11714 (void *)&cmd_config_l2_tunnel_en_dis_port,
11715 (void *)&cmd_config_l2_tunnel_en_dis_config,
11716 (void *)&cmd_config_l2_tunnel_en_dis_all_str,
11717 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
11718 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
11719 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
11724 /* enable/disable l2 tunnel for a port */
11726 cmd_config_l2_tunnel_en_dis_specific_parsed(
11727 void *parsed_result,
11728 __attribute__((unused)) struct cmdline *cl,
11729 __attribute__((unused)) void *data)
11731 struct cmd_config_l2_tunnel_en_dis_result *res =
11733 struct rte_eth_l2_tunnel_conf entry;
11735 if (port_id_is_invalid(res->id, ENABLED_WARN))
11738 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
11740 if (!strcmp("enable", res->en_dis))
11741 rte_eth_dev_l2_tunnel_offload_set(res->id,
11743 ETH_L2_TUNNEL_ENABLE_MASK,
11746 rte_eth_dev_l2_tunnel_offload_set(res->id,
11748 ETH_L2_TUNNEL_ENABLE_MASK,
11752 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = {
11753 .f = cmd_config_l2_tunnel_en_dis_specific_parsed,
11755 .help_str = "port config <port_id> l2-tunnel E-tag enable|disable",
11757 (void *)&cmd_config_l2_tunnel_en_dis_port,
11758 (void *)&cmd_config_l2_tunnel_en_dis_config,
11759 (void *)&cmd_config_l2_tunnel_en_dis_id,
11760 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
11761 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
11762 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
11767 /* E-tag configuration */
11769 /* Common result structure for all E-tag configuration */
11770 struct cmd_config_e_tag_result {
11771 cmdline_fixed_string_t e_tag;
11772 cmdline_fixed_string_t set;
11773 cmdline_fixed_string_t insertion;
11774 cmdline_fixed_string_t stripping;
11775 cmdline_fixed_string_t forwarding;
11776 cmdline_fixed_string_t filter;
11777 cmdline_fixed_string_t add;
11778 cmdline_fixed_string_t del;
11779 cmdline_fixed_string_t on;
11780 cmdline_fixed_string_t off;
11781 cmdline_fixed_string_t on_off;
11782 cmdline_fixed_string_t port_tag_id;
11783 uint32_t port_tag_id_val;
11784 cmdline_fixed_string_t e_tag_id;
11785 uint16_t e_tag_id_val;
11786 cmdline_fixed_string_t dst_pool;
11787 uint8_t dst_pool_val;
11788 cmdline_fixed_string_t port;
11790 cmdline_fixed_string_t vf;
11794 /* Common CLI fields for all E-tag configuration */
11795 cmdline_parse_token_string_t cmd_config_e_tag_e_tag =
11796 TOKEN_STRING_INITIALIZER
11797 (struct cmd_config_e_tag_result,
11799 cmdline_parse_token_string_t cmd_config_e_tag_set =
11800 TOKEN_STRING_INITIALIZER
11801 (struct cmd_config_e_tag_result,
11803 cmdline_parse_token_string_t cmd_config_e_tag_insertion =
11804 TOKEN_STRING_INITIALIZER
11805 (struct cmd_config_e_tag_result,
11806 insertion, "insertion");
11807 cmdline_parse_token_string_t cmd_config_e_tag_stripping =
11808 TOKEN_STRING_INITIALIZER
11809 (struct cmd_config_e_tag_result,
11810 stripping, "stripping");
11811 cmdline_parse_token_string_t cmd_config_e_tag_forwarding =
11812 TOKEN_STRING_INITIALIZER
11813 (struct cmd_config_e_tag_result,
11814 forwarding, "forwarding");
11815 cmdline_parse_token_string_t cmd_config_e_tag_filter =
11816 TOKEN_STRING_INITIALIZER
11817 (struct cmd_config_e_tag_result,
11819 cmdline_parse_token_string_t cmd_config_e_tag_add =
11820 TOKEN_STRING_INITIALIZER
11821 (struct cmd_config_e_tag_result,
11823 cmdline_parse_token_string_t cmd_config_e_tag_del =
11824 TOKEN_STRING_INITIALIZER
11825 (struct cmd_config_e_tag_result,
11827 cmdline_parse_token_string_t cmd_config_e_tag_on =
11828 TOKEN_STRING_INITIALIZER
11829 (struct cmd_config_e_tag_result,
11831 cmdline_parse_token_string_t cmd_config_e_tag_off =
11832 TOKEN_STRING_INITIALIZER
11833 (struct cmd_config_e_tag_result,
11835 cmdline_parse_token_string_t cmd_config_e_tag_on_off =
11836 TOKEN_STRING_INITIALIZER
11837 (struct cmd_config_e_tag_result,
11839 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id =
11840 TOKEN_STRING_INITIALIZER
11841 (struct cmd_config_e_tag_result,
11842 port_tag_id, "port-tag-id");
11843 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val =
11844 TOKEN_NUM_INITIALIZER
11845 (struct cmd_config_e_tag_result,
11846 port_tag_id_val, UINT32);
11847 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id =
11848 TOKEN_STRING_INITIALIZER
11849 (struct cmd_config_e_tag_result,
11850 e_tag_id, "e-tag-id");
11851 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val =
11852 TOKEN_NUM_INITIALIZER
11853 (struct cmd_config_e_tag_result,
11854 e_tag_id_val, UINT16);
11855 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool =
11856 TOKEN_STRING_INITIALIZER
11857 (struct cmd_config_e_tag_result,
11858 dst_pool, "dst-pool");
11859 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val =
11860 TOKEN_NUM_INITIALIZER
11861 (struct cmd_config_e_tag_result,
11862 dst_pool_val, UINT8);
11863 cmdline_parse_token_string_t cmd_config_e_tag_port =
11864 TOKEN_STRING_INITIALIZER
11865 (struct cmd_config_e_tag_result,
11867 cmdline_parse_token_num_t cmd_config_e_tag_port_id =
11868 TOKEN_NUM_INITIALIZER
11869 (struct cmd_config_e_tag_result,
11871 cmdline_parse_token_string_t cmd_config_e_tag_vf =
11872 TOKEN_STRING_INITIALIZER
11873 (struct cmd_config_e_tag_result,
11875 cmdline_parse_token_num_t cmd_config_e_tag_vf_id =
11876 TOKEN_NUM_INITIALIZER
11877 (struct cmd_config_e_tag_result,
11880 /* E-tag insertion configuration */
11882 cmd_config_e_tag_insertion_en_parsed(
11883 void *parsed_result,
11884 __attribute__((unused)) struct cmdline *cl,
11885 __attribute__((unused)) void *data)
11887 struct cmd_config_e_tag_result *res =
11889 struct rte_eth_l2_tunnel_conf entry;
11891 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11894 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
11895 entry.tunnel_id = res->port_tag_id_val;
11896 entry.vf_id = res->vf_id;
11897 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
11899 ETH_L2_TUNNEL_INSERTION_MASK,
11904 cmd_config_e_tag_insertion_dis_parsed(
11905 void *parsed_result,
11906 __attribute__((unused)) struct cmdline *cl,
11907 __attribute__((unused)) void *data)
11909 struct cmd_config_e_tag_result *res =
11911 struct rte_eth_l2_tunnel_conf entry;
11913 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11916 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
11917 entry.vf_id = res->vf_id;
11919 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
11921 ETH_L2_TUNNEL_INSERTION_MASK,
11925 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = {
11926 .f = cmd_config_e_tag_insertion_en_parsed,
11928 .help_str = "E-tag ... : E-tag insertion enable",
11930 (void *)&cmd_config_e_tag_e_tag,
11931 (void *)&cmd_config_e_tag_set,
11932 (void *)&cmd_config_e_tag_insertion,
11933 (void *)&cmd_config_e_tag_on,
11934 (void *)&cmd_config_e_tag_port_tag_id,
11935 (void *)&cmd_config_e_tag_port_tag_id_val,
11936 (void *)&cmd_config_e_tag_port,
11937 (void *)&cmd_config_e_tag_port_id,
11938 (void *)&cmd_config_e_tag_vf,
11939 (void *)&cmd_config_e_tag_vf_id,
11944 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = {
11945 .f = cmd_config_e_tag_insertion_dis_parsed,
11947 .help_str = "E-tag ... : E-tag insertion disable",
11949 (void *)&cmd_config_e_tag_e_tag,
11950 (void *)&cmd_config_e_tag_set,
11951 (void *)&cmd_config_e_tag_insertion,
11952 (void *)&cmd_config_e_tag_off,
11953 (void *)&cmd_config_e_tag_port,
11954 (void *)&cmd_config_e_tag_port_id,
11955 (void *)&cmd_config_e_tag_vf,
11956 (void *)&cmd_config_e_tag_vf_id,
11961 /* E-tag stripping configuration */
11963 cmd_config_e_tag_stripping_parsed(
11964 void *parsed_result,
11965 __attribute__((unused)) struct cmdline *cl,
11966 __attribute__((unused)) void *data)
11968 struct cmd_config_e_tag_result *res =
11970 struct rte_eth_l2_tunnel_conf entry;
11972 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11975 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
11977 if (!strcmp(res->on_off, "on"))
11978 rte_eth_dev_l2_tunnel_offload_set
11981 ETH_L2_TUNNEL_STRIPPING_MASK,
11984 rte_eth_dev_l2_tunnel_offload_set
11987 ETH_L2_TUNNEL_STRIPPING_MASK,
11991 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = {
11992 .f = cmd_config_e_tag_stripping_parsed,
11994 .help_str = "E-tag ... : E-tag stripping enable/disable",
11996 (void *)&cmd_config_e_tag_e_tag,
11997 (void *)&cmd_config_e_tag_set,
11998 (void *)&cmd_config_e_tag_stripping,
11999 (void *)&cmd_config_e_tag_on_off,
12000 (void *)&cmd_config_e_tag_port,
12001 (void *)&cmd_config_e_tag_port_id,
12006 /* E-tag forwarding configuration */
12008 cmd_config_e_tag_forwarding_parsed(
12009 void *parsed_result,
12010 __attribute__((unused)) struct cmdline *cl,
12011 __attribute__((unused)) void *data)
12013 struct cmd_config_e_tag_result *res = parsed_result;
12014 struct rte_eth_l2_tunnel_conf entry;
12016 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12019 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12021 if (!strcmp(res->on_off, "on"))
12022 rte_eth_dev_l2_tunnel_offload_set
12025 ETH_L2_TUNNEL_FORWARDING_MASK,
12028 rte_eth_dev_l2_tunnel_offload_set
12031 ETH_L2_TUNNEL_FORWARDING_MASK,
12035 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = {
12036 .f = cmd_config_e_tag_forwarding_parsed,
12038 .help_str = "E-tag ... : E-tag forwarding enable/disable",
12040 (void *)&cmd_config_e_tag_e_tag,
12041 (void *)&cmd_config_e_tag_set,
12042 (void *)&cmd_config_e_tag_forwarding,
12043 (void *)&cmd_config_e_tag_on_off,
12044 (void *)&cmd_config_e_tag_port,
12045 (void *)&cmd_config_e_tag_port_id,
12050 /* E-tag filter configuration */
12052 cmd_config_e_tag_filter_add_parsed(
12053 void *parsed_result,
12054 __attribute__((unused)) struct cmdline *cl,
12055 __attribute__((unused)) void *data)
12057 struct cmd_config_e_tag_result *res = parsed_result;
12058 struct rte_eth_l2_tunnel_conf entry;
12061 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12064 if (res->e_tag_id_val > 0x3fff) {
12065 printf("e-tag-id must be equal or less than 0x3fff.\n");
12069 ret = rte_eth_dev_filter_supported(res->port_id,
12070 RTE_ETH_FILTER_L2_TUNNEL);
12072 printf("E-tag filter is not supported on port %u.\n",
12077 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12078 entry.tunnel_id = res->e_tag_id_val;
12079 entry.pool = res->dst_pool_val;
12081 ret = rte_eth_dev_filter_ctrl(res->port_id,
12082 RTE_ETH_FILTER_L2_TUNNEL,
12083 RTE_ETH_FILTER_ADD,
12086 printf("E-tag filter programming error: (%s)\n",
12090 cmdline_parse_inst_t cmd_config_e_tag_filter_add = {
12091 .f = cmd_config_e_tag_filter_add_parsed,
12093 .help_str = "E-tag ... : E-tag filter add",
12095 (void *)&cmd_config_e_tag_e_tag,
12096 (void *)&cmd_config_e_tag_set,
12097 (void *)&cmd_config_e_tag_filter,
12098 (void *)&cmd_config_e_tag_add,
12099 (void *)&cmd_config_e_tag_e_tag_id,
12100 (void *)&cmd_config_e_tag_e_tag_id_val,
12101 (void *)&cmd_config_e_tag_dst_pool,
12102 (void *)&cmd_config_e_tag_dst_pool_val,
12103 (void *)&cmd_config_e_tag_port,
12104 (void *)&cmd_config_e_tag_port_id,
12110 cmd_config_e_tag_filter_del_parsed(
12111 void *parsed_result,
12112 __attribute__((unused)) struct cmdline *cl,
12113 __attribute__((unused)) void *data)
12115 struct cmd_config_e_tag_result *res = parsed_result;
12116 struct rte_eth_l2_tunnel_conf entry;
12119 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12122 if (res->e_tag_id_val > 0x3fff) {
12123 printf("e-tag-id must be less than 0x3fff.\n");
12127 ret = rte_eth_dev_filter_supported(res->port_id,
12128 RTE_ETH_FILTER_L2_TUNNEL);
12130 printf("E-tag filter is not supported on port %u.\n",
12135 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12136 entry.tunnel_id = res->e_tag_id_val;
12138 ret = rte_eth_dev_filter_ctrl(res->port_id,
12139 RTE_ETH_FILTER_L2_TUNNEL,
12140 RTE_ETH_FILTER_DELETE,
12143 printf("E-tag filter programming error: (%s)\n",
12147 cmdline_parse_inst_t cmd_config_e_tag_filter_del = {
12148 .f = cmd_config_e_tag_filter_del_parsed,
12150 .help_str = "E-tag ... : E-tag filter delete",
12152 (void *)&cmd_config_e_tag_e_tag,
12153 (void *)&cmd_config_e_tag_set,
12154 (void *)&cmd_config_e_tag_filter,
12155 (void *)&cmd_config_e_tag_del,
12156 (void *)&cmd_config_e_tag_e_tag_id,
12157 (void *)&cmd_config_e_tag_e_tag_id_val,
12158 (void *)&cmd_config_e_tag_port,
12159 (void *)&cmd_config_e_tag_port_id,
12164 /* vf vlan anti spoof configuration */
12166 /* Common result structure for vf vlan anti spoof */
12167 struct cmd_vf_vlan_anti_spoof_result {
12168 cmdline_fixed_string_t set;
12169 cmdline_fixed_string_t vf;
12170 cmdline_fixed_string_t vlan;
12171 cmdline_fixed_string_t antispoof;
12174 cmdline_fixed_string_t on_off;
12177 /* Common CLI fields for vf vlan anti spoof enable disable */
12178 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
12179 TOKEN_STRING_INITIALIZER
12180 (struct cmd_vf_vlan_anti_spoof_result,
12182 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
12183 TOKEN_STRING_INITIALIZER
12184 (struct cmd_vf_vlan_anti_spoof_result,
12186 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
12187 TOKEN_STRING_INITIALIZER
12188 (struct cmd_vf_vlan_anti_spoof_result,
12190 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
12191 TOKEN_STRING_INITIALIZER
12192 (struct cmd_vf_vlan_anti_spoof_result,
12193 antispoof, "antispoof");
12194 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
12195 TOKEN_NUM_INITIALIZER
12196 (struct cmd_vf_vlan_anti_spoof_result,
12198 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
12199 TOKEN_NUM_INITIALIZER
12200 (struct cmd_vf_vlan_anti_spoof_result,
12202 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
12203 TOKEN_STRING_INITIALIZER
12204 (struct cmd_vf_vlan_anti_spoof_result,
12208 cmd_set_vf_vlan_anti_spoof_parsed(
12209 void *parsed_result,
12210 __attribute__((unused)) struct cmdline *cl,
12211 __attribute__((unused)) void *data)
12213 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
12214 int ret = -ENOTSUP;
12216 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12218 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12221 #ifdef RTE_LIBRTE_IXGBE_PMD
12222 if (ret == -ENOTSUP)
12223 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
12224 res->vf_id, is_on);
12226 #ifdef RTE_LIBRTE_I40E_PMD
12227 if (ret == -ENOTSUP)
12228 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
12229 res->vf_id, is_on);
12231 #ifdef RTE_LIBRTE_BNXT_PMD
12232 if (ret == -ENOTSUP)
12233 ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
12234 res->vf_id, is_on);
12241 printf("invalid vf_id %d\n", res->vf_id);
12244 printf("invalid port_id %d\n", res->port_id);
12247 printf("function not implemented\n");
12250 printf("programming error: (%s)\n", strerror(-ret));
12254 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
12255 .f = cmd_set_vf_vlan_anti_spoof_parsed,
12257 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
12259 (void *)&cmd_vf_vlan_anti_spoof_set,
12260 (void *)&cmd_vf_vlan_anti_spoof_vf,
12261 (void *)&cmd_vf_vlan_anti_spoof_vlan,
12262 (void *)&cmd_vf_vlan_anti_spoof_antispoof,
12263 (void *)&cmd_vf_vlan_anti_spoof_port_id,
12264 (void *)&cmd_vf_vlan_anti_spoof_vf_id,
12265 (void *)&cmd_vf_vlan_anti_spoof_on_off,
12270 /* vf mac anti spoof configuration */
12272 /* Common result structure for vf mac anti spoof */
12273 struct cmd_vf_mac_anti_spoof_result {
12274 cmdline_fixed_string_t set;
12275 cmdline_fixed_string_t vf;
12276 cmdline_fixed_string_t mac;
12277 cmdline_fixed_string_t antispoof;
12280 cmdline_fixed_string_t on_off;
12283 /* Common CLI fields for vf mac anti spoof enable disable */
12284 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
12285 TOKEN_STRING_INITIALIZER
12286 (struct cmd_vf_mac_anti_spoof_result,
12288 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
12289 TOKEN_STRING_INITIALIZER
12290 (struct cmd_vf_mac_anti_spoof_result,
12292 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
12293 TOKEN_STRING_INITIALIZER
12294 (struct cmd_vf_mac_anti_spoof_result,
12296 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
12297 TOKEN_STRING_INITIALIZER
12298 (struct cmd_vf_mac_anti_spoof_result,
12299 antispoof, "antispoof");
12300 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
12301 TOKEN_NUM_INITIALIZER
12302 (struct cmd_vf_mac_anti_spoof_result,
12304 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
12305 TOKEN_NUM_INITIALIZER
12306 (struct cmd_vf_mac_anti_spoof_result,
12308 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
12309 TOKEN_STRING_INITIALIZER
12310 (struct cmd_vf_mac_anti_spoof_result,
12314 cmd_set_vf_mac_anti_spoof_parsed(
12315 void *parsed_result,
12316 __attribute__((unused)) struct cmdline *cl,
12317 __attribute__((unused)) void *data)
12319 struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
12320 int ret = -ENOTSUP;
12322 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12324 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12327 #ifdef RTE_LIBRTE_IXGBE_PMD
12328 if (ret == -ENOTSUP)
12329 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
12330 res->vf_id, is_on);
12332 #ifdef RTE_LIBRTE_I40E_PMD
12333 if (ret == -ENOTSUP)
12334 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
12335 res->vf_id, is_on);
12337 #ifdef RTE_LIBRTE_BNXT_PMD
12338 if (ret == -ENOTSUP)
12339 ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
12340 res->vf_id, is_on);
12347 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12350 printf("invalid port_id %d\n", res->port_id);
12353 printf("function not implemented\n");
12356 printf("programming error: (%s)\n", strerror(-ret));
12360 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
12361 .f = cmd_set_vf_mac_anti_spoof_parsed,
12363 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
12365 (void *)&cmd_vf_mac_anti_spoof_set,
12366 (void *)&cmd_vf_mac_anti_spoof_vf,
12367 (void *)&cmd_vf_mac_anti_spoof_mac,
12368 (void *)&cmd_vf_mac_anti_spoof_antispoof,
12369 (void *)&cmd_vf_mac_anti_spoof_port_id,
12370 (void *)&cmd_vf_mac_anti_spoof_vf_id,
12371 (void *)&cmd_vf_mac_anti_spoof_on_off,
12376 /* vf vlan strip queue configuration */
12378 /* Common result structure for vf mac anti spoof */
12379 struct cmd_vf_vlan_stripq_result {
12380 cmdline_fixed_string_t set;
12381 cmdline_fixed_string_t vf;
12382 cmdline_fixed_string_t vlan;
12383 cmdline_fixed_string_t stripq;
12386 cmdline_fixed_string_t on_off;
12389 /* Common CLI fields for vf vlan strip enable disable */
12390 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
12391 TOKEN_STRING_INITIALIZER
12392 (struct cmd_vf_vlan_stripq_result,
12394 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
12395 TOKEN_STRING_INITIALIZER
12396 (struct cmd_vf_vlan_stripq_result,
12398 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
12399 TOKEN_STRING_INITIALIZER
12400 (struct cmd_vf_vlan_stripq_result,
12402 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
12403 TOKEN_STRING_INITIALIZER
12404 (struct cmd_vf_vlan_stripq_result,
12406 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
12407 TOKEN_NUM_INITIALIZER
12408 (struct cmd_vf_vlan_stripq_result,
12410 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
12411 TOKEN_NUM_INITIALIZER
12412 (struct cmd_vf_vlan_stripq_result,
12414 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
12415 TOKEN_STRING_INITIALIZER
12416 (struct cmd_vf_vlan_stripq_result,
12420 cmd_set_vf_vlan_stripq_parsed(
12421 void *parsed_result,
12422 __attribute__((unused)) struct cmdline *cl,
12423 __attribute__((unused)) void *data)
12425 struct cmd_vf_vlan_stripq_result *res = parsed_result;
12426 int ret = -ENOTSUP;
12428 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12430 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12433 #ifdef RTE_LIBRTE_IXGBE_PMD
12434 if (ret == -ENOTSUP)
12435 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
12436 res->vf_id, is_on);
12438 #ifdef RTE_LIBRTE_I40E_PMD
12439 if (ret == -ENOTSUP)
12440 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
12441 res->vf_id, is_on);
12443 #ifdef RTE_LIBRTE_BNXT_PMD
12444 if (ret == -ENOTSUP)
12445 ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
12446 res->vf_id, is_on);
12453 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12456 printf("invalid port_id %d\n", res->port_id);
12459 printf("function not implemented\n");
12462 printf("programming error: (%s)\n", strerror(-ret));
12466 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
12467 .f = cmd_set_vf_vlan_stripq_parsed,
12469 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
12471 (void *)&cmd_vf_vlan_stripq_set,
12472 (void *)&cmd_vf_vlan_stripq_vf,
12473 (void *)&cmd_vf_vlan_stripq_vlan,
12474 (void *)&cmd_vf_vlan_stripq_stripq,
12475 (void *)&cmd_vf_vlan_stripq_port_id,
12476 (void *)&cmd_vf_vlan_stripq_vf_id,
12477 (void *)&cmd_vf_vlan_stripq_on_off,
12482 /* vf vlan insert configuration */
12484 /* Common result structure for vf vlan insert */
12485 struct cmd_vf_vlan_insert_result {
12486 cmdline_fixed_string_t set;
12487 cmdline_fixed_string_t vf;
12488 cmdline_fixed_string_t vlan;
12489 cmdline_fixed_string_t insert;
12495 /* Common CLI fields for vf vlan insert enable disable */
12496 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
12497 TOKEN_STRING_INITIALIZER
12498 (struct cmd_vf_vlan_insert_result,
12500 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
12501 TOKEN_STRING_INITIALIZER
12502 (struct cmd_vf_vlan_insert_result,
12504 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
12505 TOKEN_STRING_INITIALIZER
12506 (struct cmd_vf_vlan_insert_result,
12508 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
12509 TOKEN_STRING_INITIALIZER
12510 (struct cmd_vf_vlan_insert_result,
12512 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
12513 TOKEN_NUM_INITIALIZER
12514 (struct cmd_vf_vlan_insert_result,
12516 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
12517 TOKEN_NUM_INITIALIZER
12518 (struct cmd_vf_vlan_insert_result,
12520 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
12521 TOKEN_NUM_INITIALIZER
12522 (struct cmd_vf_vlan_insert_result,
12526 cmd_set_vf_vlan_insert_parsed(
12527 void *parsed_result,
12528 __attribute__((unused)) struct cmdline *cl,
12529 __attribute__((unused)) void *data)
12531 struct cmd_vf_vlan_insert_result *res = parsed_result;
12532 int ret = -ENOTSUP;
12534 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12537 #ifdef RTE_LIBRTE_IXGBE_PMD
12538 if (ret == -ENOTSUP)
12539 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
12542 #ifdef RTE_LIBRTE_I40E_PMD
12543 if (ret == -ENOTSUP)
12544 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
12547 #ifdef RTE_LIBRTE_BNXT_PMD
12548 if (ret == -ENOTSUP)
12549 ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
12557 printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id);
12560 printf("invalid port_id %d\n", res->port_id);
12563 printf("function not implemented\n");
12566 printf("programming error: (%s)\n", strerror(-ret));
12570 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
12571 .f = cmd_set_vf_vlan_insert_parsed,
12573 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
12575 (void *)&cmd_vf_vlan_insert_set,
12576 (void *)&cmd_vf_vlan_insert_vf,
12577 (void *)&cmd_vf_vlan_insert_vlan,
12578 (void *)&cmd_vf_vlan_insert_insert,
12579 (void *)&cmd_vf_vlan_insert_port_id,
12580 (void *)&cmd_vf_vlan_insert_vf_id,
12581 (void *)&cmd_vf_vlan_insert_vlan_id,
12586 /* tx loopback configuration */
12588 /* Common result structure for tx loopback */
12589 struct cmd_tx_loopback_result {
12590 cmdline_fixed_string_t set;
12591 cmdline_fixed_string_t tx;
12592 cmdline_fixed_string_t loopback;
12594 cmdline_fixed_string_t on_off;
12597 /* Common CLI fields for tx loopback enable disable */
12598 cmdline_parse_token_string_t cmd_tx_loopback_set =
12599 TOKEN_STRING_INITIALIZER
12600 (struct cmd_tx_loopback_result,
12602 cmdline_parse_token_string_t cmd_tx_loopback_tx =
12603 TOKEN_STRING_INITIALIZER
12604 (struct cmd_tx_loopback_result,
12606 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
12607 TOKEN_STRING_INITIALIZER
12608 (struct cmd_tx_loopback_result,
12609 loopback, "loopback");
12610 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
12611 TOKEN_NUM_INITIALIZER
12612 (struct cmd_tx_loopback_result,
12614 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
12615 TOKEN_STRING_INITIALIZER
12616 (struct cmd_tx_loopback_result,
12620 cmd_set_tx_loopback_parsed(
12621 void *parsed_result,
12622 __attribute__((unused)) struct cmdline *cl,
12623 __attribute__((unused)) void *data)
12625 struct cmd_tx_loopback_result *res = parsed_result;
12626 int ret = -ENOTSUP;
12628 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12630 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12633 #ifdef RTE_LIBRTE_IXGBE_PMD
12634 if (ret == -ENOTSUP)
12635 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
12637 #ifdef RTE_LIBRTE_I40E_PMD
12638 if (ret == -ENOTSUP)
12639 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
12641 #ifdef RTE_LIBRTE_BNXT_PMD
12642 if (ret == -ENOTSUP)
12643 ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
12650 printf("invalid is_on %d\n", is_on);
12653 printf("invalid port_id %d\n", res->port_id);
12656 printf("function not implemented\n");
12659 printf("programming error: (%s)\n", strerror(-ret));
12663 cmdline_parse_inst_t cmd_set_tx_loopback = {
12664 .f = cmd_set_tx_loopback_parsed,
12666 .help_str = "set tx loopback <port_id> on|off",
12668 (void *)&cmd_tx_loopback_set,
12669 (void *)&cmd_tx_loopback_tx,
12670 (void *)&cmd_tx_loopback_loopback,
12671 (void *)&cmd_tx_loopback_port_id,
12672 (void *)&cmd_tx_loopback_on_off,
12677 /* all queues drop enable configuration */
12679 /* Common result structure for all queues drop enable */
12680 struct cmd_all_queues_drop_en_result {
12681 cmdline_fixed_string_t set;
12682 cmdline_fixed_string_t all;
12683 cmdline_fixed_string_t queues;
12684 cmdline_fixed_string_t drop;
12686 cmdline_fixed_string_t on_off;
12689 /* Common CLI fields for tx loopback enable disable */
12690 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
12691 TOKEN_STRING_INITIALIZER
12692 (struct cmd_all_queues_drop_en_result,
12694 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
12695 TOKEN_STRING_INITIALIZER
12696 (struct cmd_all_queues_drop_en_result,
12698 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
12699 TOKEN_STRING_INITIALIZER
12700 (struct cmd_all_queues_drop_en_result,
12702 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
12703 TOKEN_STRING_INITIALIZER
12704 (struct cmd_all_queues_drop_en_result,
12706 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
12707 TOKEN_NUM_INITIALIZER
12708 (struct cmd_all_queues_drop_en_result,
12710 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
12711 TOKEN_STRING_INITIALIZER
12712 (struct cmd_all_queues_drop_en_result,
12716 cmd_set_all_queues_drop_en_parsed(
12717 void *parsed_result,
12718 __attribute__((unused)) struct cmdline *cl,
12719 __attribute__((unused)) void *data)
12721 struct cmd_all_queues_drop_en_result *res = parsed_result;
12722 int ret = -ENOTSUP;
12723 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12725 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12728 #ifdef RTE_LIBRTE_IXGBE_PMD
12729 if (ret == -ENOTSUP)
12730 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
12732 #ifdef RTE_LIBRTE_BNXT_PMD
12733 if (ret == -ENOTSUP)
12734 ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
12740 printf("invalid is_on %d\n", is_on);
12743 printf("invalid port_id %d\n", res->port_id);
12746 printf("function not implemented\n");
12749 printf("programming error: (%s)\n", strerror(-ret));
12753 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
12754 .f = cmd_set_all_queues_drop_en_parsed,
12756 .help_str = "set all queues drop <port_id> on|off",
12758 (void *)&cmd_all_queues_drop_en_set,
12759 (void *)&cmd_all_queues_drop_en_all,
12760 (void *)&cmd_all_queues_drop_en_queues,
12761 (void *)&cmd_all_queues_drop_en_drop,
12762 (void *)&cmd_all_queues_drop_en_port_id,
12763 (void *)&cmd_all_queues_drop_en_on_off,
12768 /* vf split drop enable configuration */
12770 /* Common result structure for vf split drop enable */
12771 struct cmd_vf_split_drop_en_result {
12772 cmdline_fixed_string_t set;
12773 cmdline_fixed_string_t vf;
12774 cmdline_fixed_string_t split;
12775 cmdline_fixed_string_t drop;
12778 cmdline_fixed_string_t on_off;
12781 /* Common CLI fields for vf split drop enable disable */
12782 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
12783 TOKEN_STRING_INITIALIZER
12784 (struct cmd_vf_split_drop_en_result,
12786 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
12787 TOKEN_STRING_INITIALIZER
12788 (struct cmd_vf_split_drop_en_result,
12790 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
12791 TOKEN_STRING_INITIALIZER
12792 (struct cmd_vf_split_drop_en_result,
12794 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
12795 TOKEN_STRING_INITIALIZER
12796 (struct cmd_vf_split_drop_en_result,
12798 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
12799 TOKEN_NUM_INITIALIZER
12800 (struct cmd_vf_split_drop_en_result,
12802 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
12803 TOKEN_NUM_INITIALIZER
12804 (struct cmd_vf_split_drop_en_result,
12806 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
12807 TOKEN_STRING_INITIALIZER
12808 (struct cmd_vf_split_drop_en_result,
12812 cmd_set_vf_split_drop_en_parsed(
12813 void *parsed_result,
12814 __attribute__((unused)) struct cmdline *cl,
12815 __attribute__((unused)) void *data)
12817 struct cmd_vf_split_drop_en_result *res = parsed_result;
12818 int ret = -ENOTSUP;
12819 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12821 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12824 #ifdef RTE_LIBRTE_IXGBE_PMD
12825 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
12832 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12835 printf("invalid port_id %d\n", res->port_id);
12838 printf("not supported on port %d\n", res->port_id);
12841 printf("programming error: (%s)\n", strerror(-ret));
12845 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
12846 .f = cmd_set_vf_split_drop_en_parsed,
12848 .help_str = "set vf split drop <port_id> <vf_id> on|off",
12850 (void *)&cmd_vf_split_drop_en_set,
12851 (void *)&cmd_vf_split_drop_en_vf,
12852 (void *)&cmd_vf_split_drop_en_split,
12853 (void *)&cmd_vf_split_drop_en_drop,
12854 (void *)&cmd_vf_split_drop_en_port_id,
12855 (void *)&cmd_vf_split_drop_en_vf_id,
12856 (void *)&cmd_vf_split_drop_en_on_off,
12861 /* vf mac address configuration */
12863 /* Common result structure for vf mac address */
12864 struct cmd_set_vf_mac_addr_result {
12865 cmdline_fixed_string_t set;
12866 cmdline_fixed_string_t vf;
12867 cmdline_fixed_string_t mac;
12868 cmdline_fixed_string_t addr;
12871 struct ether_addr mac_addr;
12875 /* Common CLI fields for vf split drop enable disable */
12876 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
12877 TOKEN_STRING_INITIALIZER
12878 (struct cmd_set_vf_mac_addr_result,
12880 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
12881 TOKEN_STRING_INITIALIZER
12882 (struct cmd_set_vf_mac_addr_result,
12884 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
12885 TOKEN_STRING_INITIALIZER
12886 (struct cmd_set_vf_mac_addr_result,
12888 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
12889 TOKEN_STRING_INITIALIZER
12890 (struct cmd_set_vf_mac_addr_result,
12892 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
12893 TOKEN_NUM_INITIALIZER
12894 (struct cmd_set_vf_mac_addr_result,
12896 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
12897 TOKEN_NUM_INITIALIZER
12898 (struct cmd_set_vf_mac_addr_result,
12900 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
12901 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
12905 cmd_set_vf_mac_addr_parsed(
12906 void *parsed_result,
12907 __attribute__((unused)) struct cmdline *cl,
12908 __attribute__((unused)) void *data)
12910 struct cmd_set_vf_mac_addr_result *res = parsed_result;
12911 int ret = -ENOTSUP;
12913 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12916 #ifdef RTE_LIBRTE_IXGBE_PMD
12917 if (ret == -ENOTSUP)
12918 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
12921 #ifdef RTE_LIBRTE_I40E_PMD
12922 if (ret == -ENOTSUP)
12923 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
12926 #ifdef RTE_LIBRTE_BNXT_PMD
12927 if (ret == -ENOTSUP)
12928 ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
12936 printf("invalid vf_id %d or mac_addr\n", res->vf_id);
12939 printf("invalid port_id %d\n", res->port_id);
12942 printf("function not implemented\n");
12945 printf("programming error: (%s)\n", strerror(-ret));
12949 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
12950 .f = cmd_set_vf_mac_addr_parsed,
12952 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
12954 (void *)&cmd_set_vf_mac_addr_set,
12955 (void *)&cmd_set_vf_mac_addr_vf,
12956 (void *)&cmd_set_vf_mac_addr_mac,
12957 (void *)&cmd_set_vf_mac_addr_addr,
12958 (void *)&cmd_set_vf_mac_addr_port_id,
12959 (void *)&cmd_set_vf_mac_addr_vf_id,
12960 (void *)&cmd_set_vf_mac_addr_mac_addr,
12965 /* MACsec configuration */
12967 /* Common result structure for MACsec offload enable */
12968 struct cmd_macsec_offload_on_result {
12969 cmdline_fixed_string_t set;
12970 cmdline_fixed_string_t macsec;
12971 cmdline_fixed_string_t offload;
12973 cmdline_fixed_string_t on;
12974 cmdline_fixed_string_t encrypt;
12975 cmdline_fixed_string_t en_on_off;
12976 cmdline_fixed_string_t replay_protect;
12977 cmdline_fixed_string_t rp_on_off;
12980 /* Common CLI fields for MACsec offload disable */
12981 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
12982 TOKEN_STRING_INITIALIZER
12983 (struct cmd_macsec_offload_on_result,
12985 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
12986 TOKEN_STRING_INITIALIZER
12987 (struct cmd_macsec_offload_on_result,
12989 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
12990 TOKEN_STRING_INITIALIZER
12991 (struct cmd_macsec_offload_on_result,
12992 offload, "offload");
12993 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
12994 TOKEN_NUM_INITIALIZER
12995 (struct cmd_macsec_offload_on_result,
12997 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
12998 TOKEN_STRING_INITIALIZER
12999 (struct cmd_macsec_offload_on_result,
13001 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
13002 TOKEN_STRING_INITIALIZER
13003 (struct cmd_macsec_offload_on_result,
13004 encrypt, "encrypt");
13005 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
13006 TOKEN_STRING_INITIALIZER
13007 (struct cmd_macsec_offload_on_result,
13008 en_on_off, "on#off");
13009 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
13010 TOKEN_STRING_INITIALIZER
13011 (struct cmd_macsec_offload_on_result,
13012 replay_protect, "replay-protect");
13013 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
13014 TOKEN_STRING_INITIALIZER
13015 (struct cmd_macsec_offload_on_result,
13016 rp_on_off, "on#off");
13019 cmd_set_macsec_offload_on_parsed(
13020 void *parsed_result,
13021 __attribute__((unused)) struct cmdline *cl,
13022 __attribute__((unused)) void *data)
13024 struct cmd_macsec_offload_on_result *res = parsed_result;
13025 int ret = -ENOTSUP;
13026 portid_t port_id = res->port_id;
13027 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
13028 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
13030 if (port_id_is_invalid(port_id, ENABLED_WARN))
13033 ports[port_id].tx_ol_flags |= TESTPMD_TX_OFFLOAD_MACSEC;
13034 #ifdef RTE_LIBRTE_IXGBE_PMD
13035 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
13044 printf("invalid port_id %d\n", port_id);
13047 printf("not supported on port %d\n", port_id);
13050 printf("programming error: (%s)\n", strerror(-ret));
13054 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
13055 .f = cmd_set_macsec_offload_on_parsed,
13057 .help_str = "set macsec offload <port_id> on "
13058 "encrypt on|off replay-protect on|off",
13060 (void *)&cmd_macsec_offload_on_set,
13061 (void *)&cmd_macsec_offload_on_macsec,
13062 (void *)&cmd_macsec_offload_on_offload,
13063 (void *)&cmd_macsec_offload_on_port_id,
13064 (void *)&cmd_macsec_offload_on_on,
13065 (void *)&cmd_macsec_offload_on_encrypt,
13066 (void *)&cmd_macsec_offload_on_en_on_off,
13067 (void *)&cmd_macsec_offload_on_replay_protect,
13068 (void *)&cmd_macsec_offload_on_rp_on_off,
13073 /* Common result structure for MACsec offload disable */
13074 struct cmd_macsec_offload_off_result {
13075 cmdline_fixed_string_t set;
13076 cmdline_fixed_string_t macsec;
13077 cmdline_fixed_string_t offload;
13079 cmdline_fixed_string_t off;
13082 /* Common CLI fields for MACsec offload disable */
13083 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
13084 TOKEN_STRING_INITIALIZER
13085 (struct cmd_macsec_offload_off_result,
13087 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
13088 TOKEN_STRING_INITIALIZER
13089 (struct cmd_macsec_offload_off_result,
13091 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
13092 TOKEN_STRING_INITIALIZER
13093 (struct cmd_macsec_offload_off_result,
13094 offload, "offload");
13095 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
13096 TOKEN_NUM_INITIALIZER
13097 (struct cmd_macsec_offload_off_result,
13099 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
13100 TOKEN_STRING_INITIALIZER
13101 (struct cmd_macsec_offload_off_result,
13105 cmd_set_macsec_offload_off_parsed(
13106 void *parsed_result,
13107 __attribute__((unused)) struct cmdline *cl,
13108 __attribute__((unused)) void *data)
13110 struct cmd_macsec_offload_off_result *res = parsed_result;
13111 int ret = -ENOTSUP;
13112 portid_t port_id = res->port_id;
13114 if (port_id_is_invalid(port_id, ENABLED_WARN))
13117 ports[port_id].tx_ol_flags &= ~TESTPMD_TX_OFFLOAD_MACSEC;
13118 #ifdef RTE_LIBRTE_IXGBE_PMD
13119 ret = rte_pmd_ixgbe_macsec_disable(port_id);
13126 printf("invalid port_id %d\n", port_id);
13129 printf("not supported on port %d\n", port_id);
13132 printf("programming error: (%s)\n", strerror(-ret));
13136 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
13137 .f = cmd_set_macsec_offload_off_parsed,
13139 .help_str = "set macsec offload <port_id> off",
13141 (void *)&cmd_macsec_offload_off_set,
13142 (void *)&cmd_macsec_offload_off_macsec,
13143 (void *)&cmd_macsec_offload_off_offload,
13144 (void *)&cmd_macsec_offload_off_port_id,
13145 (void *)&cmd_macsec_offload_off_off,
13150 /* Common result structure for MACsec secure connection configure */
13151 struct cmd_macsec_sc_result {
13152 cmdline_fixed_string_t set;
13153 cmdline_fixed_string_t macsec;
13154 cmdline_fixed_string_t sc;
13155 cmdline_fixed_string_t tx_rx;
13157 struct ether_addr mac;
13161 /* Common CLI fields for MACsec secure connection configure */
13162 cmdline_parse_token_string_t cmd_macsec_sc_set =
13163 TOKEN_STRING_INITIALIZER
13164 (struct cmd_macsec_sc_result,
13166 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
13167 TOKEN_STRING_INITIALIZER
13168 (struct cmd_macsec_sc_result,
13170 cmdline_parse_token_string_t cmd_macsec_sc_sc =
13171 TOKEN_STRING_INITIALIZER
13172 (struct cmd_macsec_sc_result,
13174 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
13175 TOKEN_STRING_INITIALIZER
13176 (struct cmd_macsec_sc_result,
13178 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
13179 TOKEN_NUM_INITIALIZER
13180 (struct cmd_macsec_sc_result,
13182 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
13183 TOKEN_ETHERADDR_INITIALIZER
13184 (struct cmd_macsec_sc_result,
13186 cmdline_parse_token_num_t cmd_macsec_sc_pi =
13187 TOKEN_NUM_INITIALIZER
13188 (struct cmd_macsec_sc_result,
13192 cmd_set_macsec_sc_parsed(
13193 void *parsed_result,
13194 __attribute__((unused)) struct cmdline *cl,
13195 __attribute__((unused)) void *data)
13197 struct cmd_macsec_sc_result *res = parsed_result;
13198 int ret = -ENOTSUP;
13199 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
13201 #ifdef RTE_LIBRTE_IXGBE_PMD
13203 rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
13204 res->mac.addr_bytes) :
13205 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
13206 res->mac.addr_bytes, res->pi);
13208 RTE_SET_USED(is_tx);
13214 printf("invalid port_id %d\n", res->port_id);
13217 printf("not supported on port %d\n", res->port_id);
13220 printf("programming error: (%s)\n", strerror(-ret));
13224 cmdline_parse_inst_t cmd_set_macsec_sc = {
13225 .f = cmd_set_macsec_sc_parsed,
13227 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
13229 (void *)&cmd_macsec_sc_set,
13230 (void *)&cmd_macsec_sc_macsec,
13231 (void *)&cmd_macsec_sc_sc,
13232 (void *)&cmd_macsec_sc_tx_rx,
13233 (void *)&cmd_macsec_sc_port_id,
13234 (void *)&cmd_macsec_sc_mac,
13235 (void *)&cmd_macsec_sc_pi,
13240 /* Common result structure for MACsec secure connection configure */
13241 struct cmd_macsec_sa_result {
13242 cmdline_fixed_string_t set;
13243 cmdline_fixed_string_t macsec;
13244 cmdline_fixed_string_t sa;
13245 cmdline_fixed_string_t tx_rx;
13250 cmdline_fixed_string_t key;
13253 /* Common CLI fields for MACsec secure connection configure */
13254 cmdline_parse_token_string_t cmd_macsec_sa_set =
13255 TOKEN_STRING_INITIALIZER
13256 (struct cmd_macsec_sa_result,
13258 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
13259 TOKEN_STRING_INITIALIZER
13260 (struct cmd_macsec_sa_result,
13262 cmdline_parse_token_string_t cmd_macsec_sa_sa =
13263 TOKEN_STRING_INITIALIZER
13264 (struct cmd_macsec_sa_result,
13266 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
13267 TOKEN_STRING_INITIALIZER
13268 (struct cmd_macsec_sa_result,
13270 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
13271 TOKEN_NUM_INITIALIZER
13272 (struct cmd_macsec_sa_result,
13274 cmdline_parse_token_num_t cmd_macsec_sa_idx =
13275 TOKEN_NUM_INITIALIZER
13276 (struct cmd_macsec_sa_result,
13278 cmdline_parse_token_num_t cmd_macsec_sa_an =
13279 TOKEN_NUM_INITIALIZER
13280 (struct cmd_macsec_sa_result,
13282 cmdline_parse_token_num_t cmd_macsec_sa_pn =
13283 TOKEN_NUM_INITIALIZER
13284 (struct cmd_macsec_sa_result,
13286 cmdline_parse_token_string_t cmd_macsec_sa_key =
13287 TOKEN_STRING_INITIALIZER
13288 (struct cmd_macsec_sa_result,
13292 cmd_set_macsec_sa_parsed(
13293 void *parsed_result,
13294 __attribute__((unused)) struct cmdline *cl,
13295 __attribute__((unused)) void *data)
13297 struct cmd_macsec_sa_result *res = parsed_result;
13298 int ret = -ENOTSUP;
13299 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
13300 uint8_t key[16] = { 0 };
13306 key_len = strlen(res->key) / 2;
13310 for (i = 0; i < key_len; i++) {
13311 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
13314 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
13317 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
13320 #ifdef RTE_LIBRTE_IXGBE_PMD
13322 rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
13323 res->idx, res->an, res->pn, key) :
13324 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
13325 res->idx, res->an, res->pn, key);
13327 RTE_SET_USED(is_tx);
13334 printf("invalid idx %d or an %d\n", res->idx, res->an);
13337 printf("invalid port_id %d\n", res->port_id);
13340 printf("not supported on port %d\n", res->port_id);
13343 printf("programming error: (%s)\n", strerror(-ret));
13347 cmdline_parse_inst_t cmd_set_macsec_sa = {
13348 .f = cmd_set_macsec_sa_parsed,
13350 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
13352 (void *)&cmd_macsec_sa_set,
13353 (void *)&cmd_macsec_sa_macsec,
13354 (void *)&cmd_macsec_sa_sa,
13355 (void *)&cmd_macsec_sa_tx_rx,
13356 (void *)&cmd_macsec_sa_port_id,
13357 (void *)&cmd_macsec_sa_idx,
13358 (void *)&cmd_macsec_sa_an,
13359 (void *)&cmd_macsec_sa_pn,
13360 (void *)&cmd_macsec_sa_key,
13365 /* VF unicast promiscuous mode configuration */
13367 /* Common result structure for VF unicast promiscuous mode */
13368 struct cmd_vf_promisc_result {
13369 cmdline_fixed_string_t set;
13370 cmdline_fixed_string_t vf;
13371 cmdline_fixed_string_t promisc;
13374 cmdline_fixed_string_t on_off;
13377 /* Common CLI fields for VF unicast promiscuous mode enable disable */
13378 cmdline_parse_token_string_t cmd_vf_promisc_set =
13379 TOKEN_STRING_INITIALIZER
13380 (struct cmd_vf_promisc_result,
13382 cmdline_parse_token_string_t cmd_vf_promisc_vf =
13383 TOKEN_STRING_INITIALIZER
13384 (struct cmd_vf_promisc_result,
13386 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
13387 TOKEN_STRING_INITIALIZER
13388 (struct cmd_vf_promisc_result,
13389 promisc, "promisc");
13390 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
13391 TOKEN_NUM_INITIALIZER
13392 (struct cmd_vf_promisc_result,
13394 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
13395 TOKEN_NUM_INITIALIZER
13396 (struct cmd_vf_promisc_result,
13398 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
13399 TOKEN_STRING_INITIALIZER
13400 (struct cmd_vf_promisc_result,
13404 cmd_set_vf_promisc_parsed(
13405 void *parsed_result,
13406 __attribute__((unused)) struct cmdline *cl,
13407 __attribute__((unused)) void *data)
13409 struct cmd_vf_promisc_result *res = parsed_result;
13410 int ret = -ENOTSUP;
13412 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13414 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13417 #ifdef RTE_LIBRTE_I40E_PMD
13418 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
13419 res->vf_id, is_on);
13426 printf("invalid vf_id %d\n", res->vf_id);
13429 printf("invalid port_id %d\n", res->port_id);
13432 printf("function not implemented\n");
13435 printf("programming error: (%s)\n", strerror(-ret));
13439 cmdline_parse_inst_t cmd_set_vf_promisc = {
13440 .f = cmd_set_vf_promisc_parsed,
13442 .help_str = "set vf promisc <port_id> <vf_id> on|off: "
13443 "Set unicast promiscuous mode for a VF from the PF",
13445 (void *)&cmd_vf_promisc_set,
13446 (void *)&cmd_vf_promisc_vf,
13447 (void *)&cmd_vf_promisc_promisc,
13448 (void *)&cmd_vf_promisc_port_id,
13449 (void *)&cmd_vf_promisc_vf_id,
13450 (void *)&cmd_vf_promisc_on_off,
13455 /* VF multicast promiscuous mode configuration */
13457 /* Common result structure for VF multicast promiscuous mode */
13458 struct cmd_vf_allmulti_result {
13459 cmdline_fixed_string_t set;
13460 cmdline_fixed_string_t vf;
13461 cmdline_fixed_string_t allmulti;
13464 cmdline_fixed_string_t on_off;
13467 /* Common CLI fields for VF multicast promiscuous mode enable disable */
13468 cmdline_parse_token_string_t cmd_vf_allmulti_set =
13469 TOKEN_STRING_INITIALIZER
13470 (struct cmd_vf_allmulti_result,
13472 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
13473 TOKEN_STRING_INITIALIZER
13474 (struct cmd_vf_allmulti_result,
13476 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
13477 TOKEN_STRING_INITIALIZER
13478 (struct cmd_vf_allmulti_result,
13479 allmulti, "allmulti");
13480 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
13481 TOKEN_NUM_INITIALIZER
13482 (struct cmd_vf_allmulti_result,
13484 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
13485 TOKEN_NUM_INITIALIZER
13486 (struct cmd_vf_allmulti_result,
13488 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
13489 TOKEN_STRING_INITIALIZER
13490 (struct cmd_vf_allmulti_result,
13494 cmd_set_vf_allmulti_parsed(
13495 void *parsed_result,
13496 __attribute__((unused)) struct cmdline *cl,
13497 __attribute__((unused)) void *data)
13499 struct cmd_vf_allmulti_result *res = parsed_result;
13500 int ret = -ENOTSUP;
13502 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13504 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13507 #ifdef RTE_LIBRTE_I40E_PMD
13508 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
13509 res->vf_id, is_on);
13516 printf("invalid vf_id %d\n", res->vf_id);
13519 printf("invalid port_id %d\n", res->port_id);
13522 printf("function not implemented\n");
13525 printf("programming error: (%s)\n", strerror(-ret));
13529 cmdline_parse_inst_t cmd_set_vf_allmulti = {
13530 .f = cmd_set_vf_allmulti_parsed,
13532 .help_str = "set vf allmulti <port_id> <vf_id> on|off: "
13533 "Set multicast promiscuous mode for a VF from the PF",
13535 (void *)&cmd_vf_allmulti_set,
13536 (void *)&cmd_vf_allmulti_vf,
13537 (void *)&cmd_vf_allmulti_allmulti,
13538 (void *)&cmd_vf_allmulti_port_id,
13539 (void *)&cmd_vf_allmulti_vf_id,
13540 (void *)&cmd_vf_allmulti_on_off,
13545 /* vf broadcast mode configuration */
13547 /* Common result structure for vf broadcast */
13548 struct cmd_set_vf_broadcast_result {
13549 cmdline_fixed_string_t set;
13550 cmdline_fixed_string_t vf;
13551 cmdline_fixed_string_t broadcast;
13554 cmdline_fixed_string_t on_off;
13557 /* Common CLI fields for vf broadcast enable disable */
13558 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
13559 TOKEN_STRING_INITIALIZER
13560 (struct cmd_set_vf_broadcast_result,
13562 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
13563 TOKEN_STRING_INITIALIZER
13564 (struct cmd_set_vf_broadcast_result,
13566 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
13567 TOKEN_STRING_INITIALIZER
13568 (struct cmd_set_vf_broadcast_result,
13569 broadcast, "broadcast");
13570 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
13571 TOKEN_NUM_INITIALIZER
13572 (struct cmd_set_vf_broadcast_result,
13574 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
13575 TOKEN_NUM_INITIALIZER
13576 (struct cmd_set_vf_broadcast_result,
13578 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
13579 TOKEN_STRING_INITIALIZER
13580 (struct cmd_set_vf_broadcast_result,
13584 cmd_set_vf_broadcast_parsed(
13585 void *parsed_result,
13586 __attribute__((unused)) struct cmdline *cl,
13587 __attribute__((unused)) void *data)
13589 struct cmd_set_vf_broadcast_result *res = parsed_result;
13590 int ret = -ENOTSUP;
13592 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13594 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13597 #ifdef RTE_LIBRTE_I40E_PMD
13598 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
13599 res->vf_id, is_on);
13606 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13609 printf("invalid port_id %d\n", res->port_id);
13612 printf("function not implemented\n");
13615 printf("programming error: (%s)\n", strerror(-ret));
13619 cmdline_parse_inst_t cmd_set_vf_broadcast = {
13620 .f = cmd_set_vf_broadcast_parsed,
13622 .help_str = "set vf broadcast <port_id> <vf_id> on|off",
13624 (void *)&cmd_set_vf_broadcast_set,
13625 (void *)&cmd_set_vf_broadcast_vf,
13626 (void *)&cmd_set_vf_broadcast_broadcast,
13627 (void *)&cmd_set_vf_broadcast_port_id,
13628 (void *)&cmd_set_vf_broadcast_vf_id,
13629 (void *)&cmd_set_vf_broadcast_on_off,
13634 /* vf vlan tag configuration */
13636 /* Common result structure for vf vlan tag */
13637 struct cmd_set_vf_vlan_tag_result {
13638 cmdline_fixed_string_t set;
13639 cmdline_fixed_string_t vf;
13640 cmdline_fixed_string_t vlan;
13641 cmdline_fixed_string_t tag;
13644 cmdline_fixed_string_t on_off;
13647 /* Common CLI fields for vf vlan tag enable disable */
13648 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
13649 TOKEN_STRING_INITIALIZER
13650 (struct cmd_set_vf_vlan_tag_result,
13652 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
13653 TOKEN_STRING_INITIALIZER
13654 (struct cmd_set_vf_vlan_tag_result,
13656 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
13657 TOKEN_STRING_INITIALIZER
13658 (struct cmd_set_vf_vlan_tag_result,
13660 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
13661 TOKEN_STRING_INITIALIZER
13662 (struct cmd_set_vf_vlan_tag_result,
13664 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
13665 TOKEN_NUM_INITIALIZER
13666 (struct cmd_set_vf_vlan_tag_result,
13668 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
13669 TOKEN_NUM_INITIALIZER
13670 (struct cmd_set_vf_vlan_tag_result,
13672 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
13673 TOKEN_STRING_INITIALIZER
13674 (struct cmd_set_vf_vlan_tag_result,
13678 cmd_set_vf_vlan_tag_parsed(
13679 void *parsed_result,
13680 __attribute__((unused)) struct cmdline *cl,
13681 __attribute__((unused)) void *data)
13683 struct cmd_set_vf_vlan_tag_result *res = parsed_result;
13684 int ret = -ENOTSUP;
13686 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13688 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13691 #ifdef RTE_LIBRTE_I40E_PMD
13692 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
13693 res->vf_id, is_on);
13700 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13703 printf("invalid port_id %d\n", res->port_id);
13706 printf("function not implemented\n");
13709 printf("programming error: (%s)\n", strerror(-ret));
13713 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
13714 .f = cmd_set_vf_vlan_tag_parsed,
13716 .help_str = "set vf vlan tag <port_id> <vf_id> on|off",
13718 (void *)&cmd_set_vf_vlan_tag_set,
13719 (void *)&cmd_set_vf_vlan_tag_vf,
13720 (void *)&cmd_set_vf_vlan_tag_vlan,
13721 (void *)&cmd_set_vf_vlan_tag_tag,
13722 (void *)&cmd_set_vf_vlan_tag_port_id,
13723 (void *)&cmd_set_vf_vlan_tag_vf_id,
13724 (void *)&cmd_set_vf_vlan_tag_on_off,
13729 /* Common definition of VF and TC TX bandwidth configuration */
13730 struct cmd_vf_tc_bw_result {
13731 cmdline_fixed_string_t set;
13732 cmdline_fixed_string_t vf;
13733 cmdline_fixed_string_t tc;
13734 cmdline_fixed_string_t tx;
13735 cmdline_fixed_string_t min_bw;
13736 cmdline_fixed_string_t max_bw;
13737 cmdline_fixed_string_t strict_link_prio;
13742 cmdline_fixed_string_t bw_list;
13746 cmdline_parse_token_string_t cmd_vf_tc_bw_set =
13747 TOKEN_STRING_INITIALIZER
13748 (struct cmd_vf_tc_bw_result,
13750 cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
13751 TOKEN_STRING_INITIALIZER
13752 (struct cmd_vf_tc_bw_result,
13754 cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
13755 TOKEN_STRING_INITIALIZER
13756 (struct cmd_vf_tc_bw_result,
13758 cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
13759 TOKEN_STRING_INITIALIZER
13760 (struct cmd_vf_tc_bw_result,
13762 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio =
13763 TOKEN_STRING_INITIALIZER
13764 (struct cmd_vf_tc_bw_result,
13765 strict_link_prio, "strict-link-priority");
13766 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw =
13767 TOKEN_STRING_INITIALIZER
13768 (struct cmd_vf_tc_bw_result,
13769 min_bw, "min-bandwidth");
13770 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
13771 TOKEN_STRING_INITIALIZER
13772 (struct cmd_vf_tc_bw_result,
13773 max_bw, "max-bandwidth");
13774 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
13775 TOKEN_NUM_INITIALIZER
13776 (struct cmd_vf_tc_bw_result,
13778 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
13779 TOKEN_NUM_INITIALIZER
13780 (struct cmd_vf_tc_bw_result,
13782 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no =
13783 TOKEN_NUM_INITIALIZER
13784 (struct cmd_vf_tc_bw_result,
13786 cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
13787 TOKEN_NUM_INITIALIZER
13788 (struct cmd_vf_tc_bw_result,
13790 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
13791 TOKEN_STRING_INITIALIZER
13792 (struct cmd_vf_tc_bw_result,
13794 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map =
13795 TOKEN_NUM_INITIALIZER
13796 (struct cmd_vf_tc_bw_result,
13799 /* VF max bandwidth setting */
13801 cmd_vf_max_bw_parsed(
13802 void *parsed_result,
13803 __attribute__((unused)) struct cmdline *cl,
13804 __attribute__((unused)) void *data)
13806 struct cmd_vf_tc_bw_result *res = parsed_result;
13807 int ret = -ENOTSUP;
13809 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13812 #ifdef RTE_LIBRTE_I40E_PMD
13813 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id,
13814 res->vf_id, res->bw);
13821 printf("invalid vf_id %d or bandwidth %d\n",
13822 res->vf_id, res->bw);
13825 printf("invalid port_id %d\n", res->port_id);
13828 printf("function not implemented\n");
13831 printf("programming error: (%s)\n", strerror(-ret));
13835 cmdline_parse_inst_t cmd_vf_max_bw = {
13836 .f = cmd_vf_max_bw_parsed,
13838 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
13840 (void *)&cmd_vf_tc_bw_set,
13841 (void *)&cmd_vf_tc_bw_vf,
13842 (void *)&cmd_vf_tc_bw_tx,
13843 (void *)&cmd_vf_tc_bw_max_bw,
13844 (void *)&cmd_vf_tc_bw_port_id,
13845 (void *)&cmd_vf_tc_bw_vf_id,
13846 (void *)&cmd_vf_tc_bw_bw,
13852 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
13857 const char *p, *p0 = str;
13864 p = strchr(p0, '(');
13866 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
13870 p0 = strchr(p, ')');
13872 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
13876 if (size >= sizeof(s)) {
13877 printf("The string size exceeds the internal buffer size\n");
13880 snprintf(s, sizeof(s), "%.*s", size, p);
13881 ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
13883 printf("Failed to get the bandwidth list. ");
13887 for (i = 0; i < ret; i++)
13888 bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
13893 /* TC min bandwidth setting */
13895 cmd_vf_tc_min_bw_parsed(
13896 void *parsed_result,
13897 __attribute__((unused)) struct cmdline *cl,
13898 __attribute__((unused)) void *data)
13900 struct cmd_vf_tc_bw_result *res = parsed_result;
13903 int ret = -ENOTSUP;
13905 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13908 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
13912 #ifdef RTE_LIBRTE_I40E_PMD
13913 ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
13921 printf("invalid vf_id %d or bandwidth\n", res->vf_id);
13924 printf("invalid port_id %d\n", res->port_id);
13927 printf("function not implemented\n");
13930 printf("programming error: (%s)\n", strerror(-ret));
13934 cmdline_parse_inst_t cmd_vf_tc_min_bw = {
13935 .f = cmd_vf_tc_min_bw_parsed,
13937 .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
13938 " <bw1, bw2, ...>",
13940 (void *)&cmd_vf_tc_bw_set,
13941 (void *)&cmd_vf_tc_bw_vf,
13942 (void *)&cmd_vf_tc_bw_tc,
13943 (void *)&cmd_vf_tc_bw_tx,
13944 (void *)&cmd_vf_tc_bw_min_bw,
13945 (void *)&cmd_vf_tc_bw_port_id,
13946 (void *)&cmd_vf_tc_bw_vf_id,
13947 (void *)&cmd_vf_tc_bw_bw_list,
13953 cmd_tc_min_bw_parsed(
13954 void *parsed_result,
13955 __attribute__((unused)) struct cmdline *cl,
13956 __attribute__((unused)) void *data)
13958 struct cmd_vf_tc_bw_result *res = parsed_result;
13959 struct rte_port *port;
13962 int ret = -ENOTSUP;
13964 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13967 port = &ports[res->port_id];
13968 /** Check if the port is not started **/
13969 if (port->port_status != RTE_PORT_STOPPED) {
13970 printf("Please stop port %d first\n", res->port_id);
13974 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
13978 #ifdef RTE_LIBRTE_IXGBE_PMD
13979 ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw);
13986 printf("invalid bandwidth\n");
13989 printf("invalid port_id %d\n", res->port_id);
13992 printf("function not implemented\n");
13995 printf("programming error: (%s)\n", strerror(-ret));
13999 cmdline_parse_inst_t cmd_tc_min_bw = {
14000 .f = cmd_tc_min_bw_parsed,
14002 .help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>",
14004 (void *)&cmd_vf_tc_bw_set,
14005 (void *)&cmd_vf_tc_bw_tc,
14006 (void *)&cmd_vf_tc_bw_tx,
14007 (void *)&cmd_vf_tc_bw_min_bw,
14008 (void *)&cmd_vf_tc_bw_port_id,
14009 (void *)&cmd_vf_tc_bw_bw_list,
14014 /* TC max bandwidth setting */
14016 cmd_vf_tc_max_bw_parsed(
14017 void *parsed_result,
14018 __attribute__((unused)) struct cmdline *cl,
14019 __attribute__((unused)) void *data)
14021 struct cmd_vf_tc_bw_result *res = parsed_result;
14022 int ret = -ENOTSUP;
14024 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14027 #ifdef RTE_LIBRTE_I40E_PMD
14028 ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id,
14029 res->tc_no, res->bw);
14036 printf("invalid vf_id %d, tc_no %d or bandwidth %d\n",
14037 res->vf_id, res->tc_no, res->bw);
14040 printf("invalid port_id %d\n", res->port_id);
14043 printf("function not implemented\n");
14046 printf("programming error: (%s)\n", strerror(-ret));
14050 cmdline_parse_inst_t cmd_vf_tc_max_bw = {
14051 .f = cmd_vf_tc_max_bw_parsed,
14053 .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>"
14056 (void *)&cmd_vf_tc_bw_set,
14057 (void *)&cmd_vf_tc_bw_vf,
14058 (void *)&cmd_vf_tc_bw_tc,
14059 (void *)&cmd_vf_tc_bw_tx,
14060 (void *)&cmd_vf_tc_bw_max_bw,
14061 (void *)&cmd_vf_tc_bw_port_id,
14062 (void *)&cmd_vf_tc_bw_vf_id,
14063 (void *)&cmd_vf_tc_bw_tc_no,
14064 (void *)&cmd_vf_tc_bw_bw,
14070 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
14072 /* *** Set Port default Traffic Management Hierarchy *** */
14073 struct cmd_set_port_tm_hierarchy_default_result {
14074 cmdline_fixed_string_t set;
14075 cmdline_fixed_string_t port;
14076 cmdline_fixed_string_t tm;
14077 cmdline_fixed_string_t hierarchy;
14078 cmdline_fixed_string_t def;
14082 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_set =
14083 TOKEN_STRING_INITIALIZER(
14084 struct cmd_set_port_tm_hierarchy_default_result, set, "set");
14085 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_port =
14086 TOKEN_STRING_INITIALIZER(
14087 struct cmd_set_port_tm_hierarchy_default_result, port, "port");
14088 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_tm =
14089 TOKEN_STRING_INITIALIZER(
14090 struct cmd_set_port_tm_hierarchy_default_result, tm, "tm");
14091 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_hierarchy =
14092 TOKEN_STRING_INITIALIZER(
14093 struct cmd_set_port_tm_hierarchy_default_result,
14094 hierarchy, "hierarchy");
14095 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_default =
14096 TOKEN_STRING_INITIALIZER(
14097 struct cmd_set_port_tm_hierarchy_default_result,
14099 cmdline_parse_token_num_t cmd_set_port_tm_hierarchy_default_port_id =
14100 TOKEN_NUM_INITIALIZER(
14101 struct cmd_set_port_tm_hierarchy_default_result,
14104 static void cmd_set_port_tm_hierarchy_default_parsed(void *parsed_result,
14105 __attribute__((unused)) struct cmdline *cl,
14106 __attribute__((unused)) void *data)
14108 struct cmd_set_port_tm_hierarchy_default_result *res = parsed_result;
14109 struct rte_port *p;
14110 portid_t port_id = res->port_id;
14112 if (port_id_is_invalid(port_id, ENABLED_WARN))
14115 p = &ports[port_id];
14118 if (p->softport.tm_flag == 0) {
14119 printf(" tm not enabled on port %u (error)\n", port_id);
14123 /* Forward mode: tm */
14124 if (strcmp(cur_fwd_config.fwd_eng->fwd_mode_name, "tm")) {
14125 printf(" tm mode not enabled(error)\n");
14129 /* Set the default tm hierarchy */
14130 p->softport.tm.default_hierarchy_enable = 1;
14133 cmdline_parse_inst_t cmd_set_port_tm_hierarchy_default = {
14134 .f = cmd_set_port_tm_hierarchy_default_parsed,
14136 .help_str = "set port tm hierarchy default <port_id>",
14138 (void *)&cmd_set_port_tm_hierarchy_default_set,
14139 (void *)&cmd_set_port_tm_hierarchy_default_port,
14140 (void *)&cmd_set_port_tm_hierarchy_default_tm,
14141 (void *)&cmd_set_port_tm_hierarchy_default_hierarchy,
14142 (void *)&cmd_set_port_tm_hierarchy_default_default,
14143 (void *)&cmd_set_port_tm_hierarchy_default_port_id,
14149 /* Strict link priority scheduling mode setting */
14151 cmd_strict_link_prio_parsed(
14152 void *parsed_result,
14153 __attribute__((unused)) struct cmdline *cl,
14154 __attribute__((unused)) void *data)
14156 struct cmd_vf_tc_bw_result *res = parsed_result;
14157 int ret = -ENOTSUP;
14159 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14162 #ifdef RTE_LIBRTE_I40E_PMD
14163 ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map);
14170 printf("invalid tc_bitmap 0x%x\n", res->tc_map);
14173 printf("invalid port_id %d\n", res->port_id);
14176 printf("function not implemented\n");
14179 printf("programming error: (%s)\n", strerror(-ret));
14183 cmdline_parse_inst_t cmd_strict_link_prio = {
14184 .f = cmd_strict_link_prio_parsed,
14186 .help_str = "set tx strict-link-priority <port_id> <tc_bitmap>",
14188 (void *)&cmd_vf_tc_bw_set,
14189 (void *)&cmd_vf_tc_bw_tx,
14190 (void *)&cmd_vf_tc_bw_strict_link_prio,
14191 (void *)&cmd_vf_tc_bw_port_id,
14192 (void *)&cmd_vf_tc_bw_tc_map,
14197 /* Load dynamic device personalization*/
14198 struct cmd_ddp_add_result {
14199 cmdline_fixed_string_t ddp;
14200 cmdline_fixed_string_t add;
14205 cmdline_parse_token_string_t cmd_ddp_add_ddp =
14206 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp");
14207 cmdline_parse_token_string_t cmd_ddp_add_add =
14208 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add");
14209 cmdline_parse_token_num_t cmd_ddp_add_port_id =
14210 TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id, UINT16);
14211 cmdline_parse_token_string_t cmd_ddp_add_filepath =
14212 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL);
14215 cmd_ddp_add_parsed(
14216 void *parsed_result,
14217 __attribute__((unused)) struct cmdline *cl,
14218 __attribute__((unused)) void *data)
14220 struct cmd_ddp_add_result *res = parsed_result;
14226 int ret = -ENOTSUP;
14228 if (res->port_id > nb_ports) {
14229 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
14233 if (!all_ports_stopped()) {
14234 printf("Please stop all ports first\n");
14238 filepath = strdup(res->filepath);
14239 if (filepath == NULL) {
14240 printf("Failed to allocate memory\n");
14243 file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ',');
14245 buff = open_ddp_package_file(file_fld[0], &size);
14247 free((void *)filepath);
14251 #ifdef RTE_LIBRTE_I40E_PMD
14252 if (ret == -ENOTSUP)
14253 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
14255 RTE_PMD_I40E_PKG_OP_WR_ADD);
14258 if (ret == -EEXIST)
14259 printf("Profile has already existed.\n");
14261 printf("Failed to load profile.\n");
14262 else if (file_num == 2)
14263 save_ddp_package_file(file_fld[1], buff, size);
14265 close_ddp_package_file(buff);
14266 free((void *)filepath);
14269 cmdline_parse_inst_t cmd_ddp_add = {
14270 .f = cmd_ddp_add_parsed,
14272 .help_str = "ddp add <port_id> <profile_path[,output_path]>",
14274 (void *)&cmd_ddp_add_ddp,
14275 (void *)&cmd_ddp_add_add,
14276 (void *)&cmd_ddp_add_port_id,
14277 (void *)&cmd_ddp_add_filepath,
14282 /* Delete dynamic device personalization*/
14283 struct cmd_ddp_del_result {
14284 cmdline_fixed_string_t ddp;
14285 cmdline_fixed_string_t del;
14290 cmdline_parse_token_string_t cmd_ddp_del_ddp =
14291 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp");
14292 cmdline_parse_token_string_t cmd_ddp_del_del =
14293 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del");
14294 cmdline_parse_token_num_t cmd_ddp_del_port_id =
14295 TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, UINT16);
14296 cmdline_parse_token_string_t cmd_ddp_del_filepath =
14297 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL);
14300 cmd_ddp_del_parsed(
14301 void *parsed_result,
14302 __attribute__((unused)) struct cmdline *cl,
14303 __attribute__((unused)) void *data)
14305 struct cmd_ddp_del_result *res = parsed_result;
14308 int ret = -ENOTSUP;
14310 if (res->port_id > nb_ports) {
14311 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
14315 if (!all_ports_stopped()) {
14316 printf("Please stop all ports first\n");
14320 buff = open_ddp_package_file(res->filepath, &size);
14324 #ifdef RTE_LIBRTE_I40E_PMD
14325 if (ret == -ENOTSUP)
14326 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
14328 RTE_PMD_I40E_PKG_OP_WR_DEL);
14331 if (ret == -EACCES)
14332 printf("Profile does not exist.\n");
14334 printf("Failed to delete profile.\n");
14336 close_ddp_package_file(buff);
14339 cmdline_parse_inst_t cmd_ddp_del = {
14340 .f = cmd_ddp_del_parsed,
14342 .help_str = "ddp del <port_id> <profile_path>",
14344 (void *)&cmd_ddp_del_ddp,
14345 (void *)&cmd_ddp_del_del,
14346 (void *)&cmd_ddp_del_port_id,
14347 (void *)&cmd_ddp_del_filepath,
14352 /* Get dynamic device personalization profile info */
14353 struct cmd_ddp_info_result {
14354 cmdline_fixed_string_t ddp;
14355 cmdline_fixed_string_t get;
14356 cmdline_fixed_string_t info;
14360 cmdline_parse_token_string_t cmd_ddp_info_ddp =
14361 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp");
14362 cmdline_parse_token_string_t cmd_ddp_info_get =
14363 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get");
14364 cmdline_parse_token_string_t cmd_ddp_info_info =
14365 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info");
14366 cmdline_parse_token_string_t cmd_ddp_info_filepath =
14367 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL);
14370 cmd_ddp_info_parsed(
14371 void *parsed_result,
14372 __attribute__((unused)) struct cmdline *cl,
14373 __attribute__((unused)) void *data)
14375 struct cmd_ddp_info_result *res = parsed_result;
14378 int ret = -ENOTSUP;
14379 #ifdef RTE_LIBRTE_I40E_PMD
14382 uint32_t buff_size = 0;
14383 struct rte_pmd_i40e_profile_info info;
14384 uint32_t dev_num = 0;
14385 struct rte_pmd_i40e_ddp_device_id *devs;
14386 uint32_t proto_num = 0;
14387 struct rte_pmd_i40e_proto_info *proto = NULL;
14388 uint32_t pctype_num = 0;
14389 struct rte_pmd_i40e_ptype_info *pctype;
14390 uint32_t ptype_num = 0;
14391 struct rte_pmd_i40e_ptype_info *ptype;
14396 pkg = open_ddp_package_file(res->filepath, &pkg_size);
14400 #ifdef RTE_LIBRTE_I40E_PMD
14401 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14402 (uint8_t *)&info, sizeof(info),
14403 RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER);
14405 printf("Global Track id: 0x%x\n", info.track_id);
14406 printf("Global Version: %d.%d.%d.%d\n",
14407 info.version.major,
14408 info.version.minor,
14409 info.version.update,
14410 info.version.draft);
14411 printf("Global Package name: %s\n\n", info.name);
14414 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14415 (uint8_t *)&info, sizeof(info),
14416 RTE_PMD_I40E_PKG_INFO_HEADER);
14418 printf("i40e Profile Track id: 0x%x\n", info.track_id);
14419 printf("i40e Profile Version: %d.%d.%d.%d\n",
14420 info.version.major,
14421 info.version.minor,
14422 info.version.update,
14423 info.version.draft);
14424 printf("i40e Profile name: %s\n\n", info.name);
14427 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14428 (uint8_t *)&buff_size, sizeof(buff_size),
14429 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE);
14430 if (!ret && buff_size) {
14431 buff = (uint8_t *)malloc(buff_size);
14433 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14435 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES);
14437 printf("Package Notes:\n%s\n\n", buff);
14442 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14443 (uint8_t *)&dev_num, sizeof(dev_num),
14444 RTE_PMD_I40E_PKG_INFO_DEVID_NUM);
14445 if (!ret && dev_num) {
14446 buff_size = dev_num * sizeof(struct rte_pmd_i40e_ddp_device_id);
14447 devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(buff_size);
14449 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14450 (uint8_t *)devs, buff_size,
14451 RTE_PMD_I40E_PKG_INFO_DEVID_LIST);
14453 printf("List of supported devices:\n");
14454 for (i = 0; i < dev_num; i++) {
14455 printf(" %04X:%04X %04X:%04X\n",
14456 devs[i].vendor_dev_id >> 16,
14457 devs[i].vendor_dev_id & 0xFFFF,
14458 devs[i].sub_vendor_dev_id >> 16,
14459 devs[i].sub_vendor_dev_id & 0xFFFF);
14467 /* get information about protocols and packet types */
14468 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14469 (uint8_t *)&proto_num, sizeof(proto_num),
14470 RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM);
14471 if (ret || !proto_num)
14472 goto no_print_return;
14474 buff_size = proto_num * sizeof(struct rte_pmd_i40e_proto_info);
14475 proto = (struct rte_pmd_i40e_proto_info *)malloc(buff_size);
14477 goto no_print_return;
14479 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)proto,
14481 RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST);
14483 printf("List of used protocols:\n");
14484 for (i = 0; i < proto_num; i++)
14485 printf(" %2u: %s\n", proto[i].proto_id,
14489 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14490 (uint8_t *)&pctype_num, sizeof(pctype_num),
14491 RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM);
14492 if (ret || !pctype_num)
14493 goto no_print_pctypes;
14495 buff_size = pctype_num * sizeof(struct rte_pmd_i40e_ptype_info);
14496 pctype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
14498 goto no_print_pctypes;
14500 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)pctype,
14502 RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST);
14505 goto no_print_pctypes;
14508 printf("List of defined packet classification types:\n");
14509 for (i = 0; i < pctype_num; i++) {
14510 printf(" %2u:", pctype[i].ptype_id);
14511 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
14512 proto_id = pctype[i].protocols[j];
14513 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
14514 for (n = 0; n < proto_num; n++) {
14515 if (proto[n].proto_id == proto_id) {
14516 printf(" %s", proto[n].name);
14529 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)&ptype_num,
14531 RTE_PMD_I40E_PKG_INFO_PTYPE_NUM);
14532 if (ret || !ptype_num)
14533 goto no_print_return;
14535 buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_info);
14536 ptype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
14538 goto no_print_return;
14540 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)ptype,
14542 RTE_PMD_I40E_PKG_INFO_PTYPE_LIST);
14545 goto no_print_return;
14547 printf("List of defined packet types:\n");
14548 for (i = 0; i < ptype_num; i++) {
14549 printf(" %2u:", ptype[i].ptype_id);
14550 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
14551 proto_id = ptype[i].protocols[j];
14552 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
14553 for (n = 0; n < proto_num; n++) {
14554 if (proto[n].proto_id == proto_id) {
14555 printf(" %s", proto[n].name);
14571 if (ret == -ENOTSUP)
14572 printf("Function not supported in PMD driver\n");
14573 close_ddp_package_file(pkg);
14576 cmdline_parse_inst_t cmd_ddp_get_info = {
14577 .f = cmd_ddp_info_parsed,
14579 .help_str = "ddp get info <profile_path>",
14581 (void *)&cmd_ddp_info_ddp,
14582 (void *)&cmd_ddp_info_get,
14583 (void *)&cmd_ddp_info_info,
14584 (void *)&cmd_ddp_info_filepath,
14589 /* Get dynamic device personalization profile info list*/
14590 #define PROFILE_INFO_SIZE 48
14591 #define MAX_PROFILE_NUM 16
14593 struct cmd_ddp_get_list_result {
14594 cmdline_fixed_string_t ddp;
14595 cmdline_fixed_string_t get;
14596 cmdline_fixed_string_t list;
14600 cmdline_parse_token_string_t cmd_ddp_get_list_ddp =
14601 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp");
14602 cmdline_parse_token_string_t cmd_ddp_get_list_get =
14603 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get");
14604 cmdline_parse_token_string_t cmd_ddp_get_list_list =
14605 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list");
14606 cmdline_parse_token_num_t cmd_ddp_get_list_port_id =
14607 TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id, UINT16);
14610 cmd_ddp_get_list_parsed(
14611 void *parsed_result,
14612 __attribute__((unused)) struct cmdline *cl,
14613 __attribute__((unused)) void *data)
14615 struct cmd_ddp_get_list_result *res = parsed_result;
14616 #ifdef RTE_LIBRTE_I40E_PMD
14617 struct rte_pmd_i40e_profile_list *p_list;
14618 struct rte_pmd_i40e_profile_info *p_info;
14623 int ret = -ENOTSUP;
14625 if (res->port_id > nb_ports) {
14626 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
14630 #ifdef RTE_LIBRTE_I40E_PMD
14631 size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4;
14632 p_list = (struct rte_pmd_i40e_profile_list *)malloc(size);
14634 printf("%s: Failed to malloc buffer\n", __func__);
14636 if (ret == -ENOTSUP)
14637 ret = rte_pmd_i40e_get_ddp_list(res->port_id,
14638 (uint8_t *)p_list, size);
14641 p_num = p_list->p_count;
14642 printf("Profile number is: %d\n\n", p_num);
14644 for (i = 0; i < p_num; i++) {
14645 p_info = &p_list->p_info[i];
14646 printf("Profile %d:\n", i);
14647 printf("Track id: 0x%x\n", p_info->track_id);
14648 printf("Version: %d.%d.%d.%d\n",
14649 p_info->version.major,
14650 p_info->version.minor,
14651 p_info->version.update,
14652 p_info->version.draft);
14653 printf("Profile name: %s\n\n", p_info->name);
14661 printf("Failed to get ddp list\n");
14664 cmdline_parse_inst_t cmd_ddp_get_list = {
14665 .f = cmd_ddp_get_list_parsed,
14667 .help_str = "ddp get list <port_id>",
14669 (void *)&cmd_ddp_get_list_ddp,
14670 (void *)&cmd_ddp_get_list_get,
14671 (void *)&cmd_ddp_get_list_list,
14672 (void *)&cmd_ddp_get_list_port_id,
14677 /* show vf stats */
14679 /* Common result structure for show vf stats */
14680 struct cmd_show_vf_stats_result {
14681 cmdline_fixed_string_t show;
14682 cmdline_fixed_string_t vf;
14683 cmdline_fixed_string_t stats;
14688 /* Common CLI fields show vf stats*/
14689 cmdline_parse_token_string_t cmd_show_vf_stats_show =
14690 TOKEN_STRING_INITIALIZER
14691 (struct cmd_show_vf_stats_result,
14693 cmdline_parse_token_string_t cmd_show_vf_stats_vf =
14694 TOKEN_STRING_INITIALIZER
14695 (struct cmd_show_vf_stats_result,
14697 cmdline_parse_token_string_t cmd_show_vf_stats_stats =
14698 TOKEN_STRING_INITIALIZER
14699 (struct cmd_show_vf_stats_result,
14701 cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
14702 TOKEN_NUM_INITIALIZER
14703 (struct cmd_show_vf_stats_result,
14705 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
14706 TOKEN_NUM_INITIALIZER
14707 (struct cmd_show_vf_stats_result,
14711 cmd_show_vf_stats_parsed(
14712 void *parsed_result,
14713 __attribute__((unused)) struct cmdline *cl,
14714 __attribute__((unused)) void *data)
14716 struct cmd_show_vf_stats_result *res = parsed_result;
14717 struct rte_eth_stats stats;
14718 int ret = -ENOTSUP;
14719 static const char *nic_stats_border = "########################";
14721 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14724 memset(&stats, 0, sizeof(stats));
14726 #ifdef RTE_LIBRTE_I40E_PMD
14727 if (ret == -ENOTSUP)
14728 ret = rte_pmd_i40e_get_vf_stats(res->port_id,
14732 #ifdef RTE_LIBRTE_BNXT_PMD
14733 if (ret == -ENOTSUP)
14734 ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
14743 printf("invalid vf_id %d\n", res->vf_id);
14746 printf("invalid port_id %d\n", res->port_id);
14749 printf("function not implemented\n");
14752 printf("programming error: (%s)\n", strerror(-ret));
14755 printf("\n %s NIC statistics for port %-2d vf %-2d %s\n",
14756 nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
14758 printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: "
14760 stats.ipackets, stats.imissed, stats.ibytes);
14761 printf(" RX-errors: %-"PRIu64"\n", stats.ierrors);
14762 printf(" RX-nombuf: %-10"PRIu64"\n",
14764 printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: "
14766 stats.opackets, stats.oerrors, stats.obytes);
14768 printf(" %s############################%s\n",
14769 nic_stats_border, nic_stats_border);
14772 cmdline_parse_inst_t cmd_show_vf_stats = {
14773 .f = cmd_show_vf_stats_parsed,
14775 .help_str = "show vf stats <port_id> <vf_id>",
14777 (void *)&cmd_show_vf_stats_show,
14778 (void *)&cmd_show_vf_stats_vf,
14779 (void *)&cmd_show_vf_stats_stats,
14780 (void *)&cmd_show_vf_stats_port_id,
14781 (void *)&cmd_show_vf_stats_vf_id,
14786 /* clear vf stats */
14788 /* Common result structure for clear vf stats */
14789 struct cmd_clear_vf_stats_result {
14790 cmdline_fixed_string_t clear;
14791 cmdline_fixed_string_t vf;
14792 cmdline_fixed_string_t stats;
14797 /* Common CLI fields clear vf stats*/
14798 cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
14799 TOKEN_STRING_INITIALIZER
14800 (struct cmd_clear_vf_stats_result,
14802 cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
14803 TOKEN_STRING_INITIALIZER
14804 (struct cmd_clear_vf_stats_result,
14806 cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
14807 TOKEN_STRING_INITIALIZER
14808 (struct cmd_clear_vf_stats_result,
14810 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
14811 TOKEN_NUM_INITIALIZER
14812 (struct cmd_clear_vf_stats_result,
14814 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
14815 TOKEN_NUM_INITIALIZER
14816 (struct cmd_clear_vf_stats_result,
14820 cmd_clear_vf_stats_parsed(
14821 void *parsed_result,
14822 __attribute__((unused)) struct cmdline *cl,
14823 __attribute__((unused)) void *data)
14825 struct cmd_clear_vf_stats_result *res = parsed_result;
14826 int ret = -ENOTSUP;
14828 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14831 #ifdef RTE_LIBRTE_I40E_PMD
14832 if (ret == -ENOTSUP)
14833 ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
14836 #ifdef RTE_LIBRTE_BNXT_PMD
14837 if (ret == -ENOTSUP)
14838 ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
14846 printf("invalid vf_id %d\n", res->vf_id);
14849 printf("invalid port_id %d\n", res->port_id);
14852 printf("function not implemented\n");
14855 printf("programming error: (%s)\n", strerror(-ret));
14859 cmdline_parse_inst_t cmd_clear_vf_stats = {
14860 .f = cmd_clear_vf_stats_parsed,
14862 .help_str = "clear vf stats <port_id> <vf_id>",
14864 (void *)&cmd_clear_vf_stats_clear,
14865 (void *)&cmd_clear_vf_stats_vf,
14866 (void *)&cmd_clear_vf_stats_stats,
14867 (void *)&cmd_clear_vf_stats_port_id,
14868 (void *)&cmd_clear_vf_stats_vf_id,
14873 /* port config pctype mapping reset */
14875 /* Common result structure for port config pctype mapping reset */
14876 struct cmd_pctype_mapping_reset_result {
14877 cmdline_fixed_string_t port;
14878 cmdline_fixed_string_t config;
14880 cmdline_fixed_string_t pctype;
14881 cmdline_fixed_string_t mapping;
14882 cmdline_fixed_string_t reset;
14885 /* Common CLI fields for port config pctype mapping reset*/
14886 cmdline_parse_token_string_t cmd_pctype_mapping_reset_port =
14887 TOKEN_STRING_INITIALIZER
14888 (struct cmd_pctype_mapping_reset_result,
14890 cmdline_parse_token_string_t cmd_pctype_mapping_reset_config =
14891 TOKEN_STRING_INITIALIZER
14892 (struct cmd_pctype_mapping_reset_result,
14894 cmdline_parse_token_num_t cmd_pctype_mapping_reset_port_id =
14895 TOKEN_NUM_INITIALIZER
14896 (struct cmd_pctype_mapping_reset_result,
14898 cmdline_parse_token_string_t cmd_pctype_mapping_reset_pctype =
14899 TOKEN_STRING_INITIALIZER
14900 (struct cmd_pctype_mapping_reset_result,
14902 cmdline_parse_token_string_t cmd_pctype_mapping_reset_mapping =
14903 TOKEN_STRING_INITIALIZER
14904 (struct cmd_pctype_mapping_reset_result,
14905 mapping, "mapping");
14906 cmdline_parse_token_string_t cmd_pctype_mapping_reset_reset =
14907 TOKEN_STRING_INITIALIZER
14908 (struct cmd_pctype_mapping_reset_result,
14912 cmd_pctype_mapping_reset_parsed(
14913 void *parsed_result,
14914 __attribute__((unused)) struct cmdline *cl,
14915 __attribute__((unused)) void *data)
14917 struct cmd_pctype_mapping_reset_result *res = parsed_result;
14918 int ret = -ENOTSUP;
14920 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14923 #ifdef RTE_LIBRTE_I40E_PMD
14924 ret = rte_pmd_i40e_flow_type_mapping_reset(res->port_id);
14931 printf("invalid port_id %d\n", res->port_id);
14934 printf("function not implemented\n");
14937 printf("programming error: (%s)\n", strerror(-ret));
14941 cmdline_parse_inst_t cmd_pctype_mapping_reset = {
14942 .f = cmd_pctype_mapping_reset_parsed,
14944 .help_str = "port config <port_id> pctype mapping reset",
14946 (void *)&cmd_pctype_mapping_reset_port,
14947 (void *)&cmd_pctype_mapping_reset_config,
14948 (void *)&cmd_pctype_mapping_reset_port_id,
14949 (void *)&cmd_pctype_mapping_reset_pctype,
14950 (void *)&cmd_pctype_mapping_reset_mapping,
14951 (void *)&cmd_pctype_mapping_reset_reset,
14956 /* show port pctype mapping */
14958 /* Common result structure for show port pctype mapping */
14959 struct cmd_pctype_mapping_get_result {
14960 cmdline_fixed_string_t show;
14961 cmdline_fixed_string_t port;
14963 cmdline_fixed_string_t pctype;
14964 cmdline_fixed_string_t mapping;
14967 /* Common CLI fields for pctype mapping get */
14968 cmdline_parse_token_string_t cmd_pctype_mapping_get_show =
14969 TOKEN_STRING_INITIALIZER
14970 (struct cmd_pctype_mapping_get_result,
14972 cmdline_parse_token_string_t cmd_pctype_mapping_get_port =
14973 TOKEN_STRING_INITIALIZER
14974 (struct cmd_pctype_mapping_get_result,
14976 cmdline_parse_token_num_t cmd_pctype_mapping_get_port_id =
14977 TOKEN_NUM_INITIALIZER
14978 (struct cmd_pctype_mapping_get_result,
14980 cmdline_parse_token_string_t cmd_pctype_mapping_get_pctype =
14981 TOKEN_STRING_INITIALIZER
14982 (struct cmd_pctype_mapping_get_result,
14984 cmdline_parse_token_string_t cmd_pctype_mapping_get_mapping =
14985 TOKEN_STRING_INITIALIZER
14986 (struct cmd_pctype_mapping_get_result,
14987 mapping, "mapping");
14990 cmd_pctype_mapping_get_parsed(
14991 void *parsed_result,
14992 __attribute__((unused)) struct cmdline *cl,
14993 __attribute__((unused)) void *data)
14995 struct cmd_pctype_mapping_get_result *res = parsed_result;
14996 int ret = -ENOTSUP;
14997 #ifdef RTE_LIBRTE_I40E_PMD
14998 struct rte_pmd_i40e_flow_type_mapping
14999 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
15000 int i, j, first_pctype;
15003 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15006 #ifdef RTE_LIBRTE_I40E_PMD
15007 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, mapping);
15014 printf("invalid port_id %d\n", res->port_id);
15017 printf("function not implemented\n");
15020 printf("programming error: (%s)\n", strerror(-ret));
15024 #ifdef RTE_LIBRTE_I40E_PMD
15025 for (i = 0; i < RTE_PMD_I40E_FLOW_TYPE_MAX; i++) {
15026 if (mapping[i].pctype != 0ULL) {
15029 printf("pctype: ");
15030 for (j = 0; j < RTE_PMD_I40E_PCTYPE_MAX; j++) {
15031 if (mapping[i].pctype & (1ULL << j)) {
15032 printf(first_pctype ?
15033 "%02d" : ",%02d", j);
15037 printf(" -> flowtype: %02d\n", mapping[i].flow_type);
15043 cmdline_parse_inst_t cmd_pctype_mapping_get = {
15044 .f = cmd_pctype_mapping_get_parsed,
15046 .help_str = "show port <port_id> pctype mapping",
15048 (void *)&cmd_pctype_mapping_get_show,
15049 (void *)&cmd_pctype_mapping_get_port,
15050 (void *)&cmd_pctype_mapping_get_port_id,
15051 (void *)&cmd_pctype_mapping_get_pctype,
15052 (void *)&cmd_pctype_mapping_get_mapping,
15057 /* port config pctype mapping update */
15059 /* Common result structure for port config pctype mapping update */
15060 struct cmd_pctype_mapping_update_result {
15061 cmdline_fixed_string_t port;
15062 cmdline_fixed_string_t config;
15064 cmdline_fixed_string_t pctype;
15065 cmdline_fixed_string_t mapping;
15066 cmdline_fixed_string_t update;
15067 cmdline_fixed_string_t pctype_list;
15068 uint16_t flow_type;
15071 /* Common CLI fields for pctype mapping update*/
15072 cmdline_parse_token_string_t cmd_pctype_mapping_update_port =
15073 TOKEN_STRING_INITIALIZER
15074 (struct cmd_pctype_mapping_update_result,
15076 cmdline_parse_token_string_t cmd_pctype_mapping_update_config =
15077 TOKEN_STRING_INITIALIZER
15078 (struct cmd_pctype_mapping_update_result,
15080 cmdline_parse_token_num_t cmd_pctype_mapping_update_port_id =
15081 TOKEN_NUM_INITIALIZER
15082 (struct cmd_pctype_mapping_update_result,
15084 cmdline_parse_token_string_t cmd_pctype_mapping_update_pctype =
15085 TOKEN_STRING_INITIALIZER
15086 (struct cmd_pctype_mapping_update_result,
15088 cmdline_parse_token_string_t cmd_pctype_mapping_update_mapping =
15089 TOKEN_STRING_INITIALIZER
15090 (struct cmd_pctype_mapping_update_result,
15091 mapping, "mapping");
15092 cmdline_parse_token_string_t cmd_pctype_mapping_update_update =
15093 TOKEN_STRING_INITIALIZER
15094 (struct cmd_pctype_mapping_update_result,
15096 cmdline_parse_token_string_t cmd_pctype_mapping_update_pc_type =
15097 TOKEN_STRING_INITIALIZER
15098 (struct cmd_pctype_mapping_update_result,
15099 pctype_list, NULL);
15100 cmdline_parse_token_num_t cmd_pctype_mapping_update_flow_type =
15101 TOKEN_NUM_INITIALIZER
15102 (struct cmd_pctype_mapping_update_result,
15103 flow_type, UINT16);
15106 cmd_pctype_mapping_update_parsed(
15107 void *parsed_result,
15108 __attribute__((unused)) struct cmdline *cl,
15109 __attribute__((unused)) void *data)
15111 struct cmd_pctype_mapping_update_result *res = parsed_result;
15112 int ret = -ENOTSUP;
15113 #ifdef RTE_LIBRTE_I40E_PMD
15114 struct rte_pmd_i40e_flow_type_mapping mapping;
15116 unsigned int nb_item;
15117 unsigned int pctype_list[RTE_PMD_I40E_PCTYPE_MAX];
15120 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15123 #ifdef RTE_LIBRTE_I40E_PMD
15124 nb_item = parse_item_list(res->pctype_list, "pctypes",
15125 RTE_PMD_I40E_PCTYPE_MAX, pctype_list, 1);
15126 mapping.flow_type = res->flow_type;
15127 for (i = 0, mapping.pctype = 0ULL; i < nb_item; i++)
15128 mapping.pctype |= (1ULL << pctype_list[i]);
15129 ret = rte_pmd_i40e_flow_type_mapping_update(res->port_id,
15139 printf("invalid pctype or flow type\n");
15142 printf("invalid port_id %d\n", res->port_id);
15145 printf("function not implemented\n");
15148 printf("programming error: (%s)\n", strerror(-ret));
15152 cmdline_parse_inst_t cmd_pctype_mapping_update = {
15153 .f = cmd_pctype_mapping_update_parsed,
15155 .help_str = "port config <port_id> pctype mapping update"
15156 " <pctype_id_0,[pctype_id_1]*> <flowtype_id>",
15158 (void *)&cmd_pctype_mapping_update_port,
15159 (void *)&cmd_pctype_mapping_update_config,
15160 (void *)&cmd_pctype_mapping_update_port_id,
15161 (void *)&cmd_pctype_mapping_update_pctype,
15162 (void *)&cmd_pctype_mapping_update_mapping,
15163 (void *)&cmd_pctype_mapping_update_update,
15164 (void *)&cmd_pctype_mapping_update_pc_type,
15165 (void *)&cmd_pctype_mapping_update_flow_type,
15170 /* ptype mapping get */
15172 /* Common result structure for ptype mapping get */
15173 struct cmd_ptype_mapping_get_result {
15174 cmdline_fixed_string_t ptype;
15175 cmdline_fixed_string_t mapping;
15176 cmdline_fixed_string_t get;
15178 uint8_t valid_only;
15181 /* Common CLI fields for ptype mapping get */
15182 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype =
15183 TOKEN_STRING_INITIALIZER
15184 (struct cmd_ptype_mapping_get_result,
15186 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping =
15187 TOKEN_STRING_INITIALIZER
15188 (struct cmd_ptype_mapping_get_result,
15189 mapping, "mapping");
15190 cmdline_parse_token_string_t cmd_ptype_mapping_get_get =
15191 TOKEN_STRING_INITIALIZER
15192 (struct cmd_ptype_mapping_get_result,
15194 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id =
15195 TOKEN_NUM_INITIALIZER
15196 (struct cmd_ptype_mapping_get_result,
15198 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only =
15199 TOKEN_NUM_INITIALIZER
15200 (struct cmd_ptype_mapping_get_result,
15201 valid_only, UINT8);
15204 cmd_ptype_mapping_get_parsed(
15205 void *parsed_result,
15206 __attribute__((unused)) struct cmdline *cl,
15207 __attribute__((unused)) void *data)
15209 struct cmd_ptype_mapping_get_result *res = parsed_result;
15210 int ret = -ENOTSUP;
15211 #ifdef RTE_LIBRTE_I40E_PMD
15212 int max_ptype_num = 256;
15213 struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num];
15218 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15221 #ifdef RTE_LIBRTE_I40E_PMD
15222 ret = rte_pmd_i40e_ptype_mapping_get(res->port_id,
15233 printf("invalid port_id %d\n", res->port_id);
15236 printf("function not implemented\n");
15239 printf("programming error: (%s)\n", strerror(-ret));
15242 #ifdef RTE_LIBRTE_I40E_PMD
15244 for (i = 0; i < count; i++)
15245 printf("%3d\t0x%08x\n",
15246 mapping[i].hw_ptype, mapping[i].sw_ptype);
15251 cmdline_parse_inst_t cmd_ptype_mapping_get = {
15252 .f = cmd_ptype_mapping_get_parsed,
15254 .help_str = "ptype mapping get <port_id> <valid_only>",
15256 (void *)&cmd_ptype_mapping_get_ptype,
15257 (void *)&cmd_ptype_mapping_get_mapping,
15258 (void *)&cmd_ptype_mapping_get_get,
15259 (void *)&cmd_ptype_mapping_get_port_id,
15260 (void *)&cmd_ptype_mapping_get_valid_only,
15265 /* ptype mapping replace */
15267 /* Common result structure for ptype mapping replace */
15268 struct cmd_ptype_mapping_replace_result {
15269 cmdline_fixed_string_t ptype;
15270 cmdline_fixed_string_t mapping;
15271 cmdline_fixed_string_t replace;
15278 /* Common CLI fields for ptype mapping replace */
15279 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype =
15280 TOKEN_STRING_INITIALIZER
15281 (struct cmd_ptype_mapping_replace_result,
15283 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping =
15284 TOKEN_STRING_INITIALIZER
15285 (struct cmd_ptype_mapping_replace_result,
15286 mapping, "mapping");
15287 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace =
15288 TOKEN_STRING_INITIALIZER
15289 (struct cmd_ptype_mapping_replace_result,
15290 replace, "replace");
15291 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id =
15292 TOKEN_NUM_INITIALIZER
15293 (struct cmd_ptype_mapping_replace_result,
15295 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target =
15296 TOKEN_NUM_INITIALIZER
15297 (struct cmd_ptype_mapping_replace_result,
15299 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask =
15300 TOKEN_NUM_INITIALIZER
15301 (struct cmd_ptype_mapping_replace_result,
15303 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type =
15304 TOKEN_NUM_INITIALIZER
15305 (struct cmd_ptype_mapping_replace_result,
15309 cmd_ptype_mapping_replace_parsed(
15310 void *parsed_result,
15311 __attribute__((unused)) struct cmdline *cl,
15312 __attribute__((unused)) void *data)
15314 struct cmd_ptype_mapping_replace_result *res = parsed_result;
15315 int ret = -ENOTSUP;
15317 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15320 #ifdef RTE_LIBRTE_I40E_PMD
15321 ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id,
15331 printf("invalid ptype 0x%8x or 0x%8x\n",
15332 res->target, res->pkt_type);
15335 printf("invalid port_id %d\n", res->port_id);
15338 printf("function not implemented\n");
15341 printf("programming error: (%s)\n", strerror(-ret));
15345 cmdline_parse_inst_t cmd_ptype_mapping_replace = {
15346 .f = cmd_ptype_mapping_replace_parsed,
15349 "ptype mapping replace <port_id> <target> <mask> <pkt_type>",
15351 (void *)&cmd_ptype_mapping_replace_ptype,
15352 (void *)&cmd_ptype_mapping_replace_mapping,
15353 (void *)&cmd_ptype_mapping_replace_replace,
15354 (void *)&cmd_ptype_mapping_replace_port_id,
15355 (void *)&cmd_ptype_mapping_replace_target,
15356 (void *)&cmd_ptype_mapping_replace_mask,
15357 (void *)&cmd_ptype_mapping_replace_pkt_type,
15362 /* ptype mapping reset */
15364 /* Common result structure for ptype mapping reset */
15365 struct cmd_ptype_mapping_reset_result {
15366 cmdline_fixed_string_t ptype;
15367 cmdline_fixed_string_t mapping;
15368 cmdline_fixed_string_t reset;
15372 /* Common CLI fields for ptype mapping reset*/
15373 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype =
15374 TOKEN_STRING_INITIALIZER
15375 (struct cmd_ptype_mapping_reset_result,
15377 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping =
15378 TOKEN_STRING_INITIALIZER
15379 (struct cmd_ptype_mapping_reset_result,
15380 mapping, "mapping");
15381 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset =
15382 TOKEN_STRING_INITIALIZER
15383 (struct cmd_ptype_mapping_reset_result,
15385 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id =
15386 TOKEN_NUM_INITIALIZER
15387 (struct cmd_ptype_mapping_reset_result,
15391 cmd_ptype_mapping_reset_parsed(
15392 void *parsed_result,
15393 __attribute__((unused)) struct cmdline *cl,
15394 __attribute__((unused)) void *data)
15396 struct cmd_ptype_mapping_reset_result *res = parsed_result;
15397 int ret = -ENOTSUP;
15399 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15402 #ifdef RTE_LIBRTE_I40E_PMD
15403 ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id);
15410 printf("invalid port_id %d\n", res->port_id);
15413 printf("function not implemented\n");
15416 printf("programming error: (%s)\n", strerror(-ret));
15420 cmdline_parse_inst_t cmd_ptype_mapping_reset = {
15421 .f = cmd_ptype_mapping_reset_parsed,
15423 .help_str = "ptype mapping reset <port_id>",
15425 (void *)&cmd_ptype_mapping_reset_ptype,
15426 (void *)&cmd_ptype_mapping_reset_mapping,
15427 (void *)&cmd_ptype_mapping_reset_reset,
15428 (void *)&cmd_ptype_mapping_reset_port_id,
15433 /* ptype mapping update */
15435 /* Common result structure for ptype mapping update */
15436 struct cmd_ptype_mapping_update_result {
15437 cmdline_fixed_string_t ptype;
15438 cmdline_fixed_string_t mapping;
15439 cmdline_fixed_string_t reset;
15445 /* Common CLI fields for ptype mapping update*/
15446 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype =
15447 TOKEN_STRING_INITIALIZER
15448 (struct cmd_ptype_mapping_update_result,
15450 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping =
15451 TOKEN_STRING_INITIALIZER
15452 (struct cmd_ptype_mapping_update_result,
15453 mapping, "mapping");
15454 cmdline_parse_token_string_t cmd_ptype_mapping_update_update =
15455 TOKEN_STRING_INITIALIZER
15456 (struct cmd_ptype_mapping_update_result,
15458 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id =
15459 TOKEN_NUM_INITIALIZER
15460 (struct cmd_ptype_mapping_update_result,
15462 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype =
15463 TOKEN_NUM_INITIALIZER
15464 (struct cmd_ptype_mapping_update_result,
15466 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype =
15467 TOKEN_NUM_INITIALIZER
15468 (struct cmd_ptype_mapping_update_result,
15472 cmd_ptype_mapping_update_parsed(
15473 void *parsed_result,
15474 __attribute__((unused)) struct cmdline *cl,
15475 __attribute__((unused)) void *data)
15477 struct cmd_ptype_mapping_update_result *res = parsed_result;
15478 int ret = -ENOTSUP;
15479 #ifdef RTE_LIBRTE_I40E_PMD
15480 struct rte_pmd_i40e_ptype_mapping mapping;
15482 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15485 #ifdef RTE_LIBRTE_I40E_PMD
15486 mapping.hw_ptype = res->hw_ptype;
15487 mapping.sw_ptype = res->sw_ptype;
15488 ret = rte_pmd_i40e_ptype_mapping_update(res->port_id,
15498 printf("invalid ptype 0x%8x\n", res->sw_ptype);
15501 printf("invalid port_id %d\n", res->port_id);
15504 printf("function not implemented\n");
15507 printf("programming error: (%s)\n", strerror(-ret));
15511 cmdline_parse_inst_t cmd_ptype_mapping_update = {
15512 .f = cmd_ptype_mapping_update_parsed,
15514 .help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>",
15516 (void *)&cmd_ptype_mapping_update_ptype,
15517 (void *)&cmd_ptype_mapping_update_mapping,
15518 (void *)&cmd_ptype_mapping_update_update,
15519 (void *)&cmd_ptype_mapping_update_port_id,
15520 (void *)&cmd_ptype_mapping_update_hw_ptype,
15521 (void *)&cmd_ptype_mapping_update_sw_ptype,
15526 /* Common result structure for file commands */
15527 struct cmd_cmdfile_result {
15528 cmdline_fixed_string_t load;
15529 cmdline_fixed_string_t filename;
15532 /* Common CLI fields for file commands */
15533 cmdline_parse_token_string_t cmd_load_cmdfile =
15534 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
15535 cmdline_parse_token_string_t cmd_load_cmdfile_filename =
15536 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
15539 cmd_load_from_file_parsed(
15540 void *parsed_result,
15541 __attribute__((unused)) struct cmdline *cl,
15542 __attribute__((unused)) void *data)
15544 struct cmd_cmdfile_result *res = parsed_result;
15546 cmdline_read_from_file(res->filename);
15549 cmdline_parse_inst_t cmd_load_from_file = {
15550 .f = cmd_load_from_file_parsed,
15552 .help_str = "load <filename>",
15554 (void *)&cmd_load_cmdfile,
15555 (void *)&cmd_load_cmdfile_filename,
15560 /* ******************************************************************************** */
15562 /* list of instructions */
15563 cmdline_parse_ctx_t main_ctx[] = {
15564 (cmdline_parse_inst_t *)&cmd_help_brief,
15565 (cmdline_parse_inst_t *)&cmd_help_long,
15566 (cmdline_parse_inst_t *)&cmd_quit,
15567 (cmdline_parse_inst_t *)&cmd_load_from_file,
15568 (cmdline_parse_inst_t *)&cmd_showport,
15569 (cmdline_parse_inst_t *)&cmd_showqueue,
15570 (cmdline_parse_inst_t *)&cmd_showportall,
15571 (cmdline_parse_inst_t *)&cmd_showcfg,
15572 (cmdline_parse_inst_t *)&cmd_start,
15573 (cmdline_parse_inst_t *)&cmd_start_tx_first,
15574 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
15575 (cmdline_parse_inst_t *)&cmd_set_link_up,
15576 (cmdline_parse_inst_t *)&cmd_set_link_down,
15577 (cmdline_parse_inst_t *)&cmd_reset,
15578 (cmdline_parse_inst_t *)&cmd_set_numbers,
15579 (cmdline_parse_inst_t *)&cmd_set_txpkts,
15580 (cmdline_parse_inst_t *)&cmd_set_txsplit,
15581 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
15582 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
15583 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
15584 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
15585 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
15586 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
15587 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
15588 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
15589 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
15590 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
15591 (cmdline_parse_inst_t *)&cmd_set_link_check,
15592 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
15593 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
15594 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
15595 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
15596 #ifdef RTE_LIBRTE_PMD_BOND
15597 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
15598 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
15599 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
15600 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
15601 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
15602 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
15603 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
15604 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
15605 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
15606 (cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues,
15607 (cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy,
15609 (cmdline_parse_inst_t *)&cmd_vlan_offload,
15610 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
15611 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
15612 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
15613 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
15614 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
15615 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
15616 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
15617 (cmdline_parse_inst_t *)&cmd_csum_set,
15618 (cmdline_parse_inst_t *)&cmd_csum_show,
15619 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
15620 (cmdline_parse_inst_t *)&cmd_tso_set,
15621 (cmdline_parse_inst_t *)&cmd_tso_show,
15622 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
15623 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
15624 (cmdline_parse_inst_t *)&cmd_gro_enable,
15625 (cmdline_parse_inst_t *)&cmd_gro_flush,
15626 (cmdline_parse_inst_t *)&cmd_gro_show,
15627 (cmdline_parse_inst_t *)&cmd_gso_enable,
15628 (cmdline_parse_inst_t *)&cmd_gso_size,
15629 (cmdline_parse_inst_t *)&cmd_gso_show,
15630 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
15631 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
15632 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
15633 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
15634 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
15635 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
15636 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
15637 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
15638 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
15639 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
15640 (cmdline_parse_inst_t *)&cmd_config_dcb,
15641 (cmdline_parse_inst_t *)&cmd_read_reg,
15642 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
15643 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
15644 (cmdline_parse_inst_t *)&cmd_write_reg,
15645 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
15646 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
15647 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
15648 (cmdline_parse_inst_t *)&cmd_stop,
15649 (cmdline_parse_inst_t *)&cmd_mac_addr,
15650 (cmdline_parse_inst_t *)&cmd_set_qmap,
15651 (cmdline_parse_inst_t *)&cmd_set_xstats_hide_zero,
15652 (cmdline_parse_inst_t *)&cmd_operate_port,
15653 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
15654 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
15655 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
15656 (cmdline_parse_inst_t *)&cmd_config_speed_all,
15657 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
15658 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
15659 (cmdline_parse_inst_t *)&cmd_config_mtu,
15660 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
15661 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
15662 (cmdline_parse_inst_t *)&cmd_config_rss,
15663 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
15664 (cmdline_parse_inst_t *)&cmd_config_txqflags,
15665 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
15666 (cmdline_parse_inst_t *)&cmd_showport_reta,
15667 (cmdline_parse_inst_t *)&cmd_config_burst,
15668 (cmdline_parse_inst_t *)&cmd_config_thresh,
15669 (cmdline_parse_inst_t *)&cmd_config_threshold,
15670 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
15671 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
15672 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
15673 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
15674 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
15675 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
15676 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
15677 (cmdline_parse_inst_t *)&cmd_global_config,
15678 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
15679 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
15680 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
15681 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
15682 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
15683 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
15684 (cmdline_parse_inst_t *)&cmd_dump,
15685 (cmdline_parse_inst_t *)&cmd_dump_one,
15686 (cmdline_parse_inst_t *)&cmd_ethertype_filter,
15687 (cmdline_parse_inst_t *)&cmd_syn_filter,
15688 (cmdline_parse_inst_t *)&cmd_2tuple_filter,
15689 (cmdline_parse_inst_t *)&cmd_5tuple_filter,
15690 (cmdline_parse_inst_t *)&cmd_flex_filter,
15691 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
15692 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
15693 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
15694 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director,
15695 (cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director,
15696 (cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director,
15697 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
15698 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
15699 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
15700 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
15701 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
15702 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
15703 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
15704 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
15705 (cmdline_parse_inst_t *)&cmd_get_hash_global_config,
15706 (cmdline_parse_inst_t *)&cmd_set_hash_global_config,
15707 (cmdline_parse_inst_t *)&cmd_set_hash_input_set,
15708 (cmdline_parse_inst_t *)&cmd_set_fdir_input_set,
15709 (cmdline_parse_inst_t *)&cmd_flow,
15710 (cmdline_parse_inst_t *)&cmd_show_port_meter_cap,
15711 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm,
15712 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm,
15713 (cmdline_parse_inst_t *)&cmd_del_port_meter_profile,
15714 (cmdline_parse_inst_t *)&cmd_create_port_meter,
15715 (cmdline_parse_inst_t *)&cmd_enable_port_meter,
15716 (cmdline_parse_inst_t *)&cmd_disable_port_meter,
15717 (cmdline_parse_inst_t *)&cmd_del_port_meter,
15718 (cmdline_parse_inst_t *)&cmd_set_port_meter_profile,
15719 (cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table,
15720 (cmdline_parse_inst_t *)&cmd_set_port_meter_policer_action,
15721 (cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask,
15722 (cmdline_parse_inst_t *)&cmd_show_port_meter_stats,
15723 (cmdline_parse_inst_t *)&cmd_mcast_addr,
15724 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all,
15725 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific,
15726 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all,
15727 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific,
15728 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_en,
15729 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_dis,
15730 (cmdline_parse_inst_t *)&cmd_config_e_tag_stripping_en_dis,
15731 (cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis,
15732 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_add,
15733 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_del,
15734 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
15735 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
15736 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
15737 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
15738 (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
15739 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
15740 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
15741 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
15742 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
15743 (cmdline_parse_inst_t *)&cmd_set_macsec_sc,
15744 (cmdline_parse_inst_t *)&cmd_set_macsec_sa,
15745 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
15746 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
15747 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
15748 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
15749 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
15750 (cmdline_parse_inst_t *)&cmd_set_vf_promisc,
15751 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
15752 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
15753 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
15754 (cmdline_parse_inst_t *)&cmd_vf_max_bw,
15755 (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
15756 (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
15757 (cmdline_parse_inst_t *)&cmd_strict_link_prio,
15758 (cmdline_parse_inst_t *)&cmd_tc_min_bw,
15759 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
15760 (cmdline_parse_inst_t *)&cmd_set_port_tm_hierarchy_default,
15762 (cmdline_parse_inst_t *)&cmd_ddp_add,
15763 (cmdline_parse_inst_t *)&cmd_ddp_del,
15764 (cmdline_parse_inst_t *)&cmd_ddp_get_list,
15765 (cmdline_parse_inst_t *)&cmd_ddp_get_info,
15766 (cmdline_parse_inst_t *)&cmd_show_vf_stats,
15767 (cmdline_parse_inst_t *)&cmd_clear_vf_stats,
15768 (cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
15769 (cmdline_parse_inst_t *)&cmd_ptype_mapping_replace,
15770 (cmdline_parse_inst_t *)&cmd_ptype_mapping_reset,
15771 (cmdline_parse_inst_t *)&cmd_ptype_mapping_update,
15773 (cmdline_parse_inst_t *)&cmd_pctype_mapping_get,
15774 (cmdline_parse_inst_t *)&cmd_pctype_mapping_reset,
15775 (cmdline_parse_inst_t *)&cmd_pctype_mapping_update,
15776 (cmdline_parse_inst_t *)&cmd_queue_region,
15777 (cmdline_parse_inst_t *)&cmd_region_flowtype,
15778 (cmdline_parse_inst_t *)&cmd_user_priority_region,
15779 (cmdline_parse_inst_t *)&cmd_flush_queue_region,
15780 (cmdline_parse_inst_t *)&cmd_show_queue_region_info_all,
15781 (cmdline_parse_inst_t *)&cmd_show_port_tm_cap,
15782 (cmdline_parse_inst_t *)&cmd_show_port_tm_level_cap,
15783 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_cap,
15784 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_type,
15785 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_stats,
15786 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shaper_profile,
15787 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shaper_profile,
15788 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shared_shaper,
15789 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shared_shaper,
15790 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_wred_profile,
15791 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_wred_profile,
15792 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_shaper_profile,
15793 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node,
15794 (cmdline_parse_inst_t *)&cmd_add_port_tm_leaf_node,
15795 (cmdline_parse_inst_t *)&cmd_del_port_tm_node,
15796 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_parent,
15797 (cmdline_parse_inst_t *)&cmd_port_tm_hierarchy_commit,
15801 /* read cmdline commands from file */
15803 cmdline_read_from_file(const char *filename)
15805 struct cmdline *cl;
15807 cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
15809 printf("Failed to create file based cmdline context: %s\n",
15814 cmdline_interact(cl);
15819 printf("Read CLI commands from %s\n", filename);
15822 /* prompt function, called from main on MASTER lcore */
15826 /* initialize non-constant commands */
15827 cmd_set_fwd_mode_init();
15828 cmd_set_fwd_retry_mode_init();
15830 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
15831 if (testpmd_cl == NULL)
15833 cmdline_interact(testpmd_cl);
15834 cmdline_stdin_exit(testpmd_cl);
15840 if (testpmd_cl != NULL)
15841 cmdline_quit(testpmd_cl);
15845 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
15847 if (id == (portid_t)RTE_PORT_ALL) {
15850 RTE_ETH_FOREACH_DEV(pid) {
15851 /* check if need_reconfig has been set to 1 */
15852 if (ports[pid].need_reconfig == 0)
15853 ports[pid].need_reconfig = dev;
15854 /* check if need_reconfig_queues has been set to 1 */
15855 if (ports[pid].need_reconfig_queues == 0)
15856 ports[pid].need_reconfig_queues = queue;
15858 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
15859 /* check if need_reconfig has been set to 1 */
15860 if (ports[id].need_reconfig == 0)
15861 ports[id].need_reconfig = dev;
15862 /* check if need_reconfig_queues has been set to 1 */
15863 if (ports[id].need_reconfig_queues == 0)
15864 ports[id].need_reconfig_queues = queue;