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 port (port_id) vf (vf_id) rx|tx on|off\n"
530 " Enable/Disable a VF receive/tranmit from a port\n\n"
532 "set port (port_id) vf (vf_id) (mac_addr)"
533 " (exact-mac#exact-mac-vlan#hashmac|hashmac-vlan) on|off\n"
534 " Add/Remove unicast or multicast MAC addr filter"
537 "set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM"
539 " AUPE:accepts untagged VLAN;"
540 "ROPE:accept unicast hash\n\n"
541 " BAM:accepts broadcast packets;"
542 "MPE:accepts all multicast packets\n\n"
543 " Enable/Disable a VF receive mode of a port\n\n"
545 "set port (port_id) queue (queue_id) rate (rate_num)\n"
546 " Set rate limit for a queue of a port\n\n"
548 "set port (port_id) vf (vf_id) rate (rate_num) "
549 "queue_mask (queue_mask_value)\n"
550 " Set rate limit for queues in VF of a port\n\n"
552 "set port (port_id) mirror-rule (rule_id)"
553 " (pool-mirror-up|pool-mirror-down|vlan-mirror)"
554 " (poolmask|vlanid[,vlanid]*) dst-pool (pool_id) (on|off)\n"
555 " Set pool or vlan type mirror rule on a port.\n"
556 " e.g., 'set port 0 mirror-rule 0 vlan-mirror 0,1"
557 " dst-pool 0 on' enable mirror traffic with vlan 0,1"
560 "set port (port_id) mirror-rule (rule_id)"
561 " (uplink-mirror|downlink-mirror) dst-pool"
562 " (pool_id) (on|off)\n"
563 " Set uplink or downlink type mirror rule on a port.\n"
564 " e.g., 'set port 0 mirror-rule 0 uplink-mirror dst-pool"
565 " 0 on' enable mirror income traffic to pool 0.\n\n"
567 "reset port (port_id) mirror-rule (rule_id)\n"
568 " Reset a mirror rule.\n\n"
570 "set flush_rx (on|off)\n"
571 " Flush (default) or don't flush RX streams before"
572 " forwarding. Mainly used with PCAP drivers.\n\n"
574 "set bypass mode (normal|bypass|isolate) (port_id)\n"
575 " Set the bypass mode for the lowest port on bypass enabled"
578 "set bypass event (timeout|os_on|os_off|power_on|power_off) "
579 "mode (normal|bypass|isolate) (port_id)\n"
580 " Set the event required to initiate specified bypass mode for"
581 " the lowest port on a bypass enabled NIC where:\n"
582 " timeout = enable bypass after watchdog timeout.\n"
583 " os_on = enable bypass when OS/board is powered on.\n"
584 " os_off = enable bypass when OS/board is powered off.\n"
585 " power_on = enable bypass when power supply is turned on.\n"
586 " power_off = enable bypass when power supply is turned off."
589 "set bypass timeout (0|1.5|2|3|4|8|16|32)\n"
590 " Set the bypass watchdog timeout to 'n' seconds"
591 " where 0 = instant.\n\n"
593 "show bypass config (port_id)\n"
594 " Show the bypass configuration for a bypass enabled NIC"
595 " using the lowest port on the NIC.\n\n"
597 #ifdef RTE_LIBRTE_PMD_BOND
598 "create bonded device (mode) (socket)\n"
599 " Create a new bonded device with specific bonding mode and socket.\n\n"
601 "add bonding slave (slave_id) (port_id)\n"
602 " Add a slave device to a bonded device.\n\n"
604 "remove bonding slave (slave_id) (port_id)\n"
605 " Remove a slave device from a bonded device.\n\n"
607 "set bonding mode (value) (port_id)\n"
608 " Set the bonding mode on a bonded device.\n\n"
610 "set bonding primary (slave_id) (port_id)\n"
611 " Set the primary slave for a bonded device.\n\n"
613 "show bonding config (port_id)\n"
614 " Show the bonding config for port_id.\n\n"
616 "set bonding mac_addr (port_id) (address)\n"
617 " Set the MAC address of a bonded device.\n\n"
619 "set bonding mode IEEE802.3AD aggregator policy (port_id) (agg_name)"
620 " Set Aggregation mode for IEEE802.3AD (mode 4)"
622 "set bonding xmit_balance_policy (port_id) (l2|l23|l34)\n"
623 " Set the transmit balance policy for bonded device running in balance mode.\n\n"
625 "set bonding mon_period (port_id) (value)\n"
626 " Set the bonding link status monitoring polling period in ms.\n\n"
628 "set bonding lacp dedicated_queues <port_id> (enable|disable)\n"
629 " Enable/disable dedicated queues for LACP control traffic.\n\n"
632 "set link-up port (port_id)\n"
633 " Set link up for a port.\n\n"
635 "set link-down port (port_id)\n"
636 " Set link down for a port.\n\n"
638 "E-tag set insertion on port-tag-id (value)"
639 " port (port_id) vf (vf_id)\n"
640 " Enable E-tag insertion for a VF on a port\n\n"
642 "E-tag set insertion off port (port_id) vf (vf_id)\n"
643 " Disable E-tag insertion for a VF on a port\n\n"
645 "E-tag set stripping (on|off) port (port_id)\n"
646 " Enable/disable E-tag stripping on a port\n\n"
648 "E-tag set forwarding (on|off) port (port_id)\n"
649 " Enable/disable E-tag based forwarding"
652 "E-tag set filter add e-tag-id (value) dst-pool"
653 " (pool_id) port (port_id)\n"
654 " Add an E-tag forwarding filter on a port\n\n"
656 "E-tag set filter del e-tag-id (value) port (port_id)\n"
657 " Delete an E-tag forwarding filter on a port\n\n"
659 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
660 "set port tm hierarchy default (port_id)\n"
661 " Set default traffic Management hierarchy on a port\n\n"
664 "ddp add (port_id) (profile_path[,output_path])\n"
665 " Load a profile package on a port\n\n"
667 "ddp del (port_id) (profile_path)\n"
668 " Delete a profile package from a port\n\n"
670 "ptype mapping get (port_id) (valid_only)\n"
671 " Get ptype mapping on a port\n\n"
673 "ptype mapping replace (port_id) (target) (mask) (pky_type)\n"
674 " Replace target with the pkt_type in ptype mapping\n\n"
676 "ptype mapping reset (port_id)\n"
677 " Reset ptype mapping on a port\n\n"
679 "ptype mapping update (port_id) (hw_ptype) (sw_ptype)\n"
680 " Update a ptype mapping item on a port\n\n"
682 "set port (port_id) queue-region region_id (value) "
683 "queue_start_index (value) queue_num (value)\n"
684 " Set a queue region on a port\n\n"
686 "set port (port_id) queue-region region_id (value) "
688 " Set a flowtype region index on a port\n\n"
690 "set port (port_id) queue-region UP (value) region_id (value)\n"
691 " Set the mapping of User Priority to "
692 "queue region on a port\n\n"
694 "set port (port_id) queue-region flush (on|off)\n"
695 " flush all queue region related configuration\n\n"
697 "add port meter profile srtcm_rfc2697 (port_id) (profile_id) (cir) (cbs) (ebs) (color_aware)\n"
698 " meter profile add - srtcm rfc 2697\n\n"
700 "add port meter profile trtcm_rfc2698 (port_id) (profile_id) (cir) (pir) (cbs) (pbs)\n"
701 " meter profile add - trtcm rfc 2698\n\n"
703 "add port meter profile trtcm_rfc4115 (port_id) (profile_id) (cir) (eir) (cbs) (ebs)\n"
704 " meter profile add - trtcm rfc 4115\n\n"
706 "del port meter profile (port_id) (profile_id)\n"
707 " meter profile delete\n\n"
709 "set port meter (port_id) (mtr_id) (profile_id) (g_action) (y_action) (r_action) (stats_mask) (shared)\n"
712 "del port meter (port_id) (mtr_id)\n"
715 "set port meter profile (port_id) (mtr_id) (profile_id)\n"
716 " meter update meter profile\n\n"
718 "set port meter policer action (port_id) (mtr_id) (color) (action)\n"
719 " meter update policer action\n\n"
721 "set port meter stats mask (port_id) (mtr_id) (stats_mask)\n"
722 " meter update stats\n\n"
724 "show port (port_id) queue-region\n"
725 " show all queue region related configuration info\n\n"
727 "add port tm node shaper profile (port_id) (shaper_profile_id)"
728 " (tb_rate) (tb_size) (packet_length_adjust)\n"
729 " Add port tm node private shaper profile.\n\n"
731 "del port tm node shaper profile (port_id) (shaper_profile_id)\n"
732 " Delete port tm node private shaper profile.\n\n"
734 "add port tm node shared shaper (port_id) (shared_shaper_id)"
735 " (shaper_profile_id)\n"
736 " Add/update port tm node shared shaper.\n\n"
738 "del port tm node shared shaper (port_id) (shared_shaper_id)\n"
739 " Delete port tm node shared shaper.\n\n"
741 "set port tm node shaper profile (port_id) (node_id)"
742 " (shaper_profile_id)\n"
743 " Set port tm node shaper profile.\n\n"
745 "add port tm node wred profile (port_id) (wred_profile_id)"
746 " (color_g) (min_th_g) (max_th_g) (maxp_inv_g) (wq_log2_g)"
747 " (color_y) (min_th_y) (max_th_y) (maxp_inv_y) (wq_log2_y)"
748 " (color_r) (min_th_r) (max_th_r) (maxp_inv_r) (wq_log2_r)\n"
749 " Add port tm node wred profile.\n\n"
751 "del port tm node wred profile (port_id) (wred_profile_id)\n"
752 " Delete port tm node wred profile.\n\n"
754 "add port tm nonleaf node (port_id) (node_id) (parent_node_id)"
755 " (priority) (weight) (level_id) (shaper_profile_id)"
756 " (n_sp_priorities) (stats_mask) (n_shared_shapers)"
757 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
758 " Add port tm nonleaf node.\n\n"
760 "add port tm leaf node (port_id) (node_id) (parent_node_id)"
761 " (priority) (weight) (level_id) (shaper_profile_id)"
762 " (cman_mode) (wred_profile_id) (stats_mask) (n_shared_shapers)"
763 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
764 " Add port tm leaf node.\n\n"
766 "del port tm node (port_id) (node_id)\n"
767 " Delete port tm node.\n\n"
769 "set port tm node parent (port_id) (node_id) (parent_node_id)"
770 " (priority) (weight)\n"
771 " Set port tm node parent.\n\n"
773 "port tm hierarchy commit (port_id) (clean_on_fail)\n"
774 " Commit tm hierarchy.\n\n"
776 , list_pkt_forwarding_modes()
780 if (show_all || !strcmp(res->section, "ports")) {
786 "----------------\n\n"
788 "port start (port_id|all)\n"
789 " Start all ports or port_id.\n\n"
791 "port stop (port_id|all)\n"
792 " Stop all ports or port_id.\n\n"
794 "port close (port_id|all)\n"
795 " Close all ports or port_id.\n\n"
797 "port attach (ident)\n"
798 " Attach physical or virtual dev by pci address or virtual device name\n\n"
800 "port detach (port_id)\n"
801 " Detach physical or virtual dev by port_id\n\n"
803 "port config (port_id|all)"
804 " speed (10|100|1000|10000|25000|40000|50000|100000|auto)"
805 " duplex (half|full|auto)\n"
806 " Set speed and duplex for all ports or port_id\n\n"
808 "port config all (rxq|txq|rxd|txd) (value)\n"
809 " Set number for rxq/txq/rxd/txd.\n\n"
811 "port config all max-pkt-len (value)\n"
812 " Set the max packet length.\n\n"
814 "port config all (crc-strip|scatter|rx-cksum|rx-timestamp|hw-vlan|hw-vlan-filter|"
815 "hw-vlan-strip|hw-vlan-extend|drop-en)"
817 " Set crc-strip/scatter/rx-checksum/hardware-vlan/drop_en"
820 "port config all rss (all|ip|tcp|udp|sctp|ether|port|vxlan|"
821 "geneve|nvgre|none|<flowtype_id>)\n"
822 " Set the RSS mode.\n\n"
824 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
825 " Set the RSS redirection table.\n\n"
827 "port config (port_id) dcb vt (on|off) (traffic_class)"
829 " Set the DCB mode.\n\n"
831 "port config all burst (value)\n"
832 " Set the number of packets per burst.\n\n"
834 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
836 " Set the ring prefetch/host/writeback threshold"
837 " for tx/rx queue.\n\n"
839 "port config all (txfreet|txrst|rxfreet) (value)\n"
840 " Set free threshold for rx/tx, or set"
841 " tx rs bit threshold.\n\n"
842 "port config mtu X value\n"
843 " Set the MTU of port X to a given value\n\n"
845 "port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
846 " Start/stop a rx/tx queue of port X. Only take effect"
847 " when port X is started\n\n"
849 "port config (port_id|all) l2-tunnel E-tag ether-type"
851 " Set the value of E-tag ether-type.\n\n"
853 "port config (port_id|all) l2-tunnel E-tag"
854 " (enable|disable)\n"
855 " Enable/disable the E-tag support.\n\n"
857 "port config (port_id) pctype mapping reset\n"
858 " Reset flow type to pctype mapping on a port\n\n"
860 "port config (port_id) pctype mapping update"
861 " (pctype_id_0[,pctype_id_1]*) (flow_type_id)\n"
862 " Update a flow type to pctype mapping item on a port\n\n"
866 if (show_all || !strcmp(res->section, "registers")) {
874 "read reg (port_id) (address)\n"
875 " Display value of a port register.\n\n"
877 "read regfield (port_id) (address) (bit_x) (bit_y)\n"
878 " Display a port register bit field.\n\n"
880 "read regbit (port_id) (address) (bit_x)\n"
881 " Display a single port register bit.\n\n"
883 "write reg (port_id) (address) (value)\n"
884 " Set value of a port register.\n\n"
886 "write regfield (port_id) (address) (bit_x) (bit_y)"
888 " Set bit field of a port register.\n\n"
890 "write regbit (port_id) (address) (bit_x) (value)\n"
891 " Set single bit value of a port register.\n\n"
894 if (show_all || !strcmp(res->section, "filters")) {
902 "ethertype_filter (port_id) (add|del)"
903 " (mac_addr|mac_ignr) (mac_address) ethertype"
904 " (ether_type) (drop|fwd) queue (queue_id)\n"
905 " Add/Del an ethertype filter.\n\n"
907 "2tuple_filter (port_id) (add|del)"
908 " dst_port (dst_port_value) protocol (protocol_value)"
909 " mask (mask_value) tcp_flags (tcp_flags_value)"
910 " priority (prio_value) queue (queue_id)\n"
911 " Add/Del a 2tuple filter.\n\n"
913 "5tuple_filter (port_id) (add|del)"
914 " dst_ip (dst_address) src_ip (src_address)"
915 " dst_port (dst_port_value) src_port (src_port_value)"
916 " protocol (protocol_value)"
917 " mask (mask_value) tcp_flags (tcp_flags_value)"
918 " priority (prio_value) queue (queue_id)\n"
919 " Add/Del a 5tuple filter.\n\n"
921 "syn_filter (port_id) (add|del) priority (high|low) queue (queue_id)"
922 " Add/Del syn filter.\n\n"
924 "flex_filter (port_id) (add|del) len (len_value)"
925 " bytes (bytes_value) mask (mask_value)"
926 " priority (prio_value) queue (queue_id)\n"
927 " Add/Del a flex filter.\n\n"
929 "flow_director_filter (port_id) mode IP (add|del|update)"
930 " flow (ipv4-other|ipv4-frag|ipv6-other|ipv6-frag)"
931 " src (src_ip_address) dst (dst_ip_address)"
932 " tos (tos_value) proto (proto_value) ttl (ttl_value)"
933 " vlan (vlan_value) flexbytes (flexbytes_value)"
934 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
935 " fd_id (fd_id_value)\n"
936 " Add/Del an IP type flow director filter.\n\n"
938 "flow_director_filter (port_id) mode IP (add|del|update)"
939 " flow (ipv4-tcp|ipv4-udp|ipv6-tcp|ipv6-udp)"
940 " src (src_ip_address) (src_port)"
941 " dst (dst_ip_address) (dst_port)"
942 " tos (tos_value) ttl (ttl_value)"
943 " vlan (vlan_value) flexbytes (flexbytes_value)"
944 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
945 " fd_id (fd_id_value)\n"
946 " Add/Del an UDP/TCP type flow director filter.\n\n"
948 "flow_director_filter (port_id) mode IP (add|del|update)"
949 " flow (ipv4-sctp|ipv6-sctp)"
950 " src (src_ip_address) (src_port)"
951 " dst (dst_ip_address) (dst_port)"
952 " tag (verification_tag) "
953 " tos (tos_value) ttl (ttl_value)"
955 " flexbytes (flexbytes_value) (drop|fwd)"
956 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
957 " Add/Del a SCTP type flow director filter.\n\n"
959 "flow_director_filter (port_id) mode IP (add|del|update)"
960 " flow l2_payload ether (ethertype)"
961 " flexbytes (flexbytes_value) (drop|fwd)"
962 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
963 " Add/Del a l2 payload type flow director filter.\n\n"
965 "flow_director_filter (port_id) mode MAC-VLAN (add|del|update)"
966 " mac (mac_address) vlan (vlan_value)"
967 " flexbytes (flexbytes_value) (drop|fwd)"
968 " queue (queue_id) fd_id (fd_id_value)\n"
969 " Add/Del a MAC-VLAN flow director filter.\n\n"
971 "flow_director_filter (port_id) mode Tunnel (add|del|update)"
972 " mac (mac_address) vlan (vlan_value)"
973 " tunnel (NVGRE|VxLAN) tunnel-id (tunnel_id_value)"
974 " flexbytes (flexbytes_value) (drop|fwd)"
975 " queue (queue_id) fd_id (fd_id_value)\n"
976 " Add/Del a Tunnel flow director filter.\n\n"
978 "flush_flow_director (port_id)\n"
979 " Flush all flow director entries of a device.\n\n"
981 "flow_director_mask (port_id) mode IP vlan (vlan_value)"
982 " src_mask (ipv4_src) (ipv6_src) (src_port)"
983 " dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n"
984 " Set flow director IP mask.\n\n"
986 "flow_director_mask (port_id) mode MAC-VLAN"
987 " vlan (vlan_value)\n"
988 " Set flow director MAC-VLAN mask.\n\n"
990 "flow_director_mask (port_id) mode Tunnel"
991 " vlan (vlan_value) mac (mac_value)"
992 " tunnel-type (tunnel_type_value)"
993 " tunnel-id (tunnel_id_value)\n"
994 " Set flow director Tunnel mask.\n\n"
996 "flow_director_flex_mask (port_id)"
997 " flow (none|ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
998 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|l2_payload|all)"
1000 " Configure mask of flex payload.\n\n"
1002 "flow_director_flex_payload (port_id)"
1003 " (raw|l2|l3|l4) (config)\n"
1004 " Configure flex payload selection.\n\n"
1006 "get_sym_hash_ena_per_port (port_id)\n"
1007 " get symmetric hash enable configuration per port.\n\n"
1009 "set_sym_hash_ena_per_port (port_id) (enable|disable)\n"
1010 " set symmetric hash enable configuration per port"
1011 " to enable or disable.\n\n"
1013 "get_hash_global_config (port_id)\n"
1014 " Get the global configurations of hash filters.\n\n"
1016 "set_hash_global_config (port_id) (toeplitz|simple_xor|default)"
1017 " (ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
1018 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload)"
1019 " (enable|disable)\n"
1020 " Set the global configurations of hash filters.\n\n"
1022 "set_hash_input_set (port_id) (ipv4|ipv4-frag|"
1023 "ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
1024 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1025 "l2_payload|<flowtype_id>) (ovlan|ivlan|src-ipv4|dst-ipv4|"
1026 "src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|ipv6-tc|"
1027 "ipv6-next-header|udp-src-port|udp-dst-port|"
1028 "tcp-src-port|tcp-dst-port|sctp-src-port|"
1029 "sctp-dst-port|sctp-veri-tag|udp-key|gre-key|fld-1st|"
1030 "fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|fld-7th|"
1031 "fld-8th|none) (select|add)\n"
1032 " Set the input set for hash.\n\n"
1034 "set_fdir_input_set (port_id) "
1035 "(ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
1036 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1037 "l2_payload) (ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|"
1038 "dst-ipv6|ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|"
1039 "ipv6-next-header|ipv6-hop-limits|udp-src-port|"
1040 "udp-dst-port|tcp-src-port|tcp-dst-port|"
1041 "sctp-src-port|sctp-dst-port|sctp-veri-tag|none)"
1043 " Set the input set for FDir.\n\n"
1045 "flow validate {port_id}"
1046 " [group {group_id}] [priority {level}]"
1047 " [ingress] [egress]"
1048 " pattern {item} [/ {item} [...]] / end"
1049 " actions {action} [/ {action} [...]] / end\n"
1050 " Check whether a flow rule can be created.\n\n"
1052 "flow create {port_id}"
1053 " [group {group_id}] [priority {level}]"
1054 " [ingress] [egress]"
1055 " pattern {item} [/ {item} [...]] / end"
1056 " actions {action} [/ {action} [...]] / end\n"
1057 " Create a flow rule.\n\n"
1059 "flow destroy {port_id} rule {rule_id} [...]\n"
1060 " Destroy specific flow rules.\n\n"
1062 "flow flush {port_id}\n"
1063 " Destroy all flow rules.\n\n"
1065 "flow query {port_id} {rule_id} {action}\n"
1066 " Query an existing flow rule.\n\n"
1068 "flow list {port_id} [group {group_id}] [...]\n"
1069 " List existing flow rules sorted by priority,"
1070 " filtered by group identifiers.\n\n"
1072 "flow isolate {port_id} {boolean}\n"
1073 " Restrict ingress traffic to the defined"
1079 cmdline_parse_token_string_t cmd_help_long_help =
1080 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
1082 cmdline_parse_token_string_t cmd_help_long_section =
1083 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
1084 "all#control#display#config#"
1085 "ports#registers#filters");
1087 cmdline_parse_inst_t cmd_help_long = {
1088 .f = cmd_help_long_parsed,
1090 .help_str = "help all|control|display|config|ports|register|filters: "
1093 (void *)&cmd_help_long_help,
1094 (void *)&cmd_help_long_section,
1100 /* *** start/stop/close all ports *** */
1101 struct cmd_operate_port_result {
1102 cmdline_fixed_string_t keyword;
1103 cmdline_fixed_string_t name;
1104 cmdline_fixed_string_t value;
1107 static void cmd_operate_port_parsed(void *parsed_result,
1108 __attribute__((unused)) struct cmdline *cl,
1109 __attribute__((unused)) void *data)
1111 struct cmd_operate_port_result *res = parsed_result;
1113 if (!strcmp(res->name, "start"))
1114 start_port(RTE_PORT_ALL);
1115 else if (!strcmp(res->name, "stop"))
1116 stop_port(RTE_PORT_ALL);
1117 else if (!strcmp(res->name, "close"))
1118 close_port(RTE_PORT_ALL);
1119 else if (!strcmp(res->name, "reset"))
1120 reset_port(RTE_PORT_ALL);
1122 printf("Unknown parameter\n");
1125 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
1126 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
1128 cmdline_parse_token_string_t cmd_operate_port_all_port =
1129 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
1130 "start#stop#close#reset");
1131 cmdline_parse_token_string_t cmd_operate_port_all_all =
1132 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
1134 cmdline_parse_inst_t cmd_operate_port = {
1135 .f = cmd_operate_port_parsed,
1137 .help_str = "port start|stop|close all: Start/Stop/Close/Reset all ports",
1139 (void *)&cmd_operate_port_all_cmd,
1140 (void *)&cmd_operate_port_all_port,
1141 (void *)&cmd_operate_port_all_all,
1146 /* *** start/stop/close specific port *** */
1147 struct cmd_operate_specific_port_result {
1148 cmdline_fixed_string_t keyword;
1149 cmdline_fixed_string_t name;
1153 static void cmd_operate_specific_port_parsed(void *parsed_result,
1154 __attribute__((unused)) struct cmdline *cl,
1155 __attribute__((unused)) void *data)
1157 struct cmd_operate_specific_port_result *res = parsed_result;
1159 if (!strcmp(res->name, "start"))
1160 start_port(res->value);
1161 else if (!strcmp(res->name, "stop"))
1162 stop_port(res->value);
1163 else if (!strcmp(res->name, "close"))
1164 close_port(res->value);
1165 else if (!strcmp(res->name, "reset"))
1166 reset_port(res->value);
1168 printf("Unknown parameter\n");
1171 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
1172 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1174 cmdline_parse_token_string_t cmd_operate_specific_port_port =
1175 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1176 name, "start#stop#close#reset");
1177 cmdline_parse_token_num_t cmd_operate_specific_port_id =
1178 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
1181 cmdline_parse_inst_t cmd_operate_specific_port = {
1182 .f = cmd_operate_specific_port_parsed,
1184 .help_str = "port start|stop|close <port_id>: Start/Stop/Close/Reset port_id",
1186 (void *)&cmd_operate_specific_port_cmd,
1187 (void *)&cmd_operate_specific_port_port,
1188 (void *)&cmd_operate_specific_port_id,
1193 /* *** attach a specified port *** */
1194 struct cmd_operate_attach_port_result {
1195 cmdline_fixed_string_t port;
1196 cmdline_fixed_string_t keyword;
1197 cmdline_fixed_string_t identifier;
1200 static void cmd_operate_attach_port_parsed(void *parsed_result,
1201 __attribute__((unused)) struct cmdline *cl,
1202 __attribute__((unused)) void *data)
1204 struct cmd_operate_attach_port_result *res = parsed_result;
1206 if (!strcmp(res->keyword, "attach"))
1207 attach_port(res->identifier);
1209 printf("Unknown parameter\n");
1212 cmdline_parse_token_string_t cmd_operate_attach_port_port =
1213 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1215 cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
1216 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1218 cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
1219 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1222 cmdline_parse_inst_t cmd_operate_attach_port = {
1223 .f = cmd_operate_attach_port_parsed,
1225 .help_str = "port attach <identifier>: "
1226 "(identifier: pci address or virtual dev name)",
1228 (void *)&cmd_operate_attach_port_port,
1229 (void *)&cmd_operate_attach_port_keyword,
1230 (void *)&cmd_operate_attach_port_identifier,
1235 /* *** detach a specified port *** */
1236 struct cmd_operate_detach_port_result {
1237 cmdline_fixed_string_t port;
1238 cmdline_fixed_string_t keyword;
1242 static void cmd_operate_detach_port_parsed(void *parsed_result,
1243 __attribute__((unused)) struct cmdline *cl,
1244 __attribute__((unused)) void *data)
1246 struct cmd_operate_detach_port_result *res = parsed_result;
1248 if (!strcmp(res->keyword, "detach"))
1249 detach_port(res->port_id);
1251 printf("Unknown parameter\n");
1254 cmdline_parse_token_string_t cmd_operate_detach_port_port =
1255 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1257 cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
1258 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1260 cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
1261 TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
1264 cmdline_parse_inst_t cmd_operate_detach_port = {
1265 .f = cmd_operate_detach_port_parsed,
1267 .help_str = "port detach <port_id>",
1269 (void *)&cmd_operate_detach_port_port,
1270 (void *)&cmd_operate_detach_port_keyword,
1271 (void *)&cmd_operate_detach_port_port_id,
1276 /* *** configure speed for all ports *** */
1277 struct cmd_config_speed_all {
1278 cmdline_fixed_string_t port;
1279 cmdline_fixed_string_t keyword;
1280 cmdline_fixed_string_t all;
1281 cmdline_fixed_string_t item1;
1282 cmdline_fixed_string_t item2;
1283 cmdline_fixed_string_t value1;
1284 cmdline_fixed_string_t value2;
1288 parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed)
1293 if (!strcmp(duplexstr, "half")) {
1294 duplex = ETH_LINK_HALF_DUPLEX;
1295 } else if (!strcmp(duplexstr, "full")) {
1296 duplex = ETH_LINK_FULL_DUPLEX;
1297 } else if (!strcmp(duplexstr, "auto")) {
1298 duplex = ETH_LINK_FULL_DUPLEX;
1300 printf("Unknown duplex parameter\n");
1304 if (!strcmp(speedstr, "10")) {
1305 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1306 ETH_LINK_SPEED_10M_HD : ETH_LINK_SPEED_10M;
1307 } else if (!strcmp(speedstr, "100")) {
1308 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1309 ETH_LINK_SPEED_100M_HD : ETH_LINK_SPEED_100M;
1311 if (duplex != ETH_LINK_FULL_DUPLEX) {
1312 printf("Invalid speed/duplex parameters\n");
1315 if (!strcmp(speedstr, "1000")) {
1316 *speed = ETH_LINK_SPEED_1G;
1317 } else if (!strcmp(speedstr, "10000")) {
1318 *speed = ETH_LINK_SPEED_10G;
1319 } else if (!strcmp(speedstr, "25000")) {
1320 *speed = ETH_LINK_SPEED_25G;
1321 } else if (!strcmp(speedstr, "40000")) {
1322 *speed = ETH_LINK_SPEED_40G;
1323 } else if (!strcmp(speedstr, "50000")) {
1324 *speed = ETH_LINK_SPEED_50G;
1325 } else if (!strcmp(speedstr, "100000")) {
1326 *speed = ETH_LINK_SPEED_100G;
1327 } else if (!strcmp(speedstr, "auto")) {
1328 *speed = ETH_LINK_SPEED_AUTONEG;
1330 printf("Unknown speed parameter\n");
1339 cmd_config_speed_all_parsed(void *parsed_result,
1340 __attribute__((unused)) struct cmdline *cl,
1341 __attribute__((unused)) void *data)
1343 struct cmd_config_speed_all *res = parsed_result;
1344 uint32_t link_speed;
1347 if (!all_ports_stopped()) {
1348 printf("Please stop all ports first\n");
1352 if (parse_and_check_speed_duplex(res->value1, res->value2,
1356 RTE_ETH_FOREACH_DEV(pid) {
1357 ports[pid].dev_conf.link_speeds = link_speed;
1360 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1363 cmdline_parse_token_string_t cmd_config_speed_all_port =
1364 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1365 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1366 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1368 cmdline_parse_token_string_t cmd_config_speed_all_all =
1369 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1370 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1371 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1372 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1373 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1374 "10#100#1000#10000#25000#40000#50000#100000#auto");
1375 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1376 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1377 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1378 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1381 cmdline_parse_inst_t cmd_config_speed_all = {
1382 .f = cmd_config_speed_all_parsed,
1384 .help_str = "port config all speed "
1385 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1388 (void *)&cmd_config_speed_all_port,
1389 (void *)&cmd_config_speed_all_keyword,
1390 (void *)&cmd_config_speed_all_all,
1391 (void *)&cmd_config_speed_all_item1,
1392 (void *)&cmd_config_speed_all_value1,
1393 (void *)&cmd_config_speed_all_item2,
1394 (void *)&cmd_config_speed_all_value2,
1399 /* *** configure speed for specific port *** */
1400 struct cmd_config_speed_specific {
1401 cmdline_fixed_string_t port;
1402 cmdline_fixed_string_t keyword;
1404 cmdline_fixed_string_t item1;
1405 cmdline_fixed_string_t item2;
1406 cmdline_fixed_string_t value1;
1407 cmdline_fixed_string_t value2;
1411 cmd_config_speed_specific_parsed(void *parsed_result,
1412 __attribute__((unused)) struct cmdline *cl,
1413 __attribute__((unused)) void *data)
1415 struct cmd_config_speed_specific *res = parsed_result;
1416 uint32_t link_speed;
1418 if (!all_ports_stopped()) {
1419 printf("Please stop all ports first\n");
1423 if (port_id_is_invalid(res->id, ENABLED_WARN))
1426 if (parse_and_check_speed_duplex(res->value1, res->value2,
1430 ports[res->id].dev_conf.link_speeds = link_speed;
1432 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1436 cmdline_parse_token_string_t cmd_config_speed_specific_port =
1437 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1439 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1440 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1442 cmdline_parse_token_num_t cmd_config_speed_specific_id =
1443 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT8);
1444 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1445 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1447 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1448 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1449 "10#100#1000#10000#25000#40000#50000#100000#auto");
1450 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1451 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1453 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1454 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1457 cmdline_parse_inst_t cmd_config_speed_specific = {
1458 .f = cmd_config_speed_specific_parsed,
1460 .help_str = "port config <port_id> speed "
1461 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1464 (void *)&cmd_config_speed_specific_port,
1465 (void *)&cmd_config_speed_specific_keyword,
1466 (void *)&cmd_config_speed_specific_id,
1467 (void *)&cmd_config_speed_specific_item1,
1468 (void *)&cmd_config_speed_specific_value1,
1469 (void *)&cmd_config_speed_specific_item2,
1470 (void *)&cmd_config_speed_specific_value2,
1475 /* *** configure txq/rxq, txd/rxd *** */
1476 struct cmd_config_rx_tx {
1477 cmdline_fixed_string_t port;
1478 cmdline_fixed_string_t keyword;
1479 cmdline_fixed_string_t all;
1480 cmdline_fixed_string_t name;
1485 cmd_config_rx_tx_parsed(void *parsed_result,
1486 __attribute__((unused)) struct cmdline *cl,
1487 __attribute__((unused)) void *data)
1489 struct cmd_config_rx_tx *res = parsed_result;
1491 if (!all_ports_stopped()) {
1492 printf("Please stop all ports first\n");
1495 if (!strcmp(res->name, "rxq")) {
1496 if (!res->value && !nb_txq) {
1497 printf("Warning: Either rx or tx queues should be non zero\n");
1500 nb_rxq = res->value;
1502 else if (!strcmp(res->name, "txq")) {
1503 if (!res->value && !nb_rxq) {
1504 printf("Warning: Either rx or tx queues should be non zero\n");
1507 nb_txq = res->value;
1509 else if (!strcmp(res->name, "rxd")) {
1510 if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) {
1511 printf("rxd %d invalid - must be > 0 && <= %d\n",
1512 res->value, RTE_TEST_RX_DESC_MAX);
1515 nb_rxd = res->value;
1516 } else if (!strcmp(res->name, "txd")) {
1517 if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) {
1518 printf("txd %d invalid - must be > 0 && <= %d\n",
1519 res->value, RTE_TEST_TX_DESC_MAX);
1522 nb_txd = res->value;
1524 printf("Unknown parameter\n");
1532 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1535 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1536 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1537 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1538 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1539 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1540 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1541 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1542 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1544 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1545 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
1547 cmdline_parse_inst_t cmd_config_rx_tx = {
1548 .f = cmd_config_rx_tx_parsed,
1550 .help_str = "port config all rxq|txq|rxd|txd <value>",
1552 (void *)&cmd_config_rx_tx_port,
1553 (void *)&cmd_config_rx_tx_keyword,
1554 (void *)&cmd_config_rx_tx_all,
1555 (void *)&cmd_config_rx_tx_name,
1556 (void *)&cmd_config_rx_tx_value,
1561 /* *** config max packet length *** */
1562 struct cmd_config_max_pkt_len_result {
1563 cmdline_fixed_string_t port;
1564 cmdline_fixed_string_t keyword;
1565 cmdline_fixed_string_t all;
1566 cmdline_fixed_string_t name;
1571 cmd_config_max_pkt_len_parsed(void *parsed_result,
1572 __attribute__((unused)) struct cmdline *cl,
1573 __attribute__((unused)) void *data)
1575 struct cmd_config_max_pkt_len_result *res = parsed_result;
1577 if (!all_ports_stopped()) {
1578 printf("Please stop all ports first\n");
1582 if (!strcmp(res->name, "max-pkt-len")) {
1583 if (res->value < ETHER_MIN_LEN) {
1584 printf("max-pkt-len can not be less than %d\n",
1588 if (res->value == rx_mode.max_rx_pkt_len)
1591 rx_mode.max_rx_pkt_len = res->value;
1592 if (res->value > ETHER_MAX_LEN)
1593 rx_mode.jumbo_frame = 1;
1595 rx_mode.jumbo_frame = 0;
1597 printf("Unknown parameter\n");
1603 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1606 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
1607 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
1609 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
1610 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
1612 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
1613 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
1615 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
1616 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
1618 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1619 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1622 cmdline_parse_inst_t cmd_config_max_pkt_len = {
1623 .f = cmd_config_max_pkt_len_parsed,
1625 .help_str = "port config all max-pkt-len <value>",
1627 (void *)&cmd_config_max_pkt_len_port,
1628 (void *)&cmd_config_max_pkt_len_keyword,
1629 (void *)&cmd_config_max_pkt_len_all,
1630 (void *)&cmd_config_max_pkt_len_name,
1631 (void *)&cmd_config_max_pkt_len_value,
1636 /* *** configure port MTU *** */
1637 struct cmd_config_mtu_result {
1638 cmdline_fixed_string_t port;
1639 cmdline_fixed_string_t keyword;
1640 cmdline_fixed_string_t mtu;
1646 cmd_config_mtu_parsed(void *parsed_result,
1647 __attribute__((unused)) struct cmdline *cl,
1648 __attribute__((unused)) void *data)
1650 struct cmd_config_mtu_result *res = parsed_result;
1652 if (res->value < ETHER_MIN_LEN) {
1653 printf("mtu cannot be less than %d\n", ETHER_MIN_LEN);
1656 port_mtu_set(res->port_id, res->value);
1659 cmdline_parse_token_string_t cmd_config_mtu_port =
1660 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
1662 cmdline_parse_token_string_t cmd_config_mtu_keyword =
1663 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1665 cmdline_parse_token_string_t cmd_config_mtu_mtu =
1666 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1668 cmdline_parse_token_num_t cmd_config_mtu_port_id =
1669 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT16);
1670 cmdline_parse_token_num_t cmd_config_mtu_value =
1671 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
1673 cmdline_parse_inst_t cmd_config_mtu = {
1674 .f = cmd_config_mtu_parsed,
1676 .help_str = "port config mtu <port_id> <value>",
1678 (void *)&cmd_config_mtu_port,
1679 (void *)&cmd_config_mtu_keyword,
1680 (void *)&cmd_config_mtu_mtu,
1681 (void *)&cmd_config_mtu_port_id,
1682 (void *)&cmd_config_mtu_value,
1687 /* *** configure rx mode *** */
1688 struct cmd_config_rx_mode_flag {
1689 cmdline_fixed_string_t port;
1690 cmdline_fixed_string_t keyword;
1691 cmdline_fixed_string_t all;
1692 cmdline_fixed_string_t name;
1693 cmdline_fixed_string_t value;
1697 cmd_config_rx_mode_flag_parsed(void *parsed_result,
1698 __attribute__((unused)) struct cmdline *cl,
1699 __attribute__((unused)) void *data)
1701 struct cmd_config_rx_mode_flag *res = parsed_result;
1703 if (!all_ports_stopped()) {
1704 printf("Please stop all ports first\n");
1708 if (!strcmp(res->name, "crc-strip")) {
1709 if (!strcmp(res->value, "on"))
1710 rx_mode.hw_strip_crc = 1;
1711 else if (!strcmp(res->value, "off"))
1712 rx_mode.hw_strip_crc = 0;
1714 printf("Unknown parameter\n");
1717 } else if (!strcmp(res->name, "scatter")) {
1718 if (!strcmp(res->value, "on"))
1719 rx_mode.enable_scatter = 1;
1720 else if (!strcmp(res->value, "off"))
1721 rx_mode.enable_scatter = 0;
1723 printf("Unknown parameter\n");
1726 } else if (!strcmp(res->name, "rx-cksum")) {
1727 if (!strcmp(res->value, "on"))
1728 rx_mode.hw_ip_checksum = 1;
1729 else if (!strcmp(res->value, "off"))
1730 rx_mode.hw_ip_checksum = 0;
1732 printf("Unknown parameter\n");
1735 } else if (!strcmp(res->name, "rx-timestamp")) {
1736 if (!strcmp(res->value, "on"))
1737 rx_mode.hw_timestamp = 1;
1738 else if (!strcmp(res->value, "off"))
1739 rx_mode.hw_timestamp = 0;
1741 printf("Unknown parameter\n");
1744 } else if (!strcmp(res->name, "hw-vlan")) {
1745 if (!strcmp(res->value, "on")) {
1746 rx_mode.hw_vlan_filter = 1;
1747 rx_mode.hw_vlan_strip = 1;
1749 else if (!strcmp(res->value, "off")) {
1750 rx_mode.hw_vlan_filter = 0;
1751 rx_mode.hw_vlan_strip = 0;
1754 printf("Unknown parameter\n");
1757 } else if (!strcmp(res->name, "hw-vlan-filter")) {
1758 if (!strcmp(res->value, "on"))
1759 rx_mode.hw_vlan_filter = 1;
1760 else if (!strcmp(res->value, "off"))
1761 rx_mode.hw_vlan_filter = 0;
1763 printf("Unknown parameter\n");
1766 } else if (!strcmp(res->name, "hw-vlan-strip")) {
1767 if (!strcmp(res->value, "on"))
1768 rx_mode.hw_vlan_strip = 1;
1769 else if (!strcmp(res->value, "off"))
1770 rx_mode.hw_vlan_strip = 0;
1772 printf("Unknown parameter\n");
1775 } else if (!strcmp(res->name, "hw-vlan-extend")) {
1776 if (!strcmp(res->value, "on"))
1777 rx_mode.hw_vlan_extend = 1;
1778 else if (!strcmp(res->value, "off"))
1779 rx_mode.hw_vlan_extend = 0;
1781 printf("Unknown parameter\n");
1784 } else if (!strcmp(res->name, "drop-en")) {
1785 if (!strcmp(res->value, "on"))
1787 else if (!strcmp(res->value, "off"))
1790 printf("Unknown parameter\n");
1794 printf("Unknown parameter\n");
1800 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1803 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
1804 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
1805 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
1806 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
1808 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
1809 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
1810 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
1811 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
1812 "crc-strip#scatter#rx-cksum#rx-timestamp#hw-vlan#"
1813 "hw-vlan-filter#hw-vlan-strip#hw-vlan-extend");
1814 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
1815 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
1818 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
1819 .f = cmd_config_rx_mode_flag_parsed,
1821 .help_str = "port config all crc-strip|scatter|rx-cksum|rx-timestamp|hw-vlan|"
1822 "hw-vlan-filter|hw-vlan-strip|hw-vlan-extend on|off",
1824 (void *)&cmd_config_rx_mode_flag_port,
1825 (void *)&cmd_config_rx_mode_flag_keyword,
1826 (void *)&cmd_config_rx_mode_flag_all,
1827 (void *)&cmd_config_rx_mode_flag_name,
1828 (void *)&cmd_config_rx_mode_flag_value,
1833 /* *** configure rss *** */
1834 struct cmd_config_rss {
1835 cmdline_fixed_string_t port;
1836 cmdline_fixed_string_t keyword;
1837 cmdline_fixed_string_t all;
1838 cmdline_fixed_string_t name;
1839 cmdline_fixed_string_t value;
1843 cmd_config_rss_parsed(void *parsed_result,
1844 __attribute__((unused)) struct cmdline *cl,
1845 __attribute__((unused)) void *data)
1847 struct cmd_config_rss *res = parsed_result;
1848 struct rte_eth_rss_conf rss_conf = { .rss_key_len = 0, };
1852 if (!strcmp(res->value, "all"))
1853 rss_conf.rss_hf = ETH_RSS_IP | ETH_RSS_TCP |
1854 ETH_RSS_UDP | ETH_RSS_SCTP |
1856 else if (!strcmp(res->value, "ip"))
1857 rss_conf.rss_hf = ETH_RSS_IP;
1858 else if (!strcmp(res->value, "udp"))
1859 rss_conf.rss_hf = ETH_RSS_UDP;
1860 else if (!strcmp(res->value, "tcp"))
1861 rss_conf.rss_hf = ETH_RSS_TCP;
1862 else if (!strcmp(res->value, "sctp"))
1863 rss_conf.rss_hf = ETH_RSS_SCTP;
1864 else if (!strcmp(res->value, "ether"))
1865 rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD;
1866 else if (!strcmp(res->value, "port"))
1867 rss_conf.rss_hf = ETH_RSS_PORT;
1868 else if (!strcmp(res->value, "vxlan"))
1869 rss_conf.rss_hf = ETH_RSS_VXLAN;
1870 else if (!strcmp(res->value, "geneve"))
1871 rss_conf.rss_hf = ETH_RSS_GENEVE;
1872 else if (!strcmp(res->value, "nvgre"))
1873 rss_conf.rss_hf = ETH_RSS_NVGRE;
1874 else if (!strcmp(res->value, "none"))
1875 rss_conf.rss_hf = 0;
1876 else if (isdigit(res->value[0]) && atoi(res->value) > 0 &&
1877 atoi(res->value) < 64)
1878 rss_conf.rss_hf = 1ULL << atoi(res->value);
1880 printf("Unknown parameter\n");
1883 rss_conf.rss_key = NULL;
1884 for (i = 0; i < rte_eth_dev_count(); i++) {
1885 diag = rte_eth_dev_rss_hash_update(i, &rss_conf);
1887 printf("Configuration of RSS hash at ethernet port %d "
1888 "failed with error (%d): %s.\n",
1889 i, -diag, strerror(-diag));
1893 cmdline_parse_token_string_t cmd_config_rss_port =
1894 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
1895 cmdline_parse_token_string_t cmd_config_rss_keyword =
1896 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
1897 cmdline_parse_token_string_t cmd_config_rss_all =
1898 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
1899 cmdline_parse_token_string_t cmd_config_rss_name =
1900 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
1901 cmdline_parse_token_string_t cmd_config_rss_value =
1902 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, NULL);
1904 cmdline_parse_inst_t cmd_config_rss = {
1905 .f = cmd_config_rss_parsed,
1907 .help_str = "port config all rss "
1908 "all|ip|tcp|udp|sctp|ether|port|vxlan|geneve|nvgre|none|<flowtype_id>",
1910 (void *)&cmd_config_rss_port,
1911 (void *)&cmd_config_rss_keyword,
1912 (void *)&cmd_config_rss_all,
1913 (void *)&cmd_config_rss_name,
1914 (void *)&cmd_config_rss_value,
1919 /* *** configure rss hash key *** */
1920 struct cmd_config_rss_hash_key {
1921 cmdline_fixed_string_t port;
1922 cmdline_fixed_string_t config;
1924 cmdline_fixed_string_t rss_hash_key;
1925 cmdline_fixed_string_t rss_type;
1926 cmdline_fixed_string_t key;
1930 hexa_digit_to_value(char hexa_digit)
1932 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
1933 return (uint8_t) (hexa_digit - '0');
1934 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
1935 return (uint8_t) ((hexa_digit - 'a') + 10);
1936 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
1937 return (uint8_t) ((hexa_digit - 'A') + 10);
1938 /* Invalid hexa digit */
1943 parse_and_check_key_hexa_digit(char *key, int idx)
1947 hexa_v = hexa_digit_to_value(key[idx]);
1949 printf("invalid key: character %c at position %d is not a "
1950 "valid hexa digit\n", key[idx], idx);
1955 cmd_config_rss_hash_key_parsed(void *parsed_result,
1956 __attribute__((unused)) struct cmdline *cl,
1957 __attribute__((unused)) void *data)
1959 struct cmd_config_rss_hash_key *res = parsed_result;
1960 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
1964 struct rte_eth_dev_info dev_info;
1965 uint8_t hash_key_size;
1968 memset(&dev_info, 0, sizeof(dev_info));
1969 rte_eth_dev_info_get(res->port_id, &dev_info);
1970 if (dev_info.hash_key_size > 0 &&
1971 dev_info.hash_key_size <= sizeof(hash_key))
1972 hash_key_size = dev_info.hash_key_size;
1974 printf("dev_info did not provide a valid hash key size\n");
1977 /* Check the length of the RSS hash key */
1978 key_len = strlen(res->key);
1979 if (key_len != (hash_key_size * 2)) {
1980 printf("key length: %d invalid - key must be a string of %d"
1981 " hexa-decimal numbers\n",
1982 (int) key_len, hash_key_size * 2);
1985 /* Translate RSS hash key into binary representation */
1986 for (i = 0; i < hash_key_size; i++) {
1987 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
1990 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
1993 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
1995 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
1999 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
2000 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
2001 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
2002 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
2004 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
2005 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT16);
2006 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
2007 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
2008 rss_hash_key, "rss-hash-key");
2009 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
2010 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
2011 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2012 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2013 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2014 "ipv6-tcp-ex#ipv6-udp-ex");
2015 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
2016 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
2018 cmdline_parse_inst_t cmd_config_rss_hash_key = {
2019 .f = cmd_config_rss_hash_key_parsed,
2021 .help_str = "port config <port_id> rss-hash-key "
2022 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2023 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2024 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex "
2025 "<string of hex digits (variable length, NIC dependent)>",
2027 (void *)&cmd_config_rss_hash_key_port,
2028 (void *)&cmd_config_rss_hash_key_config,
2029 (void *)&cmd_config_rss_hash_key_port_id,
2030 (void *)&cmd_config_rss_hash_key_rss_hash_key,
2031 (void *)&cmd_config_rss_hash_key_rss_type,
2032 (void *)&cmd_config_rss_hash_key_value,
2037 /* *** configure port rxq/txq start/stop *** */
2038 struct cmd_config_rxtx_queue {
2039 cmdline_fixed_string_t port;
2041 cmdline_fixed_string_t rxtxq;
2043 cmdline_fixed_string_t opname;
2047 cmd_config_rxtx_queue_parsed(void *parsed_result,
2048 __attribute__((unused)) struct cmdline *cl,
2049 __attribute__((unused)) void *data)
2051 struct cmd_config_rxtx_queue *res = parsed_result;
2056 if (test_done == 0) {
2057 printf("Please stop forwarding first\n");
2061 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2064 if (port_is_started(res->portid) != 1) {
2065 printf("Please start port %u first\n", res->portid);
2069 if (!strcmp(res->rxtxq, "rxq"))
2071 else if (!strcmp(res->rxtxq, "txq"))
2074 printf("Unknown parameter\n");
2078 if (isrx && rx_queue_id_is_invalid(res->qid))
2080 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2083 if (!strcmp(res->opname, "start"))
2085 else if (!strcmp(res->opname, "stop"))
2088 printf("Unknown parameter\n");
2092 if (isstart && isrx)
2093 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
2094 else if (!isstart && isrx)
2095 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
2096 else if (isstart && !isrx)
2097 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
2099 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
2101 if (ret == -ENOTSUP)
2102 printf("Function not supported in PMD driver\n");
2105 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
2106 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
2107 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
2108 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT16);
2109 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
2110 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
2111 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
2112 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
2113 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
2114 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
2117 cmdline_parse_inst_t cmd_config_rxtx_queue = {
2118 .f = cmd_config_rxtx_queue_parsed,
2120 .help_str = "port <port_id> rxq|txq <queue_id> start|stop",
2122 (void *)&cmd_config_speed_all_port,
2123 (void *)&cmd_config_rxtx_queue_portid,
2124 (void *)&cmd_config_rxtx_queue_rxtxq,
2125 (void *)&cmd_config_rxtx_queue_qid,
2126 (void *)&cmd_config_rxtx_queue_opname,
2131 /* *** Configure RSS RETA *** */
2132 struct cmd_config_rss_reta {
2133 cmdline_fixed_string_t port;
2134 cmdline_fixed_string_t keyword;
2136 cmdline_fixed_string_t name;
2137 cmdline_fixed_string_t list_name;
2138 cmdline_fixed_string_t list_of_items;
2142 parse_reta_config(const char *str,
2143 struct rte_eth_rss_reta_entry64 *reta_conf,
2144 uint16_t nb_entries)
2148 uint16_t hash_index, idx, shift;
2151 const char *p, *p0 = str;
2158 unsigned long int_fld[_NUM_FLD];
2159 char *str_fld[_NUM_FLD];
2161 while ((p = strchr(p0,'(')) != NULL) {
2163 if((p0 = strchr(p,')')) == NULL)
2167 if(size >= sizeof(s))
2170 snprintf(s, sizeof(s), "%.*s", size, p);
2171 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
2173 for (i = 0; i < _NUM_FLD; i++) {
2175 int_fld[i] = strtoul(str_fld[i], &end, 0);
2176 if (errno != 0 || end == str_fld[i] ||
2181 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
2182 nb_queue = (uint16_t)int_fld[FLD_QUEUE];
2184 if (hash_index >= nb_entries) {
2185 printf("Invalid RETA hash index=%d\n", hash_index);
2189 idx = hash_index / RTE_RETA_GROUP_SIZE;
2190 shift = hash_index % RTE_RETA_GROUP_SIZE;
2191 reta_conf[idx].mask |= (1ULL << shift);
2192 reta_conf[idx].reta[shift] = nb_queue;
2199 cmd_set_rss_reta_parsed(void *parsed_result,
2200 __attribute__((unused)) struct cmdline *cl,
2201 __attribute__((unused)) void *data)
2204 struct rte_eth_dev_info dev_info;
2205 struct rte_eth_rss_reta_entry64 reta_conf[8];
2206 struct cmd_config_rss_reta *res = parsed_result;
2208 memset(&dev_info, 0, sizeof(dev_info));
2209 rte_eth_dev_info_get(res->port_id, &dev_info);
2210 if (dev_info.reta_size == 0) {
2211 printf("Redirection table size is 0 which is "
2212 "invalid for RSS\n");
2215 printf("The reta size of port %d is %u\n",
2216 res->port_id, dev_info.reta_size);
2217 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
2218 printf("Currently do not support more than %u entries of "
2219 "redirection table\n", ETH_RSS_RETA_SIZE_512);
2223 memset(reta_conf, 0, sizeof(reta_conf));
2224 if (!strcmp(res->list_name, "reta")) {
2225 if (parse_reta_config(res->list_of_items, reta_conf,
2226 dev_info.reta_size)) {
2227 printf("Invalid RSS Redirection Table "
2228 "config entered\n");
2231 ret = rte_eth_dev_rss_reta_update(res->port_id,
2232 reta_conf, dev_info.reta_size);
2234 printf("Bad redirection table parameter, "
2235 "return code = %d \n", ret);
2239 cmdline_parse_token_string_t cmd_config_rss_reta_port =
2240 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
2241 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
2242 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
2243 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
2244 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT16);
2245 cmdline_parse_token_string_t cmd_config_rss_reta_name =
2246 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
2247 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
2248 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
2249 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
2250 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
2252 cmdline_parse_inst_t cmd_config_rss_reta = {
2253 .f = cmd_set_rss_reta_parsed,
2255 .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
2257 (void *)&cmd_config_rss_reta_port,
2258 (void *)&cmd_config_rss_reta_keyword,
2259 (void *)&cmd_config_rss_reta_port_id,
2260 (void *)&cmd_config_rss_reta_name,
2261 (void *)&cmd_config_rss_reta_list_name,
2262 (void *)&cmd_config_rss_reta_list_of_items,
2267 /* *** SHOW PORT RETA INFO *** */
2268 struct cmd_showport_reta {
2269 cmdline_fixed_string_t show;
2270 cmdline_fixed_string_t port;
2272 cmdline_fixed_string_t rss;
2273 cmdline_fixed_string_t reta;
2275 cmdline_fixed_string_t list_of_items;
2279 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
2280 uint16_t nb_entries,
2284 const char *p, *p0 = str;
2289 uint16_t num = (nb_entries + RTE_RETA_GROUP_SIZE - 1) /
2290 RTE_RETA_GROUP_SIZE;
2293 p = strchr(p0, '(');
2297 p0 = strchr(p, ')');
2301 if (size >= sizeof(s)) {
2302 printf("The string size exceeds the internal buffer size\n");
2305 snprintf(s, sizeof(s), "%.*s", size, p);
2306 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
2307 if (ret <= 0 || ret != num) {
2308 printf("The bits of masks do not match the number of "
2309 "reta entries: %u\n", num);
2312 for (i = 0; i < ret; i++)
2313 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
2319 cmd_showport_reta_parsed(void *parsed_result,
2320 __attribute__((unused)) struct cmdline *cl,
2321 __attribute__((unused)) void *data)
2323 struct cmd_showport_reta *res = parsed_result;
2324 struct rte_eth_rss_reta_entry64 reta_conf[8];
2325 struct rte_eth_dev_info dev_info;
2326 uint16_t max_reta_size;
2328 memset(&dev_info, 0, sizeof(dev_info));
2329 rte_eth_dev_info_get(res->port_id, &dev_info);
2330 max_reta_size = RTE_MIN(dev_info.reta_size, ETH_RSS_RETA_SIZE_512);
2331 if (res->size == 0 || res->size > max_reta_size) {
2332 printf("Invalid redirection table size: %u (1-%u)\n",
2333 res->size, max_reta_size);
2337 memset(reta_conf, 0, sizeof(reta_conf));
2338 if (showport_parse_reta_config(reta_conf, res->size,
2339 res->list_of_items) < 0) {
2340 printf("Invalid string: %s for reta masks\n",
2341 res->list_of_items);
2344 port_rss_reta_info(res->port_id, reta_conf, res->size);
2347 cmdline_parse_token_string_t cmd_showport_reta_show =
2348 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
2349 cmdline_parse_token_string_t cmd_showport_reta_port =
2350 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
2351 cmdline_parse_token_num_t cmd_showport_reta_port_id =
2352 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT16);
2353 cmdline_parse_token_string_t cmd_showport_reta_rss =
2354 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
2355 cmdline_parse_token_string_t cmd_showport_reta_reta =
2356 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
2357 cmdline_parse_token_num_t cmd_showport_reta_size =
2358 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16);
2359 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
2360 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
2361 list_of_items, NULL);
2363 cmdline_parse_inst_t cmd_showport_reta = {
2364 .f = cmd_showport_reta_parsed,
2366 .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
2368 (void *)&cmd_showport_reta_show,
2369 (void *)&cmd_showport_reta_port,
2370 (void *)&cmd_showport_reta_port_id,
2371 (void *)&cmd_showport_reta_rss,
2372 (void *)&cmd_showport_reta_reta,
2373 (void *)&cmd_showport_reta_size,
2374 (void *)&cmd_showport_reta_list_of_items,
2379 /* *** Show RSS hash configuration *** */
2380 struct cmd_showport_rss_hash {
2381 cmdline_fixed_string_t show;
2382 cmdline_fixed_string_t port;
2384 cmdline_fixed_string_t rss_hash;
2385 cmdline_fixed_string_t rss_type;
2386 cmdline_fixed_string_t key; /* optional argument */
2389 static void cmd_showport_rss_hash_parsed(void *parsed_result,
2390 __attribute__((unused)) struct cmdline *cl,
2393 struct cmd_showport_rss_hash *res = parsed_result;
2395 port_rss_hash_conf_show(res->port_id, res->rss_type,
2396 show_rss_key != NULL);
2399 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
2400 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
2401 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
2402 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
2403 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
2404 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT16);
2405 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
2406 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
2408 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash_info =
2409 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_type,
2410 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2411 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2412 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2413 "ipv6-tcp-ex#ipv6-udp-ex");
2414 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
2415 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
2417 cmdline_parse_inst_t cmd_showport_rss_hash = {
2418 .f = cmd_showport_rss_hash_parsed,
2420 .help_str = "show port <port_id> rss-hash "
2421 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2422 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2423 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex",
2425 (void *)&cmd_showport_rss_hash_show,
2426 (void *)&cmd_showport_rss_hash_port,
2427 (void *)&cmd_showport_rss_hash_port_id,
2428 (void *)&cmd_showport_rss_hash_rss_hash,
2429 (void *)&cmd_showport_rss_hash_rss_hash_info,
2434 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
2435 .f = cmd_showport_rss_hash_parsed,
2437 .help_str = "show port <port_id> rss-hash "
2438 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2439 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2440 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex key",
2442 (void *)&cmd_showport_rss_hash_show,
2443 (void *)&cmd_showport_rss_hash_port,
2444 (void *)&cmd_showport_rss_hash_port_id,
2445 (void *)&cmd_showport_rss_hash_rss_hash,
2446 (void *)&cmd_showport_rss_hash_rss_hash_info,
2447 (void *)&cmd_showport_rss_hash_rss_key,
2452 /* *** Configure DCB *** */
2453 struct cmd_config_dcb {
2454 cmdline_fixed_string_t port;
2455 cmdline_fixed_string_t config;
2457 cmdline_fixed_string_t dcb;
2458 cmdline_fixed_string_t vt;
2459 cmdline_fixed_string_t vt_en;
2461 cmdline_fixed_string_t pfc;
2462 cmdline_fixed_string_t pfc_en;
2466 cmd_config_dcb_parsed(void *parsed_result,
2467 __attribute__((unused)) struct cmdline *cl,
2468 __attribute__((unused)) void *data)
2470 struct cmd_config_dcb *res = parsed_result;
2471 portid_t port_id = res->port_id;
2472 struct rte_port *port;
2476 port = &ports[port_id];
2477 /** Check if the port is not started **/
2478 if (port->port_status != RTE_PORT_STOPPED) {
2479 printf("Please stop port %d first\n", port_id);
2483 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
2484 printf("The invalid number of traffic class,"
2485 " only 4 or 8 allowed.\n");
2489 if (nb_fwd_lcores < res->num_tcs) {
2490 printf("nb_cores shouldn't be less than number of TCs.\n");
2493 if (!strncmp(res->pfc_en, "on", 2))
2498 /* DCB in VT mode */
2499 if (!strncmp(res->vt_en, "on", 2))
2500 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
2501 (enum rte_eth_nb_tcs)res->num_tcs,
2504 ret = init_port_dcb_config(port_id, DCB_ENABLED,
2505 (enum rte_eth_nb_tcs)res->num_tcs,
2510 printf("Cannot initialize network ports.\n");
2514 cmd_reconfig_device_queue(port_id, 1, 1);
2517 cmdline_parse_token_string_t cmd_config_dcb_port =
2518 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
2519 cmdline_parse_token_string_t cmd_config_dcb_config =
2520 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
2521 cmdline_parse_token_num_t cmd_config_dcb_port_id =
2522 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT16);
2523 cmdline_parse_token_string_t cmd_config_dcb_dcb =
2524 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
2525 cmdline_parse_token_string_t cmd_config_dcb_vt =
2526 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
2527 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
2528 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
2529 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
2530 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
2531 cmdline_parse_token_string_t cmd_config_dcb_pfc=
2532 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
2533 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
2534 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
2536 cmdline_parse_inst_t cmd_config_dcb = {
2537 .f = cmd_config_dcb_parsed,
2539 .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
2541 (void *)&cmd_config_dcb_port,
2542 (void *)&cmd_config_dcb_config,
2543 (void *)&cmd_config_dcb_port_id,
2544 (void *)&cmd_config_dcb_dcb,
2545 (void *)&cmd_config_dcb_vt,
2546 (void *)&cmd_config_dcb_vt_en,
2547 (void *)&cmd_config_dcb_num_tcs,
2548 (void *)&cmd_config_dcb_pfc,
2549 (void *)&cmd_config_dcb_pfc_en,
2554 /* *** configure number of packets per burst *** */
2555 struct cmd_config_burst {
2556 cmdline_fixed_string_t port;
2557 cmdline_fixed_string_t keyword;
2558 cmdline_fixed_string_t all;
2559 cmdline_fixed_string_t name;
2564 cmd_config_burst_parsed(void *parsed_result,
2565 __attribute__((unused)) struct cmdline *cl,
2566 __attribute__((unused)) void *data)
2568 struct cmd_config_burst *res = parsed_result;
2570 if (!all_ports_stopped()) {
2571 printf("Please stop all ports first\n");
2575 if (!strcmp(res->name, "burst")) {
2576 if (res->value < 1 || res->value > MAX_PKT_BURST) {
2577 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
2580 nb_pkt_per_burst = res->value;
2582 printf("Unknown parameter\n");
2588 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2591 cmdline_parse_token_string_t cmd_config_burst_port =
2592 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
2593 cmdline_parse_token_string_t cmd_config_burst_keyword =
2594 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
2595 cmdline_parse_token_string_t cmd_config_burst_all =
2596 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
2597 cmdline_parse_token_string_t cmd_config_burst_name =
2598 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
2599 cmdline_parse_token_num_t cmd_config_burst_value =
2600 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
2602 cmdline_parse_inst_t cmd_config_burst = {
2603 .f = cmd_config_burst_parsed,
2605 .help_str = "port config all burst <value>",
2607 (void *)&cmd_config_burst_port,
2608 (void *)&cmd_config_burst_keyword,
2609 (void *)&cmd_config_burst_all,
2610 (void *)&cmd_config_burst_name,
2611 (void *)&cmd_config_burst_value,
2616 /* *** configure rx/tx queues *** */
2617 struct cmd_config_thresh {
2618 cmdline_fixed_string_t port;
2619 cmdline_fixed_string_t keyword;
2620 cmdline_fixed_string_t all;
2621 cmdline_fixed_string_t name;
2626 cmd_config_thresh_parsed(void *parsed_result,
2627 __attribute__((unused)) struct cmdline *cl,
2628 __attribute__((unused)) void *data)
2630 struct cmd_config_thresh *res = parsed_result;
2632 if (!all_ports_stopped()) {
2633 printf("Please stop all ports first\n");
2637 if (!strcmp(res->name, "txpt"))
2638 tx_pthresh = res->value;
2639 else if(!strcmp(res->name, "txht"))
2640 tx_hthresh = res->value;
2641 else if(!strcmp(res->name, "txwt"))
2642 tx_wthresh = res->value;
2643 else if(!strcmp(res->name, "rxpt"))
2644 rx_pthresh = res->value;
2645 else if(!strcmp(res->name, "rxht"))
2646 rx_hthresh = res->value;
2647 else if(!strcmp(res->name, "rxwt"))
2648 rx_wthresh = res->value;
2650 printf("Unknown parameter\n");
2656 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2659 cmdline_parse_token_string_t cmd_config_thresh_port =
2660 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
2661 cmdline_parse_token_string_t cmd_config_thresh_keyword =
2662 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
2663 cmdline_parse_token_string_t cmd_config_thresh_all =
2664 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
2665 cmdline_parse_token_string_t cmd_config_thresh_name =
2666 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
2667 "txpt#txht#txwt#rxpt#rxht#rxwt");
2668 cmdline_parse_token_num_t cmd_config_thresh_value =
2669 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
2671 cmdline_parse_inst_t cmd_config_thresh = {
2672 .f = cmd_config_thresh_parsed,
2674 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
2676 (void *)&cmd_config_thresh_port,
2677 (void *)&cmd_config_thresh_keyword,
2678 (void *)&cmd_config_thresh_all,
2679 (void *)&cmd_config_thresh_name,
2680 (void *)&cmd_config_thresh_value,
2685 /* *** configure free/rs threshold *** */
2686 struct cmd_config_threshold {
2687 cmdline_fixed_string_t port;
2688 cmdline_fixed_string_t keyword;
2689 cmdline_fixed_string_t all;
2690 cmdline_fixed_string_t name;
2695 cmd_config_threshold_parsed(void *parsed_result,
2696 __attribute__((unused)) struct cmdline *cl,
2697 __attribute__((unused)) void *data)
2699 struct cmd_config_threshold *res = parsed_result;
2701 if (!all_ports_stopped()) {
2702 printf("Please stop all ports first\n");
2706 if (!strcmp(res->name, "txfreet"))
2707 tx_free_thresh = res->value;
2708 else if (!strcmp(res->name, "txrst"))
2709 tx_rs_thresh = res->value;
2710 else if (!strcmp(res->name, "rxfreet"))
2711 rx_free_thresh = res->value;
2713 printf("Unknown parameter\n");
2719 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2722 cmdline_parse_token_string_t cmd_config_threshold_port =
2723 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
2724 cmdline_parse_token_string_t cmd_config_threshold_keyword =
2725 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
2727 cmdline_parse_token_string_t cmd_config_threshold_all =
2728 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
2729 cmdline_parse_token_string_t cmd_config_threshold_name =
2730 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
2731 "txfreet#txrst#rxfreet");
2732 cmdline_parse_token_num_t cmd_config_threshold_value =
2733 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
2735 cmdline_parse_inst_t cmd_config_threshold = {
2736 .f = cmd_config_threshold_parsed,
2738 .help_str = "port config all txfreet|txrst|rxfreet <value>",
2740 (void *)&cmd_config_threshold_port,
2741 (void *)&cmd_config_threshold_keyword,
2742 (void *)&cmd_config_threshold_all,
2743 (void *)&cmd_config_threshold_name,
2744 (void *)&cmd_config_threshold_value,
2750 struct cmd_stop_result {
2751 cmdline_fixed_string_t stop;
2754 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
2755 __attribute__((unused)) struct cmdline *cl,
2756 __attribute__((unused)) void *data)
2758 stop_packet_forwarding();
2761 cmdline_parse_token_string_t cmd_stop_stop =
2762 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
2764 cmdline_parse_inst_t cmd_stop = {
2765 .f = cmd_stop_parsed,
2767 .help_str = "stop: Stop packet forwarding",
2769 (void *)&cmd_stop_stop,
2774 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
2777 parse_item_list(char* str, const char* item_name, unsigned int max_items,
2778 unsigned int *parsed_items, int check_unique_values)
2780 unsigned int nb_item;
2788 * First parse all items in the list and store their value.
2793 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
2795 if ((c >= '0') && (c <= '9')) {
2796 value = (unsigned int) (value * 10 + (c - '0'));
2801 printf("character %c is not a decimal digit\n", c);
2805 printf("No valid value before comma\n");
2808 if (nb_item < max_items) {
2809 parsed_items[nb_item] = value;
2815 if (nb_item >= max_items) {
2816 printf("Number of %s = %u > %u (maximum items)\n",
2817 item_name, nb_item + 1, max_items);
2820 parsed_items[nb_item++] = value;
2821 if (! check_unique_values)
2825 * Then, check that all values in the list are differents.
2826 * No optimization here...
2828 for (i = 0; i < nb_item; i++) {
2829 for (j = i + 1; j < nb_item; j++) {
2830 if (parsed_items[j] == parsed_items[i]) {
2831 printf("duplicated %s %u at index %u and %u\n",
2832 item_name, parsed_items[i], i, j);
2840 struct cmd_set_list_result {
2841 cmdline_fixed_string_t cmd_keyword;
2842 cmdline_fixed_string_t list_name;
2843 cmdline_fixed_string_t list_of_items;
2846 static void cmd_set_list_parsed(void *parsed_result,
2847 __attribute__((unused)) struct cmdline *cl,
2848 __attribute__((unused)) void *data)
2850 struct cmd_set_list_result *res;
2852 unsigned int lcorelist[RTE_MAX_LCORE];
2853 unsigned int portlist[RTE_MAX_ETHPORTS];
2855 unsigned int nb_item;
2857 if (test_done == 0) {
2858 printf("Please stop forwarding first\n");
2862 res = parsed_result;
2863 if (!strcmp(res->list_name, "corelist")) {
2864 nb_item = parse_item_list(res->list_of_items, "core",
2866 parsed_items.lcorelist, 1);
2868 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
2873 if (!strcmp(res->list_name, "portlist")) {
2874 nb_item = parse_item_list(res->list_of_items, "port",
2876 parsed_items.portlist, 1);
2878 set_fwd_ports_list(parsed_items.portlist, nb_item);
2884 cmdline_parse_token_string_t cmd_set_list_keyword =
2885 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
2887 cmdline_parse_token_string_t cmd_set_list_name =
2888 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
2889 "corelist#portlist");
2890 cmdline_parse_token_string_t cmd_set_list_of_items =
2891 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
2894 cmdline_parse_inst_t cmd_set_fwd_list = {
2895 .f = cmd_set_list_parsed,
2897 .help_str = "set corelist|portlist <list0[,list1]*>",
2899 (void *)&cmd_set_list_keyword,
2900 (void *)&cmd_set_list_name,
2901 (void *)&cmd_set_list_of_items,
2906 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
2908 struct cmd_setmask_result {
2909 cmdline_fixed_string_t set;
2910 cmdline_fixed_string_t mask;
2914 static void cmd_set_mask_parsed(void *parsed_result,
2915 __attribute__((unused)) struct cmdline *cl,
2916 __attribute__((unused)) void *data)
2918 struct cmd_setmask_result *res = parsed_result;
2920 if (test_done == 0) {
2921 printf("Please stop forwarding first\n");
2924 if (!strcmp(res->mask, "coremask")) {
2925 set_fwd_lcores_mask(res->hexavalue);
2927 } else if (!strcmp(res->mask, "portmask")) {
2928 set_fwd_ports_mask(res->hexavalue);
2933 cmdline_parse_token_string_t cmd_setmask_set =
2934 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
2935 cmdline_parse_token_string_t cmd_setmask_mask =
2936 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
2937 "coremask#portmask");
2938 cmdline_parse_token_num_t cmd_setmask_value =
2939 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
2941 cmdline_parse_inst_t cmd_set_fwd_mask = {
2942 .f = cmd_set_mask_parsed,
2944 .help_str = "set coremask|portmask <hexadecimal value>",
2946 (void *)&cmd_setmask_set,
2947 (void *)&cmd_setmask_mask,
2948 (void *)&cmd_setmask_value,
2954 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
2956 struct cmd_set_result {
2957 cmdline_fixed_string_t set;
2958 cmdline_fixed_string_t what;
2962 static void cmd_set_parsed(void *parsed_result,
2963 __attribute__((unused)) struct cmdline *cl,
2964 __attribute__((unused)) void *data)
2966 struct cmd_set_result *res = parsed_result;
2967 if (!strcmp(res->what, "nbport")) {
2968 set_fwd_ports_number(res->value);
2970 } else if (!strcmp(res->what, "nbcore")) {
2971 set_fwd_lcores_number(res->value);
2973 } else if (!strcmp(res->what, "burst"))
2974 set_nb_pkt_per_burst(res->value);
2975 else if (!strcmp(res->what, "verbose"))
2976 set_verbose_level(res->value);
2979 cmdline_parse_token_string_t cmd_set_set =
2980 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
2981 cmdline_parse_token_string_t cmd_set_what =
2982 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
2983 "nbport#nbcore#burst#verbose");
2984 cmdline_parse_token_num_t cmd_set_value =
2985 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
2987 cmdline_parse_inst_t cmd_set_numbers = {
2988 .f = cmd_set_parsed,
2990 .help_str = "set nbport|nbcore|burst|verbose <value>",
2992 (void *)&cmd_set_set,
2993 (void *)&cmd_set_what,
2994 (void *)&cmd_set_value,
2999 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
3001 struct cmd_set_txpkts_result {
3002 cmdline_fixed_string_t cmd_keyword;
3003 cmdline_fixed_string_t txpkts;
3004 cmdline_fixed_string_t seg_lengths;
3008 cmd_set_txpkts_parsed(void *parsed_result,
3009 __attribute__((unused)) struct cmdline *cl,
3010 __attribute__((unused)) void *data)
3012 struct cmd_set_txpkts_result *res;
3013 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
3014 unsigned int nb_segs;
3016 res = parsed_result;
3017 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
3018 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
3020 set_tx_pkt_segments(seg_lengths, nb_segs);
3023 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
3024 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3025 cmd_keyword, "set");
3026 cmdline_parse_token_string_t cmd_set_txpkts_name =
3027 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3029 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
3030 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3033 cmdline_parse_inst_t cmd_set_txpkts = {
3034 .f = cmd_set_txpkts_parsed,
3036 .help_str = "set txpkts <len0[,len1]*>",
3038 (void *)&cmd_set_txpkts_keyword,
3039 (void *)&cmd_set_txpkts_name,
3040 (void *)&cmd_set_txpkts_lengths,
3045 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
3047 struct cmd_set_txsplit_result {
3048 cmdline_fixed_string_t cmd_keyword;
3049 cmdline_fixed_string_t txsplit;
3050 cmdline_fixed_string_t mode;
3054 cmd_set_txsplit_parsed(void *parsed_result,
3055 __attribute__((unused)) struct cmdline *cl,
3056 __attribute__((unused)) void *data)
3058 struct cmd_set_txsplit_result *res;
3060 res = parsed_result;
3061 set_tx_pkt_split(res->mode);
3064 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
3065 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3066 cmd_keyword, "set");
3067 cmdline_parse_token_string_t cmd_set_txsplit_name =
3068 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3069 txsplit, "txsplit");
3070 cmdline_parse_token_string_t cmd_set_txsplit_mode =
3071 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3074 cmdline_parse_inst_t cmd_set_txsplit = {
3075 .f = cmd_set_txsplit_parsed,
3077 .help_str = "set txsplit on|off|rand",
3079 (void *)&cmd_set_txsplit_keyword,
3080 (void *)&cmd_set_txsplit_name,
3081 (void *)&cmd_set_txsplit_mode,
3086 /* *** CONFIG TX QUEUE FLAGS *** */
3088 struct cmd_config_txqflags_result {
3089 cmdline_fixed_string_t port;
3090 cmdline_fixed_string_t config;
3091 cmdline_fixed_string_t all;
3092 cmdline_fixed_string_t what;
3096 static void cmd_config_txqflags_parsed(void *parsed_result,
3097 __attribute__((unused)) struct cmdline *cl,
3098 __attribute__((unused)) void *data)
3100 struct cmd_config_txqflags_result *res = parsed_result;
3102 if (!all_ports_stopped()) {
3103 printf("Please stop all ports first\n");
3107 if (strcmp(res->what, "txqflags")) {
3108 printf("Unknown parameter\n");
3112 if (res->hexvalue >= 0) {
3113 txq_flags = res->hexvalue;
3115 printf("txqflags must be >= 0\n");
3121 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3124 cmdline_parse_token_string_t cmd_config_txqflags_port =
3125 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, port,
3127 cmdline_parse_token_string_t cmd_config_txqflags_config =
3128 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, config,
3130 cmdline_parse_token_string_t cmd_config_txqflags_all =
3131 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, all,
3133 cmdline_parse_token_string_t cmd_config_txqflags_what =
3134 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, what,
3136 cmdline_parse_token_num_t cmd_config_txqflags_value =
3137 TOKEN_NUM_INITIALIZER(struct cmd_config_txqflags_result,
3140 cmdline_parse_inst_t cmd_config_txqflags = {
3141 .f = cmd_config_txqflags_parsed,
3143 .help_str = "port config all txqflags <value>",
3145 (void *)&cmd_config_txqflags_port,
3146 (void *)&cmd_config_txqflags_config,
3147 (void *)&cmd_config_txqflags_all,
3148 (void *)&cmd_config_txqflags_what,
3149 (void *)&cmd_config_txqflags_value,
3154 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
3155 struct cmd_rx_vlan_filter_all_result {
3156 cmdline_fixed_string_t rx_vlan;
3157 cmdline_fixed_string_t what;
3158 cmdline_fixed_string_t all;
3163 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
3164 __attribute__((unused)) struct cmdline *cl,
3165 __attribute__((unused)) void *data)
3167 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
3169 if (!strcmp(res->what, "add"))
3170 rx_vlan_all_filter_set(res->port_id, 1);
3172 rx_vlan_all_filter_set(res->port_id, 0);
3175 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
3176 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3177 rx_vlan, "rx_vlan");
3178 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
3179 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3181 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
3182 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3184 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
3185 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3188 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
3189 .f = cmd_rx_vlan_filter_all_parsed,
3191 .help_str = "rx_vlan add|rm all <port_id>: "
3192 "Add/Remove all identifiers to/from the set of VLAN "
3193 "identifiers filtered by a port",
3195 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
3196 (void *)&cmd_rx_vlan_filter_all_what,
3197 (void *)&cmd_rx_vlan_filter_all_all,
3198 (void *)&cmd_rx_vlan_filter_all_portid,
3203 /* *** VLAN OFFLOAD SET ON A PORT *** */
3204 struct cmd_vlan_offload_result {
3205 cmdline_fixed_string_t vlan;
3206 cmdline_fixed_string_t set;
3207 cmdline_fixed_string_t vlan_type;
3208 cmdline_fixed_string_t what;
3209 cmdline_fixed_string_t on;
3210 cmdline_fixed_string_t port_id;
3214 cmd_vlan_offload_parsed(void *parsed_result,
3215 __attribute__((unused)) struct cmdline *cl,
3216 __attribute__((unused)) void *data)
3219 struct cmd_vlan_offload_result *res = parsed_result;
3222 portid_t port_id = 0;
3226 len = strnlen(str, STR_TOKEN_SIZE);
3228 /* Get port_id first */
3236 tmp = strtoul(str, NULL, 0);
3237 /* If port_id greater that what portid_t can represent, return */
3238 if(tmp >= RTE_MAX_ETHPORTS)
3240 port_id = (portid_t)tmp;
3242 if (!strcmp(res->on, "on"))
3247 if (!strcmp(res->what, "strip"))
3248 rx_vlan_strip_set(port_id, on);
3249 else if(!strcmp(res->what, "stripq")){
3250 uint16_t queue_id = 0;
3252 /* No queue_id, return */
3254 printf("must specify (port,queue_id)\n");
3257 tmp = strtoul(str + i + 1, NULL, 0);
3258 /* If queue_id greater that what 16-bits can represent, return */
3262 queue_id = (uint16_t)tmp;
3263 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
3265 else if (!strcmp(res->what, "filter"))
3266 rx_vlan_filter_set(port_id, on);
3268 vlan_extend_set(port_id, on);
3273 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
3274 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3276 cmdline_parse_token_string_t cmd_vlan_offload_set =
3277 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3279 cmdline_parse_token_string_t cmd_vlan_offload_what =
3280 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3281 what, "strip#filter#qinq#stripq");
3282 cmdline_parse_token_string_t cmd_vlan_offload_on =
3283 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3285 cmdline_parse_token_string_t cmd_vlan_offload_portid =
3286 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3289 cmdline_parse_inst_t cmd_vlan_offload = {
3290 .f = cmd_vlan_offload_parsed,
3292 .help_str = "vlan set strip|filter|qinq|stripq on|off "
3293 "<port_id[,queue_id]>: "
3294 "Filter/Strip for rx side qinq(extended) for both rx/tx sides",
3296 (void *)&cmd_vlan_offload_vlan,
3297 (void *)&cmd_vlan_offload_set,
3298 (void *)&cmd_vlan_offload_what,
3299 (void *)&cmd_vlan_offload_on,
3300 (void *)&cmd_vlan_offload_portid,
3305 /* *** VLAN TPID SET ON A PORT *** */
3306 struct cmd_vlan_tpid_result {
3307 cmdline_fixed_string_t vlan;
3308 cmdline_fixed_string_t set;
3309 cmdline_fixed_string_t vlan_type;
3310 cmdline_fixed_string_t what;
3316 cmd_vlan_tpid_parsed(void *parsed_result,
3317 __attribute__((unused)) struct cmdline *cl,
3318 __attribute__((unused)) void *data)
3320 struct cmd_vlan_tpid_result *res = parsed_result;
3321 enum rte_vlan_type vlan_type;
3323 if (!strcmp(res->vlan_type, "inner"))
3324 vlan_type = ETH_VLAN_TYPE_INNER;
3325 else if (!strcmp(res->vlan_type, "outer"))
3326 vlan_type = ETH_VLAN_TYPE_OUTER;
3328 printf("Unknown vlan type\n");
3331 vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
3334 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
3335 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3337 cmdline_parse_token_string_t cmd_vlan_tpid_set =
3338 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3340 cmdline_parse_token_string_t cmd_vlan_type =
3341 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3342 vlan_type, "inner#outer");
3343 cmdline_parse_token_string_t cmd_vlan_tpid_what =
3344 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3346 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
3347 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3349 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
3350 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3353 cmdline_parse_inst_t cmd_vlan_tpid = {
3354 .f = cmd_vlan_tpid_parsed,
3356 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
3357 "Set the VLAN Ether type",
3359 (void *)&cmd_vlan_tpid_vlan,
3360 (void *)&cmd_vlan_tpid_set,
3361 (void *)&cmd_vlan_type,
3362 (void *)&cmd_vlan_tpid_what,
3363 (void *)&cmd_vlan_tpid_tpid,
3364 (void *)&cmd_vlan_tpid_portid,
3369 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
3370 struct cmd_rx_vlan_filter_result {
3371 cmdline_fixed_string_t rx_vlan;
3372 cmdline_fixed_string_t what;
3378 cmd_rx_vlan_filter_parsed(void *parsed_result,
3379 __attribute__((unused)) struct cmdline *cl,
3380 __attribute__((unused)) void *data)
3382 struct cmd_rx_vlan_filter_result *res = parsed_result;
3384 if (!strcmp(res->what, "add"))
3385 rx_vft_set(res->port_id, res->vlan_id, 1);
3387 rx_vft_set(res->port_id, res->vlan_id, 0);
3390 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
3391 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3392 rx_vlan, "rx_vlan");
3393 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
3394 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3396 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
3397 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3399 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
3400 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3403 cmdline_parse_inst_t cmd_rx_vlan_filter = {
3404 .f = cmd_rx_vlan_filter_parsed,
3406 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
3407 "Add/Remove a VLAN identifier to/from the set of VLAN "
3408 "identifiers filtered by a port",
3410 (void *)&cmd_rx_vlan_filter_rx_vlan,
3411 (void *)&cmd_rx_vlan_filter_what,
3412 (void *)&cmd_rx_vlan_filter_vlanid,
3413 (void *)&cmd_rx_vlan_filter_portid,
3418 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3419 struct cmd_tx_vlan_set_result {
3420 cmdline_fixed_string_t tx_vlan;
3421 cmdline_fixed_string_t set;
3427 cmd_tx_vlan_set_parsed(void *parsed_result,
3428 __attribute__((unused)) struct cmdline *cl,
3429 __attribute__((unused)) void *data)
3431 struct cmd_tx_vlan_set_result *res = parsed_result;
3433 tx_vlan_set(res->port_id, res->vlan_id);
3436 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
3437 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3438 tx_vlan, "tx_vlan");
3439 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
3440 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3442 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
3443 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3445 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
3446 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3449 cmdline_parse_inst_t cmd_tx_vlan_set = {
3450 .f = cmd_tx_vlan_set_parsed,
3452 .help_str = "tx_vlan set <port_id> <vlan_id>: "
3453 "Enable hardware insertion of a single VLAN header "
3454 "with a given TAG Identifier in packets sent on a port",
3456 (void *)&cmd_tx_vlan_set_tx_vlan,
3457 (void *)&cmd_tx_vlan_set_set,
3458 (void *)&cmd_tx_vlan_set_portid,
3459 (void *)&cmd_tx_vlan_set_vlanid,
3464 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
3465 struct cmd_tx_vlan_set_qinq_result {
3466 cmdline_fixed_string_t tx_vlan;
3467 cmdline_fixed_string_t set;
3470 uint16_t vlan_id_outer;
3474 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
3475 __attribute__((unused)) struct cmdline *cl,
3476 __attribute__((unused)) void *data)
3478 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
3480 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
3483 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
3484 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3485 tx_vlan, "tx_vlan");
3486 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
3487 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3489 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
3490 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3492 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
3493 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3495 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
3496 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3497 vlan_id_outer, UINT16);
3499 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
3500 .f = cmd_tx_vlan_set_qinq_parsed,
3502 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
3503 "Enable hardware insertion of double VLAN header "
3504 "with given TAG Identifiers in packets sent on a port",
3506 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
3507 (void *)&cmd_tx_vlan_set_qinq_set,
3508 (void *)&cmd_tx_vlan_set_qinq_portid,
3509 (void *)&cmd_tx_vlan_set_qinq_vlanid,
3510 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
3515 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
3516 struct cmd_tx_vlan_set_pvid_result {
3517 cmdline_fixed_string_t tx_vlan;
3518 cmdline_fixed_string_t set;
3519 cmdline_fixed_string_t pvid;
3522 cmdline_fixed_string_t mode;
3526 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
3527 __attribute__((unused)) struct cmdline *cl,
3528 __attribute__((unused)) void *data)
3530 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
3532 if (strcmp(res->mode, "on") == 0)
3533 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
3535 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
3538 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
3539 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3540 tx_vlan, "tx_vlan");
3541 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
3542 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3544 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
3545 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3547 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
3548 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3550 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
3551 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3553 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
3554 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3557 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
3558 .f = cmd_tx_vlan_set_pvid_parsed,
3560 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
3562 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
3563 (void *)&cmd_tx_vlan_set_pvid_set,
3564 (void *)&cmd_tx_vlan_set_pvid_pvid,
3565 (void *)&cmd_tx_vlan_set_pvid_port_id,
3566 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
3567 (void *)&cmd_tx_vlan_set_pvid_mode,
3572 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3573 struct cmd_tx_vlan_reset_result {
3574 cmdline_fixed_string_t tx_vlan;
3575 cmdline_fixed_string_t reset;
3580 cmd_tx_vlan_reset_parsed(void *parsed_result,
3581 __attribute__((unused)) struct cmdline *cl,
3582 __attribute__((unused)) void *data)
3584 struct cmd_tx_vlan_reset_result *res = parsed_result;
3586 tx_vlan_reset(res->port_id);
3589 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
3590 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
3591 tx_vlan, "tx_vlan");
3592 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
3593 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
3595 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
3596 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
3599 cmdline_parse_inst_t cmd_tx_vlan_reset = {
3600 .f = cmd_tx_vlan_reset_parsed,
3602 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
3603 "VLAN header in packets sent on a port",
3605 (void *)&cmd_tx_vlan_reset_tx_vlan,
3606 (void *)&cmd_tx_vlan_reset_reset,
3607 (void *)&cmd_tx_vlan_reset_portid,
3613 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
3614 struct cmd_csum_result {
3615 cmdline_fixed_string_t csum;
3616 cmdline_fixed_string_t mode;
3617 cmdline_fixed_string_t proto;
3618 cmdline_fixed_string_t hwsw;
3623 csum_show(int port_id)
3625 struct rte_eth_dev_info dev_info;
3628 ol_flags = ports[port_id].tx_ol_flags;
3629 printf("Parse tunnel is %s\n",
3630 (ol_flags & TESTPMD_TX_OFFLOAD_PARSE_TUNNEL) ? "on" : "off");
3631 printf("IP checksum offload is %s\n",
3632 (ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) ? "hw" : "sw");
3633 printf("UDP checksum offload is %s\n",
3634 (ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
3635 printf("TCP checksum offload is %s\n",
3636 (ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
3637 printf("SCTP checksum offload is %s\n",
3638 (ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
3639 printf("Outer-Ip checksum offload is %s\n",
3640 (ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) ? "hw" : "sw");
3642 /* display warnings if configuration is not supported by the NIC */
3643 rte_eth_dev_info_get(port_id, &dev_info);
3644 if ((ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) &&
3645 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
3646 printf("Warning: hardware IP checksum enabled but not "
3647 "supported by port %d\n", port_id);
3649 if ((ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) &&
3650 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
3651 printf("Warning: hardware UDP checksum enabled but not "
3652 "supported by port %d\n", port_id);
3654 if ((ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) &&
3655 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
3656 printf("Warning: hardware TCP checksum enabled but not "
3657 "supported by port %d\n", port_id);
3659 if ((ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) &&
3660 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
3661 printf("Warning: hardware SCTP checksum enabled but not "
3662 "supported by port %d\n", port_id);
3664 if ((ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) &&
3665 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
3666 printf("Warning: hardware outer IP checksum enabled but not "
3667 "supported by port %d\n", port_id);
3672 cmd_csum_parsed(void *parsed_result,
3673 __attribute__((unused)) struct cmdline *cl,
3674 __attribute__((unused)) void *data)
3676 struct cmd_csum_result *res = parsed_result;
3680 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
3681 printf("invalid port %d\n", res->port_id);
3685 if (!strcmp(res->mode, "set")) {
3687 if (!strcmp(res->hwsw, "hw"))
3690 if (!strcmp(res->proto, "ip")) {
3691 mask = TESTPMD_TX_OFFLOAD_IP_CKSUM;
3692 } else if (!strcmp(res->proto, "udp")) {
3693 mask = TESTPMD_TX_OFFLOAD_UDP_CKSUM;
3694 } else if (!strcmp(res->proto, "tcp")) {
3695 mask = TESTPMD_TX_OFFLOAD_TCP_CKSUM;
3696 } else if (!strcmp(res->proto, "sctp")) {
3697 mask = TESTPMD_TX_OFFLOAD_SCTP_CKSUM;
3698 } else if (!strcmp(res->proto, "outer-ip")) {
3699 mask = TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM;
3703 ports[res->port_id].tx_ol_flags |= mask;
3705 ports[res->port_id].tx_ol_flags &= (~mask);
3707 csum_show(res->port_id);
3710 cmdline_parse_token_string_t cmd_csum_csum =
3711 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3713 cmdline_parse_token_string_t cmd_csum_mode =
3714 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3716 cmdline_parse_token_string_t cmd_csum_proto =
3717 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3718 proto, "ip#tcp#udp#sctp#outer-ip");
3719 cmdline_parse_token_string_t cmd_csum_hwsw =
3720 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3722 cmdline_parse_token_num_t cmd_csum_portid =
3723 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
3726 cmdline_parse_inst_t cmd_csum_set = {
3727 .f = cmd_csum_parsed,
3729 .help_str = "csum set ip|tcp|udp|sctp|outer-ip hw|sw <port_id>: "
3730 "Enable/Disable hardware calculation of L3/L4 checksum when "
3731 "using csum forward engine",
3733 (void *)&cmd_csum_csum,
3734 (void *)&cmd_csum_mode,
3735 (void *)&cmd_csum_proto,
3736 (void *)&cmd_csum_hwsw,
3737 (void *)&cmd_csum_portid,
3742 cmdline_parse_token_string_t cmd_csum_mode_show =
3743 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3746 cmdline_parse_inst_t cmd_csum_show = {
3747 .f = cmd_csum_parsed,
3749 .help_str = "csum show <port_id>: Show checksum offload configuration",
3751 (void *)&cmd_csum_csum,
3752 (void *)&cmd_csum_mode_show,
3753 (void *)&cmd_csum_portid,
3758 /* Enable/disable tunnel parsing */
3759 struct cmd_csum_tunnel_result {
3760 cmdline_fixed_string_t csum;
3761 cmdline_fixed_string_t parse;
3762 cmdline_fixed_string_t onoff;
3767 cmd_csum_tunnel_parsed(void *parsed_result,
3768 __attribute__((unused)) struct cmdline *cl,
3769 __attribute__((unused)) void *data)
3771 struct cmd_csum_tunnel_result *res = parsed_result;
3773 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3776 if (!strcmp(res->onoff, "on"))
3777 ports[res->port_id].tx_ol_flags |=
3778 TESTPMD_TX_OFFLOAD_PARSE_TUNNEL;
3780 ports[res->port_id].tx_ol_flags &=
3781 (~TESTPMD_TX_OFFLOAD_PARSE_TUNNEL);
3783 csum_show(res->port_id);
3786 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
3787 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3789 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
3790 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3791 parse, "parse_tunnel");
3792 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
3793 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3795 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
3796 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
3799 cmdline_parse_inst_t cmd_csum_tunnel = {
3800 .f = cmd_csum_tunnel_parsed,
3802 .help_str = "csum parse_tunnel on|off <port_id>: "
3803 "Enable/Disable parsing of tunnels for csum engine",
3805 (void *)&cmd_csum_tunnel_csum,
3806 (void *)&cmd_csum_tunnel_parse,
3807 (void *)&cmd_csum_tunnel_onoff,
3808 (void *)&cmd_csum_tunnel_portid,
3813 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
3814 struct cmd_tso_set_result {
3815 cmdline_fixed_string_t tso;
3816 cmdline_fixed_string_t mode;
3822 cmd_tso_set_parsed(void *parsed_result,
3823 __attribute__((unused)) struct cmdline *cl,
3824 __attribute__((unused)) void *data)
3826 struct cmd_tso_set_result *res = parsed_result;
3827 struct rte_eth_dev_info dev_info;
3829 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3832 if (!strcmp(res->mode, "set"))
3833 ports[res->port_id].tso_segsz = res->tso_segsz;
3835 if (ports[res->port_id].tso_segsz == 0)
3836 printf("TSO for non-tunneled packets is disabled\n");
3838 printf("TSO segment size for non-tunneled packets is %d\n",
3839 ports[res->port_id].tso_segsz);
3841 /* display warnings if configuration is not supported by the NIC */
3842 rte_eth_dev_info_get(res->port_id, &dev_info);
3843 if ((ports[res->port_id].tso_segsz != 0) &&
3844 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
3845 printf("Warning: TSO enabled but not "
3846 "supported by port %d\n", res->port_id);
3850 cmdline_parse_token_string_t cmd_tso_set_tso =
3851 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3853 cmdline_parse_token_string_t cmd_tso_set_mode =
3854 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3856 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
3857 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3859 cmdline_parse_token_num_t cmd_tso_set_portid =
3860 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3863 cmdline_parse_inst_t cmd_tso_set = {
3864 .f = cmd_tso_set_parsed,
3866 .help_str = "tso set <tso_segsz> <port_id>: "
3867 "Set TSO segment size of non-tunneled packets for csum engine "
3870 (void *)&cmd_tso_set_tso,
3871 (void *)&cmd_tso_set_mode,
3872 (void *)&cmd_tso_set_tso_segsz,
3873 (void *)&cmd_tso_set_portid,
3878 cmdline_parse_token_string_t cmd_tso_show_mode =
3879 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3883 cmdline_parse_inst_t cmd_tso_show = {
3884 .f = cmd_tso_set_parsed,
3886 .help_str = "tso show <port_id>: "
3887 "Show TSO segment size of non-tunneled packets for csum engine",
3889 (void *)&cmd_tso_set_tso,
3890 (void *)&cmd_tso_show_mode,
3891 (void *)&cmd_tso_set_portid,
3896 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
3897 struct cmd_tunnel_tso_set_result {
3898 cmdline_fixed_string_t tso;
3899 cmdline_fixed_string_t mode;
3905 check_tunnel_tso_nic_support(portid_t port_id)
3907 struct rte_eth_dev_info dev_info;
3909 rte_eth_dev_info_get(port_id, &dev_info);
3910 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO))
3911 printf("Warning: TSO enabled but VXLAN TUNNEL TSO not "
3912 "supported by port %d\n", port_id);
3913 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO))
3914 printf("Warning: TSO enabled but GRE TUNNEL TSO not "
3915 "supported by port %d\n", port_id);
3916 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO))
3917 printf("Warning: TSO enabled but IPIP TUNNEL TSO not "
3918 "supported by port %d\n", port_id);
3919 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
3920 printf("Warning: TSO enabled but GENEVE TUNNEL TSO not "
3921 "supported by port %d\n", port_id);
3925 cmd_tunnel_tso_set_parsed(void *parsed_result,
3926 __attribute__((unused)) struct cmdline *cl,
3927 __attribute__((unused)) void *data)
3929 struct cmd_tunnel_tso_set_result *res = parsed_result;
3931 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3934 if (!strcmp(res->mode, "set"))
3935 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
3937 if (ports[res->port_id].tunnel_tso_segsz == 0)
3938 printf("TSO for tunneled packets is disabled\n");
3940 printf("TSO segment size for tunneled packets is %d\n",
3941 ports[res->port_id].tunnel_tso_segsz);
3943 /* Below conditions are needed to make it work:
3944 * (1) tunnel TSO is supported by the NIC;
3945 * (2) "csum parse_tunnel" must be set so that tunneled pkts
3947 * (3) for tunneled pkts with outer L3 of IPv4,
3948 * "csum set outer-ip" must be set to hw, because after tso,
3949 * total_len of outer IP header is changed, and the checksum
3950 * of outer IP header calculated by sw should be wrong; that
3951 * is not necessary for IPv6 tunneled pkts because there's no
3952 * checksum in IP header anymore.
3954 check_tunnel_tso_nic_support(res->port_id);
3956 if (!(ports[res->port_id].tx_ol_flags &
3957 TESTPMD_TX_OFFLOAD_PARSE_TUNNEL))
3958 printf("Warning: csum parse_tunnel must be set "
3959 "so that tunneled packets are recognized\n");
3960 if (!(ports[res->port_id].tx_ol_flags &
3961 TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM))
3962 printf("Warning: csum set outer-ip must be set to hw "
3963 "if outer L3 is IPv4; not necessary for IPv6\n");
3967 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
3968 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
3970 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
3971 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
3973 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
3974 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
3976 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
3977 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
3980 cmdline_parse_inst_t cmd_tunnel_tso_set = {
3981 .f = cmd_tunnel_tso_set_parsed,
3983 .help_str = "tunnel_tso set <tso_segsz> <port_id>: "
3984 "Set TSO segment size of tunneled packets for csum engine "
3987 (void *)&cmd_tunnel_tso_set_tso,
3988 (void *)&cmd_tunnel_tso_set_mode,
3989 (void *)&cmd_tunnel_tso_set_tso_segsz,
3990 (void *)&cmd_tunnel_tso_set_portid,
3995 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
3996 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4000 cmdline_parse_inst_t cmd_tunnel_tso_show = {
4001 .f = cmd_tunnel_tso_set_parsed,
4003 .help_str = "tunnel_tso show <port_id> "
4004 "Show TSO segment size of tunneled packets for csum engine",
4006 (void *)&cmd_tunnel_tso_set_tso,
4007 (void *)&cmd_tunnel_tso_show_mode,
4008 (void *)&cmd_tunnel_tso_set_portid,
4013 /* *** SET GRO FOR A PORT *** */
4014 struct cmd_gro_enable_result {
4015 cmdline_fixed_string_t cmd_set;
4016 cmdline_fixed_string_t cmd_port;
4017 cmdline_fixed_string_t cmd_keyword;
4018 cmdline_fixed_string_t cmd_onoff;
4023 cmd_gro_enable_parsed(void *parsed_result,
4024 __attribute__((unused)) struct cmdline *cl,
4025 __attribute__((unused)) void *data)
4027 struct cmd_gro_enable_result *res;
4029 res = parsed_result;
4030 if (!strcmp(res->cmd_keyword, "gro"))
4031 setup_gro(res->cmd_onoff, res->cmd_pid);
4034 cmdline_parse_token_string_t cmd_gro_enable_set =
4035 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4037 cmdline_parse_token_string_t cmd_gro_enable_port =
4038 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4039 cmd_keyword, "port");
4040 cmdline_parse_token_num_t cmd_gro_enable_pid =
4041 TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result,
4043 cmdline_parse_token_string_t cmd_gro_enable_keyword =
4044 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4045 cmd_keyword, "gro");
4046 cmdline_parse_token_string_t cmd_gro_enable_onoff =
4047 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4048 cmd_onoff, "on#off");
4050 cmdline_parse_inst_t cmd_gro_enable = {
4051 .f = cmd_gro_enable_parsed,
4053 .help_str = "set port <port_id> gro on|off",
4055 (void *)&cmd_gro_enable_set,
4056 (void *)&cmd_gro_enable_port,
4057 (void *)&cmd_gro_enable_pid,
4058 (void *)&cmd_gro_enable_keyword,
4059 (void *)&cmd_gro_enable_onoff,
4064 /* *** DISPLAY GRO CONFIGURATION *** */
4065 struct cmd_gro_show_result {
4066 cmdline_fixed_string_t cmd_show;
4067 cmdline_fixed_string_t cmd_port;
4068 cmdline_fixed_string_t cmd_keyword;
4073 cmd_gro_show_parsed(void *parsed_result,
4074 __attribute__((unused)) struct cmdline *cl,
4075 __attribute__((unused)) void *data)
4077 struct cmd_gro_show_result *res;
4079 res = parsed_result;
4080 if (!strcmp(res->cmd_keyword, "gro"))
4081 show_gro(res->cmd_pid);
4084 cmdline_parse_token_string_t cmd_gro_show_show =
4085 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4087 cmdline_parse_token_string_t cmd_gro_show_port =
4088 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4090 cmdline_parse_token_num_t cmd_gro_show_pid =
4091 TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result,
4093 cmdline_parse_token_string_t cmd_gro_show_keyword =
4094 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4095 cmd_keyword, "gro");
4097 cmdline_parse_inst_t cmd_gro_show = {
4098 .f = cmd_gro_show_parsed,
4100 .help_str = "show port <port_id> gro",
4102 (void *)&cmd_gro_show_show,
4103 (void *)&cmd_gro_show_port,
4104 (void *)&cmd_gro_show_pid,
4105 (void *)&cmd_gro_show_keyword,
4110 /* *** SET FLUSH CYCLES FOR GRO *** */
4111 struct cmd_gro_flush_result {
4112 cmdline_fixed_string_t cmd_set;
4113 cmdline_fixed_string_t cmd_keyword;
4114 cmdline_fixed_string_t cmd_flush;
4119 cmd_gro_flush_parsed(void *parsed_result,
4120 __attribute__((unused)) struct cmdline *cl,
4121 __attribute__((unused)) void *data)
4123 struct cmd_gro_flush_result *res;
4125 res = parsed_result;
4126 if ((!strcmp(res->cmd_keyword, "gro")) &&
4127 (!strcmp(res->cmd_flush, "flush")))
4128 setup_gro_flush_cycles(res->cmd_cycles);
4131 cmdline_parse_token_string_t cmd_gro_flush_set =
4132 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4134 cmdline_parse_token_string_t cmd_gro_flush_keyword =
4135 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4136 cmd_keyword, "gro");
4137 cmdline_parse_token_string_t cmd_gro_flush_flush =
4138 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4139 cmd_flush, "flush");
4140 cmdline_parse_token_num_t cmd_gro_flush_cycles =
4141 TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result,
4144 cmdline_parse_inst_t cmd_gro_flush = {
4145 .f = cmd_gro_flush_parsed,
4147 .help_str = "set gro flush <cycles>",
4149 (void *)&cmd_gro_flush_set,
4150 (void *)&cmd_gro_flush_keyword,
4151 (void *)&cmd_gro_flush_flush,
4152 (void *)&cmd_gro_flush_cycles,
4157 /* *** ENABLE/DISABLE GSO *** */
4158 struct cmd_gso_enable_result {
4159 cmdline_fixed_string_t cmd_set;
4160 cmdline_fixed_string_t cmd_port;
4161 cmdline_fixed_string_t cmd_keyword;
4162 cmdline_fixed_string_t cmd_mode;
4167 cmd_gso_enable_parsed(void *parsed_result,
4168 __attribute__((unused)) struct cmdline *cl,
4169 __attribute__((unused)) void *data)
4171 struct cmd_gso_enable_result *res;
4173 res = parsed_result;
4174 if (!strcmp(res->cmd_keyword, "gso"))
4175 setup_gso(res->cmd_mode, res->cmd_pid);
4178 cmdline_parse_token_string_t cmd_gso_enable_set =
4179 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4181 cmdline_parse_token_string_t cmd_gso_enable_port =
4182 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4184 cmdline_parse_token_string_t cmd_gso_enable_keyword =
4185 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4186 cmd_keyword, "gso");
4187 cmdline_parse_token_string_t cmd_gso_enable_mode =
4188 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4189 cmd_mode, "on#off");
4190 cmdline_parse_token_num_t cmd_gso_enable_pid =
4191 TOKEN_NUM_INITIALIZER(struct cmd_gso_enable_result,
4194 cmdline_parse_inst_t cmd_gso_enable = {
4195 .f = cmd_gso_enable_parsed,
4197 .help_str = "set port <port_id> gso on|off",
4199 (void *)&cmd_gso_enable_set,
4200 (void *)&cmd_gso_enable_port,
4201 (void *)&cmd_gso_enable_pid,
4202 (void *)&cmd_gso_enable_keyword,
4203 (void *)&cmd_gso_enable_mode,
4208 /* *** SET MAX PACKET LENGTH FOR GSO SEGMENTS *** */
4209 struct cmd_gso_size_result {
4210 cmdline_fixed_string_t cmd_set;
4211 cmdline_fixed_string_t cmd_keyword;
4212 cmdline_fixed_string_t cmd_segsz;
4217 cmd_gso_size_parsed(void *parsed_result,
4218 __attribute__((unused)) struct cmdline *cl,
4219 __attribute__((unused)) void *data)
4221 struct cmd_gso_size_result *res = parsed_result;
4223 if (test_done == 0) {
4224 printf("Before setting GSO segsz, please first"
4225 " stop fowarding\n");
4229 if (!strcmp(res->cmd_keyword, "gso") &&
4230 !strcmp(res->cmd_segsz, "segsz")) {
4231 if (res->cmd_size < RTE_GSO_SEG_SIZE_MIN)
4232 printf("gso_size should be larger than %zu."
4233 " Please input a legal value\n",
4234 RTE_GSO_SEG_SIZE_MIN);
4236 gso_max_segment_size = res->cmd_size;
4240 cmdline_parse_token_string_t cmd_gso_size_set =
4241 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
4243 cmdline_parse_token_string_t cmd_gso_size_keyword =
4244 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
4245 cmd_keyword, "gso");
4246 cmdline_parse_token_string_t cmd_gso_size_segsz =
4247 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
4248 cmd_segsz, "segsz");
4249 cmdline_parse_token_num_t cmd_gso_size_size =
4250 TOKEN_NUM_INITIALIZER(struct cmd_gso_size_result,
4253 cmdline_parse_inst_t cmd_gso_size = {
4254 .f = cmd_gso_size_parsed,
4256 .help_str = "set gso segsz <length>",
4258 (void *)&cmd_gso_size_set,
4259 (void *)&cmd_gso_size_keyword,
4260 (void *)&cmd_gso_size_segsz,
4261 (void *)&cmd_gso_size_size,
4266 /* *** SHOW GSO CONFIGURATION *** */
4267 struct cmd_gso_show_result {
4268 cmdline_fixed_string_t cmd_show;
4269 cmdline_fixed_string_t cmd_port;
4270 cmdline_fixed_string_t cmd_keyword;
4275 cmd_gso_show_parsed(void *parsed_result,
4276 __attribute__((unused)) struct cmdline *cl,
4277 __attribute__((unused)) void *data)
4279 struct cmd_gso_show_result *res = parsed_result;
4281 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
4282 printf("invalid port id %u\n", res->cmd_pid);
4285 if (!strcmp(res->cmd_keyword, "gso")) {
4286 if (gso_ports[res->cmd_pid].enable) {
4287 printf("Max GSO'd packet size: %uB\n"
4288 "Supported GSO types: TCP/IPv4, "
4289 "VxLAN with inner TCP/IPv4 packet, "
4290 "GRE with inner TCP/IPv4 packet\n",
4291 gso_max_segment_size);
4293 printf("GSO is not enabled on Port %u\n", res->cmd_pid);
4297 cmdline_parse_token_string_t cmd_gso_show_show =
4298 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
4300 cmdline_parse_token_string_t cmd_gso_show_port =
4301 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
4303 cmdline_parse_token_string_t cmd_gso_show_keyword =
4304 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
4305 cmd_keyword, "gso");
4306 cmdline_parse_token_num_t cmd_gso_show_pid =
4307 TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result,
4310 cmdline_parse_inst_t cmd_gso_show = {
4311 .f = cmd_gso_show_parsed,
4313 .help_str = "show port <port_id> gso",
4315 (void *)&cmd_gso_show_show,
4316 (void *)&cmd_gso_show_port,
4317 (void *)&cmd_gso_show_pid,
4318 (void *)&cmd_gso_show_keyword,
4323 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
4324 struct cmd_set_flush_rx {
4325 cmdline_fixed_string_t set;
4326 cmdline_fixed_string_t flush_rx;
4327 cmdline_fixed_string_t mode;
4331 cmd_set_flush_rx_parsed(void *parsed_result,
4332 __attribute__((unused)) struct cmdline *cl,
4333 __attribute__((unused)) void *data)
4335 struct cmd_set_flush_rx *res = parsed_result;
4336 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
4339 cmdline_parse_token_string_t cmd_setflushrx_set =
4340 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
4342 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
4343 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
4344 flush_rx, "flush_rx");
4345 cmdline_parse_token_string_t cmd_setflushrx_mode =
4346 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
4350 cmdline_parse_inst_t cmd_set_flush_rx = {
4351 .f = cmd_set_flush_rx_parsed,
4352 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
4355 (void *)&cmd_setflushrx_set,
4356 (void *)&cmd_setflushrx_flush_rx,
4357 (void *)&cmd_setflushrx_mode,
4362 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
4363 struct cmd_set_link_check {
4364 cmdline_fixed_string_t set;
4365 cmdline_fixed_string_t link_check;
4366 cmdline_fixed_string_t mode;
4370 cmd_set_link_check_parsed(void *parsed_result,
4371 __attribute__((unused)) struct cmdline *cl,
4372 __attribute__((unused)) void *data)
4374 struct cmd_set_link_check *res = parsed_result;
4375 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
4378 cmdline_parse_token_string_t cmd_setlinkcheck_set =
4379 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
4381 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
4382 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
4383 link_check, "link_check");
4384 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
4385 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
4389 cmdline_parse_inst_t cmd_set_link_check = {
4390 .f = cmd_set_link_check_parsed,
4391 .help_str = "set link_check on|off: Enable/Disable link status check "
4392 "when starting/stopping a port",
4395 (void *)&cmd_setlinkcheck_set,
4396 (void *)&cmd_setlinkcheck_link_check,
4397 (void *)&cmd_setlinkcheck_mode,
4402 /* *** SET NIC BYPASS MODE *** */
4403 struct cmd_set_bypass_mode_result {
4404 cmdline_fixed_string_t set;
4405 cmdline_fixed_string_t bypass;
4406 cmdline_fixed_string_t mode;
4407 cmdline_fixed_string_t value;
4412 cmd_set_bypass_mode_parsed(void *parsed_result,
4413 __attribute__((unused)) struct cmdline *cl,
4414 __attribute__((unused)) void *data)
4416 struct cmd_set_bypass_mode_result *res = parsed_result;
4417 portid_t port_id = res->port_id;
4418 int32_t rc = -EINVAL;
4420 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4421 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4423 if (!strcmp(res->value, "bypass"))
4424 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
4425 else if (!strcmp(res->value, "isolate"))
4426 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
4428 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4430 /* Set the bypass mode for the relevant port. */
4431 rc = rte_pmd_ixgbe_bypass_state_set(port_id, &bypass_mode);
4434 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
4437 cmdline_parse_token_string_t cmd_setbypass_mode_set =
4438 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4440 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
4441 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4443 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
4444 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4446 cmdline_parse_token_string_t cmd_setbypass_mode_value =
4447 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4448 value, "normal#bypass#isolate");
4449 cmdline_parse_token_num_t cmd_setbypass_mode_port =
4450 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
4453 cmdline_parse_inst_t cmd_set_bypass_mode = {
4454 .f = cmd_set_bypass_mode_parsed,
4455 .help_str = "set bypass mode normal|bypass|isolate <port_id>: "
4456 "Set the NIC bypass mode for port_id",
4459 (void *)&cmd_setbypass_mode_set,
4460 (void *)&cmd_setbypass_mode_bypass,
4461 (void *)&cmd_setbypass_mode_mode,
4462 (void *)&cmd_setbypass_mode_value,
4463 (void *)&cmd_setbypass_mode_port,
4468 /* *** SET NIC BYPASS EVENT *** */
4469 struct cmd_set_bypass_event_result {
4470 cmdline_fixed_string_t set;
4471 cmdline_fixed_string_t bypass;
4472 cmdline_fixed_string_t event;
4473 cmdline_fixed_string_t event_value;
4474 cmdline_fixed_string_t mode;
4475 cmdline_fixed_string_t mode_value;
4480 cmd_set_bypass_event_parsed(void *parsed_result,
4481 __attribute__((unused)) struct cmdline *cl,
4482 __attribute__((unused)) void *data)
4484 int32_t rc = -EINVAL;
4485 struct cmd_set_bypass_event_result *res = parsed_result;
4486 portid_t port_id = res->port_id;
4488 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4489 uint32_t bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
4490 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4492 if (!strcmp(res->event_value, "timeout"))
4493 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT;
4494 else if (!strcmp(res->event_value, "os_on"))
4495 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_ON;
4496 else if (!strcmp(res->event_value, "os_off"))
4497 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_OFF;
4498 else if (!strcmp(res->event_value, "power_on"))
4499 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_ON;
4500 else if (!strcmp(res->event_value, "power_off"))
4501 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_OFF;
4503 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
4505 if (!strcmp(res->mode_value, "bypass"))
4506 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
4507 else if (!strcmp(res->mode_value, "isolate"))
4508 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
4510 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4512 /* Set the watchdog timeout. */
4513 if (bypass_event == RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT) {
4516 if (RTE_PMD_IXGBE_BYPASS_TMT_VALID(bypass_timeout)) {
4517 rc = rte_pmd_ixgbe_bypass_wd_timeout_store(port_id,
4521 printf("Failed to set timeout value %u "
4522 "for port %d, errto code: %d.\n",
4523 bypass_timeout, port_id, rc);
4527 /* Set the bypass event to transition to bypass mode. */
4528 rc = rte_pmd_ixgbe_bypass_event_store(port_id, bypass_event,
4533 printf("\t Failed to set bypass event for port = %d.\n",
4537 cmdline_parse_token_string_t cmd_setbypass_event_set =
4538 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4540 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
4541 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4543 cmdline_parse_token_string_t cmd_setbypass_event_event =
4544 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4546 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
4547 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4548 event_value, "none#timeout#os_off#os_on#power_on#power_off");
4549 cmdline_parse_token_string_t cmd_setbypass_event_mode =
4550 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4552 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
4553 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4554 mode_value, "normal#bypass#isolate");
4555 cmdline_parse_token_num_t cmd_setbypass_event_port =
4556 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
4559 cmdline_parse_inst_t cmd_set_bypass_event = {
4560 .f = cmd_set_bypass_event_parsed,
4561 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
4562 "power_off mode normal|bypass|isolate <port_id>: "
4563 "Set the NIC bypass event mode for port_id",
4566 (void *)&cmd_setbypass_event_set,
4567 (void *)&cmd_setbypass_event_bypass,
4568 (void *)&cmd_setbypass_event_event,
4569 (void *)&cmd_setbypass_event_event_value,
4570 (void *)&cmd_setbypass_event_mode,
4571 (void *)&cmd_setbypass_event_mode_value,
4572 (void *)&cmd_setbypass_event_port,
4578 /* *** SET NIC BYPASS TIMEOUT *** */
4579 struct cmd_set_bypass_timeout_result {
4580 cmdline_fixed_string_t set;
4581 cmdline_fixed_string_t bypass;
4582 cmdline_fixed_string_t timeout;
4583 cmdline_fixed_string_t value;
4587 cmd_set_bypass_timeout_parsed(void *parsed_result,
4588 __attribute__((unused)) struct cmdline *cl,
4589 __attribute__((unused)) void *data)
4591 __rte_unused struct cmd_set_bypass_timeout_result *res = parsed_result;
4593 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4594 if (!strcmp(res->value, "1.5"))
4595 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_1_5_SEC;
4596 else if (!strcmp(res->value, "2"))
4597 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_2_SEC;
4598 else if (!strcmp(res->value, "3"))
4599 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_3_SEC;
4600 else if (!strcmp(res->value, "4"))
4601 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_4_SEC;
4602 else if (!strcmp(res->value, "8"))
4603 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_8_SEC;
4604 else if (!strcmp(res->value, "16"))
4605 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_16_SEC;
4606 else if (!strcmp(res->value, "32"))
4607 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_32_SEC;
4609 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
4613 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
4614 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4616 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
4617 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4619 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
4620 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4621 timeout, "timeout");
4622 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
4623 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4624 value, "0#1.5#2#3#4#8#16#32");
4626 cmdline_parse_inst_t cmd_set_bypass_timeout = {
4627 .f = cmd_set_bypass_timeout_parsed,
4628 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
4629 "Set the NIC bypass watchdog timeout in seconds",
4632 (void *)&cmd_setbypass_timeout_set,
4633 (void *)&cmd_setbypass_timeout_bypass,
4634 (void *)&cmd_setbypass_timeout_timeout,
4635 (void *)&cmd_setbypass_timeout_value,
4640 /* *** SHOW NIC BYPASS MODE *** */
4641 struct cmd_show_bypass_config_result {
4642 cmdline_fixed_string_t show;
4643 cmdline_fixed_string_t bypass;
4644 cmdline_fixed_string_t config;
4649 cmd_show_bypass_config_parsed(void *parsed_result,
4650 __attribute__((unused)) struct cmdline *cl,
4651 __attribute__((unused)) void *data)
4653 struct cmd_show_bypass_config_result *res = parsed_result;
4654 portid_t port_id = res->port_id;
4656 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4657 uint32_t event_mode;
4658 uint32_t bypass_mode;
4659 uint32_t timeout = bypass_timeout;
4662 static const char * const timeouts[RTE_PMD_IXGBE_BYPASS_TMT_NUM] =
4663 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
4664 static const char * const modes[RTE_PMD_IXGBE_BYPASS_MODE_NUM] =
4665 {"UNKNOWN", "normal", "bypass", "isolate"};
4666 static const char * const events[RTE_PMD_IXGBE_BYPASS_EVENT_NUM] = {
4673 int num_events = (sizeof events) / (sizeof events[0]);
4675 /* Display the bypass mode.*/
4676 if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) != 0) {
4677 printf("\tFailed to get bypass mode for port = %d\n", port_id);
4681 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(bypass_mode))
4682 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
4684 printf("\tbypass mode = %s\n", modes[bypass_mode]);
4687 /* Display the bypass timeout.*/
4688 if (!RTE_PMD_IXGBE_BYPASS_TMT_VALID(timeout))
4689 timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
4691 printf("\tbypass timeout = %s\n", timeouts[timeout]);
4693 /* Display the bypass events and associated modes. */
4694 for (i = RTE_PMD_IXGBE_BYPASS_EVENT_START; i < num_events; i++) {
4696 if (rte_pmd_ixgbe_bypass_event_show(port_id, i, &event_mode)) {
4697 printf("\tFailed to get bypass mode for event = %s\n",
4700 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(event_mode))
4701 event_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
4703 printf("\tbypass event: %-16s = %s\n", events[i],
4709 printf("\tFailed to get bypass configuration for port = %d\n",
4713 cmdline_parse_token_string_t cmd_showbypass_config_show =
4714 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4716 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
4717 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4719 cmdline_parse_token_string_t cmd_showbypass_config_config =
4720 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4722 cmdline_parse_token_num_t cmd_showbypass_config_port =
4723 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
4726 cmdline_parse_inst_t cmd_show_bypass_config = {
4727 .f = cmd_show_bypass_config_parsed,
4728 .help_str = "show bypass config <port_id>: "
4729 "Show the NIC bypass config for port_id",
4732 (void *)&cmd_showbypass_config_show,
4733 (void *)&cmd_showbypass_config_bypass,
4734 (void *)&cmd_showbypass_config_config,
4735 (void *)&cmd_showbypass_config_port,
4740 #ifdef RTE_LIBRTE_PMD_BOND
4741 /* *** SET BONDING MODE *** */
4742 struct cmd_set_bonding_mode_result {
4743 cmdline_fixed_string_t set;
4744 cmdline_fixed_string_t bonding;
4745 cmdline_fixed_string_t mode;
4750 static void cmd_set_bonding_mode_parsed(void *parsed_result,
4751 __attribute__((unused)) struct cmdline *cl,
4752 __attribute__((unused)) void *data)
4754 struct cmd_set_bonding_mode_result *res = parsed_result;
4755 portid_t port_id = res->port_id;
4757 /* Set the bonding mode for the relevant port. */
4758 if (0 != rte_eth_bond_mode_set(port_id, res->value))
4759 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
4762 cmdline_parse_token_string_t cmd_setbonding_mode_set =
4763 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4765 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
4766 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4767 bonding, "bonding");
4768 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
4769 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4771 cmdline_parse_token_num_t cmd_setbonding_mode_value =
4772 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
4774 cmdline_parse_token_num_t cmd_setbonding_mode_port =
4775 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
4778 cmdline_parse_inst_t cmd_set_bonding_mode = {
4779 .f = cmd_set_bonding_mode_parsed,
4780 .help_str = "set bonding mode <mode_value> <port_id>: "
4781 "Set the bonding mode for port_id",
4784 (void *) &cmd_setbonding_mode_set,
4785 (void *) &cmd_setbonding_mode_bonding,
4786 (void *) &cmd_setbonding_mode_mode,
4787 (void *) &cmd_setbonding_mode_value,
4788 (void *) &cmd_setbonding_mode_port,
4793 /* *** SET BONDING SLOW_QUEUE SW/HW *** */
4794 struct cmd_set_bonding_lacp_dedicated_queues_result {
4795 cmdline_fixed_string_t set;
4796 cmdline_fixed_string_t bonding;
4797 cmdline_fixed_string_t lacp;
4798 cmdline_fixed_string_t dedicated_queues;
4800 cmdline_fixed_string_t mode;
4803 static void cmd_set_bonding_lacp_dedicated_queues_parsed(void *parsed_result,
4804 __attribute__((unused)) struct cmdline *cl,
4805 __attribute__((unused)) void *data)
4807 struct cmd_set_bonding_lacp_dedicated_queues_result *res = parsed_result;
4808 portid_t port_id = res->port_id;
4809 struct rte_port *port;
4811 port = &ports[port_id];
4813 /** Check if the port is not started **/
4814 if (port->port_status != RTE_PORT_STOPPED) {
4815 printf("Please stop port %d first\n", port_id);
4819 if (!strcmp(res->mode, "enable")) {
4820 if (rte_eth_bond_8023ad_dedicated_queues_enable(port_id) == 0)
4821 printf("Dedicate queues for LACP control packets"
4824 printf("Enabling dedicate queues for LACP control "
4825 "packets on port %d failed\n", port_id);
4826 } else if (!strcmp(res->mode, "disable")) {
4827 if (rte_eth_bond_8023ad_dedicated_queues_disable(port_id) == 0)
4828 printf("Dedicated queues for LACP control packets "
4831 printf("Disabling dedicated queues for LACP control "
4832 "traffic on port %d failed\n", port_id);
4836 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_set =
4837 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4839 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_bonding =
4840 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4841 bonding, "bonding");
4842 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_lacp =
4843 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4845 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_dedicated_queues =
4846 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4847 dedicated_queues, "dedicated_queues");
4848 cmdline_parse_token_num_t cmd_setbonding_lacp_dedicated_queues_port_id =
4849 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4851 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_mode =
4852 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4853 mode, "enable#disable");
4855 cmdline_parse_inst_t cmd_set_lacp_dedicated_queues = {
4856 .f = cmd_set_bonding_lacp_dedicated_queues_parsed,
4857 .help_str = "set bonding lacp dedicated_queues <port_id> "
4859 "Enable/disable dedicated queues for LACP control traffic for port_id",
4862 (void *)&cmd_setbonding_lacp_dedicated_queues_set,
4863 (void *)&cmd_setbonding_lacp_dedicated_queues_bonding,
4864 (void *)&cmd_setbonding_lacp_dedicated_queues_lacp,
4865 (void *)&cmd_setbonding_lacp_dedicated_queues_dedicated_queues,
4866 (void *)&cmd_setbonding_lacp_dedicated_queues_port_id,
4867 (void *)&cmd_setbonding_lacp_dedicated_queues_mode,
4872 /* *** SET BALANCE XMIT POLICY *** */
4873 struct cmd_set_bonding_balance_xmit_policy_result {
4874 cmdline_fixed_string_t set;
4875 cmdline_fixed_string_t bonding;
4876 cmdline_fixed_string_t balance_xmit_policy;
4878 cmdline_fixed_string_t policy;
4881 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
4882 __attribute__((unused)) struct cmdline *cl,
4883 __attribute__((unused)) void *data)
4885 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
4886 portid_t port_id = res->port_id;
4889 if (!strcmp(res->policy, "l2")) {
4890 policy = BALANCE_XMIT_POLICY_LAYER2;
4891 } else if (!strcmp(res->policy, "l23")) {
4892 policy = BALANCE_XMIT_POLICY_LAYER23;
4893 } else if (!strcmp(res->policy, "l34")) {
4894 policy = BALANCE_XMIT_POLICY_LAYER34;
4896 printf("\t Invalid xmit policy selection");
4900 /* Set the bonding mode for the relevant port. */
4901 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
4902 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
4907 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
4908 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4910 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
4911 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4912 bonding, "bonding");
4913 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
4914 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4915 balance_xmit_policy, "balance_xmit_policy");
4916 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
4917 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4919 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
4920 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4921 policy, "l2#l23#l34");
4923 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
4924 .f = cmd_set_bonding_balance_xmit_policy_parsed,
4925 .help_str = "set bonding balance_xmit_policy <port_id> "
4927 "Set the bonding balance_xmit_policy for port_id",
4930 (void *)&cmd_setbonding_balance_xmit_policy_set,
4931 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
4932 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
4933 (void *)&cmd_setbonding_balance_xmit_policy_port,
4934 (void *)&cmd_setbonding_balance_xmit_policy_policy,
4939 /* *** SHOW NIC BONDING CONFIGURATION *** */
4940 struct cmd_show_bonding_config_result {
4941 cmdline_fixed_string_t show;
4942 cmdline_fixed_string_t bonding;
4943 cmdline_fixed_string_t config;
4947 static void cmd_show_bonding_config_parsed(void *parsed_result,
4948 __attribute__((unused)) struct cmdline *cl,
4949 __attribute__((unused)) void *data)
4951 struct cmd_show_bonding_config_result *res = parsed_result;
4952 int bonding_mode, agg_mode;
4953 portid_t slaves[RTE_MAX_ETHPORTS];
4954 int num_slaves, num_active_slaves;
4957 portid_t port_id = res->port_id;
4959 /* Display the bonding mode.*/
4960 bonding_mode = rte_eth_bond_mode_get(port_id);
4961 if (bonding_mode < 0) {
4962 printf("\tFailed to get bonding mode for port = %d\n", port_id);
4965 printf("\tBonding mode: %d\n", bonding_mode);
4967 if (bonding_mode == BONDING_MODE_BALANCE) {
4968 int balance_xmit_policy;
4970 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
4971 if (balance_xmit_policy < 0) {
4972 printf("\tFailed to get balance xmit policy for port = %d\n",
4976 printf("\tBalance Xmit Policy: ");
4978 switch (balance_xmit_policy) {
4979 case BALANCE_XMIT_POLICY_LAYER2:
4980 printf("BALANCE_XMIT_POLICY_LAYER2");
4982 case BALANCE_XMIT_POLICY_LAYER23:
4983 printf("BALANCE_XMIT_POLICY_LAYER23");
4985 case BALANCE_XMIT_POLICY_LAYER34:
4986 printf("BALANCE_XMIT_POLICY_LAYER34");
4993 if (bonding_mode == BONDING_MODE_8023AD) {
4994 agg_mode = rte_eth_bond_8023ad_agg_selection_get(port_id);
4995 printf("\tIEEE802.3AD Aggregator Mode: ");
4998 printf("bandwidth");
5010 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
5012 if (num_slaves < 0) {
5013 printf("\tFailed to get slave list for port = %d\n", port_id);
5016 if (num_slaves > 0) {
5017 printf("\tSlaves (%d): [", num_slaves);
5018 for (i = 0; i < num_slaves - 1; i++)
5019 printf("%d ", slaves[i]);
5021 printf("%d]\n", slaves[num_slaves - 1]);
5023 printf("\tSlaves: []\n");
5027 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
5030 if (num_active_slaves < 0) {
5031 printf("\tFailed to get active slave list for port = %d\n", port_id);
5034 if (num_active_slaves > 0) {
5035 printf("\tActive Slaves (%d): [", num_active_slaves);
5036 for (i = 0; i < num_active_slaves - 1; i++)
5037 printf("%d ", slaves[i]);
5039 printf("%d]\n", slaves[num_active_slaves - 1]);
5042 printf("\tActive Slaves: []\n");
5046 primary_id = rte_eth_bond_primary_get(port_id);
5047 if (primary_id < 0) {
5048 printf("\tFailed to get primary slave for port = %d\n", port_id);
5051 printf("\tPrimary: [%d]\n", primary_id);
5055 cmdline_parse_token_string_t cmd_showbonding_config_show =
5056 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5058 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
5059 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5060 bonding, "bonding");
5061 cmdline_parse_token_string_t cmd_showbonding_config_config =
5062 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5064 cmdline_parse_token_num_t cmd_showbonding_config_port =
5065 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
5068 cmdline_parse_inst_t cmd_show_bonding_config = {
5069 .f = cmd_show_bonding_config_parsed,
5070 .help_str = "show bonding config <port_id>: "
5071 "Show the bonding config for port_id",
5074 (void *)&cmd_showbonding_config_show,
5075 (void *)&cmd_showbonding_config_bonding,
5076 (void *)&cmd_showbonding_config_config,
5077 (void *)&cmd_showbonding_config_port,
5082 /* *** SET BONDING PRIMARY *** */
5083 struct cmd_set_bonding_primary_result {
5084 cmdline_fixed_string_t set;
5085 cmdline_fixed_string_t bonding;
5086 cmdline_fixed_string_t primary;
5091 static void cmd_set_bonding_primary_parsed(void *parsed_result,
5092 __attribute__((unused)) struct cmdline *cl,
5093 __attribute__((unused)) void *data)
5095 struct cmd_set_bonding_primary_result *res = parsed_result;
5096 portid_t master_port_id = res->port_id;
5097 portid_t slave_port_id = res->slave_id;
5099 /* Set the primary slave for a bonded device. */
5100 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
5101 printf("\t Failed to set primary slave for port = %d.\n",
5108 cmdline_parse_token_string_t cmd_setbonding_primary_set =
5109 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5111 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
5112 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5113 bonding, "bonding");
5114 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
5115 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5116 primary, "primary");
5117 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
5118 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
5120 cmdline_parse_token_num_t cmd_setbonding_primary_port =
5121 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
5124 cmdline_parse_inst_t cmd_set_bonding_primary = {
5125 .f = cmd_set_bonding_primary_parsed,
5126 .help_str = "set bonding primary <slave_id> <port_id>: "
5127 "Set the primary slave for port_id",
5130 (void *)&cmd_setbonding_primary_set,
5131 (void *)&cmd_setbonding_primary_bonding,
5132 (void *)&cmd_setbonding_primary_primary,
5133 (void *)&cmd_setbonding_primary_slave,
5134 (void *)&cmd_setbonding_primary_port,
5139 /* *** ADD SLAVE *** */
5140 struct cmd_add_bonding_slave_result {
5141 cmdline_fixed_string_t add;
5142 cmdline_fixed_string_t bonding;
5143 cmdline_fixed_string_t slave;
5148 static void cmd_add_bonding_slave_parsed(void *parsed_result,
5149 __attribute__((unused)) struct cmdline *cl,
5150 __attribute__((unused)) void *data)
5152 struct cmd_add_bonding_slave_result *res = parsed_result;
5153 portid_t master_port_id = res->port_id;
5154 portid_t slave_port_id = res->slave_id;
5156 /* add the slave for a bonded device. */
5157 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
5158 printf("\t Failed to add slave %d to master port = %d.\n",
5159 slave_port_id, master_port_id);
5163 set_port_slave_flag(slave_port_id);
5166 cmdline_parse_token_string_t cmd_addbonding_slave_add =
5167 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5169 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
5170 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5171 bonding, "bonding");
5172 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
5173 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5175 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
5176 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
5178 cmdline_parse_token_num_t cmd_addbonding_slave_port =
5179 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
5182 cmdline_parse_inst_t cmd_add_bonding_slave = {
5183 .f = cmd_add_bonding_slave_parsed,
5184 .help_str = "add bonding slave <slave_id> <port_id>: "
5185 "Add a slave device to a bonded device",
5188 (void *)&cmd_addbonding_slave_add,
5189 (void *)&cmd_addbonding_slave_bonding,
5190 (void *)&cmd_addbonding_slave_slave,
5191 (void *)&cmd_addbonding_slave_slaveid,
5192 (void *)&cmd_addbonding_slave_port,
5197 /* *** REMOVE SLAVE *** */
5198 struct cmd_remove_bonding_slave_result {
5199 cmdline_fixed_string_t remove;
5200 cmdline_fixed_string_t bonding;
5201 cmdline_fixed_string_t slave;
5206 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
5207 __attribute__((unused)) struct cmdline *cl,
5208 __attribute__((unused)) void *data)
5210 struct cmd_remove_bonding_slave_result *res = parsed_result;
5211 portid_t master_port_id = res->port_id;
5212 portid_t slave_port_id = res->slave_id;
5214 /* remove the slave from a bonded device. */
5215 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
5216 printf("\t Failed to remove slave %d from master port = %d.\n",
5217 slave_port_id, master_port_id);
5221 clear_port_slave_flag(slave_port_id);
5224 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
5225 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
5227 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
5228 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
5229 bonding, "bonding");
5230 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
5231 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
5233 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
5234 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
5236 cmdline_parse_token_num_t cmd_removebonding_slave_port =
5237 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
5240 cmdline_parse_inst_t cmd_remove_bonding_slave = {
5241 .f = cmd_remove_bonding_slave_parsed,
5242 .help_str = "remove bonding slave <slave_id> <port_id>: "
5243 "Remove a slave device from a bonded device",
5246 (void *)&cmd_removebonding_slave_remove,
5247 (void *)&cmd_removebonding_slave_bonding,
5248 (void *)&cmd_removebonding_slave_slave,
5249 (void *)&cmd_removebonding_slave_slaveid,
5250 (void *)&cmd_removebonding_slave_port,
5255 /* *** CREATE BONDED DEVICE *** */
5256 struct cmd_create_bonded_device_result {
5257 cmdline_fixed_string_t create;
5258 cmdline_fixed_string_t bonded;
5259 cmdline_fixed_string_t device;
5264 static int bond_dev_num = 0;
5266 static void cmd_create_bonded_device_parsed(void *parsed_result,
5267 __attribute__((unused)) struct cmdline *cl,
5268 __attribute__((unused)) void *data)
5270 struct cmd_create_bonded_device_result *res = parsed_result;
5271 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
5274 if (test_done == 0) {
5275 printf("Please stop forwarding first\n");
5279 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bonding_testpmd_%d",
5282 /* Create a new bonded device. */
5283 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
5285 printf("\t Failed to create bonded device.\n");
5288 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
5291 /* Update number of ports */
5292 nb_ports = rte_eth_dev_count();
5293 reconfig(port_id, res->socket);
5294 rte_eth_promiscuous_enable(port_id);
5299 cmdline_parse_token_string_t cmd_createbonded_device_create =
5300 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
5302 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
5303 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
5305 cmdline_parse_token_string_t cmd_createbonded_device_device =
5306 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
5308 cmdline_parse_token_num_t cmd_createbonded_device_mode =
5309 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
5311 cmdline_parse_token_num_t cmd_createbonded_device_socket =
5312 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
5315 cmdline_parse_inst_t cmd_create_bonded_device = {
5316 .f = cmd_create_bonded_device_parsed,
5317 .help_str = "create bonded device <mode> <socket>: "
5318 "Create a new bonded device with specific bonding mode and socket",
5321 (void *)&cmd_createbonded_device_create,
5322 (void *)&cmd_createbonded_device_bonded,
5323 (void *)&cmd_createbonded_device_device,
5324 (void *)&cmd_createbonded_device_mode,
5325 (void *)&cmd_createbonded_device_socket,
5330 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
5331 struct cmd_set_bond_mac_addr_result {
5332 cmdline_fixed_string_t set;
5333 cmdline_fixed_string_t bonding;
5334 cmdline_fixed_string_t mac_addr;
5336 struct ether_addr address;
5339 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
5340 __attribute__((unused)) struct cmdline *cl,
5341 __attribute__((unused)) void *data)
5343 struct cmd_set_bond_mac_addr_result *res = parsed_result;
5346 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
5349 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
5351 /* check the return value and print it if is < 0 */
5353 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
5356 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
5357 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
5358 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
5359 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
5361 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
5362 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
5364 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
5365 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result,
5367 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
5368 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
5370 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
5371 .f = cmd_set_bond_mac_addr_parsed,
5373 .help_str = "set bonding mac_addr <port_id> <mac_addr>",
5375 (void *)&cmd_set_bond_mac_addr_set,
5376 (void *)&cmd_set_bond_mac_addr_bonding,
5377 (void *)&cmd_set_bond_mac_addr_mac,
5378 (void *)&cmd_set_bond_mac_addr_portnum,
5379 (void *)&cmd_set_bond_mac_addr_addr,
5385 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
5386 struct cmd_set_bond_mon_period_result {
5387 cmdline_fixed_string_t set;
5388 cmdline_fixed_string_t bonding;
5389 cmdline_fixed_string_t mon_period;
5394 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
5395 __attribute__((unused)) struct cmdline *cl,
5396 __attribute__((unused)) void *data)
5398 struct cmd_set_bond_mon_period_result *res = parsed_result;
5401 if (res->port_num >= nb_ports) {
5402 printf("Port id %d must be less than %d\n", res->port_num, nb_ports);
5406 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
5408 /* check the return value and print it if is < 0 */
5410 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
5413 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
5414 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
5416 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
5417 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
5418 bonding, "bonding");
5419 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
5420 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
5421 mon_period, "mon_period");
5422 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
5423 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
5425 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
5426 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
5429 cmdline_parse_inst_t cmd_set_bond_mon_period = {
5430 .f = cmd_set_bond_mon_period_parsed,
5432 .help_str = "set bonding mon_period <port_id> <period_ms>",
5434 (void *)&cmd_set_bond_mon_period_set,
5435 (void *)&cmd_set_bond_mon_period_bonding,
5436 (void *)&cmd_set_bond_mon_period_mon_period,
5437 (void *)&cmd_set_bond_mon_period_portnum,
5438 (void *)&cmd_set_bond_mon_period_period_ms,
5445 struct cmd_set_bonding_agg_mode_policy_result {
5446 cmdline_fixed_string_t set;
5447 cmdline_fixed_string_t bonding;
5448 cmdline_fixed_string_t agg_mode;
5450 cmdline_fixed_string_t policy;
5455 cmd_set_bonding_agg_mode(void *parsed_result,
5456 __attribute__((unused)) struct cmdline *cl,
5457 __attribute__((unused)) void *data)
5459 struct cmd_set_bonding_agg_mode_policy_result *res = parsed_result;
5460 uint8_t policy = AGG_BANDWIDTH;
5462 if (res->port_num >= nb_ports) {
5463 printf("Port id %d must be less than %d\n",
5464 res->port_num, nb_ports);
5468 if (!strcmp(res->policy, "bandwidth"))
5469 policy = AGG_BANDWIDTH;
5470 else if (!strcmp(res->policy, "stable"))
5471 policy = AGG_STABLE;
5472 else if (!strcmp(res->policy, "count"))
5475 rte_eth_bond_8023ad_agg_selection_set(res->port_num, policy);
5479 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_set =
5480 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5482 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_bonding =
5483 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5484 bonding, "bonding");
5486 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_agg_mode =
5487 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5488 agg_mode, "agg_mode");
5490 cmdline_parse_token_num_t cmd_set_bonding_agg_mode_portnum =
5491 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5494 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_policy_string =
5495 TOKEN_STRING_INITIALIZER(
5496 struct cmd_set_bonding_balance_xmit_policy_result,
5497 policy, "stable#bandwidth#count");
5499 cmdline_parse_inst_t cmd_set_bonding_agg_mode_policy = {
5500 .f = cmd_set_bonding_agg_mode,
5502 .help_str = "set bonding mode IEEE802.3AD aggregator policy <port_id> <agg_name>",
5504 (void *)&cmd_set_bonding_agg_mode_set,
5505 (void *)&cmd_set_bonding_agg_mode_bonding,
5506 (void *)&cmd_set_bonding_agg_mode_agg_mode,
5507 (void *)&cmd_set_bonding_agg_mode_portnum,
5508 (void *)&cmd_set_bonding_agg_mode_policy_string,
5514 #endif /* RTE_LIBRTE_PMD_BOND */
5516 /* *** SET FORWARDING MODE *** */
5517 struct cmd_set_fwd_mode_result {
5518 cmdline_fixed_string_t set;
5519 cmdline_fixed_string_t fwd;
5520 cmdline_fixed_string_t mode;
5523 static void cmd_set_fwd_mode_parsed(void *parsed_result,
5524 __attribute__((unused)) struct cmdline *cl,
5525 __attribute__((unused)) void *data)
5527 struct cmd_set_fwd_mode_result *res = parsed_result;
5530 set_pkt_forwarding_mode(res->mode);
5533 cmdline_parse_token_string_t cmd_setfwd_set =
5534 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
5535 cmdline_parse_token_string_t cmd_setfwd_fwd =
5536 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
5537 cmdline_parse_token_string_t cmd_setfwd_mode =
5538 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
5539 "" /* defined at init */);
5541 cmdline_parse_inst_t cmd_set_fwd_mode = {
5542 .f = cmd_set_fwd_mode_parsed,
5544 .help_str = NULL, /* defined at init */
5546 (void *)&cmd_setfwd_set,
5547 (void *)&cmd_setfwd_fwd,
5548 (void *)&cmd_setfwd_mode,
5553 static void cmd_set_fwd_mode_init(void)
5556 static char token[128];
5557 static char help[256];
5558 cmdline_parse_token_string_t *token_struct;
5560 modes = list_pkt_forwarding_modes();
5561 snprintf(help, sizeof(help), "set fwd %s: "
5562 "Set packet forwarding mode", modes);
5563 cmd_set_fwd_mode.help_str = help;
5565 /* string token separator is # */
5566 for (c = token; *modes != '\0'; modes++)
5571 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
5572 token_struct->string_data.str = token;
5575 /* *** SET RETRY FORWARDING MODE *** */
5576 struct cmd_set_fwd_retry_mode_result {
5577 cmdline_fixed_string_t set;
5578 cmdline_fixed_string_t fwd;
5579 cmdline_fixed_string_t mode;
5580 cmdline_fixed_string_t retry;
5583 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
5584 __attribute__((unused)) struct cmdline *cl,
5585 __attribute__((unused)) void *data)
5587 struct cmd_set_fwd_retry_mode_result *res = parsed_result;
5590 set_pkt_forwarding_mode(res->mode);
5593 cmdline_parse_token_string_t cmd_setfwd_retry_set =
5594 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
5596 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
5597 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
5599 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
5600 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
5602 "" /* defined at init */);
5603 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
5604 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
5607 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
5608 .f = cmd_set_fwd_retry_mode_parsed,
5610 .help_str = NULL, /* defined at init */
5612 (void *)&cmd_setfwd_retry_set,
5613 (void *)&cmd_setfwd_retry_fwd,
5614 (void *)&cmd_setfwd_retry_mode,
5615 (void *)&cmd_setfwd_retry_retry,
5620 static void cmd_set_fwd_retry_mode_init(void)
5623 static char token[128];
5624 static char help[256];
5625 cmdline_parse_token_string_t *token_struct;
5627 modes = list_pkt_forwarding_retry_modes();
5628 snprintf(help, sizeof(help), "set fwd %s retry: "
5629 "Set packet forwarding mode with retry", modes);
5630 cmd_set_fwd_retry_mode.help_str = help;
5632 /* string token separator is # */
5633 for (c = token; *modes != '\0'; modes++)
5638 token_struct = (cmdline_parse_token_string_t *)
5639 cmd_set_fwd_retry_mode.tokens[2];
5640 token_struct->string_data.str = token;
5643 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
5644 struct cmd_set_burst_tx_retry_result {
5645 cmdline_fixed_string_t set;
5646 cmdline_fixed_string_t burst;
5647 cmdline_fixed_string_t tx;
5648 cmdline_fixed_string_t delay;
5650 cmdline_fixed_string_t retry;
5654 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
5655 __attribute__((unused)) struct cmdline *cl,
5656 __attribute__((unused)) void *data)
5658 struct cmd_set_burst_tx_retry_result *res = parsed_result;
5660 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
5661 && !strcmp(res->tx, "tx")) {
5662 if (!strcmp(res->delay, "delay"))
5663 burst_tx_delay_time = res->time;
5664 if (!strcmp(res->retry, "retry"))
5665 burst_tx_retry_num = res->retry_num;
5670 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
5671 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
5672 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
5673 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
5675 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
5676 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
5677 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
5678 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
5679 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
5680 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
5681 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
5682 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
5683 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
5684 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
5686 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
5687 .f = cmd_set_burst_tx_retry_parsed,
5688 .help_str = "set burst tx delay <delay_usec> retry <num_retry>",
5690 (void *)&cmd_set_burst_tx_retry_set,
5691 (void *)&cmd_set_burst_tx_retry_burst,
5692 (void *)&cmd_set_burst_tx_retry_tx,
5693 (void *)&cmd_set_burst_tx_retry_delay,
5694 (void *)&cmd_set_burst_tx_retry_time,
5695 (void *)&cmd_set_burst_tx_retry_retry,
5696 (void *)&cmd_set_burst_tx_retry_retry_num,
5701 /* *** SET PROMISC MODE *** */
5702 struct cmd_set_promisc_mode_result {
5703 cmdline_fixed_string_t set;
5704 cmdline_fixed_string_t promisc;
5705 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
5706 uint16_t port_num; /* valid if "allports" argument == 0 */
5707 cmdline_fixed_string_t mode;
5710 static void cmd_set_promisc_mode_parsed(void *parsed_result,
5711 __attribute__((unused)) struct cmdline *cl,
5714 struct cmd_set_promisc_mode_result *res = parsed_result;
5718 if (!strcmp(res->mode, "on"))
5725 RTE_ETH_FOREACH_DEV(i) {
5727 rte_eth_promiscuous_enable(i);
5729 rte_eth_promiscuous_disable(i);
5734 rte_eth_promiscuous_enable(res->port_num);
5736 rte_eth_promiscuous_disable(res->port_num);
5740 cmdline_parse_token_string_t cmd_setpromisc_set =
5741 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
5742 cmdline_parse_token_string_t cmd_setpromisc_promisc =
5743 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
5745 cmdline_parse_token_string_t cmd_setpromisc_portall =
5746 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
5748 cmdline_parse_token_num_t cmd_setpromisc_portnum =
5749 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
5751 cmdline_parse_token_string_t cmd_setpromisc_mode =
5752 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
5755 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
5756 .f = cmd_set_promisc_mode_parsed,
5758 .help_str = "set promisc all on|off: Set promisc mode for all ports",
5760 (void *)&cmd_setpromisc_set,
5761 (void *)&cmd_setpromisc_promisc,
5762 (void *)&cmd_setpromisc_portall,
5763 (void *)&cmd_setpromisc_mode,
5768 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
5769 .f = cmd_set_promisc_mode_parsed,
5771 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
5773 (void *)&cmd_setpromisc_set,
5774 (void *)&cmd_setpromisc_promisc,
5775 (void *)&cmd_setpromisc_portnum,
5776 (void *)&cmd_setpromisc_mode,
5781 /* *** SET ALLMULTI MODE *** */
5782 struct cmd_set_allmulti_mode_result {
5783 cmdline_fixed_string_t set;
5784 cmdline_fixed_string_t allmulti;
5785 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
5786 uint16_t port_num; /* valid if "allports" argument == 0 */
5787 cmdline_fixed_string_t mode;
5790 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
5791 __attribute__((unused)) struct cmdline *cl,
5794 struct cmd_set_allmulti_mode_result *res = parsed_result;
5798 if (!strcmp(res->mode, "on"))
5805 RTE_ETH_FOREACH_DEV(i) {
5807 rte_eth_allmulticast_enable(i);
5809 rte_eth_allmulticast_disable(i);
5814 rte_eth_allmulticast_enable(res->port_num);
5816 rte_eth_allmulticast_disable(res->port_num);
5820 cmdline_parse_token_string_t cmd_setallmulti_set =
5821 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
5822 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
5823 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
5825 cmdline_parse_token_string_t cmd_setallmulti_portall =
5826 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
5828 cmdline_parse_token_num_t cmd_setallmulti_portnum =
5829 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
5831 cmdline_parse_token_string_t cmd_setallmulti_mode =
5832 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
5835 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
5836 .f = cmd_set_allmulti_mode_parsed,
5838 .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
5840 (void *)&cmd_setallmulti_set,
5841 (void *)&cmd_setallmulti_allmulti,
5842 (void *)&cmd_setallmulti_portall,
5843 (void *)&cmd_setallmulti_mode,
5848 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
5849 .f = cmd_set_allmulti_mode_parsed,
5851 .help_str = "set allmulti <port_id> on|off: "
5852 "Set allmulti mode on port_id",
5854 (void *)&cmd_setallmulti_set,
5855 (void *)&cmd_setallmulti_allmulti,
5856 (void *)&cmd_setallmulti_portnum,
5857 (void *)&cmd_setallmulti_mode,
5862 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
5863 struct cmd_link_flow_ctrl_set_result {
5864 cmdline_fixed_string_t set;
5865 cmdline_fixed_string_t flow_ctrl;
5866 cmdline_fixed_string_t rx;
5867 cmdline_fixed_string_t rx_lfc_mode;
5868 cmdline_fixed_string_t tx;
5869 cmdline_fixed_string_t tx_lfc_mode;
5870 cmdline_fixed_string_t mac_ctrl_frame_fwd;
5871 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
5872 cmdline_fixed_string_t autoneg_str;
5873 cmdline_fixed_string_t autoneg;
5874 cmdline_fixed_string_t hw_str;
5875 uint32_t high_water;
5876 cmdline_fixed_string_t lw_str;
5878 cmdline_fixed_string_t pt_str;
5879 uint16_t pause_time;
5880 cmdline_fixed_string_t xon_str;
5885 cmdline_parse_token_string_t cmd_lfc_set_set =
5886 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5888 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
5889 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5890 flow_ctrl, "flow_ctrl");
5891 cmdline_parse_token_string_t cmd_lfc_set_rx =
5892 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5894 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
5895 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5896 rx_lfc_mode, "on#off");
5897 cmdline_parse_token_string_t cmd_lfc_set_tx =
5898 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5900 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
5901 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5902 tx_lfc_mode, "on#off");
5903 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
5904 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5905 hw_str, "high_water");
5906 cmdline_parse_token_num_t cmd_lfc_set_high_water =
5907 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5908 high_water, UINT32);
5909 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
5910 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5911 lw_str, "low_water");
5912 cmdline_parse_token_num_t cmd_lfc_set_low_water =
5913 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5915 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
5916 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5917 pt_str, "pause_time");
5918 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
5919 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5920 pause_time, UINT16);
5921 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
5922 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5923 xon_str, "send_xon");
5924 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
5925 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5927 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
5928 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5929 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
5930 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
5931 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5932 mac_ctrl_frame_fwd_mode, "on#off");
5933 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
5934 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5935 autoneg_str, "autoneg");
5936 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
5937 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5939 cmdline_parse_token_num_t cmd_lfc_set_portid =
5940 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5943 /* forward declaration */
5945 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
5948 cmdline_parse_inst_t cmd_link_flow_control_set = {
5949 .f = cmd_link_flow_ctrl_set_parsed,
5951 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
5952 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
5953 "autoneg on|off <port_id>: Configure the Ethernet flow control",
5955 (void *)&cmd_lfc_set_set,
5956 (void *)&cmd_lfc_set_flow_ctrl,
5957 (void *)&cmd_lfc_set_rx,
5958 (void *)&cmd_lfc_set_rx_mode,
5959 (void *)&cmd_lfc_set_tx,
5960 (void *)&cmd_lfc_set_tx_mode,
5961 (void *)&cmd_lfc_set_high_water,
5962 (void *)&cmd_lfc_set_low_water,
5963 (void *)&cmd_lfc_set_pause_time,
5964 (void *)&cmd_lfc_set_send_xon,
5965 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
5966 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
5967 (void *)&cmd_lfc_set_autoneg_str,
5968 (void *)&cmd_lfc_set_autoneg,
5969 (void *)&cmd_lfc_set_portid,
5974 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
5975 .f = cmd_link_flow_ctrl_set_parsed,
5976 .data = (void *)&cmd_link_flow_control_set_rx,
5977 .help_str = "set flow_ctrl rx on|off <port_id>: "
5978 "Change rx flow control parameter",
5980 (void *)&cmd_lfc_set_set,
5981 (void *)&cmd_lfc_set_flow_ctrl,
5982 (void *)&cmd_lfc_set_rx,
5983 (void *)&cmd_lfc_set_rx_mode,
5984 (void *)&cmd_lfc_set_portid,
5989 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
5990 .f = cmd_link_flow_ctrl_set_parsed,
5991 .data = (void *)&cmd_link_flow_control_set_tx,
5992 .help_str = "set flow_ctrl tx on|off <port_id>: "
5993 "Change tx flow control parameter",
5995 (void *)&cmd_lfc_set_set,
5996 (void *)&cmd_lfc_set_flow_ctrl,
5997 (void *)&cmd_lfc_set_tx,
5998 (void *)&cmd_lfc_set_tx_mode,
5999 (void *)&cmd_lfc_set_portid,
6004 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
6005 .f = cmd_link_flow_ctrl_set_parsed,
6006 .data = (void *)&cmd_link_flow_control_set_hw,
6007 .help_str = "set flow_ctrl high_water <value> <port_id>: "
6008 "Change high water flow control parameter",
6010 (void *)&cmd_lfc_set_set,
6011 (void *)&cmd_lfc_set_flow_ctrl,
6012 (void *)&cmd_lfc_set_high_water_str,
6013 (void *)&cmd_lfc_set_high_water,
6014 (void *)&cmd_lfc_set_portid,
6019 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
6020 .f = cmd_link_flow_ctrl_set_parsed,
6021 .data = (void *)&cmd_link_flow_control_set_lw,
6022 .help_str = "set flow_ctrl low_water <value> <port_id>: "
6023 "Change low water flow control parameter",
6025 (void *)&cmd_lfc_set_set,
6026 (void *)&cmd_lfc_set_flow_ctrl,
6027 (void *)&cmd_lfc_set_low_water_str,
6028 (void *)&cmd_lfc_set_low_water,
6029 (void *)&cmd_lfc_set_portid,
6034 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
6035 .f = cmd_link_flow_ctrl_set_parsed,
6036 .data = (void *)&cmd_link_flow_control_set_pt,
6037 .help_str = "set flow_ctrl pause_time <value> <port_id>: "
6038 "Change pause time flow control parameter",
6040 (void *)&cmd_lfc_set_set,
6041 (void *)&cmd_lfc_set_flow_ctrl,
6042 (void *)&cmd_lfc_set_pause_time_str,
6043 (void *)&cmd_lfc_set_pause_time,
6044 (void *)&cmd_lfc_set_portid,
6049 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
6050 .f = cmd_link_flow_ctrl_set_parsed,
6051 .data = (void *)&cmd_link_flow_control_set_xon,
6052 .help_str = "set flow_ctrl send_xon <value> <port_id>: "
6053 "Change send_xon flow control parameter",
6055 (void *)&cmd_lfc_set_set,
6056 (void *)&cmd_lfc_set_flow_ctrl,
6057 (void *)&cmd_lfc_set_send_xon_str,
6058 (void *)&cmd_lfc_set_send_xon,
6059 (void *)&cmd_lfc_set_portid,
6064 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
6065 .f = cmd_link_flow_ctrl_set_parsed,
6066 .data = (void *)&cmd_link_flow_control_set_macfwd,
6067 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
6068 "Change mac ctrl fwd flow control parameter",
6070 (void *)&cmd_lfc_set_set,
6071 (void *)&cmd_lfc_set_flow_ctrl,
6072 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6073 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6074 (void *)&cmd_lfc_set_portid,
6079 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
6080 .f = cmd_link_flow_ctrl_set_parsed,
6081 .data = (void *)&cmd_link_flow_control_set_autoneg,
6082 .help_str = "set flow_ctrl autoneg on|off <port_id>: "
6083 "Change autoneg flow control parameter",
6085 (void *)&cmd_lfc_set_set,
6086 (void *)&cmd_lfc_set_flow_ctrl,
6087 (void *)&cmd_lfc_set_autoneg_str,
6088 (void *)&cmd_lfc_set_autoneg,
6089 (void *)&cmd_lfc_set_portid,
6095 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
6096 __attribute__((unused)) struct cmdline *cl,
6099 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
6100 cmdline_parse_inst_t *cmd = data;
6101 struct rte_eth_fc_conf fc_conf;
6107 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
6108 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
6109 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
6110 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
6112 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
6113 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
6116 /* Partial command line, retrieve current configuration */
6118 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
6120 printf("cannot get current flow ctrl parameters, return"
6121 "code = %d\n", ret);
6125 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
6126 (fc_conf.mode == RTE_FC_FULL))
6128 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
6129 (fc_conf.mode == RTE_FC_FULL))
6133 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
6134 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
6136 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
6137 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
6139 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
6141 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
6142 fc_conf.high_water = res->high_water;
6144 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
6145 fc_conf.low_water = res->low_water;
6147 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
6148 fc_conf.pause_time = res->pause_time;
6150 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
6151 fc_conf.send_xon = res->send_xon;
6153 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
6154 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
6155 fc_conf.mac_ctrl_frame_fwd = 1;
6157 fc_conf.mac_ctrl_frame_fwd = 0;
6160 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
6161 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
6163 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
6165 printf("bad flow contrl parameter, return code = %d \n", ret);
6168 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
6169 struct cmd_priority_flow_ctrl_set_result {
6170 cmdline_fixed_string_t set;
6171 cmdline_fixed_string_t pfc_ctrl;
6172 cmdline_fixed_string_t rx;
6173 cmdline_fixed_string_t rx_pfc_mode;
6174 cmdline_fixed_string_t tx;
6175 cmdline_fixed_string_t tx_pfc_mode;
6176 uint32_t high_water;
6178 uint16_t pause_time;
6184 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
6185 __attribute__((unused)) struct cmdline *cl,
6186 __attribute__((unused)) void *data)
6188 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
6189 struct rte_eth_pfc_conf pfc_conf;
6190 int rx_fc_enable, tx_fc_enable;
6194 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
6195 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
6196 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
6197 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
6199 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
6200 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
6203 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
6204 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
6205 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
6206 pfc_conf.fc.high_water = res->high_water;
6207 pfc_conf.fc.low_water = res->low_water;
6208 pfc_conf.fc.pause_time = res->pause_time;
6209 pfc_conf.priority = res->priority;
6211 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
6213 printf("bad priority flow contrl parameter, return code = %d \n", ret);
6216 cmdline_parse_token_string_t cmd_pfc_set_set =
6217 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6219 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
6220 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6221 pfc_ctrl, "pfc_ctrl");
6222 cmdline_parse_token_string_t cmd_pfc_set_rx =
6223 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6225 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
6226 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6227 rx_pfc_mode, "on#off");
6228 cmdline_parse_token_string_t cmd_pfc_set_tx =
6229 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6231 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
6232 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6233 tx_pfc_mode, "on#off");
6234 cmdline_parse_token_num_t cmd_pfc_set_high_water =
6235 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6236 high_water, UINT32);
6237 cmdline_parse_token_num_t cmd_pfc_set_low_water =
6238 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6240 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
6241 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6242 pause_time, UINT16);
6243 cmdline_parse_token_num_t cmd_pfc_set_priority =
6244 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6246 cmdline_parse_token_num_t cmd_pfc_set_portid =
6247 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6250 cmdline_parse_inst_t cmd_priority_flow_control_set = {
6251 .f = cmd_priority_flow_ctrl_set_parsed,
6253 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
6254 "<pause_time> <priority> <port_id>: "
6255 "Configure the Ethernet priority flow control",
6257 (void *)&cmd_pfc_set_set,
6258 (void *)&cmd_pfc_set_flow_ctrl,
6259 (void *)&cmd_pfc_set_rx,
6260 (void *)&cmd_pfc_set_rx_mode,
6261 (void *)&cmd_pfc_set_tx,
6262 (void *)&cmd_pfc_set_tx_mode,
6263 (void *)&cmd_pfc_set_high_water,
6264 (void *)&cmd_pfc_set_low_water,
6265 (void *)&cmd_pfc_set_pause_time,
6266 (void *)&cmd_pfc_set_priority,
6267 (void *)&cmd_pfc_set_portid,
6272 /* *** RESET CONFIGURATION *** */
6273 struct cmd_reset_result {
6274 cmdline_fixed_string_t reset;
6275 cmdline_fixed_string_t def;
6278 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
6280 __attribute__((unused)) void *data)
6282 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
6283 set_def_fwd_config();
6286 cmdline_parse_token_string_t cmd_reset_set =
6287 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
6288 cmdline_parse_token_string_t cmd_reset_def =
6289 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
6292 cmdline_parse_inst_t cmd_reset = {
6293 .f = cmd_reset_parsed,
6295 .help_str = "set default: Reset default forwarding configuration",
6297 (void *)&cmd_reset_set,
6298 (void *)&cmd_reset_def,
6303 /* *** START FORWARDING *** */
6304 struct cmd_start_result {
6305 cmdline_fixed_string_t start;
6308 cmdline_parse_token_string_t cmd_start_start =
6309 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
6311 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
6312 __attribute__((unused)) struct cmdline *cl,
6313 __attribute__((unused)) void *data)
6315 start_packet_forwarding(0);
6318 cmdline_parse_inst_t cmd_start = {
6319 .f = cmd_start_parsed,
6321 .help_str = "start: Start packet forwarding",
6323 (void *)&cmd_start_start,
6328 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
6329 struct cmd_start_tx_first_result {
6330 cmdline_fixed_string_t start;
6331 cmdline_fixed_string_t tx_first;
6335 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
6336 __attribute__((unused)) struct cmdline *cl,
6337 __attribute__((unused)) void *data)
6339 start_packet_forwarding(1);
6342 cmdline_parse_token_string_t cmd_start_tx_first_start =
6343 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
6345 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
6346 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
6347 tx_first, "tx_first");
6349 cmdline_parse_inst_t cmd_start_tx_first = {
6350 .f = cmd_start_tx_first_parsed,
6352 .help_str = "start tx_first: Start packet forwarding, "
6353 "after sending 1 burst of packets",
6355 (void *)&cmd_start_tx_first_start,
6356 (void *)&cmd_start_tx_first_tx_first,
6361 /* *** START FORWARDING WITH N TX BURST FIRST *** */
6362 struct cmd_start_tx_first_n_result {
6363 cmdline_fixed_string_t start;
6364 cmdline_fixed_string_t tx_first;
6369 cmd_start_tx_first_n_parsed(void *parsed_result,
6370 __attribute__((unused)) struct cmdline *cl,
6371 __attribute__((unused)) void *data)
6373 struct cmd_start_tx_first_n_result *res = parsed_result;
6375 start_packet_forwarding(res->tx_num);
6378 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
6379 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
6381 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
6382 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
6383 tx_first, "tx_first");
6384 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
6385 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
6388 cmdline_parse_inst_t cmd_start_tx_first_n = {
6389 .f = cmd_start_tx_first_n_parsed,
6391 .help_str = "start tx_first <num>: "
6392 "packet forwarding, after sending <num> bursts of packets",
6394 (void *)&cmd_start_tx_first_n_start,
6395 (void *)&cmd_start_tx_first_n_tx_first,
6396 (void *)&cmd_start_tx_first_n_tx_num,
6401 /* *** SET LINK UP *** */
6402 struct cmd_set_link_up_result {
6403 cmdline_fixed_string_t set;
6404 cmdline_fixed_string_t link_up;
6405 cmdline_fixed_string_t port;
6409 cmdline_parse_token_string_t cmd_set_link_up_set =
6410 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
6411 cmdline_parse_token_string_t cmd_set_link_up_link_up =
6412 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
6414 cmdline_parse_token_string_t cmd_set_link_up_port =
6415 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
6416 cmdline_parse_token_num_t cmd_set_link_up_port_id =
6417 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT16);
6419 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result,
6420 __attribute__((unused)) struct cmdline *cl,
6421 __attribute__((unused)) void *data)
6423 struct cmd_set_link_up_result *res = parsed_result;
6424 dev_set_link_up(res->port_id);
6427 cmdline_parse_inst_t cmd_set_link_up = {
6428 .f = cmd_set_link_up_parsed,
6430 .help_str = "set link-up port <port id>",
6432 (void *)&cmd_set_link_up_set,
6433 (void *)&cmd_set_link_up_link_up,
6434 (void *)&cmd_set_link_up_port,
6435 (void *)&cmd_set_link_up_port_id,
6440 /* *** SET LINK DOWN *** */
6441 struct cmd_set_link_down_result {
6442 cmdline_fixed_string_t set;
6443 cmdline_fixed_string_t link_down;
6444 cmdline_fixed_string_t port;
6448 cmdline_parse_token_string_t cmd_set_link_down_set =
6449 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
6450 cmdline_parse_token_string_t cmd_set_link_down_link_down =
6451 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
6453 cmdline_parse_token_string_t cmd_set_link_down_port =
6454 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
6455 cmdline_parse_token_num_t cmd_set_link_down_port_id =
6456 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT16);
6458 static void cmd_set_link_down_parsed(
6459 __attribute__((unused)) void *parsed_result,
6460 __attribute__((unused)) struct cmdline *cl,
6461 __attribute__((unused)) void *data)
6463 struct cmd_set_link_down_result *res = parsed_result;
6464 dev_set_link_down(res->port_id);
6467 cmdline_parse_inst_t cmd_set_link_down = {
6468 .f = cmd_set_link_down_parsed,
6470 .help_str = "set link-down port <port id>",
6472 (void *)&cmd_set_link_down_set,
6473 (void *)&cmd_set_link_down_link_down,
6474 (void *)&cmd_set_link_down_port,
6475 (void *)&cmd_set_link_down_port_id,
6480 /* *** SHOW CFG *** */
6481 struct cmd_showcfg_result {
6482 cmdline_fixed_string_t show;
6483 cmdline_fixed_string_t cfg;
6484 cmdline_fixed_string_t what;
6487 static void cmd_showcfg_parsed(void *parsed_result,
6488 __attribute__((unused)) struct cmdline *cl,
6489 __attribute__((unused)) void *data)
6491 struct cmd_showcfg_result *res = parsed_result;
6492 if (!strcmp(res->what, "rxtx"))
6493 rxtx_config_display();
6494 else if (!strcmp(res->what, "cores"))
6495 fwd_lcores_config_display();
6496 else if (!strcmp(res->what, "fwd"))
6497 pkt_fwd_config_display(&cur_fwd_config);
6498 else if (!strcmp(res->what, "txpkts"))
6499 show_tx_pkt_segments();
6502 cmdline_parse_token_string_t cmd_showcfg_show =
6503 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
6504 cmdline_parse_token_string_t cmd_showcfg_port =
6505 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
6506 cmdline_parse_token_string_t cmd_showcfg_what =
6507 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
6508 "rxtx#cores#fwd#txpkts");
6510 cmdline_parse_inst_t cmd_showcfg = {
6511 .f = cmd_showcfg_parsed,
6513 .help_str = "show config rxtx|cores|fwd|txpkts",
6515 (void *)&cmd_showcfg_show,
6516 (void *)&cmd_showcfg_port,
6517 (void *)&cmd_showcfg_what,
6522 /* *** SHOW ALL PORT INFO *** */
6523 struct cmd_showportall_result {
6524 cmdline_fixed_string_t show;
6525 cmdline_fixed_string_t port;
6526 cmdline_fixed_string_t what;
6527 cmdline_fixed_string_t all;
6530 static void cmd_showportall_parsed(void *parsed_result,
6531 __attribute__((unused)) struct cmdline *cl,
6532 __attribute__((unused)) void *data)
6536 struct cmd_showportall_result *res = parsed_result;
6537 if (!strcmp(res->show, "clear")) {
6538 if (!strcmp(res->what, "stats"))
6539 RTE_ETH_FOREACH_DEV(i)
6541 else if (!strcmp(res->what, "xstats"))
6542 RTE_ETH_FOREACH_DEV(i)
6543 nic_xstats_clear(i);
6544 } else if (!strcmp(res->what, "info"))
6545 RTE_ETH_FOREACH_DEV(i)
6546 port_infos_display(i);
6547 else if (!strcmp(res->what, "stats"))
6548 RTE_ETH_FOREACH_DEV(i)
6549 nic_stats_display(i);
6550 else if (!strcmp(res->what, "xstats"))
6551 RTE_ETH_FOREACH_DEV(i)
6552 nic_xstats_display(i);
6553 else if (!strcmp(res->what, "fdir"))
6554 RTE_ETH_FOREACH_DEV(i)
6556 else if (!strcmp(res->what, "stat_qmap"))
6557 RTE_ETH_FOREACH_DEV(i)
6558 nic_stats_mapping_display(i);
6559 else if (!strcmp(res->what, "dcb_tc"))
6560 RTE_ETH_FOREACH_DEV(i)
6561 port_dcb_info_display(i);
6562 else if (!strcmp(res->what, "cap"))
6563 RTE_ETH_FOREACH_DEV(i)
6564 port_offload_cap_display(i);
6567 cmdline_parse_token_string_t cmd_showportall_show =
6568 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
6570 cmdline_parse_token_string_t cmd_showportall_port =
6571 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
6572 cmdline_parse_token_string_t cmd_showportall_what =
6573 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
6574 "info#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
6575 cmdline_parse_token_string_t cmd_showportall_all =
6576 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
6577 cmdline_parse_inst_t cmd_showportall = {
6578 .f = cmd_showportall_parsed,
6580 .help_str = "show|clear port "
6581 "info|stats|xstats|fdir|stat_qmap|dcb_tc|cap all",
6583 (void *)&cmd_showportall_show,
6584 (void *)&cmd_showportall_port,
6585 (void *)&cmd_showportall_what,
6586 (void *)&cmd_showportall_all,
6591 /* *** SHOW PORT INFO *** */
6592 struct cmd_showport_result {
6593 cmdline_fixed_string_t show;
6594 cmdline_fixed_string_t port;
6595 cmdline_fixed_string_t what;
6599 static void cmd_showport_parsed(void *parsed_result,
6600 __attribute__((unused)) struct cmdline *cl,
6601 __attribute__((unused)) void *data)
6603 struct cmd_showport_result *res = parsed_result;
6604 if (!strcmp(res->show, "clear")) {
6605 if (!strcmp(res->what, "stats"))
6606 nic_stats_clear(res->portnum);
6607 else if (!strcmp(res->what, "xstats"))
6608 nic_xstats_clear(res->portnum);
6609 } else if (!strcmp(res->what, "info"))
6610 port_infos_display(res->portnum);
6611 else if (!strcmp(res->what, "stats"))
6612 nic_stats_display(res->portnum);
6613 else if (!strcmp(res->what, "xstats"))
6614 nic_xstats_display(res->portnum);
6615 else if (!strcmp(res->what, "fdir"))
6616 fdir_get_infos(res->portnum);
6617 else if (!strcmp(res->what, "stat_qmap"))
6618 nic_stats_mapping_display(res->portnum);
6619 else if (!strcmp(res->what, "dcb_tc"))
6620 port_dcb_info_display(res->portnum);
6621 else if (!strcmp(res->what, "cap"))
6622 port_offload_cap_display(res->portnum);
6625 cmdline_parse_token_string_t cmd_showport_show =
6626 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
6628 cmdline_parse_token_string_t cmd_showport_port =
6629 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
6630 cmdline_parse_token_string_t cmd_showport_what =
6631 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
6632 "info#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
6633 cmdline_parse_token_num_t cmd_showport_portnum =
6634 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT16);
6636 cmdline_parse_inst_t cmd_showport = {
6637 .f = cmd_showport_parsed,
6639 .help_str = "show|clear port "
6640 "info|stats|xstats|fdir|stat_qmap|dcb_tc|cap "
6643 (void *)&cmd_showport_show,
6644 (void *)&cmd_showport_port,
6645 (void *)&cmd_showport_what,
6646 (void *)&cmd_showport_portnum,
6651 /* *** SHOW QUEUE INFO *** */
6652 struct cmd_showqueue_result {
6653 cmdline_fixed_string_t show;
6654 cmdline_fixed_string_t type;
6655 cmdline_fixed_string_t what;
6661 cmd_showqueue_parsed(void *parsed_result,
6662 __attribute__((unused)) struct cmdline *cl,
6663 __attribute__((unused)) void *data)
6665 struct cmd_showqueue_result *res = parsed_result;
6667 if (!strcmp(res->type, "rxq"))
6668 rx_queue_infos_display(res->portnum, res->queuenum);
6669 else if (!strcmp(res->type, "txq"))
6670 tx_queue_infos_display(res->portnum, res->queuenum);
6673 cmdline_parse_token_string_t cmd_showqueue_show =
6674 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
6675 cmdline_parse_token_string_t cmd_showqueue_type =
6676 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
6677 cmdline_parse_token_string_t cmd_showqueue_what =
6678 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
6679 cmdline_parse_token_num_t cmd_showqueue_portnum =
6680 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, UINT16);
6681 cmdline_parse_token_num_t cmd_showqueue_queuenum =
6682 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, UINT16);
6684 cmdline_parse_inst_t cmd_showqueue = {
6685 .f = cmd_showqueue_parsed,
6687 .help_str = "show rxq|txq info <port_id> <queue_id>",
6689 (void *)&cmd_showqueue_show,
6690 (void *)&cmd_showqueue_type,
6691 (void *)&cmd_showqueue_what,
6692 (void *)&cmd_showqueue_portnum,
6693 (void *)&cmd_showqueue_queuenum,
6698 /* *** READ PORT REGISTER *** */
6699 struct cmd_read_reg_result {
6700 cmdline_fixed_string_t read;
6701 cmdline_fixed_string_t reg;
6707 cmd_read_reg_parsed(void *parsed_result,
6708 __attribute__((unused)) struct cmdline *cl,
6709 __attribute__((unused)) void *data)
6711 struct cmd_read_reg_result *res = parsed_result;
6712 port_reg_display(res->port_id, res->reg_off);
6715 cmdline_parse_token_string_t cmd_read_reg_read =
6716 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
6717 cmdline_parse_token_string_t cmd_read_reg_reg =
6718 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
6719 cmdline_parse_token_num_t cmd_read_reg_port_id =
6720 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT16);
6721 cmdline_parse_token_num_t cmd_read_reg_reg_off =
6722 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
6724 cmdline_parse_inst_t cmd_read_reg = {
6725 .f = cmd_read_reg_parsed,
6727 .help_str = "read reg <port_id> <reg_off>",
6729 (void *)&cmd_read_reg_read,
6730 (void *)&cmd_read_reg_reg,
6731 (void *)&cmd_read_reg_port_id,
6732 (void *)&cmd_read_reg_reg_off,
6737 /* *** READ PORT REGISTER BIT FIELD *** */
6738 struct cmd_read_reg_bit_field_result {
6739 cmdline_fixed_string_t read;
6740 cmdline_fixed_string_t regfield;
6748 cmd_read_reg_bit_field_parsed(void *parsed_result,
6749 __attribute__((unused)) struct cmdline *cl,
6750 __attribute__((unused)) void *data)
6752 struct cmd_read_reg_bit_field_result *res = parsed_result;
6753 port_reg_bit_field_display(res->port_id, res->reg_off,
6754 res->bit1_pos, res->bit2_pos);
6757 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
6758 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
6760 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
6761 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
6762 regfield, "regfield");
6763 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
6764 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
6766 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
6767 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
6769 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
6770 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
6772 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
6773 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
6776 cmdline_parse_inst_t cmd_read_reg_bit_field = {
6777 .f = cmd_read_reg_bit_field_parsed,
6779 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
6780 "Read register bit field between bit_x and bit_y included",
6782 (void *)&cmd_read_reg_bit_field_read,
6783 (void *)&cmd_read_reg_bit_field_regfield,
6784 (void *)&cmd_read_reg_bit_field_port_id,
6785 (void *)&cmd_read_reg_bit_field_reg_off,
6786 (void *)&cmd_read_reg_bit_field_bit1_pos,
6787 (void *)&cmd_read_reg_bit_field_bit2_pos,
6792 /* *** READ PORT REGISTER BIT *** */
6793 struct cmd_read_reg_bit_result {
6794 cmdline_fixed_string_t read;
6795 cmdline_fixed_string_t regbit;
6802 cmd_read_reg_bit_parsed(void *parsed_result,
6803 __attribute__((unused)) struct cmdline *cl,
6804 __attribute__((unused)) void *data)
6806 struct cmd_read_reg_bit_result *res = parsed_result;
6807 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
6810 cmdline_parse_token_string_t cmd_read_reg_bit_read =
6811 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
6812 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
6813 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
6815 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
6816 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT16);
6817 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
6818 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
6819 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
6820 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
6822 cmdline_parse_inst_t cmd_read_reg_bit = {
6823 .f = cmd_read_reg_bit_parsed,
6825 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
6827 (void *)&cmd_read_reg_bit_read,
6828 (void *)&cmd_read_reg_bit_regbit,
6829 (void *)&cmd_read_reg_bit_port_id,
6830 (void *)&cmd_read_reg_bit_reg_off,
6831 (void *)&cmd_read_reg_bit_bit_pos,
6836 /* *** WRITE PORT REGISTER *** */
6837 struct cmd_write_reg_result {
6838 cmdline_fixed_string_t write;
6839 cmdline_fixed_string_t reg;
6846 cmd_write_reg_parsed(void *parsed_result,
6847 __attribute__((unused)) struct cmdline *cl,
6848 __attribute__((unused)) void *data)
6850 struct cmd_write_reg_result *res = parsed_result;
6851 port_reg_set(res->port_id, res->reg_off, res->value);
6854 cmdline_parse_token_string_t cmd_write_reg_write =
6855 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
6856 cmdline_parse_token_string_t cmd_write_reg_reg =
6857 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
6858 cmdline_parse_token_num_t cmd_write_reg_port_id =
6859 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT16);
6860 cmdline_parse_token_num_t cmd_write_reg_reg_off =
6861 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
6862 cmdline_parse_token_num_t cmd_write_reg_value =
6863 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
6865 cmdline_parse_inst_t cmd_write_reg = {
6866 .f = cmd_write_reg_parsed,
6868 .help_str = "write reg <port_id> <reg_off> <reg_value>",
6870 (void *)&cmd_write_reg_write,
6871 (void *)&cmd_write_reg_reg,
6872 (void *)&cmd_write_reg_port_id,
6873 (void *)&cmd_write_reg_reg_off,
6874 (void *)&cmd_write_reg_value,
6879 /* *** WRITE PORT REGISTER BIT FIELD *** */
6880 struct cmd_write_reg_bit_field_result {
6881 cmdline_fixed_string_t write;
6882 cmdline_fixed_string_t regfield;
6891 cmd_write_reg_bit_field_parsed(void *parsed_result,
6892 __attribute__((unused)) struct cmdline *cl,
6893 __attribute__((unused)) void *data)
6895 struct cmd_write_reg_bit_field_result *res = parsed_result;
6896 port_reg_bit_field_set(res->port_id, res->reg_off,
6897 res->bit1_pos, res->bit2_pos, res->value);
6900 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
6901 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
6903 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
6904 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
6905 regfield, "regfield");
6906 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
6907 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
6909 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
6910 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
6912 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
6913 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
6915 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
6916 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
6918 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
6919 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
6922 cmdline_parse_inst_t cmd_write_reg_bit_field = {
6923 .f = cmd_write_reg_bit_field_parsed,
6925 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
6927 "Set register bit field between bit_x and bit_y included",
6929 (void *)&cmd_write_reg_bit_field_write,
6930 (void *)&cmd_write_reg_bit_field_regfield,
6931 (void *)&cmd_write_reg_bit_field_port_id,
6932 (void *)&cmd_write_reg_bit_field_reg_off,
6933 (void *)&cmd_write_reg_bit_field_bit1_pos,
6934 (void *)&cmd_write_reg_bit_field_bit2_pos,
6935 (void *)&cmd_write_reg_bit_field_value,
6940 /* *** WRITE PORT REGISTER BIT *** */
6941 struct cmd_write_reg_bit_result {
6942 cmdline_fixed_string_t write;
6943 cmdline_fixed_string_t regbit;
6951 cmd_write_reg_bit_parsed(void *parsed_result,
6952 __attribute__((unused)) struct cmdline *cl,
6953 __attribute__((unused)) void *data)
6955 struct cmd_write_reg_bit_result *res = parsed_result;
6956 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
6959 cmdline_parse_token_string_t cmd_write_reg_bit_write =
6960 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
6962 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
6963 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
6965 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
6966 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT16);
6967 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
6968 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
6969 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
6970 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
6971 cmdline_parse_token_num_t cmd_write_reg_bit_value =
6972 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
6974 cmdline_parse_inst_t cmd_write_reg_bit = {
6975 .f = cmd_write_reg_bit_parsed,
6977 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
6980 (void *)&cmd_write_reg_bit_write,
6981 (void *)&cmd_write_reg_bit_regbit,
6982 (void *)&cmd_write_reg_bit_port_id,
6983 (void *)&cmd_write_reg_bit_reg_off,
6984 (void *)&cmd_write_reg_bit_bit_pos,
6985 (void *)&cmd_write_reg_bit_value,
6990 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
6991 struct cmd_read_rxd_txd_result {
6992 cmdline_fixed_string_t read;
6993 cmdline_fixed_string_t rxd_txd;
7000 cmd_read_rxd_txd_parsed(void *parsed_result,
7001 __attribute__((unused)) struct cmdline *cl,
7002 __attribute__((unused)) void *data)
7004 struct cmd_read_rxd_txd_result *res = parsed_result;
7006 if (!strcmp(res->rxd_txd, "rxd"))
7007 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
7008 else if (!strcmp(res->rxd_txd, "txd"))
7009 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
7012 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
7013 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
7014 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
7015 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
7017 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
7018 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT16);
7019 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
7020 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
7021 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
7022 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
7024 cmdline_parse_inst_t cmd_read_rxd_txd = {
7025 .f = cmd_read_rxd_txd_parsed,
7027 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
7029 (void *)&cmd_read_rxd_txd_read,
7030 (void *)&cmd_read_rxd_txd_rxd_txd,
7031 (void *)&cmd_read_rxd_txd_port_id,
7032 (void *)&cmd_read_rxd_txd_queue_id,
7033 (void *)&cmd_read_rxd_txd_desc_id,
7039 struct cmd_quit_result {
7040 cmdline_fixed_string_t quit;
7043 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
7045 __attribute__((unused)) void *data)
7051 cmdline_parse_token_string_t cmd_quit_quit =
7052 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
7054 cmdline_parse_inst_t cmd_quit = {
7055 .f = cmd_quit_parsed,
7057 .help_str = "quit: Exit application",
7059 (void *)&cmd_quit_quit,
7064 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
7065 struct cmd_mac_addr_result {
7066 cmdline_fixed_string_t mac_addr_cmd;
7067 cmdline_fixed_string_t what;
7069 struct ether_addr address;
7072 static void cmd_mac_addr_parsed(void *parsed_result,
7073 __attribute__((unused)) struct cmdline *cl,
7074 __attribute__((unused)) void *data)
7076 struct cmd_mac_addr_result *res = parsed_result;
7079 if (strcmp(res->what, "add") == 0)
7080 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
7081 else if (strcmp(res->what, "set") == 0)
7082 ret = rte_eth_dev_default_mac_addr_set(res->port_num,
7085 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
7087 /* check the return value and print it if is < 0 */
7089 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
7093 cmdline_parse_token_string_t cmd_mac_addr_cmd =
7094 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
7096 cmdline_parse_token_string_t cmd_mac_addr_what =
7097 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
7099 cmdline_parse_token_num_t cmd_mac_addr_portnum =
7100 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num,
7102 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
7103 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
7105 cmdline_parse_inst_t cmd_mac_addr = {
7106 .f = cmd_mac_addr_parsed,
7108 .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
7109 "Add/Remove/Set MAC address on port_id",
7111 (void *)&cmd_mac_addr_cmd,
7112 (void *)&cmd_mac_addr_what,
7113 (void *)&cmd_mac_addr_portnum,
7114 (void *)&cmd_mac_addr_addr,
7120 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
7121 struct cmd_set_qmap_result {
7122 cmdline_fixed_string_t set;
7123 cmdline_fixed_string_t qmap;
7124 cmdline_fixed_string_t what;
7131 cmd_set_qmap_parsed(void *parsed_result,
7132 __attribute__((unused)) struct cmdline *cl,
7133 __attribute__((unused)) void *data)
7135 struct cmd_set_qmap_result *res = parsed_result;
7136 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
7138 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
7141 cmdline_parse_token_string_t cmd_setqmap_set =
7142 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7144 cmdline_parse_token_string_t cmd_setqmap_qmap =
7145 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7147 cmdline_parse_token_string_t cmd_setqmap_what =
7148 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7150 cmdline_parse_token_num_t cmd_setqmap_portid =
7151 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7153 cmdline_parse_token_num_t cmd_setqmap_queueid =
7154 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7156 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
7157 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7160 cmdline_parse_inst_t cmd_set_qmap = {
7161 .f = cmd_set_qmap_parsed,
7163 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
7164 "Set statistics mapping value on tx|rx queue_id of port_id",
7166 (void *)&cmd_setqmap_set,
7167 (void *)&cmd_setqmap_qmap,
7168 (void *)&cmd_setqmap_what,
7169 (void *)&cmd_setqmap_portid,
7170 (void *)&cmd_setqmap_queueid,
7171 (void *)&cmd_setqmap_mapvalue,
7176 /* *** CONFIGURE UNICAST HASH TABLE *** */
7177 struct cmd_set_uc_hash_table {
7178 cmdline_fixed_string_t set;
7179 cmdline_fixed_string_t port;
7181 cmdline_fixed_string_t what;
7182 struct ether_addr address;
7183 cmdline_fixed_string_t mode;
7187 cmd_set_uc_hash_parsed(void *parsed_result,
7188 __attribute__((unused)) struct cmdline *cl,
7189 __attribute__((unused)) void *data)
7192 struct cmd_set_uc_hash_table *res = parsed_result;
7194 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7196 if (strcmp(res->what, "uta") == 0)
7197 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
7198 &res->address,(uint8_t)is_on);
7200 printf("bad unicast hash table parameter, return code = %d \n", ret);
7204 cmdline_parse_token_string_t cmd_set_uc_hash_set =
7205 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7207 cmdline_parse_token_string_t cmd_set_uc_hash_port =
7208 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7210 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
7211 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
7213 cmdline_parse_token_string_t cmd_set_uc_hash_what =
7214 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7216 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
7217 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
7219 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
7220 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7223 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
7224 .f = cmd_set_uc_hash_parsed,
7226 .help_str = "set port <port_id> uta <mac_addr> on|off)",
7228 (void *)&cmd_set_uc_hash_set,
7229 (void *)&cmd_set_uc_hash_port,
7230 (void *)&cmd_set_uc_hash_portid,
7231 (void *)&cmd_set_uc_hash_what,
7232 (void *)&cmd_set_uc_hash_mac,
7233 (void *)&cmd_set_uc_hash_mode,
7238 struct cmd_set_uc_all_hash_table {
7239 cmdline_fixed_string_t set;
7240 cmdline_fixed_string_t port;
7242 cmdline_fixed_string_t what;
7243 cmdline_fixed_string_t value;
7244 cmdline_fixed_string_t mode;
7248 cmd_set_uc_all_hash_parsed(void *parsed_result,
7249 __attribute__((unused)) struct cmdline *cl,
7250 __attribute__((unused)) void *data)
7253 struct cmd_set_uc_all_hash_table *res = parsed_result;
7255 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7257 if ((strcmp(res->what, "uta") == 0) &&
7258 (strcmp(res->value, "all") == 0))
7259 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
7261 printf("bad unicast hash table parameter,"
7262 "return code = %d \n", ret);
7265 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
7266 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7268 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
7269 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7271 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
7272 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
7274 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
7275 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7277 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
7278 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7280 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
7281 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7284 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
7285 .f = cmd_set_uc_all_hash_parsed,
7287 .help_str = "set port <port_id> uta all on|off",
7289 (void *)&cmd_set_uc_all_hash_set,
7290 (void *)&cmd_set_uc_all_hash_port,
7291 (void *)&cmd_set_uc_all_hash_portid,
7292 (void *)&cmd_set_uc_all_hash_what,
7293 (void *)&cmd_set_uc_all_hash_value,
7294 (void *)&cmd_set_uc_all_hash_mode,
7299 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
7300 struct cmd_set_vf_macvlan_filter {
7301 cmdline_fixed_string_t set;
7302 cmdline_fixed_string_t port;
7304 cmdline_fixed_string_t vf;
7306 struct ether_addr address;
7307 cmdline_fixed_string_t filter_type;
7308 cmdline_fixed_string_t mode;
7312 cmd_set_vf_macvlan_parsed(void *parsed_result,
7313 __attribute__((unused)) struct cmdline *cl,
7314 __attribute__((unused)) void *data)
7317 struct cmd_set_vf_macvlan_filter *res = parsed_result;
7318 struct rte_eth_mac_filter filter;
7320 memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
7322 rte_memcpy(&filter.mac_addr, &res->address, ETHER_ADDR_LEN);
7324 /* set VF MAC filter */
7328 filter.dst_id = res->vf_id;
7330 if (!strcmp(res->filter_type, "exact-mac"))
7331 filter.filter_type = RTE_MAC_PERFECT_MATCH;
7332 else if (!strcmp(res->filter_type, "exact-mac-vlan"))
7333 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
7334 else if (!strcmp(res->filter_type, "hashmac"))
7335 filter.filter_type = RTE_MAC_HASH_MATCH;
7336 else if (!strcmp(res->filter_type, "hashmac-vlan"))
7337 filter.filter_type = RTE_MACVLAN_HASH_MATCH;
7339 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7342 ret = rte_eth_dev_filter_ctrl(res->port_id,
7343 RTE_ETH_FILTER_MACVLAN,
7347 ret = rte_eth_dev_filter_ctrl(res->port_id,
7348 RTE_ETH_FILTER_MACVLAN,
7349 RTE_ETH_FILTER_DELETE,
7353 printf("bad set MAC hash parameter, return code = %d\n", ret);
7357 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
7358 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7360 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
7361 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7363 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
7364 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7366 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
7367 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7369 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
7370 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7372 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
7373 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7375 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
7376 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7377 filter_type, "exact-mac#exact-mac-vlan"
7378 "#hashmac#hashmac-vlan");
7379 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
7380 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7383 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
7384 .f = cmd_set_vf_macvlan_parsed,
7386 .help_str = "set port <port_id> vf <vf_id> <mac_addr> "
7387 "exact-mac|exact-mac-vlan|hashmac|hashmac-vlan on|off: "
7388 "Exact match rule: exact match of MAC or MAC and VLAN; "
7389 "hash match rule: hash match of MAC and exact match of VLAN",
7391 (void *)&cmd_set_vf_macvlan_set,
7392 (void *)&cmd_set_vf_macvlan_port,
7393 (void *)&cmd_set_vf_macvlan_portid,
7394 (void *)&cmd_set_vf_macvlan_vf,
7395 (void *)&cmd_set_vf_macvlan_vf_id,
7396 (void *)&cmd_set_vf_macvlan_mac,
7397 (void *)&cmd_set_vf_macvlan_filter_type,
7398 (void *)&cmd_set_vf_macvlan_mode,
7403 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
7404 struct cmd_set_vf_traffic {
7405 cmdline_fixed_string_t set;
7406 cmdline_fixed_string_t port;
7408 cmdline_fixed_string_t vf;
7410 cmdline_fixed_string_t what;
7411 cmdline_fixed_string_t mode;
7415 cmd_set_vf_traffic_parsed(void *parsed_result,
7416 __attribute__((unused)) struct cmdline *cl,
7417 __attribute__((unused)) void *data)
7419 struct cmd_set_vf_traffic *res = parsed_result;
7420 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
7421 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7423 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
7426 cmdline_parse_token_string_t cmd_setvf_traffic_set =
7427 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7429 cmdline_parse_token_string_t cmd_setvf_traffic_port =
7430 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7432 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
7433 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
7435 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
7436 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7438 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
7439 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
7441 cmdline_parse_token_string_t cmd_setvf_traffic_what =
7442 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7444 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
7445 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7448 cmdline_parse_inst_t cmd_set_vf_traffic = {
7449 .f = cmd_set_vf_traffic_parsed,
7451 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
7453 (void *)&cmd_setvf_traffic_set,
7454 (void *)&cmd_setvf_traffic_port,
7455 (void *)&cmd_setvf_traffic_portid,
7456 (void *)&cmd_setvf_traffic_vf,
7457 (void *)&cmd_setvf_traffic_vfid,
7458 (void *)&cmd_setvf_traffic_what,
7459 (void *)&cmd_setvf_traffic_mode,
7464 /* *** CONFIGURE VF RECEIVE MODE *** */
7465 struct cmd_set_vf_rxmode {
7466 cmdline_fixed_string_t set;
7467 cmdline_fixed_string_t port;
7469 cmdline_fixed_string_t vf;
7471 cmdline_fixed_string_t what;
7472 cmdline_fixed_string_t mode;
7473 cmdline_fixed_string_t on;
7477 cmd_set_vf_rxmode_parsed(void *parsed_result,
7478 __attribute__((unused)) struct cmdline *cl,
7479 __attribute__((unused)) void *data)
7482 uint16_t rx_mode = 0;
7483 struct cmd_set_vf_rxmode *res = parsed_result;
7485 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
7486 if (!strcmp(res->what,"rxmode")) {
7487 if (!strcmp(res->mode, "AUPE"))
7488 rx_mode |= ETH_VMDQ_ACCEPT_UNTAG;
7489 else if (!strcmp(res->mode, "ROPE"))
7490 rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC;
7491 else if (!strcmp(res->mode, "BAM"))
7492 rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST;
7493 else if (!strncmp(res->mode, "MPE",3))
7494 rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST;
7497 RTE_SET_USED(is_on);
7499 #ifdef RTE_LIBRTE_IXGBE_PMD
7500 if (ret == -ENOTSUP)
7501 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id,
7502 rx_mode, (uint8_t)is_on);
7504 #ifdef RTE_LIBRTE_BNXT_PMD
7505 if (ret == -ENOTSUP)
7506 ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id,
7507 rx_mode, (uint8_t)is_on);
7510 printf("bad VF receive mode parameter, return code = %d \n",
7514 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
7515 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7517 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
7518 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7520 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
7521 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
7523 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
7524 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7526 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
7527 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
7529 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
7530 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7532 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
7533 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7534 mode, "AUPE#ROPE#BAM#MPE");
7535 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
7536 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7539 cmdline_parse_inst_t cmd_set_vf_rxmode = {
7540 .f = cmd_set_vf_rxmode_parsed,
7542 .help_str = "set port <port_id> vf <vf_id> rxmode "
7543 "AUPE|ROPE|BAM|MPE on|off",
7545 (void *)&cmd_set_vf_rxmode_set,
7546 (void *)&cmd_set_vf_rxmode_port,
7547 (void *)&cmd_set_vf_rxmode_portid,
7548 (void *)&cmd_set_vf_rxmode_vf,
7549 (void *)&cmd_set_vf_rxmode_vfid,
7550 (void *)&cmd_set_vf_rxmode_what,
7551 (void *)&cmd_set_vf_rxmode_mode,
7552 (void *)&cmd_set_vf_rxmode_on,
7557 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
7558 struct cmd_vf_mac_addr_result {
7559 cmdline_fixed_string_t mac_addr_cmd;
7560 cmdline_fixed_string_t what;
7561 cmdline_fixed_string_t port;
7563 cmdline_fixed_string_t vf;
7565 struct ether_addr address;
7568 static void cmd_vf_mac_addr_parsed(void *parsed_result,
7569 __attribute__((unused)) struct cmdline *cl,
7570 __attribute__((unused)) void *data)
7572 struct cmd_vf_mac_addr_result *res = parsed_result;
7575 if (strcmp(res->what, "add") != 0)
7578 #ifdef RTE_LIBRTE_I40E_PMD
7579 if (ret == -ENOTSUP)
7580 ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num,
7583 #ifdef RTE_LIBRTE_BNXT_PMD
7584 if (ret == -ENOTSUP)
7585 ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address,
7590 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
7594 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
7595 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7596 mac_addr_cmd,"mac_addr");
7597 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
7598 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7600 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
7601 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7603 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
7604 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
7606 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
7607 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7609 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
7610 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
7612 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
7613 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
7616 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
7617 .f = cmd_vf_mac_addr_parsed,
7619 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
7620 "Add MAC address filtering for a VF on port_id",
7622 (void *)&cmd_vf_mac_addr_cmd,
7623 (void *)&cmd_vf_mac_addr_what,
7624 (void *)&cmd_vf_mac_addr_port,
7625 (void *)&cmd_vf_mac_addr_portnum,
7626 (void *)&cmd_vf_mac_addr_vf,
7627 (void *)&cmd_vf_mac_addr_vfnum,
7628 (void *)&cmd_vf_mac_addr_addr,
7633 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
7634 struct cmd_vf_rx_vlan_filter {
7635 cmdline_fixed_string_t rx_vlan;
7636 cmdline_fixed_string_t what;
7638 cmdline_fixed_string_t port;
7640 cmdline_fixed_string_t vf;
7645 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
7646 __attribute__((unused)) struct cmdline *cl,
7647 __attribute__((unused)) void *data)
7649 struct cmd_vf_rx_vlan_filter *res = parsed_result;
7652 __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
7654 #ifdef RTE_LIBRTE_IXGBE_PMD
7655 if (ret == -ENOTSUP)
7656 ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
7657 res->vlan_id, res->vf_mask, is_add);
7659 #ifdef RTE_LIBRTE_I40E_PMD
7660 if (ret == -ENOTSUP)
7661 ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
7662 res->vlan_id, res->vf_mask, is_add);
7664 #ifdef RTE_LIBRTE_BNXT_PMD
7665 if (ret == -ENOTSUP)
7666 ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id,
7667 res->vlan_id, res->vf_mask, is_add);
7674 printf("invalid vlan_id %d or vf_mask %"PRIu64"\n",
7675 res->vlan_id, res->vf_mask);
7678 printf("invalid port_id %d\n", res->port_id);
7681 printf("function not implemented or supported\n");
7684 printf("programming error: (%s)\n", strerror(-ret));
7688 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
7689 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7690 rx_vlan, "rx_vlan");
7691 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
7692 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7694 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
7695 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7697 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
7698 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7700 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
7701 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7703 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
7704 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7706 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
7707 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7710 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
7711 .f = cmd_vf_rx_vlan_filter_parsed,
7713 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
7714 "(vf_mask = hexadecimal VF mask)",
7716 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
7717 (void *)&cmd_vf_rx_vlan_filter_what,
7718 (void *)&cmd_vf_rx_vlan_filter_vlanid,
7719 (void *)&cmd_vf_rx_vlan_filter_port,
7720 (void *)&cmd_vf_rx_vlan_filter_portid,
7721 (void *)&cmd_vf_rx_vlan_filter_vf,
7722 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
7727 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
7728 struct cmd_queue_rate_limit_result {
7729 cmdline_fixed_string_t set;
7730 cmdline_fixed_string_t port;
7732 cmdline_fixed_string_t queue;
7734 cmdline_fixed_string_t rate;
7738 static void cmd_queue_rate_limit_parsed(void *parsed_result,
7739 __attribute__((unused)) struct cmdline *cl,
7740 __attribute__((unused)) void *data)
7742 struct cmd_queue_rate_limit_result *res = parsed_result;
7745 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
7746 && (strcmp(res->queue, "queue") == 0)
7747 && (strcmp(res->rate, "rate") == 0))
7748 ret = set_queue_rate_limit(res->port_num, res->queue_num,
7751 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
7755 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
7756 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7758 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
7759 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7761 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
7762 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
7764 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
7765 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7767 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
7768 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
7770 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
7771 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7773 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
7774 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
7777 cmdline_parse_inst_t cmd_queue_rate_limit = {
7778 .f = cmd_queue_rate_limit_parsed,
7780 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
7781 "Set rate limit for a queue on port_id",
7783 (void *)&cmd_queue_rate_limit_set,
7784 (void *)&cmd_queue_rate_limit_port,
7785 (void *)&cmd_queue_rate_limit_portnum,
7786 (void *)&cmd_queue_rate_limit_queue,
7787 (void *)&cmd_queue_rate_limit_queuenum,
7788 (void *)&cmd_queue_rate_limit_rate,
7789 (void *)&cmd_queue_rate_limit_ratenum,
7794 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
7795 struct cmd_vf_rate_limit_result {
7796 cmdline_fixed_string_t set;
7797 cmdline_fixed_string_t port;
7799 cmdline_fixed_string_t vf;
7801 cmdline_fixed_string_t rate;
7803 cmdline_fixed_string_t q_msk;
7807 static void cmd_vf_rate_limit_parsed(void *parsed_result,
7808 __attribute__((unused)) struct cmdline *cl,
7809 __attribute__((unused)) void *data)
7811 struct cmd_vf_rate_limit_result *res = parsed_result;
7814 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
7815 && (strcmp(res->vf, "vf") == 0)
7816 && (strcmp(res->rate, "rate") == 0)
7817 && (strcmp(res->q_msk, "queue_mask") == 0))
7818 ret = set_vf_rate_limit(res->port_num, res->vf_num,
7819 res->rate_num, res->q_msk_val);
7821 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
7825 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
7826 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7828 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
7829 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7831 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
7832 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7834 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
7835 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7837 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
7838 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7840 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
7841 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7843 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
7844 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7846 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
7847 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7848 q_msk, "queue_mask");
7849 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
7850 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7853 cmdline_parse_inst_t cmd_vf_rate_limit = {
7854 .f = cmd_vf_rate_limit_parsed,
7856 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
7857 "queue_mask <queue_mask_value>: "
7858 "Set rate limit for queues of VF on port_id",
7860 (void *)&cmd_vf_rate_limit_set,
7861 (void *)&cmd_vf_rate_limit_port,
7862 (void *)&cmd_vf_rate_limit_portnum,
7863 (void *)&cmd_vf_rate_limit_vf,
7864 (void *)&cmd_vf_rate_limit_vfnum,
7865 (void *)&cmd_vf_rate_limit_rate,
7866 (void *)&cmd_vf_rate_limit_ratenum,
7867 (void *)&cmd_vf_rate_limit_q_msk,
7868 (void *)&cmd_vf_rate_limit_q_msk_val,
7873 /* *** ADD TUNNEL FILTER OF A PORT *** */
7874 struct cmd_tunnel_filter_result {
7875 cmdline_fixed_string_t cmd;
7876 cmdline_fixed_string_t what;
7878 struct ether_addr outer_mac;
7879 struct ether_addr inner_mac;
7880 cmdline_ipaddr_t ip_value;
7881 uint16_t inner_vlan;
7882 cmdline_fixed_string_t tunnel_type;
7883 cmdline_fixed_string_t filter_type;
7889 cmd_tunnel_filter_parsed(void *parsed_result,
7890 __attribute__((unused)) struct cmdline *cl,
7891 __attribute__((unused)) void *data)
7893 struct cmd_tunnel_filter_result *res = parsed_result;
7894 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
7897 memset(&tunnel_filter_conf, 0, sizeof(tunnel_filter_conf));
7899 ether_addr_copy(&res->outer_mac, &tunnel_filter_conf.outer_mac);
7900 ether_addr_copy(&res->inner_mac, &tunnel_filter_conf.inner_mac);
7901 tunnel_filter_conf.inner_vlan = res->inner_vlan;
7903 if (res->ip_value.family == AF_INET) {
7904 tunnel_filter_conf.ip_addr.ipv4_addr =
7905 res->ip_value.addr.ipv4.s_addr;
7906 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
7908 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
7909 &(res->ip_value.addr.ipv6),
7910 sizeof(struct in6_addr));
7911 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
7914 if (!strcmp(res->filter_type, "imac-ivlan"))
7915 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
7916 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
7917 tunnel_filter_conf.filter_type =
7918 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
7919 else if (!strcmp(res->filter_type, "imac-tenid"))
7920 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
7921 else if (!strcmp(res->filter_type, "imac"))
7922 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
7923 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
7924 tunnel_filter_conf.filter_type =
7925 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
7926 else if (!strcmp(res->filter_type, "oip"))
7927 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_OIP;
7928 else if (!strcmp(res->filter_type, "iip"))
7929 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IIP;
7931 printf("The filter type is not supported");
7935 if (!strcmp(res->tunnel_type, "vxlan"))
7936 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
7937 else if (!strcmp(res->tunnel_type, "nvgre"))
7938 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE;
7939 else if (!strcmp(res->tunnel_type, "ipingre"))
7940 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_IP_IN_GRE;
7942 printf("The tunnel type %s not supported.\n", res->tunnel_type);
7946 tunnel_filter_conf.tenant_id = res->tenant_id;
7947 tunnel_filter_conf.queue_id = res->queue_num;
7948 if (!strcmp(res->what, "add"))
7949 ret = rte_eth_dev_filter_ctrl(res->port_id,
7950 RTE_ETH_FILTER_TUNNEL,
7952 &tunnel_filter_conf);
7954 ret = rte_eth_dev_filter_ctrl(res->port_id,
7955 RTE_ETH_FILTER_TUNNEL,
7956 RTE_ETH_FILTER_DELETE,
7957 &tunnel_filter_conf);
7959 printf("cmd_tunnel_filter_parsed error: (%s)\n",
7963 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
7964 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7965 cmd, "tunnel_filter");
7966 cmdline_parse_token_string_t cmd_tunnel_filter_what =
7967 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7969 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
7970 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7972 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
7973 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
7975 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
7976 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
7978 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
7979 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7980 inner_vlan, UINT16);
7981 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
7982 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
7984 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
7985 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7986 tunnel_type, "vxlan#nvgre#ipingre");
7988 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
7989 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7990 filter_type, "oip#iip#imac-ivlan#imac-ivlan-tenid#imac-tenid#"
7991 "imac#omac-imac-tenid");
7992 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
7993 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7995 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
7996 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7999 cmdline_parse_inst_t cmd_tunnel_filter = {
8000 .f = cmd_tunnel_filter_parsed,
8002 .help_str = "tunnel_filter add|rm <port_id> <outer_mac> <inner_mac> "
8003 "<ip> <inner_vlan> vxlan|nvgre|ipingre oip|iip|imac-ivlan|"
8004 "imac-ivlan-tenid|imac-tenid|imac|omac-imac-tenid <tenant_id> "
8005 "<queue_id>: Add/Rm tunnel filter of a port",
8007 (void *)&cmd_tunnel_filter_cmd,
8008 (void *)&cmd_tunnel_filter_what,
8009 (void *)&cmd_tunnel_filter_port_id,
8010 (void *)&cmd_tunnel_filter_outer_mac,
8011 (void *)&cmd_tunnel_filter_inner_mac,
8012 (void *)&cmd_tunnel_filter_ip_value,
8013 (void *)&cmd_tunnel_filter_innner_vlan,
8014 (void *)&cmd_tunnel_filter_tunnel_type,
8015 (void *)&cmd_tunnel_filter_filter_type,
8016 (void *)&cmd_tunnel_filter_tenant_id,
8017 (void *)&cmd_tunnel_filter_queue_num,
8022 /* *** CONFIGURE TUNNEL UDP PORT *** */
8023 struct cmd_tunnel_udp_config {
8024 cmdline_fixed_string_t cmd;
8025 cmdline_fixed_string_t what;
8031 cmd_tunnel_udp_config_parsed(void *parsed_result,
8032 __attribute__((unused)) struct cmdline *cl,
8033 __attribute__((unused)) void *data)
8035 struct cmd_tunnel_udp_config *res = parsed_result;
8036 struct rte_eth_udp_tunnel tunnel_udp;
8039 tunnel_udp.udp_port = res->udp_port;
8041 if (!strcmp(res->cmd, "rx_vxlan_port"))
8042 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
8044 if (!strcmp(res->what, "add"))
8045 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
8048 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
8052 printf("udp tunneling add error: (%s)\n", strerror(-ret));
8055 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
8056 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
8057 cmd, "rx_vxlan_port");
8058 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
8059 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
8061 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
8062 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
8064 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
8065 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
8068 cmdline_parse_inst_t cmd_tunnel_udp_config = {
8069 .f = cmd_tunnel_udp_config_parsed,
8071 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
8072 "Add/Remove a tunneling UDP port filter",
8074 (void *)&cmd_tunnel_udp_config_cmd,
8075 (void *)&cmd_tunnel_udp_config_what,
8076 (void *)&cmd_tunnel_udp_config_udp_port,
8077 (void *)&cmd_tunnel_udp_config_port_id,
8082 /* *** GLOBAL CONFIG *** */
8083 struct cmd_global_config_result {
8084 cmdline_fixed_string_t cmd;
8086 cmdline_fixed_string_t cfg_type;
8091 cmd_global_config_parsed(void *parsed_result,
8092 __attribute__((unused)) struct cmdline *cl,
8093 __attribute__((unused)) void *data)
8095 struct cmd_global_config_result *res = parsed_result;
8096 struct rte_eth_global_cfg conf;
8099 memset(&conf, 0, sizeof(conf));
8100 conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN;
8101 conf.cfg.gre_key_len = res->len;
8102 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE,
8103 RTE_ETH_FILTER_SET, &conf);
8105 printf("Global config error\n");
8108 cmdline_parse_token_string_t cmd_global_config_cmd =
8109 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd,
8111 cmdline_parse_token_num_t cmd_global_config_port_id =
8112 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id,
8114 cmdline_parse_token_string_t cmd_global_config_type =
8115 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result,
8116 cfg_type, "gre-key-len");
8117 cmdline_parse_token_num_t cmd_global_config_gre_key_len =
8118 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result,
8121 cmdline_parse_inst_t cmd_global_config = {
8122 .f = cmd_global_config_parsed,
8123 .data = (void *)NULL,
8124 .help_str = "global_config <port_id> gre-key-len <key_len>",
8126 (void *)&cmd_global_config_cmd,
8127 (void *)&cmd_global_config_port_id,
8128 (void *)&cmd_global_config_type,
8129 (void *)&cmd_global_config_gre_key_len,
8134 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
8135 struct cmd_set_mirror_mask_result {
8136 cmdline_fixed_string_t set;
8137 cmdline_fixed_string_t port;
8139 cmdline_fixed_string_t mirror;
8141 cmdline_fixed_string_t what;
8142 cmdline_fixed_string_t value;
8143 cmdline_fixed_string_t dstpool;
8145 cmdline_fixed_string_t on;
8148 cmdline_parse_token_string_t cmd_mirror_mask_set =
8149 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8151 cmdline_parse_token_string_t cmd_mirror_mask_port =
8152 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8154 cmdline_parse_token_num_t cmd_mirror_mask_portid =
8155 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
8157 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
8158 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8159 mirror, "mirror-rule");
8160 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
8161 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
8163 cmdline_parse_token_string_t cmd_mirror_mask_what =
8164 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8165 what, "pool-mirror-up#pool-mirror-down"
8167 cmdline_parse_token_string_t cmd_mirror_mask_value =
8168 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8170 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
8171 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8172 dstpool, "dst-pool");
8173 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
8174 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
8176 cmdline_parse_token_string_t cmd_mirror_mask_on =
8177 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8181 cmd_set_mirror_mask_parsed(void *parsed_result,
8182 __attribute__((unused)) struct cmdline *cl,
8183 __attribute__((unused)) void *data)
8186 struct cmd_set_mirror_mask_result *res = parsed_result;
8187 struct rte_eth_mirror_conf mr_conf;
8189 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
8191 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
8193 mr_conf.dst_pool = res->dstpool_id;
8195 if (!strcmp(res->what, "pool-mirror-up")) {
8196 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
8197 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
8198 } else if (!strcmp(res->what, "pool-mirror-down")) {
8199 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
8200 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
8201 } else if (!strcmp(res->what, "vlan-mirror")) {
8202 mr_conf.rule_type = ETH_MIRROR_VLAN;
8203 nb_item = parse_item_list(res->value, "vlan",
8204 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
8208 for (i = 0; i < nb_item; i++) {
8209 if (vlan_list[i] > ETHER_MAX_VLAN_ID) {
8210 printf("Invalid vlan_id: must be < 4096\n");
8214 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
8215 mr_conf.vlan.vlan_mask |= 1ULL << i;
8219 if (!strcmp(res->on, "on"))
8220 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8223 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8226 printf("mirror rule add error: (%s)\n", strerror(-ret));
8229 cmdline_parse_inst_t cmd_set_mirror_mask = {
8230 .f = cmd_set_mirror_mask_parsed,
8232 .help_str = "set port <port_id> mirror-rule <rule_id> "
8233 "pool-mirror-up|pool-mirror-down|vlan-mirror "
8234 "<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off",
8236 (void *)&cmd_mirror_mask_set,
8237 (void *)&cmd_mirror_mask_port,
8238 (void *)&cmd_mirror_mask_portid,
8239 (void *)&cmd_mirror_mask_mirror,
8240 (void *)&cmd_mirror_mask_ruleid,
8241 (void *)&cmd_mirror_mask_what,
8242 (void *)&cmd_mirror_mask_value,
8243 (void *)&cmd_mirror_mask_dstpool,
8244 (void *)&cmd_mirror_mask_poolid,
8245 (void *)&cmd_mirror_mask_on,
8250 /* *** CONFIGURE VM MIRROR UPLINK/DOWNLINK RULE *** */
8251 struct cmd_set_mirror_link_result {
8252 cmdline_fixed_string_t set;
8253 cmdline_fixed_string_t port;
8255 cmdline_fixed_string_t mirror;
8257 cmdline_fixed_string_t what;
8258 cmdline_fixed_string_t dstpool;
8260 cmdline_fixed_string_t on;
8263 cmdline_parse_token_string_t cmd_mirror_link_set =
8264 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8266 cmdline_parse_token_string_t cmd_mirror_link_port =
8267 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8269 cmdline_parse_token_num_t cmd_mirror_link_portid =
8270 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
8272 cmdline_parse_token_string_t cmd_mirror_link_mirror =
8273 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8274 mirror, "mirror-rule");
8275 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
8276 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
8278 cmdline_parse_token_string_t cmd_mirror_link_what =
8279 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8280 what, "uplink-mirror#downlink-mirror");
8281 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
8282 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8283 dstpool, "dst-pool");
8284 cmdline_parse_token_num_t cmd_mirror_link_poolid =
8285 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
8287 cmdline_parse_token_string_t cmd_mirror_link_on =
8288 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8292 cmd_set_mirror_link_parsed(void *parsed_result,
8293 __attribute__((unused)) struct cmdline *cl,
8294 __attribute__((unused)) void *data)
8297 struct cmd_set_mirror_link_result *res = parsed_result;
8298 struct rte_eth_mirror_conf mr_conf;
8300 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
8301 if (!strcmp(res->what, "uplink-mirror"))
8302 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
8304 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
8306 mr_conf.dst_pool = res->dstpool_id;
8308 if (!strcmp(res->on, "on"))
8309 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8312 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8315 /* check the return value and print it if is < 0 */
8317 printf("mirror rule add error: (%s)\n", strerror(-ret));
8321 cmdline_parse_inst_t cmd_set_mirror_link = {
8322 .f = cmd_set_mirror_link_parsed,
8324 .help_str = "set port <port_id> mirror-rule <rule_id> "
8325 "uplink-mirror|downlink-mirror dst-pool <pool_id> on|off",
8327 (void *)&cmd_mirror_link_set,
8328 (void *)&cmd_mirror_link_port,
8329 (void *)&cmd_mirror_link_portid,
8330 (void *)&cmd_mirror_link_mirror,
8331 (void *)&cmd_mirror_link_ruleid,
8332 (void *)&cmd_mirror_link_what,
8333 (void *)&cmd_mirror_link_dstpool,
8334 (void *)&cmd_mirror_link_poolid,
8335 (void *)&cmd_mirror_link_on,
8340 /* *** RESET VM MIRROR RULE *** */
8341 struct cmd_rm_mirror_rule_result {
8342 cmdline_fixed_string_t reset;
8343 cmdline_fixed_string_t port;
8345 cmdline_fixed_string_t mirror;
8349 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
8350 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
8352 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
8353 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
8355 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
8356 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
8358 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
8359 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
8360 mirror, "mirror-rule");
8361 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
8362 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
8366 cmd_reset_mirror_rule_parsed(void *parsed_result,
8367 __attribute__((unused)) struct cmdline *cl,
8368 __attribute__((unused)) void *data)
8371 struct cmd_set_mirror_link_result *res = parsed_result;
8373 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
8375 printf("mirror rule remove error: (%s)\n", strerror(-ret));
8378 cmdline_parse_inst_t cmd_reset_mirror_rule = {
8379 .f = cmd_reset_mirror_rule_parsed,
8381 .help_str = "reset port <port_id> mirror-rule <rule_id>",
8383 (void *)&cmd_rm_mirror_rule_reset,
8384 (void *)&cmd_rm_mirror_rule_port,
8385 (void *)&cmd_rm_mirror_rule_portid,
8386 (void *)&cmd_rm_mirror_rule_mirror,
8387 (void *)&cmd_rm_mirror_rule_ruleid,
8392 /* ******************************************************************************** */
8394 struct cmd_dump_result {
8395 cmdline_fixed_string_t dump;
8399 dump_struct_sizes(void)
8401 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
8402 DUMP_SIZE(struct rte_mbuf);
8403 DUMP_SIZE(struct rte_mempool);
8404 DUMP_SIZE(struct rte_ring);
8408 static void cmd_dump_parsed(void *parsed_result,
8409 __attribute__((unused)) struct cmdline *cl,
8410 __attribute__((unused)) void *data)
8412 struct cmd_dump_result *res = parsed_result;
8414 if (!strcmp(res->dump, "dump_physmem"))
8415 rte_dump_physmem_layout(stdout);
8416 else if (!strcmp(res->dump, "dump_memzone"))
8417 rte_memzone_dump(stdout);
8418 else if (!strcmp(res->dump, "dump_struct_sizes"))
8419 dump_struct_sizes();
8420 else if (!strcmp(res->dump, "dump_ring"))
8421 rte_ring_list_dump(stdout);
8422 else if (!strcmp(res->dump, "dump_mempool"))
8423 rte_mempool_list_dump(stdout);
8424 else if (!strcmp(res->dump, "dump_devargs"))
8425 rte_eal_devargs_dump(stdout);
8426 else if (!strcmp(res->dump, "dump_log_types"))
8427 rte_log_dump(stdout);
8430 cmdline_parse_token_string_t cmd_dump_dump =
8431 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
8434 "dump_struct_sizes#"
8440 cmdline_parse_inst_t cmd_dump = {
8441 .f = cmd_dump_parsed, /* function to call */
8442 .data = NULL, /* 2nd arg of func */
8443 .help_str = "Dump status",
8444 .tokens = { /* token list, NULL terminated */
8445 (void *)&cmd_dump_dump,
8450 /* ******************************************************************************** */
8452 struct cmd_dump_one_result {
8453 cmdline_fixed_string_t dump;
8454 cmdline_fixed_string_t name;
8457 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
8458 __attribute__((unused)) void *data)
8460 struct cmd_dump_one_result *res = parsed_result;
8462 if (!strcmp(res->dump, "dump_ring")) {
8464 r = rte_ring_lookup(res->name);
8466 cmdline_printf(cl, "Cannot find ring\n");
8469 rte_ring_dump(stdout, r);
8470 } else if (!strcmp(res->dump, "dump_mempool")) {
8471 struct rte_mempool *mp;
8472 mp = rte_mempool_lookup(res->name);
8474 cmdline_printf(cl, "Cannot find mempool\n");
8477 rte_mempool_dump(stdout, mp);
8481 cmdline_parse_token_string_t cmd_dump_one_dump =
8482 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
8483 "dump_ring#dump_mempool");
8485 cmdline_parse_token_string_t cmd_dump_one_name =
8486 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
8488 cmdline_parse_inst_t cmd_dump_one = {
8489 .f = cmd_dump_one_parsed, /* function to call */
8490 .data = NULL, /* 2nd arg of func */
8491 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
8492 .tokens = { /* token list, NULL terminated */
8493 (void *)&cmd_dump_one_dump,
8494 (void *)&cmd_dump_one_name,
8499 /* *** Add/Del syn filter *** */
8500 struct cmd_syn_filter_result {
8501 cmdline_fixed_string_t filter;
8503 cmdline_fixed_string_t ops;
8504 cmdline_fixed_string_t priority;
8505 cmdline_fixed_string_t high;
8506 cmdline_fixed_string_t queue;
8511 cmd_syn_filter_parsed(void *parsed_result,
8512 __attribute__((unused)) struct cmdline *cl,
8513 __attribute__((unused)) void *data)
8515 struct cmd_syn_filter_result *res = parsed_result;
8516 struct rte_eth_syn_filter syn_filter;
8519 ret = rte_eth_dev_filter_supported(res->port_id,
8520 RTE_ETH_FILTER_SYN);
8522 printf("syn filter is not supported on port %u.\n",
8527 memset(&syn_filter, 0, sizeof(syn_filter));
8529 if (!strcmp(res->ops, "add")) {
8530 if (!strcmp(res->high, "high"))
8531 syn_filter.hig_pri = 1;
8533 syn_filter.hig_pri = 0;
8535 syn_filter.queue = res->queue_id;
8536 ret = rte_eth_dev_filter_ctrl(res->port_id,
8541 ret = rte_eth_dev_filter_ctrl(res->port_id,
8543 RTE_ETH_FILTER_DELETE,
8547 printf("syn filter programming error: (%s)\n",
8551 cmdline_parse_token_string_t cmd_syn_filter_filter =
8552 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8553 filter, "syn_filter");
8554 cmdline_parse_token_num_t cmd_syn_filter_port_id =
8555 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
8557 cmdline_parse_token_string_t cmd_syn_filter_ops =
8558 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8560 cmdline_parse_token_string_t cmd_syn_filter_priority =
8561 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8562 priority, "priority");
8563 cmdline_parse_token_string_t cmd_syn_filter_high =
8564 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8566 cmdline_parse_token_string_t cmd_syn_filter_queue =
8567 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8569 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
8570 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
8573 cmdline_parse_inst_t cmd_syn_filter = {
8574 .f = cmd_syn_filter_parsed,
8576 .help_str = "syn_filter <port_id> add|del priority high|low queue "
8577 "<queue_id>: Add/Delete syn filter",
8579 (void *)&cmd_syn_filter_filter,
8580 (void *)&cmd_syn_filter_port_id,
8581 (void *)&cmd_syn_filter_ops,
8582 (void *)&cmd_syn_filter_priority,
8583 (void *)&cmd_syn_filter_high,
8584 (void *)&cmd_syn_filter_queue,
8585 (void *)&cmd_syn_filter_queue_id,
8590 /* *** queue region set *** */
8591 struct cmd_queue_region_result {
8592 cmdline_fixed_string_t set;
8593 cmdline_fixed_string_t port;
8595 cmdline_fixed_string_t cmd;
8596 cmdline_fixed_string_t region;
8598 cmdline_fixed_string_t queue_start_index;
8600 cmdline_fixed_string_t queue_num;
8601 uint8_t queue_num_value;
8605 cmd_queue_region_parsed(void *parsed_result,
8606 __attribute__((unused)) struct cmdline *cl,
8607 __attribute__((unused)) void *data)
8609 struct cmd_queue_region_result *res = parsed_result;
8611 #ifdef RTE_LIBRTE_I40E_PMD
8612 struct rte_pmd_i40e_queue_region_conf region_conf;
8613 enum rte_pmd_i40e_queue_region_op op_type;
8616 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
8619 #ifdef RTE_LIBRTE_I40E_PMD
8620 memset(®ion_conf, 0, sizeof(region_conf));
8621 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_SET;
8622 region_conf.region_id = res->region_id;
8623 region_conf.queue_num = res->queue_num_value;
8624 region_conf.queue_start_index = res->queue_id;
8626 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
8627 op_type, ®ion_conf);
8634 printf("function not implemented or supported\n");
8637 printf("queue region config error: (%s)\n", strerror(-ret));
8641 cmdline_parse_token_string_t cmd_queue_region_set =
8642 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
8644 cmdline_parse_token_string_t cmd_queue_region_port =
8645 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, port, "port");
8646 cmdline_parse_token_num_t cmd_queue_region_port_id =
8647 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
8649 cmdline_parse_token_string_t cmd_queue_region_cmd =
8650 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
8651 cmd, "queue-region");
8652 cmdline_parse_token_string_t cmd_queue_region_id =
8653 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
8654 region, "region_id");
8655 cmdline_parse_token_num_t cmd_queue_region_index =
8656 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
8658 cmdline_parse_token_string_t cmd_queue_region_queue_start_index =
8659 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
8660 queue_start_index, "queue_start_index");
8661 cmdline_parse_token_num_t cmd_queue_region_queue_id =
8662 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
8664 cmdline_parse_token_string_t cmd_queue_region_queue_num =
8665 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
8666 queue_num, "queue_num");
8667 cmdline_parse_token_num_t cmd_queue_region_queue_num_value =
8668 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
8669 queue_num_value, UINT8);
8671 cmdline_parse_inst_t cmd_queue_region = {
8672 .f = cmd_queue_region_parsed,
8674 .help_str = "set port <port_id> queue-region region_id <value> "
8675 "queue_start_index <value> queue_num <value>: Set a queue region",
8677 (void *)&cmd_queue_region_set,
8678 (void *)&cmd_queue_region_port,
8679 (void *)&cmd_queue_region_port_id,
8680 (void *)&cmd_queue_region_cmd,
8681 (void *)&cmd_queue_region_id,
8682 (void *)&cmd_queue_region_index,
8683 (void *)&cmd_queue_region_queue_start_index,
8684 (void *)&cmd_queue_region_queue_id,
8685 (void *)&cmd_queue_region_queue_num,
8686 (void *)&cmd_queue_region_queue_num_value,
8691 /* *** queue region and flowtype set *** */
8692 struct cmd_region_flowtype_result {
8693 cmdline_fixed_string_t set;
8694 cmdline_fixed_string_t port;
8696 cmdline_fixed_string_t cmd;
8697 cmdline_fixed_string_t region;
8699 cmdline_fixed_string_t flowtype;
8700 uint8_t flowtype_id;
8704 cmd_region_flowtype_parsed(void *parsed_result,
8705 __attribute__((unused)) struct cmdline *cl,
8706 __attribute__((unused)) void *data)
8708 struct cmd_region_flowtype_result *res = parsed_result;
8710 #ifdef RTE_LIBRTE_I40E_PMD
8711 struct rte_pmd_i40e_queue_region_conf region_conf;
8712 enum rte_pmd_i40e_queue_region_op op_type;
8715 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
8718 #ifdef RTE_LIBRTE_I40E_PMD
8719 memset(®ion_conf, 0, sizeof(region_conf));
8721 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_FLOWTYPE_SET;
8722 region_conf.region_id = res->region_id;
8723 region_conf.hw_flowtype = res->flowtype_id;
8725 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
8726 op_type, ®ion_conf);
8733 printf("function not implemented or supported\n");
8736 printf("region flowtype config error: (%s)\n", strerror(-ret));
8740 cmdline_parse_token_string_t cmd_region_flowtype_set =
8741 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
8743 cmdline_parse_token_string_t cmd_region_flowtype_port =
8744 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
8746 cmdline_parse_token_num_t cmd_region_flowtype_port_index =
8747 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
8749 cmdline_parse_token_string_t cmd_region_flowtype_cmd =
8750 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
8751 cmd, "queue-region");
8752 cmdline_parse_token_string_t cmd_region_flowtype_index =
8753 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
8754 region, "region_id");
8755 cmdline_parse_token_num_t cmd_region_flowtype_id =
8756 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
8758 cmdline_parse_token_string_t cmd_region_flowtype_flow_index =
8759 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
8760 flowtype, "flowtype");
8761 cmdline_parse_token_num_t cmd_region_flowtype_flow_id =
8762 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
8763 flowtype_id, UINT8);
8764 cmdline_parse_inst_t cmd_region_flowtype = {
8765 .f = cmd_region_flowtype_parsed,
8767 .help_str = "set port <port_id> queue-region region_id <value> "
8768 "flowtype <value>: Set a flowtype region index",
8770 (void *)&cmd_region_flowtype_set,
8771 (void *)&cmd_region_flowtype_port,
8772 (void *)&cmd_region_flowtype_port_index,
8773 (void *)&cmd_region_flowtype_cmd,
8774 (void *)&cmd_region_flowtype_index,
8775 (void *)&cmd_region_flowtype_id,
8776 (void *)&cmd_region_flowtype_flow_index,
8777 (void *)&cmd_region_flowtype_flow_id,
8782 /* *** User Priority (UP) to queue region (region_id) set *** */
8783 struct cmd_user_priority_region_result {
8784 cmdline_fixed_string_t set;
8785 cmdline_fixed_string_t port;
8787 cmdline_fixed_string_t cmd;
8788 cmdline_fixed_string_t user_priority;
8789 uint8_t user_priority_id;
8790 cmdline_fixed_string_t region;
8795 cmd_user_priority_region_parsed(void *parsed_result,
8796 __attribute__((unused)) struct cmdline *cl,
8797 __attribute__((unused)) void *data)
8799 struct cmd_user_priority_region_result *res = parsed_result;
8801 #ifdef RTE_LIBRTE_I40E_PMD
8802 struct rte_pmd_i40e_queue_region_conf region_conf;
8803 enum rte_pmd_i40e_queue_region_op op_type;
8806 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
8809 #ifdef RTE_LIBRTE_I40E_PMD
8810 memset(®ion_conf, 0, sizeof(region_conf));
8811 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_USER_PRIORITY_SET;
8812 region_conf.user_priority = res->user_priority_id;
8813 region_conf.region_id = res->region_id;
8815 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
8816 op_type, ®ion_conf);
8823 printf("function not implemented or supported\n");
8826 printf("user_priority region config error: (%s)\n",
8831 cmdline_parse_token_string_t cmd_user_priority_region_set =
8832 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
8834 cmdline_parse_token_string_t cmd_user_priority_region_port =
8835 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
8837 cmdline_parse_token_num_t cmd_user_priority_region_port_index =
8838 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
8840 cmdline_parse_token_string_t cmd_user_priority_region_cmd =
8841 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
8842 cmd, "queue-region");
8843 cmdline_parse_token_string_t cmd_user_priority_region_UP =
8844 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
8845 user_priority, "UP");
8846 cmdline_parse_token_num_t cmd_user_priority_region_UP_id =
8847 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
8848 user_priority_id, UINT8);
8849 cmdline_parse_token_string_t cmd_user_priority_region_region =
8850 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
8851 region, "region_id");
8852 cmdline_parse_token_num_t cmd_user_priority_region_region_id =
8853 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
8856 cmdline_parse_inst_t cmd_user_priority_region = {
8857 .f = cmd_user_priority_region_parsed,
8859 .help_str = "set port <port_id> queue-region UP <value> "
8860 "region_id <value>: Set the mapping of User Priority (UP) "
8861 "to queue region (region_id) ",
8863 (void *)&cmd_user_priority_region_set,
8864 (void *)&cmd_user_priority_region_port,
8865 (void *)&cmd_user_priority_region_port_index,
8866 (void *)&cmd_user_priority_region_cmd,
8867 (void *)&cmd_user_priority_region_UP,
8868 (void *)&cmd_user_priority_region_UP_id,
8869 (void *)&cmd_user_priority_region_region,
8870 (void *)&cmd_user_priority_region_region_id,
8875 /* *** flush all queue region related configuration *** */
8876 struct cmd_flush_queue_region_result {
8877 cmdline_fixed_string_t set;
8878 cmdline_fixed_string_t port;
8880 cmdline_fixed_string_t cmd;
8881 cmdline_fixed_string_t flush;
8882 cmdline_fixed_string_t what;
8886 cmd_flush_queue_region_parsed(void *parsed_result,
8887 __attribute__((unused)) struct cmdline *cl,
8888 __attribute__((unused)) void *data)
8890 struct cmd_flush_queue_region_result *res = parsed_result;
8892 #ifdef RTE_LIBRTE_I40E_PMD
8893 struct rte_pmd_i40e_queue_region_conf region_conf;
8894 enum rte_pmd_i40e_queue_region_op op_type;
8897 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
8900 #ifdef RTE_LIBRTE_I40E_PMD
8901 memset(®ion_conf, 0, sizeof(region_conf));
8903 if (strcmp(res->what, "on") == 0)
8904 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_ON;
8906 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_OFF;
8908 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
8909 op_type, ®ion_conf);
8916 printf("function not implemented or supported\n");
8919 printf("queue region config flush error: (%s)\n",
8924 cmdline_parse_token_string_t cmd_flush_queue_region_set =
8925 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
8927 cmdline_parse_token_string_t cmd_flush_queue_region_port =
8928 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
8930 cmdline_parse_token_num_t cmd_flush_queue_region_port_index =
8931 TOKEN_NUM_INITIALIZER(struct cmd_flush_queue_region_result,
8933 cmdline_parse_token_string_t cmd_flush_queue_region_cmd =
8934 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
8935 cmd, "queue-region");
8936 cmdline_parse_token_string_t cmd_flush_queue_region_flush =
8937 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
8939 cmdline_parse_token_string_t cmd_flush_queue_region_what =
8940 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
8943 cmdline_parse_inst_t cmd_flush_queue_region = {
8944 .f = cmd_flush_queue_region_parsed,
8946 .help_str = "set port <port_id> queue-region flush on|off"
8947 ": flush all queue region related configuration",
8949 (void *)&cmd_flush_queue_region_set,
8950 (void *)&cmd_flush_queue_region_port,
8951 (void *)&cmd_flush_queue_region_port_index,
8952 (void *)&cmd_flush_queue_region_cmd,
8953 (void *)&cmd_flush_queue_region_flush,
8954 (void *)&cmd_flush_queue_region_what,
8959 /* *** get all queue region related configuration info *** */
8960 struct cmd_show_queue_region_info {
8961 cmdline_fixed_string_t show;
8962 cmdline_fixed_string_t port;
8964 cmdline_fixed_string_t cmd;
8968 cmd_show_queue_region_info_parsed(void *parsed_result,
8969 __attribute__((unused)) struct cmdline *cl,
8970 __attribute__((unused)) void *data)
8972 struct cmd_show_queue_region_info *res = parsed_result;
8974 #ifdef RTE_LIBRTE_I40E_PMD
8975 struct rte_pmd_i40e_queue_regions rte_pmd_regions;
8976 enum rte_pmd_i40e_queue_region_op op_type;
8979 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
8982 #ifdef RTE_LIBRTE_I40E_PMD
8983 memset(&rte_pmd_regions, 0, sizeof(rte_pmd_regions));
8985 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_INFO_GET;
8987 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
8988 op_type, &rte_pmd_regions);
8990 port_queue_region_info_display(res->port_id, &rte_pmd_regions);
8997 printf("function not implemented or supported\n");
9000 printf("queue region config info show error: (%s)\n",
9005 cmdline_parse_token_string_t cmd_show_queue_region_info_get =
9006 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
9008 cmdline_parse_token_string_t cmd_show_queue_region_info_port =
9009 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
9011 cmdline_parse_token_num_t cmd_show_queue_region_info_port_index =
9012 TOKEN_NUM_INITIALIZER(struct cmd_show_queue_region_info,
9014 cmdline_parse_token_string_t cmd_show_queue_region_info_cmd =
9015 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
9016 cmd, "queue-region");
9018 cmdline_parse_inst_t cmd_show_queue_region_info_all = {
9019 .f = cmd_show_queue_region_info_parsed,
9021 .help_str = "show port <port_id> queue-region"
9022 ": show all queue region related configuration info",
9024 (void *)&cmd_show_queue_region_info_get,
9025 (void *)&cmd_show_queue_region_info_port,
9026 (void *)&cmd_show_queue_region_info_port_index,
9027 (void *)&cmd_show_queue_region_info_cmd,
9032 /* *** ADD/REMOVE A 2tuple FILTER *** */
9033 struct cmd_2tuple_filter_result {
9034 cmdline_fixed_string_t filter;
9036 cmdline_fixed_string_t ops;
9037 cmdline_fixed_string_t dst_port;
9038 uint16_t dst_port_value;
9039 cmdline_fixed_string_t protocol;
9040 uint8_t protocol_value;
9041 cmdline_fixed_string_t mask;
9043 cmdline_fixed_string_t tcp_flags;
9044 uint8_t tcp_flags_value;
9045 cmdline_fixed_string_t priority;
9046 uint8_t priority_value;
9047 cmdline_fixed_string_t queue;
9052 cmd_2tuple_filter_parsed(void *parsed_result,
9053 __attribute__((unused)) struct cmdline *cl,
9054 __attribute__((unused)) void *data)
9056 struct rte_eth_ntuple_filter filter;
9057 struct cmd_2tuple_filter_result *res = parsed_result;
9060 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
9062 printf("ntuple filter is not supported on port %u.\n",
9067 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
9069 filter.flags = RTE_2TUPLE_FLAGS;
9070 filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
9071 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
9072 filter.proto = res->protocol_value;
9073 filter.priority = res->priority_value;
9074 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
9075 printf("nonzero tcp_flags is only meaningful"
9076 " when protocol is TCP.\n");
9079 if (res->tcp_flags_value > TCP_FLAG_ALL) {
9080 printf("invalid TCP flags.\n");
9084 if (res->tcp_flags_value != 0) {
9085 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
9086 filter.tcp_flags = res->tcp_flags_value;
9089 /* need convert to big endian. */
9090 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
9091 filter.queue = res->queue_id;
9093 if (!strcmp(res->ops, "add"))
9094 ret = rte_eth_dev_filter_ctrl(res->port_id,
9095 RTE_ETH_FILTER_NTUPLE,
9099 ret = rte_eth_dev_filter_ctrl(res->port_id,
9100 RTE_ETH_FILTER_NTUPLE,
9101 RTE_ETH_FILTER_DELETE,
9104 printf("2tuple filter programming error: (%s)\n",
9109 cmdline_parse_token_string_t cmd_2tuple_filter_filter =
9110 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9111 filter, "2tuple_filter");
9112 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
9113 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9115 cmdline_parse_token_string_t cmd_2tuple_filter_ops =
9116 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9118 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
9119 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9120 dst_port, "dst_port");
9121 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
9122 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9123 dst_port_value, UINT16);
9124 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
9125 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9126 protocol, "protocol");
9127 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
9128 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9129 protocol_value, UINT8);
9130 cmdline_parse_token_string_t cmd_2tuple_filter_mask =
9131 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9133 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value =
9134 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9136 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags =
9137 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9138 tcp_flags, "tcp_flags");
9139 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value =
9140 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9141 tcp_flags_value, UINT8);
9142 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
9143 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9144 priority, "priority");
9145 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
9146 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9147 priority_value, UINT8);
9148 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
9149 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9151 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
9152 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9155 cmdline_parse_inst_t cmd_2tuple_filter = {
9156 .f = cmd_2tuple_filter_parsed,
9158 .help_str = "2tuple_filter <port_id> add|del dst_port <value> protocol "
9159 "<value> mask <value> tcp_flags <value> priority <value> queue "
9160 "<queue_id>: Add a 2tuple filter",
9162 (void *)&cmd_2tuple_filter_filter,
9163 (void *)&cmd_2tuple_filter_port_id,
9164 (void *)&cmd_2tuple_filter_ops,
9165 (void *)&cmd_2tuple_filter_dst_port,
9166 (void *)&cmd_2tuple_filter_dst_port_value,
9167 (void *)&cmd_2tuple_filter_protocol,
9168 (void *)&cmd_2tuple_filter_protocol_value,
9169 (void *)&cmd_2tuple_filter_mask,
9170 (void *)&cmd_2tuple_filter_mask_value,
9171 (void *)&cmd_2tuple_filter_tcp_flags,
9172 (void *)&cmd_2tuple_filter_tcp_flags_value,
9173 (void *)&cmd_2tuple_filter_priority,
9174 (void *)&cmd_2tuple_filter_priority_value,
9175 (void *)&cmd_2tuple_filter_queue,
9176 (void *)&cmd_2tuple_filter_queue_id,
9181 /* *** ADD/REMOVE A 5tuple FILTER *** */
9182 struct cmd_5tuple_filter_result {
9183 cmdline_fixed_string_t filter;
9185 cmdline_fixed_string_t ops;
9186 cmdline_fixed_string_t dst_ip;
9187 cmdline_ipaddr_t dst_ip_value;
9188 cmdline_fixed_string_t src_ip;
9189 cmdline_ipaddr_t src_ip_value;
9190 cmdline_fixed_string_t dst_port;
9191 uint16_t dst_port_value;
9192 cmdline_fixed_string_t src_port;
9193 uint16_t src_port_value;
9194 cmdline_fixed_string_t protocol;
9195 uint8_t protocol_value;
9196 cmdline_fixed_string_t mask;
9198 cmdline_fixed_string_t tcp_flags;
9199 uint8_t tcp_flags_value;
9200 cmdline_fixed_string_t priority;
9201 uint8_t priority_value;
9202 cmdline_fixed_string_t queue;
9207 cmd_5tuple_filter_parsed(void *parsed_result,
9208 __attribute__((unused)) struct cmdline *cl,
9209 __attribute__((unused)) void *data)
9211 struct rte_eth_ntuple_filter filter;
9212 struct cmd_5tuple_filter_result *res = parsed_result;
9215 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
9217 printf("ntuple filter is not supported on port %u.\n",
9222 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
9224 filter.flags = RTE_5TUPLE_FLAGS;
9225 filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0;
9226 filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0;
9227 filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0;
9228 filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
9229 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
9230 filter.proto = res->protocol_value;
9231 filter.priority = res->priority_value;
9232 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
9233 printf("nonzero tcp_flags is only meaningful"
9234 " when protocol is TCP.\n");
9237 if (res->tcp_flags_value > TCP_FLAG_ALL) {
9238 printf("invalid TCP flags.\n");
9242 if (res->tcp_flags_value != 0) {
9243 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
9244 filter.tcp_flags = res->tcp_flags_value;
9247 if (res->dst_ip_value.family == AF_INET)
9248 /* no need to convert, already big endian. */
9249 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
9251 if (filter.dst_ip_mask == 0) {
9252 printf("can not support ipv6 involved compare.\n");
9258 if (res->src_ip_value.family == AF_INET)
9259 /* no need to convert, already big endian. */
9260 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
9262 if (filter.src_ip_mask == 0) {
9263 printf("can not support ipv6 involved compare.\n");
9268 /* need convert to big endian. */
9269 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
9270 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
9271 filter.queue = res->queue_id;
9273 if (!strcmp(res->ops, "add"))
9274 ret = rte_eth_dev_filter_ctrl(res->port_id,
9275 RTE_ETH_FILTER_NTUPLE,
9279 ret = rte_eth_dev_filter_ctrl(res->port_id,
9280 RTE_ETH_FILTER_NTUPLE,
9281 RTE_ETH_FILTER_DELETE,
9284 printf("5tuple filter programming error: (%s)\n",
9288 cmdline_parse_token_string_t cmd_5tuple_filter_filter =
9289 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9290 filter, "5tuple_filter");
9291 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
9292 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9294 cmdline_parse_token_string_t cmd_5tuple_filter_ops =
9295 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9297 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
9298 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9300 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
9301 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
9303 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
9304 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9306 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
9307 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
9309 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
9310 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9311 dst_port, "dst_port");
9312 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
9313 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9314 dst_port_value, UINT16);
9315 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
9316 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9317 src_port, "src_port");
9318 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
9319 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9320 src_port_value, UINT16);
9321 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
9322 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9323 protocol, "protocol");
9324 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
9325 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9326 protocol_value, UINT8);
9327 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
9328 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9330 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
9331 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9333 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags =
9334 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9335 tcp_flags, "tcp_flags");
9336 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value =
9337 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9338 tcp_flags_value, UINT8);
9339 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
9340 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9341 priority, "priority");
9342 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
9343 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9344 priority_value, UINT8);
9345 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
9346 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9348 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
9349 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9352 cmdline_parse_inst_t cmd_5tuple_filter = {
9353 .f = cmd_5tuple_filter_parsed,
9355 .help_str = "5tuple_filter <port_id> add|del dst_ip <value> "
9356 "src_ip <value> dst_port <value> src_port <value> "
9357 "protocol <value> mask <value> tcp_flags <value> "
9358 "priority <value> queue <queue_id>: Add/Del a 5tuple filter",
9360 (void *)&cmd_5tuple_filter_filter,
9361 (void *)&cmd_5tuple_filter_port_id,
9362 (void *)&cmd_5tuple_filter_ops,
9363 (void *)&cmd_5tuple_filter_dst_ip,
9364 (void *)&cmd_5tuple_filter_dst_ip_value,
9365 (void *)&cmd_5tuple_filter_src_ip,
9366 (void *)&cmd_5tuple_filter_src_ip_value,
9367 (void *)&cmd_5tuple_filter_dst_port,
9368 (void *)&cmd_5tuple_filter_dst_port_value,
9369 (void *)&cmd_5tuple_filter_src_port,
9370 (void *)&cmd_5tuple_filter_src_port_value,
9371 (void *)&cmd_5tuple_filter_protocol,
9372 (void *)&cmd_5tuple_filter_protocol_value,
9373 (void *)&cmd_5tuple_filter_mask,
9374 (void *)&cmd_5tuple_filter_mask_value,
9375 (void *)&cmd_5tuple_filter_tcp_flags,
9376 (void *)&cmd_5tuple_filter_tcp_flags_value,
9377 (void *)&cmd_5tuple_filter_priority,
9378 (void *)&cmd_5tuple_filter_priority_value,
9379 (void *)&cmd_5tuple_filter_queue,
9380 (void *)&cmd_5tuple_filter_queue_id,
9385 /* *** ADD/REMOVE A flex FILTER *** */
9386 struct cmd_flex_filter_result {
9387 cmdline_fixed_string_t filter;
9388 cmdline_fixed_string_t ops;
9390 cmdline_fixed_string_t len;
9392 cmdline_fixed_string_t bytes;
9393 cmdline_fixed_string_t bytes_value;
9394 cmdline_fixed_string_t mask;
9395 cmdline_fixed_string_t mask_value;
9396 cmdline_fixed_string_t priority;
9397 uint8_t priority_value;
9398 cmdline_fixed_string_t queue;
9402 static int xdigit2val(unsigned char c)
9407 else if (isupper(c))
9415 cmd_flex_filter_parsed(void *parsed_result,
9416 __attribute__((unused)) struct cmdline *cl,
9417 __attribute__((unused)) void *data)
9420 struct rte_eth_flex_filter filter;
9421 struct cmd_flex_filter_result *res = parsed_result;
9422 char *bytes_ptr, *mask_ptr;
9423 uint16_t len, i, j = 0;
9428 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) {
9429 printf("the len exceed the max length 128\n");
9432 memset(&filter, 0, sizeof(struct rte_eth_flex_filter));
9433 filter.len = res->len_value;
9434 filter.priority = res->priority_value;
9435 filter.queue = res->queue_id;
9436 bytes_ptr = res->bytes_value;
9437 mask_ptr = res->mask_value;
9439 /* translate bytes string to array. */
9440 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
9441 (bytes_ptr[1] == 'X')))
9443 len = strnlen(bytes_ptr, res->len_value * 2);
9444 if (len == 0 || (len % 8 != 0)) {
9445 printf("please check len and bytes input\n");
9448 for (i = 0; i < len; i++) {
9450 if (isxdigit(c) == 0) {
9451 /* invalid characters. */
9452 printf("invalid input\n");
9455 val = xdigit2val(c);
9458 filter.bytes[j] = byte;
9459 printf("bytes[%d]:%02x ", j, filter.bytes[j]);
9466 /* translate mask string to uint8_t array. */
9467 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
9468 (mask_ptr[1] == 'X')))
9470 len = strnlen(mask_ptr, (res->len_value + 3) / 4);
9472 printf("invalid input\n");
9477 for (i = 0; i < len; i++) {
9479 if (isxdigit(c) == 0) {
9480 /* invalid characters. */
9481 printf("invalid input\n");
9484 val = xdigit2val(c);
9487 filter.mask[j] = byte;
9488 printf("mask[%d]:%02x ", j, filter.mask[j]);
9496 if (!strcmp(res->ops, "add"))
9497 ret = rte_eth_dev_filter_ctrl(res->port_id,
9498 RTE_ETH_FILTER_FLEXIBLE,
9502 ret = rte_eth_dev_filter_ctrl(res->port_id,
9503 RTE_ETH_FILTER_FLEXIBLE,
9504 RTE_ETH_FILTER_DELETE,
9508 printf("flex filter setting error: (%s)\n", strerror(-ret));
9511 cmdline_parse_token_string_t cmd_flex_filter_filter =
9512 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9513 filter, "flex_filter");
9514 cmdline_parse_token_num_t cmd_flex_filter_port_id =
9515 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
9517 cmdline_parse_token_string_t cmd_flex_filter_ops =
9518 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9520 cmdline_parse_token_string_t cmd_flex_filter_len =
9521 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9523 cmdline_parse_token_num_t cmd_flex_filter_len_value =
9524 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
9526 cmdline_parse_token_string_t cmd_flex_filter_bytes =
9527 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9529 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
9530 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9532 cmdline_parse_token_string_t cmd_flex_filter_mask =
9533 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9535 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
9536 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9538 cmdline_parse_token_string_t cmd_flex_filter_priority =
9539 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9540 priority, "priority");
9541 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
9542 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
9543 priority_value, UINT8);
9544 cmdline_parse_token_string_t cmd_flex_filter_queue =
9545 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9547 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
9548 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
9550 cmdline_parse_inst_t cmd_flex_filter = {
9551 .f = cmd_flex_filter_parsed,
9553 .help_str = "flex_filter <port_id> add|del len <value> bytes "
9554 "<value> mask <value> priority <value> queue <queue_id>: "
9555 "Add/Del a flex filter",
9557 (void *)&cmd_flex_filter_filter,
9558 (void *)&cmd_flex_filter_port_id,
9559 (void *)&cmd_flex_filter_ops,
9560 (void *)&cmd_flex_filter_len,
9561 (void *)&cmd_flex_filter_len_value,
9562 (void *)&cmd_flex_filter_bytes,
9563 (void *)&cmd_flex_filter_bytes_value,
9564 (void *)&cmd_flex_filter_mask,
9565 (void *)&cmd_flex_filter_mask_value,
9566 (void *)&cmd_flex_filter_priority,
9567 (void *)&cmd_flex_filter_priority_value,
9568 (void *)&cmd_flex_filter_queue,
9569 (void *)&cmd_flex_filter_queue_id,
9574 /* *** Filters Control *** */
9576 /* *** deal with ethertype filter *** */
9577 struct cmd_ethertype_filter_result {
9578 cmdline_fixed_string_t filter;
9580 cmdline_fixed_string_t ops;
9581 cmdline_fixed_string_t mac;
9582 struct ether_addr mac_addr;
9583 cmdline_fixed_string_t ethertype;
9584 uint16_t ethertype_value;
9585 cmdline_fixed_string_t drop;
9586 cmdline_fixed_string_t queue;
9590 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
9591 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9592 filter, "ethertype_filter");
9593 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
9594 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
9596 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
9597 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9599 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
9600 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9601 mac, "mac_addr#mac_ignr");
9602 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
9603 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
9605 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
9606 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9607 ethertype, "ethertype");
9608 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
9609 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
9610 ethertype_value, UINT16);
9611 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
9612 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9614 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
9615 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9617 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
9618 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
9622 cmd_ethertype_filter_parsed(void *parsed_result,
9623 __attribute__((unused)) struct cmdline *cl,
9624 __attribute__((unused)) void *data)
9626 struct cmd_ethertype_filter_result *res = parsed_result;
9627 struct rte_eth_ethertype_filter filter;
9630 ret = rte_eth_dev_filter_supported(res->port_id,
9631 RTE_ETH_FILTER_ETHERTYPE);
9633 printf("ethertype filter is not supported on port %u.\n",
9638 memset(&filter, 0, sizeof(filter));
9639 if (!strcmp(res->mac, "mac_addr")) {
9640 filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
9641 rte_memcpy(&filter.mac_addr, &res->mac_addr,
9642 sizeof(struct ether_addr));
9644 if (!strcmp(res->drop, "drop"))
9645 filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
9646 filter.ether_type = res->ethertype_value;
9647 filter.queue = res->queue_id;
9649 if (!strcmp(res->ops, "add"))
9650 ret = rte_eth_dev_filter_ctrl(res->port_id,
9651 RTE_ETH_FILTER_ETHERTYPE,
9655 ret = rte_eth_dev_filter_ctrl(res->port_id,
9656 RTE_ETH_FILTER_ETHERTYPE,
9657 RTE_ETH_FILTER_DELETE,
9660 printf("ethertype filter programming error: (%s)\n",
9664 cmdline_parse_inst_t cmd_ethertype_filter = {
9665 .f = cmd_ethertype_filter_parsed,
9667 .help_str = "ethertype_filter <port_id> add|del mac_addr|mac_ignr "
9668 "<mac_addr> ethertype <value> drop|fw queue <queue_id>: "
9669 "Add or delete an ethertype filter entry",
9671 (void *)&cmd_ethertype_filter_filter,
9672 (void *)&cmd_ethertype_filter_port_id,
9673 (void *)&cmd_ethertype_filter_ops,
9674 (void *)&cmd_ethertype_filter_mac,
9675 (void *)&cmd_ethertype_filter_mac_addr,
9676 (void *)&cmd_ethertype_filter_ethertype,
9677 (void *)&cmd_ethertype_filter_ethertype_value,
9678 (void *)&cmd_ethertype_filter_drop,
9679 (void *)&cmd_ethertype_filter_queue,
9680 (void *)&cmd_ethertype_filter_queue_id,
9685 /* *** deal with flow director filter *** */
9686 struct cmd_flow_director_result {
9687 cmdline_fixed_string_t flow_director_filter;
9689 cmdline_fixed_string_t mode;
9690 cmdline_fixed_string_t mode_value;
9691 cmdline_fixed_string_t ops;
9692 cmdline_fixed_string_t flow;
9693 cmdline_fixed_string_t flow_type;
9694 cmdline_fixed_string_t ether;
9695 uint16_t ether_type;
9696 cmdline_fixed_string_t src;
9697 cmdline_ipaddr_t ip_src;
9699 cmdline_fixed_string_t dst;
9700 cmdline_ipaddr_t ip_dst;
9702 cmdline_fixed_string_t verify_tag;
9703 uint32_t verify_tag_value;
9704 cmdline_ipaddr_t tos;
9706 cmdline_ipaddr_t proto;
9707 uint8_t proto_value;
9708 cmdline_ipaddr_t ttl;
9710 cmdline_fixed_string_t vlan;
9711 uint16_t vlan_value;
9712 cmdline_fixed_string_t flexbytes;
9713 cmdline_fixed_string_t flexbytes_value;
9714 cmdline_fixed_string_t pf_vf;
9715 cmdline_fixed_string_t drop;
9716 cmdline_fixed_string_t queue;
9718 cmdline_fixed_string_t fd_id;
9719 uint32_t fd_id_value;
9720 cmdline_fixed_string_t mac;
9721 struct ether_addr mac_addr;
9722 cmdline_fixed_string_t tunnel;
9723 cmdline_fixed_string_t tunnel_type;
9724 cmdline_fixed_string_t tunnel_id;
9725 uint32_t tunnel_id_value;
9729 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
9732 const char *p, *p0 = q_arg;
9734 unsigned long int_fld;
9735 char *str_fld[max_num];
9740 p = strchr(p0, '(');
9744 p0 = strchr(p, ')');
9749 if (size >= sizeof(s))
9752 snprintf(s, sizeof(s), "%.*s", size, p);
9753 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
9754 if (ret < 0 || ret > max_num)
9756 for (i = 0; i < ret; i++) {
9758 int_fld = strtoul(str_fld[i], &end, 0);
9759 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
9761 flexbytes[i] = (uint8_t)int_fld;
9767 str2flowtype(char *string)
9770 static const struct {
9773 } flowtype_str[] = {
9774 {"raw", RTE_ETH_FLOW_RAW},
9775 {"ipv4", RTE_ETH_FLOW_IPV4},
9776 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
9777 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
9778 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
9779 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
9780 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
9781 {"ipv6", RTE_ETH_FLOW_IPV6},
9782 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
9783 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
9784 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
9785 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
9786 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
9787 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
9790 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
9791 if (!strcmp(flowtype_str[i].str, string))
9792 return flowtype_str[i].type;
9795 if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64)
9796 return (uint16_t)atoi(string);
9798 return RTE_ETH_FLOW_UNKNOWN;
9801 static enum rte_eth_fdir_tunnel_type
9802 str2fdir_tunneltype(char *string)
9806 static const struct {
9808 enum rte_eth_fdir_tunnel_type type;
9809 } tunneltype_str[] = {
9810 {"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE},
9811 {"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN},
9814 for (i = 0; i < RTE_DIM(tunneltype_str); i++) {
9815 if (!strcmp(tunneltype_str[i].str, string))
9816 return tunneltype_str[i].type;
9818 return RTE_FDIR_TUNNEL_TYPE_UNKNOWN;
9821 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
9823 if ((ip_addr).family == AF_INET) \
9824 (ip) = (ip_addr).addr.ipv4.s_addr; \
9826 printf("invalid parameter.\n"); \
9831 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
9833 if ((ip_addr).family == AF_INET6) \
9835 &((ip_addr).addr.ipv6), \
9836 sizeof(struct in6_addr)); \
9838 printf("invalid parameter.\n"); \
9844 cmd_flow_director_filter_parsed(void *parsed_result,
9845 __attribute__((unused)) struct cmdline *cl,
9846 __attribute__((unused)) void *data)
9848 struct cmd_flow_director_result *res = parsed_result;
9849 struct rte_eth_fdir_filter entry;
9850 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
9852 unsigned long vf_id;
9855 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
9857 printf("flow director is not supported on port %u.\n",
9861 memset(flexbytes, 0, sizeof(flexbytes));
9862 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
9864 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
9865 if (strcmp(res->mode_value, "MAC-VLAN")) {
9866 printf("Please set mode to MAC-VLAN.\n");
9869 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
9870 if (strcmp(res->mode_value, "Tunnel")) {
9871 printf("Please set mode to Tunnel.\n");
9875 if (strcmp(res->mode_value, "IP")) {
9876 printf("Please set mode to IP.\n");
9879 entry.input.flow_type = str2flowtype(res->flow_type);
9882 ret = parse_flexbytes(res->flexbytes_value,
9884 RTE_ETH_FDIR_MAX_FLEXLEN);
9886 printf("error: Cannot parse flexbytes input.\n");
9890 switch (entry.input.flow_type) {
9891 case RTE_ETH_FLOW_FRAG_IPV4:
9892 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
9893 entry.input.flow.ip4_flow.proto = res->proto_value;
9895 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
9896 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
9897 IPV4_ADDR_TO_UINT(res->ip_dst,
9898 entry.input.flow.ip4_flow.dst_ip);
9899 IPV4_ADDR_TO_UINT(res->ip_src,
9900 entry.input.flow.ip4_flow.src_ip);
9901 entry.input.flow.ip4_flow.tos = res->tos_value;
9902 entry.input.flow.ip4_flow.ttl = res->ttl_value;
9903 /* need convert to big endian. */
9904 entry.input.flow.udp4_flow.dst_port =
9905 rte_cpu_to_be_16(res->port_dst);
9906 entry.input.flow.udp4_flow.src_port =
9907 rte_cpu_to_be_16(res->port_src);
9909 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
9910 IPV4_ADDR_TO_UINT(res->ip_dst,
9911 entry.input.flow.sctp4_flow.ip.dst_ip);
9912 IPV4_ADDR_TO_UINT(res->ip_src,
9913 entry.input.flow.sctp4_flow.ip.src_ip);
9914 entry.input.flow.ip4_flow.tos = res->tos_value;
9915 entry.input.flow.ip4_flow.ttl = res->ttl_value;
9916 /* need convert to big endian. */
9917 entry.input.flow.sctp4_flow.dst_port =
9918 rte_cpu_to_be_16(res->port_dst);
9919 entry.input.flow.sctp4_flow.src_port =
9920 rte_cpu_to_be_16(res->port_src);
9921 entry.input.flow.sctp4_flow.verify_tag =
9922 rte_cpu_to_be_32(res->verify_tag_value);
9924 case RTE_ETH_FLOW_FRAG_IPV6:
9925 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
9926 entry.input.flow.ipv6_flow.proto = res->proto_value;
9928 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
9929 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
9930 IPV6_ADDR_TO_ARRAY(res->ip_dst,
9931 entry.input.flow.ipv6_flow.dst_ip);
9932 IPV6_ADDR_TO_ARRAY(res->ip_src,
9933 entry.input.flow.ipv6_flow.src_ip);
9934 entry.input.flow.ipv6_flow.tc = res->tos_value;
9935 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
9936 /* need convert to big endian. */
9937 entry.input.flow.udp6_flow.dst_port =
9938 rte_cpu_to_be_16(res->port_dst);
9939 entry.input.flow.udp6_flow.src_port =
9940 rte_cpu_to_be_16(res->port_src);
9942 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
9943 IPV6_ADDR_TO_ARRAY(res->ip_dst,
9944 entry.input.flow.sctp6_flow.ip.dst_ip);
9945 IPV6_ADDR_TO_ARRAY(res->ip_src,
9946 entry.input.flow.sctp6_flow.ip.src_ip);
9947 entry.input.flow.ipv6_flow.tc = res->tos_value;
9948 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
9949 /* need convert to big endian. */
9950 entry.input.flow.sctp6_flow.dst_port =
9951 rte_cpu_to_be_16(res->port_dst);
9952 entry.input.flow.sctp6_flow.src_port =
9953 rte_cpu_to_be_16(res->port_src);
9954 entry.input.flow.sctp6_flow.verify_tag =
9955 rte_cpu_to_be_32(res->verify_tag_value);
9957 case RTE_ETH_FLOW_L2_PAYLOAD:
9958 entry.input.flow.l2_flow.ether_type =
9959 rte_cpu_to_be_16(res->ether_type);
9965 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN)
9966 rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr,
9968 sizeof(struct ether_addr));
9970 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
9971 rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr,
9973 sizeof(struct ether_addr));
9974 entry.input.flow.tunnel_flow.tunnel_type =
9975 str2fdir_tunneltype(res->tunnel_type);
9976 entry.input.flow.tunnel_flow.tunnel_id =
9977 rte_cpu_to_be_32(res->tunnel_id_value);
9980 rte_memcpy(entry.input.flow_ext.flexbytes,
9982 RTE_ETH_FDIR_MAX_FLEXLEN);
9984 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
9986 entry.action.flex_off = 0; /*use 0 by default */
9987 if (!strcmp(res->drop, "drop"))
9988 entry.action.behavior = RTE_ETH_FDIR_REJECT;
9990 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
9992 if (fdir_conf.mode != RTE_FDIR_MODE_PERFECT_MAC_VLAN &&
9993 fdir_conf.mode != RTE_FDIR_MODE_PERFECT_TUNNEL) {
9994 if (!strcmp(res->pf_vf, "pf"))
9995 entry.input.flow_ext.is_vf = 0;
9996 else if (!strncmp(res->pf_vf, "vf", 2)) {
9997 struct rte_eth_dev_info dev_info;
9999 memset(&dev_info, 0, sizeof(dev_info));
10000 rte_eth_dev_info_get(res->port_id, &dev_info);
10002 vf_id = strtoul(res->pf_vf + 2, &end, 10);
10003 if (errno != 0 || *end != '\0' ||
10004 vf_id >= dev_info.max_vfs) {
10005 printf("invalid parameter %s.\n", res->pf_vf);
10008 entry.input.flow_ext.is_vf = 1;
10009 entry.input.flow_ext.dst_id = (uint16_t)vf_id;
10011 printf("invalid parameter %s.\n", res->pf_vf);
10016 /* set to report FD ID by default */
10017 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
10018 entry.action.rx_queue = res->queue_id;
10019 entry.soft_id = res->fd_id_value;
10020 if (!strcmp(res->ops, "add"))
10021 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10022 RTE_ETH_FILTER_ADD, &entry);
10023 else if (!strcmp(res->ops, "del"))
10024 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10025 RTE_ETH_FILTER_DELETE, &entry);
10027 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10028 RTE_ETH_FILTER_UPDATE, &entry);
10030 printf("flow director programming error: (%s)\n",
10034 cmdline_parse_token_string_t cmd_flow_director_filter =
10035 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10036 flow_director_filter, "flow_director_filter");
10037 cmdline_parse_token_num_t cmd_flow_director_port_id =
10038 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10040 cmdline_parse_token_string_t cmd_flow_director_ops =
10041 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10042 ops, "add#del#update");
10043 cmdline_parse_token_string_t cmd_flow_director_flow =
10044 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10046 cmdline_parse_token_string_t cmd_flow_director_flow_type =
10047 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10048 flow_type, "ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
10049 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload");
10050 cmdline_parse_token_string_t cmd_flow_director_ether =
10051 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10053 cmdline_parse_token_num_t cmd_flow_director_ether_type =
10054 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10055 ether_type, UINT16);
10056 cmdline_parse_token_string_t cmd_flow_director_src =
10057 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10059 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
10060 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
10062 cmdline_parse_token_num_t cmd_flow_director_port_src =
10063 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10065 cmdline_parse_token_string_t cmd_flow_director_dst =
10066 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10068 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
10069 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
10071 cmdline_parse_token_num_t cmd_flow_director_port_dst =
10072 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10074 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
10075 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10076 verify_tag, "verify_tag");
10077 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
10078 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10079 verify_tag_value, UINT32);
10080 cmdline_parse_token_string_t cmd_flow_director_tos =
10081 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10083 cmdline_parse_token_num_t cmd_flow_director_tos_value =
10084 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10086 cmdline_parse_token_string_t cmd_flow_director_proto =
10087 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10089 cmdline_parse_token_num_t cmd_flow_director_proto_value =
10090 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10091 proto_value, UINT8);
10092 cmdline_parse_token_string_t cmd_flow_director_ttl =
10093 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10095 cmdline_parse_token_num_t cmd_flow_director_ttl_value =
10096 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10098 cmdline_parse_token_string_t cmd_flow_director_vlan =
10099 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10101 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
10102 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10103 vlan_value, UINT16);
10104 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
10105 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10106 flexbytes, "flexbytes");
10107 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
10108 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10109 flexbytes_value, NULL);
10110 cmdline_parse_token_string_t cmd_flow_director_drop =
10111 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10113 cmdline_parse_token_string_t cmd_flow_director_pf_vf =
10114 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10116 cmdline_parse_token_string_t cmd_flow_director_queue =
10117 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10119 cmdline_parse_token_num_t cmd_flow_director_queue_id =
10120 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10122 cmdline_parse_token_string_t cmd_flow_director_fd_id =
10123 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10125 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
10126 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10127 fd_id_value, UINT32);
10129 cmdline_parse_token_string_t cmd_flow_director_mode =
10130 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10132 cmdline_parse_token_string_t cmd_flow_director_mode_ip =
10133 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10135 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan =
10136 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10137 mode_value, "MAC-VLAN");
10138 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel =
10139 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10140 mode_value, "Tunnel");
10141 cmdline_parse_token_string_t cmd_flow_director_mac =
10142 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10144 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr =
10145 TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result,
10147 cmdline_parse_token_string_t cmd_flow_director_tunnel =
10148 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10150 cmdline_parse_token_string_t cmd_flow_director_tunnel_type =
10151 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10152 tunnel_type, "NVGRE#VxLAN");
10153 cmdline_parse_token_string_t cmd_flow_director_tunnel_id =
10154 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10155 tunnel_id, "tunnel-id");
10156 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value =
10157 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10158 tunnel_id_value, UINT32);
10160 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
10161 .f = cmd_flow_director_filter_parsed,
10163 .help_str = "flow_director_filter <port_id> mode IP add|del|update flow"
10164 " ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
10165 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
10166 "l2_payload src <src_ip> dst <dst_ip> tos <tos_value> "
10167 "proto <proto_value> ttl <ttl_value> vlan <vlan_value> "
10168 "flexbytes <flexbyte_vaues> drop|fw <pf_vf> queue <queue_id> "
10169 "fd_id <fd_id_value>: "
10170 "Add or delete an ip flow director entry on NIC",
10172 (void *)&cmd_flow_director_filter,
10173 (void *)&cmd_flow_director_port_id,
10174 (void *)&cmd_flow_director_mode,
10175 (void *)&cmd_flow_director_mode_ip,
10176 (void *)&cmd_flow_director_ops,
10177 (void *)&cmd_flow_director_flow,
10178 (void *)&cmd_flow_director_flow_type,
10179 (void *)&cmd_flow_director_src,
10180 (void *)&cmd_flow_director_ip_src,
10181 (void *)&cmd_flow_director_dst,
10182 (void *)&cmd_flow_director_ip_dst,
10183 (void *)&cmd_flow_director_tos,
10184 (void *)&cmd_flow_director_tos_value,
10185 (void *)&cmd_flow_director_proto,
10186 (void *)&cmd_flow_director_proto_value,
10187 (void *)&cmd_flow_director_ttl,
10188 (void *)&cmd_flow_director_ttl_value,
10189 (void *)&cmd_flow_director_vlan,
10190 (void *)&cmd_flow_director_vlan_value,
10191 (void *)&cmd_flow_director_flexbytes,
10192 (void *)&cmd_flow_director_flexbytes_value,
10193 (void *)&cmd_flow_director_drop,
10194 (void *)&cmd_flow_director_pf_vf,
10195 (void *)&cmd_flow_director_queue,
10196 (void *)&cmd_flow_director_queue_id,
10197 (void *)&cmd_flow_director_fd_id,
10198 (void *)&cmd_flow_director_fd_id_value,
10203 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
10204 .f = cmd_flow_director_filter_parsed,
10206 .help_str = "flow_director_filter ... : Add or delete an udp/tcp flow "
10207 "director entry on NIC",
10209 (void *)&cmd_flow_director_filter,
10210 (void *)&cmd_flow_director_port_id,
10211 (void *)&cmd_flow_director_mode,
10212 (void *)&cmd_flow_director_mode_ip,
10213 (void *)&cmd_flow_director_ops,
10214 (void *)&cmd_flow_director_flow,
10215 (void *)&cmd_flow_director_flow_type,
10216 (void *)&cmd_flow_director_src,
10217 (void *)&cmd_flow_director_ip_src,
10218 (void *)&cmd_flow_director_port_src,
10219 (void *)&cmd_flow_director_dst,
10220 (void *)&cmd_flow_director_ip_dst,
10221 (void *)&cmd_flow_director_port_dst,
10222 (void *)&cmd_flow_director_tos,
10223 (void *)&cmd_flow_director_tos_value,
10224 (void *)&cmd_flow_director_ttl,
10225 (void *)&cmd_flow_director_ttl_value,
10226 (void *)&cmd_flow_director_vlan,
10227 (void *)&cmd_flow_director_vlan_value,
10228 (void *)&cmd_flow_director_flexbytes,
10229 (void *)&cmd_flow_director_flexbytes_value,
10230 (void *)&cmd_flow_director_drop,
10231 (void *)&cmd_flow_director_pf_vf,
10232 (void *)&cmd_flow_director_queue,
10233 (void *)&cmd_flow_director_queue_id,
10234 (void *)&cmd_flow_director_fd_id,
10235 (void *)&cmd_flow_director_fd_id_value,
10240 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
10241 .f = cmd_flow_director_filter_parsed,
10243 .help_str = "flow_director_filter ... : Add or delete a sctp flow "
10244 "director entry on NIC",
10246 (void *)&cmd_flow_director_filter,
10247 (void *)&cmd_flow_director_port_id,
10248 (void *)&cmd_flow_director_mode,
10249 (void *)&cmd_flow_director_mode_ip,
10250 (void *)&cmd_flow_director_ops,
10251 (void *)&cmd_flow_director_flow,
10252 (void *)&cmd_flow_director_flow_type,
10253 (void *)&cmd_flow_director_src,
10254 (void *)&cmd_flow_director_ip_src,
10255 (void *)&cmd_flow_director_port_dst,
10256 (void *)&cmd_flow_director_dst,
10257 (void *)&cmd_flow_director_ip_dst,
10258 (void *)&cmd_flow_director_port_dst,
10259 (void *)&cmd_flow_director_verify_tag,
10260 (void *)&cmd_flow_director_verify_tag_value,
10261 (void *)&cmd_flow_director_tos,
10262 (void *)&cmd_flow_director_tos_value,
10263 (void *)&cmd_flow_director_ttl,
10264 (void *)&cmd_flow_director_ttl_value,
10265 (void *)&cmd_flow_director_vlan,
10266 (void *)&cmd_flow_director_vlan_value,
10267 (void *)&cmd_flow_director_flexbytes,
10268 (void *)&cmd_flow_director_flexbytes_value,
10269 (void *)&cmd_flow_director_drop,
10270 (void *)&cmd_flow_director_pf_vf,
10271 (void *)&cmd_flow_director_queue,
10272 (void *)&cmd_flow_director_queue_id,
10273 (void *)&cmd_flow_director_fd_id,
10274 (void *)&cmd_flow_director_fd_id_value,
10279 cmdline_parse_inst_t cmd_add_del_l2_flow_director = {
10280 .f = cmd_flow_director_filter_parsed,
10282 .help_str = "flow_director_filter ... : Add or delete a L2 flow "
10283 "director entry on NIC",
10285 (void *)&cmd_flow_director_filter,
10286 (void *)&cmd_flow_director_port_id,
10287 (void *)&cmd_flow_director_mode,
10288 (void *)&cmd_flow_director_mode_ip,
10289 (void *)&cmd_flow_director_ops,
10290 (void *)&cmd_flow_director_flow,
10291 (void *)&cmd_flow_director_flow_type,
10292 (void *)&cmd_flow_director_ether,
10293 (void *)&cmd_flow_director_ether_type,
10294 (void *)&cmd_flow_director_flexbytes,
10295 (void *)&cmd_flow_director_flexbytes_value,
10296 (void *)&cmd_flow_director_drop,
10297 (void *)&cmd_flow_director_pf_vf,
10298 (void *)&cmd_flow_director_queue,
10299 (void *)&cmd_flow_director_queue_id,
10300 (void *)&cmd_flow_director_fd_id,
10301 (void *)&cmd_flow_director_fd_id_value,
10306 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = {
10307 .f = cmd_flow_director_filter_parsed,
10309 .help_str = "flow_director_filter ... : Add or delete a MAC VLAN flow "
10310 "director entry on NIC",
10312 (void *)&cmd_flow_director_filter,
10313 (void *)&cmd_flow_director_port_id,
10314 (void *)&cmd_flow_director_mode,
10315 (void *)&cmd_flow_director_mode_mac_vlan,
10316 (void *)&cmd_flow_director_ops,
10317 (void *)&cmd_flow_director_mac,
10318 (void *)&cmd_flow_director_mac_addr,
10319 (void *)&cmd_flow_director_vlan,
10320 (void *)&cmd_flow_director_vlan_value,
10321 (void *)&cmd_flow_director_flexbytes,
10322 (void *)&cmd_flow_director_flexbytes_value,
10323 (void *)&cmd_flow_director_drop,
10324 (void *)&cmd_flow_director_queue,
10325 (void *)&cmd_flow_director_queue_id,
10326 (void *)&cmd_flow_director_fd_id,
10327 (void *)&cmd_flow_director_fd_id_value,
10332 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = {
10333 .f = cmd_flow_director_filter_parsed,
10335 .help_str = "flow_director_filter ... : Add or delete a tunnel flow "
10336 "director entry on NIC",
10338 (void *)&cmd_flow_director_filter,
10339 (void *)&cmd_flow_director_port_id,
10340 (void *)&cmd_flow_director_mode,
10341 (void *)&cmd_flow_director_mode_tunnel,
10342 (void *)&cmd_flow_director_ops,
10343 (void *)&cmd_flow_director_mac,
10344 (void *)&cmd_flow_director_mac_addr,
10345 (void *)&cmd_flow_director_vlan,
10346 (void *)&cmd_flow_director_vlan_value,
10347 (void *)&cmd_flow_director_tunnel,
10348 (void *)&cmd_flow_director_tunnel_type,
10349 (void *)&cmd_flow_director_tunnel_id,
10350 (void *)&cmd_flow_director_tunnel_id_value,
10351 (void *)&cmd_flow_director_flexbytes,
10352 (void *)&cmd_flow_director_flexbytes_value,
10353 (void *)&cmd_flow_director_drop,
10354 (void *)&cmd_flow_director_queue,
10355 (void *)&cmd_flow_director_queue_id,
10356 (void *)&cmd_flow_director_fd_id,
10357 (void *)&cmd_flow_director_fd_id_value,
10362 struct cmd_flush_flow_director_result {
10363 cmdline_fixed_string_t flush_flow_director;
10367 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
10368 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
10369 flush_flow_director, "flush_flow_director");
10370 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
10371 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
10375 cmd_flush_flow_director_parsed(void *parsed_result,
10376 __attribute__((unused)) struct cmdline *cl,
10377 __attribute__((unused)) void *data)
10379 struct cmd_flow_director_result *res = parsed_result;
10382 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
10384 printf("flow director is not supported on port %u.\n",
10389 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10390 RTE_ETH_FILTER_FLUSH, NULL);
10392 printf("flow director table flushing error: (%s)\n",
10396 cmdline_parse_inst_t cmd_flush_flow_director = {
10397 .f = cmd_flush_flow_director_parsed,
10399 .help_str = "flush_flow_director <port_id>: "
10400 "Flush all flow director entries of a device on NIC",
10402 (void *)&cmd_flush_flow_director_flush,
10403 (void *)&cmd_flush_flow_director_port_id,
10408 /* *** deal with flow director mask *** */
10409 struct cmd_flow_director_mask_result {
10410 cmdline_fixed_string_t flow_director_mask;
10412 cmdline_fixed_string_t mode;
10413 cmdline_fixed_string_t mode_value;
10414 cmdline_fixed_string_t vlan;
10415 uint16_t vlan_mask;
10416 cmdline_fixed_string_t src_mask;
10417 cmdline_ipaddr_t ipv4_src;
10418 cmdline_ipaddr_t ipv6_src;
10420 cmdline_fixed_string_t dst_mask;
10421 cmdline_ipaddr_t ipv4_dst;
10422 cmdline_ipaddr_t ipv6_dst;
10424 cmdline_fixed_string_t mac;
10425 uint8_t mac_addr_byte_mask;
10426 cmdline_fixed_string_t tunnel_id;
10427 uint32_t tunnel_id_mask;
10428 cmdline_fixed_string_t tunnel_type;
10429 uint8_t tunnel_type_mask;
10433 cmd_flow_director_mask_parsed(void *parsed_result,
10434 __attribute__((unused)) struct cmdline *cl,
10435 __attribute__((unused)) void *data)
10437 struct cmd_flow_director_mask_result *res = parsed_result;
10438 struct rte_eth_fdir_masks *mask;
10439 struct rte_port *port;
10441 if (res->port_id > nb_ports) {
10442 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
10446 port = &ports[res->port_id];
10447 /** Check if the port is not started **/
10448 if (port->port_status != RTE_PORT_STOPPED) {
10449 printf("Please stop port %d first\n", res->port_id);
10453 mask = &port->dev_conf.fdir_conf.mask;
10455 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
10456 if (strcmp(res->mode_value, "MAC-VLAN")) {
10457 printf("Please set mode to MAC-VLAN.\n");
10461 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10462 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
10463 if (strcmp(res->mode_value, "Tunnel")) {
10464 printf("Please set mode to Tunnel.\n");
10468 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10469 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
10470 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
10471 mask->tunnel_type_mask = res->tunnel_type_mask;
10473 if (strcmp(res->mode_value, "IP")) {
10474 printf("Please set mode to IP.\n");
10478 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10479 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
10480 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
10481 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
10482 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
10483 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
10484 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
10487 cmd_reconfig_device_queue(res->port_id, 1, 1);
10490 cmdline_parse_token_string_t cmd_flow_director_mask =
10491 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10492 flow_director_mask, "flow_director_mask");
10493 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
10494 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10496 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
10497 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10499 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
10500 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10501 vlan_mask, UINT16);
10502 cmdline_parse_token_string_t cmd_flow_director_mask_src =
10503 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10504 src_mask, "src_mask");
10505 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
10506 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10508 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
10509 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10511 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
10512 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10514 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
10515 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10516 dst_mask, "dst_mask");
10517 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
10518 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10520 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
10521 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10523 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
10524 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10527 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
10528 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10530 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
10531 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10533 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
10534 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10535 mode_value, "MAC-VLAN");
10536 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
10537 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10538 mode_value, "Tunnel");
10539 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
10540 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10542 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
10543 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10544 mac_addr_byte_mask, UINT8);
10545 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
10546 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10547 tunnel_type, "tunnel-type");
10548 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
10549 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10550 tunnel_type_mask, UINT8);
10551 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
10552 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10553 tunnel_id, "tunnel-id");
10554 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
10555 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10556 tunnel_id_mask, UINT32);
10558 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
10559 .f = cmd_flow_director_mask_parsed,
10561 .help_str = "flow_director_mask ... : "
10562 "Set IP mode flow director's mask on NIC",
10564 (void *)&cmd_flow_director_mask,
10565 (void *)&cmd_flow_director_mask_port_id,
10566 (void *)&cmd_flow_director_mask_mode,
10567 (void *)&cmd_flow_director_mask_mode_ip,
10568 (void *)&cmd_flow_director_mask_vlan,
10569 (void *)&cmd_flow_director_mask_vlan_value,
10570 (void *)&cmd_flow_director_mask_src,
10571 (void *)&cmd_flow_director_mask_ipv4_src,
10572 (void *)&cmd_flow_director_mask_ipv6_src,
10573 (void *)&cmd_flow_director_mask_port_src,
10574 (void *)&cmd_flow_director_mask_dst,
10575 (void *)&cmd_flow_director_mask_ipv4_dst,
10576 (void *)&cmd_flow_director_mask_ipv6_dst,
10577 (void *)&cmd_flow_director_mask_port_dst,
10582 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
10583 .f = cmd_flow_director_mask_parsed,
10585 .help_str = "flow_director_mask ... : Set MAC VLAN mode "
10586 "flow director's mask on NIC",
10588 (void *)&cmd_flow_director_mask,
10589 (void *)&cmd_flow_director_mask_port_id,
10590 (void *)&cmd_flow_director_mask_mode,
10591 (void *)&cmd_flow_director_mask_mode_mac_vlan,
10592 (void *)&cmd_flow_director_mask_vlan,
10593 (void *)&cmd_flow_director_mask_vlan_value,
10598 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
10599 .f = cmd_flow_director_mask_parsed,
10601 .help_str = "flow_director_mask ... : Set tunnel mode "
10602 "flow director's mask on NIC",
10604 (void *)&cmd_flow_director_mask,
10605 (void *)&cmd_flow_director_mask_port_id,
10606 (void *)&cmd_flow_director_mask_mode,
10607 (void *)&cmd_flow_director_mask_mode_tunnel,
10608 (void *)&cmd_flow_director_mask_vlan,
10609 (void *)&cmd_flow_director_mask_vlan_value,
10610 (void *)&cmd_flow_director_mask_mac,
10611 (void *)&cmd_flow_director_mask_mac_value,
10612 (void *)&cmd_flow_director_mask_tunnel_type,
10613 (void *)&cmd_flow_director_mask_tunnel_type_value,
10614 (void *)&cmd_flow_director_mask_tunnel_id,
10615 (void *)&cmd_flow_director_mask_tunnel_id_value,
10620 /* *** deal with flow director mask on flexible payload *** */
10621 struct cmd_flow_director_flex_mask_result {
10622 cmdline_fixed_string_t flow_director_flexmask;
10624 cmdline_fixed_string_t flow;
10625 cmdline_fixed_string_t flow_type;
10626 cmdline_fixed_string_t mask;
10630 cmd_flow_director_flex_mask_parsed(void *parsed_result,
10631 __attribute__((unused)) struct cmdline *cl,
10632 __attribute__((unused)) void *data)
10634 struct cmd_flow_director_flex_mask_result *res = parsed_result;
10635 struct rte_eth_fdir_info fdir_info;
10636 struct rte_eth_fdir_flex_mask flex_mask;
10637 struct rte_port *port;
10638 uint32_t flow_type_mask;
10642 if (res->port_id > nb_ports) {
10643 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
10647 port = &ports[res->port_id];
10648 /** Check if the port is not started **/
10649 if (port->port_status != RTE_PORT_STOPPED) {
10650 printf("Please stop port %d first\n", res->port_id);
10654 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
10655 ret = parse_flexbytes(res->mask,
10657 RTE_ETH_FDIR_MAX_FLEXLEN);
10659 printf("error: Cannot parse mask input.\n");
10663 memset(&fdir_info, 0, sizeof(fdir_info));
10664 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10665 RTE_ETH_FILTER_INFO, &fdir_info);
10667 printf("Cannot get FDir filter info\n");
10671 if (!strcmp(res->flow_type, "none")) {
10672 /* means don't specify the flow type */
10673 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN;
10674 for (i = 0; i < RTE_ETH_FLOW_MAX; i++)
10675 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i],
10676 0, sizeof(struct rte_eth_fdir_flex_mask));
10677 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1;
10678 rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0],
10680 sizeof(struct rte_eth_fdir_flex_mask));
10681 cmd_reconfig_device_queue(res->port_id, 1, 1);
10684 flow_type_mask = fdir_info.flow_types_mask[0];
10685 if (!strcmp(res->flow_type, "all")) {
10686 if (!flow_type_mask) {
10687 printf("No flow type supported\n");
10690 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
10691 if (flow_type_mask & (1 << i)) {
10692 flex_mask.flow_type = i;
10693 fdir_set_flex_mask(res->port_id, &flex_mask);
10696 cmd_reconfig_device_queue(res->port_id, 1, 1);
10699 flex_mask.flow_type = str2flowtype(res->flow_type);
10700 if (!(flow_type_mask & (1 << flex_mask.flow_type))) {
10701 printf("Flow type %s not supported on port %d\n",
10702 res->flow_type, res->port_id);
10705 fdir_set_flex_mask(res->port_id, &flex_mask);
10706 cmd_reconfig_device_queue(res->port_id, 1, 1);
10709 cmdline_parse_token_string_t cmd_flow_director_flexmask =
10710 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
10711 flow_director_flexmask,
10712 "flow_director_flex_mask");
10713 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
10714 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
10716 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
10717 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
10719 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
10720 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
10721 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
10722 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all");
10723 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
10724 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
10727 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
10728 .f = cmd_flow_director_flex_mask_parsed,
10730 .help_str = "flow_director_flex_mask ... : "
10731 "Set flow director's flex mask on NIC",
10733 (void *)&cmd_flow_director_flexmask,
10734 (void *)&cmd_flow_director_flexmask_port_id,
10735 (void *)&cmd_flow_director_flexmask_flow,
10736 (void *)&cmd_flow_director_flexmask_flow_type,
10737 (void *)&cmd_flow_director_flexmask_mask,
10742 /* *** deal with flow director flexible payload configuration *** */
10743 struct cmd_flow_director_flexpayload_result {
10744 cmdline_fixed_string_t flow_director_flexpayload;
10746 cmdline_fixed_string_t payload_layer;
10747 cmdline_fixed_string_t payload_cfg;
10751 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
10754 const char *p, *p0 = q_arg;
10756 unsigned long int_fld;
10757 char *str_fld[max_num];
10762 p = strchr(p0, '(');
10766 p0 = strchr(p, ')');
10771 if (size >= sizeof(s))
10774 snprintf(s, sizeof(s), "%.*s", size, p);
10775 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
10776 if (ret < 0 || ret > max_num)
10778 for (i = 0; i < ret; i++) {
10780 int_fld = strtoul(str_fld[i], &end, 0);
10781 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
10783 offsets[i] = (uint16_t)int_fld;
10789 cmd_flow_director_flxpld_parsed(void *parsed_result,
10790 __attribute__((unused)) struct cmdline *cl,
10791 __attribute__((unused)) void *data)
10793 struct cmd_flow_director_flexpayload_result *res = parsed_result;
10794 struct rte_eth_flex_payload_cfg flex_cfg;
10795 struct rte_port *port;
10798 if (res->port_id > nb_ports) {
10799 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
10803 port = &ports[res->port_id];
10804 /** Check if the port is not started **/
10805 if (port->port_status != RTE_PORT_STOPPED) {
10806 printf("Please stop port %d first\n", res->port_id);
10810 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
10812 if (!strcmp(res->payload_layer, "raw"))
10813 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
10814 else if (!strcmp(res->payload_layer, "l2"))
10815 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
10816 else if (!strcmp(res->payload_layer, "l3"))
10817 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
10818 else if (!strcmp(res->payload_layer, "l4"))
10819 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
10821 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
10822 RTE_ETH_FDIR_MAX_FLEXLEN);
10824 printf("error: Cannot parse flex payload input.\n");
10828 fdir_set_flex_payload(res->port_id, &flex_cfg);
10829 cmd_reconfig_device_queue(res->port_id, 1, 1);
10832 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
10833 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10834 flow_director_flexpayload,
10835 "flow_director_flex_payload");
10836 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
10837 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10839 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
10840 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10841 payload_layer, "raw#l2#l3#l4");
10842 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
10843 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10844 payload_cfg, NULL);
10846 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
10847 .f = cmd_flow_director_flxpld_parsed,
10849 .help_str = "flow_director_flexpayload ... : "
10850 "Set flow director's flex payload on NIC",
10852 (void *)&cmd_flow_director_flexpayload,
10853 (void *)&cmd_flow_director_flexpayload_port_id,
10854 (void *)&cmd_flow_director_flexpayload_payload_layer,
10855 (void *)&cmd_flow_director_flexpayload_payload_cfg,
10860 /* Generic flow interface command. */
10861 extern cmdline_parse_inst_t cmd_flow;
10863 /* *** Classification Filters Control *** */
10864 /* *** Get symmetric hash enable per port *** */
10865 struct cmd_get_sym_hash_ena_per_port_result {
10866 cmdline_fixed_string_t get_sym_hash_ena_per_port;
10871 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
10872 __rte_unused struct cmdline *cl,
10873 __rte_unused void *data)
10875 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
10876 struct rte_eth_hash_filter_info info;
10879 if (rte_eth_dev_filter_supported(res->port_id,
10880 RTE_ETH_FILTER_HASH) < 0) {
10881 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
10886 memset(&info, 0, sizeof(info));
10887 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
10888 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
10889 RTE_ETH_FILTER_GET, &info);
10892 printf("Cannot get symmetric hash enable per port "
10893 "on port %u\n", res->port_id);
10897 printf("Symmetric hash is %s on port %u\n", info.info.enable ?
10898 "enabled" : "disabled", res->port_id);
10901 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
10902 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
10903 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
10904 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
10905 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
10908 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
10909 .f = cmd_get_sym_hash_per_port_parsed,
10911 .help_str = "get_sym_hash_ena_per_port <port_id>",
10913 (void *)&cmd_get_sym_hash_ena_per_port_all,
10914 (void *)&cmd_get_sym_hash_ena_per_port_port_id,
10919 /* *** Set symmetric hash enable per port *** */
10920 struct cmd_set_sym_hash_ena_per_port_result {
10921 cmdline_fixed_string_t set_sym_hash_ena_per_port;
10922 cmdline_fixed_string_t enable;
10927 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
10928 __rte_unused struct cmdline *cl,
10929 __rte_unused void *data)
10931 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
10932 struct rte_eth_hash_filter_info info;
10935 if (rte_eth_dev_filter_supported(res->port_id,
10936 RTE_ETH_FILTER_HASH) < 0) {
10937 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
10942 memset(&info, 0, sizeof(info));
10943 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
10944 if (!strcmp(res->enable, "enable"))
10945 info.info.enable = 1;
10946 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
10947 RTE_ETH_FILTER_SET, &info);
10949 printf("Cannot set symmetric hash enable per port on "
10950 "port %u\n", res->port_id);
10953 printf("Symmetric hash has been set to %s on port %u\n",
10954 res->enable, res->port_id);
10957 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
10958 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
10959 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
10960 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
10961 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
10963 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
10964 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
10965 enable, "enable#disable");
10967 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
10968 .f = cmd_set_sym_hash_per_port_parsed,
10970 .help_str = "set_sym_hash_ena_per_port <port_id> enable|disable",
10972 (void *)&cmd_set_sym_hash_ena_per_port_all,
10973 (void *)&cmd_set_sym_hash_ena_per_port_port_id,
10974 (void *)&cmd_set_sym_hash_ena_per_port_enable,
10979 /* Get global config of hash function */
10980 struct cmd_get_hash_global_config_result {
10981 cmdline_fixed_string_t get_hash_global_config;
10986 flowtype_to_str(uint16_t ftype)
10992 } ftype_table[] = {
10993 {"ipv4", RTE_ETH_FLOW_IPV4},
10994 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
10995 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
10996 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
10997 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
10998 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
10999 {"ipv6", RTE_ETH_FLOW_IPV6},
11000 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
11001 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
11002 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
11003 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
11004 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
11005 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
11006 {"port", RTE_ETH_FLOW_PORT},
11007 {"vxlan", RTE_ETH_FLOW_VXLAN},
11008 {"geneve", RTE_ETH_FLOW_GENEVE},
11009 {"nvgre", RTE_ETH_FLOW_NVGRE},
11012 for (i = 0; i < RTE_DIM(ftype_table); i++) {
11013 if (ftype_table[i].ftype == ftype)
11014 return ftype_table[i].str;
11021 cmd_get_hash_global_config_parsed(void *parsed_result,
11022 __rte_unused struct cmdline *cl,
11023 __rte_unused void *data)
11025 struct cmd_get_hash_global_config_result *res = parsed_result;
11026 struct rte_eth_hash_filter_info info;
11027 uint32_t idx, offset;
11032 if (rte_eth_dev_filter_supported(res->port_id,
11033 RTE_ETH_FILTER_HASH) < 0) {
11034 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
11039 memset(&info, 0, sizeof(info));
11040 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
11041 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11042 RTE_ETH_FILTER_GET, &info);
11044 printf("Cannot get hash global configurations by port %d\n",
11049 switch (info.info.global_conf.hash_func) {
11050 case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
11051 printf("Hash function is Toeplitz\n");
11053 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
11054 printf("Hash function is Simple XOR\n");
11057 printf("Unknown hash function\n");
11061 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) {
11062 idx = i / UINT32_BIT;
11063 offset = i % UINT32_BIT;
11064 if (!(info.info.global_conf.valid_bit_mask[idx] &
11067 str = flowtype_to_str(i);
11070 printf("Symmetric hash is %s globally for flow type %s "
11072 ((info.info.global_conf.sym_hash_enable_mask[idx] &
11073 (1UL << offset)) ? "enabled" : "disabled"), str,
11078 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
11079 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
11080 get_hash_global_config, "get_hash_global_config");
11081 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
11082 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
11085 cmdline_parse_inst_t cmd_get_hash_global_config = {
11086 .f = cmd_get_hash_global_config_parsed,
11088 .help_str = "get_hash_global_config <port_id>",
11090 (void *)&cmd_get_hash_global_config_all,
11091 (void *)&cmd_get_hash_global_config_port_id,
11096 /* Set global config of hash function */
11097 struct cmd_set_hash_global_config_result {
11098 cmdline_fixed_string_t set_hash_global_config;
11100 cmdline_fixed_string_t hash_func;
11101 cmdline_fixed_string_t flow_type;
11102 cmdline_fixed_string_t enable;
11106 cmd_set_hash_global_config_parsed(void *parsed_result,
11107 __rte_unused struct cmdline *cl,
11108 __rte_unused void *data)
11110 struct cmd_set_hash_global_config_result *res = parsed_result;
11111 struct rte_eth_hash_filter_info info;
11112 uint32_t ftype, idx, offset;
11115 if (rte_eth_dev_filter_supported(res->port_id,
11116 RTE_ETH_FILTER_HASH) < 0) {
11117 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
11121 memset(&info, 0, sizeof(info));
11122 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
11123 if (!strcmp(res->hash_func, "toeplitz"))
11124 info.info.global_conf.hash_func =
11125 RTE_ETH_HASH_FUNCTION_TOEPLITZ;
11126 else if (!strcmp(res->hash_func, "simple_xor"))
11127 info.info.global_conf.hash_func =
11128 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
11129 else if (!strcmp(res->hash_func, "default"))
11130 info.info.global_conf.hash_func =
11131 RTE_ETH_HASH_FUNCTION_DEFAULT;
11133 ftype = str2flowtype(res->flow_type);
11134 idx = ftype / (CHAR_BIT * sizeof(uint32_t));
11135 offset = ftype % (CHAR_BIT * sizeof(uint32_t));
11136 info.info.global_conf.valid_bit_mask[idx] |= (1UL << offset);
11137 if (!strcmp(res->enable, "enable"))
11138 info.info.global_conf.sym_hash_enable_mask[idx] |=
11140 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11141 RTE_ETH_FILTER_SET, &info);
11143 printf("Cannot set global hash configurations by port %d\n",
11146 printf("Global hash configurations have been set "
11147 "succcessfully by port %d\n", res->port_id);
11150 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
11151 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11152 set_hash_global_config, "set_hash_global_config");
11153 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
11154 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
11156 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
11157 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11158 hash_func, "toeplitz#simple_xor#default");
11159 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
11160 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11162 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
11163 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
11164 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
11165 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11166 enable, "enable#disable");
11168 cmdline_parse_inst_t cmd_set_hash_global_config = {
11169 .f = cmd_set_hash_global_config_parsed,
11171 .help_str = "set_hash_global_config <port_id> "
11172 "toeplitz|simple_xor|default "
11173 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
11174 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
11175 "l2_payload enable|disable",
11177 (void *)&cmd_set_hash_global_config_all,
11178 (void *)&cmd_set_hash_global_config_port_id,
11179 (void *)&cmd_set_hash_global_config_hash_func,
11180 (void *)&cmd_set_hash_global_config_flow_type,
11181 (void *)&cmd_set_hash_global_config_enable,
11186 /* Set hash input set */
11187 struct cmd_set_hash_input_set_result {
11188 cmdline_fixed_string_t set_hash_input_set;
11190 cmdline_fixed_string_t flow_type;
11191 cmdline_fixed_string_t inset_field;
11192 cmdline_fixed_string_t select;
11195 static enum rte_eth_input_set_field
11196 str2inset(char *string)
11200 static const struct {
11202 enum rte_eth_input_set_field inset;
11203 } inset_table[] = {
11204 {"ethertype", RTE_ETH_INPUT_SET_L2_ETHERTYPE},
11205 {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN},
11206 {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN},
11207 {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4},
11208 {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4},
11209 {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS},
11210 {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO},
11211 {"ipv4-ttl", RTE_ETH_INPUT_SET_L3_IP4_TTL},
11212 {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6},
11213 {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6},
11214 {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC},
11215 {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER},
11216 {"ipv6-hop-limits", RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS},
11217 {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT},
11218 {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT},
11219 {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT},
11220 {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT},
11221 {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT},
11222 {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT},
11223 {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG},
11224 {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY},
11225 {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY},
11226 {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD},
11227 {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD},
11228 {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD},
11229 {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD},
11230 {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD},
11231 {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD},
11232 {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD},
11233 {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD},
11234 {"none", RTE_ETH_INPUT_SET_NONE},
11237 for (i = 0; i < RTE_DIM(inset_table); i++) {
11238 if (!strcmp(string, inset_table[i].str))
11239 return inset_table[i].inset;
11242 return RTE_ETH_INPUT_SET_UNKNOWN;
11246 cmd_set_hash_input_set_parsed(void *parsed_result,
11247 __rte_unused struct cmdline *cl,
11248 __rte_unused void *data)
11250 struct cmd_set_hash_input_set_result *res = parsed_result;
11251 struct rte_eth_hash_filter_info info;
11253 memset(&info, 0, sizeof(info));
11254 info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT;
11255 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
11256 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
11257 info.info.input_set_conf.inset_size = 1;
11258 if (!strcmp(res->select, "select"))
11259 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
11260 else if (!strcmp(res->select, "add"))
11261 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
11262 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11263 RTE_ETH_FILTER_SET, &info);
11266 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd =
11267 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
11268 set_hash_input_set, "set_hash_input_set");
11269 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id =
11270 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result,
11272 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type =
11273 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
11275 cmdline_parse_token_string_t cmd_set_hash_input_set_field =
11276 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
11278 "ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
11279 "ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#"
11280 "udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#"
11281 "sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#"
11282 "fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#"
11284 cmdline_parse_token_string_t cmd_set_hash_input_set_select =
11285 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
11286 select, "select#add");
11288 cmdline_parse_inst_t cmd_set_hash_input_set = {
11289 .f = cmd_set_hash_input_set_parsed,
11291 .help_str = "set_hash_input_set <port_id> "
11292 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
11293 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload|<flowtype_id> "
11294 "ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|"
11295 "ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|"
11296 "tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|"
11297 "gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
11298 "fld-7th|fld-8th|none select|add",
11300 (void *)&cmd_set_hash_input_set_cmd,
11301 (void *)&cmd_set_hash_input_set_port_id,
11302 (void *)&cmd_set_hash_input_set_flow_type,
11303 (void *)&cmd_set_hash_input_set_field,
11304 (void *)&cmd_set_hash_input_set_select,
11309 /* Set flow director input set */
11310 struct cmd_set_fdir_input_set_result {
11311 cmdline_fixed_string_t set_fdir_input_set;
11313 cmdline_fixed_string_t flow_type;
11314 cmdline_fixed_string_t inset_field;
11315 cmdline_fixed_string_t select;
11319 cmd_set_fdir_input_set_parsed(void *parsed_result,
11320 __rte_unused struct cmdline *cl,
11321 __rte_unused void *data)
11323 struct cmd_set_fdir_input_set_result *res = parsed_result;
11324 struct rte_eth_fdir_filter_info info;
11326 memset(&info, 0, sizeof(info));
11327 info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT;
11328 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
11329 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
11330 info.info.input_set_conf.inset_size = 1;
11331 if (!strcmp(res->select, "select"))
11332 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
11333 else if (!strcmp(res->select, "add"))
11334 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
11335 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11336 RTE_ETH_FILTER_SET, &info);
11339 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd =
11340 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
11341 set_fdir_input_set, "set_fdir_input_set");
11342 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id =
11343 TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result,
11345 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type =
11346 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
11348 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
11349 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
11350 cmdline_parse_token_string_t cmd_set_fdir_input_set_field =
11351 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
11353 "ivlan#ethertype#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
11354 "ipv4-tos#ipv4-proto#ipv4-ttl#ipv6-tc#ipv6-next-header#"
11355 "ipv6-hop-limits#udp-src-port#udp-dst-port#"
11356 "tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#"
11357 "sctp-veri-tag#none");
11358 cmdline_parse_token_string_t cmd_set_fdir_input_set_select =
11359 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
11360 select, "select#add");
11362 cmdline_parse_inst_t cmd_set_fdir_input_set = {
11363 .f = cmd_set_fdir_input_set_parsed,
11365 .help_str = "set_fdir_input_set <port_id> "
11366 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
11367 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
11368 "ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|"
11369 "ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|ipv6-next-header|"
11370 "ipv6-hop-limits|udp-src-port|udp-dst-port|"
11371 "tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|"
11372 "sctp-veri-tag|none select|add",
11374 (void *)&cmd_set_fdir_input_set_cmd,
11375 (void *)&cmd_set_fdir_input_set_port_id,
11376 (void *)&cmd_set_fdir_input_set_flow_type,
11377 (void *)&cmd_set_fdir_input_set_field,
11378 (void *)&cmd_set_fdir_input_set_select,
11383 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
11384 struct cmd_mcast_addr_result {
11385 cmdline_fixed_string_t mcast_addr_cmd;
11386 cmdline_fixed_string_t what;
11388 struct ether_addr mc_addr;
11391 static void cmd_mcast_addr_parsed(void *parsed_result,
11392 __attribute__((unused)) struct cmdline *cl,
11393 __attribute__((unused)) void *data)
11395 struct cmd_mcast_addr_result *res = parsed_result;
11397 if (!is_multicast_ether_addr(&res->mc_addr)) {
11398 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
11399 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
11400 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
11401 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
11404 if (strcmp(res->what, "add") == 0)
11405 mcast_addr_add(res->port_num, &res->mc_addr);
11407 mcast_addr_remove(res->port_num, &res->mc_addr);
11410 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
11411 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
11412 mcast_addr_cmd, "mcast_addr");
11413 cmdline_parse_token_string_t cmd_mcast_addr_what =
11414 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
11416 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
11417 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT16);
11418 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
11419 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
11421 cmdline_parse_inst_t cmd_mcast_addr = {
11422 .f = cmd_mcast_addr_parsed,
11424 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
11425 "Add/Remove multicast MAC address on port_id",
11427 (void *)&cmd_mcast_addr_cmd,
11428 (void *)&cmd_mcast_addr_what,
11429 (void *)&cmd_mcast_addr_portnum,
11430 (void *)&cmd_mcast_addr_addr,
11435 /* l2 tunnel config
11436 * only support E-tag now.
11439 /* Ether type config */
11440 struct cmd_config_l2_tunnel_eth_type_result {
11441 cmdline_fixed_string_t port;
11442 cmdline_fixed_string_t config;
11443 cmdline_fixed_string_t all;
11445 cmdline_fixed_string_t l2_tunnel;
11446 cmdline_fixed_string_t l2_tunnel_type;
11447 cmdline_fixed_string_t eth_type;
11448 uint16_t eth_type_val;
11451 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port =
11452 TOKEN_STRING_INITIALIZER
11453 (struct cmd_config_l2_tunnel_eth_type_result,
11455 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config =
11456 TOKEN_STRING_INITIALIZER
11457 (struct cmd_config_l2_tunnel_eth_type_result,
11459 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str =
11460 TOKEN_STRING_INITIALIZER
11461 (struct cmd_config_l2_tunnel_eth_type_result,
11463 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id =
11464 TOKEN_NUM_INITIALIZER
11465 (struct cmd_config_l2_tunnel_eth_type_result,
11467 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel =
11468 TOKEN_STRING_INITIALIZER
11469 (struct cmd_config_l2_tunnel_eth_type_result,
11470 l2_tunnel, "l2-tunnel");
11471 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type =
11472 TOKEN_STRING_INITIALIZER
11473 (struct cmd_config_l2_tunnel_eth_type_result,
11474 l2_tunnel_type, "E-tag");
11475 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type =
11476 TOKEN_STRING_INITIALIZER
11477 (struct cmd_config_l2_tunnel_eth_type_result,
11478 eth_type, "ether-type");
11479 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val =
11480 TOKEN_NUM_INITIALIZER
11481 (struct cmd_config_l2_tunnel_eth_type_result,
11482 eth_type_val, UINT16);
11484 static enum rte_eth_tunnel_type
11485 str2fdir_l2_tunnel_type(char *string)
11489 static const struct {
11491 enum rte_eth_tunnel_type type;
11492 } l2_tunnel_type_str[] = {
11493 {"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG},
11496 for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) {
11497 if (!strcmp(l2_tunnel_type_str[i].str, string))
11498 return l2_tunnel_type_str[i].type;
11500 return RTE_TUNNEL_TYPE_NONE;
11503 /* ether type config for all ports */
11505 cmd_config_l2_tunnel_eth_type_all_parsed
11506 (void *parsed_result,
11507 __attribute__((unused)) struct cmdline *cl,
11508 __attribute__((unused)) void *data)
11510 struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result;
11511 struct rte_eth_l2_tunnel_conf entry;
11514 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
11515 entry.ether_type = res->eth_type_val;
11517 RTE_ETH_FOREACH_DEV(pid) {
11518 rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry);
11522 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = {
11523 .f = cmd_config_l2_tunnel_eth_type_all_parsed,
11525 .help_str = "port config all l2-tunnel E-tag ether-type <value>",
11527 (void *)&cmd_config_l2_tunnel_eth_type_port,
11528 (void *)&cmd_config_l2_tunnel_eth_type_config,
11529 (void *)&cmd_config_l2_tunnel_eth_type_all_str,
11530 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
11531 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
11532 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
11533 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
11538 /* ether type config for a specific port */
11540 cmd_config_l2_tunnel_eth_type_specific_parsed(
11541 void *parsed_result,
11542 __attribute__((unused)) struct cmdline *cl,
11543 __attribute__((unused)) void *data)
11545 struct cmd_config_l2_tunnel_eth_type_result *res =
11547 struct rte_eth_l2_tunnel_conf entry;
11549 if (port_id_is_invalid(res->id, ENABLED_WARN))
11552 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
11553 entry.ether_type = res->eth_type_val;
11555 rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry);
11558 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = {
11559 .f = cmd_config_l2_tunnel_eth_type_specific_parsed,
11561 .help_str = "port config <port_id> l2-tunnel E-tag ether-type <value>",
11563 (void *)&cmd_config_l2_tunnel_eth_type_port,
11564 (void *)&cmd_config_l2_tunnel_eth_type_config,
11565 (void *)&cmd_config_l2_tunnel_eth_type_id,
11566 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
11567 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
11568 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
11569 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
11574 /* Enable/disable l2 tunnel */
11575 struct cmd_config_l2_tunnel_en_dis_result {
11576 cmdline_fixed_string_t port;
11577 cmdline_fixed_string_t config;
11578 cmdline_fixed_string_t all;
11580 cmdline_fixed_string_t l2_tunnel;
11581 cmdline_fixed_string_t l2_tunnel_type;
11582 cmdline_fixed_string_t en_dis;
11585 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port =
11586 TOKEN_STRING_INITIALIZER
11587 (struct cmd_config_l2_tunnel_en_dis_result,
11589 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config =
11590 TOKEN_STRING_INITIALIZER
11591 (struct cmd_config_l2_tunnel_en_dis_result,
11593 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str =
11594 TOKEN_STRING_INITIALIZER
11595 (struct cmd_config_l2_tunnel_en_dis_result,
11597 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id =
11598 TOKEN_NUM_INITIALIZER
11599 (struct cmd_config_l2_tunnel_en_dis_result,
11601 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel =
11602 TOKEN_STRING_INITIALIZER
11603 (struct cmd_config_l2_tunnel_en_dis_result,
11604 l2_tunnel, "l2-tunnel");
11605 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type =
11606 TOKEN_STRING_INITIALIZER
11607 (struct cmd_config_l2_tunnel_en_dis_result,
11608 l2_tunnel_type, "E-tag");
11609 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis =
11610 TOKEN_STRING_INITIALIZER
11611 (struct cmd_config_l2_tunnel_en_dis_result,
11612 en_dis, "enable#disable");
11614 /* enable/disable l2 tunnel for all ports */
11616 cmd_config_l2_tunnel_en_dis_all_parsed(
11617 void *parsed_result,
11618 __attribute__((unused)) struct cmdline *cl,
11619 __attribute__((unused)) void *data)
11621 struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result;
11622 struct rte_eth_l2_tunnel_conf entry;
11626 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
11628 if (!strcmp("enable", res->en_dis))
11633 RTE_ETH_FOREACH_DEV(pid) {
11634 rte_eth_dev_l2_tunnel_offload_set(pid,
11636 ETH_L2_TUNNEL_ENABLE_MASK,
11641 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = {
11642 .f = cmd_config_l2_tunnel_en_dis_all_parsed,
11644 .help_str = "port config all l2-tunnel E-tag enable|disable",
11646 (void *)&cmd_config_l2_tunnel_en_dis_port,
11647 (void *)&cmd_config_l2_tunnel_en_dis_config,
11648 (void *)&cmd_config_l2_tunnel_en_dis_all_str,
11649 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
11650 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
11651 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
11656 /* enable/disable l2 tunnel for a port */
11658 cmd_config_l2_tunnel_en_dis_specific_parsed(
11659 void *parsed_result,
11660 __attribute__((unused)) struct cmdline *cl,
11661 __attribute__((unused)) void *data)
11663 struct cmd_config_l2_tunnel_en_dis_result *res =
11665 struct rte_eth_l2_tunnel_conf entry;
11667 if (port_id_is_invalid(res->id, ENABLED_WARN))
11670 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
11672 if (!strcmp("enable", res->en_dis))
11673 rte_eth_dev_l2_tunnel_offload_set(res->id,
11675 ETH_L2_TUNNEL_ENABLE_MASK,
11678 rte_eth_dev_l2_tunnel_offload_set(res->id,
11680 ETH_L2_TUNNEL_ENABLE_MASK,
11684 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = {
11685 .f = cmd_config_l2_tunnel_en_dis_specific_parsed,
11687 .help_str = "port config <port_id> l2-tunnel E-tag enable|disable",
11689 (void *)&cmd_config_l2_tunnel_en_dis_port,
11690 (void *)&cmd_config_l2_tunnel_en_dis_config,
11691 (void *)&cmd_config_l2_tunnel_en_dis_id,
11692 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
11693 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
11694 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
11699 /* E-tag configuration */
11701 /* Common result structure for all E-tag configuration */
11702 struct cmd_config_e_tag_result {
11703 cmdline_fixed_string_t e_tag;
11704 cmdline_fixed_string_t set;
11705 cmdline_fixed_string_t insertion;
11706 cmdline_fixed_string_t stripping;
11707 cmdline_fixed_string_t forwarding;
11708 cmdline_fixed_string_t filter;
11709 cmdline_fixed_string_t add;
11710 cmdline_fixed_string_t del;
11711 cmdline_fixed_string_t on;
11712 cmdline_fixed_string_t off;
11713 cmdline_fixed_string_t on_off;
11714 cmdline_fixed_string_t port_tag_id;
11715 uint32_t port_tag_id_val;
11716 cmdline_fixed_string_t e_tag_id;
11717 uint16_t e_tag_id_val;
11718 cmdline_fixed_string_t dst_pool;
11719 uint8_t dst_pool_val;
11720 cmdline_fixed_string_t port;
11722 cmdline_fixed_string_t vf;
11726 /* Common CLI fields for all E-tag configuration */
11727 cmdline_parse_token_string_t cmd_config_e_tag_e_tag =
11728 TOKEN_STRING_INITIALIZER
11729 (struct cmd_config_e_tag_result,
11731 cmdline_parse_token_string_t cmd_config_e_tag_set =
11732 TOKEN_STRING_INITIALIZER
11733 (struct cmd_config_e_tag_result,
11735 cmdline_parse_token_string_t cmd_config_e_tag_insertion =
11736 TOKEN_STRING_INITIALIZER
11737 (struct cmd_config_e_tag_result,
11738 insertion, "insertion");
11739 cmdline_parse_token_string_t cmd_config_e_tag_stripping =
11740 TOKEN_STRING_INITIALIZER
11741 (struct cmd_config_e_tag_result,
11742 stripping, "stripping");
11743 cmdline_parse_token_string_t cmd_config_e_tag_forwarding =
11744 TOKEN_STRING_INITIALIZER
11745 (struct cmd_config_e_tag_result,
11746 forwarding, "forwarding");
11747 cmdline_parse_token_string_t cmd_config_e_tag_filter =
11748 TOKEN_STRING_INITIALIZER
11749 (struct cmd_config_e_tag_result,
11751 cmdline_parse_token_string_t cmd_config_e_tag_add =
11752 TOKEN_STRING_INITIALIZER
11753 (struct cmd_config_e_tag_result,
11755 cmdline_parse_token_string_t cmd_config_e_tag_del =
11756 TOKEN_STRING_INITIALIZER
11757 (struct cmd_config_e_tag_result,
11759 cmdline_parse_token_string_t cmd_config_e_tag_on =
11760 TOKEN_STRING_INITIALIZER
11761 (struct cmd_config_e_tag_result,
11763 cmdline_parse_token_string_t cmd_config_e_tag_off =
11764 TOKEN_STRING_INITIALIZER
11765 (struct cmd_config_e_tag_result,
11767 cmdline_parse_token_string_t cmd_config_e_tag_on_off =
11768 TOKEN_STRING_INITIALIZER
11769 (struct cmd_config_e_tag_result,
11771 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id =
11772 TOKEN_STRING_INITIALIZER
11773 (struct cmd_config_e_tag_result,
11774 port_tag_id, "port-tag-id");
11775 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val =
11776 TOKEN_NUM_INITIALIZER
11777 (struct cmd_config_e_tag_result,
11778 port_tag_id_val, UINT32);
11779 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id =
11780 TOKEN_STRING_INITIALIZER
11781 (struct cmd_config_e_tag_result,
11782 e_tag_id, "e-tag-id");
11783 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val =
11784 TOKEN_NUM_INITIALIZER
11785 (struct cmd_config_e_tag_result,
11786 e_tag_id_val, UINT16);
11787 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool =
11788 TOKEN_STRING_INITIALIZER
11789 (struct cmd_config_e_tag_result,
11790 dst_pool, "dst-pool");
11791 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val =
11792 TOKEN_NUM_INITIALIZER
11793 (struct cmd_config_e_tag_result,
11794 dst_pool_val, UINT8);
11795 cmdline_parse_token_string_t cmd_config_e_tag_port =
11796 TOKEN_STRING_INITIALIZER
11797 (struct cmd_config_e_tag_result,
11799 cmdline_parse_token_num_t cmd_config_e_tag_port_id =
11800 TOKEN_NUM_INITIALIZER
11801 (struct cmd_config_e_tag_result,
11803 cmdline_parse_token_string_t cmd_config_e_tag_vf =
11804 TOKEN_STRING_INITIALIZER
11805 (struct cmd_config_e_tag_result,
11807 cmdline_parse_token_num_t cmd_config_e_tag_vf_id =
11808 TOKEN_NUM_INITIALIZER
11809 (struct cmd_config_e_tag_result,
11812 /* E-tag insertion configuration */
11814 cmd_config_e_tag_insertion_en_parsed(
11815 void *parsed_result,
11816 __attribute__((unused)) struct cmdline *cl,
11817 __attribute__((unused)) void *data)
11819 struct cmd_config_e_tag_result *res =
11821 struct rte_eth_l2_tunnel_conf entry;
11823 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11826 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
11827 entry.tunnel_id = res->port_tag_id_val;
11828 entry.vf_id = res->vf_id;
11829 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
11831 ETH_L2_TUNNEL_INSERTION_MASK,
11836 cmd_config_e_tag_insertion_dis_parsed(
11837 void *parsed_result,
11838 __attribute__((unused)) struct cmdline *cl,
11839 __attribute__((unused)) void *data)
11841 struct cmd_config_e_tag_result *res =
11843 struct rte_eth_l2_tunnel_conf entry;
11845 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11848 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
11849 entry.vf_id = res->vf_id;
11851 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
11853 ETH_L2_TUNNEL_INSERTION_MASK,
11857 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = {
11858 .f = cmd_config_e_tag_insertion_en_parsed,
11860 .help_str = "E-tag ... : E-tag insertion enable",
11862 (void *)&cmd_config_e_tag_e_tag,
11863 (void *)&cmd_config_e_tag_set,
11864 (void *)&cmd_config_e_tag_insertion,
11865 (void *)&cmd_config_e_tag_on,
11866 (void *)&cmd_config_e_tag_port_tag_id,
11867 (void *)&cmd_config_e_tag_port_tag_id_val,
11868 (void *)&cmd_config_e_tag_port,
11869 (void *)&cmd_config_e_tag_port_id,
11870 (void *)&cmd_config_e_tag_vf,
11871 (void *)&cmd_config_e_tag_vf_id,
11876 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = {
11877 .f = cmd_config_e_tag_insertion_dis_parsed,
11879 .help_str = "E-tag ... : E-tag insertion disable",
11881 (void *)&cmd_config_e_tag_e_tag,
11882 (void *)&cmd_config_e_tag_set,
11883 (void *)&cmd_config_e_tag_insertion,
11884 (void *)&cmd_config_e_tag_off,
11885 (void *)&cmd_config_e_tag_port,
11886 (void *)&cmd_config_e_tag_port_id,
11887 (void *)&cmd_config_e_tag_vf,
11888 (void *)&cmd_config_e_tag_vf_id,
11893 /* E-tag stripping configuration */
11895 cmd_config_e_tag_stripping_parsed(
11896 void *parsed_result,
11897 __attribute__((unused)) struct cmdline *cl,
11898 __attribute__((unused)) void *data)
11900 struct cmd_config_e_tag_result *res =
11902 struct rte_eth_l2_tunnel_conf entry;
11904 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11907 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
11909 if (!strcmp(res->on_off, "on"))
11910 rte_eth_dev_l2_tunnel_offload_set
11913 ETH_L2_TUNNEL_STRIPPING_MASK,
11916 rte_eth_dev_l2_tunnel_offload_set
11919 ETH_L2_TUNNEL_STRIPPING_MASK,
11923 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = {
11924 .f = cmd_config_e_tag_stripping_parsed,
11926 .help_str = "E-tag ... : E-tag stripping enable/disable",
11928 (void *)&cmd_config_e_tag_e_tag,
11929 (void *)&cmd_config_e_tag_set,
11930 (void *)&cmd_config_e_tag_stripping,
11931 (void *)&cmd_config_e_tag_on_off,
11932 (void *)&cmd_config_e_tag_port,
11933 (void *)&cmd_config_e_tag_port_id,
11938 /* E-tag forwarding configuration */
11940 cmd_config_e_tag_forwarding_parsed(
11941 void *parsed_result,
11942 __attribute__((unused)) struct cmdline *cl,
11943 __attribute__((unused)) void *data)
11945 struct cmd_config_e_tag_result *res = parsed_result;
11946 struct rte_eth_l2_tunnel_conf entry;
11948 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11951 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
11953 if (!strcmp(res->on_off, "on"))
11954 rte_eth_dev_l2_tunnel_offload_set
11957 ETH_L2_TUNNEL_FORWARDING_MASK,
11960 rte_eth_dev_l2_tunnel_offload_set
11963 ETH_L2_TUNNEL_FORWARDING_MASK,
11967 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = {
11968 .f = cmd_config_e_tag_forwarding_parsed,
11970 .help_str = "E-tag ... : E-tag forwarding enable/disable",
11972 (void *)&cmd_config_e_tag_e_tag,
11973 (void *)&cmd_config_e_tag_set,
11974 (void *)&cmd_config_e_tag_forwarding,
11975 (void *)&cmd_config_e_tag_on_off,
11976 (void *)&cmd_config_e_tag_port,
11977 (void *)&cmd_config_e_tag_port_id,
11982 /* E-tag filter configuration */
11984 cmd_config_e_tag_filter_add_parsed(
11985 void *parsed_result,
11986 __attribute__((unused)) struct cmdline *cl,
11987 __attribute__((unused)) void *data)
11989 struct cmd_config_e_tag_result *res = parsed_result;
11990 struct rte_eth_l2_tunnel_conf entry;
11993 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11996 if (res->e_tag_id_val > 0x3fff) {
11997 printf("e-tag-id must be equal or less than 0x3fff.\n");
12001 ret = rte_eth_dev_filter_supported(res->port_id,
12002 RTE_ETH_FILTER_L2_TUNNEL);
12004 printf("E-tag filter is not supported on port %u.\n",
12009 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12010 entry.tunnel_id = res->e_tag_id_val;
12011 entry.pool = res->dst_pool_val;
12013 ret = rte_eth_dev_filter_ctrl(res->port_id,
12014 RTE_ETH_FILTER_L2_TUNNEL,
12015 RTE_ETH_FILTER_ADD,
12018 printf("E-tag filter programming error: (%s)\n",
12022 cmdline_parse_inst_t cmd_config_e_tag_filter_add = {
12023 .f = cmd_config_e_tag_filter_add_parsed,
12025 .help_str = "E-tag ... : E-tag filter add",
12027 (void *)&cmd_config_e_tag_e_tag,
12028 (void *)&cmd_config_e_tag_set,
12029 (void *)&cmd_config_e_tag_filter,
12030 (void *)&cmd_config_e_tag_add,
12031 (void *)&cmd_config_e_tag_e_tag_id,
12032 (void *)&cmd_config_e_tag_e_tag_id_val,
12033 (void *)&cmd_config_e_tag_dst_pool,
12034 (void *)&cmd_config_e_tag_dst_pool_val,
12035 (void *)&cmd_config_e_tag_port,
12036 (void *)&cmd_config_e_tag_port_id,
12042 cmd_config_e_tag_filter_del_parsed(
12043 void *parsed_result,
12044 __attribute__((unused)) struct cmdline *cl,
12045 __attribute__((unused)) void *data)
12047 struct cmd_config_e_tag_result *res = parsed_result;
12048 struct rte_eth_l2_tunnel_conf entry;
12051 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12054 if (res->e_tag_id_val > 0x3fff) {
12055 printf("e-tag-id must be less than 0x3fff.\n");
12059 ret = rte_eth_dev_filter_supported(res->port_id,
12060 RTE_ETH_FILTER_L2_TUNNEL);
12062 printf("E-tag filter is not supported on port %u.\n",
12067 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12068 entry.tunnel_id = res->e_tag_id_val;
12070 ret = rte_eth_dev_filter_ctrl(res->port_id,
12071 RTE_ETH_FILTER_L2_TUNNEL,
12072 RTE_ETH_FILTER_DELETE,
12075 printf("E-tag filter programming error: (%s)\n",
12079 cmdline_parse_inst_t cmd_config_e_tag_filter_del = {
12080 .f = cmd_config_e_tag_filter_del_parsed,
12082 .help_str = "E-tag ... : E-tag filter delete",
12084 (void *)&cmd_config_e_tag_e_tag,
12085 (void *)&cmd_config_e_tag_set,
12086 (void *)&cmd_config_e_tag_filter,
12087 (void *)&cmd_config_e_tag_del,
12088 (void *)&cmd_config_e_tag_e_tag_id,
12089 (void *)&cmd_config_e_tag_e_tag_id_val,
12090 (void *)&cmd_config_e_tag_port,
12091 (void *)&cmd_config_e_tag_port_id,
12096 /* vf vlan anti spoof configuration */
12098 /* Common result structure for vf vlan anti spoof */
12099 struct cmd_vf_vlan_anti_spoof_result {
12100 cmdline_fixed_string_t set;
12101 cmdline_fixed_string_t vf;
12102 cmdline_fixed_string_t vlan;
12103 cmdline_fixed_string_t antispoof;
12106 cmdline_fixed_string_t on_off;
12109 /* Common CLI fields for vf vlan anti spoof enable disable */
12110 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
12111 TOKEN_STRING_INITIALIZER
12112 (struct cmd_vf_vlan_anti_spoof_result,
12114 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
12115 TOKEN_STRING_INITIALIZER
12116 (struct cmd_vf_vlan_anti_spoof_result,
12118 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
12119 TOKEN_STRING_INITIALIZER
12120 (struct cmd_vf_vlan_anti_spoof_result,
12122 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
12123 TOKEN_STRING_INITIALIZER
12124 (struct cmd_vf_vlan_anti_spoof_result,
12125 antispoof, "antispoof");
12126 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
12127 TOKEN_NUM_INITIALIZER
12128 (struct cmd_vf_vlan_anti_spoof_result,
12130 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
12131 TOKEN_NUM_INITIALIZER
12132 (struct cmd_vf_vlan_anti_spoof_result,
12134 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
12135 TOKEN_STRING_INITIALIZER
12136 (struct cmd_vf_vlan_anti_spoof_result,
12140 cmd_set_vf_vlan_anti_spoof_parsed(
12141 void *parsed_result,
12142 __attribute__((unused)) struct cmdline *cl,
12143 __attribute__((unused)) void *data)
12145 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
12146 int ret = -ENOTSUP;
12148 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12150 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12153 #ifdef RTE_LIBRTE_IXGBE_PMD
12154 if (ret == -ENOTSUP)
12155 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
12156 res->vf_id, is_on);
12158 #ifdef RTE_LIBRTE_I40E_PMD
12159 if (ret == -ENOTSUP)
12160 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
12161 res->vf_id, is_on);
12163 #ifdef RTE_LIBRTE_BNXT_PMD
12164 if (ret == -ENOTSUP)
12165 ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
12166 res->vf_id, is_on);
12173 printf("invalid vf_id %d\n", res->vf_id);
12176 printf("invalid port_id %d\n", res->port_id);
12179 printf("function not implemented\n");
12182 printf("programming error: (%s)\n", strerror(-ret));
12186 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
12187 .f = cmd_set_vf_vlan_anti_spoof_parsed,
12189 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
12191 (void *)&cmd_vf_vlan_anti_spoof_set,
12192 (void *)&cmd_vf_vlan_anti_spoof_vf,
12193 (void *)&cmd_vf_vlan_anti_spoof_vlan,
12194 (void *)&cmd_vf_vlan_anti_spoof_antispoof,
12195 (void *)&cmd_vf_vlan_anti_spoof_port_id,
12196 (void *)&cmd_vf_vlan_anti_spoof_vf_id,
12197 (void *)&cmd_vf_vlan_anti_spoof_on_off,
12202 /* vf mac anti spoof configuration */
12204 /* Common result structure for vf mac anti spoof */
12205 struct cmd_vf_mac_anti_spoof_result {
12206 cmdline_fixed_string_t set;
12207 cmdline_fixed_string_t vf;
12208 cmdline_fixed_string_t mac;
12209 cmdline_fixed_string_t antispoof;
12212 cmdline_fixed_string_t on_off;
12215 /* Common CLI fields for vf mac anti spoof enable disable */
12216 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
12217 TOKEN_STRING_INITIALIZER
12218 (struct cmd_vf_mac_anti_spoof_result,
12220 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
12221 TOKEN_STRING_INITIALIZER
12222 (struct cmd_vf_mac_anti_spoof_result,
12224 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
12225 TOKEN_STRING_INITIALIZER
12226 (struct cmd_vf_mac_anti_spoof_result,
12228 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
12229 TOKEN_STRING_INITIALIZER
12230 (struct cmd_vf_mac_anti_spoof_result,
12231 antispoof, "antispoof");
12232 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
12233 TOKEN_NUM_INITIALIZER
12234 (struct cmd_vf_mac_anti_spoof_result,
12236 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
12237 TOKEN_NUM_INITIALIZER
12238 (struct cmd_vf_mac_anti_spoof_result,
12240 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
12241 TOKEN_STRING_INITIALIZER
12242 (struct cmd_vf_mac_anti_spoof_result,
12246 cmd_set_vf_mac_anti_spoof_parsed(
12247 void *parsed_result,
12248 __attribute__((unused)) struct cmdline *cl,
12249 __attribute__((unused)) void *data)
12251 struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
12252 int ret = -ENOTSUP;
12254 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12256 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12259 #ifdef RTE_LIBRTE_IXGBE_PMD
12260 if (ret == -ENOTSUP)
12261 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
12262 res->vf_id, is_on);
12264 #ifdef RTE_LIBRTE_I40E_PMD
12265 if (ret == -ENOTSUP)
12266 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
12267 res->vf_id, is_on);
12269 #ifdef RTE_LIBRTE_BNXT_PMD
12270 if (ret == -ENOTSUP)
12271 ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
12272 res->vf_id, is_on);
12279 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12282 printf("invalid port_id %d\n", res->port_id);
12285 printf("function not implemented\n");
12288 printf("programming error: (%s)\n", strerror(-ret));
12292 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
12293 .f = cmd_set_vf_mac_anti_spoof_parsed,
12295 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
12297 (void *)&cmd_vf_mac_anti_spoof_set,
12298 (void *)&cmd_vf_mac_anti_spoof_vf,
12299 (void *)&cmd_vf_mac_anti_spoof_mac,
12300 (void *)&cmd_vf_mac_anti_spoof_antispoof,
12301 (void *)&cmd_vf_mac_anti_spoof_port_id,
12302 (void *)&cmd_vf_mac_anti_spoof_vf_id,
12303 (void *)&cmd_vf_mac_anti_spoof_on_off,
12308 /* vf vlan strip queue configuration */
12310 /* Common result structure for vf mac anti spoof */
12311 struct cmd_vf_vlan_stripq_result {
12312 cmdline_fixed_string_t set;
12313 cmdline_fixed_string_t vf;
12314 cmdline_fixed_string_t vlan;
12315 cmdline_fixed_string_t stripq;
12318 cmdline_fixed_string_t on_off;
12321 /* Common CLI fields for vf vlan strip enable disable */
12322 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
12323 TOKEN_STRING_INITIALIZER
12324 (struct cmd_vf_vlan_stripq_result,
12326 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
12327 TOKEN_STRING_INITIALIZER
12328 (struct cmd_vf_vlan_stripq_result,
12330 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
12331 TOKEN_STRING_INITIALIZER
12332 (struct cmd_vf_vlan_stripq_result,
12334 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
12335 TOKEN_STRING_INITIALIZER
12336 (struct cmd_vf_vlan_stripq_result,
12338 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
12339 TOKEN_NUM_INITIALIZER
12340 (struct cmd_vf_vlan_stripq_result,
12342 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
12343 TOKEN_NUM_INITIALIZER
12344 (struct cmd_vf_vlan_stripq_result,
12346 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
12347 TOKEN_STRING_INITIALIZER
12348 (struct cmd_vf_vlan_stripq_result,
12352 cmd_set_vf_vlan_stripq_parsed(
12353 void *parsed_result,
12354 __attribute__((unused)) struct cmdline *cl,
12355 __attribute__((unused)) void *data)
12357 struct cmd_vf_vlan_stripq_result *res = parsed_result;
12358 int ret = -ENOTSUP;
12360 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12362 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12365 #ifdef RTE_LIBRTE_IXGBE_PMD
12366 if (ret == -ENOTSUP)
12367 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
12368 res->vf_id, is_on);
12370 #ifdef RTE_LIBRTE_I40E_PMD
12371 if (ret == -ENOTSUP)
12372 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
12373 res->vf_id, is_on);
12375 #ifdef RTE_LIBRTE_BNXT_PMD
12376 if (ret == -ENOTSUP)
12377 ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
12378 res->vf_id, is_on);
12385 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12388 printf("invalid port_id %d\n", res->port_id);
12391 printf("function not implemented\n");
12394 printf("programming error: (%s)\n", strerror(-ret));
12398 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
12399 .f = cmd_set_vf_vlan_stripq_parsed,
12401 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
12403 (void *)&cmd_vf_vlan_stripq_set,
12404 (void *)&cmd_vf_vlan_stripq_vf,
12405 (void *)&cmd_vf_vlan_stripq_vlan,
12406 (void *)&cmd_vf_vlan_stripq_stripq,
12407 (void *)&cmd_vf_vlan_stripq_port_id,
12408 (void *)&cmd_vf_vlan_stripq_vf_id,
12409 (void *)&cmd_vf_vlan_stripq_on_off,
12414 /* vf vlan insert configuration */
12416 /* Common result structure for vf vlan insert */
12417 struct cmd_vf_vlan_insert_result {
12418 cmdline_fixed_string_t set;
12419 cmdline_fixed_string_t vf;
12420 cmdline_fixed_string_t vlan;
12421 cmdline_fixed_string_t insert;
12427 /* Common CLI fields for vf vlan insert enable disable */
12428 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
12429 TOKEN_STRING_INITIALIZER
12430 (struct cmd_vf_vlan_insert_result,
12432 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
12433 TOKEN_STRING_INITIALIZER
12434 (struct cmd_vf_vlan_insert_result,
12436 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
12437 TOKEN_STRING_INITIALIZER
12438 (struct cmd_vf_vlan_insert_result,
12440 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
12441 TOKEN_STRING_INITIALIZER
12442 (struct cmd_vf_vlan_insert_result,
12444 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
12445 TOKEN_NUM_INITIALIZER
12446 (struct cmd_vf_vlan_insert_result,
12448 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
12449 TOKEN_NUM_INITIALIZER
12450 (struct cmd_vf_vlan_insert_result,
12452 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
12453 TOKEN_NUM_INITIALIZER
12454 (struct cmd_vf_vlan_insert_result,
12458 cmd_set_vf_vlan_insert_parsed(
12459 void *parsed_result,
12460 __attribute__((unused)) struct cmdline *cl,
12461 __attribute__((unused)) void *data)
12463 struct cmd_vf_vlan_insert_result *res = parsed_result;
12464 int ret = -ENOTSUP;
12466 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12469 #ifdef RTE_LIBRTE_IXGBE_PMD
12470 if (ret == -ENOTSUP)
12471 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
12474 #ifdef RTE_LIBRTE_I40E_PMD
12475 if (ret == -ENOTSUP)
12476 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
12479 #ifdef RTE_LIBRTE_BNXT_PMD
12480 if (ret == -ENOTSUP)
12481 ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
12489 printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id);
12492 printf("invalid port_id %d\n", res->port_id);
12495 printf("function not implemented\n");
12498 printf("programming error: (%s)\n", strerror(-ret));
12502 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
12503 .f = cmd_set_vf_vlan_insert_parsed,
12505 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
12507 (void *)&cmd_vf_vlan_insert_set,
12508 (void *)&cmd_vf_vlan_insert_vf,
12509 (void *)&cmd_vf_vlan_insert_vlan,
12510 (void *)&cmd_vf_vlan_insert_insert,
12511 (void *)&cmd_vf_vlan_insert_port_id,
12512 (void *)&cmd_vf_vlan_insert_vf_id,
12513 (void *)&cmd_vf_vlan_insert_vlan_id,
12518 /* tx loopback configuration */
12520 /* Common result structure for tx loopback */
12521 struct cmd_tx_loopback_result {
12522 cmdline_fixed_string_t set;
12523 cmdline_fixed_string_t tx;
12524 cmdline_fixed_string_t loopback;
12526 cmdline_fixed_string_t on_off;
12529 /* Common CLI fields for tx loopback enable disable */
12530 cmdline_parse_token_string_t cmd_tx_loopback_set =
12531 TOKEN_STRING_INITIALIZER
12532 (struct cmd_tx_loopback_result,
12534 cmdline_parse_token_string_t cmd_tx_loopback_tx =
12535 TOKEN_STRING_INITIALIZER
12536 (struct cmd_tx_loopback_result,
12538 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
12539 TOKEN_STRING_INITIALIZER
12540 (struct cmd_tx_loopback_result,
12541 loopback, "loopback");
12542 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
12543 TOKEN_NUM_INITIALIZER
12544 (struct cmd_tx_loopback_result,
12546 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
12547 TOKEN_STRING_INITIALIZER
12548 (struct cmd_tx_loopback_result,
12552 cmd_set_tx_loopback_parsed(
12553 void *parsed_result,
12554 __attribute__((unused)) struct cmdline *cl,
12555 __attribute__((unused)) void *data)
12557 struct cmd_tx_loopback_result *res = parsed_result;
12558 int ret = -ENOTSUP;
12560 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12562 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12565 #ifdef RTE_LIBRTE_IXGBE_PMD
12566 if (ret == -ENOTSUP)
12567 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
12569 #ifdef RTE_LIBRTE_I40E_PMD
12570 if (ret == -ENOTSUP)
12571 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
12573 #ifdef RTE_LIBRTE_BNXT_PMD
12574 if (ret == -ENOTSUP)
12575 ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
12582 printf("invalid is_on %d\n", is_on);
12585 printf("invalid port_id %d\n", res->port_id);
12588 printf("function not implemented\n");
12591 printf("programming error: (%s)\n", strerror(-ret));
12595 cmdline_parse_inst_t cmd_set_tx_loopback = {
12596 .f = cmd_set_tx_loopback_parsed,
12598 .help_str = "set tx loopback <port_id> on|off",
12600 (void *)&cmd_tx_loopback_set,
12601 (void *)&cmd_tx_loopback_tx,
12602 (void *)&cmd_tx_loopback_loopback,
12603 (void *)&cmd_tx_loopback_port_id,
12604 (void *)&cmd_tx_loopback_on_off,
12609 /* all queues drop enable configuration */
12611 /* Common result structure for all queues drop enable */
12612 struct cmd_all_queues_drop_en_result {
12613 cmdline_fixed_string_t set;
12614 cmdline_fixed_string_t all;
12615 cmdline_fixed_string_t queues;
12616 cmdline_fixed_string_t drop;
12618 cmdline_fixed_string_t on_off;
12621 /* Common CLI fields for tx loopback enable disable */
12622 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
12623 TOKEN_STRING_INITIALIZER
12624 (struct cmd_all_queues_drop_en_result,
12626 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
12627 TOKEN_STRING_INITIALIZER
12628 (struct cmd_all_queues_drop_en_result,
12630 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
12631 TOKEN_STRING_INITIALIZER
12632 (struct cmd_all_queues_drop_en_result,
12634 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
12635 TOKEN_STRING_INITIALIZER
12636 (struct cmd_all_queues_drop_en_result,
12638 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
12639 TOKEN_NUM_INITIALIZER
12640 (struct cmd_all_queues_drop_en_result,
12642 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
12643 TOKEN_STRING_INITIALIZER
12644 (struct cmd_all_queues_drop_en_result,
12648 cmd_set_all_queues_drop_en_parsed(
12649 void *parsed_result,
12650 __attribute__((unused)) struct cmdline *cl,
12651 __attribute__((unused)) void *data)
12653 struct cmd_all_queues_drop_en_result *res = parsed_result;
12654 int ret = -ENOTSUP;
12655 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12657 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12660 #ifdef RTE_LIBRTE_IXGBE_PMD
12661 if (ret == -ENOTSUP)
12662 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
12664 #ifdef RTE_LIBRTE_BNXT_PMD
12665 if (ret == -ENOTSUP)
12666 ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
12672 printf("invalid is_on %d\n", is_on);
12675 printf("invalid port_id %d\n", res->port_id);
12678 printf("function not implemented\n");
12681 printf("programming error: (%s)\n", strerror(-ret));
12685 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
12686 .f = cmd_set_all_queues_drop_en_parsed,
12688 .help_str = "set all queues drop <port_id> on|off",
12690 (void *)&cmd_all_queues_drop_en_set,
12691 (void *)&cmd_all_queues_drop_en_all,
12692 (void *)&cmd_all_queues_drop_en_queues,
12693 (void *)&cmd_all_queues_drop_en_drop,
12694 (void *)&cmd_all_queues_drop_en_port_id,
12695 (void *)&cmd_all_queues_drop_en_on_off,
12700 /* vf split drop enable configuration */
12702 /* Common result structure for vf split drop enable */
12703 struct cmd_vf_split_drop_en_result {
12704 cmdline_fixed_string_t set;
12705 cmdline_fixed_string_t vf;
12706 cmdline_fixed_string_t split;
12707 cmdline_fixed_string_t drop;
12710 cmdline_fixed_string_t on_off;
12713 /* Common CLI fields for vf split drop enable disable */
12714 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
12715 TOKEN_STRING_INITIALIZER
12716 (struct cmd_vf_split_drop_en_result,
12718 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
12719 TOKEN_STRING_INITIALIZER
12720 (struct cmd_vf_split_drop_en_result,
12722 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
12723 TOKEN_STRING_INITIALIZER
12724 (struct cmd_vf_split_drop_en_result,
12726 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
12727 TOKEN_STRING_INITIALIZER
12728 (struct cmd_vf_split_drop_en_result,
12730 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
12731 TOKEN_NUM_INITIALIZER
12732 (struct cmd_vf_split_drop_en_result,
12734 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
12735 TOKEN_NUM_INITIALIZER
12736 (struct cmd_vf_split_drop_en_result,
12738 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
12739 TOKEN_STRING_INITIALIZER
12740 (struct cmd_vf_split_drop_en_result,
12744 cmd_set_vf_split_drop_en_parsed(
12745 void *parsed_result,
12746 __attribute__((unused)) struct cmdline *cl,
12747 __attribute__((unused)) void *data)
12749 struct cmd_vf_split_drop_en_result *res = parsed_result;
12750 int ret = -ENOTSUP;
12751 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12753 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12756 #ifdef RTE_LIBRTE_IXGBE_PMD
12757 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
12764 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12767 printf("invalid port_id %d\n", res->port_id);
12770 printf("not supported on port %d\n", res->port_id);
12773 printf("programming error: (%s)\n", strerror(-ret));
12777 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
12778 .f = cmd_set_vf_split_drop_en_parsed,
12780 .help_str = "set vf split drop <port_id> <vf_id> on|off",
12782 (void *)&cmd_vf_split_drop_en_set,
12783 (void *)&cmd_vf_split_drop_en_vf,
12784 (void *)&cmd_vf_split_drop_en_split,
12785 (void *)&cmd_vf_split_drop_en_drop,
12786 (void *)&cmd_vf_split_drop_en_port_id,
12787 (void *)&cmd_vf_split_drop_en_vf_id,
12788 (void *)&cmd_vf_split_drop_en_on_off,
12793 /* vf mac address configuration */
12795 /* Common result structure for vf mac address */
12796 struct cmd_set_vf_mac_addr_result {
12797 cmdline_fixed_string_t set;
12798 cmdline_fixed_string_t vf;
12799 cmdline_fixed_string_t mac;
12800 cmdline_fixed_string_t addr;
12803 struct ether_addr mac_addr;
12807 /* Common CLI fields for vf split drop enable disable */
12808 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
12809 TOKEN_STRING_INITIALIZER
12810 (struct cmd_set_vf_mac_addr_result,
12812 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
12813 TOKEN_STRING_INITIALIZER
12814 (struct cmd_set_vf_mac_addr_result,
12816 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
12817 TOKEN_STRING_INITIALIZER
12818 (struct cmd_set_vf_mac_addr_result,
12820 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
12821 TOKEN_STRING_INITIALIZER
12822 (struct cmd_set_vf_mac_addr_result,
12824 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
12825 TOKEN_NUM_INITIALIZER
12826 (struct cmd_set_vf_mac_addr_result,
12828 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
12829 TOKEN_NUM_INITIALIZER
12830 (struct cmd_set_vf_mac_addr_result,
12832 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
12833 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
12837 cmd_set_vf_mac_addr_parsed(
12838 void *parsed_result,
12839 __attribute__((unused)) struct cmdline *cl,
12840 __attribute__((unused)) void *data)
12842 struct cmd_set_vf_mac_addr_result *res = parsed_result;
12843 int ret = -ENOTSUP;
12845 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12848 #ifdef RTE_LIBRTE_IXGBE_PMD
12849 if (ret == -ENOTSUP)
12850 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
12853 #ifdef RTE_LIBRTE_I40E_PMD
12854 if (ret == -ENOTSUP)
12855 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
12858 #ifdef RTE_LIBRTE_BNXT_PMD
12859 if (ret == -ENOTSUP)
12860 ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
12868 printf("invalid vf_id %d or mac_addr\n", res->vf_id);
12871 printf("invalid port_id %d\n", res->port_id);
12874 printf("function not implemented\n");
12877 printf("programming error: (%s)\n", strerror(-ret));
12881 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
12882 .f = cmd_set_vf_mac_addr_parsed,
12884 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
12886 (void *)&cmd_set_vf_mac_addr_set,
12887 (void *)&cmd_set_vf_mac_addr_vf,
12888 (void *)&cmd_set_vf_mac_addr_mac,
12889 (void *)&cmd_set_vf_mac_addr_addr,
12890 (void *)&cmd_set_vf_mac_addr_port_id,
12891 (void *)&cmd_set_vf_mac_addr_vf_id,
12892 (void *)&cmd_set_vf_mac_addr_mac_addr,
12897 /* MACsec configuration */
12899 /* Common result structure for MACsec offload enable */
12900 struct cmd_macsec_offload_on_result {
12901 cmdline_fixed_string_t set;
12902 cmdline_fixed_string_t macsec;
12903 cmdline_fixed_string_t offload;
12905 cmdline_fixed_string_t on;
12906 cmdline_fixed_string_t encrypt;
12907 cmdline_fixed_string_t en_on_off;
12908 cmdline_fixed_string_t replay_protect;
12909 cmdline_fixed_string_t rp_on_off;
12912 /* Common CLI fields for MACsec offload disable */
12913 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
12914 TOKEN_STRING_INITIALIZER
12915 (struct cmd_macsec_offload_on_result,
12917 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
12918 TOKEN_STRING_INITIALIZER
12919 (struct cmd_macsec_offload_on_result,
12921 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
12922 TOKEN_STRING_INITIALIZER
12923 (struct cmd_macsec_offload_on_result,
12924 offload, "offload");
12925 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
12926 TOKEN_NUM_INITIALIZER
12927 (struct cmd_macsec_offload_on_result,
12929 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
12930 TOKEN_STRING_INITIALIZER
12931 (struct cmd_macsec_offload_on_result,
12933 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
12934 TOKEN_STRING_INITIALIZER
12935 (struct cmd_macsec_offload_on_result,
12936 encrypt, "encrypt");
12937 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
12938 TOKEN_STRING_INITIALIZER
12939 (struct cmd_macsec_offload_on_result,
12940 en_on_off, "on#off");
12941 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
12942 TOKEN_STRING_INITIALIZER
12943 (struct cmd_macsec_offload_on_result,
12944 replay_protect, "replay-protect");
12945 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
12946 TOKEN_STRING_INITIALIZER
12947 (struct cmd_macsec_offload_on_result,
12948 rp_on_off, "on#off");
12951 cmd_set_macsec_offload_on_parsed(
12952 void *parsed_result,
12953 __attribute__((unused)) struct cmdline *cl,
12954 __attribute__((unused)) void *data)
12956 struct cmd_macsec_offload_on_result *res = parsed_result;
12957 int ret = -ENOTSUP;
12958 portid_t port_id = res->port_id;
12959 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
12960 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
12962 if (port_id_is_invalid(port_id, ENABLED_WARN))
12965 ports[port_id].tx_ol_flags |= TESTPMD_TX_OFFLOAD_MACSEC;
12966 #ifdef RTE_LIBRTE_IXGBE_PMD
12967 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
12976 printf("invalid port_id %d\n", port_id);
12979 printf("not supported on port %d\n", port_id);
12982 printf("programming error: (%s)\n", strerror(-ret));
12986 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
12987 .f = cmd_set_macsec_offload_on_parsed,
12989 .help_str = "set macsec offload <port_id> on "
12990 "encrypt on|off replay-protect on|off",
12992 (void *)&cmd_macsec_offload_on_set,
12993 (void *)&cmd_macsec_offload_on_macsec,
12994 (void *)&cmd_macsec_offload_on_offload,
12995 (void *)&cmd_macsec_offload_on_port_id,
12996 (void *)&cmd_macsec_offload_on_on,
12997 (void *)&cmd_macsec_offload_on_encrypt,
12998 (void *)&cmd_macsec_offload_on_en_on_off,
12999 (void *)&cmd_macsec_offload_on_replay_protect,
13000 (void *)&cmd_macsec_offload_on_rp_on_off,
13005 /* Common result structure for MACsec offload disable */
13006 struct cmd_macsec_offload_off_result {
13007 cmdline_fixed_string_t set;
13008 cmdline_fixed_string_t macsec;
13009 cmdline_fixed_string_t offload;
13011 cmdline_fixed_string_t off;
13014 /* Common CLI fields for MACsec offload disable */
13015 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
13016 TOKEN_STRING_INITIALIZER
13017 (struct cmd_macsec_offload_off_result,
13019 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
13020 TOKEN_STRING_INITIALIZER
13021 (struct cmd_macsec_offload_off_result,
13023 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
13024 TOKEN_STRING_INITIALIZER
13025 (struct cmd_macsec_offload_off_result,
13026 offload, "offload");
13027 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
13028 TOKEN_NUM_INITIALIZER
13029 (struct cmd_macsec_offload_off_result,
13031 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
13032 TOKEN_STRING_INITIALIZER
13033 (struct cmd_macsec_offload_off_result,
13037 cmd_set_macsec_offload_off_parsed(
13038 void *parsed_result,
13039 __attribute__((unused)) struct cmdline *cl,
13040 __attribute__((unused)) void *data)
13042 struct cmd_macsec_offload_off_result *res = parsed_result;
13043 int ret = -ENOTSUP;
13044 portid_t port_id = res->port_id;
13046 if (port_id_is_invalid(port_id, ENABLED_WARN))
13049 ports[port_id].tx_ol_flags &= ~TESTPMD_TX_OFFLOAD_MACSEC;
13050 #ifdef RTE_LIBRTE_IXGBE_PMD
13051 ret = rte_pmd_ixgbe_macsec_disable(port_id);
13058 printf("invalid port_id %d\n", port_id);
13061 printf("not supported on port %d\n", port_id);
13064 printf("programming error: (%s)\n", strerror(-ret));
13068 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
13069 .f = cmd_set_macsec_offload_off_parsed,
13071 .help_str = "set macsec offload <port_id> off",
13073 (void *)&cmd_macsec_offload_off_set,
13074 (void *)&cmd_macsec_offload_off_macsec,
13075 (void *)&cmd_macsec_offload_off_offload,
13076 (void *)&cmd_macsec_offload_off_port_id,
13077 (void *)&cmd_macsec_offload_off_off,
13082 /* Common result structure for MACsec secure connection configure */
13083 struct cmd_macsec_sc_result {
13084 cmdline_fixed_string_t set;
13085 cmdline_fixed_string_t macsec;
13086 cmdline_fixed_string_t sc;
13087 cmdline_fixed_string_t tx_rx;
13089 struct ether_addr mac;
13093 /* Common CLI fields for MACsec secure connection configure */
13094 cmdline_parse_token_string_t cmd_macsec_sc_set =
13095 TOKEN_STRING_INITIALIZER
13096 (struct cmd_macsec_sc_result,
13098 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
13099 TOKEN_STRING_INITIALIZER
13100 (struct cmd_macsec_sc_result,
13102 cmdline_parse_token_string_t cmd_macsec_sc_sc =
13103 TOKEN_STRING_INITIALIZER
13104 (struct cmd_macsec_sc_result,
13106 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
13107 TOKEN_STRING_INITIALIZER
13108 (struct cmd_macsec_sc_result,
13110 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
13111 TOKEN_NUM_INITIALIZER
13112 (struct cmd_macsec_sc_result,
13114 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
13115 TOKEN_ETHERADDR_INITIALIZER
13116 (struct cmd_macsec_sc_result,
13118 cmdline_parse_token_num_t cmd_macsec_sc_pi =
13119 TOKEN_NUM_INITIALIZER
13120 (struct cmd_macsec_sc_result,
13124 cmd_set_macsec_sc_parsed(
13125 void *parsed_result,
13126 __attribute__((unused)) struct cmdline *cl,
13127 __attribute__((unused)) void *data)
13129 struct cmd_macsec_sc_result *res = parsed_result;
13130 int ret = -ENOTSUP;
13131 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
13133 #ifdef RTE_LIBRTE_IXGBE_PMD
13135 rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
13136 res->mac.addr_bytes) :
13137 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
13138 res->mac.addr_bytes, res->pi);
13140 RTE_SET_USED(is_tx);
13146 printf("invalid port_id %d\n", res->port_id);
13149 printf("not supported on port %d\n", res->port_id);
13152 printf("programming error: (%s)\n", strerror(-ret));
13156 cmdline_parse_inst_t cmd_set_macsec_sc = {
13157 .f = cmd_set_macsec_sc_parsed,
13159 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
13161 (void *)&cmd_macsec_sc_set,
13162 (void *)&cmd_macsec_sc_macsec,
13163 (void *)&cmd_macsec_sc_sc,
13164 (void *)&cmd_macsec_sc_tx_rx,
13165 (void *)&cmd_macsec_sc_port_id,
13166 (void *)&cmd_macsec_sc_mac,
13167 (void *)&cmd_macsec_sc_pi,
13172 /* Common result structure for MACsec secure connection configure */
13173 struct cmd_macsec_sa_result {
13174 cmdline_fixed_string_t set;
13175 cmdline_fixed_string_t macsec;
13176 cmdline_fixed_string_t sa;
13177 cmdline_fixed_string_t tx_rx;
13182 cmdline_fixed_string_t key;
13185 /* Common CLI fields for MACsec secure connection configure */
13186 cmdline_parse_token_string_t cmd_macsec_sa_set =
13187 TOKEN_STRING_INITIALIZER
13188 (struct cmd_macsec_sa_result,
13190 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
13191 TOKEN_STRING_INITIALIZER
13192 (struct cmd_macsec_sa_result,
13194 cmdline_parse_token_string_t cmd_macsec_sa_sa =
13195 TOKEN_STRING_INITIALIZER
13196 (struct cmd_macsec_sa_result,
13198 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
13199 TOKEN_STRING_INITIALIZER
13200 (struct cmd_macsec_sa_result,
13202 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
13203 TOKEN_NUM_INITIALIZER
13204 (struct cmd_macsec_sa_result,
13206 cmdline_parse_token_num_t cmd_macsec_sa_idx =
13207 TOKEN_NUM_INITIALIZER
13208 (struct cmd_macsec_sa_result,
13210 cmdline_parse_token_num_t cmd_macsec_sa_an =
13211 TOKEN_NUM_INITIALIZER
13212 (struct cmd_macsec_sa_result,
13214 cmdline_parse_token_num_t cmd_macsec_sa_pn =
13215 TOKEN_NUM_INITIALIZER
13216 (struct cmd_macsec_sa_result,
13218 cmdline_parse_token_string_t cmd_macsec_sa_key =
13219 TOKEN_STRING_INITIALIZER
13220 (struct cmd_macsec_sa_result,
13224 cmd_set_macsec_sa_parsed(
13225 void *parsed_result,
13226 __attribute__((unused)) struct cmdline *cl,
13227 __attribute__((unused)) void *data)
13229 struct cmd_macsec_sa_result *res = parsed_result;
13230 int ret = -ENOTSUP;
13231 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
13232 uint8_t key[16] = { 0 };
13238 key_len = strlen(res->key) / 2;
13242 for (i = 0; i < key_len; i++) {
13243 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
13246 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
13249 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
13252 #ifdef RTE_LIBRTE_IXGBE_PMD
13254 rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
13255 res->idx, res->an, res->pn, key) :
13256 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
13257 res->idx, res->an, res->pn, key);
13259 RTE_SET_USED(is_tx);
13266 printf("invalid idx %d or an %d\n", res->idx, res->an);
13269 printf("invalid port_id %d\n", res->port_id);
13272 printf("not supported on port %d\n", res->port_id);
13275 printf("programming error: (%s)\n", strerror(-ret));
13279 cmdline_parse_inst_t cmd_set_macsec_sa = {
13280 .f = cmd_set_macsec_sa_parsed,
13282 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
13284 (void *)&cmd_macsec_sa_set,
13285 (void *)&cmd_macsec_sa_macsec,
13286 (void *)&cmd_macsec_sa_sa,
13287 (void *)&cmd_macsec_sa_tx_rx,
13288 (void *)&cmd_macsec_sa_port_id,
13289 (void *)&cmd_macsec_sa_idx,
13290 (void *)&cmd_macsec_sa_an,
13291 (void *)&cmd_macsec_sa_pn,
13292 (void *)&cmd_macsec_sa_key,
13297 /* VF unicast promiscuous mode configuration */
13299 /* Common result structure for VF unicast promiscuous mode */
13300 struct cmd_vf_promisc_result {
13301 cmdline_fixed_string_t set;
13302 cmdline_fixed_string_t vf;
13303 cmdline_fixed_string_t promisc;
13306 cmdline_fixed_string_t on_off;
13309 /* Common CLI fields for VF unicast promiscuous mode enable disable */
13310 cmdline_parse_token_string_t cmd_vf_promisc_set =
13311 TOKEN_STRING_INITIALIZER
13312 (struct cmd_vf_promisc_result,
13314 cmdline_parse_token_string_t cmd_vf_promisc_vf =
13315 TOKEN_STRING_INITIALIZER
13316 (struct cmd_vf_promisc_result,
13318 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
13319 TOKEN_STRING_INITIALIZER
13320 (struct cmd_vf_promisc_result,
13321 promisc, "promisc");
13322 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
13323 TOKEN_NUM_INITIALIZER
13324 (struct cmd_vf_promisc_result,
13326 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
13327 TOKEN_NUM_INITIALIZER
13328 (struct cmd_vf_promisc_result,
13330 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
13331 TOKEN_STRING_INITIALIZER
13332 (struct cmd_vf_promisc_result,
13336 cmd_set_vf_promisc_parsed(
13337 void *parsed_result,
13338 __attribute__((unused)) struct cmdline *cl,
13339 __attribute__((unused)) void *data)
13341 struct cmd_vf_promisc_result *res = parsed_result;
13342 int ret = -ENOTSUP;
13344 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13346 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13349 #ifdef RTE_LIBRTE_I40E_PMD
13350 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
13351 res->vf_id, is_on);
13358 printf("invalid vf_id %d\n", res->vf_id);
13361 printf("invalid port_id %d\n", res->port_id);
13364 printf("function not implemented\n");
13367 printf("programming error: (%s)\n", strerror(-ret));
13371 cmdline_parse_inst_t cmd_set_vf_promisc = {
13372 .f = cmd_set_vf_promisc_parsed,
13374 .help_str = "set vf promisc <port_id> <vf_id> on|off: "
13375 "Set unicast promiscuous mode for a VF from the PF",
13377 (void *)&cmd_vf_promisc_set,
13378 (void *)&cmd_vf_promisc_vf,
13379 (void *)&cmd_vf_promisc_promisc,
13380 (void *)&cmd_vf_promisc_port_id,
13381 (void *)&cmd_vf_promisc_vf_id,
13382 (void *)&cmd_vf_promisc_on_off,
13387 /* VF multicast promiscuous mode configuration */
13389 /* Common result structure for VF multicast promiscuous mode */
13390 struct cmd_vf_allmulti_result {
13391 cmdline_fixed_string_t set;
13392 cmdline_fixed_string_t vf;
13393 cmdline_fixed_string_t allmulti;
13396 cmdline_fixed_string_t on_off;
13399 /* Common CLI fields for VF multicast promiscuous mode enable disable */
13400 cmdline_parse_token_string_t cmd_vf_allmulti_set =
13401 TOKEN_STRING_INITIALIZER
13402 (struct cmd_vf_allmulti_result,
13404 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
13405 TOKEN_STRING_INITIALIZER
13406 (struct cmd_vf_allmulti_result,
13408 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
13409 TOKEN_STRING_INITIALIZER
13410 (struct cmd_vf_allmulti_result,
13411 allmulti, "allmulti");
13412 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
13413 TOKEN_NUM_INITIALIZER
13414 (struct cmd_vf_allmulti_result,
13416 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
13417 TOKEN_NUM_INITIALIZER
13418 (struct cmd_vf_allmulti_result,
13420 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
13421 TOKEN_STRING_INITIALIZER
13422 (struct cmd_vf_allmulti_result,
13426 cmd_set_vf_allmulti_parsed(
13427 void *parsed_result,
13428 __attribute__((unused)) struct cmdline *cl,
13429 __attribute__((unused)) void *data)
13431 struct cmd_vf_allmulti_result *res = parsed_result;
13432 int ret = -ENOTSUP;
13434 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13436 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13439 #ifdef RTE_LIBRTE_I40E_PMD
13440 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
13441 res->vf_id, is_on);
13448 printf("invalid vf_id %d\n", res->vf_id);
13451 printf("invalid port_id %d\n", res->port_id);
13454 printf("function not implemented\n");
13457 printf("programming error: (%s)\n", strerror(-ret));
13461 cmdline_parse_inst_t cmd_set_vf_allmulti = {
13462 .f = cmd_set_vf_allmulti_parsed,
13464 .help_str = "set vf allmulti <port_id> <vf_id> on|off: "
13465 "Set multicast promiscuous mode for a VF from the PF",
13467 (void *)&cmd_vf_allmulti_set,
13468 (void *)&cmd_vf_allmulti_vf,
13469 (void *)&cmd_vf_allmulti_allmulti,
13470 (void *)&cmd_vf_allmulti_port_id,
13471 (void *)&cmd_vf_allmulti_vf_id,
13472 (void *)&cmd_vf_allmulti_on_off,
13477 /* vf broadcast mode configuration */
13479 /* Common result structure for vf broadcast */
13480 struct cmd_set_vf_broadcast_result {
13481 cmdline_fixed_string_t set;
13482 cmdline_fixed_string_t vf;
13483 cmdline_fixed_string_t broadcast;
13486 cmdline_fixed_string_t on_off;
13489 /* Common CLI fields for vf broadcast enable disable */
13490 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
13491 TOKEN_STRING_INITIALIZER
13492 (struct cmd_set_vf_broadcast_result,
13494 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
13495 TOKEN_STRING_INITIALIZER
13496 (struct cmd_set_vf_broadcast_result,
13498 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
13499 TOKEN_STRING_INITIALIZER
13500 (struct cmd_set_vf_broadcast_result,
13501 broadcast, "broadcast");
13502 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
13503 TOKEN_NUM_INITIALIZER
13504 (struct cmd_set_vf_broadcast_result,
13506 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
13507 TOKEN_NUM_INITIALIZER
13508 (struct cmd_set_vf_broadcast_result,
13510 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
13511 TOKEN_STRING_INITIALIZER
13512 (struct cmd_set_vf_broadcast_result,
13516 cmd_set_vf_broadcast_parsed(
13517 void *parsed_result,
13518 __attribute__((unused)) struct cmdline *cl,
13519 __attribute__((unused)) void *data)
13521 struct cmd_set_vf_broadcast_result *res = parsed_result;
13522 int ret = -ENOTSUP;
13524 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13526 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13529 #ifdef RTE_LIBRTE_I40E_PMD
13530 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
13531 res->vf_id, is_on);
13538 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13541 printf("invalid port_id %d\n", res->port_id);
13544 printf("function not implemented\n");
13547 printf("programming error: (%s)\n", strerror(-ret));
13551 cmdline_parse_inst_t cmd_set_vf_broadcast = {
13552 .f = cmd_set_vf_broadcast_parsed,
13554 .help_str = "set vf broadcast <port_id> <vf_id> on|off",
13556 (void *)&cmd_set_vf_broadcast_set,
13557 (void *)&cmd_set_vf_broadcast_vf,
13558 (void *)&cmd_set_vf_broadcast_broadcast,
13559 (void *)&cmd_set_vf_broadcast_port_id,
13560 (void *)&cmd_set_vf_broadcast_vf_id,
13561 (void *)&cmd_set_vf_broadcast_on_off,
13566 /* vf vlan tag configuration */
13568 /* Common result structure for vf vlan tag */
13569 struct cmd_set_vf_vlan_tag_result {
13570 cmdline_fixed_string_t set;
13571 cmdline_fixed_string_t vf;
13572 cmdline_fixed_string_t vlan;
13573 cmdline_fixed_string_t tag;
13576 cmdline_fixed_string_t on_off;
13579 /* Common CLI fields for vf vlan tag enable disable */
13580 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
13581 TOKEN_STRING_INITIALIZER
13582 (struct cmd_set_vf_vlan_tag_result,
13584 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
13585 TOKEN_STRING_INITIALIZER
13586 (struct cmd_set_vf_vlan_tag_result,
13588 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
13589 TOKEN_STRING_INITIALIZER
13590 (struct cmd_set_vf_vlan_tag_result,
13592 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
13593 TOKEN_STRING_INITIALIZER
13594 (struct cmd_set_vf_vlan_tag_result,
13596 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
13597 TOKEN_NUM_INITIALIZER
13598 (struct cmd_set_vf_vlan_tag_result,
13600 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
13601 TOKEN_NUM_INITIALIZER
13602 (struct cmd_set_vf_vlan_tag_result,
13604 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
13605 TOKEN_STRING_INITIALIZER
13606 (struct cmd_set_vf_vlan_tag_result,
13610 cmd_set_vf_vlan_tag_parsed(
13611 void *parsed_result,
13612 __attribute__((unused)) struct cmdline *cl,
13613 __attribute__((unused)) void *data)
13615 struct cmd_set_vf_vlan_tag_result *res = parsed_result;
13616 int ret = -ENOTSUP;
13618 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13620 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13623 #ifdef RTE_LIBRTE_I40E_PMD
13624 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
13625 res->vf_id, is_on);
13632 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13635 printf("invalid port_id %d\n", res->port_id);
13638 printf("function not implemented\n");
13641 printf("programming error: (%s)\n", strerror(-ret));
13645 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
13646 .f = cmd_set_vf_vlan_tag_parsed,
13648 .help_str = "set vf vlan tag <port_id> <vf_id> on|off",
13650 (void *)&cmd_set_vf_vlan_tag_set,
13651 (void *)&cmd_set_vf_vlan_tag_vf,
13652 (void *)&cmd_set_vf_vlan_tag_vlan,
13653 (void *)&cmd_set_vf_vlan_tag_tag,
13654 (void *)&cmd_set_vf_vlan_tag_port_id,
13655 (void *)&cmd_set_vf_vlan_tag_vf_id,
13656 (void *)&cmd_set_vf_vlan_tag_on_off,
13661 /* Common definition of VF and TC TX bandwidth configuration */
13662 struct cmd_vf_tc_bw_result {
13663 cmdline_fixed_string_t set;
13664 cmdline_fixed_string_t vf;
13665 cmdline_fixed_string_t tc;
13666 cmdline_fixed_string_t tx;
13667 cmdline_fixed_string_t min_bw;
13668 cmdline_fixed_string_t max_bw;
13669 cmdline_fixed_string_t strict_link_prio;
13674 cmdline_fixed_string_t bw_list;
13678 cmdline_parse_token_string_t cmd_vf_tc_bw_set =
13679 TOKEN_STRING_INITIALIZER
13680 (struct cmd_vf_tc_bw_result,
13682 cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
13683 TOKEN_STRING_INITIALIZER
13684 (struct cmd_vf_tc_bw_result,
13686 cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
13687 TOKEN_STRING_INITIALIZER
13688 (struct cmd_vf_tc_bw_result,
13690 cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
13691 TOKEN_STRING_INITIALIZER
13692 (struct cmd_vf_tc_bw_result,
13694 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio =
13695 TOKEN_STRING_INITIALIZER
13696 (struct cmd_vf_tc_bw_result,
13697 strict_link_prio, "strict-link-priority");
13698 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw =
13699 TOKEN_STRING_INITIALIZER
13700 (struct cmd_vf_tc_bw_result,
13701 min_bw, "min-bandwidth");
13702 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
13703 TOKEN_STRING_INITIALIZER
13704 (struct cmd_vf_tc_bw_result,
13705 max_bw, "max-bandwidth");
13706 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
13707 TOKEN_NUM_INITIALIZER
13708 (struct cmd_vf_tc_bw_result,
13710 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
13711 TOKEN_NUM_INITIALIZER
13712 (struct cmd_vf_tc_bw_result,
13714 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no =
13715 TOKEN_NUM_INITIALIZER
13716 (struct cmd_vf_tc_bw_result,
13718 cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
13719 TOKEN_NUM_INITIALIZER
13720 (struct cmd_vf_tc_bw_result,
13722 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
13723 TOKEN_STRING_INITIALIZER
13724 (struct cmd_vf_tc_bw_result,
13726 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map =
13727 TOKEN_NUM_INITIALIZER
13728 (struct cmd_vf_tc_bw_result,
13731 /* VF max bandwidth setting */
13733 cmd_vf_max_bw_parsed(
13734 void *parsed_result,
13735 __attribute__((unused)) struct cmdline *cl,
13736 __attribute__((unused)) void *data)
13738 struct cmd_vf_tc_bw_result *res = parsed_result;
13739 int ret = -ENOTSUP;
13741 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13744 #ifdef RTE_LIBRTE_I40E_PMD
13745 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id,
13746 res->vf_id, res->bw);
13753 printf("invalid vf_id %d or bandwidth %d\n",
13754 res->vf_id, res->bw);
13757 printf("invalid port_id %d\n", res->port_id);
13760 printf("function not implemented\n");
13763 printf("programming error: (%s)\n", strerror(-ret));
13767 cmdline_parse_inst_t cmd_vf_max_bw = {
13768 .f = cmd_vf_max_bw_parsed,
13770 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
13772 (void *)&cmd_vf_tc_bw_set,
13773 (void *)&cmd_vf_tc_bw_vf,
13774 (void *)&cmd_vf_tc_bw_tx,
13775 (void *)&cmd_vf_tc_bw_max_bw,
13776 (void *)&cmd_vf_tc_bw_port_id,
13777 (void *)&cmd_vf_tc_bw_vf_id,
13778 (void *)&cmd_vf_tc_bw_bw,
13784 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
13789 const char *p, *p0 = str;
13796 p = strchr(p0, '(');
13798 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
13802 p0 = strchr(p, ')');
13804 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
13808 if (size >= sizeof(s)) {
13809 printf("The string size exceeds the internal buffer size\n");
13812 snprintf(s, sizeof(s), "%.*s", size, p);
13813 ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
13815 printf("Failed to get the bandwidth list. ");
13819 for (i = 0; i < ret; i++)
13820 bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
13825 /* TC min bandwidth setting */
13827 cmd_vf_tc_min_bw_parsed(
13828 void *parsed_result,
13829 __attribute__((unused)) struct cmdline *cl,
13830 __attribute__((unused)) void *data)
13832 struct cmd_vf_tc_bw_result *res = parsed_result;
13835 int ret = -ENOTSUP;
13837 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13840 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
13844 #ifdef RTE_LIBRTE_I40E_PMD
13845 ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
13853 printf("invalid vf_id %d or bandwidth\n", res->vf_id);
13856 printf("invalid port_id %d\n", res->port_id);
13859 printf("function not implemented\n");
13862 printf("programming error: (%s)\n", strerror(-ret));
13866 cmdline_parse_inst_t cmd_vf_tc_min_bw = {
13867 .f = cmd_vf_tc_min_bw_parsed,
13869 .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
13870 " <bw1, bw2, ...>",
13872 (void *)&cmd_vf_tc_bw_set,
13873 (void *)&cmd_vf_tc_bw_vf,
13874 (void *)&cmd_vf_tc_bw_tc,
13875 (void *)&cmd_vf_tc_bw_tx,
13876 (void *)&cmd_vf_tc_bw_min_bw,
13877 (void *)&cmd_vf_tc_bw_port_id,
13878 (void *)&cmd_vf_tc_bw_vf_id,
13879 (void *)&cmd_vf_tc_bw_bw_list,
13885 cmd_tc_min_bw_parsed(
13886 void *parsed_result,
13887 __attribute__((unused)) struct cmdline *cl,
13888 __attribute__((unused)) void *data)
13890 struct cmd_vf_tc_bw_result *res = parsed_result;
13891 struct rte_port *port;
13894 int ret = -ENOTSUP;
13896 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13899 port = &ports[res->port_id];
13900 /** Check if the port is not started **/
13901 if (port->port_status != RTE_PORT_STOPPED) {
13902 printf("Please stop port %d first\n", res->port_id);
13906 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
13910 #ifdef RTE_LIBRTE_IXGBE_PMD
13911 ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw);
13918 printf("invalid bandwidth\n");
13921 printf("invalid port_id %d\n", res->port_id);
13924 printf("function not implemented\n");
13927 printf("programming error: (%s)\n", strerror(-ret));
13931 cmdline_parse_inst_t cmd_tc_min_bw = {
13932 .f = cmd_tc_min_bw_parsed,
13934 .help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>",
13936 (void *)&cmd_vf_tc_bw_set,
13937 (void *)&cmd_vf_tc_bw_tc,
13938 (void *)&cmd_vf_tc_bw_tx,
13939 (void *)&cmd_vf_tc_bw_min_bw,
13940 (void *)&cmd_vf_tc_bw_port_id,
13941 (void *)&cmd_vf_tc_bw_bw_list,
13946 /* TC max bandwidth setting */
13948 cmd_vf_tc_max_bw_parsed(
13949 void *parsed_result,
13950 __attribute__((unused)) struct cmdline *cl,
13951 __attribute__((unused)) void *data)
13953 struct cmd_vf_tc_bw_result *res = parsed_result;
13954 int ret = -ENOTSUP;
13956 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13959 #ifdef RTE_LIBRTE_I40E_PMD
13960 ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id,
13961 res->tc_no, res->bw);
13968 printf("invalid vf_id %d, tc_no %d or bandwidth %d\n",
13969 res->vf_id, res->tc_no, res->bw);
13972 printf("invalid port_id %d\n", res->port_id);
13975 printf("function not implemented\n");
13978 printf("programming error: (%s)\n", strerror(-ret));
13982 cmdline_parse_inst_t cmd_vf_tc_max_bw = {
13983 .f = cmd_vf_tc_max_bw_parsed,
13985 .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>"
13988 (void *)&cmd_vf_tc_bw_set,
13989 (void *)&cmd_vf_tc_bw_vf,
13990 (void *)&cmd_vf_tc_bw_tc,
13991 (void *)&cmd_vf_tc_bw_tx,
13992 (void *)&cmd_vf_tc_bw_max_bw,
13993 (void *)&cmd_vf_tc_bw_port_id,
13994 (void *)&cmd_vf_tc_bw_vf_id,
13995 (void *)&cmd_vf_tc_bw_tc_no,
13996 (void *)&cmd_vf_tc_bw_bw,
14002 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
14004 /* *** Set Port default Traffic Management Hierarchy *** */
14005 struct cmd_set_port_tm_hierarchy_default_result {
14006 cmdline_fixed_string_t set;
14007 cmdline_fixed_string_t port;
14008 cmdline_fixed_string_t tm;
14009 cmdline_fixed_string_t hierarchy;
14010 cmdline_fixed_string_t def;
14014 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_set =
14015 TOKEN_STRING_INITIALIZER(
14016 struct cmd_set_port_tm_hierarchy_default_result, set, "set");
14017 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_port =
14018 TOKEN_STRING_INITIALIZER(
14019 struct cmd_set_port_tm_hierarchy_default_result, port, "port");
14020 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_tm =
14021 TOKEN_STRING_INITIALIZER(
14022 struct cmd_set_port_tm_hierarchy_default_result, tm, "tm");
14023 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_hierarchy =
14024 TOKEN_STRING_INITIALIZER(
14025 struct cmd_set_port_tm_hierarchy_default_result,
14026 hierarchy, "hierarchy");
14027 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_default =
14028 TOKEN_STRING_INITIALIZER(
14029 struct cmd_set_port_tm_hierarchy_default_result,
14031 cmdline_parse_token_num_t cmd_set_port_tm_hierarchy_default_port_id =
14032 TOKEN_NUM_INITIALIZER(
14033 struct cmd_set_port_tm_hierarchy_default_result,
14036 static void cmd_set_port_tm_hierarchy_default_parsed(void *parsed_result,
14037 __attribute__((unused)) struct cmdline *cl,
14038 __attribute__((unused)) void *data)
14040 struct cmd_set_port_tm_hierarchy_default_result *res = parsed_result;
14041 struct rte_port *p;
14042 portid_t port_id = res->port_id;
14044 if (port_id_is_invalid(port_id, ENABLED_WARN))
14047 p = &ports[port_id];
14050 if (p->softport.tm_flag == 0) {
14051 printf(" tm not enabled on port %u (error)\n", port_id);
14055 /* Forward mode: tm */
14056 if (strcmp(cur_fwd_config.fwd_eng->fwd_mode_name, "tm")) {
14057 printf(" tm mode not enabled(error)\n");
14061 /* Set the default tm hierarchy */
14062 p->softport.tm.default_hierarchy_enable = 1;
14065 cmdline_parse_inst_t cmd_set_port_tm_hierarchy_default = {
14066 .f = cmd_set_port_tm_hierarchy_default_parsed,
14068 .help_str = "set port tm hierarchy default <port_id>",
14070 (void *)&cmd_set_port_tm_hierarchy_default_set,
14071 (void *)&cmd_set_port_tm_hierarchy_default_port,
14072 (void *)&cmd_set_port_tm_hierarchy_default_tm,
14073 (void *)&cmd_set_port_tm_hierarchy_default_hierarchy,
14074 (void *)&cmd_set_port_tm_hierarchy_default_default,
14075 (void *)&cmd_set_port_tm_hierarchy_default_port_id,
14081 /* Strict link priority scheduling mode setting */
14083 cmd_strict_link_prio_parsed(
14084 void *parsed_result,
14085 __attribute__((unused)) struct cmdline *cl,
14086 __attribute__((unused)) void *data)
14088 struct cmd_vf_tc_bw_result *res = parsed_result;
14089 int ret = -ENOTSUP;
14091 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14094 #ifdef RTE_LIBRTE_I40E_PMD
14095 ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map);
14102 printf("invalid tc_bitmap 0x%x\n", res->tc_map);
14105 printf("invalid port_id %d\n", res->port_id);
14108 printf("function not implemented\n");
14111 printf("programming error: (%s)\n", strerror(-ret));
14115 cmdline_parse_inst_t cmd_strict_link_prio = {
14116 .f = cmd_strict_link_prio_parsed,
14118 .help_str = "set tx strict-link-priority <port_id> <tc_bitmap>",
14120 (void *)&cmd_vf_tc_bw_set,
14121 (void *)&cmd_vf_tc_bw_tx,
14122 (void *)&cmd_vf_tc_bw_strict_link_prio,
14123 (void *)&cmd_vf_tc_bw_port_id,
14124 (void *)&cmd_vf_tc_bw_tc_map,
14129 /* Load dynamic device personalization*/
14130 struct cmd_ddp_add_result {
14131 cmdline_fixed_string_t ddp;
14132 cmdline_fixed_string_t add;
14137 cmdline_parse_token_string_t cmd_ddp_add_ddp =
14138 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp");
14139 cmdline_parse_token_string_t cmd_ddp_add_add =
14140 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add");
14141 cmdline_parse_token_num_t cmd_ddp_add_port_id =
14142 TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id, UINT16);
14143 cmdline_parse_token_string_t cmd_ddp_add_filepath =
14144 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL);
14147 cmd_ddp_add_parsed(
14148 void *parsed_result,
14149 __attribute__((unused)) struct cmdline *cl,
14150 __attribute__((unused)) void *data)
14152 struct cmd_ddp_add_result *res = parsed_result;
14158 int ret = -ENOTSUP;
14160 if (res->port_id > nb_ports) {
14161 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
14165 if (!all_ports_stopped()) {
14166 printf("Please stop all ports first\n");
14170 filepath = strdup(res->filepath);
14171 if (filepath == NULL) {
14172 printf("Failed to allocate memory\n");
14175 file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ',');
14177 buff = open_ddp_package_file(file_fld[0], &size);
14179 free((void *)filepath);
14183 #ifdef RTE_LIBRTE_I40E_PMD
14184 if (ret == -ENOTSUP)
14185 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
14187 RTE_PMD_I40E_PKG_OP_WR_ADD);
14190 if (ret == -EEXIST)
14191 printf("Profile has already existed.\n");
14193 printf("Failed to load profile.\n");
14194 else if (file_num == 2)
14195 save_ddp_package_file(file_fld[1], buff, size);
14197 close_ddp_package_file(buff);
14198 free((void *)filepath);
14201 cmdline_parse_inst_t cmd_ddp_add = {
14202 .f = cmd_ddp_add_parsed,
14204 .help_str = "ddp add <port_id> <profile_path[,output_path]>",
14206 (void *)&cmd_ddp_add_ddp,
14207 (void *)&cmd_ddp_add_add,
14208 (void *)&cmd_ddp_add_port_id,
14209 (void *)&cmd_ddp_add_filepath,
14214 /* Delete dynamic device personalization*/
14215 struct cmd_ddp_del_result {
14216 cmdline_fixed_string_t ddp;
14217 cmdline_fixed_string_t del;
14222 cmdline_parse_token_string_t cmd_ddp_del_ddp =
14223 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp");
14224 cmdline_parse_token_string_t cmd_ddp_del_del =
14225 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del");
14226 cmdline_parse_token_num_t cmd_ddp_del_port_id =
14227 TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, UINT16);
14228 cmdline_parse_token_string_t cmd_ddp_del_filepath =
14229 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL);
14232 cmd_ddp_del_parsed(
14233 void *parsed_result,
14234 __attribute__((unused)) struct cmdline *cl,
14235 __attribute__((unused)) void *data)
14237 struct cmd_ddp_del_result *res = parsed_result;
14240 int ret = -ENOTSUP;
14242 if (res->port_id > nb_ports) {
14243 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
14247 if (!all_ports_stopped()) {
14248 printf("Please stop all ports first\n");
14252 buff = open_ddp_package_file(res->filepath, &size);
14256 #ifdef RTE_LIBRTE_I40E_PMD
14257 if (ret == -ENOTSUP)
14258 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
14260 RTE_PMD_I40E_PKG_OP_WR_DEL);
14263 if (ret == -EACCES)
14264 printf("Profile does not exist.\n");
14266 printf("Failed to delete profile.\n");
14268 close_ddp_package_file(buff);
14271 cmdline_parse_inst_t cmd_ddp_del = {
14272 .f = cmd_ddp_del_parsed,
14274 .help_str = "ddp del <port_id> <profile_path>",
14276 (void *)&cmd_ddp_del_ddp,
14277 (void *)&cmd_ddp_del_del,
14278 (void *)&cmd_ddp_del_port_id,
14279 (void *)&cmd_ddp_del_filepath,
14284 /* Get dynamic device personalization profile info */
14285 struct cmd_ddp_info_result {
14286 cmdline_fixed_string_t ddp;
14287 cmdline_fixed_string_t get;
14288 cmdline_fixed_string_t info;
14292 cmdline_parse_token_string_t cmd_ddp_info_ddp =
14293 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp");
14294 cmdline_parse_token_string_t cmd_ddp_info_get =
14295 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get");
14296 cmdline_parse_token_string_t cmd_ddp_info_info =
14297 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info");
14298 cmdline_parse_token_string_t cmd_ddp_info_filepath =
14299 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL);
14302 cmd_ddp_info_parsed(
14303 void *parsed_result,
14304 __attribute__((unused)) struct cmdline *cl,
14305 __attribute__((unused)) void *data)
14307 struct cmd_ddp_info_result *res = parsed_result;
14310 int ret = -ENOTSUP;
14311 #ifdef RTE_LIBRTE_I40E_PMD
14314 uint32_t buff_size = 0;
14315 struct rte_pmd_i40e_profile_info info;
14316 uint32_t dev_num = 0;
14317 struct rte_pmd_i40e_ddp_device_id *devs;
14318 uint32_t proto_num = 0;
14319 struct rte_pmd_i40e_proto_info *proto;
14320 uint32_t pctype_num = 0;
14321 struct rte_pmd_i40e_ptype_info *pctype;
14322 uint32_t ptype_num = 0;
14323 struct rte_pmd_i40e_ptype_info *ptype;
14328 pkg = open_ddp_package_file(res->filepath, &pkg_size);
14332 #ifdef RTE_LIBRTE_I40E_PMD
14333 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14334 (uint8_t *)&info, sizeof(info),
14335 RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER);
14337 printf("Global Track id: 0x%x\n", info.track_id);
14338 printf("Global Version: %d.%d.%d.%d\n",
14339 info.version.major,
14340 info.version.minor,
14341 info.version.update,
14342 info.version.draft);
14343 printf("Global Package name: %s\n\n", info.name);
14346 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14347 (uint8_t *)&info, sizeof(info),
14348 RTE_PMD_I40E_PKG_INFO_HEADER);
14350 printf("i40e Profile Track id: 0x%x\n", info.track_id);
14351 printf("i40e Profile Version: %d.%d.%d.%d\n",
14352 info.version.major,
14353 info.version.minor,
14354 info.version.update,
14355 info.version.draft);
14356 printf("i40e Profile name: %s\n\n", info.name);
14359 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14360 (uint8_t *)&buff_size, sizeof(buff_size),
14361 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE);
14362 if (!ret && buff_size) {
14363 buff = (uint8_t *)malloc(buff_size);
14365 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14367 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES);
14369 printf("Package Notes:\n%s\n\n", buff);
14374 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14375 (uint8_t *)&dev_num, sizeof(dev_num),
14376 RTE_PMD_I40E_PKG_INFO_DEVID_NUM);
14377 if (!ret && dev_num) {
14378 buff_size = dev_num * sizeof(struct rte_pmd_i40e_ddp_device_id);
14379 devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(buff_size);
14381 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14382 (uint8_t *)devs, buff_size,
14383 RTE_PMD_I40E_PKG_INFO_DEVID_LIST);
14385 printf("List of supported devices:\n");
14386 for (i = 0; i < dev_num; i++) {
14387 printf(" %04X:%04X %04X:%04X\n",
14388 devs[i].vendor_dev_id >> 16,
14389 devs[i].vendor_dev_id & 0xFFFF,
14390 devs[i].sub_vendor_dev_id >> 16,
14391 devs[i].sub_vendor_dev_id & 0xFFFF);
14399 /* get information about protocols and packet types */
14400 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14401 (uint8_t *)&proto_num, sizeof(proto_num),
14402 RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM);
14403 if (ret || !proto_num)
14404 goto no_print_return;
14406 buff_size = proto_num * sizeof(struct rte_pmd_i40e_proto_info);
14407 proto = (struct rte_pmd_i40e_proto_info *)malloc(buff_size);
14409 goto no_print_return;
14411 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)proto,
14413 RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST);
14415 printf("List of used protocols:\n");
14416 for (i = 0; i < proto_num; i++)
14417 printf(" %2u: %s\n", proto[i].proto_id,
14421 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14422 (uint8_t *)&pctype_num, sizeof(pctype_num),
14423 RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM);
14424 if (ret || !pctype_num)
14425 goto no_print_pctypes;
14427 buff_size = pctype_num * sizeof(struct rte_pmd_i40e_ptype_info);
14428 pctype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
14430 goto no_print_pctypes;
14432 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)pctype,
14434 RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST);
14437 goto no_print_pctypes;
14440 printf("List of defined packet classification types:\n");
14441 for (i = 0; i < pctype_num; i++) {
14442 printf(" %2u:", pctype[i].ptype_id);
14443 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
14444 proto_id = pctype[i].protocols[j];
14445 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
14446 for (n = 0; n < proto_num; n++) {
14447 if (proto[n].proto_id == proto_id) {
14448 printf(" %s", proto[n].name);
14461 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)&ptype_num,
14463 RTE_PMD_I40E_PKG_INFO_PTYPE_NUM);
14464 if (ret || !ptype_num)
14465 goto no_print_return;
14467 buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_info);
14468 ptype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
14470 goto no_print_return;
14472 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)ptype,
14474 RTE_PMD_I40E_PKG_INFO_PTYPE_LIST);
14477 goto no_print_return;
14479 printf("List of defined packet types:\n");
14480 for (i = 0; i < ptype_num; i++) {
14481 printf(" %2u:", ptype[i].ptype_id);
14482 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
14483 proto_id = ptype[i].protocols[j];
14484 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
14485 for (n = 0; n < proto_num; n++) {
14486 if (proto[n].proto_id == proto_id) {
14487 printf(" %s", proto[n].name);
14502 if (ret == -ENOTSUP)
14503 printf("Function not supported in PMD driver\n");
14504 close_ddp_package_file(pkg);
14507 cmdline_parse_inst_t cmd_ddp_get_info = {
14508 .f = cmd_ddp_info_parsed,
14510 .help_str = "ddp get info <profile_path>",
14512 (void *)&cmd_ddp_info_ddp,
14513 (void *)&cmd_ddp_info_get,
14514 (void *)&cmd_ddp_info_info,
14515 (void *)&cmd_ddp_info_filepath,
14520 /* Get dynamic device personalization profile info list*/
14521 #define PROFILE_INFO_SIZE 48
14522 #define MAX_PROFILE_NUM 16
14524 struct cmd_ddp_get_list_result {
14525 cmdline_fixed_string_t ddp;
14526 cmdline_fixed_string_t get;
14527 cmdline_fixed_string_t list;
14531 cmdline_parse_token_string_t cmd_ddp_get_list_ddp =
14532 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp");
14533 cmdline_parse_token_string_t cmd_ddp_get_list_get =
14534 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get");
14535 cmdline_parse_token_string_t cmd_ddp_get_list_list =
14536 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list");
14537 cmdline_parse_token_num_t cmd_ddp_get_list_port_id =
14538 TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id, UINT16);
14541 cmd_ddp_get_list_parsed(
14542 void *parsed_result,
14543 __attribute__((unused)) struct cmdline *cl,
14544 __attribute__((unused)) void *data)
14546 struct cmd_ddp_get_list_result *res = parsed_result;
14547 #ifdef RTE_LIBRTE_I40E_PMD
14548 struct rte_pmd_i40e_profile_list *p_list;
14549 struct rte_pmd_i40e_profile_info *p_info;
14554 int ret = -ENOTSUP;
14556 if (res->port_id > nb_ports) {
14557 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
14561 #ifdef RTE_LIBRTE_I40E_PMD
14562 size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4;
14563 p_list = (struct rte_pmd_i40e_profile_list *)malloc(size);
14565 printf("%s: Failed to malloc buffer\n", __func__);
14567 if (ret == -ENOTSUP)
14568 ret = rte_pmd_i40e_get_ddp_list(res->port_id,
14569 (uint8_t *)p_list, size);
14572 p_num = p_list->p_count;
14573 printf("Profile number is: %d\n\n", p_num);
14575 for (i = 0; i < p_num; i++) {
14576 p_info = &p_list->p_info[i];
14577 printf("Profile %d:\n", i);
14578 printf("Track id: 0x%x\n", p_info->track_id);
14579 printf("Version: %d.%d.%d.%d\n",
14580 p_info->version.major,
14581 p_info->version.minor,
14582 p_info->version.update,
14583 p_info->version.draft);
14584 printf("Profile name: %s\n\n", p_info->name);
14592 printf("Failed to get ddp list\n");
14595 cmdline_parse_inst_t cmd_ddp_get_list = {
14596 .f = cmd_ddp_get_list_parsed,
14598 .help_str = "ddp get list <port_id>",
14600 (void *)&cmd_ddp_get_list_ddp,
14601 (void *)&cmd_ddp_get_list_get,
14602 (void *)&cmd_ddp_get_list_list,
14603 (void *)&cmd_ddp_get_list_port_id,
14608 /* show vf stats */
14610 /* Common result structure for show vf stats */
14611 struct cmd_show_vf_stats_result {
14612 cmdline_fixed_string_t show;
14613 cmdline_fixed_string_t vf;
14614 cmdline_fixed_string_t stats;
14619 /* Common CLI fields show vf stats*/
14620 cmdline_parse_token_string_t cmd_show_vf_stats_show =
14621 TOKEN_STRING_INITIALIZER
14622 (struct cmd_show_vf_stats_result,
14624 cmdline_parse_token_string_t cmd_show_vf_stats_vf =
14625 TOKEN_STRING_INITIALIZER
14626 (struct cmd_show_vf_stats_result,
14628 cmdline_parse_token_string_t cmd_show_vf_stats_stats =
14629 TOKEN_STRING_INITIALIZER
14630 (struct cmd_show_vf_stats_result,
14632 cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
14633 TOKEN_NUM_INITIALIZER
14634 (struct cmd_show_vf_stats_result,
14636 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
14637 TOKEN_NUM_INITIALIZER
14638 (struct cmd_show_vf_stats_result,
14642 cmd_show_vf_stats_parsed(
14643 void *parsed_result,
14644 __attribute__((unused)) struct cmdline *cl,
14645 __attribute__((unused)) void *data)
14647 struct cmd_show_vf_stats_result *res = parsed_result;
14648 struct rte_eth_stats stats;
14649 int ret = -ENOTSUP;
14650 static const char *nic_stats_border = "########################";
14652 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14655 memset(&stats, 0, sizeof(stats));
14657 #ifdef RTE_LIBRTE_I40E_PMD
14658 if (ret == -ENOTSUP)
14659 ret = rte_pmd_i40e_get_vf_stats(res->port_id,
14663 #ifdef RTE_LIBRTE_BNXT_PMD
14664 if (ret == -ENOTSUP)
14665 ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
14674 printf("invalid vf_id %d\n", res->vf_id);
14677 printf("invalid port_id %d\n", res->port_id);
14680 printf("function not implemented\n");
14683 printf("programming error: (%s)\n", strerror(-ret));
14686 printf("\n %s NIC statistics for port %-2d vf %-2d %s\n",
14687 nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
14689 printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: "
14691 stats.ipackets, stats.imissed, stats.ibytes);
14692 printf(" RX-errors: %-"PRIu64"\n", stats.ierrors);
14693 printf(" RX-nombuf: %-10"PRIu64"\n",
14695 printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: "
14697 stats.opackets, stats.oerrors, stats.obytes);
14699 printf(" %s############################%s\n",
14700 nic_stats_border, nic_stats_border);
14703 cmdline_parse_inst_t cmd_show_vf_stats = {
14704 .f = cmd_show_vf_stats_parsed,
14706 .help_str = "show vf stats <port_id> <vf_id>",
14708 (void *)&cmd_show_vf_stats_show,
14709 (void *)&cmd_show_vf_stats_vf,
14710 (void *)&cmd_show_vf_stats_stats,
14711 (void *)&cmd_show_vf_stats_port_id,
14712 (void *)&cmd_show_vf_stats_vf_id,
14717 /* clear vf stats */
14719 /* Common result structure for clear vf stats */
14720 struct cmd_clear_vf_stats_result {
14721 cmdline_fixed_string_t clear;
14722 cmdline_fixed_string_t vf;
14723 cmdline_fixed_string_t stats;
14728 /* Common CLI fields clear vf stats*/
14729 cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
14730 TOKEN_STRING_INITIALIZER
14731 (struct cmd_clear_vf_stats_result,
14733 cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
14734 TOKEN_STRING_INITIALIZER
14735 (struct cmd_clear_vf_stats_result,
14737 cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
14738 TOKEN_STRING_INITIALIZER
14739 (struct cmd_clear_vf_stats_result,
14741 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
14742 TOKEN_NUM_INITIALIZER
14743 (struct cmd_clear_vf_stats_result,
14745 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
14746 TOKEN_NUM_INITIALIZER
14747 (struct cmd_clear_vf_stats_result,
14751 cmd_clear_vf_stats_parsed(
14752 void *parsed_result,
14753 __attribute__((unused)) struct cmdline *cl,
14754 __attribute__((unused)) void *data)
14756 struct cmd_clear_vf_stats_result *res = parsed_result;
14757 int ret = -ENOTSUP;
14759 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14762 #ifdef RTE_LIBRTE_I40E_PMD
14763 if (ret == -ENOTSUP)
14764 ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
14767 #ifdef RTE_LIBRTE_BNXT_PMD
14768 if (ret == -ENOTSUP)
14769 ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
14777 printf("invalid vf_id %d\n", res->vf_id);
14780 printf("invalid port_id %d\n", res->port_id);
14783 printf("function not implemented\n");
14786 printf("programming error: (%s)\n", strerror(-ret));
14790 cmdline_parse_inst_t cmd_clear_vf_stats = {
14791 .f = cmd_clear_vf_stats_parsed,
14793 .help_str = "clear vf stats <port_id> <vf_id>",
14795 (void *)&cmd_clear_vf_stats_clear,
14796 (void *)&cmd_clear_vf_stats_vf,
14797 (void *)&cmd_clear_vf_stats_stats,
14798 (void *)&cmd_clear_vf_stats_port_id,
14799 (void *)&cmd_clear_vf_stats_vf_id,
14804 /* port config pctype mapping reset */
14806 /* Common result structure for port config pctype mapping reset */
14807 struct cmd_pctype_mapping_reset_result {
14808 cmdline_fixed_string_t port;
14809 cmdline_fixed_string_t config;
14811 cmdline_fixed_string_t pctype;
14812 cmdline_fixed_string_t mapping;
14813 cmdline_fixed_string_t reset;
14816 /* Common CLI fields for port config pctype mapping reset*/
14817 cmdline_parse_token_string_t cmd_pctype_mapping_reset_port =
14818 TOKEN_STRING_INITIALIZER
14819 (struct cmd_pctype_mapping_reset_result,
14821 cmdline_parse_token_string_t cmd_pctype_mapping_reset_config =
14822 TOKEN_STRING_INITIALIZER
14823 (struct cmd_pctype_mapping_reset_result,
14825 cmdline_parse_token_num_t cmd_pctype_mapping_reset_port_id =
14826 TOKEN_NUM_INITIALIZER
14827 (struct cmd_pctype_mapping_reset_result,
14829 cmdline_parse_token_string_t cmd_pctype_mapping_reset_pctype =
14830 TOKEN_STRING_INITIALIZER
14831 (struct cmd_pctype_mapping_reset_result,
14833 cmdline_parse_token_string_t cmd_pctype_mapping_reset_mapping =
14834 TOKEN_STRING_INITIALIZER
14835 (struct cmd_pctype_mapping_reset_result,
14836 mapping, "mapping");
14837 cmdline_parse_token_string_t cmd_pctype_mapping_reset_reset =
14838 TOKEN_STRING_INITIALIZER
14839 (struct cmd_pctype_mapping_reset_result,
14843 cmd_pctype_mapping_reset_parsed(
14844 void *parsed_result,
14845 __attribute__((unused)) struct cmdline *cl,
14846 __attribute__((unused)) void *data)
14848 struct cmd_pctype_mapping_reset_result *res = parsed_result;
14849 int ret = -ENOTSUP;
14851 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14854 #ifdef RTE_LIBRTE_I40E_PMD
14855 ret = rte_pmd_i40e_flow_type_mapping_reset(res->port_id);
14862 printf("invalid port_id %d\n", res->port_id);
14865 printf("function not implemented\n");
14868 printf("programming error: (%s)\n", strerror(-ret));
14872 cmdline_parse_inst_t cmd_pctype_mapping_reset = {
14873 .f = cmd_pctype_mapping_reset_parsed,
14875 .help_str = "port config <port_id> pctype mapping reset",
14877 (void *)&cmd_pctype_mapping_reset_port,
14878 (void *)&cmd_pctype_mapping_reset_config,
14879 (void *)&cmd_pctype_mapping_reset_port_id,
14880 (void *)&cmd_pctype_mapping_reset_pctype,
14881 (void *)&cmd_pctype_mapping_reset_mapping,
14882 (void *)&cmd_pctype_mapping_reset_reset,
14887 /* show port pctype mapping */
14889 /* Common result structure for show port pctype mapping */
14890 struct cmd_pctype_mapping_get_result {
14891 cmdline_fixed_string_t show;
14892 cmdline_fixed_string_t port;
14894 cmdline_fixed_string_t pctype;
14895 cmdline_fixed_string_t mapping;
14898 /* Common CLI fields for pctype mapping get */
14899 cmdline_parse_token_string_t cmd_pctype_mapping_get_show =
14900 TOKEN_STRING_INITIALIZER
14901 (struct cmd_pctype_mapping_get_result,
14903 cmdline_parse_token_string_t cmd_pctype_mapping_get_port =
14904 TOKEN_STRING_INITIALIZER
14905 (struct cmd_pctype_mapping_get_result,
14907 cmdline_parse_token_num_t cmd_pctype_mapping_get_port_id =
14908 TOKEN_NUM_INITIALIZER
14909 (struct cmd_pctype_mapping_get_result,
14911 cmdline_parse_token_string_t cmd_pctype_mapping_get_pctype =
14912 TOKEN_STRING_INITIALIZER
14913 (struct cmd_pctype_mapping_get_result,
14915 cmdline_parse_token_string_t cmd_pctype_mapping_get_mapping =
14916 TOKEN_STRING_INITIALIZER
14917 (struct cmd_pctype_mapping_get_result,
14918 mapping, "mapping");
14921 cmd_pctype_mapping_get_parsed(
14922 void *parsed_result,
14923 __attribute__((unused)) struct cmdline *cl,
14924 __attribute__((unused)) void *data)
14926 struct cmd_pctype_mapping_get_result *res = parsed_result;
14927 int ret = -ENOTSUP;
14928 #ifdef RTE_LIBRTE_I40E_PMD
14929 struct rte_pmd_i40e_flow_type_mapping
14930 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
14931 int i, j, first_pctype;
14934 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14937 #ifdef RTE_LIBRTE_I40E_PMD
14938 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, mapping);
14945 printf("invalid port_id %d\n", res->port_id);
14948 printf("function not implemented\n");
14951 printf("programming error: (%s)\n", strerror(-ret));
14955 #ifdef RTE_LIBRTE_I40E_PMD
14956 for (i = 0; i < RTE_PMD_I40E_FLOW_TYPE_MAX; i++) {
14957 if (mapping[i].pctype != 0ULL) {
14960 printf("pctype: ");
14961 for (j = 0; j < RTE_PMD_I40E_PCTYPE_MAX; j++) {
14962 if (mapping[i].pctype & (1ULL << j)) {
14963 printf(first_pctype ?
14964 "%02d" : ",%02d", j);
14968 printf(" -> flowtype: %02d\n", mapping[i].flow_type);
14974 cmdline_parse_inst_t cmd_pctype_mapping_get = {
14975 .f = cmd_pctype_mapping_get_parsed,
14977 .help_str = "show port <port_id> pctype mapping",
14979 (void *)&cmd_pctype_mapping_get_show,
14980 (void *)&cmd_pctype_mapping_get_port,
14981 (void *)&cmd_pctype_mapping_get_port_id,
14982 (void *)&cmd_pctype_mapping_get_pctype,
14983 (void *)&cmd_pctype_mapping_get_mapping,
14988 /* port config pctype mapping update */
14990 /* Common result structure for port config pctype mapping update */
14991 struct cmd_pctype_mapping_update_result {
14992 cmdline_fixed_string_t port;
14993 cmdline_fixed_string_t config;
14995 cmdline_fixed_string_t pctype;
14996 cmdline_fixed_string_t mapping;
14997 cmdline_fixed_string_t update;
14998 cmdline_fixed_string_t pctype_list;
14999 uint16_t flow_type;
15002 /* Common CLI fields for pctype mapping update*/
15003 cmdline_parse_token_string_t cmd_pctype_mapping_update_port =
15004 TOKEN_STRING_INITIALIZER
15005 (struct cmd_pctype_mapping_update_result,
15007 cmdline_parse_token_string_t cmd_pctype_mapping_update_config =
15008 TOKEN_STRING_INITIALIZER
15009 (struct cmd_pctype_mapping_update_result,
15011 cmdline_parse_token_num_t cmd_pctype_mapping_update_port_id =
15012 TOKEN_NUM_INITIALIZER
15013 (struct cmd_pctype_mapping_update_result,
15015 cmdline_parse_token_string_t cmd_pctype_mapping_update_pctype =
15016 TOKEN_STRING_INITIALIZER
15017 (struct cmd_pctype_mapping_update_result,
15019 cmdline_parse_token_string_t cmd_pctype_mapping_update_mapping =
15020 TOKEN_STRING_INITIALIZER
15021 (struct cmd_pctype_mapping_update_result,
15022 mapping, "mapping");
15023 cmdline_parse_token_string_t cmd_pctype_mapping_update_update =
15024 TOKEN_STRING_INITIALIZER
15025 (struct cmd_pctype_mapping_update_result,
15027 cmdline_parse_token_string_t cmd_pctype_mapping_update_pc_type =
15028 TOKEN_STRING_INITIALIZER
15029 (struct cmd_pctype_mapping_update_result,
15030 pctype_list, NULL);
15031 cmdline_parse_token_num_t cmd_pctype_mapping_update_flow_type =
15032 TOKEN_NUM_INITIALIZER
15033 (struct cmd_pctype_mapping_update_result,
15034 flow_type, UINT16);
15037 cmd_pctype_mapping_update_parsed(
15038 void *parsed_result,
15039 __attribute__((unused)) struct cmdline *cl,
15040 __attribute__((unused)) void *data)
15042 struct cmd_pctype_mapping_update_result *res = parsed_result;
15043 int ret = -ENOTSUP;
15044 #ifdef RTE_LIBRTE_I40E_PMD
15045 struct rte_pmd_i40e_flow_type_mapping mapping;
15047 unsigned int nb_item;
15048 unsigned int pctype_list[RTE_PMD_I40E_PCTYPE_MAX];
15051 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15054 #ifdef RTE_LIBRTE_I40E_PMD
15055 nb_item = parse_item_list(res->pctype_list, "pctypes",
15056 RTE_PMD_I40E_PCTYPE_MAX, pctype_list, 1);
15057 mapping.flow_type = res->flow_type;
15058 for (i = 0, mapping.pctype = 0ULL; i < nb_item; i++)
15059 mapping.pctype |= (1ULL << pctype_list[i]);
15060 ret = rte_pmd_i40e_flow_type_mapping_update(res->port_id,
15070 printf("invalid pctype or flow type\n");
15073 printf("invalid port_id %d\n", res->port_id);
15076 printf("function not implemented\n");
15079 printf("programming error: (%s)\n", strerror(-ret));
15083 cmdline_parse_inst_t cmd_pctype_mapping_update = {
15084 .f = cmd_pctype_mapping_update_parsed,
15086 .help_str = "port config <port_id> pctype mapping update"
15087 " <pctype_id_0,[pctype_id_1]*> <flowtype_id>",
15089 (void *)&cmd_pctype_mapping_update_port,
15090 (void *)&cmd_pctype_mapping_update_config,
15091 (void *)&cmd_pctype_mapping_update_port_id,
15092 (void *)&cmd_pctype_mapping_update_pctype,
15093 (void *)&cmd_pctype_mapping_update_mapping,
15094 (void *)&cmd_pctype_mapping_update_update,
15095 (void *)&cmd_pctype_mapping_update_pc_type,
15096 (void *)&cmd_pctype_mapping_update_flow_type,
15101 /* ptype mapping get */
15103 /* Common result structure for ptype mapping get */
15104 struct cmd_ptype_mapping_get_result {
15105 cmdline_fixed_string_t ptype;
15106 cmdline_fixed_string_t mapping;
15107 cmdline_fixed_string_t get;
15109 uint8_t valid_only;
15112 /* Common CLI fields for ptype mapping get */
15113 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype =
15114 TOKEN_STRING_INITIALIZER
15115 (struct cmd_ptype_mapping_get_result,
15117 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping =
15118 TOKEN_STRING_INITIALIZER
15119 (struct cmd_ptype_mapping_get_result,
15120 mapping, "mapping");
15121 cmdline_parse_token_string_t cmd_ptype_mapping_get_get =
15122 TOKEN_STRING_INITIALIZER
15123 (struct cmd_ptype_mapping_get_result,
15125 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id =
15126 TOKEN_NUM_INITIALIZER
15127 (struct cmd_ptype_mapping_get_result,
15129 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only =
15130 TOKEN_NUM_INITIALIZER
15131 (struct cmd_ptype_mapping_get_result,
15132 valid_only, UINT8);
15135 cmd_ptype_mapping_get_parsed(
15136 void *parsed_result,
15137 __attribute__((unused)) struct cmdline *cl,
15138 __attribute__((unused)) void *data)
15140 struct cmd_ptype_mapping_get_result *res = parsed_result;
15141 int ret = -ENOTSUP;
15142 #ifdef RTE_LIBRTE_I40E_PMD
15143 int max_ptype_num = 256;
15144 struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num];
15149 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15152 #ifdef RTE_LIBRTE_I40E_PMD
15153 ret = rte_pmd_i40e_ptype_mapping_get(res->port_id,
15164 printf("invalid port_id %d\n", res->port_id);
15167 printf("function not implemented\n");
15170 printf("programming error: (%s)\n", strerror(-ret));
15173 #ifdef RTE_LIBRTE_I40E_PMD
15175 for (i = 0; i < count; i++)
15176 printf("%3d\t0x%08x\n",
15177 mapping[i].hw_ptype, mapping[i].sw_ptype);
15182 cmdline_parse_inst_t cmd_ptype_mapping_get = {
15183 .f = cmd_ptype_mapping_get_parsed,
15185 .help_str = "ptype mapping get <port_id> <valid_only>",
15187 (void *)&cmd_ptype_mapping_get_ptype,
15188 (void *)&cmd_ptype_mapping_get_mapping,
15189 (void *)&cmd_ptype_mapping_get_get,
15190 (void *)&cmd_ptype_mapping_get_port_id,
15191 (void *)&cmd_ptype_mapping_get_valid_only,
15196 /* ptype mapping replace */
15198 /* Common result structure for ptype mapping replace */
15199 struct cmd_ptype_mapping_replace_result {
15200 cmdline_fixed_string_t ptype;
15201 cmdline_fixed_string_t mapping;
15202 cmdline_fixed_string_t replace;
15209 /* Common CLI fields for ptype mapping replace */
15210 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype =
15211 TOKEN_STRING_INITIALIZER
15212 (struct cmd_ptype_mapping_replace_result,
15214 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping =
15215 TOKEN_STRING_INITIALIZER
15216 (struct cmd_ptype_mapping_replace_result,
15217 mapping, "mapping");
15218 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace =
15219 TOKEN_STRING_INITIALIZER
15220 (struct cmd_ptype_mapping_replace_result,
15221 replace, "replace");
15222 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id =
15223 TOKEN_NUM_INITIALIZER
15224 (struct cmd_ptype_mapping_replace_result,
15226 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target =
15227 TOKEN_NUM_INITIALIZER
15228 (struct cmd_ptype_mapping_replace_result,
15230 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask =
15231 TOKEN_NUM_INITIALIZER
15232 (struct cmd_ptype_mapping_replace_result,
15234 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type =
15235 TOKEN_NUM_INITIALIZER
15236 (struct cmd_ptype_mapping_replace_result,
15240 cmd_ptype_mapping_replace_parsed(
15241 void *parsed_result,
15242 __attribute__((unused)) struct cmdline *cl,
15243 __attribute__((unused)) void *data)
15245 struct cmd_ptype_mapping_replace_result *res = parsed_result;
15246 int ret = -ENOTSUP;
15248 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15251 #ifdef RTE_LIBRTE_I40E_PMD
15252 ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id,
15262 printf("invalid ptype 0x%8x or 0x%8x\n",
15263 res->target, res->pkt_type);
15266 printf("invalid port_id %d\n", res->port_id);
15269 printf("function not implemented\n");
15272 printf("programming error: (%s)\n", strerror(-ret));
15276 cmdline_parse_inst_t cmd_ptype_mapping_replace = {
15277 .f = cmd_ptype_mapping_replace_parsed,
15280 "ptype mapping replace <port_id> <target> <mask> <pkt_type>",
15282 (void *)&cmd_ptype_mapping_replace_ptype,
15283 (void *)&cmd_ptype_mapping_replace_mapping,
15284 (void *)&cmd_ptype_mapping_replace_replace,
15285 (void *)&cmd_ptype_mapping_replace_port_id,
15286 (void *)&cmd_ptype_mapping_replace_target,
15287 (void *)&cmd_ptype_mapping_replace_mask,
15288 (void *)&cmd_ptype_mapping_replace_pkt_type,
15293 /* ptype mapping reset */
15295 /* Common result structure for ptype mapping reset */
15296 struct cmd_ptype_mapping_reset_result {
15297 cmdline_fixed_string_t ptype;
15298 cmdline_fixed_string_t mapping;
15299 cmdline_fixed_string_t reset;
15303 /* Common CLI fields for ptype mapping reset*/
15304 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype =
15305 TOKEN_STRING_INITIALIZER
15306 (struct cmd_ptype_mapping_reset_result,
15308 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping =
15309 TOKEN_STRING_INITIALIZER
15310 (struct cmd_ptype_mapping_reset_result,
15311 mapping, "mapping");
15312 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset =
15313 TOKEN_STRING_INITIALIZER
15314 (struct cmd_ptype_mapping_reset_result,
15316 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id =
15317 TOKEN_NUM_INITIALIZER
15318 (struct cmd_ptype_mapping_reset_result,
15322 cmd_ptype_mapping_reset_parsed(
15323 void *parsed_result,
15324 __attribute__((unused)) struct cmdline *cl,
15325 __attribute__((unused)) void *data)
15327 struct cmd_ptype_mapping_reset_result *res = parsed_result;
15328 int ret = -ENOTSUP;
15330 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15333 #ifdef RTE_LIBRTE_I40E_PMD
15334 ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id);
15341 printf("invalid port_id %d\n", res->port_id);
15344 printf("function not implemented\n");
15347 printf("programming error: (%s)\n", strerror(-ret));
15351 cmdline_parse_inst_t cmd_ptype_mapping_reset = {
15352 .f = cmd_ptype_mapping_reset_parsed,
15354 .help_str = "ptype mapping reset <port_id>",
15356 (void *)&cmd_ptype_mapping_reset_ptype,
15357 (void *)&cmd_ptype_mapping_reset_mapping,
15358 (void *)&cmd_ptype_mapping_reset_reset,
15359 (void *)&cmd_ptype_mapping_reset_port_id,
15364 /* ptype mapping update */
15366 /* Common result structure for ptype mapping update */
15367 struct cmd_ptype_mapping_update_result {
15368 cmdline_fixed_string_t ptype;
15369 cmdline_fixed_string_t mapping;
15370 cmdline_fixed_string_t reset;
15376 /* Common CLI fields for ptype mapping update*/
15377 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype =
15378 TOKEN_STRING_INITIALIZER
15379 (struct cmd_ptype_mapping_update_result,
15381 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping =
15382 TOKEN_STRING_INITIALIZER
15383 (struct cmd_ptype_mapping_update_result,
15384 mapping, "mapping");
15385 cmdline_parse_token_string_t cmd_ptype_mapping_update_update =
15386 TOKEN_STRING_INITIALIZER
15387 (struct cmd_ptype_mapping_update_result,
15389 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id =
15390 TOKEN_NUM_INITIALIZER
15391 (struct cmd_ptype_mapping_update_result,
15393 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype =
15394 TOKEN_NUM_INITIALIZER
15395 (struct cmd_ptype_mapping_update_result,
15397 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype =
15398 TOKEN_NUM_INITIALIZER
15399 (struct cmd_ptype_mapping_update_result,
15403 cmd_ptype_mapping_update_parsed(
15404 void *parsed_result,
15405 __attribute__((unused)) struct cmdline *cl,
15406 __attribute__((unused)) void *data)
15408 struct cmd_ptype_mapping_update_result *res = parsed_result;
15409 int ret = -ENOTSUP;
15410 #ifdef RTE_LIBRTE_I40E_PMD
15411 struct rte_pmd_i40e_ptype_mapping mapping;
15413 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15416 #ifdef RTE_LIBRTE_I40E_PMD
15417 mapping.hw_ptype = res->hw_ptype;
15418 mapping.sw_ptype = res->sw_ptype;
15419 ret = rte_pmd_i40e_ptype_mapping_update(res->port_id,
15429 printf("invalid ptype 0x%8x\n", res->sw_ptype);
15432 printf("invalid port_id %d\n", res->port_id);
15435 printf("function not implemented\n");
15438 printf("programming error: (%s)\n", strerror(-ret));
15442 cmdline_parse_inst_t cmd_ptype_mapping_update = {
15443 .f = cmd_ptype_mapping_update_parsed,
15445 .help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>",
15447 (void *)&cmd_ptype_mapping_update_ptype,
15448 (void *)&cmd_ptype_mapping_update_mapping,
15449 (void *)&cmd_ptype_mapping_update_update,
15450 (void *)&cmd_ptype_mapping_update_port_id,
15451 (void *)&cmd_ptype_mapping_update_hw_ptype,
15452 (void *)&cmd_ptype_mapping_update_sw_ptype,
15457 /* Common result structure for file commands */
15458 struct cmd_cmdfile_result {
15459 cmdline_fixed_string_t load;
15460 cmdline_fixed_string_t filename;
15463 /* Common CLI fields for file commands */
15464 cmdline_parse_token_string_t cmd_load_cmdfile =
15465 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
15466 cmdline_parse_token_string_t cmd_load_cmdfile_filename =
15467 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
15470 cmd_load_from_file_parsed(
15471 void *parsed_result,
15472 __attribute__((unused)) struct cmdline *cl,
15473 __attribute__((unused)) void *data)
15475 struct cmd_cmdfile_result *res = parsed_result;
15477 cmdline_read_from_file(res->filename);
15480 cmdline_parse_inst_t cmd_load_from_file = {
15481 .f = cmd_load_from_file_parsed,
15483 .help_str = "load <filename>",
15485 (void *)&cmd_load_cmdfile,
15486 (void *)&cmd_load_cmdfile_filename,
15491 /* ******************************************************************************** */
15493 /* list of instructions */
15494 cmdline_parse_ctx_t main_ctx[] = {
15495 (cmdline_parse_inst_t *)&cmd_help_brief,
15496 (cmdline_parse_inst_t *)&cmd_help_long,
15497 (cmdline_parse_inst_t *)&cmd_quit,
15498 (cmdline_parse_inst_t *)&cmd_load_from_file,
15499 (cmdline_parse_inst_t *)&cmd_showport,
15500 (cmdline_parse_inst_t *)&cmd_showqueue,
15501 (cmdline_parse_inst_t *)&cmd_showportall,
15502 (cmdline_parse_inst_t *)&cmd_showcfg,
15503 (cmdline_parse_inst_t *)&cmd_start,
15504 (cmdline_parse_inst_t *)&cmd_start_tx_first,
15505 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
15506 (cmdline_parse_inst_t *)&cmd_set_link_up,
15507 (cmdline_parse_inst_t *)&cmd_set_link_down,
15508 (cmdline_parse_inst_t *)&cmd_reset,
15509 (cmdline_parse_inst_t *)&cmd_set_numbers,
15510 (cmdline_parse_inst_t *)&cmd_set_txpkts,
15511 (cmdline_parse_inst_t *)&cmd_set_txsplit,
15512 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
15513 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
15514 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
15515 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
15516 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
15517 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
15518 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
15519 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
15520 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
15521 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
15522 (cmdline_parse_inst_t *)&cmd_set_link_check,
15523 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
15524 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
15525 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
15526 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
15527 #ifdef RTE_LIBRTE_PMD_BOND
15528 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
15529 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
15530 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
15531 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
15532 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
15533 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
15534 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
15535 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
15536 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
15537 (cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues,
15538 (cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy,
15540 (cmdline_parse_inst_t *)&cmd_vlan_offload,
15541 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
15542 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
15543 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
15544 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
15545 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
15546 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
15547 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
15548 (cmdline_parse_inst_t *)&cmd_csum_set,
15549 (cmdline_parse_inst_t *)&cmd_csum_show,
15550 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
15551 (cmdline_parse_inst_t *)&cmd_tso_set,
15552 (cmdline_parse_inst_t *)&cmd_tso_show,
15553 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
15554 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
15555 (cmdline_parse_inst_t *)&cmd_gro_enable,
15556 (cmdline_parse_inst_t *)&cmd_gro_flush,
15557 (cmdline_parse_inst_t *)&cmd_gro_show,
15558 (cmdline_parse_inst_t *)&cmd_gso_enable,
15559 (cmdline_parse_inst_t *)&cmd_gso_size,
15560 (cmdline_parse_inst_t *)&cmd_gso_show,
15561 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
15562 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
15563 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
15564 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
15565 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
15566 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
15567 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
15568 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
15569 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
15570 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
15571 (cmdline_parse_inst_t *)&cmd_config_dcb,
15572 (cmdline_parse_inst_t *)&cmd_read_reg,
15573 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
15574 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
15575 (cmdline_parse_inst_t *)&cmd_write_reg,
15576 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
15577 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
15578 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
15579 (cmdline_parse_inst_t *)&cmd_stop,
15580 (cmdline_parse_inst_t *)&cmd_mac_addr,
15581 (cmdline_parse_inst_t *)&cmd_set_qmap,
15582 (cmdline_parse_inst_t *)&cmd_operate_port,
15583 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
15584 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
15585 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
15586 (cmdline_parse_inst_t *)&cmd_config_speed_all,
15587 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
15588 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
15589 (cmdline_parse_inst_t *)&cmd_config_mtu,
15590 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
15591 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
15592 (cmdline_parse_inst_t *)&cmd_config_rss,
15593 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
15594 (cmdline_parse_inst_t *)&cmd_config_txqflags,
15595 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
15596 (cmdline_parse_inst_t *)&cmd_showport_reta,
15597 (cmdline_parse_inst_t *)&cmd_config_burst,
15598 (cmdline_parse_inst_t *)&cmd_config_thresh,
15599 (cmdline_parse_inst_t *)&cmd_config_threshold,
15600 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
15601 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
15602 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
15603 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
15604 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
15605 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
15606 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
15607 (cmdline_parse_inst_t *)&cmd_global_config,
15608 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
15609 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
15610 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
15611 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
15612 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
15613 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
15614 (cmdline_parse_inst_t *)&cmd_dump,
15615 (cmdline_parse_inst_t *)&cmd_dump_one,
15616 (cmdline_parse_inst_t *)&cmd_ethertype_filter,
15617 (cmdline_parse_inst_t *)&cmd_syn_filter,
15618 (cmdline_parse_inst_t *)&cmd_2tuple_filter,
15619 (cmdline_parse_inst_t *)&cmd_5tuple_filter,
15620 (cmdline_parse_inst_t *)&cmd_flex_filter,
15621 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
15622 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
15623 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
15624 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director,
15625 (cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director,
15626 (cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director,
15627 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
15628 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
15629 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
15630 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
15631 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
15632 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
15633 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
15634 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
15635 (cmdline_parse_inst_t *)&cmd_get_hash_global_config,
15636 (cmdline_parse_inst_t *)&cmd_set_hash_global_config,
15637 (cmdline_parse_inst_t *)&cmd_set_hash_input_set,
15638 (cmdline_parse_inst_t *)&cmd_set_fdir_input_set,
15639 (cmdline_parse_inst_t *)&cmd_flow,
15640 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm,
15641 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm,
15642 (cmdline_parse_inst_t *)&cmd_del_port_meter_profile,
15643 (cmdline_parse_inst_t *)&cmd_set_port_meter,
15644 (cmdline_parse_inst_t *)&cmd_del_port_meter,
15645 (cmdline_parse_inst_t *)&cmd_set_port_meter_profile,
15646 (cmdline_parse_inst_t *)&cmd_set_port_meter_policer_action,
15647 (cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask,
15648 (cmdline_parse_inst_t *)&cmd_show_port_meter_stats,
15649 (cmdline_parse_inst_t *)&cmd_mcast_addr,
15650 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all,
15651 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific,
15652 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all,
15653 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific,
15654 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_en,
15655 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_dis,
15656 (cmdline_parse_inst_t *)&cmd_config_e_tag_stripping_en_dis,
15657 (cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis,
15658 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_add,
15659 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_del,
15660 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
15661 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
15662 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
15663 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
15664 (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
15665 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
15666 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
15667 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
15668 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
15669 (cmdline_parse_inst_t *)&cmd_set_macsec_sc,
15670 (cmdline_parse_inst_t *)&cmd_set_macsec_sa,
15671 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
15672 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
15673 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
15674 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
15675 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
15676 (cmdline_parse_inst_t *)&cmd_set_vf_promisc,
15677 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
15678 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
15679 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
15680 (cmdline_parse_inst_t *)&cmd_vf_max_bw,
15681 (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
15682 (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
15683 (cmdline_parse_inst_t *)&cmd_strict_link_prio,
15684 (cmdline_parse_inst_t *)&cmd_tc_min_bw,
15685 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
15686 (cmdline_parse_inst_t *)&cmd_set_port_tm_hierarchy_default,
15688 (cmdline_parse_inst_t *)&cmd_ddp_add,
15689 (cmdline_parse_inst_t *)&cmd_ddp_del,
15690 (cmdline_parse_inst_t *)&cmd_ddp_get_list,
15691 (cmdline_parse_inst_t *)&cmd_ddp_get_info,
15692 (cmdline_parse_inst_t *)&cmd_show_vf_stats,
15693 (cmdline_parse_inst_t *)&cmd_clear_vf_stats,
15694 (cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
15695 (cmdline_parse_inst_t *)&cmd_ptype_mapping_replace,
15696 (cmdline_parse_inst_t *)&cmd_ptype_mapping_reset,
15697 (cmdline_parse_inst_t *)&cmd_ptype_mapping_update,
15699 (cmdline_parse_inst_t *)&cmd_pctype_mapping_get,
15700 (cmdline_parse_inst_t *)&cmd_pctype_mapping_reset,
15701 (cmdline_parse_inst_t *)&cmd_pctype_mapping_update,
15702 (cmdline_parse_inst_t *)&cmd_queue_region,
15703 (cmdline_parse_inst_t *)&cmd_region_flowtype,
15704 (cmdline_parse_inst_t *)&cmd_user_priority_region,
15705 (cmdline_parse_inst_t *)&cmd_flush_queue_region,
15706 (cmdline_parse_inst_t *)&cmd_show_queue_region_info_all,
15707 (cmdline_parse_inst_t *)&cmd_show_port_tm_cap,
15708 (cmdline_parse_inst_t *)&cmd_show_port_tm_level_cap,
15709 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_cap,
15710 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_type,
15711 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_stats,
15712 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shaper_profile,
15713 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shaper_profile,
15714 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shared_shaper,
15715 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shared_shaper,
15716 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_wred_profile,
15717 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_wred_profile,
15718 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_shaper_profile,
15719 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node,
15720 (cmdline_parse_inst_t *)&cmd_add_port_tm_leaf_node,
15721 (cmdline_parse_inst_t *)&cmd_del_port_tm_node,
15722 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_parent,
15723 (cmdline_parse_inst_t *)&cmd_port_tm_hierarchy_commit,
15727 /* read cmdline commands from file */
15729 cmdline_read_from_file(const char *filename)
15731 struct cmdline *cl;
15733 cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
15735 printf("Failed to create file based cmdline context: %s\n",
15740 cmdline_interact(cl);
15745 printf("Read CLI commands from %s\n", filename);
15748 /* prompt function, called from main on MASTER lcore */
15752 /* initialize non-constant commands */
15753 cmd_set_fwd_mode_init();
15754 cmd_set_fwd_retry_mode_init();
15756 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
15757 if (testpmd_cl == NULL)
15759 cmdline_interact(testpmd_cl);
15760 cmdline_stdin_exit(testpmd_cl);
15766 if (testpmd_cl != NULL)
15767 cmdline_quit(testpmd_cl);
15771 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
15773 if (id == (portid_t)RTE_PORT_ALL) {
15776 RTE_ETH_FOREACH_DEV(pid) {
15777 /* check if need_reconfig has been set to 1 */
15778 if (ports[pid].need_reconfig == 0)
15779 ports[pid].need_reconfig = dev;
15780 /* check if need_reconfig_queues has been set to 1 */
15781 if (ports[pid].need_reconfig_queues == 0)
15782 ports[pid].need_reconfig_queues = queue;
15784 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
15785 /* check if need_reconfig has been set to 1 */
15786 if (ports[id].need_reconfig == 0)
15787 ports[id].need_reconfig = dev;
15788 /* check if need_reconfig_queues has been set to 1 */
15789 if (ports[id].need_reconfig_queues == 0)
15790 ports[id].need_reconfig_queues = queue;