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;
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 #ifdef RTE_LIBRTE_IXGBE_PMD
7498 if (ret == -ENOTSUP)
7499 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id,
7500 rx_mode, (uint8_t)is_on);
7502 #ifdef RTE_LIBRTE_BNXT_PMD
7503 if (ret == -ENOTSUP)
7504 ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id,
7505 rx_mode, (uint8_t)is_on);
7508 printf("bad VF receive mode parameter, return code = %d \n",
7512 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
7513 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7515 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
7516 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7518 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
7519 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
7521 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
7522 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7524 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
7525 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
7527 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
7528 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7530 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
7531 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7532 mode, "AUPE#ROPE#BAM#MPE");
7533 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
7534 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7537 cmdline_parse_inst_t cmd_set_vf_rxmode = {
7538 .f = cmd_set_vf_rxmode_parsed,
7540 .help_str = "set port <port_id> vf <vf_id> rxmode "
7541 "AUPE|ROPE|BAM|MPE on|off",
7543 (void *)&cmd_set_vf_rxmode_set,
7544 (void *)&cmd_set_vf_rxmode_port,
7545 (void *)&cmd_set_vf_rxmode_portid,
7546 (void *)&cmd_set_vf_rxmode_vf,
7547 (void *)&cmd_set_vf_rxmode_vfid,
7548 (void *)&cmd_set_vf_rxmode_what,
7549 (void *)&cmd_set_vf_rxmode_mode,
7550 (void *)&cmd_set_vf_rxmode_on,
7555 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
7556 struct cmd_vf_mac_addr_result {
7557 cmdline_fixed_string_t mac_addr_cmd;
7558 cmdline_fixed_string_t what;
7559 cmdline_fixed_string_t port;
7561 cmdline_fixed_string_t vf;
7563 struct ether_addr address;
7566 static void cmd_vf_mac_addr_parsed(void *parsed_result,
7567 __attribute__((unused)) struct cmdline *cl,
7568 __attribute__((unused)) void *data)
7570 struct cmd_vf_mac_addr_result *res = parsed_result;
7573 if (strcmp(res->what, "add") != 0)
7576 #ifdef RTE_LIBRTE_I40E_PMD
7577 if (ret == -ENOTSUP)
7578 ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num,
7581 #ifdef RTE_LIBRTE_BNXT_PMD
7582 if (ret == -ENOTSUP)
7583 ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address,
7588 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
7592 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
7593 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7594 mac_addr_cmd,"mac_addr");
7595 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
7596 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7598 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
7599 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7601 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
7602 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
7604 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
7605 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7607 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
7608 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
7610 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
7611 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
7614 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
7615 .f = cmd_vf_mac_addr_parsed,
7617 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
7618 "Add MAC address filtering for a VF on port_id",
7620 (void *)&cmd_vf_mac_addr_cmd,
7621 (void *)&cmd_vf_mac_addr_what,
7622 (void *)&cmd_vf_mac_addr_port,
7623 (void *)&cmd_vf_mac_addr_portnum,
7624 (void *)&cmd_vf_mac_addr_vf,
7625 (void *)&cmd_vf_mac_addr_vfnum,
7626 (void *)&cmd_vf_mac_addr_addr,
7631 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
7632 struct cmd_vf_rx_vlan_filter {
7633 cmdline_fixed_string_t rx_vlan;
7634 cmdline_fixed_string_t what;
7636 cmdline_fixed_string_t port;
7638 cmdline_fixed_string_t vf;
7643 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
7644 __attribute__((unused)) struct cmdline *cl,
7645 __attribute__((unused)) void *data)
7647 struct cmd_vf_rx_vlan_filter *res = parsed_result;
7650 __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
7652 #ifdef RTE_LIBRTE_IXGBE_PMD
7653 if (ret == -ENOTSUP)
7654 ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
7655 res->vlan_id, res->vf_mask, is_add);
7657 #ifdef RTE_LIBRTE_I40E_PMD
7658 if (ret == -ENOTSUP)
7659 ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
7660 res->vlan_id, res->vf_mask, is_add);
7662 #ifdef RTE_LIBRTE_BNXT_PMD
7663 if (ret == -ENOTSUP)
7664 ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id,
7665 res->vlan_id, res->vf_mask, is_add);
7672 printf("invalid vlan_id %d or vf_mask %"PRIu64"\n",
7673 res->vlan_id, res->vf_mask);
7676 printf("invalid port_id %d\n", res->port_id);
7679 printf("function not implemented or supported\n");
7682 printf("programming error: (%s)\n", strerror(-ret));
7686 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
7687 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7688 rx_vlan, "rx_vlan");
7689 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
7690 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7692 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
7693 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7695 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
7696 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7698 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
7699 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7701 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
7702 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7704 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
7705 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7708 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
7709 .f = cmd_vf_rx_vlan_filter_parsed,
7711 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
7712 "(vf_mask = hexadecimal VF mask)",
7714 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
7715 (void *)&cmd_vf_rx_vlan_filter_what,
7716 (void *)&cmd_vf_rx_vlan_filter_vlanid,
7717 (void *)&cmd_vf_rx_vlan_filter_port,
7718 (void *)&cmd_vf_rx_vlan_filter_portid,
7719 (void *)&cmd_vf_rx_vlan_filter_vf,
7720 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
7725 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
7726 struct cmd_queue_rate_limit_result {
7727 cmdline_fixed_string_t set;
7728 cmdline_fixed_string_t port;
7730 cmdline_fixed_string_t queue;
7732 cmdline_fixed_string_t rate;
7736 static void cmd_queue_rate_limit_parsed(void *parsed_result,
7737 __attribute__((unused)) struct cmdline *cl,
7738 __attribute__((unused)) void *data)
7740 struct cmd_queue_rate_limit_result *res = parsed_result;
7743 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
7744 && (strcmp(res->queue, "queue") == 0)
7745 && (strcmp(res->rate, "rate") == 0))
7746 ret = set_queue_rate_limit(res->port_num, res->queue_num,
7749 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
7753 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
7754 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7756 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
7757 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7759 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
7760 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
7762 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
7763 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7765 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
7766 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
7768 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
7769 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7771 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
7772 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
7775 cmdline_parse_inst_t cmd_queue_rate_limit = {
7776 .f = cmd_queue_rate_limit_parsed,
7778 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
7779 "Set rate limit for a queue on port_id",
7781 (void *)&cmd_queue_rate_limit_set,
7782 (void *)&cmd_queue_rate_limit_port,
7783 (void *)&cmd_queue_rate_limit_portnum,
7784 (void *)&cmd_queue_rate_limit_queue,
7785 (void *)&cmd_queue_rate_limit_queuenum,
7786 (void *)&cmd_queue_rate_limit_rate,
7787 (void *)&cmd_queue_rate_limit_ratenum,
7792 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
7793 struct cmd_vf_rate_limit_result {
7794 cmdline_fixed_string_t set;
7795 cmdline_fixed_string_t port;
7797 cmdline_fixed_string_t vf;
7799 cmdline_fixed_string_t rate;
7801 cmdline_fixed_string_t q_msk;
7805 static void cmd_vf_rate_limit_parsed(void *parsed_result,
7806 __attribute__((unused)) struct cmdline *cl,
7807 __attribute__((unused)) void *data)
7809 struct cmd_vf_rate_limit_result *res = parsed_result;
7812 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
7813 && (strcmp(res->vf, "vf") == 0)
7814 && (strcmp(res->rate, "rate") == 0)
7815 && (strcmp(res->q_msk, "queue_mask") == 0))
7816 ret = set_vf_rate_limit(res->port_num, res->vf_num,
7817 res->rate_num, res->q_msk_val);
7819 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
7823 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
7824 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7826 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
7827 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7829 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
7830 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7832 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
7833 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7835 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
7836 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7838 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
7839 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7841 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
7842 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7844 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
7845 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7846 q_msk, "queue_mask");
7847 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
7848 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7851 cmdline_parse_inst_t cmd_vf_rate_limit = {
7852 .f = cmd_vf_rate_limit_parsed,
7854 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
7855 "queue_mask <queue_mask_value>: "
7856 "Set rate limit for queues of VF on port_id",
7858 (void *)&cmd_vf_rate_limit_set,
7859 (void *)&cmd_vf_rate_limit_port,
7860 (void *)&cmd_vf_rate_limit_portnum,
7861 (void *)&cmd_vf_rate_limit_vf,
7862 (void *)&cmd_vf_rate_limit_vfnum,
7863 (void *)&cmd_vf_rate_limit_rate,
7864 (void *)&cmd_vf_rate_limit_ratenum,
7865 (void *)&cmd_vf_rate_limit_q_msk,
7866 (void *)&cmd_vf_rate_limit_q_msk_val,
7871 /* *** ADD TUNNEL FILTER OF A PORT *** */
7872 struct cmd_tunnel_filter_result {
7873 cmdline_fixed_string_t cmd;
7874 cmdline_fixed_string_t what;
7876 struct ether_addr outer_mac;
7877 struct ether_addr inner_mac;
7878 cmdline_ipaddr_t ip_value;
7879 uint16_t inner_vlan;
7880 cmdline_fixed_string_t tunnel_type;
7881 cmdline_fixed_string_t filter_type;
7887 cmd_tunnel_filter_parsed(void *parsed_result,
7888 __attribute__((unused)) struct cmdline *cl,
7889 __attribute__((unused)) void *data)
7891 struct cmd_tunnel_filter_result *res = parsed_result;
7892 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
7895 memset(&tunnel_filter_conf, 0, sizeof(tunnel_filter_conf));
7897 ether_addr_copy(&res->outer_mac, &tunnel_filter_conf.outer_mac);
7898 ether_addr_copy(&res->inner_mac, &tunnel_filter_conf.inner_mac);
7899 tunnel_filter_conf.inner_vlan = res->inner_vlan;
7901 if (res->ip_value.family == AF_INET) {
7902 tunnel_filter_conf.ip_addr.ipv4_addr =
7903 res->ip_value.addr.ipv4.s_addr;
7904 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
7906 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
7907 &(res->ip_value.addr.ipv6),
7908 sizeof(struct in6_addr));
7909 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
7912 if (!strcmp(res->filter_type, "imac-ivlan"))
7913 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
7914 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
7915 tunnel_filter_conf.filter_type =
7916 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
7917 else if (!strcmp(res->filter_type, "imac-tenid"))
7918 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
7919 else if (!strcmp(res->filter_type, "imac"))
7920 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
7921 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
7922 tunnel_filter_conf.filter_type =
7923 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
7924 else if (!strcmp(res->filter_type, "oip"))
7925 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_OIP;
7926 else if (!strcmp(res->filter_type, "iip"))
7927 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IIP;
7929 printf("The filter type is not supported");
7933 if (!strcmp(res->tunnel_type, "vxlan"))
7934 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
7935 else if (!strcmp(res->tunnel_type, "nvgre"))
7936 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE;
7937 else if (!strcmp(res->tunnel_type, "ipingre"))
7938 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_IP_IN_GRE;
7940 printf("The tunnel type %s not supported.\n", res->tunnel_type);
7944 tunnel_filter_conf.tenant_id = res->tenant_id;
7945 tunnel_filter_conf.queue_id = res->queue_num;
7946 if (!strcmp(res->what, "add"))
7947 ret = rte_eth_dev_filter_ctrl(res->port_id,
7948 RTE_ETH_FILTER_TUNNEL,
7950 &tunnel_filter_conf);
7952 ret = rte_eth_dev_filter_ctrl(res->port_id,
7953 RTE_ETH_FILTER_TUNNEL,
7954 RTE_ETH_FILTER_DELETE,
7955 &tunnel_filter_conf);
7957 printf("cmd_tunnel_filter_parsed error: (%s)\n",
7961 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
7962 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7963 cmd, "tunnel_filter");
7964 cmdline_parse_token_string_t cmd_tunnel_filter_what =
7965 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7967 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
7968 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7970 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
7971 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
7973 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
7974 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
7976 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
7977 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7978 inner_vlan, UINT16);
7979 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
7980 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
7982 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
7983 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7984 tunnel_type, "vxlan#nvgre#ipingre");
7986 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
7987 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7988 filter_type, "oip#iip#imac-ivlan#imac-ivlan-tenid#imac-tenid#"
7989 "imac#omac-imac-tenid");
7990 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
7991 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7993 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
7994 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7997 cmdline_parse_inst_t cmd_tunnel_filter = {
7998 .f = cmd_tunnel_filter_parsed,
8000 .help_str = "tunnel_filter add|rm <port_id> <outer_mac> <inner_mac> "
8001 "<ip> <inner_vlan> vxlan|nvgre|ipingre oip|iip|imac-ivlan|"
8002 "imac-ivlan-tenid|imac-tenid|imac|omac-imac-tenid <tenant_id> "
8003 "<queue_id>: Add/Rm tunnel filter of a port",
8005 (void *)&cmd_tunnel_filter_cmd,
8006 (void *)&cmd_tunnel_filter_what,
8007 (void *)&cmd_tunnel_filter_port_id,
8008 (void *)&cmd_tunnel_filter_outer_mac,
8009 (void *)&cmd_tunnel_filter_inner_mac,
8010 (void *)&cmd_tunnel_filter_ip_value,
8011 (void *)&cmd_tunnel_filter_innner_vlan,
8012 (void *)&cmd_tunnel_filter_tunnel_type,
8013 (void *)&cmd_tunnel_filter_filter_type,
8014 (void *)&cmd_tunnel_filter_tenant_id,
8015 (void *)&cmd_tunnel_filter_queue_num,
8020 /* *** CONFIGURE TUNNEL UDP PORT *** */
8021 struct cmd_tunnel_udp_config {
8022 cmdline_fixed_string_t cmd;
8023 cmdline_fixed_string_t what;
8029 cmd_tunnel_udp_config_parsed(void *parsed_result,
8030 __attribute__((unused)) struct cmdline *cl,
8031 __attribute__((unused)) void *data)
8033 struct cmd_tunnel_udp_config *res = parsed_result;
8034 struct rte_eth_udp_tunnel tunnel_udp;
8037 tunnel_udp.udp_port = res->udp_port;
8039 if (!strcmp(res->cmd, "rx_vxlan_port"))
8040 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
8042 if (!strcmp(res->what, "add"))
8043 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
8046 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
8050 printf("udp tunneling add error: (%s)\n", strerror(-ret));
8053 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
8054 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
8055 cmd, "rx_vxlan_port");
8056 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
8057 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
8059 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
8060 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
8062 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
8063 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
8066 cmdline_parse_inst_t cmd_tunnel_udp_config = {
8067 .f = cmd_tunnel_udp_config_parsed,
8069 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
8070 "Add/Remove a tunneling UDP port filter",
8072 (void *)&cmd_tunnel_udp_config_cmd,
8073 (void *)&cmd_tunnel_udp_config_what,
8074 (void *)&cmd_tunnel_udp_config_udp_port,
8075 (void *)&cmd_tunnel_udp_config_port_id,
8080 /* *** GLOBAL CONFIG *** */
8081 struct cmd_global_config_result {
8082 cmdline_fixed_string_t cmd;
8084 cmdline_fixed_string_t cfg_type;
8089 cmd_global_config_parsed(void *parsed_result,
8090 __attribute__((unused)) struct cmdline *cl,
8091 __attribute__((unused)) void *data)
8093 struct cmd_global_config_result *res = parsed_result;
8094 struct rte_eth_global_cfg conf;
8097 memset(&conf, 0, sizeof(conf));
8098 conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN;
8099 conf.cfg.gre_key_len = res->len;
8100 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE,
8101 RTE_ETH_FILTER_SET, &conf);
8103 printf("Global config error\n");
8106 cmdline_parse_token_string_t cmd_global_config_cmd =
8107 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd,
8109 cmdline_parse_token_num_t cmd_global_config_port_id =
8110 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id,
8112 cmdline_parse_token_string_t cmd_global_config_type =
8113 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result,
8114 cfg_type, "gre-key-len");
8115 cmdline_parse_token_num_t cmd_global_config_gre_key_len =
8116 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result,
8119 cmdline_parse_inst_t cmd_global_config = {
8120 .f = cmd_global_config_parsed,
8121 .data = (void *)NULL,
8122 .help_str = "global_config <port_id> gre-key-len <key_len>",
8124 (void *)&cmd_global_config_cmd,
8125 (void *)&cmd_global_config_port_id,
8126 (void *)&cmd_global_config_type,
8127 (void *)&cmd_global_config_gre_key_len,
8132 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
8133 struct cmd_set_mirror_mask_result {
8134 cmdline_fixed_string_t set;
8135 cmdline_fixed_string_t port;
8137 cmdline_fixed_string_t mirror;
8139 cmdline_fixed_string_t what;
8140 cmdline_fixed_string_t value;
8141 cmdline_fixed_string_t dstpool;
8143 cmdline_fixed_string_t on;
8146 cmdline_parse_token_string_t cmd_mirror_mask_set =
8147 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8149 cmdline_parse_token_string_t cmd_mirror_mask_port =
8150 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8152 cmdline_parse_token_num_t cmd_mirror_mask_portid =
8153 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
8155 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
8156 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8157 mirror, "mirror-rule");
8158 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
8159 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
8161 cmdline_parse_token_string_t cmd_mirror_mask_what =
8162 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8163 what, "pool-mirror-up#pool-mirror-down"
8165 cmdline_parse_token_string_t cmd_mirror_mask_value =
8166 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8168 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
8169 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8170 dstpool, "dst-pool");
8171 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
8172 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
8174 cmdline_parse_token_string_t cmd_mirror_mask_on =
8175 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8179 cmd_set_mirror_mask_parsed(void *parsed_result,
8180 __attribute__((unused)) struct cmdline *cl,
8181 __attribute__((unused)) void *data)
8184 struct cmd_set_mirror_mask_result *res = parsed_result;
8185 struct rte_eth_mirror_conf mr_conf;
8187 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
8189 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
8191 mr_conf.dst_pool = res->dstpool_id;
8193 if (!strcmp(res->what, "pool-mirror-up")) {
8194 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
8195 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
8196 } else if (!strcmp(res->what, "pool-mirror-down")) {
8197 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
8198 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
8199 } else if (!strcmp(res->what, "vlan-mirror")) {
8200 mr_conf.rule_type = ETH_MIRROR_VLAN;
8201 nb_item = parse_item_list(res->value, "vlan",
8202 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
8206 for (i = 0; i < nb_item; i++) {
8207 if (vlan_list[i] > ETHER_MAX_VLAN_ID) {
8208 printf("Invalid vlan_id: must be < 4096\n");
8212 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
8213 mr_conf.vlan.vlan_mask |= 1ULL << i;
8217 if (!strcmp(res->on, "on"))
8218 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8221 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8224 printf("mirror rule add error: (%s)\n", strerror(-ret));
8227 cmdline_parse_inst_t cmd_set_mirror_mask = {
8228 .f = cmd_set_mirror_mask_parsed,
8230 .help_str = "set port <port_id> mirror-rule <rule_id> "
8231 "pool-mirror-up|pool-mirror-down|vlan-mirror "
8232 "<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off",
8234 (void *)&cmd_mirror_mask_set,
8235 (void *)&cmd_mirror_mask_port,
8236 (void *)&cmd_mirror_mask_portid,
8237 (void *)&cmd_mirror_mask_mirror,
8238 (void *)&cmd_mirror_mask_ruleid,
8239 (void *)&cmd_mirror_mask_what,
8240 (void *)&cmd_mirror_mask_value,
8241 (void *)&cmd_mirror_mask_dstpool,
8242 (void *)&cmd_mirror_mask_poolid,
8243 (void *)&cmd_mirror_mask_on,
8248 /* *** CONFIGURE VM MIRROR UPLINK/DOWNLINK RULE *** */
8249 struct cmd_set_mirror_link_result {
8250 cmdline_fixed_string_t set;
8251 cmdline_fixed_string_t port;
8253 cmdline_fixed_string_t mirror;
8255 cmdline_fixed_string_t what;
8256 cmdline_fixed_string_t dstpool;
8258 cmdline_fixed_string_t on;
8261 cmdline_parse_token_string_t cmd_mirror_link_set =
8262 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8264 cmdline_parse_token_string_t cmd_mirror_link_port =
8265 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8267 cmdline_parse_token_num_t cmd_mirror_link_portid =
8268 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
8270 cmdline_parse_token_string_t cmd_mirror_link_mirror =
8271 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8272 mirror, "mirror-rule");
8273 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
8274 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
8276 cmdline_parse_token_string_t cmd_mirror_link_what =
8277 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8278 what, "uplink-mirror#downlink-mirror");
8279 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
8280 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8281 dstpool, "dst-pool");
8282 cmdline_parse_token_num_t cmd_mirror_link_poolid =
8283 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
8285 cmdline_parse_token_string_t cmd_mirror_link_on =
8286 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8290 cmd_set_mirror_link_parsed(void *parsed_result,
8291 __attribute__((unused)) struct cmdline *cl,
8292 __attribute__((unused)) void *data)
8295 struct cmd_set_mirror_link_result *res = parsed_result;
8296 struct rte_eth_mirror_conf mr_conf;
8298 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
8299 if (!strcmp(res->what, "uplink-mirror"))
8300 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
8302 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
8304 mr_conf.dst_pool = res->dstpool_id;
8306 if (!strcmp(res->on, "on"))
8307 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8310 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8313 /* check the return value and print it if is < 0 */
8315 printf("mirror rule add error: (%s)\n", strerror(-ret));
8319 cmdline_parse_inst_t cmd_set_mirror_link = {
8320 .f = cmd_set_mirror_link_parsed,
8322 .help_str = "set port <port_id> mirror-rule <rule_id> "
8323 "uplink-mirror|downlink-mirror dst-pool <pool_id> on|off",
8325 (void *)&cmd_mirror_link_set,
8326 (void *)&cmd_mirror_link_port,
8327 (void *)&cmd_mirror_link_portid,
8328 (void *)&cmd_mirror_link_mirror,
8329 (void *)&cmd_mirror_link_ruleid,
8330 (void *)&cmd_mirror_link_what,
8331 (void *)&cmd_mirror_link_dstpool,
8332 (void *)&cmd_mirror_link_poolid,
8333 (void *)&cmd_mirror_link_on,
8338 /* *** RESET VM MIRROR RULE *** */
8339 struct cmd_rm_mirror_rule_result {
8340 cmdline_fixed_string_t reset;
8341 cmdline_fixed_string_t port;
8343 cmdline_fixed_string_t mirror;
8347 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
8348 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
8350 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
8351 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
8353 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
8354 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
8356 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
8357 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
8358 mirror, "mirror-rule");
8359 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
8360 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
8364 cmd_reset_mirror_rule_parsed(void *parsed_result,
8365 __attribute__((unused)) struct cmdline *cl,
8366 __attribute__((unused)) void *data)
8369 struct cmd_set_mirror_link_result *res = parsed_result;
8371 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
8373 printf("mirror rule remove error: (%s)\n", strerror(-ret));
8376 cmdline_parse_inst_t cmd_reset_mirror_rule = {
8377 .f = cmd_reset_mirror_rule_parsed,
8379 .help_str = "reset port <port_id> mirror-rule <rule_id>",
8381 (void *)&cmd_rm_mirror_rule_reset,
8382 (void *)&cmd_rm_mirror_rule_port,
8383 (void *)&cmd_rm_mirror_rule_portid,
8384 (void *)&cmd_rm_mirror_rule_mirror,
8385 (void *)&cmd_rm_mirror_rule_ruleid,
8390 /* ******************************************************************************** */
8392 struct cmd_dump_result {
8393 cmdline_fixed_string_t dump;
8397 dump_struct_sizes(void)
8399 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
8400 DUMP_SIZE(struct rte_mbuf);
8401 DUMP_SIZE(struct rte_mempool);
8402 DUMP_SIZE(struct rte_ring);
8406 static void cmd_dump_parsed(void *parsed_result,
8407 __attribute__((unused)) struct cmdline *cl,
8408 __attribute__((unused)) void *data)
8410 struct cmd_dump_result *res = parsed_result;
8412 if (!strcmp(res->dump, "dump_physmem"))
8413 rte_dump_physmem_layout(stdout);
8414 else if (!strcmp(res->dump, "dump_memzone"))
8415 rte_memzone_dump(stdout);
8416 else if (!strcmp(res->dump, "dump_struct_sizes"))
8417 dump_struct_sizes();
8418 else if (!strcmp(res->dump, "dump_ring"))
8419 rte_ring_list_dump(stdout);
8420 else if (!strcmp(res->dump, "dump_mempool"))
8421 rte_mempool_list_dump(stdout);
8422 else if (!strcmp(res->dump, "dump_devargs"))
8423 rte_eal_devargs_dump(stdout);
8424 else if (!strcmp(res->dump, "dump_log_types"))
8425 rte_log_dump(stdout);
8428 cmdline_parse_token_string_t cmd_dump_dump =
8429 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
8432 "dump_struct_sizes#"
8438 cmdline_parse_inst_t cmd_dump = {
8439 .f = cmd_dump_parsed, /* function to call */
8440 .data = NULL, /* 2nd arg of func */
8441 .help_str = "Dump status",
8442 .tokens = { /* token list, NULL terminated */
8443 (void *)&cmd_dump_dump,
8448 /* ******************************************************************************** */
8450 struct cmd_dump_one_result {
8451 cmdline_fixed_string_t dump;
8452 cmdline_fixed_string_t name;
8455 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
8456 __attribute__((unused)) void *data)
8458 struct cmd_dump_one_result *res = parsed_result;
8460 if (!strcmp(res->dump, "dump_ring")) {
8462 r = rte_ring_lookup(res->name);
8464 cmdline_printf(cl, "Cannot find ring\n");
8467 rte_ring_dump(stdout, r);
8468 } else if (!strcmp(res->dump, "dump_mempool")) {
8469 struct rte_mempool *mp;
8470 mp = rte_mempool_lookup(res->name);
8472 cmdline_printf(cl, "Cannot find mempool\n");
8475 rte_mempool_dump(stdout, mp);
8479 cmdline_parse_token_string_t cmd_dump_one_dump =
8480 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
8481 "dump_ring#dump_mempool");
8483 cmdline_parse_token_string_t cmd_dump_one_name =
8484 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
8486 cmdline_parse_inst_t cmd_dump_one = {
8487 .f = cmd_dump_one_parsed, /* function to call */
8488 .data = NULL, /* 2nd arg of func */
8489 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
8490 .tokens = { /* token list, NULL terminated */
8491 (void *)&cmd_dump_one_dump,
8492 (void *)&cmd_dump_one_name,
8497 /* *** Add/Del syn filter *** */
8498 struct cmd_syn_filter_result {
8499 cmdline_fixed_string_t filter;
8501 cmdline_fixed_string_t ops;
8502 cmdline_fixed_string_t priority;
8503 cmdline_fixed_string_t high;
8504 cmdline_fixed_string_t queue;
8509 cmd_syn_filter_parsed(void *parsed_result,
8510 __attribute__((unused)) struct cmdline *cl,
8511 __attribute__((unused)) void *data)
8513 struct cmd_syn_filter_result *res = parsed_result;
8514 struct rte_eth_syn_filter syn_filter;
8517 ret = rte_eth_dev_filter_supported(res->port_id,
8518 RTE_ETH_FILTER_SYN);
8520 printf("syn filter is not supported on port %u.\n",
8525 memset(&syn_filter, 0, sizeof(syn_filter));
8527 if (!strcmp(res->ops, "add")) {
8528 if (!strcmp(res->high, "high"))
8529 syn_filter.hig_pri = 1;
8531 syn_filter.hig_pri = 0;
8533 syn_filter.queue = res->queue_id;
8534 ret = rte_eth_dev_filter_ctrl(res->port_id,
8539 ret = rte_eth_dev_filter_ctrl(res->port_id,
8541 RTE_ETH_FILTER_DELETE,
8545 printf("syn filter programming error: (%s)\n",
8549 cmdline_parse_token_string_t cmd_syn_filter_filter =
8550 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8551 filter, "syn_filter");
8552 cmdline_parse_token_num_t cmd_syn_filter_port_id =
8553 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
8555 cmdline_parse_token_string_t cmd_syn_filter_ops =
8556 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8558 cmdline_parse_token_string_t cmd_syn_filter_priority =
8559 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8560 priority, "priority");
8561 cmdline_parse_token_string_t cmd_syn_filter_high =
8562 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8564 cmdline_parse_token_string_t cmd_syn_filter_queue =
8565 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8567 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
8568 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
8571 cmdline_parse_inst_t cmd_syn_filter = {
8572 .f = cmd_syn_filter_parsed,
8574 .help_str = "syn_filter <port_id> add|del priority high|low queue "
8575 "<queue_id>: Add/Delete syn filter",
8577 (void *)&cmd_syn_filter_filter,
8578 (void *)&cmd_syn_filter_port_id,
8579 (void *)&cmd_syn_filter_ops,
8580 (void *)&cmd_syn_filter_priority,
8581 (void *)&cmd_syn_filter_high,
8582 (void *)&cmd_syn_filter_queue,
8583 (void *)&cmd_syn_filter_queue_id,
8588 /* *** queue region set *** */
8589 struct cmd_queue_region_result {
8590 cmdline_fixed_string_t set;
8591 cmdline_fixed_string_t port;
8593 cmdline_fixed_string_t cmd;
8594 cmdline_fixed_string_t region;
8596 cmdline_fixed_string_t queue_start_index;
8598 cmdline_fixed_string_t queue_num;
8599 uint8_t queue_num_value;
8603 cmd_queue_region_parsed(void *parsed_result,
8604 __attribute__((unused)) struct cmdline *cl,
8605 __attribute__((unused)) void *data)
8607 struct cmd_queue_region_result *res = parsed_result;
8609 #ifdef RTE_LIBRTE_I40E_PMD
8610 struct rte_pmd_i40e_queue_region_conf region_conf;
8611 enum rte_pmd_i40e_queue_region_op op_type;
8614 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
8617 #ifdef RTE_LIBRTE_I40E_PMD
8618 memset(®ion_conf, 0, sizeof(region_conf));
8619 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_SET;
8620 region_conf.region_id = res->region_id;
8621 region_conf.queue_num = res->queue_num_value;
8622 region_conf.queue_start_index = res->queue_id;
8624 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
8625 op_type, ®ion_conf);
8632 printf("function not implemented or supported\n");
8635 printf("queue region config error: (%s)\n", strerror(-ret));
8639 cmdline_parse_token_string_t cmd_queue_region_set =
8640 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
8642 cmdline_parse_token_string_t cmd_queue_region_port =
8643 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, port, "port");
8644 cmdline_parse_token_num_t cmd_queue_region_port_id =
8645 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
8647 cmdline_parse_token_string_t cmd_queue_region_cmd =
8648 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
8649 cmd, "queue-region");
8650 cmdline_parse_token_string_t cmd_queue_region_id =
8651 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
8652 region, "region_id");
8653 cmdline_parse_token_num_t cmd_queue_region_index =
8654 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
8656 cmdline_parse_token_string_t cmd_queue_region_queue_start_index =
8657 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
8658 queue_start_index, "queue_start_index");
8659 cmdline_parse_token_num_t cmd_queue_region_queue_id =
8660 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
8662 cmdline_parse_token_string_t cmd_queue_region_queue_num =
8663 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
8664 queue_num, "queue_num");
8665 cmdline_parse_token_num_t cmd_queue_region_queue_num_value =
8666 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
8667 queue_num_value, UINT8);
8669 cmdline_parse_inst_t cmd_queue_region = {
8670 .f = cmd_queue_region_parsed,
8672 .help_str = "set port <port_id> queue-region region_id <value> "
8673 "queue_start_index <value> queue_num <value>: Set a queue region",
8675 (void *)&cmd_queue_region_set,
8676 (void *)&cmd_queue_region_port,
8677 (void *)&cmd_queue_region_port_id,
8678 (void *)&cmd_queue_region_cmd,
8679 (void *)&cmd_queue_region_id,
8680 (void *)&cmd_queue_region_index,
8681 (void *)&cmd_queue_region_queue_start_index,
8682 (void *)&cmd_queue_region_queue_id,
8683 (void *)&cmd_queue_region_queue_num,
8684 (void *)&cmd_queue_region_queue_num_value,
8689 /* *** queue region and flowtype set *** */
8690 struct cmd_region_flowtype_result {
8691 cmdline_fixed_string_t set;
8692 cmdline_fixed_string_t port;
8694 cmdline_fixed_string_t cmd;
8695 cmdline_fixed_string_t region;
8697 cmdline_fixed_string_t flowtype;
8698 uint8_t flowtype_id;
8702 cmd_region_flowtype_parsed(void *parsed_result,
8703 __attribute__((unused)) struct cmdline *cl,
8704 __attribute__((unused)) void *data)
8706 struct cmd_region_flowtype_result *res = parsed_result;
8708 #ifdef RTE_LIBRTE_I40E_PMD
8709 struct rte_pmd_i40e_queue_region_conf region_conf;
8710 enum rte_pmd_i40e_queue_region_op op_type;
8713 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
8716 #ifdef RTE_LIBRTE_I40E_PMD
8717 memset(®ion_conf, 0, sizeof(region_conf));
8719 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_FLOWTYPE_SET;
8720 region_conf.region_id = res->region_id;
8721 region_conf.hw_flowtype = res->flowtype_id;
8723 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
8724 op_type, ®ion_conf);
8731 printf("function not implemented or supported\n");
8734 printf("region flowtype config error: (%s)\n", strerror(-ret));
8738 cmdline_parse_token_string_t cmd_region_flowtype_set =
8739 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
8741 cmdline_parse_token_string_t cmd_region_flowtype_port =
8742 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
8744 cmdline_parse_token_num_t cmd_region_flowtype_port_index =
8745 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
8747 cmdline_parse_token_string_t cmd_region_flowtype_cmd =
8748 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
8749 cmd, "queue-region");
8750 cmdline_parse_token_string_t cmd_region_flowtype_index =
8751 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
8752 region, "region_id");
8753 cmdline_parse_token_num_t cmd_region_flowtype_id =
8754 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
8756 cmdline_parse_token_string_t cmd_region_flowtype_flow_index =
8757 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
8758 flowtype, "flowtype");
8759 cmdline_parse_token_num_t cmd_region_flowtype_flow_id =
8760 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
8761 flowtype_id, UINT8);
8762 cmdline_parse_inst_t cmd_region_flowtype = {
8763 .f = cmd_region_flowtype_parsed,
8765 .help_str = "set port <port_id> queue-region region_id <value> "
8766 "flowtype <value>: Set a flowtype region index",
8768 (void *)&cmd_region_flowtype_set,
8769 (void *)&cmd_region_flowtype_port,
8770 (void *)&cmd_region_flowtype_port_index,
8771 (void *)&cmd_region_flowtype_cmd,
8772 (void *)&cmd_region_flowtype_index,
8773 (void *)&cmd_region_flowtype_id,
8774 (void *)&cmd_region_flowtype_flow_index,
8775 (void *)&cmd_region_flowtype_flow_id,
8780 /* *** User Priority (UP) to queue region (region_id) set *** */
8781 struct cmd_user_priority_region_result {
8782 cmdline_fixed_string_t set;
8783 cmdline_fixed_string_t port;
8785 cmdline_fixed_string_t cmd;
8786 cmdline_fixed_string_t user_priority;
8787 uint8_t user_priority_id;
8788 cmdline_fixed_string_t region;
8793 cmd_user_priority_region_parsed(void *parsed_result,
8794 __attribute__((unused)) struct cmdline *cl,
8795 __attribute__((unused)) void *data)
8797 struct cmd_user_priority_region_result *res = parsed_result;
8799 #ifdef RTE_LIBRTE_I40E_PMD
8800 struct rte_pmd_i40e_queue_region_conf region_conf;
8801 enum rte_pmd_i40e_queue_region_op op_type;
8804 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
8807 #ifdef RTE_LIBRTE_I40E_PMD
8808 memset(®ion_conf, 0, sizeof(region_conf));
8809 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_USER_PRIORITY_SET;
8810 region_conf.user_priority = res->user_priority_id;
8811 region_conf.region_id = res->region_id;
8813 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
8814 op_type, ®ion_conf);
8821 printf("function not implemented or supported\n");
8824 printf("user_priority region config error: (%s)\n",
8829 cmdline_parse_token_string_t cmd_user_priority_region_set =
8830 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
8832 cmdline_parse_token_string_t cmd_user_priority_region_port =
8833 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
8835 cmdline_parse_token_num_t cmd_user_priority_region_port_index =
8836 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
8838 cmdline_parse_token_string_t cmd_user_priority_region_cmd =
8839 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
8840 cmd, "queue-region");
8841 cmdline_parse_token_string_t cmd_user_priority_region_UP =
8842 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
8843 user_priority, "UP");
8844 cmdline_parse_token_num_t cmd_user_priority_region_UP_id =
8845 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
8846 user_priority_id, UINT8);
8847 cmdline_parse_token_string_t cmd_user_priority_region_region =
8848 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
8849 region, "region_id");
8850 cmdline_parse_token_num_t cmd_user_priority_region_region_id =
8851 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
8854 cmdline_parse_inst_t cmd_user_priority_region = {
8855 .f = cmd_user_priority_region_parsed,
8857 .help_str = "set port <port_id> queue-region UP <value> "
8858 "region_id <value>: Set the mapping of User Priority (UP) "
8859 "to queue region (region_id) ",
8861 (void *)&cmd_user_priority_region_set,
8862 (void *)&cmd_user_priority_region_port,
8863 (void *)&cmd_user_priority_region_port_index,
8864 (void *)&cmd_user_priority_region_cmd,
8865 (void *)&cmd_user_priority_region_UP,
8866 (void *)&cmd_user_priority_region_UP_id,
8867 (void *)&cmd_user_priority_region_region,
8868 (void *)&cmd_user_priority_region_region_id,
8873 /* *** flush all queue region related configuration *** */
8874 struct cmd_flush_queue_region_result {
8875 cmdline_fixed_string_t set;
8876 cmdline_fixed_string_t port;
8878 cmdline_fixed_string_t cmd;
8879 cmdline_fixed_string_t flush;
8880 cmdline_fixed_string_t what;
8884 cmd_flush_queue_region_parsed(void *parsed_result,
8885 __attribute__((unused)) struct cmdline *cl,
8886 __attribute__((unused)) void *data)
8888 struct cmd_flush_queue_region_result *res = parsed_result;
8890 #ifdef RTE_LIBRTE_I40E_PMD
8891 struct rte_pmd_i40e_queue_region_conf region_conf;
8892 enum rte_pmd_i40e_queue_region_op op_type;
8895 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
8898 #ifdef RTE_LIBRTE_I40E_PMD
8899 memset(®ion_conf, 0, sizeof(region_conf));
8901 if (strcmp(res->what, "on") == 0)
8902 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_ON;
8904 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_OFF;
8906 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
8907 op_type, ®ion_conf);
8914 printf("function not implemented or supported\n");
8917 printf("queue region config flush error: (%s)\n",
8922 cmdline_parse_token_string_t cmd_flush_queue_region_set =
8923 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
8925 cmdline_parse_token_string_t cmd_flush_queue_region_port =
8926 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
8928 cmdline_parse_token_num_t cmd_flush_queue_region_port_index =
8929 TOKEN_NUM_INITIALIZER(struct cmd_flush_queue_region_result,
8931 cmdline_parse_token_string_t cmd_flush_queue_region_cmd =
8932 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
8933 cmd, "queue-region");
8934 cmdline_parse_token_string_t cmd_flush_queue_region_flush =
8935 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
8937 cmdline_parse_token_string_t cmd_flush_queue_region_what =
8938 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
8941 cmdline_parse_inst_t cmd_flush_queue_region = {
8942 .f = cmd_flush_queue_region_parsed,
8944 .help_str = "set port <port_id> queue-region flush on|off"
8945 ": flush all queue region related configuration",
8947 (void *)&cmd_flush_queue_region_set,
8948 (void *)&cmd_flush_queue_region_port,
8949 (void *)&cmd_flush_queue_region_port_index,
8950 (void *)&cmd_flush_queue_region_cmd,
8951 (void *)&cmd_flush_queue_region_flush,
8952 (void *)&cmd_flush_queue_region_what,
8957 /* *** get all queue region related configuration info *** */
8958 struct cmd_show_queue_region_info {
8959 cmdline_fixed_string_t show;
8960 cmdline_fixed_string_t port;
8962 cmdline_fixed_string_t cmd;
8966 cmd_show_queue_region_info_parsed(void *parsed_result,
8967 __attribute__((unused)) struct cmdline *cl,
8968 __attribute__((unused)) void *data)
8970 struct cmd_show_queue_region_info *res = parsed_result;
8972 #ifdef RTE_LIBRTE_I40E_PMD
8973 struct rte_pmd_i40e_queue_regions rte_pmd_regions;
8974 enum rte_pmd_i40e_queue_region_op op_type;
8977 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
8980 #ifdef RTE_LIBRTE_I40E_PMD
8981 memset(&rte_pmd_regions, 0, sizeof(rte_pmd_regions));
8983 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_INFO_GET;
8985 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
8986 op_type, &rte_pmd_regions);
8988 port_queue_region_info_display(res->port_id, &rte_pmd_regions);
8995 printf("function not implemented or supported\n");
8998 printf("queue region config info show error: (%s)\n",
9003 cmdline_parse_token_string_t cmd_show_queue_region_info_get =
9004 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
9006 cmdline_parse_token_string_t cmd_show_queue_region_info_port =
9007 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
9009 cmdline_parse_token_num_t cmd_show_queue_region_info_port_index =
9010 TOKEN_NUM_INITIALIZER(struct cmd_show_queue_region_info,
9012 cmdline_parse_token_string_t cmd_show_queue_region_info_cmd =
9013 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
9014 cmd, "queue-region");
9016 cmdline_parse_inst_t cmd_show_queue_region_info_all = {
9017 .f = cmd_show_queue_region_info_parsed,
9019 .help_str = "show port <port_id> queue-region"
9020 ": show all queue region related configuration info",
9022 (void *)&cmd_show_queue_region_info_get,
9023 (void *)&cmd_show_queue_region_info_port,
9024 (void *)&cmd_show_queue_region_info_port_index,
9025 (void *)&cmd_show_queue_region_info_cmd,
9030 /* *** ADD/REMOVE A 2tuple FILTER *** */
9031 struct cmd_2tuple_filter_result {
9032 cmdline_fixed_string_t filter;
9034 cmdline_fixed_string_t ops;
9035 cmdline_fixed_string_t dst_port;
9036 uint16_t dst_port_value;
9037 cmdline_fixed_string_t protocol;
9038 uint8_t protocol_value;
9039 cmdline_fixed_string_t mask;
9041 cmdline_fixed_string_t tcp_flags;
9042 uint8_t tcp_flags_value;
9043 cmdline_fixed_string_t priority;
9044 uint8_t priority_value;
9045 cmdline_fixed_string_t queue;
9050 cmd_2tuple_filter_parsed(void *parsed_result,
9051 __attribute__((unused)) struct cmdline *cl,
9052 __attribute__((unused)) void *data)
9054 struct rte_eth_ntuple_filter filter;
9055 struct cmd_2tuple_filter_result *res = parsed_result;
9058 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
9060 printf("ntuple filter is not supported on port %u.\n",
9065 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
9067 filter.flags = RTE_2TUPLE_FLAGS;
9068 filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
9069 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
9070 filter.proto = res->protocol_value;
9071 filter.priority = res->priority_value;
9072 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
9073 printf("nonzero tcp_flags is only meaningful"
9074 " when protocol is TCP.\n");
9077 if (res->tcp_flags_value > TCP_FLAG_ALL) {
9078 printf("invalid TCP flags.\n");
9082 if (res->tcp_flags_value != 0) {
9083 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
9084 filter.tcp_flags = res->tcp_flags_value;
9087 /* need convert to big endian. */
9088 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
9089 filter.queue = res->queue_id;
9091 if (!strcmp(res->ops, "add"))
9092 ret = rte_eth_dev_filter_ctrl(res->port_id,
9093 RTE_ETH_FILTER_NTUPLE,
9097 ret = rte_eth_dev_filter_ctrl(res->port_id,
9098 RTE_ETH_FILTER_NTUPLE,
9099 RTE_ETH_FILTER_DELETE,
9102 printf("2tuple filter programming error: (%s)\n",
9107 cmdline_parse_token_string_t cmd_2tuple_filter_filter =
9108 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9109 filter, "2tuple_filter");
9110 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
9111 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9113 cmdline_parse_token_string_t cmd_2tuple_filter_ops =
9114 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9116 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
9117 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9118 dst_port, "dst_port");
9119 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
9120 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9121 dst_port_value, UINT16);
9122 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
9123 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9124 protocol, "protocol");
9125 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
9126 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9127 protocol_value, UINT8);
9128 cmdline_parse_token_string_t cmd_2tuple_filter_mask =
9129 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9131 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value =
9132 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9134 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags =
9135 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9136 tcp_flags, "tcp_flags");
9137 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value =
9138 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9139 tcp_flags_value, UINT8);
9140 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
9141 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9142 priority, "priority");
9143 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
9144 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9145 priority_value, UINT8);
9146 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
9147 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9149 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
9150 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9153 cmdline_parse_inst_t cmd_2tuple_filter = {
9154 .f = cmd_2tuple_filter_parsed,
9156 .help_str = "2tuple_filter <port_id> add|del dst_port <value> protocol "
9157 "<value> mask <value> tcp_flags <value> priority <value> queue "
9158 "<queue_id>: Add a 2tuple filter",
9160 (void *)&cmd_2tuple_filter_filter,
9161 (void *)&cmd_2tuple_filter_port_id,
9162 (void *)&cmd_2tuple_filter_ops,
9163 (void *)&cmd_2tuple_filter_dst_port,
9164 (void *)&cmd_2tuple_filter_dst_port_value,
9165 (void *)&cmd_2tuple_filter_protocol,
9166 (void *)&cmd_2tuple_filter_protocol_value,
9167 (void *)&cmd_2tuple_filter_mask,
9168 (void *)&cmd_2tuple_filter_mask_value,
9169 (void *)&cmd_2tuple_filter_tcp_flags,
9170 (void *)&cmd_2tuple_filter_tcp_flags_value,
9171 (void *)&cmd_2tuple_filter_priority,
9172 (void *)&cmd_2tuple_filter_priority_value,
9173 (void *)&cmd_2tuple_filter_queue,
9174 (void *)&cmd_2tuple_filter_queue_id,
9179 /* *** ADD/REMOVE A 5tuple FILTER *** */
9180 struct cmd_5tuple_filter_result {
9181 cmdline_fixed_string_t filter;
9183 cmdline_fixed_string_t ops;
9184 cmdline_fixed_string_t dst_ip;
9185 cmdline_ipaddr_t dst_ip_value;
9186 cmdline_fixed_string_t src_ip;
9187 cmdline_ipaddr_t src_ip_value;
9188 cmdline_fixed_string_t dst_port;
9189 uint16_t dst_port_value;
9190 cmdline_fixed_string_t src_port;
9191 uint16_t src_port_value;
9192 cmdline_fixed_string_t protocol;
9193 uint8_t protocol_value;
9194 cmdline_fixed_string_t mask;
9196 cmdline_fixed_string_t tcp_flags;
9197 uint8_t tcp_flags_value;
9198 cmdline_fixed_string_t priority;
9199 uint8_t priority_value;
9200 cmdline_fixed_string_t queue;
9205 cmd_5tuple_filter_parsed(void *parsed_result,
9206 __attribute__((unused)) struct cmdline *cl,
9207 __attribute__((unused)) void *data)
9209 struct rte_eth_ntuple_filter filter;
9210 struct cmd_5tuple_filter_result *res = parsed_result;
9213 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
9215 printf("ntuple filter is not supported on port %u.\n",
9220 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
9222 filter.flags = RTE_5TUPLE_FLAGS;
9223 filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0;
9224 filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0;
9225 filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0;
9226 filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
9227 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
9228 filter.proto = res->protocol_value;
9229 filter.priority = res->priority_value;
9230 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
9231 printf("nonzero tcp_flags is only meaningful"
9232 " when protocol is TCP.\n");
9235 if (res->tcp_flags_value > TCP_FLAG_ALL) {
9236 printf("invalid TCP flags.\n");
9240 if (res->tcp_flags_value != 0) {
9241 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
9242 filter.tcp_flags = res->tcp_flags_value;
9245 if (res->dst_ip_value.family == AF_INET)
9246 /* no need to convert, already big endian. */
9247 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
9249 if (filter.dst_ip_mask == 0) {
9250 printf("can not support ipv6 involved compare.\n");
9256 if (res->src_ip_value.family == AF_INET)
9257 /* no need to convert, already big endian. */
9258 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
9260 if (filter.src_ip_mask == 0) {
9261 printf("can not support ipv6 involved compare.\n");
9266 /* need convert to big endian. */
9267 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
9268 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
9269 filter.queue = res->queue_id;
9271 if (!strcmp(res->ops, "add"))
9272 ret = rte_eth_dev_filter_ctrl(res->port_id,
9273 RTE_ETH_FILTER_NTUPLE,
9277 ret = rte_eth_dev_filter_ctrl(res->port_id,
9278 RTE_ETH_FILTER_NTUPLE,
9279 RTE_ETH_FILTER_DELETE,
9282 printf("5tuple filter programming error: (%s)\n",
9286 cmdline_parse_token_string_t cmd_5tuple_filter_filter =
9287 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9288 filter, "5tuple_filter");
9289 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
9290 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9292 cmdline_parse_token_string_t cmd_5tuple_filter_ops =
9293 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9295 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
9296 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9298 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
9299 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
9301 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
9302 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9304 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
9305 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
9307 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
9308 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9309 dst_port, "dst_port");
9310 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
9311 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9312 dst_port_value, UINT16);
9313 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
9314 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9315 src_port, "src_port");
9316 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
9317 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9318 src_port_value, UINT16);
9319 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
9320 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9321 protocol, "protocol");
9322 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
9323 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9324 protocol_value, UINT8);
9325 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
9326 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9328 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
9329 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9331 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags =
9332 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9333 tcp_flags, "tcp_flags");
9334 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value =
9335 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9336 tcp_flags_value, UINT8);
9337 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
9338 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9339 priority, "priority");
9340 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
9341 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9342 priority_value, UINT8);
9343 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
9344 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9346 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
9347 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9350 cmdline_parse_inst_t cmd_5tuple_filter = {
9351 .f = cmd_5tuple_filter_parsed,
9353 .help_str = "5tuple_filter <port_id> add|del dst_ip <value> "
9354 "src_ip <value> dst_port <value> src_port <value> "
9355 "protocol <value> mask <value> tcp_flags <value> "
9356 "priority <value> queue <queue_id>: Add/Del a 5tuple filter",
9358 (void *)&cmd_5tuple_filter_filter,
9359 (void *)&cmd_5tuple_filter_port_id,
9360 (void *)&cmd_5tuple_filter_ops,
9361 (void *)&cmd_5tuple_filter_dst_ip,
9362 (void *)&cmd_5tuple_filter_dst_ip_value,
9363 (void *)&cmd_5tuple_filter_src_ip,
9364 (void *)&cmd_5tuple_filter_src_ip_value,
9365 (void *)&cmd_5tuple_filter_dst_port,
9366 (void *)&cmd_5tuple_filter_dst_port_value,
9367 (void *)&cmd_5tuple_filter_src_port,
9368 (void *)&cmd_5tuple_filter_src_port_value,
9369 (void *)&cmd_5tuple_filter_protocol,
9370 (void *)&cmd_5tuple_filter_protocol_value,
9371 (void *)&cmd_5tuple_filter_mask,
9372 (void *)&cmd_5tuple_filter_mask_value,
9373 (void *)&cmd_5tuple_filter_tcp_flags,
9374 (void *)&cmd_5tuple_filter_tcp_flags_value,
9375 (void *)&cmd_5tuple_filter_priority,
9376 (void *)&cmd_5tuple_filter_priority_value,
9377 (void *)&cmd_5tuple_filter_queue,
9378 (void *)&cmd_5tuple_filter_queue_id,
9383 /* *** ADD/REMOVE A flex FILTER *** */
9384 struct cmd_flex_filter_result {
9385 cmdline_fixed_string_t filter;
9386 cmdline_fixed_string_t ops;
9388 cmdline_fixed_string_t len;
9390 cmdline_fixed_string_t bytes;
9391 cmdline_fixed_string_t bytes_value;
9392 cmdline_fixed_string_t mask;
9393 cmdline_fixed_string_t mask_value;
9394 cmdline_fixed_string_t priority;
9395 uint8_t priority_value;
9396 cmdline_fixed_string_t queue;
9400 static int xdigit2val(unsigned char c)
9405 else if (isupper(c))
9413 cmd_flex_filter_parsed(void *parsed_result,
9414 __attribute__((unused)) struct cmdline *cl,
9415 __attribute__((unused)) void *data)
9418 struct rte_eth_flex_filter filter;
9419 struct cmd_flex_filter_result *res = parsed_result;
9420 char *bytes_ptr, *mask_ptr;
9421 uint16_t len, i, j = 0;
9426 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) {
9427 printf("the len exceed the max length 128\n");
9430 memset(&filter, 0, sizeof(struct rte_eth_flex_filter));
9431 filter.len = res->len_value;
9432 filter.priority = res->priority_value;
9433 filter.queue = res->queue_id;
9434 bytes_ptr = res->bytes_value;
9435 mask_ptr = res->mask_value;
9437 /* translate bytes string to array. */
9438 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
9439 (bytes_ptr[1] == 'X')))
9441 len = strnlen(bytes_ptr, res->len_value * 2);
9442 if (len == 0 || (len % 8 != 0)) {
9443 printf("please check len and bytes input\n");
9446 for (i = 0; i < len; i++) {
9448 if (isxdigit(c) == 0) {
9449 /* invalid characters. */
9450 printf("invalid input\n");
9453 val = xdigit2val(c);
9456 filter.bytes[j] = byte;
9457 printf("bytes[%d]:%02x ", j, filter.bytes[j]);
9464 /* translate mask string to uint8_t array. */
9465 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
9466 (mask_ptr[1] == 'X')))
9468 len = strnlen(mask_ptr, (res->len_value + 3) / 4);
9470 printf("invalid input\n");
9475 for (i = 0; i < len; i++) {
9477 if (isxdigit(c) == 0) {
9478 /* invalid characters. */
9479 printf("invalid input\n");
9482 val = xdigit2val(c);
9485 filter.mask[j] = byte;
9486 printf("mask[%d]:%02x ", j, filter.mask[j]);
9494 if (!strcmp(res->ops, "add"))
9495 ret = rte_eth_dev_filter_ctrl(res->port_id,
9496 RTE_ETH_FILTER_FLEXIBLE,
9500 ret = rte_eth_dev_filter_ctrl(res->port_id,
9501 RTE_ETH_FILTER_FLEXIBLE,
9502 RTE_ETH_FILTER_DELETE,
9506 printf("flex filter setting error: (%s)\n", strerror(-ret));
9509 cmdline_parse_token_string_t cmd_flex_filter_filter =
9510 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9511 filter, "flex_filter");
9512 cmdline_parse_token_num_t cmd_flex_filter_port_id =
9513 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
9515 cmdline_parse_token_string_t cmd_flex_filter_ops =
9516 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9518 cmdline_parse_token_string_t cmd_flex_filter_len =
9519 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9521 cmdline_parse_token_num_t cmd_flex_filter_len_value =
9522 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
9524 cmdline_parse_token_string_t cmd_flex_filter_bytes =
9525 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9527 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
9528 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9530 cmdline_parse_token_string_t cmd_flex_filter_mask =
9531 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9533 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
9534 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9536 cmdline_parse_token_string_t cmd_flex_filter_priority =
9537 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9538 priority, "priority");
9539 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
9540 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
9541 priority_value, UINT8);
9542 cmdline_parse_token_string_t cmd_flex_filter_queue =
9543 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9545 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
9546 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
9548 cmdline_parse_inst_t cmd_flex_filter = {
9549 .f = cmd_flex_filter_parsed,
9551 .help_str = "flex_filter <port_id> add|del len <value> bytes "
9552 "<value> mask <value> priority <value> queue <queue_id>: "
9553 "Add/Del a flex filter",
9555 (void *)&cmd_flex_filter_filter,
9556 (void *)&cmd_flex_filter_port_id,
9557 (void *)&cmd_flex_filter_ops,
9558 (void *)&cmd_flex_filter_len,
9559 (void *)&cmd_flex_filter_len_value,
9560 (void *)&cmd_flex_filter_bytes,
9561 (void *)&cmd_flex_filter_bytes_value,
9562 (void *)&cmd_flex_filter_mask,
9563 (void *)&cmd_flex_filter_mask_value,
9564 (void *)&cmd_flex_filter_priority,
9565 (void *)&cmd_flex_filter_priority_value,
9566 (void *)&cmd_flex_filter_queue,
9567 (void *)&cmd_flex_filter_queue_id,
9572 /* *** Filters Control *** */
9574 /* *** deal with ethertype filter *** */
9575 struct cmd_ethertype_filter_result {
9576 cmdline_fixed_string_t filter;
9578 cmdline_fixed_string_t ops;
9579 cmdline_fixed_string_t mac;
9580 struct ether_addr mac_addr;
9581 cmdline_fixed_string_t ethertype;
9582 uint16_t ethertype_value;
9583 cmdline_fixed_string_t drop;
9584 cmdline_fixed_string_t queue;
9588 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
9589 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9590 filter, "ethertype_filter");
9591 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
9592 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
9594 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
9595 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9597 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
9598 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9599 mac, "mac_addr#mac_ignr");
9600 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
9601 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
9603 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
9604 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9605 ethertype, "ethertype");
9606 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
9607 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
9608 ethertype_value, UINT16);
9609 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
9610 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9612 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
9613 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9615 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
9616 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
9620 cmd_ethertype_filter_parsed(void *parsed_result,
9621 __attribute__((unused)) struct cmdline *cl,
9622 __attribute__((unused)) void *data)
9624 struct cmd_ethertype_filter_result *res = parsed_result;
9625 struct rte_eth_ethertype_filter filter;
9628 ret = rte_eth_dev_filter_supported(res->port_id,
9629 RTE_ETH_FILTER_ETHERTYPE);
9631 printf("ethertype filter is not supported on port %u.\n",
9636 memset(&filter, 0, sizeof(filter));
9637 if (!strcmp(res->mac, "mac_addr")) {
9638 filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
9639 rte_memcpy(&filter.mac_addr, &res->mac_addr,
9640 sizeof(struct ether_addr));
9642 if (!strcmp(res->drop, "drop"))
9643 filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
9644 filter.ether_type = res->ethertype_value;
9645 filter.queue = res->queue_id;
9647 if (!strcmp(res->ops, "add"))
9648 ret = rte_eth_dev_filter_ctrl(res->port_id,
9649 RTE_ETH_FILTER_ETHERTYPE,
9653 ret = rte_eth_dev_filter_ctrl(res->port_id,
9654 RTE_ETH_FILTER_ETHERTYPE,
9655 RTE_ETH_FILTER_DELETE,
9658 printf("ethertype filter programming error: (%s)\n",
9662 cmdline_parse_inst_t cmd_ethertype_filter = {
9663 .f = cmd_ethertype_filter_parsed,
9665 .help_str = "ethertype_filter <port_id> add|del mac_addr|mac_ignr "
9666 "<mac_addr> ethertype <value> drop|fw queue <queue_id>: "
9667 "Add or delete an ethertype filter entry",
9669 (void *)&cmd_ethertype_filter_filter,
9670 (void *)&cmd_ethertype_filter_port_id,
9671 (void *)&cmd_ethertype_filter_ops,
9672 (void *)&cmd_ethertype_filter_mac,
9673 (void *)&cmd_ethertype_filter_mac_addr,
9674 (void *)&cmd_ethertype_filter_ethertype,
9675 (void *)&cmd_ethertype_filter_ethertype_value,
9676 (void *)&cmd_ethertype_filter_drop,
9677 (void *)&cmd_ethertype_filter_queue,
9678 (void *)&cmd_ethertype_filter_queue_id,
9683 /* *** deal with flow director filter *** */
9684 struct cmd_flow_director_result {
9685 cmdline_fixed_string_t flow_director_filter;
9687 cmdline_fixed_string_t mode;
9688 cmdline_fixed_string_t mode_value;
9689 cmdline_fixed_string_t ops;
9690 cmdline_fixed_string_t flow;
9691 cmdline_fixed_string_t flow_type;
9692 cmdline_fixed_string_t ether;
9693 uint16_t ether_type;
9694 cmdline_fixed_string_t src;
9695 cmdline_ipaddr_t ip_src;
9697 cmdline_fixed_string_t dst;
9698 cmdline_ipaddr_t ip_dst;
9700 cmdline_fixed_string_t verify_tag;
9701 uint32_t verify_tag_value;
9702 cmdline_ipaddr_t tos;
9704 cmdline_ipaddr_t proto;
9705 uint8_t proto_value;
9706 cmdline_ipaddr_t ttl;
9708 cmdline_fixed_string_t vlan;
9709 uint16_t vlan_value;
9710 cmdline_fixed_string_t flexbytes;
9711 cmdline_fixed_string_t flexbytes_value;
9712 cmdline_fixed_string_t pf_vf;
9713 cmdline_fixed_string_t drop;
9714 cmdline_fixed_string_t queue;
9716 cmdline_fixed_string_t fd_id;
9717 uint32_t fd_id_value;
9718 cmdline_fixed_string_t mac;
9719 struct ether_addr mac_addr;
9720 cmdline_fixed_string_t tunnel;
9721 cmdline_fixed_string_t tunnel_type;
9722 cmdline_fixed_string_t tunnel_id;
9723 uint32_t tunnel_id_value;
9727 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
9730 const char *p, *p0 = q_arg;
9732 unsigned long int_fld;
9733 char *str_fld[max_num];
9738 p = strchr(p0, '(');
9742 p0 = strchr(p, ')');
9747 if (size >= sizeof(s))
9750 snprintf(s, sizeof(s), "%.*s", size, p);
9751 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
9752 if (ret < 0 || ret > max_num)
9754 for (i = 0; i < ret; i++) {
9756 int_fld = strtoul(str_fld[i], &end, 0);
9757 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
9759 flexbytes[i] = (uint8_t)int_fld;
9765 str2flowtype(char *string)
9768 static const struct {
9771 } flowtype_str[] = {
9772 {"raw", RTE_ETH_FLOW_RAW},
9773 {"ipv4", RTE_ETH_FLOW_IPV4},
9774 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
9775 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
9776 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
9777 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
9778 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
9779 {"ipv6", RTE_ETH_FLOW_IPV6},
9780 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
9781 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
9782 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
9783 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
9784 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
9785 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
9788 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
9789 if (!strcmp(flowtype_str[i].str, string))
9790 return flowtype_str[i].type;
9793 if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64)
9794 return (uint16_t)atoi(string);
9796 return RTE_ETH_FLOW_UNKNOWN;
9799 static enum rte_eth_fdir_tunnel_type
9800 str2fdir_tunneltype(char *string)
9804 static const struct {
9806 enum rte_eth_fdir_tunnel_type type;
9807 } tunneltype_str[] = {
9808 {"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE},
9809 {"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN},
9812 for (i = 0; i < RTE_DIM(tunneltype_str); i++) {
9813 if (!strcmp(tunneltype_str[i].str, string))
9814 return tunneltype_str[i].type;
9816 return RTE_FDIR_TUNNEL_TYPE_UNKNOWN;
9819 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
9821 if ((ip_addr).family == AF_INET) \
9822 (ip) = (ip_addr).addr.ipv4.s_addr; \
9824 printf("invalid parameter.\n"); \
9829 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
9831 if ((ip_addr).family == AF_INET6) \
9833 &((ip_addr).addr.ipv6), \
9834 sizeof(struct in6_addr)); \
9836 printf("invalid parameter.\n"); \
9842 cmd_flow_director_filter_parsed(void *parsed_result,
9843 __attribute__((unused)) struct cmdline *cl,
9844 __attribute__((unused)) void *data)
9846 struct cmd_flow_director_result *res = parsed_result;
9847 struct rte_eth_fdir_filter entry;
9848 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
9850 unsigned long vf_id;
9853 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
9855 printf("flow director is not supported on port %u.\n",
9859 memset(flexbytes, 0, sizeof(flexbytes));
9860 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
9862 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
9863 if (strcmp(res->mode_value, "MAC-VLAN")) {
9864 printf("Please set mode to MAC-VLAN.\n");
9867 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
9868 if (strcmp(res->mode_value, "Tunnel")) {
9869 printf("Please set mode to Tunnel.\n");
9873 if (strcmp(res->mode_value, "IP")) {
9874 printf("Please set mode to IP.\n");
9877 entry.input.flow_type = str2flowtype(res->flow_type);
9880 ret = parse_flexbytes(res->flexbytes_value,
9882 RTE_ETH_FDIR_MAX_FLEXLEN);
9884 printf("error: Cannot parse flexbytes input.\n");
9888 switch (entry.input.flow_type) {
9889 case RTE_ETH_FLOW_FRAG_IPV4:
9890 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
9891 entry.input.flow.ip4_flow.proto = res->proto_value;
9893 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
9894 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
9895 IPV4_ADDR_TO_UINT(res->ip_dst,
9896 entry.input.flow.ip4_flow.dst_ip);
9897 IPV4_ADDR_TO_UINT(res->ip_src,
9898 entry.input.flow.ip4_flow.src_ip);
9899 entry.input.flow.ip4_flow.tos = res->tos_value;
9900 entry.input.flow.ip4_flow.ttl = res->ttl_value;
9901 /* need convert to big endian. */
9902 entry.input.flow.udp4_flow.dst_port =
9903 rte_cpu_to_be_16(res->port_dst);
9904 entry.input.flow.udp4_flow.src_port =
9905 rte_cpu_to_be_16(res->port_src);
9907 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
9908 IPV4_ADDR_TO_UINT(res->ip_dst,
9909 entry.input.flow.sctp4_flow.ip.dst_ip);
9910 IPV4_ADDR_TO_UINT(res->ip_src,
9911 entry.input.flow.sctp4_flow.ip.src_ip);
9912 entry.input.flow.ip4_flow.tos = res->tos_value;
9913 entry.input.flow.ip4_flow.ttl = res->ttl_value;
9914 /* need convert to big endian. */
9915 entry.input.flow.sctp4_flow.dst_port =
9916 rte_cpu_to_be_16(res->port_dst);
9917 entry.input.flow.sctp4_flow.src_port =
9918 rte_cpu_to_be_16(res->port_src);
9919 entry.input.flow.sctp4_flow.verify_tag =
9920 rte_cpu_to_be_32(res->verify_tag_value);
9922 case RTE_ETH_FLOW_FRAG_IPV6:
9923 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
9924 entry.input.flow.ipv6_flow.proto = res->proto_value;
9926 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
9927 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
9928 IPV6_ADDR_TO_ARRAY(res->ip_dst,
9929 entry.input.flow.ipv6_flow.dst_ip);
9930 IPV6_ADDR_TO_ARRAY(res->ip_src,
9931 entry.input.flow.ipv6_flow.src_ip);
9932 entry.input.flow.ipv6_flow.tc = res->tos_value;
9933 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
9934 /* need convert to big endian. */
9935 entry.input.flow.udp6_flow.dst_port =
9936 rte_cpu_to_be_16(res->port_dst);
9937 entry.input.flow.udp6_flow.src_port =
9938 rte_cpu_to_be_16(res->port_src);
9940 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
9941 IPV6_ADDR_TO_ARRAY(res->ip_dst,
9942 entry.input.flow.sctp6_flow.ip.dst_ip);
9943 IPV6_ADDR_TO_ARRAY(res->ip_src,
9944 entry.input.flow.sctp6_flow.ip.src_ip);
9945 entry.input.flow.ipv6_flow.tc = res->tos_value;
9946 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
9947 /* need convert to big endian. */
9948 entry.input.flow.sctp6_flow.dst_port =
9949 rte_cpu_to_be_16(res->port_dst);
9950 entry.input.flow.sctp6_flow.src_port =
9951 rte_cpu_to_be_16(res->port_src);
9952 entry.input.flow.sctp6_flow.verify_tag =
9953 rte_cpu_to_be_32(res->verify_tag_value);
9955 case RTE_ETH_FLOW_L2_PAYLOAD:
9956 entry.input.flow.l2_flow.ether_type =
9957 rte_cpu_to_be_16(res->ether_type);
9963 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN)
9964 rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr,
9966 sizeof(struct ether_addr));
9968 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
9969 rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr,
9971 sizeof(struct ether_addr));
9972 entry.input.flow.tunnel_flow.tunnel_type =
9973 str2fdir_tunneltype(res->tunnel_type);
9974 entry.input.flow.tunnel_flow.tunnel_id =
9975 rte_cpu_to_be_32(res->tunnel_id_value);
9978 rte_memcpy(entry.input.flow_ext.flexbytes,
9980 RTE_ETH_FDIR_MAX_FLEXLEN);
9982 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
9984 entry.action.flex_off = 0; /*use 0 by default */
9985 if (!strcmp(res->drop, "drop"))
9986 entry.action.behavior = RTE_ETH_FDIR_REJECT;
9988 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
9990 if (fdir_conf.mode != RTE_FDIR_MODE_PERFECT_MAC_VLAN &&
9991 fdir_conf.mode != RTE_FDIR_MODE_PERFECT_TUNNEL) {
9992 if (!strcmp(res->pf_vf, "pf"))
9993 entry.input.flow_ext.is_vf = 0;
9994 else if (!strncmp(res->pf_vf, "vf", 2)) {
9995 struct rte_eth_dev_info dev_info;
9997 memset(&dev_info, 0, sizeof(dev_info));
9998 rte_eth_dev_info_get(res->port_id, &dev_info);
10000 vf_id = strtoul(res->pf_vf + 2, &end, 10);
10001 if (errno != 0 || *end != '\0' ||
10002 vf_id >= dev_info.max_vfs) {
10003 printf("invalid parameter %s.\n", res->pf_vf);
10006 entry.input.flow_ext.is_vf = 1;
10007 entry.input.flow_ext.dst_id = (uint16_t)vf_id;
10009 printf("invalid parameter %s.\n", res->pf_vf);
10014 /* set to report FD ID by default */
10015 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
10016 entry.action.rx_queue = res->queue_id;
10017 entry.soft_id = res->fd_id_value;
10018 if (!strcmp(res->ops, "add"))
10019 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10020 RTE_ETH_FILTER_ADD, &entry);
10021 else if (!strcmp(res->ops, "del"))
10022 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10023 RTE_ETH_FILTER_DELETE, &entry);
10025 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10026 RTE_ETH_FILTER_UPDATE, &entry);
10028 printf("flow director programming error: (%s)\n",
10032 cmdline_parse_token_string_t cmd_flow_director_filter =
10033 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10034 flow_director_filter, "flow_director_filter");
10035 cmdline_parse_token_num_t cmd_flow_director_port_id =
10036 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10038 cmdline_parse_token_string_t cmd_flow_director_ops =
10039 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10040 ops, "add#del#update");
10041 cmdline_parse_token_string_t cmd_flow_director_flow =
10042 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10044 cmdline_parse_token_string_t cmd_flow_director_flow_type =
10045 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10046 flow_type, "ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
10047 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload");
10048 cmdline_parse_token_string_t cmd_flow_director_ether =
10049 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10051 cmdline_parse_token_num_t cmd_flow_director_ether_type =
10052 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10053 ether_type, UINT16);
10054 cmdline_parse_token_string_t cmd_flow_director_src =
10055 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10057 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
10058 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
10060 cmdline_parse_token_num_t cmd_flow_director_port_src =
10061 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10063 cmdline_parse_token_string_t cmd_flow_director_dst =
10064 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10066 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
10067 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
10069 cmdline_parse_token_num_t cmd_flow_director_port_dst =
10070 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10072 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
10073 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10074 verify_tag, "verify_tag");
10075 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
10076 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10077 verify_tag_value, UINT32);
10078 cmdline_parse_token_string_t cmd_flow_director_tos =
10079 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10081 cmdline_parse_token_num_t cmd_flow_director_tos_value =
10082 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10084 cmdline_parse_token_string_t cmd_flow_director_proto =
10085 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10087 cmdline_parse_token_num_t cmd_flow_director_proto_value =
10088 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10089 proto_value, UINT8);
10090 cmdline_parse_token_string_t cmd_flow_director_ttl =
10091 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10093 cmdline_parse_token_num_t cmd_flow_director_ttl_value =
10094 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10096 cmdline_parse_token_string_t cmd_flow_director_vlan =
10097 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10099 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
10100 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10101 vlan_value, UINT16);
10102 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
10103 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10104 flexbytes, "flexbytes");
10105 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
10106 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10107 flexbytes_value, NULL);
10108 cmdline_parse_token_string_t cmd_flow_director_drop =
10109 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10111 cmdline_parse_token_string_t cmd_flow_director_pf_vf =
10112 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10114 cmdline_parse_token_string_t cmd_flow_director_queue =
10115 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10117 cmdline_parse_token_num_t cmd_flow_director_queue_id =
10118 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10120 cmdline_parse_token_string_t cmd_flow_director_fd_id =
10121 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10123 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
10124 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10125 fd_id_value, UINT32);
10127 cmdline_parse_token_string_t cmd_flow_director_mode =
10128 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10130 cmdline_parse_token_string_t cmd_flow_director_mode_ip =
10131 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10133 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan =
10134 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10135 mode_value, "MAC-VLAN");
10136 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel =
10137 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10138 mode_value, "Tunnel");
10139 cmdline_parse_token_string_t cmd_flow_director_mac =
10140 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10142 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr =
10143 TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result,
10145 cmdline_parse_token_string_t cmd_flow_director_tunnel =
10146 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10148 cmdline_parse_token_string_t cmd_flow_director_tunnel_type =
10149 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10150 tunnel_type, "NVGRE#VxLAN");
10151 cmdline_parse_token_string_t cmd_flow_director_tunnel_id =
10152 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10153 tunnel_id, "tunnel-id");
10154 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value =
10155 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10156 tunnel_id_value, UINT32);
10158 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
10159 .f = cmd_flow_director_filter_parsed,
10161 .help_str = "flow_director_filter <port_id> mode IP add|del|update flow"
10162 " ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
10163 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
10164 "l2_payload src <src_ip> dst <dst_ip> tos <tos_value> "
10165 "proto <proto_value> ttl <ttl_value> vlan <vlan_value> "
10166 "flexbytes <flexbyte_vaues> drop|fw <pf_vf> queue <queue_id> "
10167 "fd_id <fd_id_value>: "
10168 "Add or delete an ip flow director entry on NIC",
10170 (void *)&cmd_flow_director_filter,
10171 (void *)&cmd_flow_director_port_id,
10172 (void *)&cmd_flow_director_mode,
10173 (void *)&cmd_flow_director_mode_ip,
10174 (void *)&cmd_flow_director_ops,
10175 (void *)&cmd_flow_director_flow,
10176 (void *)&cmd_flow_director_flow_type,
10177 (void *)&cmd_flow_director_src,
10178 (void *)&cmd_flow_director_ip_src,
10179 (void *)&cmd_flow_director_dst,
10180 (void *)&cmd_flow_director_ip_dst,
10181 (void *)&cmd_flow_director_tos,
10182 (void *)&cmd_flow_director_tos_value,
10183 (void *)&cmd_flow_director_proto,
10184 (void *)&cmd_flow_director_proto_value,
10185 (void *)&cmd_flow_director_ttl,
10186 (void *)&cmd_flow_director_ttl_value,
10187 (void *)&cmd_flow_director_vlan,
10188 (void *)&cmd_flow_director_vlan_value,
10189 (void *)&cmd_flow_director_flexbytes,
10190 (void *)&cmd_flow_director_flexbytes_value,
10191 (void *)&cmd_flow_director_drop,
10192 (void *)&cmd_flow_director_pf_vf,
10193 (void *)&cmd_flow_director_queue,
10194 (void *)&cmd_flow_director_queue_id,
10195 (void *)&cmd_flow_director_fd_id,
10196 (void *)&cmd_flow_director_fd_id_value,
10201 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
10202 .f = cmd_flow_director_filter_parsed,
10204 .help_str = "flow_director_filter ... : Add or delete an udp/tcp flow "
10205 "director entry on NIC",
10207 (void *)&cmd_flow_director_filter,
10208 (void *)&cmd_flow_director_port_id,
10209 (void *)&cmd_flow_director_mode,
10210 (void *)&cmd_flow_director_mode_ip,
10211 (void *)&cmd_flow_director_ops,
10212 (void *)&cmd_flow_director_flow,
10213 (void *)&cmd_flow_director_flow_type,
10214 (void *)&cmd_flow_director_src,
10215 (void *)&cmd_flow_director_ip_src,
10216 (void *)&cmd_flow_director_port_src,
10217 (void *)&cmd_flow_director_dst,
10218 (void *)&cmd_flow_director_ip_dst,
10219 (void *)&cmd_flow_director_port_dst,
10220 (void *)&cmd_flow_director_tos,
10221 (void *)&cmd_flow_director_tos_value,
10222 (void *)&cmd_flow_director_ttl,
10223 (void *)&cmd_flow_director_ttl_value,
10224 (void *)&cmd_flow_director_vlan,
10225 (void *)&cmd_flow_director_vlan_value,
10226 (void *)&cmd_flow_director_flexbytes,
10227 (void *)&cmd_flow_director_flexbytes_value,
10228 (void *)&cmd_flow_director_drop,
10229 (void *)&cmd_flow_director_pf_vf,
10230 (void *)&cmd_flow_director_queue,
10231 (void *)&cmd_flow_director_queue_id,
10232 (void *)&cmd_flow_director_fd_id,
10233 (void *)&cmd_flow_director_fd_id_value,
10238 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
10239 .f = cmd_flow_director_filter_parsed,
10241 .help_str = "flow_director_filter ... : Add or delete a sctp flow "
10242 "director entry on NIC",
10244 (void *)&cmd_flow_director_filter,
10245 (void *)&cmd_flow_director_port_id,
10246 (void *)&cmd_flow_director_mode,
10247 (void *)&cmd_flow_director_mode_ip,
10248 (void *)&cmd_flow_director_ops,
10249 (void *)&cmd_flow_director_flow,
10250 (void *)&cmd_flow_director_flow_type,
10251 (void *)&cmd_flow_director_src,
10252 (void *)&cmd_flow_director_ip_src,
10253 (void *)&cmd_flow_director_port_dst,
10254 (void *)&cmd_flow_director_dst,
10255 (void *)&cmd_flow_director_ip_dst,
10256 (void *)&cmd_flow_director_port_dst,
10257 (void *)&cmd_flow_director_verify_tag,
10258 (void *)&cmd_flow_director_verify_tag_value,
10259 (void *)&cmd_flow_director_tos,
10260 (void *)&cmd_flow_director_tos_value,
10261 (void *)&cmd_flow_director_ttl,
10262 (void *)&cmd_flow_director_ttl_value,
10263 (void *)&cmd_flow_director_vlan,
10264 (void *)&cmd_flow_director_vlan_value,
10265 (void *)&cmd_flow_director_flexbytes,
10266 (void *)&cmd_flow_director_flexbytes_value,
10267 (void *)&cmd_flow_director_drop,
10268 (void *)&cmd_flow_director_pf_vf,
10269 (void *)&cmd_flow_director_queue,
10270 (void *)&cmd_flow_director_queue_id,
10271 (void *)&cmd_flow_director_fd_id,
10272 (void *)&cmd_flow_director_fd_id_value,
10277 cmdline_parse_inst_t cmd_add_del_l2_flow_director = {
10278 .f = cmd_flow_director_filter_parsed,
10280 .help_str = "flow_director_filter ... : Add or delete a L2 flow "
10281 "director entry on NIC",
10283 (void *)&cmd_flow_director_filter,
10284 (void *)&cmd_flow_director_port_id,
10285 (void *)&cmd_flow_director_mode,
10286 (void *)&cmd_flow_director_mode_ip,
10287 (void *)&cmd_flow_director_ops,
10288 (void *)&cmd_flow_director_flow,
10289 (void *)&cmd_flow_director_flow_type,
10290 (void *)&cmd_flow_director_ether,
10291 (void *)&cmd_flow_director_ether_type,
10292 (void *)&cmd_flow_director_flexbytes,
10293 (void *)&cmd_flow_director_flexbytes_value,
10294 (void *)&cmd_flow_director_drop,
10295 (void *)&cmd_flow_director_pf_vf,
10296 (void *)&cmd_flow_director_queue,
10297 (void *)&cmd_flow_director_queue_id,
10298 (void *)&cmd_flow_director_fd_id,
10299 (void *)&cmd_flow_director_fd_id_value,
10304 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = {
10305 .f = cmd_flow_director_filter_parsed,
10307 .help_str = "flow_director_filter ... : Add or delete a MAC VLAN flow "
10308 "director entry on NIC",
10310 (void *)&cmd_flow_director_filter,
10311 (void *)&cmd_flow_director_port_id,
10312 (void *)&cmd_flow_director_mode,
10313 (void *)&cmd_flow_director_mode_mac_vlan,
10314 (void *)&cmd_flow_director_ops,
10315 (void *)&cmd_flow_director_mac,
10316 (void *)&cmd_flow_director_mac_addr,
10317 (void *)&cmd_flow_director_vlan,
10318 (void *)&cmd_flow_director_vlan_value,
10319 (void *)&cmd_flow_director_flexbytes,
10320 (void *)&cmd_flow_director_flexbytes_value,
10321 (void *)&cmd_flow_director_drop,
10322 (void *)&cmd_flow_director_queue,
10323 (void *)&cmd_flow_director_queue_id,
10324 (void *)&cmd_flow_director_fd_id,
10325 (void *)&cmd_flow_director_fd_id_value,
10330 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = {
10331 .f = cmd_flow_director_filter_parsed,
10333 .help_str = "flow_director_filter ... : Add or delete a tunnel flow "
10334 "director entry on NIC",
10336 (void *)&cmd_flow_director_filter,
10337 (void *)&cmd_flow_director_port_id,
10338 (void *)&cmd_flow_director_mode,
10339 (void *)&cmd_flow_director_mode_tunnel,
10340 (void *)&cmd_flow_director_ops,
10341 (void *)&cmd_flow_director_mac,
10342 (void *)&cmd_flow_director_mac_addr,
10343 (void *)&cmd_flow_director_vlan,
10344 (void *)&cmd_flow_director_vlan_value,
10345 (void *)&cmd_flow_director_tunnel,
10346 (void *)&cmd_flow_director_tunnel_type,
10347 (void *)&cmd_flow_director_tunnel_id,
10348 (void *)&cmd_flow_director_tunnel_id_value,
10349 (void *)&cmd_flow_director_flexbytes,
10350 (void *)&cmd_flow_director_flexbytes_value,
10351 (void *)&cmd_flow_director_drop,
10352 (void *)&cmd_flow_director_queue,
10353 (void *)&cmd_flow_director_queue_id,
10354 (void *)&cmd_flow_director_fd_id,
10355 (void *)&cmd_flow_director_fd_id_value,
10360 struct cmd_flush_flow_director_result {
10361 cmdline_fixed_string_t flush_flow_director;
10365 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
10366 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
10367 flush_flow_director, "flush_flow_director");
10368 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
10369 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
10373 cmd_flush_flow_director_parsed(void *parsed_result,
10374 __attribute__((unused)) struct cmdline *cl,
10375 __attribute__((unused)) void *data)
10377 struct cmd_flow_director_result *res = parsed_result;
10380 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
10382 printf("flow director is not supported on port %u.\n",
10387 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10388 RTE_ETH_FILTER_FLUSH, NULL);
10390 printf("flow director table flushing error: (%s)\n",
10394 cmdline_parse_inst_t cmd_flush_flow_director = {
10395 .f = cmd_flush_flow_director_parsed,
10397 .help_str = "flush_flow_director <port_id>: "
10398 "Flush all flow director entries of a device on NIC",
10400 (void *)&cmd_flush_flow_director_flush,
10401 (void *)&cmd_flush_flow_director_port_id,
10406 /* *** deal with flow director mask *** */
10407 struct cmd_flow_director_mask_result {
10408 cmdline_fixed_string_t flow_director_mask;
10410 cmdline_fixed_string_t mode;
10411 cmdline_fixed_string_t mode_value;
10412 cmdline_fixed_string_t vlan;
10413 uint16_t vlan_mask;
10414 cmdline_fixed_string_t src_mask;
10415 cmdline_ipaddr_t ipv4_src;
10416 cmdline_ipaddr_t ipv6_src;
10418 cmdline_fixed_string_t dst_mask;
10419 cmdline_ipaddr_t ipv4_dst;
10420 cmdline_ipaddr_t ipv6_dst;
10422 cmdline_fixed_string_t mac;
10423 uint8_t mac_addr_byte_mask;
10424 cmdline_fixed_string_t tunnel_id;
10425 uint32_t tunnel_id_mask;
10426 cmdline_fixed_string_t tunnel_type;
10427 uint8_t tunnel_type_mask;
10431 cmd_flow_director_mask_parsed(void *parsed_result,
10432 __attribute__((unused)) struct cmdline *cl,
10433 __attribute__((unused)) void *data)
10435 struct cmd_flow_director_mask_result *res = parsed_result;
10436 struct rte_eth_fdir_masks *mask;
10437 struct rte_port *port;
10439 if (res->port_id > nb_ports) {
10440 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
10444 port = &ports[res->port_id];
10445 /** Check if the port is not started **/
10446 if (port->port_status != RTE_PORT_STOPPED) {
10447 printf("Please stop port %d first\n", res->port_id);
10451 mask = &port->dev_conf.fdir_conf.mask;
10453 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
10454 if (strcmp(res->mode_value, "MAC-VLAN")) {
10455 printf("Please set mode to MAC-VLAN.\n");
10459 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10460 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
10461 if (strcmp(res->mode_value, "Tunnel")) {
10462 printf("Please set mode to Tunnel.\n");
10466 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10467 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
10468 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
10469 mask->tunnel_type_mask = res->tunnel_type_mask;
10471 if (strcmp(res->mode_value, "IP")) {
10472 printf("Please set mode to IP.\n");
10476 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10477 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
10478 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
10479 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
10480 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
10481 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
10482 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
10485 cmd_reconfig_device_queue(res->port_id, 1, 1);
10488 cmdline_parse_token_string_t cmd_flow_director_mask =
10489 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10490 flow_director_mask, "flow_director_mask");
10491 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
10492 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10494 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
10495 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10497 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
10498 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10499 vlan_mask, UINT16);
10500 cmdline_parse_token_string_t cmd_flow_director_mask_src =
10501 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10502 src_mask, "src_mask");
10503 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
10504 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10506 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
10507 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10509 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
10510 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10512 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
10513 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10514 dst_mask, "dst_mask");
10515 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
10516 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10518 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
10519 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10521 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
10522 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10525 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
10526 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10528 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
10529 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10531 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
10532 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10533 mode_value, "MAC-VLAN");
10534 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
10535 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10536 mode_value, "Tunnel");
10537 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
10538 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10540 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
10541 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10542 mac_addr_byte_mask, UINT8);
10543 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
10544 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10545 tunnel_type, "tunnel-type");
10546 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
10547 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10548 tunnel_type_mask, UINT8);
10549 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
10550 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10551 tunnel_id, "tunnel-id");
10552 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
10553 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10554 tunnel_id_mask, UINT32);
10556 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
10557 .f = cmd_flow_director_mask_parsed,
10559 .help_str = "flow_director_mask ... : "
10560 "Set IP mode flow director's mask on NIC",
10562 (void *)&cmd_flow_director_mask,
10563 (void *)&cmd_flow_director_mask_port_id,
10564 (void *)&cmd_flow_director_mask_mode,
10565 (void *)&cmd_flow_director_mask_mode_ip,
10566 (void *)&cmd_flow_director_mask_vlan,
10567 (void *)&cmd_flow_director_mask_vlan_value,
10568 (void *)&cmd_flow_director_mask_src,
10569 (void *)&cmd_flow_director_mask_ipv4_src,
10570 (void *)&cmd_flow_director_mask_ipv6_src,
10571 (void *)&cmd_flow_director_mask_port_src,
10572 (void *)&cmd_flow_director_mask_dst,
10573 (void *)&cmd_flow_director_mask_ipv4_dst,
10574 (void *)&cmd_flow_director_mask_ipv6_dst,
10575 (void *)&cmd_flow_director_mask_port_dst,
10580 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
10581 .f = cmd_flow_director_mask_parsed,
10583 .help_str = "flow_director_mask ... : Set MAC VLAN mode "
10584 "flow director's mask on NIC",
10586 (void *)&cmd_flow_director_mask,
10587 (void *)&cmd_flow_director_mask_port_id,
10588 (void *)&cmd_flow_director_mask_mode,
10589 (void *)&cmd_flow_director_mask_mode_mac_vlan,
10590 (void *)&cmd_flow_director_mask_vlan,
10591 (void *)&cmd_flow_director_mask_vlan_value,
10596 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
10597 .f = cmd_flow_director_mask_parsed,
10599 .help_str = "flow_director_mask ... : Set tunnel mode "
10600 "flow director's mask on NIC",
10602 (void *)&cmd_flow_director_mask,
10603 (void *)&cmd_flow_director_mask_port_id,
10604 (void *)&cmd_flow_director_mask_mode,
10605 (void *)&cmd_flow_director_mask_mode_tunnel,
10606 (void *)&cmd_flow_director_mask_vlan,
10607 (void *)&cmd_flow_director_mask_vlan_value,
10608 (void *)&cmd_flow_director_mask_mac,
10609 (void *)&cmd_flow_director_mask_mac_value,
10610 (void *)&cmd_flow_director_mask_tunnel_type,
10611 (void *)&cmd_flow_director_mask_tunnel_type_value,
10612 (void *)&cmd_flow_director_mask_tunnel_id,
10613 (void *)&cmd_flow_director_mask_tunnel_id_value,
10618 /* *** deal with flow director mask on flexible payload *** */
10619 struct cmd_flow_director_flex_mask_result {
10620 cmdline_fixed_string_t flow_director_flexmask;
10622 cmdline_fixed_string_t flow;
10623 cmdline_fixed_string_t flow_type;
10624 cmdline_fixed_string_t mask;
10628 cmd_flow_director_flex_mask_parsed(void *parsed_result,
10629 __attribute__((unused)) struct cmdline *cl,
10630 __attribute__((unused)) void *data)
10632 struct cmd_flow_director_flex_mask_result *res = parsed_result;
10633 struct rte_eth_fdir_info fdir_info;
10634 struct rte_eth_fdir_flex_mask flex_mask;
10635 struct rte_port *port;
10636 uint32_t flow_type_mask;
10640 if (res->port_id > nb_ports) {
10641 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
10645 port = &ports[res->port_id];
10646 /** Check if the port is not started **/
10647 if (port->port_status != RTE_PORT_STOPPED) {
10648 printf("Please stop port %d first\n", res->port_id);
10652 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
10653 ret = parse_flexbytes(res->mask,
10655 RTE_ETH_FDIR_MAX_FLEXLEN);
10657 printf("error: Cannot parse mask input.\n");
10661 memset(&fdir_info, 0, sizeof(fdir_info));
10662 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10663 RTE_ETH_FILTER_INFO, &fdir_info);
10665 printf("Cannot get FDir filter info\n");
10669 if (!strcmp(res->flow_type, "none")) {
10670 /* means don't specify the flow type */
10671 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN;
10672 for (i = 0; i < RTE_ETH_FLOW_MAX; i++)
10673 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i],
10674 0, sizeof(struct rte_eth_fdir_flex_mask));
10675 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1;
10676 rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0],
10678 sizeof(struct rte_eth_fdir_flex_mask));
10679 cmd_reconfig_device_queue(res->port_id, 1, 1);
10682 flow_type_mask = fdir_info.flow_types_mask[0];
10683 if (!strcmp(res->flow_type, "all")) {
10684 if (!flow_type_mask) {
10685 printf("No flow type supported\n");
10688 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
10689 if (flow_type_mask & (1 << i)) {
10690 flex_mask.flow_type = i;
10691 fdir_set_flex_mask(res->port_id, &flex_mask);
10694 cmd_reconfig_device_queue(res->port_id, 1, 1);
10697 flex_mask.flow_type = str2flowtype(res->flow_type);
10698 if (!(flow_type_mask & (1 << flex_mask.flow_type))) {
10699 printf("Flow type %s not supported on port %d\n",
10700 res->flow_type, res->port_id);
10703 fdir_set_flex_mask(res->port_id, &flex_mask);
10704 cmd_reconfig_device_queue(res->port_id, 1, 1);
10707 cmdline_parse_token_string_t cmd_flow_director_flexmask =
10708 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
10709 flow_director_flexmask,
10710 "flow_director_flex_mask");
10711 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
10712 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
10714 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
10715 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
10717 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
10718 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
10719 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
10720 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all");
10721 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
10722 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
10725 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
10726 .f = cmd_flow_director_flex_mask_parsed,
10728 .help_str = "flow_director_flex_mask ... : "
10729 "Set flow director's flex mask on NIC",
10731 (void *)&cmd_flow_director_flexmask,
10732 (void *)&cmd_flow_director_flexmask_port_id,
10733 (void *)&cmd_flow_director_flexmask_flow,
10734 (void *)&cmd_flow_director_flexmask_flow_type,
10735 (void *)&cmd_flow_director_flexmask_mask,
10740 /* *** deal with flow director flexible payload configuration *** */
10741 struct cmd_flow_director_flexpayload_result {
10742 cmdline_fixed_string_t flow_director_flexpayload;
10744 cmdline_fixed_string_t payload_layer;
10745 cmdline_fixed_string_t payload_cfg;
10749 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
10752 const char *p, *p0 = q_arg;
10754 unsigned long int_fld;
10755 char *str_fld[max_num];
10760 p = strchr(p0, '(');
10764 p0 = strchr(p, ')');
10769 if (size >= sizeof(s))
10772 snprintf(s, sizeof(s), "%.*s", size, p);
10773 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
10774 if (ret < 0 || ret > max_num)
10776 for (i = 0; i < ret; i++) {
10778 int_fld = strtoul(str_fld[i], &end, 0);
10779 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
10781 offsets[i] = (uint16_t)int_fld;
10787 cmd_flow_director_flxpld_parsed(void *parsed_result,
10788 __attribute__((unused)) struct cmdline *cl,
10789 __attribute__((unused)) void *data)
10791 struct cmd_flow_director_flexpayload_result *res = parsed_result;
10792 struct rte_eth_flex_payload_cfg flex_cfg;
10793 struct rte_port *port;
10796 if (res->port_id > nb_ports) {
10797 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
10801 port = &ports[res->port_id];
10802 /** Check if the port is not started **/
10803 if (port->port_status != RTE_PORT_STOPPED) {
10804 printf("Please stop port %d first\n", res->port_id);
10808 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
10810 if (!strcmp(res->payload_layer, "raw"))
10811 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
10812 else if (!strcmp(res->payload_layer, "l2"))
10813 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
10814 else if (!strcmp(res->payload_layer, "l3"))
10815 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
10816 else if (!strcmp(res->payload_layer, "l4"))
10817 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
10819 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
10820 RTE_ETH_FDIR_MAX_FLEXLEN);
10822 printf("error: Cannot parse flex payload input.\n");
10826 fdir_set_flex_payload(res->port_id, &flex_cfg);
10827 cmd_reconfig_device_queue(res->port_id, 1, 1);
10830 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
10831 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10832 flow_director_flexpayload,
10833 "flow_director_flex_payload");
10834 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
10835 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10837 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
10838 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10839 payload_layer, "raw#l2#l3#l4");
10840 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
10841 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10842 payload_cfg, NULL);
10844 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
10845 .f = cmd_flow_director_flxpld_parsed,
10847 .help_str = "flow_director_flexpayload ... : "
10848 "Set flow director's flex payload on NIC",
10850 (void *)&cmd_flow_director_flexpayload,
10851 (void *)&cmd_flow_director_flexpayload_port_id,
10852 (void *)&cmd_flow_director_flexpayload_payload_layer,
10853 (void *)&cmd_flow_director_flexpayload_payload_cfg,
10858 /* Generic flow interface command. */
10859 extern cmdline_parse_inst_t cmd_flow;
10861 /* *** Classification Filters Control *** */
10862 /* *** Get symmetric hash enable per port *** */
10863 struct cmd_get_sym_hash_ena_per_port_result {
10864 cmdline_fixed_string_t get_sym_hash_ena_per_port;
10869 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
10870 __rte_unused struct cmdline *cl,
10871 __rte_unused void *data)
10873 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
10874 struct rte_eth_hash_filter_info info;
10877 if (rte_eth_dev_filter_supported(res->port_id,
10878 RTE_ETH_FILTER_HASH) < 0) {
10879 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
10884 memset(&info, 0, sizeof(info));
10885 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
10886 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
10887 RTE_ETH_FILTER_GET, &info);
10890 printf("Cannot get symmetric hash enable per port "
10891 "on port %u\n", res->port_id);
10895 printf("Symmetric hash is %s on port %u\n", info.info.enable ?
10896 "enabled" : "disabled", res->port_id);
10899 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
10900 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
10901 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
10902 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
10903 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
10906 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
10907 .f = cmd_get_sym_hash_per_port_parsed,
10909 .help_str = "get_sym_hash_ena_per_port <port_id>",
10911 (void *)&cmd_get_sym_hash_ena_per_port_all,
10912 (void *)&cmd_get_sym_hash_ena_per_port_port_id,
10917 /* *** Set symmetric hash enable per port *** */
10918 struct cmd_set_sym_hash_ena_per_port_result {
10919 cmdline_fixed_string_t set_sym_hash_ena_per_port;
10920 cmdline_fixed_string_t enable;
10925 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
10926 __rte_unused struct cmdline *cl,
10927 __rte_unused void *data)
10929 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
10930 struct rte_eth_hash_filter_info info;
10933 if (rte_eth_dev_filter_supported(res->port_id,
10934 RTE_ETH_FILTER_HASH) < 0) {
10935 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
10940 memset(&info, 0, sizeof(info));
10941 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
10942 if (!strcmp(res->enable, "enable"))
10943 info.info.enable = 1;
10944 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
10945 RTE_ETH_FILTER_SET, &info);
10947 printf("Cannot set symmetric hash enable per port on "
10948 "port %u\n", res->port_id);
10951 printf("Symmetric hash has been set to %s on port %u\n",
10952 res->enable, res->port_id);
10955 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
10956 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
10957 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
10958 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
10959 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
10961 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
10962 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
10963 enable, "enable#disable");
10965 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
10966 .f = cmd_set_sym_hash_per_port_parsed,
10968 .help_str = "set_sym_hash_ena_per_port <port_id> enable|disable",
10970 (void *)&cmd_set_sym_hash_ena_per_port_all,
10971 (void *)&cmd_set_sym_hash_ena_per_port_port_id,
10972 (void *)&cmd_set_sym_hash_ena_per_port_enable,
10977 /* Get global config of hash function */
10978 struct cmd_get_hash_global_config_result {
10979 cmdline_fixed_string_t get_hash_global_config;
10984 flowtype_to_str(uint16_t ftype)
10990 } ftype_table[] = {
10991 {"ipv4", RTE_ETH_FLOW_IPV4},
10992 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
10993 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
10994 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
10995 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
10996 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
10997 {"ipv6", RTE_ETH_FLOW_IPV6},
10998 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
10999 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
11000 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
11001 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
11002 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
11003 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
11004 {"port", RTE_ETH_FLOW_PORT},
11005 {"vxlan", RTE_ETH_FLOW_VXLAN},
11006 {"geneve", RTE_ETH_FLOW_GENEVE},
11007 {"nvgre", RTE_ETH_FLOW_NVGRE},
11010 for (i = 0; i < RTE_DIM(ftype_table); i++) {
11011 if (ftype_table[i].ftype == ftype)
11012 return ftype_table[i].str;
11019 cmd_get_hash_global_config_parsed(void *parsed_result,
11020 __rte_unused struct cmdline *cl,
11021 __rte_unused void *data)
11023 struct cmd_get_hash_global_config_result *res = parsed_result;
11024 struct rte_eth_hash_filter_info info;
11025 uint32_t idx, offset;
11030 if (rte_eth_dev_filter_supported(res->port_id,
11031 RTE_ETH_FILTER_HASH) < 0) {
11032 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
11037 memset(&info, 0, sizeof(info));
11038 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
11039 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11040 RTE_ETH_FILTER_GET, &info);
11042 printf("Cannot get hash global configurations by port %d\n",
11047 switch (info.info.global_conf.hash_func) {
11048 case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
11049 printf("Hash function is Toeplitz\n");
11051 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
11052 printf("Hash function is Simple XOR\n");
11055 printf("Unknown hash function\n");
11059 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) {
11060 idx = i / UINT32_BIT;
11061 offset = i % UINT32_BIT;
11062 if (!(info.info.global_conf.valid_bit_mask[idx] &
11065 str = flowtype_to_str(i);
11068 printf("Symmetric hash is %s globally for flow type %s "
11070 ((info.info.global_conf.sym_hash_enable_mask[idx] &
11071 (1UL << offset)) ? "enabled" : "disabled"), str,
11076 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
11077 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
11078 get_hash_global_config, "get_hash_global_config");
11079 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
11080 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
11083 cmdline_parse_inst_t cmd_get_hash_global_config = {
11084 .f = cmd_get_hash_global_config_parsed,
11086 .help_str = "get_hash_global_config <port_id>",
11088 (void *)&cmd_get_hash_global_config_all,
11089 (void *)&cmd_get_hash_global_config_port_id,
11094 /* Set global config of hash function */
11095 struct cmd_set_hash_global_config_result {
11096 cmdline_fixed_string_t set_hash_global_config;
11098 cmdline_fixed_string_t hash_func;
11099 cmdline_fixed_string_t flow_type;
11100 cmdline_fixed_string_t enable;
11104 cmd_set_hash_global_config_parsed(void *parsed_result,
11105 __rte_unused struct cmdline *cl,
11106 __rte_unused void *data)
11108 struct cmd_set_hash_global_config_result *res = parsed_result;
11109 struct rte_eth_hash_filter_info info;
11110 uint32_t ftype, idx, offset;
11113 if (rte_eth_dev_filter_supported(res->port_id,
11114 RTE_ETH_FILTER_HASH) < 0) {
11115 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
11119 memset(&info, 0, sizeof(info));
11120 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
11121 if (!strcmp(res->hash_func, "toeplitz"))
11122 info.info.global_conf.hash_func =
11123 RTE_ETH_HASH_FUNCTION_TOEPLITZ;
11124 else if (!strcmp(res->hash_func, "simple_xor"))
11125 info.info.global_conf.hash_func =
11126 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
11127 else if (!strcmp(res->hash_func, "default"))
11128 info.info.global_conf.hash_func =
11129 RTE_ETH_HASH_FUNCTION_DEFAULT;
11131 ftype = str2flowtype(res->flow_type);
11132 idx = ftype / (CHAR_BIT * sizeof(uint32_t));
11133 offset = ftype % (CHAR_BIT * sizeof(uint32_t));
11134 info.info.global_conf.valid_bit_mask[idx] |= (1UL << offset);
11135 if (!strcmp(res->enable, "enable"))
11136 info.info.global_conf.sym_hash_enable_mask[idx] |=
11138 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11139 RTE_ETH_FILTER_SET, &info);
11141 printf("Cannot set global hash configurations by port %d\n",
11144 printf("Global hash configurations have been set "
11145 "succcessfully by port %d\n", res->port_id);
11148 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
11149 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11150 set_hash_global_config, "set_hash_global_config");
11151 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
11152 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
11154 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
11155 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11156 hash_func, "toeplitz#simple_xor#default");
11157 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
11158 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11160 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
11161 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
11162 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
11163 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11164 enable, "enable#disable");
11166 cmdline_parse_inst_t cmd_set_hash_global_config = {
11167 .f = cmd_set_hash_global_config_parsed,
11169 .help_str = "set_hash_global_config <port_id> "
11170 "toeplitz|simple_xor|default "
11171 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
11172 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
11173 "l2_payload enable|disable",
11175 (void *)&cmd_set_hash_global_config_all,
11176 (void *)&cmd_set_hash_global_config_port_id,
11177 (void *)&cmd_set_hash_global_config_hash_func,
11178 (void *)&cmd_set_hash_global_config_flow_type,
11179 (void *)&cmd_set_hash_global_config_enable,
11184 /* Set hash input set */
11185 struct cmd_set_hash_input_set_result {
11186 cmdline_fixed_string_t set_hash_input_set;
11188 cmdline_fixed_string_t flow_type;
11189 cmdline_fixed_string_t inset_field;
11190 cmdline_fixed_string_t select;
11193 static enum rte_eth_input_set_field
11194 str2inset(char *string)
11198 static const struct {
11200 enum rte_eth_input_set_field inset;
11201 } inset_table[] = {
11202 {"ethertype", RTE_ETH_INPUT_SET_L2_ETHERTYPE},
11203 {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN},
11204 {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN},
11205 {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4},
11206 {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4},
11207 {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS},
11208 {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO},
11209 {"ipv4-ttl", RTE_ETH_INPUT_SET_L3_IP4_TTL},
11210 {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6},
11211 {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6},
11212 {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC},
11213 {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER},
11214 {"ipv6-hop-limits", RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS},
11215 {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT},
11216 {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT},
11217 {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT},
11218 {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT},
11219 {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT},
11220 {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT},
11221 {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG},
11222 {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY},
11223 {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY},
11224 {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD},
11225 {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD},
11226 {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD},
11227 {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD},
11228 {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD},
11229 {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD},
11230 {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD},
11231 {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD},
11232 {"none", RTE_ETH_INPUT_SET_NONE},
11235 for (i = 0; i < RTE_DIM(inset_table); i++) {
11236 if (!strcmp(string, inset_table[i].str))
11237 return inset_table[i].inset;
11240 return RTE_ETH_INPUT_SET_UNKNOWN;
11244 cmd_set_hash_input_set_parsed(void *parsed_result,
11245 __rte_unused struct cmdline *cl,
11246 __rte_unused void *data)
11248 struct cmd_set_hash_input_set_result *res = parsed_result;
11249 struct rte_eth_hash_filter_info info;
11251 memset(&info, 0, sizeof(info));
11252 info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT;
11253 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
11254 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
11255 info.info.input_set_conf.inset_size = 1;
11256 if (!strcmp(res->select, "select"))
11257 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
11258 else if (!strcmp(res->select, "add"))
11259 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
11260 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11261 RTE_ETH_FILTER_SET, &info);
11264 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd =
11265 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
11266 set_hash_input_set, "set_hash_input_set");
11267 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id =
11268 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result,
11270 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type =
11271 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
11273 cmdline_parse_token_string_t cmd_set_hash_input_set_field =
11274 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
11276 "ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
11277 "ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#"
11278 "udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#"
11279 "sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#"
11280 "fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#"
11282 cmdline_parse_token_string_t cmd_set_hash_input_set_select =
11283 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
11284 select, "select#add");
11286 cmdline_parse_inst_t cmd_set_hash_input_set = {
11287 .f = cmd_set_hash_input_set_parsed,
11289 .help_str = "set_hash_input_set <port_id> "
11290 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
11291 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload|<flowtype_id> "
11292 "ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|"
11293 "ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|"
11294 "tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|"
11295 "gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
11296 "fld-7th|fld-8th|none select|add",
11298 (void *)&cmd_set_hash_input_set_cmd,
11299 (void *)&cmd_set_hash_input_set_port_id,
11300 (void *)&cmd_set_hash_input_set_flow_type,
11301 (void *)&cmd_set_hash_input_set_field,
11302 (void *)&cmd_set_hash_input_set_select,
11307 /* Set flow director input set */
11308 struct cmd_set_fdir_input_set_result {
11309 cmdline_fixed_string_t set_fdir_input_set;
11311 cmdline_fixed_string_t flow_type;
11312 cmdline_fixed_string_t inset_field;
11313 cmdline_fixed_string_t select;
11317 cmd_set_fdir_input_set_parsed(void *parsed_result,
11318 __rte_unused struct cmdline *cl,
11319 __rte_unused void *data)
11321 struct cmd_set_fdir_input_set_result *res = parsed_result;
11322 struct rte_eth_fdir_filter_info info;
11324 memset(&info, 0, sizeof(info));
11325 info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT;
11326 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
11327 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
11328 info.info.input_set_conf.inset_size = 1;
11329 if (!strcmp(res->select, "select"))
11330 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
11331 else if (!strcmp(res->select, "add"))
11332 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
11333 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11334 RTE_ETH_FILTER_SET, &info);
11337 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd =
11338 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
11339 set_fdir_input_set, "set_fdir_input_set");
11340 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id =
11341 TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result,
11343 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type =
11344 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
11346 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
11347 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
11348 cmdline_parse_token_string_t cmd_set_fdir_input_set_field =
11349 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
11351 "ivlan#ethertype#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
11352 "ipv4-tos#ipv4-proto#ipv4-ttl#ipv6-tc#ipv6-next-header#"
11353 "ipv6-hop-limits#udp-src-port#udp-dst-port#"
11354 "tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#"
11355 "sctp-veri-tag#none");
11356 cmdline_parse_token_string_t cmd_set_fdir_input_set_select =
11357 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
11358 select, "select#add");
11360 cmdline_parse_inst_t cmd_set_fdir_input_set = {
11361 .f = cmd_set_fdir_input_set_parsed,
11363 .help_str = "set_fdir_input_set <port_id> "
11364 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
11365 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
11366 "ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|"
11367 "ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|ipv6-next-header|"
11368 "ipv6-hop-limits|udp-src-port|udp-dst-port|"
11369 "tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|"
11370 "sctp-veri-tag|none select|add",
11372 (void *)&cmd_set_fdir_input_set_cmd,
11373 (void *)&cmd_set_fdir_input_set_port_id,
11374 (void *)&cmd_set_fdir_input_set_flow_type,
11375 (void *)&cmd_set_fdir_input_set_field,
11376 (void *)&cmd_set_fdir_input_set_select,
11381 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
11382 struct cmd_mcast_addr_result {
11383 cmdline_fixed_string_t mcast_addr_cmd;
11384 cmdline_fixed_string_t what;
11386 struct ether_addr mc_addr;
11389 static void cmd_mcast_addr_parsed(void *parsed_result,
11390 __attribute__((unused)) struct cmdline *cl,
11391 __attribute__((unused)) void *data)
11393 struct cmd_mcast_addr_result *res = parsed_result;
11395 if (!is_multicast_ether_addr(&res->mc_addr)) {
11396 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
11397 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
11398 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
11399 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
11402 if (strcmp(res->what, "add") == 0)
11403 mcast_addr_add(res->port_num, &res->mc_addr);
11405 mcast_addr_remove(res->port_num, &res->mc_addr);
11408 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
11409 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
11410 mcast_addr_cmd, "mcast_addr");
11411 cmdline_parse_token_string_t cmd_mcast_addr_what =
11412 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
11414 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
11415 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT16);
11416 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
11417 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
11419 cmdline_parse_inst_t cmd_mcast_addr = {
11420 .f = cmd_mcast_addr_parsed,
11422 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
11423 "Add/Remove multicast MAC address on port_id",
11425 (void *)&cmd_mcast_addr_cmd,
11426 (void *)&cmd_mcast_addr_what,
11427 (void *)&cmd_mcast_addr_portnum,
11428 (void *)&cmd_mcast_addr_addr,
11433 /* l2 tunnel config
11434 * only support E-tag now.
11437 /* Ether type config */
11438 struct cmd_config_l2_tunnel_eth_type_result {
11439 cmdline_fixed_string_t port;
11440 cmdline_fixed_string_t config;
11441 cmdline_fixed_string_t all;
11443 cmdline_fixed_string_t l2_tunnel;
11444 cmdline_fixed_string_t l2_tunnel_type;
11445 cmdline_fixed_string_t eth_type;
11446 uint16_t eth_type_val;
11449 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port =
11450 TOKEN_STRING_INITIALIZER
11451 (struct cmd_config_l2_tunnel_eth_type_result,
11453 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config =
11454 TOKEN_STRING_INITIALIZER
11455 (struct cmd_config_l2_tunnel_eth_type_result,
11457 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str =
11458 TOKEN_STRING_INITIALIZER
11459 (struct cmd_config_l2_tunnel_eth_type_result,
11461 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id =
11462 TOKEN_NUM_INITIALIZER
11463 (struct cmd_config_l2_tunnel_eth_type_result,
11465 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel =
11466 TOKEN_STRING_INITIALIZER
11467 (struct cmd_config_l2_tunnel_eth_type_result,
11468 l2_tunnel, "l2-tunnel");
11469 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type =
11470 TOKEN_STRING_INITIALIZER
11471 (struct cmd_config_l2_tunnel_eth_type_result,
11472 l2_tunnel_type, "E-tag");
11473 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type =
11474 TOKEN_STRING_INITIALIZER
11475 (struct cmd_config_l2_tunnel_eth_type_result,
11476 eth_type, "ether-type");
11477 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val =
11478 TOKEN_NUM_INITIALIZER
11479 (struct cmd_config_l2_tunnel_eth_type_result,
11480 eth_type_val, UINT16);
11482 static enum rte_eth_tunnel_type
11483 str2fdir_l2_tunnel_type(char *string)
11487 static const struct {
11489 enum rte_eth_tunnel_type type;
11490 } l2_tunnel_type_str[] = {
11491 {"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG},
11494 for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) {
11495 if (!strcmp(l2_tunnel_type_str[i].str, string))
11496 return l2_tunnel_type_str[i].type;
11498 return RTE_TUNNEL_TYPE_NONE;
11501 /* ether type config for all ports */
11503 cmd_config_l2_tunnel_eth_type_all_parsed
11504 (void *parsed_result,
11505 __attribute__((unused)) struct cmdline *cl,
11506 __attribute__((unused)) void *data)
11508 struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result;
11509 struct rte_eth_l2_tunnel_conf entry;
11512 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
11513 entry.ether_type = res->eth_type_val;
11515 RTE_ETH_FOREACH_DEV(pid) {
11516 rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry);
11520 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = {
11521 .f = cmd_config_l2_tunnel_eth_type_all_parsed,
11523 .help_str = "port config all l2-tunnel E-tag ether-type <value>",
11525 (void *)&cmd_config_l2_tunnel_eth_type_port,
11526 (void *)&cmd_config_l2_tunnel_eth_type_config,
11527 (void *)&cmd_config_l2_tunnel_eth_type_all_str,
11528 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
11529 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
11530 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
11531 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
11536 /* ether type config for a specific port */
11538 cmd_config_l2_tunnel_eth_type_specific_parsed(
11539 void *parsed_result,
11540 __attribute__((unused)) struct cmdline *cl,
11541 __attribute__((unused)) void *data)
11543 struct cmd_config_l2_tunnel_eth_type_result *res =
11545 struct rte_eth_l2_tunnel_conf entry;
11547 if (port_id_is_invalid(res->id, ENABLED_WARN))
11550 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
11551 entry.ether_type = res->eth_type_val;
11553 rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry);
11556 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = {
11557 .f = cmd_config_l2_tunnel_eth_type_specific_parsed,
11559 .help_str = "port config <port_id> l2-tunnel E-tag ether-type <value>",
11561 (void *)&cmd_config_l2_tunnel_eth_type_port,
11562 (void *)&cmd_config_l2_tunnel_eth_type_config,
11563 (void *)&cmd_config_l2_tunnel_eth_type_id,
11564 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
11565 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
11566 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
11567 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
11572 /* Enable/disable l2 tunnel */
11573 struct cmd_config_l2_tunnel_en_dis_result {
11574 cmdline_fixed_string_t port;
11575 cmdline_fixed_string_t config;
11576 cmdline_fixed_string_t all;
11578 cmdline_fixed_string_t l2_tunnel;
11579 cmdline_fixed_string_t l2_tunnel_type;
11580 cmdline_fixed_string_t en_dis;
11583 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port =
11584 TOKEN_STRING_INITIALIZER
11585 (struct cmd_config_l2_tunnel_en_dis_result,
11587 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config =
11588 TOKEN_STRING_INITIALIZER
11589 (struct cmd_config_l2_tunnel_en_dis_result,
11591 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str =
11592 TOKEN_STRING_INITIALIZER
11593 (struct cmd_config_l2_tunnel_en_dis_result,
11595 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id =
11596 TOKEN_NUM_INITIALIZER
11597 (struct cmd_config_l2_tunnel_en_dis_result,
11599 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel =
11600 TOKEN_STRING_INITIALIZER
11601 (struct cmd_config_l2_tunnel_en_dis_result,
11602 l2_tunnel, "l2-tunnel");
11603 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type =
11604 TOKEN_STRING_INITIALIZER
11605 (struct cmd_config_l2_tunnel_en_dis_result,
11606 l2_tunnel_type, "E-tag");
11607 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis =
11608 TOKEN_STRING_INITIALIZER
11609 (struct cmd_config_l2_tunnel_en_dis_result,
11610 en_dis, "enable#disable");
11612 /* enable/disable l2 tunnel for all ports */
11614 cmd_config_l2_tunnel_en_dis_all_parsed(
11615 void *parsed_result,
11616 __attribute__((unused)) struct cmdline *cl,
11617 __attribute__((unused)) void *data)
11619 struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result;
11620 struct rte_eth_l2_tunnel_conf entry;
11624 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
11626 if (!strcmp("enable", res->en_dis))
11631 RTE_ETH_FOREACH_DEV(pid) {
11632 rte_eth_dev_l2_tunnel_offload_set(pid,
11634 ETH_L2_TUNNEL_ENABLE_MASK,
11639 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = {
11640 .f = cmd_config_l2_tunnel_en_dis_all_parsed,
11642 .help_str = "port config all l2-tunnel E-tag enable|disable",
11644 (void *)&cmd_config_l2_tunnel_en_dis_port,
11645 (void *)&cmd_config_l2_tunnel_en_dis_config,
11646 (void *)&cmd_config_l2_tunnel_en_dis_all_str,
11647 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
11648 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
11649 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
11654 /* enable/disable l2 tunnel for a port */
11656 cmd_config_l2_tunnel_en_dis_specific_parsed(
11657 void *parsed_result,
11658 __attribute__((unused)) struct cmdline *cl,
11659 __attribute__((unused)) void *data)
11661 struct cmd_config_l2_tunnel_en_dis_result *res =
11663 struct rte_eth_l2_tunnel_conf entry;
11665 if (port_id_is_invalid(res->id, ENABLED_WARN))
11668 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
11670 if (!strcmp("enable", res->en_dis))
11671 rte_eth_dev_l2_tunnel_offload_set(res->id,
11673 ETH_L2_TUNNEL_ENABLE_MASK,
11676 rte_eth_dev_l2_tunnel_offload_set(res->id,
11678 ETH_L2_TUNNEL_ENABLE_MASK,
11682 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = {
11683 .f = cmd_config_l2_tunnel_en_dis_specific_parsed,
11685 .help_str = "port config <port_id> l2-tunnel E-tag enable|disable",
11687 (void *)&cmd_config_l2_tunnel_en_dis_port,
11688 (void *)&cmd_config_l2_tunnel_en_dis_config,
11689 (void *)&cmd_config_l2_tunnel_en_dis_id,
11690 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
11691 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
11692 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
11697 /* E-tag configuration */
11699 /* Common result structure for all E-tag configuration */
11700 struct cmd_config_e_tag_result {
11701 cmdline_fixed_string_t e_tag;
11702 cmdline_fixed_string_t set;
11703 cmdline_fixed_string_t insertion;
11704 cmdline_fixed_string_t stripping;
11705 cmdline_fixed_string_t forwarding;
11706 cmdline_fixed_string_t filter;
11707 cmdline_fixed_string_t add;
11708 cmdline_fixed_string_t del;
11709 cmdline_fixed_string_t on;
11710 cmdline_fixed_string_t off;
11711 cmdline_fixed_string_t on_off;
11712 cmdline_fixed_string_t port_tag_id;
11713 uint32_t port_tag_id_val;
11714 cmdline_fixed_string_t e_tag_id;
11715 uint16_t e_tag_id_val;
11716 cmdline_fixed_string_t dst_pool;
11717 uint8_t dst_pool_val;
11718 cmdline_fixed_string_t port;
11720 cmdline_fixed_string_t vf;
11724 /* Common CLI fields for all E-tag configuration */
11725 cmdline_parse_token_string_t cmd_config_e_tag_e_tag =
11726 TOKEN_STRING_INITIALIZER
11727 (struct cmd_config_e_tag_result,
11729 cmdline_parse_token_string_t cmd_config_e_tag_set =
11730 TOKEN_STRING_INITIALIZER
11731 (struct cmd_config_e_tag_result,
11733 cmdline_parse_token_string_t cmd_config_e_tag_insertion =
11734 TOKEN_STRING_INITIALIZER
11735 (struct cmd_config_e_tag_result,
11736 insertion, "insertion");
11737 cmdline_parse_token_string_t cmd_config_e_tag_stripping =
11738 TOKEN_STRING_INITIALIZER
11739 (struct cmd_config_e_tag_result,
11740 stripping, "stripping");
11741 cmdline_parse_token_string_t cmd_config_e_tag_forwarding =
11742 TOKEN_STRING_INITIALIZER
11743 (struct cmd_config_e_tag_result,
11744 forwarding, "forwarding");
11745 cmdline_parse_token_string_t cmd_config_e_tag_filter =
11746 TOKEN_STRING_INITIALIZER
11747 (struct cmd_config_e_tag_result,
11749 cmdline_parse_token_string_t cmd_config_e_tag_add =
11750 TOKEN_STRING_INITIALIZER
11751 (struct cmd_config_e_tag_result,
11753 cmdline_parse_token_string_t cmd_config_e_tag_del =
11754 TOKEN_STRING_INITIALIZER
11755 (struct cmd_config_e_tag_result,
11757 cmdline_parse_token_string_t cmd_config_e_tag_on =
11758 TOKEN_STRING_INITIALIZER
11759 (struct cmd_config_e_tag_result,
11761 cmdline_parse_token_string_t cmd_config_e_tag_off =
11762 TOKEN_STRING_INITIALIZER
11763 (struct cmd_config_e_tag_result,
11765 cmdline_parse_token_string_t cmd_config_e_tag_on_off =
11766 TOKEN_STRING_INITIALIZER
11767 (struct cmd_config_e_tag_result,
11769 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id =
11770 TOKEN_STRING_INITIALIZER
11771 (struct cmd_config_e_tag_result,
11772 port_tag_id, "port-tag-id");
11773 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val =
11774 TOKEN_NUM_INITIALIZER
11775 (struct cmd_config_e_tag_result,
11776 port_tag_id_val, UINT32);
11777 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id =
11778 TOKEN_STRING_INITIALIZER
11779 (struct cmd_config_e_tag_result,
11780 e_tag_id, "e-tag-id");
11781 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val =
11782 TOKEN_NUM_INITIALIZER
11783 (struct cmd_config_e_tag_result,
11784 e_tag_id_val, UINT16);
11785 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool =
11786 TOKEN_STRING_INITIALIZER
11787 (struct cmd_config_e_tag_result,
11788 dst_pool, "dst-pool");
11789 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val =
11790 TOKEN_NUM_INITIALIZER
11791 (struct cmd_config_e_tag_result,
11792 dst_pool_val, UINT8);
11793 cmdline_parse_token_string_t cmd_config_e_tag_port =
11794 TOKEN_STRING_INITIALIZER
11795 (struct cmd_config_e_tag_result,
11797 cmdline_parse_token_num_t cmd_config_e_tag_port_id =
11798 TOKEN_NUM_INITIALIZER
11799 (struct cmd_config_e_tag_result,
11801 cmdline_parse_token_string_t cmd_config_e_tag_vf =
11802 TOKEN_STRING_INITIALIZER
11803 (struct cmd_config_e_tag_result,
11805 cmdline_parse_token_num_t cmd_config_e_tag_vf_id =
11806 TOKEN_NUM_INITIALIZER
11807 (struct cmd_config_e_tag_result,
11810 /* E-tag insertion configuration */
11812 cmd_config_e_tag_insertion_en_parsed(
11813 void *parsed_result,
11814 __attribute__((unused)) struct cmdline *cl,
11815 __attribute__((unused)) void *data)
11817 struct cmd_config_e_tag_result *res =
11819 struct rte_eth_l2_tunnel_conf entry;
11821 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11824 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
11825 entry.tunnel_id = res->port_tag_id_val;
11826 entry.vf_id = res->vf_id;
11827 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
11829 ETH_L2_TUNNEL_INSERTION_MASK,
11834 cmd_config_e_tag_insertion_dis_parsed(
11835 void *parsed_result,
11836 __attribute__((unused)) struct cmdline *cl,
11837 __attribute__((unused)) void *data)
11839 struct cmd_config_e_tag_result *res =
11841 struct rte_eth_l2_tunnel_conf entry;
11843 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11846 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
11847 entry.vf_id = res->vf_id;
11849 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
11851 ETH_L2_TUNNEL_INSERTION_MASK,
11855 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = {
11856 .f = cmd_config_e_tag_insertion_en_parsed,
11858 .help_str = "E-tag ... : E-tag insertion enable",
11860 (void *)&cmd_config_e_tag_e_tag,
11861 (void *)&cmd_config_e_tag_set,
11862 (void *)&cmd_config_e_tag_insertion,
11863 (void *)&cmd_config_e_tag_on,
11864 (void *)&cmd_config_e_tag_port_tag_id,
11865 (void *)&cmd_config_e_tag_port_tag_id_val,
11866 (void *)&cmd_config_e_tag_port,
11867 (void *)&cmd_config_e_tag_port_id,
11868 (void *)&cmd_config_e_tag_vf,
11869 (void *)&cmd_config_e_tag_vf_id,
11874 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = {
11875 .f = cmd_config_e_tag_insertion_dis_parsed,
11877 .help_str = "E-tag ... : E-tag insertion disable",
11879 (void *)&cmd_config_e_tag_e_tag,
11880 (void *)&cmd_config_e_tag_set,
11881 (void *)&cmd_config_e_tag_insertion,
11882 (void *)&cmd_config_e_tag_off,
11883 (void *)&cmd_config_e_tag_port,
11884 (void *)&cmd_config_e_tag_port_id,
11885 (void *)&cmd_config_e_tag_vf,
11886 (void *)&cmd_config_e_tag_vf_id,
11891 /* E-tag stripping configuration */
11893 cmd_config_e_tag_stripping_parsed(
11894 void *parsed_result,
11895 __attribute__((unused)) struct cmdline *cl,
11896 __attribute__((unused)) void *data)
11898 struct cmd_config_e_tag_result *res =
11900 struct rte_eth_l2_tunnel_conf entry;
11902 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11905 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
11907 if (!strcmp(res->on_off, "on"))
11908 rte_eth_dev_l2_tunnel_offload_set
11911 ETH_L2_TUNNEL_STRIPPING_MASK,
11914 rte_eth_dev_l2_tunnel_offload_set
11917 ETH_L2_TUNNEL_STRIPPING_MASK,
11921 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = {
11922 .f = cmd_config_e_tag_stripping_parsed,
11924 .help_str = "E-tag ... : E-tag stripping enable/disable",
11926 (void *)&cmd_config_e_tag_e_tag,
11927 (void *)&cmd_config_e_tag_set,
11928 (void *)&cmd_config_e_tag_stripping,
11929 (void *)&cmd_config_e_tag_on_off,
11930 (void *)&cmd_config_e_tag_port,
11931 (void *)&cmd_config_e_tag_port_id,
11936 /* E-tag forwarding configuration */
11938 cmd_config_e_tag_forwarding_parsed(
11939 void *parsed_result,
11940 __attribute__((unused)) struct cmdline *cl,
11941 __attribute__((unused)) void *data)
11943 struct cmd_config_e_tag_result *res = parsed_result;
11944 struct rte_eth_l2_tunnel_conf entry;
11946 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11949 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
11951 if (!strcmp(res->on_off, "on"))
11952 rte_eth_dev_l2_tunnel_offload_set
11955 ETH_L2_TUNNEL_FORWARDING_MASK,
11958 rte_eth_dev_l2_tunnel_offload_set
11961 ETH_L2_TUNNEL_FORWARDING_MASK,
11965 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = {
11966 .f = cmd_config_e_tag_forwarding_parsed,
11968 .help_str = "E-tag ... : E-tag forwarding enable/disable",
11970 (void *)&cmd_config_e_tag_e_tag,
11971 (void *)&cmd_config_e_tag_set,
11972 (void *)&cmd_config_e_tag_forwarding,
11973 (void *)&cmd_config_e_tag_on_off,
11974 (void *)&cmd_config_e_tag_port,
11975 (void *)&cmd_config_e_tag_port_id,
11980 /* E-tag filter configuration */
11982 cmd_config_e_tag_filter_add_parsed(
11983 void *parsed_result,
11984 __attribute__((unused)) struct cmdline *cl,
11985 __attribute__((unused)) void *data)
11987 struct cmd_config_e_tag_result *res = parsed_result;
11988 struct rte_eth_l2_tunnel_conf entry;
11991 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11994 if (res->e_tag_id_val > 0x3fff) {
11995 printf("e-tag-id must be equal or less than 0x3fff.\n");
11999 ret = rte_eth_dev_filter_supported(res->port_id,
12000 RTE_ETH_FILTER_L2_TUNNEL);
12002 printf("E-tag filter is not supported on port %u.\n",
12007 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12008 entry.tunnel_id = res->e_tag_id_val;
12009 entry.pool = res->dst_pool_val;
12011 ret = rte_eth_dev_filter_ctrl(res->port_id,
12012 RTE_ETH_FILTER_L2_TUNNEL,
12013 RTE_ETH_FILTER_ADD,
12016 printf("E-tag filter programming error: (%s)\n",
12020 cmdline_parse_inst_t cmd_config_e_tag_filter_add = {
12021 .f = cmd_config_e_tag_filter_add_parsed,
12023 .help_str = "E-tag ... : E-tag filter add",
12025 (void *)&cmd_config_e_tag_e_tag,
12026 (void *)&cmd_config_e_tag_set,
12027 (void *)&cmd_config_e_tag_filter,
12028 (void *)&cmd_config_e_tag_add,
12029 (void *)&cmd_config_e_tag_e_tag_id,
12030 (void *)&cmd_config_e_tag_e_tag_id_val,
12031 (void *)&cmd_config_e_tag_dst_pool,
12032 (void *)&cmd_config_e_tag_dst_pool_val,
12033 (void *)&cmd_config_e_tag_port,
12034 (void *)&cmd_config_e_tag_port_id,
12040 cmd_config_e_tag_filter_del_parsed(
12041 void *parsed_result,
12042 __attribute__((unused)) struct cmdline *cl,
12043 __attribute__((unused)) void *data)
12045 struct cmd_config_e_tag_result *res = parsed_result;
12046 struct rte_eth_l2_tunnel_conf entry;
12049 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12052 if (res->e_tag_id_val > 0x3fff) {
12053 printf("e-tag-id must be less than 0x3fff.\n");
12057 ret = rte_eth_dev_filter_supported(res->port_id,
12058 RTE_ETH_FILTER_L2_TUNNEL);
12060 printf("E-tag filter is not supported on port %u.\n",
12065 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12066 entry.tunnel_id = res->e_tag_id_val;
12068 ret = rte_eth_dev_filter_ctrl(res->port_id,
12069 RTE_ETH_FILTER_L2_TUNNEL,
12070 RTE_ETH_FILTER_DELETE,
12073 printf("E-tag filter programming error: (%s)\n",
12077 cmdline_parse_inst_t cmd_config_e_tag_filter_del = {
12078 .f = cmd_config_e_tag_filter_del_parsed,
12080 .help_str = "E-tag ... : E-tag filter delete",
12082 (void *)&cmd_config_e_tag_e_tag,
12083 (void *)&cmd_config_e_tag_set,
12084 (void *)&cmd_config_e_tag_filter,
12085 (void *)&cmd_config_e_tag_del,
12086 (void *)&cmd_config_e_tag_e_tag_id,
12087 (void *)&cmd_config_e_tag_e_tag_id_val,
12088 (void *)&cmd_config_e_tag_port,
12089 (void *)&cmd_config_e_tag_port_id,
12094 /* vf vlan anti spoof configuration */
12096 /* Common result structure for vf vlan anti spoof */
12097 struct cmd_vf_vlan_anti_spoof_result {
12098 cmdline_fixed_string_t set;
12099 cmdline_fixed_string_t vf;
12100 cmdline_fixed_string_t vlan;
12101 cmdline_fixed_string_t antispoof;
12104 cmdline_fixed_string_t on_off;
12107 /* Common CLI fields for vf vlan anti spoof enable disable */
12108 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
12109 TOKEN_STRING_INITIALIZER
12110 (struct cmd_vf_vlan_anti_spoof_result,
12112 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
12113 TOKEN_STRING_INITIALIZER
12114 (struct cmd_vf_vlan_anti_spoof_result,
12116 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
12117 TOKEN_STRING_INITIALIZER
12118 (struct cmd_vf_vlan_anti_spoof_result,
12120 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
12121 TOKEN_STRING_INITIALIZER
12122 (struct cmd_vf_vlan_anti_spoof_result,
12123 antispoof, "antispoof");
12124 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
12125 TOKEN_NUM_INITIALIZER
12126 (struct cmd_vf_vlan_anti_spoof_result,
12128 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
12129 TOKEN_NUM_INITIALIZER
12130 (struct cmd_vf_vlan_anti_spoof_result,
12132 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
12133 TOKEN_STRING_INITIALIZER
12134 (struct cmd_vf_vlan_anti_spoof_result,
12138 cmd_set_vf_vlan_anti_spoof_parsed(
12139 void *parsed_result,
12140 __attribute__((unused)) struct cmdline *cl,
12141 __attribute__((unused)) void *data)
12143 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
12144 int ret = -ENOTSUP;
12146 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12148 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12151 #ifdef RTE_LIBRTE_IXGBE_PMD
12152 if (ret == -ENOTSUP)
12153 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
12154 res->vf_id, is_on);
12156 #ifdef RTE_LIBRTE_I40E_PMD
12157 if (ret == -ENOTSUP)
12158 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
12159 res->vf_id, is_on);
12161 #ifdef RTE_LIBRTE_BNXT_PMD
12162 if (ret == -ENOTSUP)
12163 ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
12164 res->vf_id, is_on);
12171 printf("invalid vf_id %d\n", res->vf_id);
12174 printf("invalid port_id %d\n", res->port_id);
12177 printf("function not implemented\n");
12180 printf("programming error: (%s)\n", strerror(-ret));
12184 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
12185 .f = cmd_set_vf_vlan_anti_spoof_parsed,
12187 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
12189 (void *)&cmd_vf_vlan_anti_spoof_set,
12190 (void *)&cmd_vf_vlan_anti_spoof_vf,
12191 (void *)&cmd_vf_vlan_anti_spoof_vlan,
12192 (void *)&cmd_vf_vlan_anti_spoof_antispoof,
12193 (void *)&cmd_vf_vlan_anti_spoof_port_id,
12194 (void *)&cmd_vf_vlan_anti_spoof_vf_id,
12195 (void *)&cmd_vf_vlan_anti_spoof_on_off,
12200 /* vf mac anti spoof configuration */
12202 /* Common result structure for vf mac anti spoof */
12203 struct cmd_vf_mac_anti_spoof_result {
12204 cmdline_fixed_string_t set;
12205 cmdline_fixed_string_t vf;
12206 cmdline_fixed_string_t mac;
12207 cmdline_fixed_string_t antispoof;
12210 cmdline_fixed_string_t on_off;
12213 /* Common CLI fields for vf mac anti spoof enable disable */
12214 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
12215 TOKEN_STRING_INITIALIZER
12216 (struct cmd_vf_mac_anti_spoof_result,
12218 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
12219 TOKEN_STRING_INITIALIZER
12220 (struct cmd_vf_mac_anti_spoof_result,
12222 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
12223 TOKEN_STRING_INITIALIZER
12224 (struct cmd_vf_mac_anti_spoof_result,
12226 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
12227 TOKEN_STRING_INITIALIZER
12228 (struct cmd_vf_mac_anti_spoof_result,
12229 antispoof, "antispoof");
12230 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
12231 TOKEN_NUM_INITIALIZER
12232 (struct cmd_vf_mac_anti_spoof_result,
12234 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
12235 TOKEN_NUM_INITIALIZER
12236 (struct cmd_vf_mac_anti_spoof_result,
12238 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
12239 TOKEN_STRING_INITIALIZER
12240 (struct cmd_vf_mac_anti_spoof_result,
12244 cmd_set_vf_mac_anti_spoof_parsed(
12245 void *parsed_result,
12246 __attribute__((unused)) struct cmdline *cl,
12247 __attribute__((unused)) void *data)
12249 struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
12250 int ret = -ENOTSUP;
12252 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12254 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12257 #ifdef RTE_LIBRTE_IXGBE_PMD
12258 if (ret == -ENOTSUP)
12259 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
12260 res->vf_id, is_on);
12262 #ifdef RTE_LIBRTE_I40E_PMD
12263 if (ret == -ENOTSUP)
12264 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
12265 res->vf_id, is_on);
12267 #ifdef RTE_LIBRTE_BNXT_PMD
12268 if (ret == -ENOTSUP)
12269 ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
12270 res->vf_id, is_on);
12277 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12280 printf("invalid port_id %d\n", res->port_id);
12283 printf("function not implemented\n");
12286 printf("programming error: (%s)\n", strerror(-ret));
12290 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
12291 .f = cmd_set_vf_mac_anti_spoof_parsed,
12293 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
12295 (void *)&cmd_vf_mac_anti_spoof_set,
12296 (void *)&cmd_vf_mac_anti_spoof_vf,
12297 (void *)&cmd_vf_mac_anti_spoof_mac,
12298 (void *)&cmd_vf_mac_anti_spoof_antispoof,
12299 (void *)&cmd_vf_mac_anti_spoof_port_id,
12300 (void *)&cmd_vf_mac_anti_spoof_vf_id,
12301 (void *)&cmd_vf_mac_anti_spoof_on_off,
12306 /* vf vlan strip queue configuration */
12308 /* Common result structure for vf mac anti spoof */
12309 struct cmd_vf_vlan_stripq_result {
12310 cmdline_fixed_string_t set;
12311 cmdline_fixed_string_t vf;
12312 cmdline_fixed_string_t vlan;
12313 cmdline_fixed_string_t stripq;
12316 cmdline_fixed_string_t on_off;
12319 /* Common CLI fields for vf vlan strip enable disable */
12320 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
12321 TOKEN_STRING_INITIALIZER
12322 (struct cmd_vf_vlan_stripq_result,
12324 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
12325 TOKEN_STRING_INITIALIZER
12326 (struct cmd_vf_vlan_stripq_result,
12328 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
12329 TOKEN_STRING_INITIALIZER
12330 (struct cmd_vf_vlan_stripq_result,
12332 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
12333 TOKEN_STRING_INITIALIZER
12334 (struct cmd_vf_vlan_stripq_result,
12336 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
12337 TOKEN_NUM_INITIALIZER
12338 (struct cmd_vf_vlan_stripq_result,
12340 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
12341 TOKEN_NUM_INITIALIZER
12342 (struct cmd_vf_vlan_stripq_result,
12344 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
12345 TOKEN_STRING_INITIALIZER
12346 (struct cmd_vf_vlan_stripq_result,
12350 cmd_set_vf_vlan_stripq_parsed(
12351 void *parsed_result,
12352 __attribute__((unused)) struct cmdline *cl,
12353 __attribute__((unused)) void *data)
12355 struct cmd_vf_vlan_stripq_result *res = parsed_result;
12356 int ret = -ENOTSUP;
12358 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12360 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12363 #ifdef RTE_LIBRTE_IXGBE_PMD
12364 if (ret == -ENOTSUP)
12365 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
12366 res->vf_id, is_on);
12368 #ifdef RTE_LIBRTE_I40E_PMD
12369 if (ret == -ENOTSUP)
12370 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
12371 res->vf_id, is_on);
12373 #ifdef RTE_LIBRTE_BNXT_PMD
12374 if (ret == -ENOTSUP)
12375 ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
12376 res->vf_id, is_on);
12383 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12386 printf("invalid port_id %d\n", res->port_id);
12389 printf("function not implemented\n");
12392 printf("programming error: (%s)\n", strerror(-ret));
12396 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
12397 .f = cmd_set_vf_vlan_stripq_parsed,
12399 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
12401 (void *)&cmd_vf_vlan_stripq_set,
12402 (void *)&cmd_vf_vlan_stripq_vf,
12403 (void *)&cmd_vf_vlan_stripq_vlan,
12404 (void *)&cmd_vf_vlan_stripq_stripq,
12405 (void *)&cmd_vf_vlan_stripq_port_id,
12406 (void *)&cmd_vf_vlan_stripq_vf_id,
12407 (void *)&cmd_vf_vlan_stripq_on_off,
12412 /* vf vlan insert configuration */
12414 /* Common result structure for vf vlan insert */
12415 struct cmd_vf_vlan_insert_result {
12416 cmdline_fixed_string_t set;
12417 cmdline_fixed_string_t vf;
12418 cmdline_fixed_string_t vlan;
12419 cmdline_fixed_string_t insert;
12425 /* Common CLI fields for vf vlan insert enable disable */
12426 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
12427 TOKEN_STRING_INITIALIZER
12428 (struct cmd_vf_vlan_insert_result,
12430 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
12431 TOKEN_STRING_INITIALIZER
12432 (struct cmd_vf_vlan_insert_result,
12434 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
12435 TOKEN_STRING_INITIALIZER
12436 (struct cmd_vf_vlan_insert_result,
12438 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
12439 TOKEN_STRING_INITIALIZER
12440 (struct cmd_vf_vlan_insert_result,
12442 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
12443 TOKEN_NUM_INITIALIZER
12444 (struct cmd_vf_vlan_insert_result,
12446 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
12447 TOKEN_NUM_INITIALIZER
12448 (struct cmd_vf_vlan_insert_result,
12450 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
12451 TOKEN_NUM_INITIALIZER
12452 (struct cmd_vf_vlan_insert_result,
12456 cmd_set_vf_vlan_insert_parsed(
12457 void *parsed_result,
12458 __attribute__((unused)) struct cmdline *cl,
12459 __attribute__((unused)) void *data)
12461 struct cmd_vf_vlan_insert_result *res = parsed_result;
12462 int ret = -ENOTSUP;
12464 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12467 #ifdef RTE_LIBRTE_IXGBE_PMD
12468 if (ret == -ENOTSUP)
12469 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
12472 #ifdef RTE_LIBRTE_I40E_PMD
12473 if (ret == -ENOTSUP)
12474 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
12477 #ifdef RTE_LIBRTE_BNXT_PMD
12478 if (ret == -ENOTSUP)
12479 ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
12487 printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id);
12490 printf("invalid port_id %d\n", res->port_id);
12493 printf("function not implemented\n");
12496 printf("programming error: (%s)\n", strerror(-ret));
12500 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
12501 .f = cmd_set_vf_vlan_insert_parsed,
12503 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
12505 (void *)&cmd_vf_vlan_insert_set,
12506 (void *)&cmd_vf_vlan_insert_vf,
12507 (void *)&cmd_vf_vlan_insert_vlan,
12508 (void *)&cmd_vf_vlan_insert_insert,
12509 (void *)&cmd_vf_vlan_insert_port_id,
12510 (void *)&cmd_vf_vlan_insert_vf_id,
12511 (void *)&cmd_vf_vlan_insert_vlan_id,
12516 /* tx loopback configuration */
12518 /* Common result structure for tx loopback */
12519 struct cmd_tx_loopback_result {
12520 cmdline_fixed_string_t set;
12521 cmdline_fixed_string_t tx;
12522 cmdline_fixed_string_t loopback;
12524 cmdline_fixed_string_t on_off;
12527 /* Common CLI fields for tx loopback enable disable */
12528 cmdline_parse_token_string_t cmd_tx_loopback_set =
12529 TOKEN_STRING_INITIALIZER
12530 (struct cmd_tx_loopback_result,
12532 cmdline_parse_token_string_t cmd_tx_loopback_tx =
12533 TOKEN_STRING_INITIALIZER
12534 (struct cmd_tx_loopback_result,
12536 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
12537 TOKEN_STRING_INITIALIZER
12538 (struct cmd_tx_loopback_result,
12539 loopback, "loopback");
12540 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
12541 TOKEN_NUM_INITIALIZER
12542 (struct cmd_tx_loopback_result,
12544 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
12545 TOKEN_STRING_INITIALIZER
12546 (struct cmd_tx_loopback_result,
12550 cmd_set_tx_loopback_parsed(
12551 void *parsed_result,
12552 __attribute__((unused)) struct cmdline *cl,
12553 __attribute__((unused)) void *data)
12555 struct cmd_tx_loopback_result *res = parsed_result;
12556 int ret = -ENOTSUP;
12558 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12560 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12563 #ifdef RTE_LIBRTE_IXGBE_PMD
12564 if (ret == -ENOTSUP)
12565 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
12567 #ifdef RTE_LIBRTE_I40E_PMD
12568 if (ret == -ENOTSUP)
12569 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
12571 #ifdef RTE_LIBRTE_BNXT_PMD
12572 if (ret == -ENOTSUP)
12573 ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
12580 printf("invalid is_on %d\n", is_on);
12583 printf("invalid port_id %d\n", res->port_id);
12586 printf("function not implemented\n");
12589 printf("programming error: (%s)\n", strerror(-ret));
12593 cmdline_parse_inst_t cmd_set_tx_loopback = {
12594 .f = cmd_set_tx_loopback_parsed,
12596 .help_str = "set tx loopback <port_id> on|off",
12598 (void *)&cmd_tx_loopback_set,
12599 (void *)&cmd_tx_loopback_tx,
12600 (void *)&cmd_tx_loopback_loopback,
12601 (void *)&cmd_tx_loopback_port_id,
12602 (void *)&cmd_tx_loopback_on_off,
12607 /* all queues drop enable configuration */
12609 /* Common result structure for all queues drop enable */
12610 struct cmd_all_queues_drop_en_result {
12611 cmdline_fixed_string_t set;
12612 cmdline_fixed_string_t all;
12613 cmdline_fixed_string_t queues;
12614 cmdline_fixed_string_t drop;
12616 cmdline_fixed_string_t on_off;
12619 /* Common CLI fields for tx loopback enable disable */
12620 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
12621 TOKEN_STRING_INITIALIZER
12622 (struct cmd_all_queues_drop_en_result,
12624 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
12625 TOKEN_STRING_INITIALIZER
12626 (struct cmd_all_queues_drop_en_result,
12628 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
12629 TOKEN_STRING_INITIALIZER
12630 (struct cmd_all_queues_drop_en_result,
12632 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
12633 TOKEN_STRING_INITIALIZER
12634 (struct cmd_all_queues_drop_en_result,
12636 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
12637 TOKEN_NUM_INITIALIZER
12638 (struct cmd_all_queues_drop_en_result,
12640 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
12641 TOKEN_STRING_INITIALIZER
12642 (struct cmd_all_queues_drop_en_result,
12646 cmd_set_all_queues_drop_en_parsed(
12647 void *parsed_result,
12648 __attribute__((unused)) struct cmdline *cl,
12649 __attribute__((unused)) void *data)
12651 struct cmd_all_queues_drop_en_result *res = parsed_result;
12652 int ret = -ENOTSUP;
12653 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12655 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12658 #ifdef RTE_LIBRTE_IXGBE_PMD
12659 if (ret == -ENOTSUP)
12660 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
12662 #ifdef RTE_LIBRTE_BNXT_PMD
12663 if (ret == -ENOTSUP)
12664 ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
12670 printf("invalid is_on %d\n", is_on);
12673 printf("invalid port_id %d\n", res->port_id);
12676 printf("function not implemented\n");
12679 printf("programming error: (%s)\n", strerror(-ret));
12683 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
12684 .f = cmd_set_all_queues_drop_en_parsed,
12686 .help_str = "set all queues drop <port_id> on|off",
12688 (void *)&cmd_all_queues_drop_en_set,
12689 (void *)&cmd_all_queues_drop_en_all,
12690 (void *)&cmd_all_queues_drop_en_queues,
12691 (void *)&cmd_all_queues_drop_en_drop,
12692 (void *)&cmd_all_queues_drop_en_port_id,
12693 (void *)&cmd_all_queues_drop_en_on_off,
12698 /* vf split drop enable configuration */
12700 /* Common result structure for vf split drop enable */
12701 struct cmd_vf_split_drop_en_result {
12702 cmdline_fixed_string_t set;
12703 cmdline_fixed_string_t vf;
12704 cmdline_fixed_string_t split;
12705 cmdline_fixed_string_t drop;
12708 cmdline_fixed_string_t on_off;
12711 /* Common CLI fields for vf split drop enable disable */
12712 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
12713 TOKEN_STRING_INITIALIZER
12714 (struct cmd_vf_split_drop_en_result,
12716 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
12717 TOKEN_STRING_INITIALIZER
12718 (struct cmd_vf_split_drop_en_result,
12720 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
12721 TOKEN_STRING_INITIALIZER
12722 (struct cmd_vf_split_drop_en_result,
12724 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
12725 TOKEN_STRING_INITIALIZER
12726 (struct cmd_vf_split_drop_en_result,
12728 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
12729 TOKEN_NUM_INITIALIZER
12730 (struct cmd_vf_split_drop_en_result,
12732 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
12733 TOKEN_NUM_INITIALIZER
12734 (struct cmd_vf_split_drop_en_result,
12736 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
12737 TOKEN_STRING_INITIALIZER
12738 (struct cmd_vf_split_drop_en_result,
12742 cmd_set_vf_split_drop_en_parsed(
12743 void *parsed_result,
12744 __attribute__((unused)) struct cmdline *cl,
12745 __attribute__((unused)) void *data)
12747 struct cmd_vf_split_drop_en_result *res = parsed_result;
12748 int ret = -ENOTSUP;
12749 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12751 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12754 #ifdef RTE_LIBRTE_IXGBE_PMD
12755 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
12762 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12765 printf("invalid port_id %d\n", res->port_id);
12768 printf("not supported on port %d\n", res->port_id);
12771 printf("programming error: (%s)\n", strerror(-ret));
12775 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
12776 .f = cmd_set_vf_split_drop_en_parsed,
12778 .help_str = "set vf split drop <port_id> <vf_id> on|off",
12780 (void *)&cmd_vf_split_drop_en_set,
12781 (void *)&cmd_vf_split_drop_en_vf,
12782 (void *)&cmd_vf_split_drop_en_split,
12783 (void *)&cmd_vf_split_drop_en_drop,
12784 (void *)&cmd_vf_split_drop_en_port_id,
12785 (void *)&cmd_vf_split_drop_en_vf_id,
12786 (void *)&cmd_vf_split_drop_en_on_off,
12791 /* vf mac address configuration */
12793 /* Common result structure for vf mac address */
12794 struct cmd_set_vf_mac_addr_result {
12795 cmdline_fixed_string_t set;
12796 cmdline_fixed_string_t vf;
12797 cmdline_fixed_string_t mac;
12798 cmdline_fixed_string_t addr;
12801 struct ether_addr mac_addr;
12805 /* Common CLI fields for vf split drop enable disable */
12806 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
12807 TOKEN_STRING_INITIALIZER
12808 (struct cmd_set_vf_mac_addr_result,
12810 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
12811 TOKEN_STRING_INITIALIZER
12812 (struct cmd_set_vf_mac_addr_result,
12814 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
12815 TOKEN_STRING_INITIALIZER
12816 (struct cmd_set_vf_mac_addr_result,
12818 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
12819 TOKEN_STRING_INITIALIZER
12820 (struct cmd_set_vf_mac_addr_result,
12822 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
12823 TOKEN_NUM_INITIALIZER
12824 (struct cmd_set_vf_mac_addr_result,
12826 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
12827 TOKEN_NUM_INITIALIZER
12828 (struct cmd_set_vf_mac_addr_result,
12830 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
12831 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
12835 cmd_set_vf_mac_addr_parsed(
12836 void *parsed_result,
12837 __attribute__((unused)) struct cmdline *cl,
12838 __attribute__((unused)) void *data)
12840 struct cmd_set_vf_mac_addr_result *res = parsed_result;
12841 int ret = -ENOTSUP;
12843 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12846 #ifdef RTE_LIBRTE_IXGBE_PMD
12847 if (ret == -ENOTSUP)
12848 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
12851 #ifdef RTE_LIBRTE_I40E_PMD
12852 if (ret == -ENOTSUP)
12853 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
12856 #ifdef RTE_LIBRTE_BNXT_PMD
12857 if (ret == -ENOTSUP)
12858 ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
12866 printf("invalid vf_id %d or mac_addr\n", res->vf_id);
12869 printf("invalid port_id %d\n", res->port_id);
12872 printf("function not implemented\n");
12875 printf("programming error: (%s)\n", strerror(-ret));
12879 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
12880 .f = cmd_set_vf_mac_addr_parsed,
12882 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
12884 (void *)&cmd_set_vf_mac_addr_set,
12885 (void *)&cmd_set_vf_mac_addr_vf,
12886 (void *)&cmd_set_vf_mac_addr_mac,
12887 (void *)&cmd_set_vf_mac_addr_addr,
12888 (void *)&cmd_set_vf_mac_addr_port_id,
12889 (void *)&cmd_set_vf_mac_addr_vf_id,
12890 (void *)&cmd_set_vf_mac_addr_mac_addr,
12895 /* MACsec configuration */
12897 /* Common result structure for MACsec offload enable */
12898 struct cmd_macsec_offload_on_result {
12899 cmdline_fixed_string_t set;
12900 cmdline_fixed_string_t macsec;
12901 cmdline_fixed_string_t offload;
12903 cmdline_fixed_string_t on;
12904 cmdline_fixed_string_t encrypt;
12905 cmdline_fixed_string_t en_on_off;
12906 cmdline_fixed_string_t replay_protect;
12907 cmdline_fixed_string_t rp_on_off;
12910 /* Common CLI fields for MACsec offload disable */
12911 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
12912 TOKEN_STRING_INITIALIZER
12913 (struct cmd_macsec_offload_on_result,
12915 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
12916 TOKEN_STRING_INITIALIZER
12917 (struct cmd_macsec_offload_on_result,
12919 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
12920 TOKEN_STRING_INITIALIZER
12921 (struct cmd_macsec_offload_on_result,
12922 offload, "offload");
12923 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
12924 TOKEN_NUM_INITIALIZER
12925 (struct cmd_macsec_offload_on_result,
12927 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
12928 TOKEN_STRING_INITIALIZER
12929 (struct cmd_macsec_offload_on_result,
12931 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
12932 TOKEN_STRING_INITIALIZER
12933 (struct cmd_macsec_offload_on_result,
12934 encrypt, "encrypt");
12935 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
12936 TOKEN_STRING_INITIALIZER
12937 (struct cmd_macsec_offload_on_result,
12938 en_on_off, "on#off");
12939 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
12940 TOKEN_STRING_INITIALIZER
12941 (struct cmd_macsec_offload_on_result,
12942 replay_protect, "replay-protect");
12943 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
12944 TOKEN_STRING_INITIALIZER
12945 (struct cmd_macsec_offload_on_result,
12946 rp_on_off, "on#off");
12949 cmd_set_macsec_offload_on_parsed(
12950 void *parsed_result,
12951 __attribute__((unused)) struct cmdline *cl,
12952 __attribute__((unused)) void *data)
12954 struct cmd_macsec_offload_on_result *res = parsed_result;
12955 int ret = -ENOTSUP;
12956 portid_t port_id = res->port_id;
12957 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
12958 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
12960 if (port_id_is_invalid(port_id, ENABLED_WARN))
12963 ports[port_id].tx_ol_flags |= TESTPMD_TX_OFFLOAD_MACSEC;
12964 #ifdef RTE_LIBRTE_IXGBE_PMD
12965 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
12974 printf("invalid port_id %d\n", port_id);
12977 printf("not supported on port %d\n", port_id);
12980 printf("programming error: (%s)\n", strerror(-ret));
12984 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
12985 .f = cmd_set_macsec_offload_on_parsed,
12987 .help_str = "set macsec offload <port_id> on "
12988 "encrypt on|off replay-protect on|off",
12990 (void *)&cmd_macsec_offload_on_set,
12991 (void *)&cmd_macsec_offload_on_macsec,
12992 (void *)&cmd_macsec_offload_on_offload,
12993 (void *)&cmd_macsec_offload_on_port_id,
12994 (void *)&cmd_macsec_offload_on_on,
12995 (void *)&cmd_macsec_offload_on_encrypt,
12996 (void *)&cmd_macsec_offload_on_en_on_off,
12997 (void *)&cmd_macsec_offload_on_replay_protect,
12998 (void *)&cmd_macsec_offload_on_rp_on_off,
13003 /* Common result structure for MACsec offload disable */
13004 struct cmd_macsec_offload_off_result {
13005 cmdline_fixed_string_t set;
13006 cmdline_fixed_string_t macsec;
13007 cmdline_fixed_string_t offload;
13009 cmdline_fixed_string_t off;
13012 /* Common CLI fields for MACsec offload disable */
13013 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
13014 TOKEN_STRING_INITIALIZER
13015 (struct cmd_macsec_offload_off_result,
13017 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
13018 TOKEN_STRING_INITIALIZER
13019 (struct cmd_macsec_offload_off_result,
13021 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
13022 TOKEN_STRING_INITIALIZER
13023 (struct cmd_macsec_offload_off_result,
13024 offload, "offload");
13025 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
13026 TOKEN_NUM_INITIALIZER
13027 (struct cmd_macsec_offload_off_result,
13029 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
13030 TOKEN_STRING_INITIALIZER
13031 (struct cmd_macsec_offload_off_result,
13035 cmd_set_macsec_offload_off_parsed(
13036 void *parsed_result,
13037 __attribute__((unused)) struct cmdline *cl,
13038 __attribute__((unused)) void *data)
13040 struct cmd_macsec_offload_off_result *res = parsed_result;
13041 int ret = -ENOTSUP;
13042 portid_t port_id = res->port_id;
13044 if (port_id_is_invalid(port_id, ENABLED_WARN))
13047 ports[port_id].tx_ol_flags &= ~TESTPMD_TX_OFFLOAD_MACSEC;
13048 #ifdef RTE_LIBRTE_IXGBE_PMD
13049 ret = rte_pmd_ixgbe_macsec_disable(port_id);
13056 printf("invalid port_id %d\n", port_id);
13059 printf("not supported on port %d\n", port_id);
13062 printf("programming error: (%s)\n", strerror(-ret));
13066 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
13067 .f = cmd_set_macsec_offload_off_parsed,
13069 .help_str = "set macsec offload <port_id> off",
13071 (void *)&cmd_macsec_offload_off_set,
13072 (void *)&cmd_macsec_offload_off_macsec,
13073 (void *)&cmd_macsec_offload_off_offload,
13074 (void *)&cmd_macsec_offload_off_port_id,
13075 (void *)&cmd_macsec_offload_off_off,
13080 /* Common result structure for MACsec secure connection configure */
13081 struct cmd_macsec_sc_result {
13082 cmdline_fixed_string_t set;
13083 cmdline_fixed_string_t macsec;
13084 cmdline_fixed_string_t sc;
13085 cmdline_fixed_string_t tx_rx;
13087 struct ether_addr mac;
13091 /* Common CLI fields for MACsec secure connection configure */
13092 cmdline_parse_token_string_t cmd_macsec_sc_set =
13093 TOKEN_STRING_INITIALIZER
13094 (struct cmd_macsec_sc_result,
13096 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
13097 TOKEN_STRING_INITIALIZER
13098 (struct cmd_macsec_sc_result,
13100 cmdline_parse_token_string_t cmd_macsec_sc_sc =
13101 TOKEN_STRING_INITIALIZER
13102 (struct cmd_macsec_sc_result,
13104 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
13105 TOKEN_STRING_INITIALIZER
13106 (struct cmd_macsec_sc_result,
13108 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
13109 TOKEN_NUM_INITIALIZER
13110 (struct cmd_macsec_sc_result,
13112 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
13113 TOKEN_ETHERADDR_INITIALIZER
13114 (struct cmd_macsec_sc_result,
13116 cmdline_parse_token_num_t cmd_macsec_sc_pi =
13117 TOKEN_NUM_INITIALIZER
13118 (struct cmd_macsec_sc_result,
13122 cmd_set_macsec_sc_parsed(
13123 void *parsed_result,
13124 __attribute__((unused)) struct cmdline *cl,
13125 __attribute__((unused)) void *data)
13127 struct cmd_macsec_sc_result *res = parsed_result;
13128 int ret = -ENOTSUP;
13129 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
13131 #ifdef RTE_LIBRTE_IXGBE_PMD
13133 rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
13134 res->mac.addr_bytes) :
13135 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
13136 res->mac.addr_bytes, res->pi);
13138 RTE_SET_USED(is_tx);
13144 printf("invalid port_id %d\n", res->port_id);
13147 printf("not supported on port %d\n", res->port_id);
13150 printf("programming error: (%s)\n", strerror(-ret));
13154 cmdline_parse_inst_t cmd_set_macsec_sc = {
13155 .f = cmd_set_macsec_sc_parsed,
13157 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
13159 (void *)&cmd_macsec_sc_set,
13160 (void *)&cmd_macsec_sc_macsec,
13161 (void *)&cmd_macsec_sc_sc,
13162 (void *)&cmd_macsec_sc_tx_rx,
13163 (void *)&cmd_macsec_sc_port_id,
13164 (void *)&cmd_macsec_sc_mac,
13165 (void *)&cmd_macsec_sc_pi,
13170 /* Common result structure for MACsec secure connection configure */
13171 struct cmd_macsec_sa_result {
13172 cmdline_fixed_string_t set;
13173 cmdline_fixed_string_t macsec;
13174 cmdline_fixed_string_t sa;
13175 cmdline_fixed_string_t tx_rx;
13180 cmdline_fixed_string_t key;
13183 /* Common CLI fields for MACsec secure connection configure */
13184 cmdline_parse_token_string_t cmd_macsec_sa_set =
13185 TOKEN_STRING_INITIALIZER
13186 (struct cmd_macsec_sa_result,
13188 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
13189 TOKEN_STRING_INITIALIZER
13190 (struct cmd_macsec_sa_result,
13192 cmdline_parse_token_string_t cmd_macsec_sa_sa =
13193 TOKEN_STRING_INITIALIZER
13194 (struct cmd_macsec_sa_result,
13196 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
13197 TOKEN_STRING_INITIALIZER
13198 (struct cmd_macsec_sa_result,
13200 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
13201 TOKEN_NUM_INITIALIZER
13202 (struct cmd_macsec_sa_result,
13204 cmdline_parse_token_num_t cmd_macsec_sa_idx =
13205 TOKEN_NUM_INITIALIZER
13206 (struct cmd_macsec_sa_result,
13208 cmdline_parse_token_num_t cmd_macsec_sa_an =
13209 TOKEN_NUM_INITIALIZER
13210 (struct cmd_macsec_sa_result,
13212 cmdline_parse_token_num_t cmd_macsec_sa_pn =
13213 TOKEN_NUM_INITIALIZER
13214 (struct cmd_macsec_sa_result,
13216 cmdline_parse_token_string_t cmd_macsec_sa_key =
13217 TOKEN_STRING_INITIALIZER
13218 (struct cmd_macsec_sa_result,
13222 cmd_set_macsec_sa_parsed(
13223 void *parsed_result,
13224 __attribute__((unused)) struct cmdline *cl,
13225 __attribute__((unused)) void *data)
13227 struct cmd_macsec_sa_result *res = parsed_result;
13228 int ret = -ENOTSUP;
13229 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
13230 uint8_t key[16] = { 0 };
13236 key_len = strlen(res->key) / 2;
13240 for (i = 0; i < key_len; i++) {
13241 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
13244 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
13247 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
13250 #ifdef RTE_LIBRTE_IXGBE_PMD
13252 rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
13253 res->idx, res->an, res->pn, key) :
13254 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
13255 res->idx, res->an, res->pn, key);
13257 RTE_SET_USED(is_tx);
13264 printf("invalid idx %d or an %d\n", res->idx, res->an);
13267 printf("invalid port_id %d\n", res->port_id);
13270 printf("not supported on port %d\n", res->port_id);
13273 printf("programming error: (%s)\n", strerror(-ret));
13277 cmdline_parse_inst_t cmd_set_macsec_sa = {
13278 .f = cmd_set_macsec_sa_parsed,
13280 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
13282 (void *)&cmd_macsec_sa_set,
13283 (void *)&cmd_macsec_sa_macsec,
13284 (void *)&cmd_macsec_sa_sa,
13285 (void *)&cmd_macsec_sa_tx_rx,
13286 (void *)&cmd_macsec_sa_port_id,
13287 (void *)&cmd_macsec_sa_idx,
13288 (void *)&cmd_macsec_sa_an,
13289 (void *)&cmd_macsec_sa_pn,
13290 (void *)&cmd_macsec_sa_key,
13295 /* VF unicast promiscuous mode configuration */
13297 /* Common result structure for VF unicast promiscuous mode */
13298 struct cmd_vf_promisc_result {
13299 cmdline_fixed_string_t set;
13300 cmdline_fixed_string_t vf;
13301 cmdline_fixed_string_t promisc;
13304 cmdline_fixed_string_t on_off;
13307 /* Common CLI fields for VF unicast promiscuous mode enable disable */
13308 cmdline_parse_token_string_t cmd_vf_promisc_set =
13309 TOKEN_STRING_INITIALIZER
13310 (struct cmd_vf_promisc_result,
13312 cmdline_parse_token_string_t cmd_vf_promisc_vf =
13313 TOKEN_STRING_INITIALIZER
13314 (struct cmd_vf_promisc_result,
13316 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
13317 TOKEN_STRING_INITIALIZER
13318 (struct cmd_vf_promisc_result,
13319 promisc, "promisc");
13320 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
13321 TOKEN_NUM_INITIALIZER
13322 (struct cmd_vf_promisc_result,
13324 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
13325 TOKEN_NUM_INITIALIZER
13326 (struct cmd_vf_promisc_result,
13328 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
13329 TOKEN_STRING_INITIALIZER
13330 (struct cmd_vf_promisc_result,
13334 cmd_set_vf_promisc_parsed(
13335 void *parsed_result,
13336 __attribute__((unused)) struct cmdline *cl,
13337 __attribute__((unused)) void *data)
13339 struct cmd_vf_promisc_result *res = parsed_result;
13340 int ret = -ENOTSUP;
13342 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13344 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13347 #ifdef RTE_LIBRTE_I40E_PMD
13348 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
13349 res->vf_id, is_on);
13356 printf("invalid vf_id %d\n", res->vf_id);
13359 printf("invalid port_id %d\n", res->port_id);
13362 printf("function not implemented\n");
13365 printf("programming error: (%s)\n", strerror(-ret));
13369 cmdline_parse_inst_t cmd_set_vf_promisc = {
13370 .f = cmd_set_vf_promisc_parsed,
13372 .help_str = "set vf promisc <port_id> <vf_id> on|off: "
13373 "Set unicast promiscuous mode for a VF from the PF",
13375 (void *)&cmd_vf_promisc_set,
13376 (void *)&cmd_vf_promisc_vf,
13377 (void *)&cmd_vf_promisc_promisc,
13378 (void *)&cmd_vf_promisc_port_id,
13379 (void *)&cmd_vf_promisc_vf_id,
13380 (void *)&cmd_vf_promisc_on_off,
13385 /* VF multicast promiscuous mode configuration */
13387 /* Common result structure for VF multicast promiscuous mode */
13388 struct cmd_vf_allmulti_result {
13389 cmdline_fixed_string_t set;
13390 cmdline_fixed_string_t vf;
13391 cmdline_fixed_string_t allmulti;
13394 cmdline_fixed_string_t on_off;
13397 /* Common CLI fields for VF multicast promiscuous mode enable disable */
13398 cmdline_parse_token_string_t cmd_vf_allmulti_set =
13399 TOKEN_STRING_INITIALIZER
13400 (struct cmd_vf_allmulti_result,
13402 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
13403 TOKEN_STRING_INITIALIZER
13404 (struct cmd_vf_allmulti_result,
13406 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
13407 TOKEN_STRING_INITIALIZER
13408 (struct cmd_vf_allmulti_result,
13409 allmulti, "allmulti");
13410 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
13411 TOKEN_NUM_INITIALIZER
13412 (struct cmd_vf_allmulti_result,
13414 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
13415 TOKEN_NUM_INITIALIZER
13416 (struct cmd_vf_allmulti_result,
13418 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
13419 TOKEN_STRING_INITIALIZER
13420 (struct cmd_vf_allmulti_result,
13424 cmd_set_vf_allmulti_parsed(
13425 void *parsed_result,
13426 __attribute__((unused)) struct cmdline *cl,
13427 __attribute__((unused)) void *data)
13429 struct cmd_vf_allmulti_result *res = parsed_result;
13430 int ret = -ENOTSUP;
13432 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13434 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13437 #ifdef RTE_LIBRTE_I40E_PMD
13438 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
13439 res->vf_id, is_on);
13446 printf("invalid vf_id %d\n", res->vf_id);
13449 printf("invalid port_id %d\n", res->port_id);
13452 printf("function not implemented\n");
13455 printf("programming error: (%s)\n", strerror(-ret));
13459 cmdline_parse_inst_t cmd_set_vf_allmulti = {
13460 .f = cmd_set_vf_allmulti_parsed,
13462 .help_str = "set vf allmulti <port_id> <vf_id> on|off: "
13463 "Set multicast promiscuous mode for a VF from the PF",
13465 (void *)&cmd_vf_allmulti_set,
13466 (void *)&cmd_vf_allmulti_vf,
13467 (void *)&cmd_vf_allmulti_allmulti,
13468 (void *)&cmd_vf_allmulti_port_id,
13469 (void *)&cmd_vf_allmulti_vf_id,
13470 (void *)&cmd_vf_allmulti_on_off,
13475 /* vf broadcast mode configuration */
13477 /* Common result structure for vf broadcast */
13478 struct cmd_set_vf_broadcast_result {
13479 cmdline_fixed_string_t set;
13480 cmdline_fixed_string_t vf;
13481 cmdline_fixed_string_t broadcast;
13484 cmdline_fixed_string_t on_off;
13487 /* Common CLI fields for vf broadcast enable disable */
13488 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
13489 TOKEN_STRING_INITIALIZER
13490 (struct cmd_set_vf_broadcast_result,
13492 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
13493 TOKEN_STRING_INITIALIZER
13494 (struct cmd_set_vf_broadcast_result,
13496 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
13497 TOKEN_STRING_INITIALIZER
13498 (struct cmd_set_vf_broadcast_result,
13499 broadcast, "broadcast");
13500 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
13501 TOKEN_NUM_INITIALIZER
13502 (struct cmd_set_vf_broadcast_result,
13504 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
13505 TOKEN_NUM_INITIALIZER
13506 (struct cmd_set_vf_broadcast_result,
13508 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
13509 TOKEN_STRING_INITIALIZER
13510 (struct cmd_set_vf_broadcast_result,
13514 cmd_set_vf_broadcast_parsed(
13515 void *parsed_result,
13516 __attribute__((unused)) struct cmdline *cl,
13517 __attribute__((unused)) void *data)
13519 struct cmd_set_vf_broadcast_result *res = parsed_result;
13520 int ret = -ENOTSUP;
13522 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13524 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13527 #ifdef RTE_LIBRTE_I40E_PMD
13528 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
13529 res->vf_id, is_on);
13536 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13539 printf("invalid port_id %d\n", res->port_id);
13542 printf("function not implemented\n");
13545 printf("programming error: (%s)\n", strerror(-ret));
13549 cmdline_parse_inst_t cmd_set_vf_broadcast = {
13550 .f = cmd_set_vf_broadcast_parsed,
13552 .help_str = "set vf broadcast <port_id> <vf_id> on|off",
13554 (void *)&cmd_set_vf_broadcast_set,
13555 (void *)&cmd_set_vf_broadcast_vf,
13556 (void *)&cmd_set_vf_broadcast_broadcast,
13557 (void *)&cmd_set_vf_broadcast_port_id,
13558 (void *)&cmd_set_vf_broadcast_vf_id,
13559 (void *)&cmd_set_vf_broadcast_on_off,
13564 /* vf vlan tag configuration */
13566 /* Common result structure for vf vlan tag */
13567 struct cmd_set_vf_vlan_tag_result {
13568 cmdline_fixed_string_t set;
13569 cmdline_fixed_string_t vf;
13570 cmdline_fixed_string_t vlan;
13571 cmdline_fixed_string_t tag;
13574 cmdline_fixed_string_t on_off;
13577 /* Common CLI fields for vf vlan tag enable disable */
13578 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
13579 TOKEN_STRING_INITIALIZER
13580 (struct cmd_set_vf_vlan_tag_result,
13582 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
13583 TOKEN_STRING_INITIALIZER
13584 (struct cmd_set_vf_vlan_tag_result,
13586 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
13587 TOKEN_STRING_INITIALIZER
13588 (struct cmd_set_vf_vlan_tag_result,
13590 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
13591 TOKEN_STRING_INITIALIZER
13592 (struct cmd_set_vf_vlan_tag_result,
13594 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
13595 TOKEN_NUM_INITIALIZER
13596 (struct cmd_set_vf_vlan_tag_result,
13598 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
13599 TOKEN_NUM_INITIALIZER
13600 (struct cmd_set_vf_vlan_tag_result,
13602 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
13603 TOKEN_STRING_INITIALIZER
13604 (struct cmd_set_vf_vlan_tag_result,
13608 cmd_set_vf_vlan_tag_parsed(
13609 void *parsed_result,
13610 __attribute__((unused)) struct cmdline *cl,
13611 __attribute__((unused)) void *data)
13613 struct cmd_set_vf_vlan_tag_result *res = parsed_result;
13614 int ret = -ENOTSUP;
13616 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13618 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13621 #ifdef RTE_LIBRTE_I40E_PMD
13622 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
13623 res->vf_id, is_on);
13630 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13633 printf("invalid port_id %d\n", res->port_id);
13636 printf("function not implemented\n");
13639 printf("programming error: (%s)\n", strerror(-ret));
13643 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
13644 .f = cmd_set_vf_vlan_tag_parsed,
13646 .help_str = "set vf vlan tag <port_id> <vf_id> on|off",
13648 (void *)&cmd_set_vf_vlan_tag_set,
13649 (void *)&cmd_set_vf_vlan_tag_vf,
13650 (void *)&cmd_set_vf_vlan_tag_vlan,
13651 (void *)&cmd_set_vf_vlan_tag_tag,
13652 (void *)&cmd_set_vf_vlan_tag_port_id,
13653 (void *)&cmd_set_vf_vlan_tag_vf_id,
13654 (void *)&cmd_set_vf_vlan_tag_on_off,
13659 /* Common definition of VF and TC TX bandwidth configuration */
13660 struct cmd_vf_tc_bw_result {
13661 cmdline_fixed_string_t set;
13662 cmdline_fixed_string_t vf;
13663 cmdline_fixed_string_t tc;
13664 cmdline_fixed_string_t tx;
13665 cmdline_fixed_string_t min_bw;
13666 cmdline_fixed_string_t max_bw;
13667 cmdline_fixed_string_t strict_link_prio;
13672 cmdline_fixed_string_t bw_list;
13676 cmdline_parse_token_string_t cmd_vf_tc_bw_set =
13677 TOKEN_STRING_INITIALIZER
13678 (struct cmd_vf_tc_bw_result,
13680 cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
13681 TOKEN_STRING_INITIALIZER
13682 (struct cmd_vf_tc_bw_result,
13684 cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
13685 TOKEN_STRING_INITIALIZER
13686 (struct cmd_vf_tc_bw_result,
13688 cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
13689 TOKEN_STRING_INITIALIZER
13690 (struct cmd_vf_tc_bw_result,
13692 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio =
13693 TOKEN_STRING_INITIALIZER
13694 (struct cmd_vf_tc_bw_result,
13695 strict_link_prio, "strict-link-priority");
13696 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw =
13697 TOKEN_STRING_INITIALIZER
13698 (struct cmd_vf_tc_bw_result,
13699 min_bw, "min-bandwidth");
13700 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
13701 TOKEN_STRING_INITIALIZER
13702 (struct cmd_vf_tc_bw_result,
13703 max_bw, "max-bandwidth");
13704 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
13705 TOKEN_NUM_INITIALIZER
13706 (struct cmd_vf_tc_bw_result,
13708 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
13709 TOKEN_NUM_INITIALIZER
13710 (struct cmd_vf_tc_bw_result,
13712 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no =
13713 TOKEN_NUM_INITIALIZER
13714 (struct cmd_vf_tc_bw_result,
13716 cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
13717 TOKEN_NUM_INITIALIZER
13718 (struct cmd_vf_tc_bw_result,
13720 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
13721 TOKEN_STRING_INITIALIZER
13722 (struct cmd_vf_tc_bw_result,
13724 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map =
13725 TOKEN_NUM_INITIALIZER
13726 (struct cmd_vf_tc_bw_result,
13729 /* VF max bandwidth setting */
13731 cmd_vf_max_bw_parsed(
13732 void *parsed_result,
13733 __attribute__((unused)) struct cmdline *cl,
13734 __attribute__((unused)) void *data)
13736 struct cmd_vf_tc_bw_result *res = parsed_result;
13737 int ret = -ENOTSUP;
13739 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13742 #ifdef RTE_LIBRTE_I40E_PMD
13743 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id,
13744 res->vf_id, res->bw);
13751 printf("invalid vf_id %d or bandwidth %d\n",
13752 res->vf_id, res->bw);
13755 printf("invalid port_id %d\n", res->port_id);
13758 printf("function not implemented\n");
13761 printf("programming error: (%s)\n", strerror(-ret));
13765 cmdline_parse_inst_t cmd_vf_max_bw = {
13766 .f = cmd_vf_max_bw_parsed,
13768 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
13770 (void *)&cmd_vf_tc_bw_set,
13771 (void *)&cmd_vf_tc_bw_vf,
13772 (void *)&cmd_vf_tc_bw_tx,
13773 (void *)&cmd_vf_tc_bw_max_bw,
13774 (void *)&cmd_vf_tc_bw_port_id,
13775 (void *)&cmd_vf_tc_bw_vf_id,
13776 (void *)&cmd_vf_tc_bw_bw,
13782 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
13787 const char *p, *p0 = str;
13794 p = strchr(p0, '(');
13796 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
13800 p0 = strchr(p, ')');
13802 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
13806 if (size >= sizeof(s)) {
13807 printf("The string size exceeds the internal buffer size\n");
13810 snprintf(s, sizeof(s), "%.*s", size, p);
13811 ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
13813 printf("Failed to get the bandwidth list. ");
13817 for (i = 0; i < ret; i++)
13818 bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
13823 /* TC min bandwidth setting */
13825 cmd_vf_tc_min_bw_parsed(
13826 void *parsed_result,
13827 __attribute__((unused)) struct cmdline *cl,
13828 __attribute__((unused)) void *data)
13830 struct cmd_vf_tc_bw_result *res = parsed_result;
13833 int ret = -ENOTSUP;
13835 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13838 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
13842 #ifdef RTE_LIBRTE_I40E_PMD
13843 ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
13851 printf("invalid vf_id %d or bandwidth\n", res->vf_id);
13854 printf("invalid port_id %d\n", res->port_id);
13857 printf("function not implemented\n");
13860 printf("programming error: (%s)\n", strerror(-ret));
13864 cmdline_parse_inst_t cmd_vf_tc_min_bw = {
13865 .f = cmd_vf_tc_min_bw_parsed,
13867 .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
13868 " <bw1, bw2, ...>",
13870 (void *)&cmd_vf_tc_bw_set,
13871 (void *)&cmd_vf_tc_bw_vf,
13872 (void *)&cmd_vf_tc_bw_tc,
13873 (void *)&cmd_vf_tc_bw_tx,
13874 (void *)&cmd_vf_tc_bw_min_bw,
13875 (void *)&cmd_vf_tc_bw_port_id,
13876 (void *)&cmd_vf_tc_bw_vf_id,
13877 (void *)&cmd_vf_tc_bw_bw_list,
13883 cmd_tc_min_bw_parsed(
13884 void *parsed_result,
13885 __attribute__((unused)) struct cmdline *cl,
13886 __attribute__((unused)) void *data)
13888 struct cmd_vf_tc_bw_result *res = parsed_result;
13889 struct rte_port *port;
13892 int ret = -ENOTSUP;
13894 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13897 port = &ports[res->port_id];
13898 /** Check if the port is not started **/
13899 if (port->port_status != RTE_PORT_STOPPED) {
13900 printf("Please stop port %d first\n", res->port_id);
13904 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
13908 #ifdef RTE_LIBRTE_IXGBE_PMD
13909 ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw);
13916 printf("invalid bandwidth\n");
13919 printf("invalid port_id %d\n", res->port_id);
13922 printf("function not implemented\n");
13925 printf("programming error: (%s)\n", strerror(-ret));
13929 cmdline_parse_inst_t cmd_tc_min_bw = {
13930 .f = cmd_tc_min_bw_parsed,
13932 .help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>",
13934 (void *)&cmd_vf_tc_bw_set,
13935 (void *)&cmd_vf_tc_bw_tc,
13936 (void *)&cmd_vf_tc_bw_tx,
13937 (void *)&cmd_vf_tc_bw_min_bw,
13938 (void *)&cmd_vf_tc_bw_port_id,
13939 (void *)&cmd_vf_tc_bw_bw_list,
13944 /* TC max bandwidth setting */
13946 cmd_vf_tc_max_bw_parsed(
13947 void *parsed_result,
13948 __attribute__((unused)) struct cmdline *cl,
13949 __attribute__((unused)) void *data)
13951 struct cmd_vf_tc_bw_result *res = parsed_result;
13952 int ret = -ENOTSUP;
13954 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13957 #ifdef RTE_LIBRTE_I40E_PMD
13958 ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id,
13959 res->tc_no, res->bw);
13966 printf("invalid vf_id %d, tc_no %d or bandwidth %d\n",
13967 res->vf_id, res->tc_no, res->bw);
13970 printf("invalid port_id %d\n", res->port_id);
13973 printf("function not implemented\n");
13976 printf("programming error: (%s)\n", strerror(-ret));
13980 cmdline_parse_inst_t cmd_vf_tc_max_bw = {
13981 .f = cmd_vf_tc_max_bw_parsed,
13983 .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>"
13986 (void *)&cmd_vf_tc_bw_set,
13987 (void *)&cmd_vf_tc_bw_vf,
13988 (void *)&cmd_vf_tc_bw_tc,
13989 (void *)&cmd_vf_tc_bw_tx,
13990 (void *)&cmd_vf_tc_bw_max_bw,
13991 (void *)&cmd_vf_tc_bw_port_id,
13992 (void *)&cmd_vf_tc_bw_vf_id,
13993 (void *)&cmd_vf_tc_bw_tc_no,
13994 (void *)&cmd_vf_tc_bw_bw,
14000 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
14002 /* *** Set Port default Traffic Management Hierarchy *** */
14003 struct cmd_set_port_tm_hierarchy_default_result {
14004 cmdline_fixed_string_t set;
14005 cmdline_fixed_string_t port;
14006 cmdline_fixed_string_t tm;
14007 cmdline_fixed_string_t hierarchy;
14008 cmdline_fixed_string_t def;
14012 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_set =
14013 TOKEN_STRING_INITIALIZER(
14014 struct cmd_set_port_tm_hierarchy_default_result, set, "set");
14015 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_port =
14016 TOKEN_STRING_INITIALIZER(
14017 struct cmd_set_port_tm_hierarchy_default_result, port, "port");
14018 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_tm =
14019 TOKEN_STRING_INITIALIZER(
14020 struct cmd_set_port_tm_hierarchy_default_result, tm, "tm");
14021 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_hierarchy =
14022 TOKEN_STRING_INITIALIZER(
14023 struct cmd_set_port_tm_hierarchy_default_result,
14024 hierarchy, "hierarchy");
14025 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_default =
14026 TOKEN_STRING_INITIALIZER(
14027 struct cmd_set_port_tm_hierarchy_default_result,
14029 cmdline_parse_token_num_t cmd_set_port_tm_hierarchy_default_port_id =
14030 TOKEN_NUM_INITIALIZER(
14031 struct cmd_set_port_tm_hierarchy_default_result,
14034 static void cmd_set_port_tm_hierarchy_default_parsed(void *parsed_result,
14035 __attribute__((unused)) struct cmdline *cl,
14036 __attribute__((unused)) void *data)
14038 struct cmd_set_port_tm_hierarchy_default_result *res = parsed_result;
14039 struct rte_port *p;
14040 portid_t port_id = res->port_id;
14042 if (port_id_is_invalid(port_id, ENABLED_WARN))
14045 p = &ports[port_id];
14048 if (p->softport.tm_flag == 0) {
14049 printf(" tm not enabled on port %u (error)\n", port_id);
14053 /* Forward mode: tm */
14054 if (strcmp(cur_fwd_config.fwd_eng->fwd_mode_name, "tm")) {
14055 printf(" tm mode not enabled(error)\n");
14059 /* Set the default tm hierarchy */
14060 p->softport.tm.default_hierarchy_enable = 1;
14063 cmdline_parse_inst_t cmd_set_port_tm_hierarchy_default = {
14064 .f = cmd_set_port_tm_hierarchy_default_parsed,
14066 .help_str = "set port tm hierarchy default <port_id>",
14068 (void *)&cmd_set_port_tm_hierarchy_default_set,
14069 (void *)&cmd_set_port_tm_hierarchy_default_port,
14070 (void *)&cmd_set_port_tm_hierarchy_default_tm,
14071 (void *)&cmd_set_port_tm_hierarchy_default_hierarchy,
14072 (void *)&cmd_set_port_tm_hierarchy_default_default,
14073 (void *)&cmd_set_port_tm_hierarchy_default_port_id,
14079 /* Strict link priority scheduling mode setting */
14081 cmd_strict_link_prio_parsed(
14082 void *parsed_result,
14083 __attribute__((unused)) struct cmdline *cl,
14084 __attribute__((unused)) void *data)
14086 struct cmd_vf_tc_bw_result *res = parsed_result;
14087 int ret = -ENOTSUP;
14089 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14092 #ifdef RTE_LIBRTE_I40E_PMD
14093 ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map);
14100 printf("invalid tc_bitmap 0x%x\n", res->tc_map);
14103 printf("invalid port_id %d\n", res->port_id);
14106 printf("function not implemented\n");
14109 printf("programming error: (%s)\n", strerror(-ret));
14113 cmdline_parse_inst_t cmd_strict_link_prio = {
14114 .f = cmd_strict_link_prio_parsed,
14116 .help_str = "set tx strict-link-priority <port_id> <tc_bitmap>",
14118 (void *)&cmd_vf_tc_bw_set,
14119 (void *)&cmd_vf_tc_bw_tx,
14120 (void *)&cmd_vf_tc_bw_strict_link_prio,
14121 (void *)&cmd_vf_tc_bw_port_id,
14122 (void *)&cmd_vf_tc_bw_tc_map,
14127 /* Load dynamic device personalization*/
14128 struct cmd_ddp_add_result {
14129 cmdline_fixed_string_t ddp;
14130 cmdline_fixed_string_t add;
14135 cmdline_parse_token_string_t cmd_ddp_add_ddp =
14136 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp");
14137 cmdline_parse_token_string_t cmd_ddp_add_add =
14138 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add");
14139 cmdline_parse_token_num_t cmd_ddp_add_port_id =
14140 TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id, UINT16);
14141 cmdline_parse_token_string_t cmd_ddp_add_filepath =
14142 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL);
14145 cmd_ddp_add_parsed(
14146 void *parsed_result,
14147 __attribute__((unused)) struct cmdline *cl,
14148 __attribute__((unused)) void *data)
14150 struct cmd_ddp_add_result *res = parsed_result;
14156 int ret = -ENOTSUP;
14158 if (res->port_id > nb_ports) {
14159 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
14163 if (!all_ports_stopped()) {
14164 printf("Please stop all ports first\n");
14168 filepath = strdup(res->filepath);
14169 if (filepath == NULL) {
14170 printf("Failed to allocate memory\n");
14173 file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ',');
14175 buff = open_ddp_package_file(file_fld[0], &size);
14177 free((void *)filepath);
14181 #ifdef RTE_LIBRTE_I40E_PMD
14182 if (ret == -ENOTSUP)
14183 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
14185 RTE_PMD_I40E_PKG_OP_WR_ADD);
14188 if (ret == -EEXIST)
14189 printf("Profile has already existed.\n");
14191 printf("Failed to load profile.\n");
14192 else if (file_num == 2)
14193 save_ddp_package_file(file_fld[1], buff, size);
14195 close_ddp_package_file(buff);
14196 free((void *)filepath);
14199 cmdline_parse_inst_t cmd_ddp_add = {
14200 .f = cmd_ddp_add_parsed,
14202 .help_str = "ddp add <port_id> <profile_path[,output_path]>",
14204 (void *)&cmd_ddp_add_ddp,
14205 (void *)&cmd_ddp_add_add,
14206 (void *)&cmd_ddp_add_port_id,
14207 (void *)&cmd_ddp_add_filepath,
14212 /* Delete dynamic device personalization*/
14213 struct cmd_ddp_del_result {
14214 cmdline_fixed_string_t ddp;
14215 cmdline_fixed_string_t del;
14220 cmdline_parse_token_string_t cmd_ddp_del_ddp =
14221 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp");
14222 cmdline_parse_token_string_t cmd_ddp_del_del =
14223 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del");
14224 cmdline_parse_token_num_t cmd_ddp_del_port_id =
14225 TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, UINT16);
14226 cmdline_parse_token_string_t cmd_ddp_del_filepath =
14227 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL);
14230 cmd_ddp_del_parsed(
14231 void *parsed_result,
14232 __attribute__((unused)) struct cmdline *cl,
14233 __attribute__((unused)) void *data)
14235 struct cmd_ddp_del_result *res = parsed_result;
14238 int ret = -ENOTSUP;
14240 if (res->port_id > nb_ports) {
14241 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
14245 if (!all_ports_stopped()) {
14246 printf("Please stop all ports first\n");
14250 buff = open_ddp_package_file(res->filepath, &size);
14254 #ifdef RTE_LIBRTE_I40E_PMD
14255 if (ret == -ENOTSUP)
14256 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
14258 RTE_PMD_I40E_PKG_OP_WR_DEL);
14261 if (ret == -EACCES)
14262 printf("Profile does not exist.\n");
14264 printf("Failed to delete profile.\n");
14266 close_ddp_package_file(buff);
14269 cmdline_parse_inst_t cmd_ddp_del = {
14270 .f = cmd_ddp_del_parsed,
14272 .help_str = "ddp del <port_id> <profile_path>",
14274 (void *)&cmd_ddp_del_ddp,
14275 (void *)&cmd_ddp_del_del,
14276 (void *)&cmd_ddp_del_port_id,
14277 (void *)&cmd_ddp_del_filepath,
14282 /* Get dynamic device personalization profile info */
14283 struct cmd_ddp_info_result {
14284 cmdline_fixed_string_t ddp;
14285 cmdline_fixed_string_t get;
14286 cmdline_fixed_string_t info;
14290 cmdline_parse_token_string_t cmd_ddp_info_ddp =
14291 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp");
14292 cmdline_parse_token_string_t cmd_ddp_info_get =
14293 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get");
14294 cmdline_parse_token_string_t cmd_ddp_info_info =
14295 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info");
14296 cmdline_parse_token_string_t cmd_ddp_info_filepath =
14297 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL);
14300 cmd_ddp_info_parsed(
14301 void *parsed_result,
14302 __attribute__((unused)) struct cmdline *cl,
14303 __attribute__((unused)) void *data)
14305 struct cmd_ddp_info_result *res = parsed_result;
14308 int ret = -ENOTSUP;
14309 #ifdef RTE_LIBRTE_I40E_PMD
14312 uint32_t buff_size = 0;
14313 struct rte_pmd_i40e_profile_info info;
14314 uint32_t dev_num = 0;
14315 struct rte_pmd_i40e_ddp_device_id *devs;
14316 uint32_t proto_num = 0;
14317 struct rte_pmd_i40e_proto_info *proto;
14318 uint32_t pctype_num = 0;
14319 struct rte_pmd_i40e_ptype_info *pctype;
14320 uint32_t ptype_num = 0;
14321 struct rte_pmd_i40e_ptype_info *ptype;
14326 pkg = open_ddp_package_file(res->filepath, &pkg_size);
14330 #ifdef RTE_LIBRTE_I40E_PMD
14331 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14332 (uint8_t *)&info, sizeof(info),
14333 RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER);
14335 printf("Global Track id: 0x%x\n", info.track_id);
14336 printf("Global Version: %d.%d.%d.%d\n",
14337 info.version.major,
14338 info.version.minor,
14339 info.version.update,
14340 info.version.draft);
14341 printf("Global Package name: %s\n\n", info.name);
14344 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14345 (uint8_t *)&info, sizeof(info),
14346 RTE_PMD_I40E_PKG_INFO_HEADER);
14348 printf("i40e Profile Track id: 0x%x\n", info.track_id);
14349 printf("i40e Profile Version: %d.%d.%d.%d\n",
14350 info.version.major,
14351 info.version.minor,
14352 info.version.update,
14353 info.version.draft);
14354 printf("i40e Profile name: %s\n\n", info.name);
14357 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14358 (uint8_t *)&buff_size, sizeof(buff_size),
14359 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE);
14360 if (!ret && buff_size) {
14361 buff = (uint8_t *)malloc(buff_size);
14363 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14365 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES);
14367 printf("Package Notes:\n%s\n\n", buff);
14372 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14373 (uint8_t *)&dev_num, sizeof(dev_num),
14374 RTE_PMD_I40E_PKG_INFO_DEVID_NUM);
14375 if (!ret && dev_num) {
14376 buff_size = dev_num * sizeof(struct rte_pmd_i40e_ddp_device_id);
14377 devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(buff_size);
14379 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14380 (uint8_t *)devs, buff_size,
14381 RTE_PMD_I40E_PKG_INFO_DEVID_LIST);
14383 printf("List of supported devices:\n");
14384 for (i = 0; i < dev_num; i++) {
14385 printf(" %04X:%04X %04X:%04X\n",
14386 devs[i].vendor_dev_id >> 16,
14387 devs[i].vendor_dev_id & 0xFFFF,
14388 devs[i].sub_vendor_dev_id >> 16,
14389 devs[i].sub_vendor_dev_id & 0xFFFF);
14397 /* get information about protocols and packet types */
14398 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14399 (uint8_t *)&proto_num, sizeof(proto_num),
14400 RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM);
14401 if (ret || !proto_num)
14402 goto no_print_return;
14404 buff_size = proto_num * sizeof(struct rte_pmd_i40e_proto_info);
14405 proto = (struct rte_pmd_i40e_proto_info *)malloc(buff_size);
14407 goto no_print_return;
14409 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)proto,
14411 RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST);
14413 printf("List of used protocols:\n");
14414 for (i = 0; i < proto_num; i++)
14415 printf(" %2u: %s\n", proto[i].proto_id,
14419 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14420 (uint8_t *)&pctype_num, sizeof(pctype_num),
14421 RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM);
14422 if (ret || !pctype_num)
14423 goto no_print_pctypes;
14425 buff_size = pctype_num * sizeof(struct rte_pmd_i40e_ptype_info);
14426 pctype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
14428 goto no_print_pctypes;
14430 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)pctype,
14432 RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST);
14435 goto no_print_pctypes;
14438 printf("List of defined packet classification types:\n");
14439 for (i = 0; i < pctype_num; i++) {
14440 printf(" %2u:", pctype[i].ptype_id);
14441 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
14442 proto_id = pctype[i].protocols[j];
14443 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
14444 for (n = 0; n < proto_num; n++) {
14445 if (proto[n].proto_id == proto_id) {
14446 printf(" %s", proto[n].name);
14459 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)&ptype_num,
14461 RTE_PMD_I40E_PKG_INFO_PTYPE_NUM);
14462 if (ret || !ptype_num)
14463 goto no_print_return;
14465 buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_info);
14466 ptype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
14468 goto no_print_return;
14470 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)ptype,
14472 RTE_PMD_I40E_PKG_INFO_PTYPE_LIST);
14475 goto no_print_return;
14477 printf("List of defined packet types:\n");
14478 for (i = 0; i < ptype_num; i++) {
14479 printf(" %2u:", ptype[i].ptype_id);
14480 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
14481 proto_id = ptype[i].protocols[j];
14482 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
14483 for (n = 0; n < proto_num; n++) {
14484 if (proto[n].proto_id == proto_id) {
14485 printf(" %s", proto[n].name);
14500 if (ret == -ENOTSUP)
14501 printf("Function not supported in PMD driver\n");
14502 close_ddp_package_file(pkg);
14505 cmdline_parse_inst_t cmd_ddp_get_info = {
14506 .f = cmd_ddp_info_parsed,
14508 .help_str = "ddp get info <profile_path>",
14510 (void *)&cmd_ddp_info_ddp,
14511 (void *)&cmd_ddp_info_get,
14512 (void *)&cmd_ddp_info_info,
14513 (void *)&cmd_ddp_info_filepath,
14518 /* Get dynamic device personalization profile info list*/
14519 #define PROFILE_INFO_SIZE 48
14520 #define MAX_PROFILE_NUM 16
14522 struct cmd_ddp_get_list_result {
14523 cmdline_fixed_string_t ddp;
14524 cmdline_fixed_string_t get;
14525 cmdline_fixed_string_t list;
14529 cmdline_parse_token_string_t cmd_ddp_get_list_ddp =
14530 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp");
14531 cmdline_parse_token_string_t cmd_ddp_get_list_get =
14532 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get");
14533 cmdline_parse_token_string_t cmd_ddp_get_list_list =
14534 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list");
14535 cmdline_parse_token_num_t cmd_ddp_get_list_port_id =
14536 TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id, UINT16);
14539 cmd_ddp_get_list_parsed(
14540 void *parsed_result,
14541 __attribute__((unused)) struct cmdline *cl,
14542 __attribute__((unused)) void *data)
14544 struct cmd_ddp_get_list_result *res = parsed_result;
14545 #ifdef RTE_LIBRTE_I40E_PMD
14546 struct rte_pmd_i40e_profile_list *p_list;
14547 struct rte_pmd_i40e_profile_info *p_info;
14552 int ret = -ENOTSUP;
14554 if (res->port_id > nb_ports) {
14555 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
14559 #ifdef RTE_LIBRTE_I40E_PMD
14560 size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4;
14561 p_list = (struct rte_pmd_i40e_profile_list *)malloc(size);
14563 printf("%s: Failed to malloc buffer\n", __func__);
14565 if (ret == -ENOTSUP)
14566 ret = rte_pmd_i40e_get_ddp_list(res->port_id,
14567 (uint8_t *)p_list, size);
14570 p_num = p_list->p_count;
14571 printf("Profile number is: %d\n\n", p_num);
14573 for (i = 0; i < p_num; i++) {
14574 p_info = &p_list->p_info[i];
14575 printf("Profile %d:\n", i);
14576 printf("Track id: 0x%x\n", p_info->track_id);
14577 printf("Version: %d.%d.%d.%d\n",
14578 p_info->version.major,
14579 p_info->version.minor,
14580 p_info->version.update,
14581 p_info->version.draft);
14582 printf("Profile name: %s\n\n", p_info->name);
14590 printf("Failed to get ddp list\n");
14593 cmdline_parse_inst_t cmd_ddp_get_list = {
14594 .f = cmd_ddp_get_list_parsed,
14596 .help_str = "ddp get list <port_id>",
14598 (void *)&cmd_ddp_get_list_ddp,
14599 (void *)&cmd_ddp_get_list_get,
14600 (void *)&cmd_ddp_get_list_list,
14601 (void *)&cmd_ddp_get_list_port_id,
14606 /* show vf stats */
14608 /* Common result structure for show vf stats */
14609 struct cmd_show_vf_stats_result {
14610 cmdline_fixed_string_t show;
14611 cmdline_fixed_string_t vf;
14612 cmdline_fixed_string_t stats;
14617 /* Common CLI fields show vf stats*/
14618 cmdline_parse_token_string_t cmd_show_vf_stats_show =
14619 TOKEN_STRING_INITIALIZER
14620 (struct cmd_show_vf_stats_result,
14622 cmdline_parse_token_string_t cmd_show_vf_stats_vf =
14623 TOKEN_STRING_INITIALIZER
14624 (struct cmd_show_vf_stats_result,
14626 cmdline_parse_token_string_t cmd_show_vf_stats_stats =
14627 TOKEN_STRING_INITIALIZER
14628 (struct cmd_show_vf_stats_result,
14630 cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
14631 TOKEN_NUM_INITIALIZER
14632 (struct cmd_show_vf_stats_result,
14634 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
14635 TOKEN_NUM_INITIALIZER
14636 (struct cmd_show_vf_stats_result,
14640 cmd_show_vf_stats_parsed(
14641 void *parsed_result,
14642 __attribute__((unused)) struct cmdline *cl,
14643 __attribute__((unused)) void *data)
14645 struct cmd_show_vf_stats_result *res = parsed_result;
14646 struct rte_eth_stats stats;
14647 int ret = -ENOTSUP;
14648 static const char *nic_stats_border = "########################";
14650 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14653 memset(&stats, 0, sizeof(stats));
14655 #ifdef RTE_LIBRTE_I40E_PMD
14656 if (ret == -ENOTSUP)
14657 ret = rte_pmd_i40e_get_vf_stats(res->port_id,
14661 #ifdef RTE_LIBRTE_BNXT_PMD
14662 if (ret == -ENOTSUP)
14663 ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
14672 printf("invalid vf_id %d\n", res->vf_id);
14675 printf("invalid port_id %d\n", res->port_id);
14678 printf("function not implemented\n");
14681 printf("programming error: (%s)\n", strerror(-ret));
14684 printf("\n %s NIC statistics for port %-2d vf %-2d %s\n",
14685 nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
14687 printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: "
14689 stats.ipackets, stats.imissed, stats.ibytes);
14690 printf(" RX-errors: %-"PRIu64"\n", stats.ierrors);
14691 printf(" RX-nombuf: %-10"PRIu64"\n",
14693 printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: "
14695 stats.opackets, stats.oerrors, stats.obytes);
14697 printf(" %s############################%s\n",
14698 nic_stats_border, nic_stats_border);
14701 cmdline_parse_inst_t cmd_show_vf_stats = {
14702 .f = cmd_show_vf_stats_parsed,
14704 .help_str = "show vf stats <port_id> <vf_id>",
14706 (void *)&cmd_show_vf_stats_show,
14707 (void *)&cmd_show_vf_stats_vf,
14708 (void *)&cmd_show_vf_stats_stats,
14709 (void *)&cmd_show_vf_stats_port_id,
14710 (void *)&cmd_show_vf_stats_vf_id,
14715 /* clear vf stats */
14717 /* Common result structure for clear vf stats */
14718 struct cmd_clear_vf_stats_result {
14719 cmdline_fixed_string_t clear;
14720 cmdline_fixed_string_t vf;
14721 cmdline_fixed_string_t stats;
14726 /* Common CLI fields clear vf stats*/
14727 cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
14728 TOKEN_STRING_INITIALIZER
14729 (struct cmd_clear_vf_stats_result,
14731 cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
14732 TOKEN_STRING_INITIALIZER
14733 (struct cmd_clear_vf_stats_result,
14735 cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
14736 TOKEN_STRING_INITIALIZER
14737 (struct cmd_clear_vf_stats_result,
14739 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
14740 TOKEN_NUM_INITIALIZER
14741 (struct cmd_clear_vf_stats_result,
14743 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
14744 TOKEN_NUM_INITIALIZER
14745 (struct cmd_clear_vf_stats_result,
14749 cmd_clear_vf_stats_parsed(
14750 void *parsed_result,
14751 __attribute__((unused)) struct cmdline *cl,
14752 __attribute__((unused)) void *data)
14754 struct cmd_clear_vf_stats_result *res = parsed_result;
14755 int ret = -ENOTSUP;
14757 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14760 #ifdef RTE_LIBRTE_I40E_PMD
14761 if (ret == -ENOTSUP)
14762 ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
14765 #ifdef RTE_LIBRTE_BNXT_PMD
14766 if (ret == -ENOTSUP)
14767 ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
14775 printf("invalid vf_id %d\n", res->vf_id);
14778 printf("invalid port_id %d\n", res->port_id);
14781 printf("function not implemented\n");
14784 printf("programming error: (%s)\n", strerror(-ret));
14788 cmdline_parse_inst_t cmd_clear_vf_stats = {
14789 .f = cmd_clear_vf_stats_parsed,
14791 .help_str = "clear vf stats <port_id> <vf_id>",
14793 (void *)&cmd_clear_vf_stats_clear,
14794 (void *)&cmd_clear_vf_stats_vf,
14795 (void *)&cmd_clear_vf_stats_stats,
14796 (void *)&cmd_clear_vf_stats_port_id,
14797 (void *)&cmd_clear_vf_stats_vf_id,
14802 /* port config pctype mapping reset */
14804 /* Common result structure for port config pctype mapping reset */
14805 struct cmd_pctype_mapping_reset_result {
14806 cmdline_fixed_string_t port;
14807 cmdline_fixed_string_t config;
14809 cmdline_fixed_string_t pctype;
14810 cmdline_fixed_string_t mapping;
14811 cmdline_fixed_string_t reset;
14814 /* Common CLI fields for port config pctype mapping reset*/
14815 cmdline_parse_token_string_t cmd_pctype_mapping_reset_port =
14816 TOKEN_STRING_INITIALIZER
14817 (struct cmd_pctype_mapping_reset_result,
14819 cmdline_parse_token_string_t cmd_pctype_mapping_reset_config =
14820 TOKEN_STRING_INITIALIZER
14821 (struct cmd_pctype_mapping_reset_result,
14823 cmdline_parse_token_num_t cmd_pctype_mapping_reset_port_id =
14824 TOKEN_NUM_INITIALIZER
14825 (struct cmd_pctype_mapping_reset_result,
14827 cmdline_parse_token_string_t cmd_pctype_mapping_reset_pctype =
14828 TOKEN_STRING_INITIALIZER
14829 (struct cmd_pctype_mapping_reset_result,
14831 cmdline_parse_token_string_t cmd_pctype_mapping_reset_mapping =
14832 TOKEN_STRING_INITIALIZER
14833 (struct cmd_pctype_mapping_reset_result,
14834 mapping, "mapping");
14835 cmdline_parse_token_string_t cmd_pctype_mapping_reset_reset =
14836 TOKEN_STRING_INITIALIZER
14837 (struct cmd_pctype_mapping_reset_result,
14841 cmd_pctype_mapping_reset_parsed(
14842 void *parsed_result,
14843 __attribute__((unused)) struct cmdline *cl,
14844 __attribute__((unused)) void *data)
14846 struct cmd_pctype_mapping_reset_result *res = parsed_result;
14847 int ret = -ENOTSUP;
14849 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14852 #ifdef RTE_LIBRTE_I40E_PMD
14853 ret = rte_pmd_i40e_flow_type_mapping_reset(res->port_id);
14860 printf("invalid port_id %d\n", res->port_id);
14863 printf("function not implemented\n");
14866 printf("programming error: (%s)\n", strerror(-ret));
14870 cmdline_parse_inst_t cmd_pctype_mapping_reset = {
14871 .f = cmd_pctype_mapping_reset_parsed,
14873 .help_str = "port config <port_id> pctype mapping reset",
14875 (void *)&cmd_pctype_mapping_reset_port,
14876 (void *)&cmd_pctype_mapping_reset_config,
14877 (void *)&cmd_pctype_mapping_reset_port_id,
14878 (void *)&cmd_pctype_mapping_reset_pctype,
14879 (void *)&cmd_pctype_mapping_reset_mapping,
14880 (void *)&cmd_pctype_mapping_reset_reset,
14885 /* show port pctype mapping */
14887 /* Common result structure for show port pctype mapping */
14888 struct cmd_pctype_mapping_get_result {
14889 cmdline_fixed_string_t show;
14890 cmdline_fixed_string_t port;
14892 cmdline_fixed_string_t pctype;
14893 cmdline_fixed_string_t mapping;
14896 /* Common CLI fields for pctype mapping get */
14897 cmdline_parse_token_string_t cmd_pctype_mapping_get_show =
14898 TOKEN_STRING_INITIALIZER
14899 (struct cmd_pctype_mapping_get_result,
14901 cmdline_parse_token_string_t cmd_pctype_mapping_get_port =
14902 TOKEN_STRING_INITIALIZER
14903 (struct cmd_pctype_mapping_get_result,
14905 cmdline_parse_token_num_t cmd_pctype_mapping_get_port_id =
14906 TOKEN_NUM_INITIALIZER
14907 (struct cmd_pctype_mapping_get_result,
14909 cmdline_parse_token_string_t cmd_pctype_mapping_get_pctype =
14910 TOKEN_STRING_INITIALIZER
14911 (struct cmd_pctype_mapping_get_result,
14913 cmdline_parse_token_string_t cmd_pctype_mapping_get_mapping =
14914 TOKEN_STRING_INITIALIZER
14915 (struct cmd_pctype_mapping_get_result,
14916 mapping, "mapping");
14919 cmd_pctype_mapping_get_parsed(
14920 void *parsed_result,
14921 __attribute__((unused)) struct cmdline *cl,
14922 __attribute__((unused)) void *data)
14924 struct cmd_pctype_mapping_get_result *res = parsed_result;
14925 int ret = -ENOTSUP;
14926 #ifdef RTE_LIBRTE_I40E_PMD
14927 struct rte_pmd_i40e_flow_type_mapping
14928 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
14929 int i, j, first_pctype;
14932 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14935 #ifdef RTE_LIBRTE_I40E_PMD
14936 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, mapping);
14943 printf("invalid port_id %d\n", res->port_id);
14946 printf("function not implemented\n");
14949 printf("programming error: (%s)\n", strerror(-ret));
14953 #ifdef RTE_LIBRTE_I40E_PMD
14954 for (i = 0; i < RTE_PMD_I40E_FLOW_TYPE_MAX; i++) {
14955 if (mapping[i].pctype != 0ULL) {
14958 printf("pctype: ");
14959 for (j = 0; j < RTE_PMD_I40E_PCTYPE_MAX; j++) {
14960 if (mapping[i].pctype & (1ULL << j)) {
14961 printf(first_pctype ?
14962 "%02d" : ",%02d", j);
14966 printf(" -> flowtype: %02d\n", mapping[i].flow_type);
14972 cmdline_parse_inst_t cmd_pctype_mapping_get = {
14973 .f = cmd_pctype_mapping_get_parsed,
14975 .help_str = "show port <port_id> pctype mapping",
14977 (void *)&cmd_pctype_mapping_get_show,
14978 (void *)&cmd_pctype_mapping_get_port,
14979 (void *)&cmd_pctype_mapping_get_port_id,
14980 (void *)&cmd_pctype_mapping_get_pctype,
14981 (void *)&cmd_pctype_mapping_get_mapping,
14986 /* port config pctype mapping update */
14988 /* Common result structure for port config pctype mapping update */
14989 struct cmd_pctype_mapping_update_result {
14990 cmdline_fixed_string_t port;
14991 cmdline_fixed_string_t config;
14993 cmdline_fixed_string_t pctype;
14994 cmdline_fixed_string_t mapping;
14995 cmdline_fixed_string_t update;
14996 cmdline_fixed_string_t pctype_list;
14997 uint16_t flow_type;
15000 /* Common CLI fields for pctype mapping update*/
15001 cmdline_parse_token_string_t cmd_pctype_mapping_update_port =
15002 TOKEN_STRING_INITIALIZER
15003 (struct cmd_pctype_mapping_update_result,
15005 cmdline_parse_token_string_t cmd_pctype_mapping_update_config =
15006 TOKEN_STRING_INITIALIZER
15007 (struct cmd_pctype_mapping_update_result,
15009 cmdline_parse_token_num_t cmd_pctype_mapping_update_port_id =
15010 TOKEN_NUM_INITIALIZER
15011 (struct cmd_pctype_mapping_update_result,
15013 cmdline_parse_token_string_t cmd_pctype_mapping_update_pctype =
15014 TOKEN_STRING_INITIALIZER
15015 (struct cmd_pctype_mapping_update_result,
15017 cmdline_parse_token_string_t cmd_pctype_mapping_update_mapping =
15018 TOKEN_STRING_INITIALIZER
15019 (struct cmd_pctype_mapping_update_result,
15020 mapping, "mapping");
15021 cmdline_parse_token_string_t cmd_pctype_mapping_update_update =
15022 TOKEN_STRING_INITIALIZER
15023 (struct cmd_pctype_mapping_update_result,
15025 cmdline_parse_token_string_t cmd_pctype_mapping_update_pc_type =
15026 TOKEN_STRING_INITIALIZER
15027 (struct cmd_pctype_mapping_update_result,
15028 pctype_list, NULL);
15029 cmdline_parse_token_num_t cmd_pctype_mapping_update_flow_type =
15030 TOKEN_NUM_INITIALIZER
15031 (struct cmd_pctype_mapping_update_result,
15032 flow_type, UINT16);
15035 cmd_pctype_mapping_update_parsed(
15036 void *parsed_result,
15037 __attribute__((unused)) struct cmdline *cl,
15038 __attribute__((unused)) void *data)
15040 struct cmd_pctype_mapping_update_result *res = parsed_result;
15041 int ret = -ENOTSUP;
15042 #ifdef RTE_LIBRTE_I40E_PMD
15043 struct rte_pmd_i40e_flow_type_mapping mapping;
15045 unsigned int nb_item;
15046 unsigned int pctype_list[RTE_PMD_I40E_PCTYPE_MAX];
15049 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15052 #ifdef RTE_LIBRTE_I40E_PMD
15053 nb_item = parse_item_list(res->pctype_list, "pctypes",
15054 RTE_PMD_I40E_PCTYPE_MAX, pctype_list, 1);
15055 mapping.flow_type = res->flow_type;
15056 for (i = 0, mapping.pctype = 0ULL; i < nb_item; i++)
15057 mapping.pctype |= (1ULL << pctype_list[i]);
15058 ret = rte_pmd_i40e_flow_type_mapping_update(res->port_id,
15068 printf("invalid pctype or flow type\n");
15071 printf("invalid port_id %d\n", res->port_id);
15074 printf("function not implemented\n");
15077 printf("programming error: (%s)\n", strerror(-ret));
15081 cmdline_parse_inst_t cmd_pctype_mapping_update = {
15082 .f = cmd_pctype_mapping_update_parsed,
15084 .help_str = "port config <port_id> pctype mapping update"
15085 " <pctype_id_0,[pctype_id_1]*> <flowtype_id>",
15087 (void *)&cmd_pctype_mapping_update_port,
15088 (void *)&cmd_pctype_mapping_update_config,
15089 (void *)&cmd_pctype_mapping_update_port_id,
15090 (void *)&cmd_pctype_mapping_update_pctype,
15091 (void *)&cmd_pctype_mapping_update_mapping,
15092 (void *)&cmd_pctype_mapping_update_update,
15093 (void *)&cmd_pctype_mapping_update_pc_type,
15094 (void *)&cmd_pctype_mapping_update_flow_type,
15099 /* ptype mapping get */
15101 /* Common result structure for ptype mapping get */
15102 struct cmd_ptype_mapping_get_result {
15103 cmdline_fixed_string_t ptype;
15104 cmdline_fixed_string_t mapping;
15105 cmdline_fixed_string_t get;
15107 uint8_t valid_only;
15110 /* Common CLI fields for ptype mapping get */
15111 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype =
15112 TOKEN_STRING_INITIALIZER
15113 (struct cmd_ptype_mapping_get_result,
15115 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping =
15116 TOKEN_STRING_INITIALIZER
15117 (struct cmd_ptype_mapping_get_result,
15118 mapping, "mapping");
15119 cmdline_parse_token_string_t cmd_ptype_mapping_get_get =
15120 TOKEN_STRING_INITIALIZER
15121 (struct cmd_ptype_mapping_get_result,
15123 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id =
15124 TOKEN_NUM_INITIALIZER
15125 (struct cmd_ptype_mapping_get_result,
15127 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only =
15128 TOKEN_NUM_INITIALIZER
15129 (struct cmd_ptype_mapping_get_result,
15130 valid_only, UINT8);
15133 cmd_ptype_mapping_get_parsed(
15134 void *parsed_result,
15135 __attribute__((unused)) struct cmdline *cl,
15136 __attribute__((unused)) void *data)
15138 struct cmd_ptype_mapping_get_result *res = parsed_result;
15139 int ret = -ENOTSUP;
15140 #ifdef RTE_LIBRTE_I40E_PMD
15141 int max_ptype_num = 256;
15142 struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num];
15147 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15150 #ifdef RTE_LIBRTE_I40E_PMD
15151 ret = rte_pmd_i40e_ptype_mapping_get(res->port_id,
15162 printf("invalid port_id %d\n", res->port_id);
15165 printf("function not implemented\n");
15168 printf("programming error: (%s)\n", strerror(-ret));
15171 #ifdef RTE_LIBRTE_I40E_PMD
15173 for (i = 0; i < count; i++)
15174 printf("%3d\t0x%08x\n",
15175 mapping[i].hw_ptype, mapping[i].sw_ptype);
15180 cmdline_parse_inst_t cmd_ptype_mapping_get = {
15181 .f = cmd_ptype_mapping_get_parsed,
15183 .help_str = "ptype mapping get <port_id> <valid_only>",
15185 (void *)&cmd_ptype_mapping_get_ptype,
15186 (void *)&cmd_ptype_mapping_get_mapping,
15187 (void *)&cmd_ptype_mapping_get_get,
15188 (void *)&cmd_ptype_mapping_get_port_id,
15189 (void *)&cmd_ptype_mapping_get_valid_only,
15194 /* ptype mapping replace */
15196 /* Common result structure for ptype mapping replace */
15197 struct cmd_ptype_mapping_replace_result {
15198 cmdline_fixed_string_t ptype;
15199 cmdline_fixed_string_t mapping;
15200 cmdline_fixed_string_t replace;
15207 /* Common CLI fields for ptype mapping replace */
15208 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype =
15209 TOKEN_STRING_INITIALIZER
15210 (struct cmd_ptype_mapping_replace_result,
15212 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping =
15213 TOKEN_STRING_INITIALIZER
15214 (struct cmd_ptype_mapping_replace_result,
15215 mapping, "mapping");
15216 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace =
15217 TOKEN_STRING_INITIALIZER
15218 (struct cmd_ptype_mapping_replace_result,
15219 replace, "replace");
15220 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id =
15221 TOKEN_NUM_INITIALIZER
15222 (struct cmd_ptype_mapping_replace_result,
15224 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target =
15225 TOKEN_NUM_INITIALIZER
15226 (struct cmd_ptype_mapping_replace_result,
15228 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask =
15229 TOKEN_NUM_INITIALIZER
15230 (struct cmd_ptype_mapping_replace_result,
15232 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type =
15233 TOKEN_NUM_INITIALIZER
15234 (struct cmd_ptype_mapping_replace_result,
15238 cmd_ptype_mapping_replace_parsed(
15239 void *parsed_result,
15240 __attribute__((unused)) struct cmdline *cl,
15241 __attribute__((unused)) void *data)
15243 struct cmd_ptype_mapping_replace_result *res = parsed_result;
15244 int ret = -ENOTSUP;
15246 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15249 #ifdef RTE_LIBRTE_I40E_PMD
15250 ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id,
15260 printf("invalid ptype 0x%8x or 0x%8x\n",
15261 res->target, res->pkt_type);
15264 printf("invalid port_id %d\n", res->port_id);
15267 printf("function not implemented\n");
15270 printf("programming error: (%s)\n", strerror(-ret));
15274 cmdline_parse_inst_t cmd_ptype_mapping_replace = {
15275 .f = cmd_ptype_mapping_replace_parsed,
15278 "ptype mapping replace <port_id> <target> <mask> <pkt_type>",
15280 (void *)&cmd_ptype_mapping_replace_ptype,
15281 (void *)&cmd_ptype_mapping_replace_mapping,
15282 (void *)&cmd_ptype_mapping_replace_replace,
15283 (void *)&cmd_ptype_mapping_replace_port_id,
15284 (void *)&cmd_ptype_mapping_replace_target,
15285 (void *)&cmd_ptype_mapping_replace_mask,
15286 (void *)&cmd_ptype_mapping_replace_pkt_type,
15291 /* ptype mapping reset */
15293 /* Common result structure for ptype mapping reset */
15294 struct cmd_ptype_mapping_reset_result {
15295 cmdline_fixed_string_t ptype;
15296 cmdline_fixed_string_t mapping;
15297 cmdline_fixed_string_t reset;
15301 /* Common CLI fields for ptype mapping reset*/
15302 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype =
15303 TOKEN_STRING_INITIALIZER
15304 (struct cmd_ptype_mapping_reset_result,
15306 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping =
15307 TOKEN_STRING_INITIALIZER
15308 (struct cmd_ptype_mapping_reset_result,
15309 mapping, "mapping");
15310 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset =
15311 TOKEN_STRING_INITIALIZER
15312 (struct cmd_ptype_mapping_reset_result,
15314 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id =
15315 TOKEN_NUM_INITIALIZER
15316 (struct cmd_ptype_mapping_reset_result,
15320 cmd_ptype_mapping_reset_parsed(
15321 void *parsed_result,
15322 __attribute__((unused)) struct cmdline *cl,
15323 __attribute__((unused)) void *data)
15325 struct cmd_ptype_mapping_reset_result *res = parsed_result;
15326 int ret = -ENOTSUP;
15328 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15331 #ifdef RTE_LIBRTE_I40E_PMD
15332 ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id);
15339 printf("invalid port_id %d\n", res->port_id);
15342 printf("function not implemented\n");
15345 printf("programming error: (%s)\n", strerror(-ret));
15349 cmdline_parse_inst_t cmd_ptype_mapping_reset = {
15350 .f = cmd_ptype_mapping_reset_parsed,
15352 .help_str = "ptype mapping reset <port_id>",
15354 (void *)&cmd_ptype_mapping_reset_ptype,
15355 (void *)&cmd_ptype_mapping_reset_mapping,
15356 (void *)&cmd_ptype_mapping_reset_reset,
15357 (void *)&cmd_ptype_mapping_reset_port_id,
15362 /* ptype mapping update */
15364 /* Common result structure for ptype mapping update */
15365 struct cmd_ptype_mapping_update_result {
15366 cmdline_fixed_string_t ptype;
15367 cmdline_fixed_string_t mapping;
15368 cmdline_fixed_string_t reset;
15374 /* Common CLI fields for ptype mapping update*/
15375 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype =
15376 TOKEN_STRING_INITIALIZER
15377 (struct cmd_ptype_mapping_update_result,
15379 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping =
15380 TOKEN_STRING_INITIALIZER
15381 (struct cmd_ptype_mapping_update_result,
15382 mapping, "mapping");
15383 cmdline_parse_token_string_t cmd_ptype_mapping_update_update =
15384 TOKEN_STRING_INITIALIZER
15385 (struct cmd_ptype_mapping_update_result,
15387 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id =
15388 TOKEN_NUM_INITIALIZER
15389 (struct cmd_ptype_mapping_update_result,
15391 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype =
15392 TOKEN_NUM_INITIALIZER
15393 (struct cmd_ptype_mapping_update_result,
15395 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype =
15396 TOKEN_NUM_INITIALIZER
15397 (struct cmd_ptype_mapping_update_result,
15401 cmd_ptype_mapping_update_parsed(
15402 void *parsed_result,
15403 __attribute__((unused)) struct cmdline *cl,
15404 __attribute__((unused)) void *data)
15406 struct cmd_ptype_mapping_update_result *res = parsed_result;
15407 int ret = -ENOTSUP;
15408 #ifdef RTE_LIBRTE_I40E_PMD
15409 struct rte_pmd_i40e_ptype_mapping mapping;
15411 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15414 #ifdef RTE_LIBRTE_I40E_PMD
15415 mapping.hw_ptype = res->hw_ptype;
15416 mapping.sw_ptype = res->sw_ptype;
15417 ret = rte_pmd_i40e_ptype_mapping_update(res->port_id,
15427 printf("invalid ptype 0x%8x\n", res->sw_ptype);
15430 printf("invalid port_id %d\n", res->port_id);
15433 printf("function not implemented\n");
15436 printf("programming error: (%s)\n", strerror(-ret));
15440 cmdline_parse_inst_t cmd_ptype_mapping_update = {
15441 .f = cmd_ptype_mapping_update_parsed,
15443 .help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>",
15445 (void *)&cmd_ptype_mapping_update_ptype,
15446 (void *)&cmd_ptype_mapping_update_mapping,
15447 (void *)&cmd_ptype_mapping_update_update,
15448 (void *)&cmd_ptype_mapping_update_port_id,
15449 (void *)&cmd_ptype_mapping_update_hw_ptype,
15450 (void *)&cmd_ptype_mapping_update_sw_ptype,
15455 /* Common result structure for file commands */
15456 struct cmd_cmdfile_result {
15457 cmdline_fixed_string_t load;
15458 cmdline_fixed_string_t filename;
15461 /* Common CLI fields for file commands */
15462 cmdline_parse_token_string_t cmd_load_cmdfile =
15463 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
15464 cmdline_parse_token_string_t cmd_load_cmdfile_filename =
15465 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
15468 cmd_load_from_file_parsed(
15469 void *parsed_result,
15470 __attribute__((unused)) struct cmdline *cl,
15471 __attribute__((unused)) void *data)
15473 struct cmd_cmdfile_result *res = parsed_result;
15475 cmdline_read_from_file(res->filename);
15478 cmdline_parse_inst_t cmd_load_from_file = {
15479 .f = cmd_load_from_file_parsed,
15481 .help_str = "load <filename>",
15483 (void *)&cmd_load_cmdfile,
15484 (void *)&cmd_load_cmdfile_filename,
15489 /* ******************************************************************************** */
15491 /* list of instructions */
15492 cmdline_parse_ctx_t main_ctx[] = {
15493 (cmdline_parse_inst_t *)&cmd_help_brief,
15494 (cmdline_parse_inst_t *)&cmd_help_long,
15495 (cmdline_parse_inst_t *)&cmd_quit,
15496 (cmdline_parse_inst_t *)&cmd_load_from_file,
15497 (cmdline_parse_inst_t *)&cmd_showport,
15498 (cmdline_parse_inst_t *)&cmd_showqueue,
15499 (cmdline_parse_inst_t *)&cmd_showportall,
15500 (cmdline_parse_inst_t *)&cmd_showcfg,
15501 (cmdline_parse_inst_t *)&cmd_start,
15502 (cmdline_parse_inst_t *)&cmd_start_tx_first,
15503 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
15504 (cmdline_parse_inst_t *)&cmd_set_link_up,
15505 (cmdline_parse_inst_t *)&cmd_set_link_down,
15506 (cmdline_parse_inst_t *)&cmd_reset,
15507 (cmdline_parse_inst_t *)&cmd_set_numbers,
15508 (cmdline_parse_inst_t *)&cmd_set_txpkts,
15509 (cmdline_parse_inst_t *)&cmd_set_txsplit,
15510 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
15511 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
15512 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
15513 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
15514 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
15515 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
15516 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
15517 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
15518 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
15519 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
15520 (cmdline_parse_inst_t *)&cmd_set_link_check,
15521 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
15522 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
15523 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
15524 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
15525 #ifdef RTE_LIBRTE_PMD_BOND
15526 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
15527 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
15528 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
15529 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
15530 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
15531 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
15532 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
15533 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
15534 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
15535 (cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues,
15536 (cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy,
15538 (cmdline_parse_inst_t *)&cmd_vlan_offload,
15539 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
15540 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
15541 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
15542 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
15543 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
15544 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
15545 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
15546 (cmdline_parse_inst_t *)&cmd_csum_set,
15547 (cmdline_parse_inst_t *)&cmd_csum_show,
15548 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
15549 (cmdline_parse_inst_t *)&cmd_tso_set,
15550 (cmdline_parse_inst_t *)&cmd_tso_show,
15551 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
15552 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
15553 (cmdline_parse_inst_t *)&cmd_gro_enable,
15554 (cmdline_parse_inst_t *)&cmd_gro_flush,
15555 (cmdline_parse_inst_t *)&cmd_gro_show,
15556 (cmdline_parse_inst_t *)&cmd_gso_enable,
15557 (cmdline_parse_inst_t *)&cmd_gso_size,
15558 (cmdline_parse_inst_t *)&cmd_gso_show,
15559 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
15560 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
15561 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
15562 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
15563 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
15564 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
15565 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
15566 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
15567 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
15568 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
15569 (cmdline_parse_inst_t *)&cmd_config_dcb,
15570 (cmdline_parse_inst_t *)&cmd_read_reg,
15571 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
15572 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
15573 (cmdline_parse_inst_t *)&cmd_write_reg,
15574 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
15575 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
15576 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
15577 (cmdline_parse_inst_t *)&cmd_stop,
15578 (cmdline_parse_inst_t *)&cmd_mac_addr,
15579 (cmdline_parse_inst_t *)&cmd_set_qmap,
15580 (cmdline_parse_inst_t *)&cmd_operate_port,
15581 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
15582 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
15583 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
15584 (cmdline_parse_inst_t *)&cmd_config_speed_all,
15585 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
15586 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
15587 (cmdline_parse_inst_t *)&cmd_config_mtu,
15588 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
15589 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
15590 (cmdline_parse_inst_t *)&cmd_config_rss,
15591 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
15592 (cmdline_parse_inst_t *)&cmd_config_txqflags,
15593 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
15594 (cmdline_parse_inst_t *)&cmd_showport_reta,
15595 (cmdline_parse_inst_t *)&cmd_config_burst,
15596 (cmdline_parse_inst_t *)&cmd_config_thresh,
15597 (cmdline_parse_inst_t *)&cmd_config_threshold,
15598 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
15599 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
15600 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
15601 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
15602 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
15603 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
15604 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
15605 (cmdline_parse_inst_t *)&cmd_global_config,
15606 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
15607 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
15608 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
15609 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
15610 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
15611 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
15612 (cmdline_parse_inst_t *)&cmd_dump,
15613 (cmdline_parse_inst_t *)&cmd_dump_one,
15614 (cmdline_parse_inst_t *)&cmd_ethertype_filter,
15615 (cmdline_parse_inst_t *)&cmd_syn_filter,
15616 (cmdline_parse_inst_t *)&cmd_2tuple_filter,
15617 (cmdline_parse_inst_t *)&cmd_5tuple_filter,
15618 (cmdline_parse_inst_t *)&cmd_flex_filter,
15619 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
15620 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
15621 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
15622 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director,
15623 (cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director,
15624 (cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director,
15625 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
15626 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
15627 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
15628 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
15629 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
15630 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
15631 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
15632 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
15633 (cmdline_parse_inst_t *)&cmd_get_hash_global_config,
15634 (cmdline_parse_inst_t *)&cmd_set_hash_global_config,
15635 (cmdline_parse_inst_t *)&cmd_set_hash_input_set,
15636 (cmdline_parse_inst_t *)&cmd_set_fdir_input_set,
15637 (cmdline_parse_inst_t *)&cmd_flow,
15638 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm,
15639 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm,
15640 (cmdline_parse_inst_t *)&cmd_del_port_meter_profile,
15641 (cmdline_parse_inst_t *)&cmd_set_port_meter,
15642 (cmdline_parse_inst_t *)&cmd_del_port_meter,
15643 (cmdline_parse_inst_t *)&cmd_set_port_meter_profile,
15644 (cmdline_parse_inst_t *)&cmd_set_port_meter_policer_action,
15645 (cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask,
15646 (cmdline_parse_inst_t *)&cmd_show_port_meter_stats,
15647 (cmdline_parse_inst_t *)&cmd_mcast_addr,
15648 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all,
15649 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific,
15650 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all,
15651 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific,
15652 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_en,
15653 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_dis,
15654 (cmdline_parse_inst_t *)&cmd_config_e_tag_stripping_en_dis,
15655 (cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis,
15656 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_add,
15657 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_del,
15658 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
15659 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
15660 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
15661 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
15662 (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
15663 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
15664 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
15665 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
15666 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
15667 (cmdline_parse_inst_t *)&cmd_set_macsec_sc,
15668 (cmdline_parse_inst_t *)&cmd_set_macsec_sa,
15669 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
15670 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
15671 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
15672 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
15673 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
15674 (cmdline_parse_inst_t *)&cmd_set_vf_promisc,
15675 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
15676 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
15677 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
15678 (cmdline_parse_inst_t *)&cmd_vf_max_bw,
15679 (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
15680 (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
15681 (cmdline_parse_inst_t *)&cmd_strict_link_prio,
15682 (cmdline_parse_inst_t *)&cmd_tc_min_bw,
15683 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
15684 (cmdline_parse_inst_t *)&cmd_set_port_tm_hierarchy_default,
15686 (cmdline_parse_inst_t *)&cmd_ddp_add,
15687 (cmdline_parse_inst_t *)&cmd_ddp_del,
15688 (cmdline_parse_inst_t *)&cmd_ddp_get_list,
15689 (cmdline_parse_inst_t *)&cmd_ddp_get_info,
15690 (cmdline_parse_inst_t *)&cmd_show_vf_stats,
15691 (cmdline_parse_inst_t *)&cmd_clear_vf_stats,
15692 (cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
15693 (cmdline_parse_inst_t *)&cmd_ptype_mapping_replace,
15694 (cmdline_parse_inst_t *)&cmd_ptype_mapping_reset,
15695 (cmdline_parse_inst_t *)&cmd_ptype_mapping_update,
15697 (cmdline_parse_inst_t *)&cmd_pctype_mapping_get,
15698 (cmdline_parse_inst_t *)&cmd_pctype_mapping_reset,
15699 (cmdline_parse_inst_t *)&cmd_pctype_mapping_update,
15700 (cmdline_parse_inst_t *)&cmd_queue_region,
15701 (cmdline_parse_inst_t *)&cmd_region_flowtype,
15702 (cmdline_parse_inst_t *)&cmd_user_priority_region,
15703 (cmdline_parse_inst_t *)&cmd_flush_queue_region,
15704 (cmdline_parse_inst_t *)&cmd_show_queue_region_info_all,
15705 (cmdline_parse_inst_t *)&cmd_show_port_tm_cap,
15706 (cmdline_parse_inst_t *)&cmd_show_port_tm_level_cap,
15707 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_cap,
15708 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_type,
15709 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_stats,
15710 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shaper_profile,
15711 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shaper_profile,
15712 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shared_shaper,
15713 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shared_shaper,
15714 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_wred_profile,
15715 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_wred_profile,
15716 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_shaper_profile,
15717 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node,
15718 (cmdline_parse_inst_t *)&cmd_add_port_tm_leaf_node,
15719 (cmdline_parse_inst_t *)&cmd_del_port_tm_node,
15720 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_parent,
15721 (cmdline_parse_inst_t *)&cmd_port_tm_hierarchy_commit,
15725 /* read cmdline commands from file */
15727 cmdline_read_from_file(const char *filename)
15729 struct cmdline *cl;
15731 cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
15733 printf("Failed to create file based cmdline context: %s\n",
15738 cmdline_interact(cl);
15743 printf("Read CLI commands from %s\n", filename);
15746 /* prompt function, called from main on MASTER lcore */
15750 /* initialize non-constant commands */
15751 cmd_set_fwd_mode_init();
15752 cmd_set_fwd_retry_mode_init();
15754 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
15755 if (testpmd_cl == NULL)
15757 cmdline_interact(testpmd_cl);
15758 cmdline_stdin_exit(testpmd_cl);
15764 if (testpmd_cl != NULL)
15765 cmdline_quit(testpmd_cl);
15769 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
15771 if (id == (portid_t)RTE_PORT_ALL) {
15774 RTE_ETH_FOREACH_DEV(pid) {
15775 /* check if need_reconfig has been set to 1 */
15776 if (ports[pid].need_reconfig == 0)
15777 ports[pid].need_reconfig = dev;
15778 /* check if need_reconfig_queues has been set to 1 */
15779 if (ports[pid].need_reconfig_queues == 0)
15780 ports[pid].need_reconfig_queues = queue;
15782 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
15783 /* check if need_reconfig has been set to 1 */
15784 if (ports[id].need_reconfig == 0)
15785 ports[id].need_reconfig = dev;
15786 /* check if need_reconfig_queues has been set to 1 */
15787 if (ports[id].need_reconfig_queues == 0)
15788 ports[id].need_reconfig_queues = queue;