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 , list_pkt_forwarding_modes()
758 if (show_all || !strcmp(res->section, "ports")) {
764 "----------------\n\n"
766 "port start (port_id|all)\n"
767 " Start all ports or port_id.\n\n"
769 "port stop (port_id|all)\n"
770 " Stop all ports or port_id.\n\n"
772 "port close (port_id|all)\n"
773 " Close all ports or port_id.\n\n"
775 "port attach (ident)\n"
776 " Attach physical or virtual dev by pci address or virtual device name\n\n"
778 "port detach (port_id)\n"
779 " Detach physical or virtual dev by port_id\n\n"
781 "port config (port_id|all)"
782 " speed (10|100|1000|10000|25000|40000|50000|100000|auto)"
783 " duplex (half|full|auto)\n"
784 " Set speed and duplex for all ports or port_id\n\n"
786 "port config all (rxq|txq|rxd|txd) (value)\n"
787 " Set number for rxq/txq/rxd/txd.\n\n"
789 "port config all max-pkt-len (value)\n"
790 " Set the max packet length.\n\n"
792 "port config all (crc-strip|scatter|rx-cksum|rx-timestamp|hw-vlan|hw-vlan-filter|"
793 "hw-vlan-strip|hw-vlan-extend|drop-en)"
795 " Set crc-strip/scatter/rx-checksum/hardware-vlan/drop_en"
798 "port config all rss (all|ip|tcp|udp|sctp|ether|port|vxlan|"
799 "geneve|nvgre|none|<flowtype_id>)\n"
800 " Set the RSS mode.\n\n"
802 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
803 " Set the RSS redirection table.\n\n"
805 "port config (port_id) dcb vt (on|off) (traffic_class)"
807 " Set the DCB mode.\n\n"
809 "port config all burst (value)\n"
810 " Set the number of packets per burst.\n\n"
812 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
814 " Set the ring prefetch/host/writeback threshold"
815 " for tx/rx queue.\n\n"
817 "port config all (txfreet|txrst|rxfreet) (value)\n"
818 " Set free threshold for rx/tx, or set"
819 " tx rs bit threshold.\n\n"
820 "port config mtu X value\n"
821 " Set the MTU of port X to a given value\n\n"
823 "port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
824 " Start/stop a rx/tx queue of port X. Only take effect"
825 " when port X is started\n\n"
827 "port config (port_id|all) l2-tunnel E-tag ether-type"
829 " Set the value of E-tag ether-type.\n\n"
831 "port config (port_id|all) l2-tunnel E-tag"
832 " (enable|disable)\n"
833 " Enable/disable the E-tag support.\n\n"
835 "port config (port_id) pctype mapping reset\n"
836 " Reset flow type to pctype mapping on a port\n\n"
838 "port config (port_id) pctype mapping update"
839 " (pctype_id_0[,pctype_id_1]*) (flow_type_id)\n"
840 " Update a flow type to pctype mapping item on a port\n\n"
844 if (show_all || !strcmp(res->section, "registers")) {
852 "read reg (port_id) (address)\n"
853 " Display value of a port register.\n\n"
855 "read regfield (port_id) (address) (bit_x) (bit_y)\n"
856 " Display a port register bit field.\n\n"
858 "read regbit (port_id) (address) (bit_x)\n"
859 " Display a single port register bit.\n\n"
861 "write reg (port_id) (address) (value)\n"
862 " Set value of a port register.\n\n"
864 "write regfield (port_id) (address) (bit_x) (bit_y)"
866 " Set bit field of a port register.\n\n"
868 "write regbit (port_id) (address) (bit_x) (value)\n"
869 " Set single bit value of a port register.\n\n"
872 if (show_all || !strcmp(res->section, "filters")) {
880 "ethertype_filter (port_id) (add|del)"
881 " (mac_addr|mac_ignr) (mac_address) ethertype"
882 " (ether_type) (drop|fwd) queue (queue_id)\n"
883 " Add/Del an ethertype filter.\n\n"
885 "2tuple_filter (port_id) (add|del)"
886 " dst_port (dst_port_value) protocol (protocol_value)"
887 " mask (mask_value) tcp_flags (tcp_flags_value)"
888 " priority (prio_value) queue (queue_id)\n"
889 " Add/Del a 2tuple filter.\n\n"
891 "5tuple_filter (port_id) (add|del)"
892 " dst_ip (dst_address) src_ip (src_address)"
893 " dst_port (dst_port_value) src_port (src_port_value)"
894 " protocol (protocol_value)"
895 " mask (mask_value) tcp_flags (tcp_flags_value)"
896 " priority (prio_value) queue (queue_id)\n"
897 " Add/Del a 5tuple filter.\n\n"
899 "syn_filter (port_id) (add|del) priority (high|low) queue (queue_id)"
900 " Add/Del syn filter.\n\n"
902 "flex_filter (port_id) (add|del) len (len_value)"
903 " bytes (bytes_value) mask (mask_value)"
904 " priority (prio_value) queue (queue_id)\n"
905 " Add/Del a flex filter.\n\n"
907 "flow_director_filter (port_id) mode IP (add|del|update)"
908 " flow (ipv4-other|ipv4-frag|ipv6-other|ipv6-frag)"
909 " src (src_ip_address) dst (dst_ip_address)"
910 " tos (tos_value) proto (proto_value) ttl (ttl_value)"
911 " vlan (vlan_value) flexbytes (flexbytes_value)"
912 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
913 " fd_id (fd_id_value)\n"
914 " Add/Del an IP type flow director filter.\n\n"
916 "flow_director_filter (port_id) mode IP (add|del|update)"
917 " flow (ipv4-tcp|ipv4-udp|ipv6-tcp|ipv6-udp)"
918 " src (src_ip_address) (src_port)"
919 " dst (dst_ip_address) (dst_port)"
920 " tos (tos_value) ttl (ttl_value)"
921 " vlan (vlan_value) flexbytes (flexbytes_value)"
922 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
923 " fd_id (fd_id_value)\n"
924 " Add/Del an UDP/TCP type flow director filter.\n\n"
926 "flow_director_filter (port_id) mode IP (add|del|update)"
927 " flow (ipv4-sctp|ipv6-sctp)"
928 " src (src_ip_address) (src_port)"
929 " dst (dst_ip_address) (dst_port)"
930 " tag (verification_tag) "
931 " tos (tos_value) ttl (ttl_value)"
933 " flexbytes (flexbytes_value) (drop|fwd)"
934 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
935 " Add/Del a SCTP type flow director filter.\n\n"
937 "flow_director_filter (port_id) mode IP (add|del|update)"
938 " flow l2_payload ether (ethertype)"
939 " flexbytes (flexbytes_value) (drop|fwd)"
940 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
941 " Add/Del a l2 payload type flow director filter.\n\n"
943 "flow_director_filter (port_id) mode MAC-VLAN (add|del|update)"
944 " mac (mac_address) vlan (vlan_value)"
945 " flexbytes (flexbytes_value) (drop|fwd)"
946 " queue (queue_id) fd_id (fd_id_value)\n"
947 " Add/Del a MAC-VLAN flow director filter.\n\n"
949 "flow_director_filter (port_id) mode Tunnel (add|del|update)"
950 " mac (mac_address) vlan (vlan_value)"
951 " tunnel (NVGRE|VxLAN) tunnel-id (tunnel_id_value)"
952 " flexbytes (flexbytes_value) (drop|fwd)"
953 " queue (queue_id) fd_id (fd_id_value)\n"
954 " Add/Del a Tunnel flow director filter.\n\n"
956 "flush_flow_director (port_id)\n"
957 " Flush all flow director entries of a device.\n\n"
959 "flow_director_mask (port_id) mode IP vlan (vlan_value)"
960 " src_mask (ipv4_src) (ipv6_src) (src_port)"
961 " dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n"
962 " Set flow director IP mask.\n\n"
964 "flow_director_mask (port_id) mode MAC-VLAN"
965 " vlan (vlan_value)\n"
966 " Set flow director MAC-VLAN mask.\n\n"
968 "flow_director_mask (port_id) mode Tunnel"
969 " vlan (vlan_value) mac (mac_value)"
970 " tunnel-type (tunnel_type_value)"
971 " tunnel-id (tunnel_id_value)\n"
972 " Set flow director Tunnel mask.\n\n"
974 "flow_director_flex_mask (port_id)"
975 " flow (none|ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
976 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|l2_payload|all)"
978 " Configure mask of flex payload.\n\n"
980 "flow_director_flex_payload (port_id)"
981 " (raw|l2|l3|l4) (config)\n"
982 " Configure flex payload selection.\n\n"
984 "get_sym_hash_ena_per_port (port_id)\n"
985 " get symmetric hash enable configuration per port.\n\n"
987 "set_sym_hash_ena_per_port (port_id) (enable|disable)\n"
988 " set symmetric hash enable configuration per port"
989 " to enable or disable.\n\n"
991 "get_hash_global_config (port_id)\n"
992 " Get the global configurations of hash filters.\n\n"
994 "set_hash_global_config (port_id) (toeplitz|simple_xor|default)"
995 " (ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
996 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload)"
997 " (enable|disable)\n"
998 " Set the global configurations of hash filters.\n\n"
1000 "set_hash_input_set (port_id) (ipv4|ipv4-frag|"
1001 "ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
1002 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1003 "l2_payload|<flowtype_id>) (ovlan|ivlan|src-ipv4|dst-ipv4|"
1004 "src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|ipv6-tc|"
1005 "ipv6-next-header|udp-src-port|udp-dst-port|"
1006 "tcp-src-port|tcp-dst-port|sctp-src-port|"
1007 "sctp-dst-port|sctp-veri-tag|udp-key|gre-key|fld-1st|"
1008 "fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|fld-7th|"
1009 "fld-8th|none) (select|add)\n"
1010 " Set the input set for hash.\n\n"
1012 "set_fdir_input_set (port_id) "
1013 "(ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
1014 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1015 "l2_payload) (ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|"
1016 "dst-ipv6|ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|"
1017 "ipv6-next-header|ipv6-hop-limits|udp-src-port|"
1018 "udp-dst-port|tcp-src-port|tcp-dst-port|"
1019 "sctp-src-port|sctp-dst-port|sctp-veri-tag|none)"
1021 " Set the input set for FDir.\n\n"
1023 "flow validate {port_id}"
1024 " [group {group_id}] [priority {level}]"
1025 " [ingress] [egress]"
1026 " pattern {item} [/ {item} [...]] / end"
1027 " actions {action} [/ {action} [...]] / end\n"
1028 " Check whether a flow rule can be created.\n\n"
1030 "flow create {port_id}"
1031 " [group {group_id}] [priority {level}]"
1032 " [ingress] [egress]"
1033 " pattern {item} [/ {item} [...]] / end"
1034 " actions {action} [/ {action} [...]] / end\n"
1035 " Create a flow rule.\n\n"
1037 "flow destroy {port_id} rule {rule_id} [...]\n"
1038 " Destroy specific flow rules.\n\n"
1040 "flow flush {port_id}\n"
1041 " Destroy all flow rules.\n\n"
1043 "flow query {port_id} {rule_id} {action}\n"
1044 " Query an existing flow rule.\n\n"
1046 "flow list {port_id} [group {group_id}] [...]\n"
1047 " List existing flow rules sorted by priority,"
1048 " filtered by group identifiers.\n\n"
1050 "flow isolate {port_id} {boolean}\n"
1051 " Restrict ingress traffic to the defined"
1057 cmdline_parse_token_string_t cmd_help_long_help =
1058 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
1060 cmdline_parse_token_string_t cmd_help_long_section =
1061 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
1062 "all#control#display#config#"
1063 "ports#registers#filters");
1065 cmdline_parse_inst_t cmd_help_long = {
1066 .f = cmd_help_long_parsed,
1068 .help_str = "help all|control|display|config|ports|register|filters: "
1071 (void *)&cmd_help_long_help,
1072 (void *)&cmd_help_long_section,
1078 /* *** start/stop/close all ports *** */
1079 struct cmd_operate_port_result {
1080 cmdline_fixed_string_t keyword;
1081 cmdline_fixed_string_t name;
1082 cmdline_fixed_string_t value;
1085 static void cmd_operate_port_parsed(void *parsed_result,
1086 __attribute__((unused)) struct cmdline *cl,
1087 __attribute__((unused)) void *data)
1089 struct cmd_operate_port_result *res = parsed_result;
1091 if (!strcmp(res->name, "start"))
1092 start_port(RTE_PORT_ALL);
1093 else if (!strcmp(res->name, "stop"))
1094 stop_port(RTE_PORT_ALL);
1095 else if (!strcmp(res->name, "close"))
1096 close_port(RTE_PORT_ALL);
1097 else if (!strcmp(res->name, "reset"))
1098 reset_port(RTE_PORT_ALL);
1100 printf("Unknown parameter\n");
1103 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
1104 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
1106 cmdline_parse_token_string_t cmd_operate_port_all_port =
1107 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
1108 "start#stop#close#reset");
1109 cmdline_parse_token_string_t cmd_operate_port_all_all =
1110 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
1112 cmdline_parse_inst_t cmd_operate_port = {
1113 .f = cmd_operate_port_parsed,
1115 .help_str = "port start|stop|close all: Start/Stop/Close/Reset all ports",
1117 (void *)&cmd_operate_port_all_cmd,
1118 (void *)&cmd_operate_port_all_port,
1119 (void *)&cmd_operate_port_all_all,
1124 /* *** start/stop/close specific port *** */
1125 struct cmd_operate_specific_port_result {
1126 cmdline_fixed_string_t keyword;
1127 cmdline_fixed_string_t name;
1131 static void cmd_operate_specific_port_parsed(void *parsed_result,
1132 __attribute__((unused)) struct cmdline *cl,
1133 __attribute__((unused)) void *data)
1135 struct cmd_operate_specific_port_result *res = parsed_result;
1137 if (!strcmp(res->name, "start"))
1138 start_port(res->value);
1139 else if (!strcmp(res->name, "stop"))
1140 stop_port(res->value);
1141 else if (!strcmp(res->name, "close"))
1142 close_port(res->value);
1143 else if (!strcmp(res->name, "reset"))
1144 reset_port(res->value);
1146 printf("Unknown parameter\n");
1149 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
1150 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1152 cmdline_parse_token_string_t cmd_operate_specific_port_port =
1153 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1154 name, "start#stop#close#reset");
1155 cmdline_parse_token_num_t cmd_operate_specific_port_id =
1156 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
1159 cmdline_parse_inst_t cmd_operate_specific_port = {
1160 .f = cmd_operate_specific_port_parsed,
1162 .help_str = "port start|stop|close <port_id>: Start/Stop/Close/Reset port_id",
1164 (void *)&cmd_operate_specific_port_cmd,
1165 (void *)&cmd_operate_specific_port_port,
1166 (void *)&cmd_operate_specific_port_id,
1171 /* *** attach a specified port *** */
1172 struct cmd_operate_attach_port_result {
1173 cmdline_fixed_string_t port;
1174 cmdline_fixed_string_t keyword;
1175 cmdline_fixed_string_t identifier;
1178 static void cmd_operate_attach_port_parsed(void *parsed_result,
1179 __attribute__((unused)) struct cmdline *cl,
1180 __attribute__((unused)) void *data)
1182 struct cmd_operate_attach_port_result *res = parsed_result;
1184 if (!strcmp(res->keyword, "attach"))
1185 attach_port(res->identifier);
1187 printf("Unknown parameter\n");
1190 cmdline_parse_token_string_t cmd_operate_attach_port_port =
1191 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1193 cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
1194 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1196 cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
1197 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1200 cmdline_parse_inst_t cmd_operate_attach_port = {
1201 .f = cmd_operate_attach_port_parsed,
1203 .help_str = "port attach <identifier>: "
1204 "(identifier: pci address or virtual dev name)",
1206 (void *)&cmd_operate_attach_port_port,
1207 (void *)&cmd_operate_attach_port_keyword,
1208 (void *)&cmd_operate_attach_port_identifier,
1213 /* *** detach a specified port *** */
1214 struct cmd_operate_detach_port_result {
1215 cmdline_fixed_string_t port;
1216 cmdline_fixed_string_t keyword;
1220 static void cmd_operate_detach_port_parsed(void *parsed_result,
1221 __attribute__((unused)) struct cmdline *cl,
1222 __attribute__((unused)) void *data)
1224 struct cmd_operate_detach_port_result *res = parsed_result;
1226 if (!strcmp(res->keyword, "detach"))
1227 detach_port(res->port_id);
1229 printf("Unknown parameter\n");
1232 cmdline_parse_token_string_t cmd_operate_detach_port_port =
1233 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1235 cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
1236 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1238 cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
1239 TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
1242 cmdline_parse_inst_t cmd_operate_detach_port = {
1243 .f = cmd_operate_detach_port_parsed,
1245 .help_str = "port detach <port_id>",
1247 (void *)&cmd_operate_detach_port_port,
1248 (void *)&cmd_operate_detach_port_keyword,
1249 (void *)&cmd_operate_detach_port_port_id,
1254 /* *** configure speed for all ports *** */
1255 struct cmd_config_speed_all {
1256 cmdline_fixed_string_t port;
1257 cmdline_fixed_string_t keyword;
1258 cmdline_fixed_string_t all;
1259 cmdline_fixed_string_t item1;
1260 cmdline_fixed_string_t item2;
1261 cmdline_fixed_string_t value1;
1262 cmdline_fixed_string_t value2;
1266 parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed)
1271 if (!strcmp(duplexstr, "half")) {
1272 duplex = ETH_LINK_HALF_DUPLEX;
1273 } else if (!strcmp(duplexstr, "full")) {
1274 duplex = ETH_LINK_FULL_DUPLEX;
1275 } else if (!strcmp(duplexstr, "auto")) {
1276 duplex = ETH_LINK_FULL_DUPLEX;
1278 printf("Unknown duplex parameter\n");
1282 if (!strcmp(speedstr, "10")) {
1283 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1284 ETH_LINK_SPEED_10M_HD : ETH_LINK_SPEED_10M;
1285 } else if (!strcmp(speedstr, "100")) {
1286 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1287 ETH_LINK_SPEED_100M_HD : ETH_LINK_SPEED_100M;
1289 if (duplex != ETH_LINK_FULL_DUPLEX) {
1290 printf("Invalid speed/duplex parameters\n");
1293 if (!strcmp(speedstr, "1000")) {
1294 *speed = ETH_LINK_SPEED_1G;
1295 } else if (!strcmp(speedstr, "10000")) {
1296 *speed = ETH_LINK_SPEED_10G;
1297 } else if (!strcmp(speedstr, "25000")) {
1298 *speed = ETH_LINK_SPEED_25G;
1299 } else if (!strcmp(speedstr, "40000")) {
1300 *speed = ETH_LINK_SPEED_40G;
1301 } else if (!strcmp(speedstr, "50000")) {
1302 *speed = ETH_LINK_SPEED_50G;
1303 } else if (!strcmp(speedstr, "100000")) {
1304 *speed = ETH_LINK_SPEED_100G;
1305 } else if (!strcmp(speedstr, "auto")) {
1306 *speed = ETH_LINK_SPEED_AUTONEG;
1308 printf("Unknown speed parameter\n");
1317 cmd_config_speed_all_parsed(void *parsed_result,
1318 __attribute__((unused)) struct cmdline *cl,
1319 __attribute__((unused)) void *data)
1321 struct cmd_config_speed_all *res = parsed_result;
1322 uint32_t link_speed;
1325 if (!all_ports_stopped()) {
1326 printf("Please stop all ports first\n");
1330 if (parse_and_check_speed_duplex(res->value1, res->value2,
1334 RTE_ETH_FOREACH_DEV(pid) {
1335 ports[pid].dev_conf.link_speeds = link_speed;
1338 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1341 cmdline_parse_token_string_t cmd_config_speed_all_port =
1342 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1343 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1344 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1346 cmdline_parse_token_string_t cmd_config_speed_all_all =
1347 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1348 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1349 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1350 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1351 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1352 "10#100#1000#10000#25000#40000#50000#100000#auto");
1353 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1354 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1355 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1356 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1359 cmdline_parse_inst_t cmd_config_speed_all = {
1360 .f = cmd_config_speed_all_parsed,
1362 .help_str = "port config all speed "
1363 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1366 (void *)&cmd_config_speed_all_port,
1367 (void *)&cmd_config_speed_all_keyword,
1368 (void *)&cmd_config_speed_all_all,
1369 (void *)&cmd_config_speed_all_item1,
1370 (void *)&cmd_config_speed_all_value1,
1371 (void *)&cmd_config_speed_all_item2,
1372 (void *)&cmd_config_speed_all_value2,
1377 /* *** configure speed for specific port *** */
1378 struct cmd_config_speed_specific {
1379 cmdline_fixed_string_t port;
1380 cmdline_fixed_string_t keyword;
1382 cmdline_fixed_string_t item1;
1383 cmdline_fixed_string_t item2;
1384 cmdline_fixed_string_t value1;
1385 cmdline_fixed_string_t value2;
1389 cmd_config_speed_specific_parsed(void *parsed_result,
1390 __attribute__((unused)) struct cmdline *cl,
1391 __attribute__((unused)) void *data)
1393 struct cmd_config_speed_specific *res = parsed_result;
1394 uint32_t link_speed;
1396 if (!all_ports_stopped()) {
1397 printf("Please stop all ports first\n");
1401 if (port_id_is_invalid(res->id, ENABLED_WARN))
1404 if (parse_and_check_speed_duplex(res->value1, res->value2,
1408 ports[res->id].dev_conf.link_speeds = link_speed;
1410 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1414 cmdline_parse_token_string_t cmd_config_speed_specific_port =
1415 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1417 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1418 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1420 cmdline_parse_token_num_t cmd_config_speed_specific_id =
1421 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT8);
1422 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1423 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1425 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1426 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1427 "10#100#1000#10000#25000#40000#50000#100000#auto");
1428 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1429 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1431 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1432 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1435 cmdline_parse_inst_t cmd_config_speed_specific = {
1436 .f = cmd_config_speed_specific_parsed,
1438 .help_str = "port config <port_id> speed "
1439 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1442 (void *)&cmd_config_speed_specific_port,
1443 (void *)&cmd_config_speed_specific_keyword,
1444 (void *)&cmd_config_speed_specific_id,
1445 (void *)&cmd_config_speed_specific_item1,
1446 (void *)&cmd_config_speed_specific_value1,
1447 (void *)&cmd_config_speed_specific_item2,
1448 (void *)&cmd_config_speed_specific_value2,
1453 /* *** configure txq/rxq, txd/rxd *** */
1454 struct cmd_config_rx_tx {
1455 cmdline_fixed_string_t port;
1456 cmdline_fixed_string_t keyword;
1457 cmdline_fixed_string_t all;
1458 cmdline_fixed_string_t name;
1463 cmd_config_rx_tx_parsed(void *parsed_result,
1464 __attribute__((unused)) struct cmdline *cl,
1465 __attribute__((unused)) void *data)
1467 struct cmd_config_rx_tx *res = parsed_result;
1469 if (!all_ports_stopped()) {
1470 printf("Please stop all ports first\n");
1473 if (!strcmp(res->name, "rxq")) {
1474 if (!res->value && !nb_txq) {
1475 printf("Warning: Either rx or tx queues should be non zero\n");
1478 nb_rxq = res->value;
1480 else if (!strcmp(res->name, "txq")) {
1481 if (!res->value && !nb_rxq) {
1482 printf("Warning: Either rx or tx queues should be non zero\n");
1485 nb_txq = res->value;
1487 else if (!strcmp(res->name, "rxd")) {
1488 if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) {
1489 printf("rxd %d invalid - must be > 0 && <= %d\n",
1490 res->value, RTE_TEST_RX_DESC_MAX);
1493 nb_rxd = res->value;
1494 } else if (!strcmp(res->name, "txd")) {
1495 if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) {
1496 printf("txd %d invalid - must be > 0 && <= %d\n",
1497 res->value, RTE_TEST_TX_DESC_MAX);
1500 nb_txd = res->value;
1502 printf("Unknown parameter\n");
1510 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1513 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1514 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1515 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1516 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1517 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1518 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1519 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1520 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1522 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1523 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
1525 cmdline_parse_inst_t cmd_config_rx_tx = {
1526 .f = cmd_config_rx_tx_parsed,
1528 .help_str = "port config all rxq|txq|rxd|txd <value>",
1530 (void *)&cmd_config_rx_tx_port,
1531 (void *)&cmd_config_rx_tx_keyword,
1532 (void *)&cmd_config_rx_tx_all,
1533 (void *)&cmd_config_rx_tx_name,
1534 (void *)&cmd_config_rx_tx_value,
1539 /* *** config max packet length *** */
1540 struct cmd_config_max_pkt_len_result {
1541 cmdline_fixed_string_t port;
1542 cmdline_fixed_string_t keyword;
1543 cmdline_fixed_string_t all;
1544 cmdline_fixed_string_t name;
1549 cmd_config_max_pkt_len_parsed(void *parsed_result,
1550 __attribute__((unused)) struct cmdline *cl,
1551 __attribute__((unused)) void *data)
1553 struct cmd_config_max_pkt_len_result *res = parsed_result;
1555 if (!all_ports_stopped()) {
1556 printf("Please stop all ports first\n");
1560 if (!strcmp(res->name, "max-pkt-len")) {
1561 if (res->value < ETHER_MIN_LEN) {
1562 printf("max-pkt-len can not be less than %d\n",
1566 if (res->value == rx_mode.max_rx_pkt_len)
1569 rx_mode.max_rx_pkt_len = res->value;
1570 if (res->value > ETHER_MAX_LEN)
1571 rx_mode.jumbo_frame = 1;
1573 rx_mode.jumbo_frame = 0;
1575 printf("Unknown parameter\n");
1581 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1584 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
1585 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
1587 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
1588 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
1590 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
1591 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
1593 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
1594 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
1596 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1597 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1600 cmdline_parse_inst_t cmd_config_max_pkt_len = {
1601 .f = cmd_config_max_pkt_len_parsed,
1603 .help_str = "port config all max-pkt-len <value>",
1605 (void *)&cmd_config_max_pkt_len_port,
1606 (void *)&cmd_config_max_pkt_len_keyword,
1607 (void *)&cmd_config_max_pkt_len_all,
1608 (void *)&cmd_config_max_pkt_len_name,
1609 (void *)&cmd_config_max_pkt_len_value,
1614 /* *** configure port MTU *** */
1615 struct cmd_config_mtu_result {
1616 cmdline_fixed_string_t port;
1617 cmdline_fixed_string_t keyword;
1618 cmdline_fixed_string_t mtu;
1624 cmd_config_mtu_parsed(void *parsed_result,
1625 __attribute__((unused)) struct cmdline *cl,
1626 __attribute__((unused)) void *data)
1628 struct cmd_config_mtu_result *res = parsed_result;
1630 if (res->value < ETHER_MIN_LEN) {
1631 printf("mtu cannot be less than %d\n", ETHER_MIN_LEN);
1634 port_mtu_set(res->port_id, res->value);
1637 cmdline_parse_token_string_t cmd_config_mtu_port =
1638 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
1640 cmdline_parse_token_string_t cmd_config_mtu_keyword =
1641 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1643 cmdline_parse_token_string_t cmd_config_mtu_mtu =
1644 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1646 cmdline_parse_token_num_t cmd_config_mtu_port_id =
1647 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT16);
1648 cmdline_parse_token_num_t cmd_config_mtu_value =
1649 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
1651 cmdline_parse_inst_t cmd_config_mtu = {
1652 .f = cmd_config_mtu_parsed,
1654 .help_str = "port config mtu <port_id> <value>",
1656 (void *)&cmd_config_mtu_port,
1657 (void *)&cmd_config_mtu_keyword,
1658 (void *)&cmd_config_mtu_mtu,
1659 (void *)&cmd_config_mtu_port_id,
1660 (void *)&cmd_config_mtu_value,
1665 /* *** configure rx mode *** */
1666 struct cmd_config_rx_mode_flag {
1667 cmdline_fixed_string_t port;
1668 cmdline_fixed_string_t keyword;
1669 cmdline_fixed_string_t all;
1670 cmdline_fixed_string_t name;
1671 cmdline_fixed_string_t value;
1675 cmd_config_rx_mode_flag_parsed(void *parsed_result,
1676 __attribute__((unused)) struct cmdline *cl,
1677 __attribute__((unused)) void *data)
1679 struct cmd_config_rx_mode_flag *res = parsed_result;
1681 if (!all_ports_stopped()) {
1682 printf("Please stop all ports first\n");
1686 if (!strcmp(res->name, "crc-strip")) {
1687 if (!strcmp(res->value, "on"))
1688 rx_mode.hw_strip_crc = 1;
1689 else if (!strcmp(res->value, "off"))
1690 rx_mode.hw_strip_crc = 0;
1692 printf("Unknown parameter\n");
1695 } else if (!strcmp(res->name, "scatter")) {
1696 if (!strcmp(res->value, "on"))
1697 rx_mode.enable_scatter = 1;
1698 else if (!strcmp(res->value, "off"))
1699 rx_mode.enable_scatter = 0;
1701 printf("Unknown parameter\n");
1704 } else if (!strcmp(res->name, "rx-cksum")) {
1705 if (!strcmp(res->value, "on"))
1706 rx_mode.hw_ip_checksum = 1;
1707 else if (!strcmp(res->value, "off"))
1708 rx_mode.hw_ip_checksum = 0;
1710 printf("Unknown parameter\n");
1713 } else if (!strcmp(res->name, "rx-timestamp")) {
1714 if (!strcmp(res->value, "on"))
1715 rx_mode.hw_timestamp = 1;
1716 else if (!strcmp(res->value, "off"))
1717 rx_mode.hw_timestamp = 0;
1719 printf("Unknown parameter\n");
1722 } else if (!strcmp(res->name, "hw-vlan")) {
1723 if (!strcmp(res->value, "on")) {
1724 rx_mode.hw_vlan_filter = 1;
1725 rx_mode.hw_vlan_strip = 1;
1727 else if (!strcmp(res->value, "off")) {
1728 rx_mode.hw_vlan_filter = 0;
1729 rx_mode.hw_vlan_strip = 0;
1732 printf("Unknown parameter\n");
1735 } else if (!strcmp(res->name, "hw-vlan-filter")) {
1736 if (!strcmp(res->value, "on"))
1737 rx_mode.hw_vlan_filter = 1;
1738 else if (!strcmp(res->value, "off"))
1739 rx_mode.hw_vlan_filter = 0;
1741 printf("Unknown parameter\n");
1744 } else if (!strcmp(res->name, "hw-vlan-strip")) {
1745 if (!strcmp(res->value, "on"))
1746 rx_mode.hw_vlan_strip = 1;
1747 else if (!strcmp(res->value, "off"))
1748 rx_mode.hw_vlan_strip = 0;
1750 printf("Unknown parameter\n");
1753 } else if (!strcmp(res->name, "hw-vlan-extend")) {
1754 if (!strcmp(res->value, "on"))
1755 rx_mode.hw_vlan_extend = 1;
1756 else if (!strcmp(res->value, "off"))
1757 rx_mode.hw_vlan_extend = 0;
1759 printf("Unknown parameter\n");
1762 } else if (!strcmp(res->name, "drop-en")) {
1763 if (!strcmp(res->value, "on"))
1765 else if (!strcmp(res->value, "off"))
1768 printf("Unknown parameter\n");
1772 printf("Unknown parameter\n");
1778 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1781 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
1782 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
1783 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
1784 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
1786 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
1787 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
1788 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
1789 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
1790 "crc-strip#scatter#rx-cksum#rx-timestamp#hw-vlan#"
1791 "hw-vlan-filter#hw-vlan-strip#hw-vlan-extend");
1792 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
1793 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
1796 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
1797 .f = cmd_config_rx_mode_flag_parsed,
1799 .help_str = "port config all crc-strip|scatter|rx-cksum|rx-timestamp|hw-vlan|"
1800 "hw-vlan-filter|hw-vlan-strip|hw-vlan-extend on|off",
1802 (void *)&cmd_config_rx_mode_flag_port,
1803 (void *)&cmd_config_rx_mode_flag_keyword,
1804 (void *)&cmd_config_rx_mode_flag_all,
1805 (void *)&cmd_config_rx_mode_flag_name,
1806 (void *)&cmd_config_rx_mode_flag_value,
1811 /* *** configure rss *** */
1812 struct cmd_config_rss {
1813 cmdline_fixed_string_t port;
1814 cmdline_fixed_string_t keyword;
1815 cmdline_fixed_string_t all;
1816 cmdline_fixed_string_t name;
1817 cmdline_fixed_string_t value;
1821 cmd_config_rss_parsed(void *parsed_result,
1822 __attribute__((unused)) struct cmdline *cl,
1823 __attribute__((unused)) void *data)
1825 struct cmd_config_rss *res = parsed_result;
1826 struct rte_eth_rss_conf rss_conf;
1830 if (!strcmp(res->value, "all"))
1831 rss_conf.rss_hf = ETH_RSS_IP | ETH_RSS_TCP |
1832 ETH_RSS_UDP | ETH_RSS_SCTP |
1834 else if (!strcmp(res->value, "ip"))
1835 rss_conf.rss_hf = ETH_RSS_IP;
1836 else if (!strcmp(res->value, "udp"))
1837 rss_conf.rss_hf = ETH_RSS_UDP;
1838 else if (!strcmp(res->value, "tcp"))
1839 rss_conf.rss_hf = ETH_RSS_TCP;
1840 else if (!strcmp(res->value, "sctp"))
1841 rss_conf.rss_hf = ETH_RSS_SCTP;
1842 else if (!strcmp(res->value, "ether"))
1843 rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD;
1844 else if (!strcmp(res->value, "port"))
1845 rss_conf.rss_hf = ETH_RSS_PORT;
1846 else if (!strcmp(res->value, "vxlan"))
1847 rss_conf.rss_hf = ETH_RSS_VXLAN;
1848 else if (!strcmp(res->value, "geneve"))
1849 rss_conf.rss_hf = ETH_RSS_GENEVE;
1850 else if (!strcmp(res->value, "nvgre"))
1851 rss_conf.rss_hf = ETH_RSS_NVGRE;
1852 else if (!strcmp(res->value, "none"))
1853 rss_conf.rss_hf = 0;
1854 else if (isdigit(res->value[0]) && atoi(res->value) > 0 &&
1855 atoi(res->value) < 64)
1856 rss_conf.rss_hf = 1ULL << atoi(res->value);
1858 printf("Unknown parameter\n");
1861 rss_conf.rss_key = NULL;
1862 for (i = 0; i < rte_eth_dev_count(); i++) {
1863 diag = rte_eth_dev_rss_hash_update(i, &rss_conf);
1865 printf("Configuration of RSS hash at ethernet port %d "
1866 "failed with error (%d): %s.\n",
1867 i, -diag, strerror(-diag));
1871 cmdline_parse_token_string_t cmd_config_rss_port =
1872 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
1873 cmdline_parse_token_string_t cmd_config_rss_keyword =
1874 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
1875 cmdline_parse_token_string_t cmd_config_rss_all =
1876 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
1877 cmdline_parse_token_string_t cmd_config_rss_name =
1878 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
1879 cmdline_parse_token_string_t cmd_config_rss_value =
1880 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, NULL);
1882 cmdline_parse_inst_t cmd_config_rss = {
1883 .f = cmd_config_rss_parsed,
1885 .help_str = "port config all rss "
1886 "all|ip|tcp|udp|sctp|ether|port|vxlan|geneve|nvgre|none|<flowtype_id>",
1888 (void *)&cmd_config_rss_port,
1889 (void *)&cmd_config_rss_keyword,
1890 (void *)&cmd_config_rss_all,
1891 (void *)&cmd_config_rss_name,
1892 (void *)&cmd_config_rss_value,
1897 /* *** configure rss hash key *** */
1898 struct cmd_config_rss_hash_key {
1899 cmdline_fixed_string_t port;
1900 cmdline_fixed_string_t config;
1902 cmdline_fixed_string_t rss_hash_key;
1903 cmdline_fixed_string_t rss_type;
1904 cmdline_fixed_string_t key;
1908 hexa_digit_to_value(char hexa_digit)
1910 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
1911 return (uint8_t) (hexa_digit - '0');
1912 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
1913 return (uint8_t) ((hexa_digit - 'a') + 10);
1914 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
1915 return (uint8_t) ((hexa_digit - 'A') + 10);
1916 /* Invalid hexa digit */
1921 parse_and_check_key_hexa_digit(char *key, int idx)
1925 hexa_v = hexa_digit_to_value(key[idx]);
1927 printf("invalid key: character %c at position %d is not a "
1928 "valid hexa digit\n", key[idx], idx);
1933 cmd_config_rss_hash_key_parsed(void *parsed_result,
1934 __attribute__((unused)) struct cmdline *cl,
1935 __attribute__((unused)) void *data)
1937 struct cmd_config_rss_hash_key *res = parsed_result;
1938 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
1942 struct rte_eth_dev_info dev_info;
1943 uint8_t hash_key_size;
1946 memset(&dev_info, 0, sizeof(dev_info));
1947 rte_eth_dev_info_get(res->port_id, &dev_info);
1948 if (dev_info.hash_key_size > 0 &&
1949 dev_info.hash_key_size <= sizeof(hash_key))
1950 hash_key_size = dev_info.hash_key_size;
1952 printf("dev_info did not provide a valid hash key size\n");
1955 /* Check the length of the RSS hash key */
1956 key_len = strlen(res->key);
1957 if (key_len != (hash_key_size * 2)) {
1958 printf("key length: %d invalid - key must be a string of %d"
1959 " hexa-decimal numbers\n",
1960 (int) key_len, hash_key_size * 2);
1963 /* Translate RSS hash key into binary representation */
1964 for (i = 0; i < hash_key_size; i++) {
1965 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
1968 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
1971 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
1973 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
1977 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
1978 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
1979 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
1980 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
1982 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
1983 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT16);
1984 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
1985 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
1986 rss_hash_key, "rss-hash-key");
1987 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
1988 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
1989 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
1990 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
1991 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
1992 "ipv6-tcp-ex#ipv6-udp-ex");
1993 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
1994 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
1996 cmdline_parse_inst_t cmd_config_rss_hash_key = {
1997 .f = cmd_config_rss_hash_key_parsed,
1999 .help_str = "port config <port_id> rss-hash-key "
2000 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2001 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2002 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex "
2003 "<string of hex digits (variable length, NIC dependent)>",
2005 (void *)&cmd_config_rss_hash_key_port,
2006 (void *)&cmd_config_rss_hash_key_config,
2007 (void *)&cmd_config_rss_hash_key_port_id,
2008 (void *)&cmd_config_rss_hash_key_rss_hash_key,
2009 (void *)&cmd_config_rss_hash_key_rss_type,
2010 (void *)&cmd_config_rss_hash_key_value,
2015 /* *** configure port rxq/txq start/stop *** */
2016 struct cmd_config_rxtx_queue {
2017 cmdline_fixed_string_t port;
2019 cmdline_fixed_string_t rxtxq;
2021 cmdline_fixed_string_t opname;
2025 cmd_config_rxtx_queue_parsed(void *parsed_result,
2026 __attribute__((unused)) struct cmdline *cl,
2027 __attribute__((unused)) void *data)
2029 struct cmd_config_rxtx_queue *res = parsed_result;
2034 if (test_done == 0) {
2035 printf("Please stop forwarding first\n");
2039 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2042 if (port_is_started(res->portid) != 1) {
2043 printf("Please start port %u first\n", res->portid);
2047 if (!strcmp(res->rxtxq, "rxq"))
2049 else if (!strcmp(res->rxtxq, "txq"))
2052 printf("Unknown parameter\n");
2056 if (isrx && rx_queue_id_is_invalid(res->qid))
2058 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2061 if (!strcmp(res->opname, "start"))
2063 else if (!strcmp(res->opname, "stop"))
2066 printf("Unknown parameter\n");
2070 if (isstart && isrx)
2071 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
2072 else if (!isstart && isrx)
2073 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
2074 else if (isstart && !isrx)
2075 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
2077 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
2079 if (ret == -ENOTSUP)
2080 printf("Function not supported in PMD driver\n");
2083 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
2084 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
2085 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
2086 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT16);
2087 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
2088 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
2089 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
2090 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
2091 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
2092 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
2095 cmdline_parse_inst_t cmd_config_rxtx_queue = {
2096 .f = cmd_config_rxtx_queue_parsed,
2098 .help_str = "port <port_id> rxq|txq <queue_id> start|stop",
2100 (void *)&cmd_config_speed_all_port,
2101 (void *)&cmd_config_rxtx_queue_portid,
2102 (void *)&cmd_config_rxtx_queue_rxtxq,
2103 (void *)&cmd_config_rxtx_queue_qid,
2104 (void *)&cmd_config_rxtx_queue_opname,
2109 /* *** Configure RSS RETA *** */
2110 struct cmd_config_rss_reta {
2111 cmdline_fixed_string_t port;
2112 cmdline_fixed_string_t keyword;
2114 cmdline_fixed_string_t name;
2115 cmdline_fixed_string_t list_name;
2116 cmdline_fixed_string_t list_of_items;
2120 parse_reta_config(const char *str,
2121 struct rte_eth_rss_reta_entry64 *reta_conf,
2122 uint16_t nb_entries)
2126 uint16_t hash_index, idx, shift;
2129 const char *p, *p0 = str;
2136 unsigned long int_fld[_NUM_FLD];
2137 char *str_fld[_NUM_FLD];
2139 while ((p = strchr(p0,'(')) != NULL) {
2141 if((p0 = strchr(p,')')) == NULL)
2145 if(size >= sizeof(s))
2148 snprintf(s, sizeof(s), "%.*s", size, p);
2149 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
2151 for (i = 0; i < _NUM_FLD; i++) {
2153 int_fld[i] = strtoul(str_fld[i], &end, 0);
2154 if (errno != 0 || end == str_fld[i] ||
2159 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
2160 nb_queue = (uint16_t)int_fld[FLD_QUEUE];
2162 if (hash_index >= nb_entries) {
2163 printf("Invalid RETA hash index=%d\n", hash_index);
2167 idx = hash_index / RTE_RETA_GROUP_SIZE;
2168 shift = hash_index % RTE_RETA_GROUP_SIZE;
2169 reta_conf[idx].mask |= (1ULL << shift);
2170 reta_conf[idx].reta[shift] = nb_queue;
2177 cmd_set_rss_reta_parsed(void *parsed_result,
2178 __attribute__((unused)) struct cmdline *cl,
2179 __attribute__((unused)) void *data)
2182 struct rte_eth_dev_info dev_info;
2183 struct rte_eth_rss_reta_entry64 reta_conf[8];
2184 struct cmd_config_rss_reta *res = parsed_result;
2186 memset(&dev_info, 0, sizeof(dev_info));
2187 rte_eth_dev_info_get(res->port_id, &dev_info);
2188 if (dev_info.reta_size == 0) {
2189 printf("Redirection table size is 0 which is "
2190 "invalid for RSS\n");
2193 printf("The reta size of port %d is %u\n",
2194 res->port_id, dev_info.reta_size);
2195 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
2196 printf("Currently do not support more than %u entries of "
2197 "redirection table\n", ETH_RSS_RETA_SIZE_512);
2201 memset(reta_conf, 0, sizeof(reta_conf));
2202 if (!strcmp(res->list_name, "reta")) {
2203 if (parse_reta_config(res->list_of_items, reta_conf,
2204 dev_info.reta_size)) {
2205 printf("Invalid RSS Redirection Table "
2206 "config entered\n");
2209 ret = rte_eth_dev_rss_reta_update(res->port_id,
2210 reta_conf, dev_info.reta_size);
2212 printf("Bad redirection table parameter, "
2213 "return code = %d \n", ret);
2217 cmdline_parse_token_string_t cmd_config_rss_reta_port =
2218 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
2219 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
2220 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
2221 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
2222 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT16);
2223 cmdline_parse_token_string_t cmd_config_rss_reta_name =
2224 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
2225 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
2226 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
2227 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
2228 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
2230 cmdline_parse_inst_t cmd_config_rss_reta = {
2231 .f = cmd_set_rss_reta_parsed,
2233 .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
2235 (void *)&cmd_config_rss_reta_port,
2236 (void *)&cmd_config_rss_reta_keyword,
2237 (void *)&cmd_config_rss_reta_port_id,
2238 (void *)&cmd_config_rss_reta_name,
2239 (void *)&cmd_config_rss_reta_list_name,
2240 (void *)&cmd_config_rss_reta_list_of_items,
2245 /* *** SHOW PORT RETA INFO *** */
2246 struct cmd_showport_reta {
2247 cmdline_fixed_string_t show;
2248 cmdline_fixed_string_t port;
2250 cmdline_fixed_string_t rss;
2251 cmdline_fixed_string_t reta;
2253 cmdline_fixed_string_t list_of_items;
2257 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
2258 uint16_t nb_entries,
2262 const char *p, *p0 = str;
2267 uint16_t num = (nb_entries + RTE_RETA_GROUP_SIZE - 1) /
2268 RTE_RETA_GROUP_SIZE;
2271 p = strchr(p0, '(');
2275 p0 = strchr(p, ')');
2279 if (size >= sizeof(s)) {
2280 printf("The string size exceeds the internal buffer size\n");
2283 snprintf(s, sizeof(s), "%.*s", size, p);
2284 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
2285 if (ret <= 0 || ret != num) {
2286 printf("The bits of masks do not match the number of "
2287 "reta entries: %u\n", num);
2290 for (i = 0; i < ret; i++)
2291 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
2297 cmd_showport_reta_parsed(void *parsed_result,
2298 __attribute__((unused)) struct cmdline *cl,
2299 __attribute__((unused)) void *data)
2301 struct cmd_showport_reta *res = parsed_result;
2302 struct rte_eth_rss_reta_entry64 reta_conf[8];
2303 struct rte_eth_dev_info dev_info;
2304 uint16_t max_reta_size;
2306 memset(&dev_info, 0, sizeof(dev_info));
2307 rte_eth_dev_info_get(res->port_id, &dev_info);
2308 max_reta_size = RTE_MIN(dev_info.reta_size, ETH_RSS_RETA_SIZE_512);
2309 if (res->size == 0 || res->size > max_reta_size) {
2310 printf("Invalid redirection table size: %u (1-%u)\n",
2311 res->size, max_reta_size);
2315 memset(reta_conf, 0, sizeof(reta_conf));
2316 if (showport_parse_reta_config(reta_conf, res->size,
2317 res->list_of_items) < 0) {
2318 printf("Invalid string: %s for reta masks\n",
2319 res->list_of_items);
2322 port_rss_reta_info(res->port_id, reta_conf, res->size);
2325 cmdline_parse_token_string_t cmd_showport_reta_show =
2326 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
2327 cmdline_parse_token_string_t cmd_showport_reta_port =
2328 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
2329 cmdline_parse_token_num_t cmd_showport_reta_port_id =
2330 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT16);
2331 cmdline_parse_token_string_t cmd_showport_reta_rss =
2332 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
2333 cmdline_parse_token_string_t cmd_showport_reta_reta =
2334 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
2335 cmdline_parse_token_num_t cmd_showport_reta_size =
2336 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16);
2337 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
2338 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
2339 list_of_items, NULL);
2341 cmdline_parse_inst_t cmd_showport_reta = {
2342 .f = cmd_showport_reta_parsed,
2344 .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
2346 (void *)&cmd_showport_reta_show,
2347 (void *)&cmd_showport_reta_port,
2348 (void *)&cmd_showport_reta_port_id,
2349 (void *)&cmd_showport_reta_rss,
2350 (void *)&cmd_showport_reta_reta,
2351 (void *)&cmd_showport_reta_size,
2352 (void *)&cmd_showport_reta_list_of_items,
2357 /* *** Show RSS hash configuration *** */
2358 struct cmd_showport_rss_hash {
2359 cmdline_fixed_string_t show;
2360 cmdline_fixed_string_t port;
2362 cmdline_fixed_string_t rss_hash;
2363 cmdline_fixed_string_t rss_type;
2364 cmdline_fixed_string_t key; /* optional argument */
2367 static void cmd_showport_rss_hash_parsed(void *parsed_result,
2368 __attribute__((unused)) struct cmdline *cl,
2371 struct cmd_showport_rss_hash *res = parsed_result;
2373 port_rss_hash_conf_show(res->port_id, res->rss_type,
2374 show_rss_key != NULL);
2377 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
2378 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
2379 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
2380 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
2381 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
2382 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT16);
2383 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
2384 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
2386 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash_info =
2387 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_type,
2388 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2389 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2390 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2391 "ipv6-tcp-ex#ipv6-udp-ex");
2392 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
2393 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
2395 cmdline_parse_inst_t cmd_showport_rss_hash = {
2396 .f = cmd_showport_rss_hash_parsed,
2398 .help_str = "show port <port_id> rss-hash "
2399 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2400 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2401 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex",
2403 (void *)&cmd_showport_rss_hash_show,
2404 (void *)&cmd_showport_rss_hash_port,
2405 (void *)&cmd_showport_rss_hash_port_id,
2406 (void *)&cmd_showport_rss_hash_rss_hash,
2407 (void *)&cmd_showport_rss_hash_rss_hash_info,
2412 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
2413 .f = cmd_showport_rss_hash_parsed,
2415 .help_str = "show port <port_id> rss-hash "
2416 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2417 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2418 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex key",
2420 (void *)&cmd_showport_rss_hash_show,
2421 (void *)&cmd_showport_rss_hash_port,
2422 (void *)&cmd_showport_rss_hash_port_id,
2423 (void *)&cmd_showport_rss_hash_rss_hash,
2424 (void *)&cmd_showport_rss_hash_rss_hash_info,
2425 (void *)&cmd_showport_rss_hash_rss_key,
2430 /* *** Configure DCB *** */
2431 struct cmd_config_dcb {
2432 cmdline_fixed_string_t port;
2433 cmdline_fixed_string_t config;
2435 cmdline_fixed_string_t dcb;
2436 cmdline_fixed_string_t vt;
2437 cmdline_fixed_string_t vt_en;
2439 cmdline_fixed_string_t pfc;
2440 cmdline_fixed_string_t pfc_en;
2444 cmd_config_dcb_parsed(void *parsed_result,
2445 __attribute__((unused)) struct cmdline *cl,
2446 __attribute__((unused)) void *data)
2448 struct cmd_config_dcb *res = parsed_result;
2449 portid_t port_id = res->port_id;
2450 struct rte_port *port;
2454 port = &ports[port_id];
2455 /** Check if the port is not started **/
2456 if (port->port_status != RTE_PORT_STOPPED) {
2457 printf("Please stop port %d first\n", port_id);
2461 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
2462 printf("The invalid number of traffic class,"
2463 " only 4 or 8 allowed.\n");
2467 if (nb_fwd_lcores < res->num_tcs) {
2468 printf("nb_cores shouldn't be less than number of TCs.\n");
2471 if (!strncmp(res->pfc_en, "on", 2))
2476 /* DCB in VT mode */
2477 if (!strncmp(res->vt_en, "on", 2))
2478 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
2479 (enum rte_eth_nb_tcs)res->num_tcs,
2482 ret = init_port_dcb_config(port_id, DCB_ENABLED,
2483 (enum rte_eth_nb_tcs)res->num_tcs,
2488 printf("Cannot initialize network ports.\n");
2492 cmd_reconfig_device_queue(port_id, 1, 1);
2495 cmdline_parse_token_string_t cmd_config_dcb_port =
2496 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
2497 cmdline_parse_token_string_t cmd_config_dcb_config =
2498 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
2499 cmdline_parse_token_num_t cmd_config_dcb_port_id =
2500 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT16);
2501 cmdline_parse_token_string_t cmd_config_dcb_dcb =
2502 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
2503 cmdline_parse_token_string_t cmd_config_dcb_vt =
2504 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
2505 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
2506 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
2507 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
2508 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
2509 cmdline_parse_token_string_t cmd_config_dcb_pfc=
2510 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
2511 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
2512 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
2514 cmdline_parse_inst_t cmd_config_dcb = {
2515 .f = cmd_config_dcb_parsed,
2517 .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
2519 (void *)&cmd_config_dcb_port,
2520 (void *)&cmd_config_dcb_config,
2521 (void *)&cmd_config_dcb_port_id,
2522 (void *)&cmd_config_dcb_dcb,
2523 (void *)&cmd_config_dcb_vt,
2524 (void *)&cmd_config_dcb_vt_en,
2525 (void *)&cmd_config_dcb_num_tcs,
2526 (void *)&cmd_config_dcb_pfc,
2527 (void *)&cmd_config_dcb_pfc_en,
2532 /* *** configure number of packets per burst *** */
2533 struct cmd_config_burst {
2534 cmdline_fixed_string_t port;
2535 cmdline_fixed_string_t keyword;
2536 cmdline_fixed_string_t all;
2537 cmdline_fixed_string_t name;
2542 cmd_config_burst_parsed(void *parsed_result,
2543 __attribute__((unused)) struct cmdline *cl,
2544 __attribute__((unused)) void *data)
2546 struct cmd_config_burst *res = parsed_result;
2548 if (!all_ports_stopped()) {
2549 printf("Please stop all ports first\n");
2553 if (!strcmp(res->name, "burst")) {
2554 if (res->value < 1 || res->value > MAX_PKT_BURST) {
2555 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
2558 nb_pkt_per_burst = res->value;
2560 printf("Unknown parameter\n");
2566 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2569 cmdline_parse_token_string_t cmd_config_burst_port =
2570 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
2571 cmdline_parse_token_string_t cmd_config_burst_keyword =
2572 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
2573 cmdline_parse_token_string_t cmd_config_burst_all =
2574 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
2575 cmdline_parse_token_string_t cmd_config_burst_name =
2576 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
2577 cmdline_parse_token_num_t cmd_config_burst_value =
2578 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
2580 cmdline_parse_inst_t cmd_config_burst = {
2581 .f = cmd_config_burst_parsed,
2583 .help_str = "port config all burst <value>",
2585 (void *)&cmd_config_burst_port,
2586 (void *)&cmd_config_burst_keyword,
2587 (void *)&cmd_config_burst_all,
2588 (void *)&cmd_config_burst_name,
2589 (void *)&cmd_config_burst_value,
2594 /* *** configure rx/tx queues *** */
2595 struct cmd_config_thresh {
2596 cmdline_fixed_string_t port;
2597 cmdline_fixed_string_t keyword;
2598 cmdline_fixed_string_t all;
2599 cmdline_fixed_string_t name;
2604 cmd_config_thresh_parsed(void *parsed_result,
2605 __attribute__((unused)) struct cmdline *cl,
2606 __attribute__((unused)) void *data)
2608 struct cmd_config_thresh *res = parsed_result;
2610 if (!all_ports_stopped()) {
2611 printf("Please stop all ports first\n");
2615 if (!strcmp(res->name, "txpt"))
2616 tx_pthresh = res->value;
2617 else if(!strcmp(res->name, "txht"))
2618 tx_hthresh = res->value;
2619 else if(!strcmp(res->name, "txwt"))
2620 tx_wthresh = res->value;
2621 else if(!strcmp(res->name, "rxpt"))
2622 rx_pthresh = res->value;
2623 else if(!strcmp(res->name, "rxht"))
2624 rx_hthresh = res->value;
2625 else if(!strcmp(res->name, "rxwt"))
2626 rx_wthresh = res->value;
2628 printf("Unknown parameter\n");
2634 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2637 cmdline_parse_token_string_t cmd_config_thresh_port =
2638 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
2639 cmdline_parse_token_string_t cmd_config_thresh_keyword =
2640 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
2641 cmdline_parse_token_string_t cmd_config_thresh_all =
2642 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
2643 cmdline_parse_token_string_t cmd_config_thresh_name =
2644 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
2645 "txpt#txht#txwt#rxpt#rxht#rxwt");
2646 cmdline_parse_token_num_t cmd_config_thresh_value =
2647 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
2649 cmdline_parse_inst_t cmd_config_thresh = {
2650 .f = cmd_config_thresh_parsed,
2652 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
2654 (void *)&cmd_config_thresh_port,
2655 (void *)&cmd_config_thresh_keyword,
2656 (void *)&cmd_config_thresh_all,
2657 (void *)&cmd_config_thresh_name,
2658 (void *)&cmd_config_thresh_value,
2663 /* *** configure free/rs threshold *** */
2664 struct cmd_config_threshold {
2665 cmdline_fixed_string_t port;
2666 cmdline_fixed_string_t keyword;
2667 cmdline_fixed_string_t all;
2668 cmdline_fixed_string_t name;
2673 cmd_config_threshold_parsed(void *parsed_result,
2674 __attribute__((unused)) struct cmdline *cl,
2675 __attribute__((unused)) void *data)
2677 struct cmd_config_threshold *res = parsed_result;
2679 if (!all_ports_stopped()) {
2680 printf("Please stop all ports first\n");
2684 if (!strcmp(res->name, "txfreet"))
2685 tx_free_thresh = res->value;
2686 else if (!strcmp(res->name, "txrst"))
2687 tx_rs_thresh = res->value;
2688 else if (!strcmp(res->name, "rxfreet"))
2689 rx_free_thresh = res->value;
2691 printf("Unknown parameter\n");
2697 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2700 cmdline_parse_token_string_t cmd_config_threshold_port =
2701 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
2702 cmdline_parse_token_string_t cmd_config_threshold_keyword =
2703 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
2705 cmdline_parse_token_string_t cmd_config_threshold_all =
2706 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
2707 cmdline_parse_token_string_t cmd_config_threshold_name =
2708 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
2709 "txfreet#txrst#rxfreet");
2710 cmdline_parse_token_num_t cmd_config_threshold_value =
2711 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
2713 cmdline_parse_inst_t cmd_config_threshold = {
2714 .f = cmd_config_threshold_parsed,
2716 .help_str = "port config all txfreet|txrst|rxfreet <value>",
2718 (void *)&cmd_config_threshold_port,
2719 (void *)&cmd_config_threshold_keyword,
2720 (void *)&cmd_config_threshold_all,
2721 (void *)&cmd_config_threshold_name,
2722 (void *)&cmd_config_threshold_value,
2728 struct cmd_stop_result {
2729 cmdline_fixed_string_t stop;
2732 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
2733 __attribute__((unused)) struct cmdline *cl,
2734 __attribute__((unused)) void *data)
2736 stop_packet_forwarding();
2739 cmdline_parse_token_string_t cmd_stop_stop =
2740 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
2742 cmdline_parse_inst_t cmd_stop = {
2743 .f = cmd_stop_parsed,
2745 .help_str = "stop: Stop packet forwarding",
2747 (void *)&cmd_stop_stop,
2752 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
2755 parse_item_list(char* str, const char* item_name, unsigned int max_items,
2756 unsigned int *parsed_items, int check_unique_values)
2758 unsigned int nb_item;
2766 * First parse all items in the list and store their value.
2771 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
2773 if ((c >= '0') && (c <= '9')) {
2774 value = (unsigned int) (value * 10 + (c - '0'));
2779 printf("character %c is not a decimal digit\n", c);
2783 printf("No valid value before comma\n");
2786 if (nb_item < max_items) {
2787 parsed_items[nb_item] = value;
2793 if (nb_item >= max_items) {
2794 printf("Number of %s = %u > %u (maximum items)\n",
2795 item_name, nb_item + 1, max_items);
2798 parsed_items[nb_item++] = value;
2799 if (! check_unique_values)
2803 * Then, check that all values in the list are differents.
2804 * No optimization here...
2806 for (i = 0; i < nb_item; i++) {
2807 for (j = i + 1; j < nb_item; j++) {
2808 if (parsed_items[j] == parsed_items[i]) {
2809 printf("duplicated %s %u at index %u and %u\n",
2810 item_name, parsed_items[i], i, j);
2818 struct cmd_set_list_result {
2819 cmdline_fixed_string_t cmd_keyword;
2820 cmdline_fixed_string_t list_name;
2821 cmdline_fixed_string_t list_of_items;
2824 static void cmd_set_list_parsed(void *parsed_result,
2825 __attribute__((unused)) struct cmdline *cl,
2826 __attribute__((unused)) void *data)
2828 struct cmd_set_list_result *res;
2830 unsigned int lcorelist[RTE_MAX_LCORE];
2831 unsigned int portlist[RTE_MAX_ETHPORTS];
2833 unsigned int nb_item;
2835 if (test_done == 0) {
2836 printf("Please stop forwarding first\n");
2840 res = parsed_result;
2841 if (!strcmp(res->list_name, "corelist")) {
2842 nb_item = parse_item_list(res->list_of_items, "core",
2844 parsed_items.lcorelist, 1);
2846 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
2851 if (!strcmp(res->list_name, "portlist")) {
2852 nb_item = parse_item_list(res->list_of_items, "port",
2854 parsed_items.portlist, 1);
2856 set_fwd_ports_list(parsed_items.portlist, nb_item);
2862 cmdline_parse_token_string_t cmd_set_list_keyword =
2863 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
2865 cmdline_parse_token_string_t cmd_set_list_name =
2866 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
2867 "corelist#portlist");
2868 cmdline_parse_token_string_t cmd_set_list_of_items =
2869 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
2872 cmdline_parse_inst_t cmd_set_fwd_list = {
2873 .f = cmd_set_list_parsed,
2875 .help_str = "set corelist|portlist <list0[,list1]*>",
2877 (void *)&cmd_set_list_keyword,
2878 (void *)&cmd_set_list_name,
2879 (void *)&cmd_set_list_of_items,
2884 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
2886 struct cmd_setmask_result {
2887 cmdline_fixed_string_t set;
2888 cmdline_fixed_string_t mask;
2892 static void cmd_set_mask_parsed(void *parsed_result,
2893 __attribute__((unused)) struct cmdline *cl,
2894 __attribute__((unused)) void *data)
2896 struct cmd_setmask_result *res = parsed_result;
2898 if (test_done == 0) {
2899 printf("Please stop forwarding first\n");
2902 if (!strcmp(res->mask, "coremask")) {
2903 set_fwd_lcores_mask(res->hexavalue);
2905 } else if (!strcmp(res->mask, "portmask")) {
2906 set_fwd_ports_mask(res->hexavalue);
2911 cmdline_parse_token_string_t cmd_setmask_set =
2912 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
2913 cmdline_parse_token_string_t cmd_setmask_mask =
2914 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
2915 "coremask#portmask");
2916 cmdline_parse_token_num_t cmd_setmask_value =
2917 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
2919 cmdline_parse_inst_t cmd_set_fwd_mask = {
2920 .f = cmd_set_mask_parsed,
2922 .help_str = "set coremask|portmask <hexadecimal value>",
2924 (void *)&cmd_setmask_set,
2925 (void *)&cmd_setmask_mask,
2926 (void *)&cmd_setmask_value,
2932 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
2934 struct cmd_set_result {
2935 cmdline_fixed_string_t set;
2936 cmdline_fixed_string_t what;
2940 static void cmd_set_parsed(void *parsed_result,
2941 __attribute__((unused)) struct cmdline *cl,
2942 __attribute__((unused)) void *data)
2944 struct cmd_set_result *res = parsed_result;
2945 if (!strcmp(res->what, "nbport")) {
2946 set_fwd_ports_number(res->value);
2948 } else if (!strcmp(res->what, "nbcore")) {
2949 set_fwd_lcores_number(res->value);
2951 } else if (!strcmp(res->what, "burst"))
2952 set_nb_pkt_per_burst(res->value);
2953 else if (!strcmp(res->what, "verbose"))
2954 set_verbose_level(res->value);
2957 cmdline_parse_token_string_t cmd_set_set =
2958 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
2959 cmdline_parse_token_string_t cmd_set_what =
2960 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
2961 "nbport#nbcore#burst#verbose");
2962 cmdline_parse_token_num_t cmd_set_value =
2963 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
2965 cmdline_parse_inst_t cmd_set_numbers = {
2966 .f = cmd_set_parsed,
2968 .help_str = "set nbport|nbcore|burst|verbose <value>",
2970 (void *)&cmd_set_set,
2971 (void *)&cmd_set_what,
2972 (void *)&cmd_set_value,
2977 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
2979 struct cmd_set_txpkts_result {
2980 cmdline_fixed_string_t cmd_keyword;
2981 cmdline_fixed_string_t txpkts;
2982 cmdline_fixed_string_t seg_lengths;
2986 cmd_set_txpkts_parsed(void *parsed_result,
2987 __attribute__((unused)) struct cmdline *cl,
2988 __attribute__((unused)) void *data)
2990 struct cmd_set_txpkts_result *res;
2991 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
2992 unsigned int nb_segs;
2994 res = parsed_result;
2995 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
2996 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
2998 set_tx_pkt_segments(seg_lengths, nb_segs);
3001 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
3002 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3003 cmd_keyword, "set");
3004 cmdline_parse_token_string_t cmd_set_txpkts_name =
3005 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3007 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
3008 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3011 cmdline_parse_inst_t cmd_set_txpkts = {
3012 .f = cmd_set_txpkts_parsed,
3014 .help_str = "set txpkts <len0[,len1]*>",
3016 (void *)&cmd_set_txpkts_keyword,
3017 (void *)&cmd_set_txpkts_name,
3018 (void *)&cmd_set_txpkts_lengths,
3023 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
3025 struct cmd_set_txsplit_result {
3026 cmdline_fixed_string_t cmd_keyword;
3027 cmdline_fixed_string_t txsplit;
3028 cmdline_fixed_string_t mode;
3032 cmd_set_txsplit_parsed(void *parsed_result,
3033 __attribute__((unused)) struct cmdline *cl,
3034 __attribute__((unused)) void *data)
3036 struct cmd_set_txsplit_result *res;
3038 res = parsed_result;
3039 set_tx_pkt_split(res->mode);
3042 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
3043 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3044 cmd_keyword, "set");
3045 cmdline_parse_token_string_t cmd_set_txsplit_name =
3046 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3047 txsplit, "txsplit");
3048 cmdline_parse_token_string_t cmd_set_txsplit_mode =
3049 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3052 cmdline_parse_inst_t cmd_set_txsplit = {
3053 .f = cmd_set_txsplit_parsed,
3055 .help_str = "set txsplit on|off|rand",
3057 (void *)&cmd_set_txsplit_keyword,
3058 (void *)&cmd_set_txsplit_name,
3059 (void *)&cmd_set_txsplit_mode,
3064 /* *** CONFIG TX QUEUE FLAGS *** */
3066 struct cmd_config_txqflags_result {
3067 cmdline_fixed_string_t port;
3068 cmdline_fixed_string_t config;
3069 cmdline_fixed_string_t all;
3070 cmdline_fixed_string_t what;
3074 static void cmd_config_txqflags_parsed(void *parsed_result,
3075 __attribute__((unused)) struct cmdline *cl,
3076 __attribute__((unused)) void *data)
3078 struct cmd_config_txqflags_result *res = parsed_result;
3080 if (!all_ports_stopped()) {
3081 printf("Please stop all ports first\n");
3085 if (strcmp(res->what, "txqflags")) {
3086 printf("Unknown parameter\n");
3090 if (res->hexvalue >= 0) {
3091 txq_flags = res->hexvalue;
3093 printf("txqflags must be >= 0\n");
3099 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3102 cmdline_parse_token_string_t cmd_config_txqflags_port =
3103 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, port,
3105 cmdline_parse_token_string_t cmd_config_txqflags_config =
3106 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, config,
3108 cmdline_parse_token_string_t cmd_config_txqflags_all =
3109 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, all,
3111 cmdline_parse_token_string_t cmd_config_txqflags_what =
3112 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, what,
3114 cmdline_parse_token_num_t cmd_config_txqflags_value =
3115 TOKEN_NUM_INITIALIZER(struct cmd_config_txqflags_result,
3118 cmdline_parse_inst_t cmd_config_txqflags = {
3119 .f = cmd_config_txqflags_parsed,
3121 .help_str = "port config all txqflags <value>",
3123 (void *)&cmd_config_txqflags_port,
3124 (void *)&cmd_config_txqflags_config,
3125 (void *)&cmd_config_txqflags_all,
3126 (void *)&cmd_config_txqflags_what,
3127 (void *)&cmd_config_txqflags_value,
3132 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
3133 struct cmd_rx_vlan_filter_all_result {
3134 cmdline_fixed_string_t rx_vlan;
3135 cmdline_fixed_string_t what;
3136 cmdline_fixed_string_t all;
3141 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
3142 __attribute__((unused)) struct cmdline *cl,
3143 __attribute__((unused)) void *data)
3145 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
3147 if (!strcmp(res->what, "add"))
3148 rx_vlan_all_filter_set(res->port_id, 1);
3150 rx_vlan_all_filter_set(res->port_id, 0);
3153 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
3154 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3155 rx_vlan, "rx_vlan");
3156 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
3157 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3159 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
3160 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3162 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
3163 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3166 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
3167 .f = cmd_rx_vlan_filter_all_parsed,
3169 .help_str = "rx_vlan add|rm all <port_id>: "
3170 "Add/Remove all identifiers to/from the set of VLAN "
3171 "identifiers filtered by a port",
3173 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
3174 (void *)&cmd_rx_vlan_filter_all_what,
3175 (void *)&cmd_rx_vlan_filter_all_all,
3176 (void *)&cmd_rx_vlan_filter_all_portid,
3181 /* *** VLAN OFFLOAD SET ON A PORT *** */
3182 struct cmd_vlan_offload_result {
3183 cmdline_fixed_string_t vlan;
3184 cmdline_fixed_string_t set;
3185 cmdline_fixed_string_t vlan_type;
3186 cmdline_fixed_string_t what;
3187 cmdline_fixed_string_t on;
3188 cmdline_fixed_string_t port_id;
3192 cmd_vlan_offload_parsed(void *parsed_result,
3193 __attribute__((unused)) struct cmdline *cl,
3194 __attribute__((unused)) void *data)
3197 struct cmd_vlan_offload_result *res = parsed_result;
3200 portid_t port_id = 0;
3204 len = strnlen(str, STR_TOKEN_SIZE);
3206 /* Get port_id first */
3214 tmp = strtoul(str, NULL, 0);
3215 /* If port_id greater that what portid_t can represent, return */
3216 if(tmp >= RTE_MAX_ETHPORTS)
3218 port_id = (portid_t)tmp;
3220 if (!strcmp(res->on, "on"))
3225 if (!strcmp(res->what, "strip"))
3226 rx_vlan_strip_set(port_id, on);
3227 else if(!strcmp(res->what, "stripq")){
3228 uint16_t queue_id = 0;
3230 /* No queue_id, return */
3232 printf("must specify (port,queue_id)\n");
3235 tmp = strtoul(str + i + 1, NULL, 0);
3236 /* If queue_id greater that what 16-bits can represent, return */
3240 queue_id = (uint16_t)tmp;
3241 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
3243 else if (!strcmp(res->what, "filter"))
3244 rx_vlan_filter_set(port_id, on);
3246 vlan_extend_set(port_id, on);
3251 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
3252 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3254 cmdline_parse_token_string_t cmd_vlan_offload_set =
3255 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3257 cmdline_parse_token_string_t cmd_vlan_offload_what =
3258 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3259 what, "strip#filter#qinq#stripq");
3260 cmdline_parse_token_string_t cmd_vlan_offload_on =
3261 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3263 cmdline_parse_token_string_t cmd_vlan_offload_portid =
3264 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3267 cmdline_parse_inst_t cmd_vlan_offload = {
3268 .f = cmd_vlan_offload_parsed,
3270 .help_str = "vlan set strip|filter|qinq|stripq on|off "
3271 "<port_id[,queue_id]>: "
3272 "Filter/Strip for rx side qinq(extended) for both rx/tx sides",
3274 (void *)&cmd_vlan_offload_vlan,
3275 (void *)&cmd_vlan_offload_set,
3276 (void *)&cmd_vlan_offload_what,
3277 (void *)&cmd_vlan_offload_on,
3278 (void *)&cmd_vlan_offload_portid,
3283 /* *** VLAN TPID SET ON A PORT *** */
3284 struct cmd_vlan_tpid_result {
3285 cmdline_fixed_string_t vlan;
3286 cmdline_fixed_string_t set;
3287 cmdline_fixed_string_t vlan_type;
3288 cmdline_fixed_string_t what;
3294 cmd_vlan_tpid_parsed(void *parsed_result,
3295 __attribute__((unused)) struct cmdline *cl,
3296 __attribute__((unused)) void *data)
3298 struct cmd_vlan_tpid_result *res = parsed_result;
3299 enum rte_vlan_type vlan_type;
3301 if (!strcmp(res->vlan_type, "inner"))
3302 vlan_type = ETH_VLAN_TYPE_INNER;
3303 else if (!strcmp(res->vlan_type, "outer"))
3304 vlan_type = ETH_VLAN_TYPE_OUTER;
3306 printf("Unknown vlan type\n");
3309 vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
3312 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
3313 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3315 cmdline_parse_token_string_t cmd_vlan_tpid_set =
3316 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3318 cmdline_parse_token_string_t cmd_vlan_type =
3319 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3320 vlan_type, "inner#outer");
3321 cmdline_parse_token_string_t cmd_vlan_tpid_what =
3322 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3324 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
3325 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3327 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
3328 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3331 cmdline_parse_inst_t cmd_vlan_tpid = {
3332 .f = cmd_vlan_tpid_parsed,
3334 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
3335 "Set the VLAN Ether type",
3337 (void *)&cmd_vlan_tpid_vlan,
3338 (void *)&cmd_vlan_tpid_set,
3339 (void *)&cmd_vlan_type,
3340 (void *)&cmd_vlan_tpid_what,
3341 (void *)&cmd_vlan_tpid_tpid,
3342 (void *)&cmd_vlan_tpid_portid,
3347 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
3348 struct cmd_rx_vlan_filter_result {
3349 cmdline_fixed_string_t rx_vlan;
3350 cmdline_fixed_string_t what;
3356 cmd_rx_vlan_filter_parsed(void *parsed_result,
3357 __attribute__((unused)) struct cmdline *cl,
3358 __attribute__((unused)) void *data)
3360 struct cmd_rx_vlan_filter_result *res = parsed_result;
3362 if (!strcmp(res->what, "add"))
3363 rx_vft_set(res->port_id, res->vlan_id, 1);
3365 rx_vft_set(res->port_id, res->vlan_id, 0);
3368 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
3369 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3370 rx_vlan, "rx_vlan");
3371 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
3372 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3374 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
3375 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3377 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
3378 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3381 cmdline_parse_inst_t cmd_rx_vlan_filter = {
3382 .f = cmd_rx_vlan_filter_parsed,
3384 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
3385 "Add/Remove a VLAN identifier to/from the set of VLAN "
3386 "identifiers filtered by a port",
3388 (void *)&cmd_rx_vlan_filter_rx_vlan,
3389 (void *)&cmd_rx_vlan_filter_what,
3390 (void *)&cmd_rx_vlan_filter_vlanid,
3391 (void *)&cmd_rx_vlan_filter_portid,
3396 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3397 struct cmd_tx_vlan_set_result {
3398 cmdline_fixed_string_t tx_vlan;
3399 cmdline_fixed_string_t set;
3405 cmd_tx_vlan_set_parsed(void *parsed_result,
3406 __attribute__((unused)) struct cmdline *cl,
3407 __attribute__((unused)) void *data)
3409 struct cmd_tx_vlan_set_result *res = parsed_result;
3411 tx_vlan_set(res->port_id, res->vlan_id);
3414 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
3415 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3416 tx_vlan, "tx_vlan");
3417 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
3418 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3420 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
3421 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3423 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
3424 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3427 cmdline_parse_inst_t cmd_tx_vlan_set = {
3428 .f = cmd_tx_vlan_set_parsed,
3430 .help_str = "tx_vlan set <port_id> <vlan_id>: "
3431 "Enable hardware insertion of a single VLAN header "
3432 "with a given TAG Identifier in packets sent on a port",
3434 (void *)&cmd_tx_vlan_set_tx_vlan,
3435 (void *)&cmd_tx_vlan_set_set,
3436 (void *)&cmd_tx_vlan_set_portid,
3437 (void *)&cmd_tx_vlan_set_vlanid,
3442 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
3443 struct cmd_tx_vlan_set_qinq_result {
3444 cmdline_fixed_string_t tx_vlan;
3445 cmdline_fixed_string_t set;
3448 uint16_t vlan_id_outer;
3452 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
3453 __attribute__((unused)) struct cmdline *cl,
3454 __attribute__((unused)) void *data)
3456 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
3458 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
3461 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
3462 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3463 tx_vlan, "tx_vlan");
3464 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
3465 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3467 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
3468 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3470 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
3471 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3473 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
3474 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3475 vlan_id_outer, UINT16);
3477 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
3478 .f = cmd_tx_vlan_set_qinq_parsed,
3480 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
3481 "Enable hardware insertion of double VLAN header "
3482 "with given TAG Identifiers in packets sent on a port",
3484 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
3485 (void *)&cmd_tx_vlan_set_qinq_set,
3486 (void *)&cmd_tx_vlan_set_qinq_portid,
3487 (void *)&cmd_tx_vlan_set_qinq_vlanid,
3488 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
3493 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
3494 struct cmd_tx_vlan_set_pvid_result {
3495 cmdline_fixed_string_t tx_vlan;
3496 cmdline_fixed_string_t set;
3497 cmdline_fixed_string_t pvid;
3500 cmdline_fixed_string_t mode;
3504 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
3505 __attribute__((unused)) struct cmdline *cl,
3506 __attribute__((unused)) void *data)
3508 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
3510 if (strcmp(res->mode, "on") == 0)
3511 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
3513 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
3516 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
3517 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3518 tx_vlan, "tx_vlan");
3519 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
3520 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3522 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
3523 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3525 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
3526 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3528 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
3529 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3531 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
3532 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3535 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
3536 .f = cmd_tx_vlan_set_pvid_parsed,
3538 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
3540 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
3541 (void *)&cmd_tx_vlan_set_pvid_set,
3542 (void *)&cmd_tx_vlan_set_pvid_pvid,
3543 (void *)&cmd_tx_vlan_set_pvid_port_id,
3544 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
3545 (void *)&cmd_tx_vlan_set_pvid_mode,
3550 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3551 struct cmd_tx_vlan_reset_result {
3552 cmdline_fixed_string_t tx_vlan;
3553 cmdline_fixed_string_t reset;
3558 cmd_tx_vlan_reset_parsed(void *parsed_result,
3559 __attribute__((unused)) struct cmdline *cl,
3560 __attribute__((unused)) void *data)
3562 struct cmd_tx_vlan_reset_result *res = parsed_result;
3564 tx_vlan_reset(res->port_id);
3567 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
3568 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
3569 tx_vlan, "tx_vlan");
3570 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
3571 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
3573 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
3574 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
3577 cmdline_parse_inst_t cmd_tx_vlan_reset = {
3578 .f = cmd_tx_vlan_reset_parsed,
3580 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
3581 "VLAN header in packets sent on a port",
3583 (void *)&cmd_tx_vlan_reset_tx_vlan,
3584 (void *)&cmd_tx_vlan_reset_reset,
3585 (void *)&cmd_tx_vlan_reset_portid,
3591 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
3592 struct cmd_csum_result {
3593 cmdline_fixed_string_t csum;
3594 cmdline_fixed_string_t mode;
3595 cmdline_fixed_string_t proto;
3596 cmdline_fixed_string_t hwsw;
3601 csum_show(int port_id)
3603 struct rte_eth_dev_info dev_info;
3606 ol_flags = ports[port_id].tx_ol_flags;
3607 printf("Parse tunnel is %s\n",
3608 (ol_flags & TESTPMD_TX_OFFLOAD_PARSE_TUNNEL) ? "on" : "off");
3609 printf("IP checksum offload is %s\n",
3610 (ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) ? "hw" : "sw");
3611 printf("UDP checksum offload is %s\n",
3612 (ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
3613 printf("TCP checksum offload is %s\n",
3614 (ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
3615 printf("SCTP checksum offload is %s\n",
3616 (ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
3617 printf("Outer-Ip checksum offload is %s\n",
3618 (ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) ? "hw" : "sw");
3620 /* display warnings if configuration is not supported by the NIC */
3621 rte_eth_dev_info_get(port_id, &dev_info);
3622 if ((ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) &&
3623 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
3624 printf("Warning: hardware IP checksum enabled but not "
3625 "supported by port %d\n", port_id);
3627 if ((ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) &&
3628 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
3629 printf("Warning: hardware UDP checksum enabled but not "
3630 "supported by port %d\n", port_id);
3632 if ((ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) &&
3633 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
3634 printf("Warning: hardware TCP checksum enabled but not "
3635 "supported by port %d\n", port_id);
3637 if ((ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) &&
3638 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
3639 printf("Warning: hardware SCTP checksum enabled but not "
3640 "supported by port %d\n", port_id);
3642 if ((ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) &&
3643 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
3644 printf("Warning: hardware outer IP checksum enabled but not "
3645 "supported by port %d\n", port_id);
3650 cmd_csum_parsed(void *parsed_result,
3651 __attribute__((unused)) struct cmdline *cl,
3652 __attribute__((unused)) void *data)
3654 struct cmd_csum_result *res = parsed_result;
3658 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
3659 printf("invalid port %d\n", res->port_id);
3663 if (!strcmp(res->mode, "set")) {
3665 if (!strcmp(res->hwsw, "hw"))
3668 if (!strcmp(res->proto, "ip")) {
3669 mask = TESTPMD_TX_OFFLOAD_IP_CKSUM;
3670 } else if (!strcmp(res->proto, "udp")) {
3671 mask = TESTPMD_TX_OFFLOAD_UDP_CKSUM;
3672 } else if (!strcmp(res->proto, "tcp")) {
3673 mask = TESTPMD_TX_OFFLOAD_TCP_CKSUM;
3674 } else if (!strcmp(res->proto, "sctp")) {
3675 mask = TESTPMD_TX_OFFLOAD_SCTP_CKSUM;
3676 } else if (!strcmp(res->proto, "outer-ip")) {
3677 mask = TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM;
3681 ports[res->port_id].tx_ol_flags |= mask;
3683 ports[res->port_id].tx_ol_flags &= (~mask);
3685 csum_show(res->port_id);
3688 cmdline_parse_token_string_t cmd_csum_csum =
3689 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3691 cmdline_parse_token_string_t cmd_csum_mode =
3692 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3694 cmdline_parse_token_string_t cmd_csum_proto =
3695 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3696 proto, "ip#tcp#udp#sctp#outer-ip");
3697 cmdline_parse_token_string_t cmd_csum_hwsw =
3698 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3700 cmdline_parse_token_num_t cmd_csum_portid =
3701 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
3704 cmdline_parse_inst_t cmd_csum_set = {
3705 .f = cmd_csum_parsed,
3707 .help_str = "csum set ip|tcp|udp|sctp|outer-ip hw|sw <port_id>: "
3708 "Enable/Disable hardware calculation of L3/L4 checksum when "
3709 "using csum forward engine",
3711 (void *)&cmd_csum_csum,
3712 (void *)&cmd_csum_mode,
3713 (void *)&cmd_csum_proto,
3714 (void *)&cmd_csum_hwsw,
3715 (void *)&cmd_csum_portid,
3720 cmdline_parse_token_string_t cmd_csum_mode_show =
3721 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3724 cmdline_parse_inst_t cmd_csum_show = {
3725 .f = cmd_csum_parsed,
3727 .help_str = "csum show <port_id>: Show checksum offload configuration",
3729 (void *)&cmd_csum_csum,
3730 (void *)&cmd_csum_mode_show,
3731 (void *)&cmd_csum_portid,
3736 /* Enable/disable tunnel parsing */
3737 struct cmd_csum_tunnel_result {
3738 cmdline_fixed_string_t csum;
3739 cmdline_fixed_string_t parse;
3740 cmdline_fixed_string_t onoff;
3745 cmd_csum_tunnel_parsed(void *parsed_result,
3746 __attribute__((unused)) struct cmdline *cl,
3747 __attribute__((unused)) void *data)
3749 struct cmd_csum_tunnel_result *res = parsed_result;
3751 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3754 if (!strcmp(res->onoff, "on"))
3755 ports[res->port_id].tx_ol_flags |=
3756 TESTPMD_TX_OFFLOAD_PARSE_TUNNEL;
3758 ports[res->port_id].tx_ol_flags &=
3759 (~TESTPMD_TX_OFFLOAD_PARSE_TUNNEL);
3761 csum_show(res->port_id);
3764 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
3765 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3767 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
3768 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3769 parse, "parse_tunnel");
3770 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
3771 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3773 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
3774 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
3777 cmdline_parse_inst_t cmd_csum_tunnel = {
3778 .f = cmd_csum_tunnel_parsed,
3780 .help_str = "csum parse_tunnel on|off <port_id>: "
3781 "Enable/Disable parsing of tunnels for csum engine",
3783 (void *)&cmd_csum_tunnel_csum,
3784 (void *)&cmd_csum_tunnel_parse,
3785 (void *)&cmd_csum_tunnel_onoff,
3786 (void *)&cmd_csum_tunnel_portid,
3791 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
3792 struct cmd_tso_set_result {
3793 cmdline_fixed_string_t tso;
3794 cmdline_fixed_string_t mode;
3800 cmd_tso_set_parsed(void *parsed_result,
3801 __attribute__((unused)) struct cmdline *cl,
3802 __attribute__((unused)) void *data)
3804 struct cmd_tso_set_result *res = parsed_result;
3805 struct rte_eth_dev_info dev_info;
3807 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3810 if (!strcmp(res->mode, "set"))
3811 ports[res->port_id].tso_segsz = res->tso_segsz;
3813 if (ports[res->port_id].tso_segsz == 0)
3814 printf("TSO for non-tunneled packets is disabled\n");
3816 printf("TSO segment size for non-tunneled packets is %d\n",
3817 ports[res->port_id].tso_segsz);
3819 /* display warnings if configuration is not supported by the NIC */
3820 rte_eth_dev_info_get(res->port_id, &dev_info);
3821 if ((ports[res->port_id].tso_segsz != 0) &&
3822 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
3823 printf("Warning: TSO enabled but not "
3824 "supported by port %d\n", res->port_id);
3828 cmdline_parse_token_string_t cmd_tso_set_tso =
3829 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3831 cmdline_parse_token_string_t cmd_tso_set_mode =
3832 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3834 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
3835 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3837 cmdline_parse_token_num_t cmd_tso_set_portid =
3838 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3841 cmdline_parse_inst_t cmd_tso_set = {
3842 .f = cmd_tso_set_parsed,
3844 .help_str = "tso set <tso_segsz> <port_id>: "
3845 "Set TSO segment size of non-tunneled packets for csum engine "
3848 (void *)&cmd_tso_set_tso,
3849 (void *)&cmd_tso_set_mode,
3850 (void *)&cmd_tso_set_tso_segsz,
3851 (void *)&cmd_tso_set_portid,
3856 cmdline_parse_token_string_t cmd_tso_show_mode =
3857 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3861 cmdline_parse_inst_t cmd_tso_show = {
3862 .f = cmd_tso_set_parsed,
3864 .help_str = "tso show <port_id>: "
3865 "Show TSO segment size of non-tunneled packets for csum engine",
3867 (void *)&cmd_tso_set_tso,
3868 (void *)&cmd_tso_show_mode,
3869 (void *)&cmd_tso_set_portid,
3874 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
3875 struct cmd_tunnel_tso_set_result {
3876 cmdline_fixed_string_t tso;
3877 cmdline_fixed_string_t mode;
3883 check_tunnel_tso_nic_support(portid_t port_id)
3885 struct rte_eth_dev_info dev_info;
3887 rte_eth_dev_info_get(port_id, &dev_info);
3888 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO))
3889 printf("Warning: TSO enabled but VXLAN TUNNEL TSO not "
3890 "supported by port %d\n", port_id);
3891 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO))
3892 printf("Warning: TSO enabled but GRE TUNNEL TSO not "
3893 "supported by port %d\n", port_id);
3894 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO))
3895 printf("Warning: TSO enabled but IPIP TUNNEL TSO not "
3896 "supported by port %d\n", port_id);
3897 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
3898 printf("Warning: TSO enabled but GENEVE TUNNEL TSO not "
3899 "supported by port %d\n", port_id);
3903 cmd_tunnel_tso_set_parsed(void *parsed_result,
3904 __attribute__((unused)) struct cmdline *cl,
3905 __attribute__((unused)) void *data)
3907 struct cmd_tunnel_tso_set_result *res = parsed_result;
3909 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3912 if (!strcmp(res->mode, "set"))
3913 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
3915 if (ports[res->port_id].tunnel_tso_segsz == 0)
3916 printf("TSO for tunneled packets is disabled\n");
3918 printf("TSO segment size for tunneled packets is %d\n",
3919 ports[res->port_id].tunnel_tso_segsz);
3921 /* Below conditions are needed to make it work:
3922 * (1) tunnel TSO is supported by the NIC;
3923 * (2) "csum parse_tunnel" must be set so that tunneled pkts
3925 * (3) for tunneled pkts with outer L3 of IPv4,
3926 * "csum set outer-ip" must be set to hw, because after tso,
3927 * total_len of outer IP header is changed, and the checksum
3928 * of outer IP header calculated by sw should be wrong; that
3929 * is not necessary for IPv6 tunneled pkts because there's no
3930 * checksum in IP header anymore.
3932 check_tunnel_tso_nic_support(res->port_id);
3934 if (!(ports[res->port_id].tx_ol_flags &
3935 TESTPMD_TX_OFFLOAD_PARSE_TUNNEL))
3936 printf("Warning: csum parse_tunnel must be set "
3937 "so that tunneled packets are recognized\n");
3938 if (!(ports[res->port_id].tx_ol_flags &
3939 TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM))
3940 printf("Warning: csum set outer-ip must be set to hw "
3941 "if outer L3 is IPv4; not necessary for IPv6\n");
3945 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
3946 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
3948 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
3949 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
3951 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
3952 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
3954 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
3955 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
3958 cmdline_parse_inst_t cmd_tunnel_tso_set = {
3959 .f = cmd_tunnel_tso_set_parsed,
3961 .help_str = "tunnel_tso set <tso_segsz> <port_id>: "
3962 "Set TSO segment size of tunneled packets for csum engine "
3965 (void *)&cmd_tunnel_tso_set_tso,
3966 (void *)&cmd_tunnel_tso_set_mode,
3967 (void *)&cmd_tunnel_tso_set_tso_segsz,
3968 (void *)&cmd_tunnel_tso_set_portid,
3973 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
3974 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
3978 cmdline_parse_inst_t cmd_tunnel_tso_show = {
3979 .f = cmd_tunnel_tso_set_parsed,
3981 .help_str = "tunnel_tso show <port_id> "
3982 "Show TSO segment size of tunneled packets for csum engine",
3984 (void *)&cmd_tunnel_tso_set_tso,
3985 (void *)&cmd_tunnel_tso_show_mode,
3986 (void *)&cmd_tunnel_tso_set_portid,
3991 /* *** SET GRO FOR A PORT *** */
3992 struct cmd_gro_enable_result {
3993 cmdline_fixed_string_t cmd_set;
3994 cmdline_fixed_string_t cmd_port;
3995 cmdline_fixed_string_t cmd_keyword;
3996 cmdline_fixed_string_t cmd_onoff;
4001 cmd_gro_enable_parsed(void *parsed_result,
4002 __attribute__((unused)) struct cmdline *cl,
4003 __attribute__((unused)) void *data)
4005 struct cmd_gro_enable_result *res;
4007 res = parsed_result;
4008 if (!strcmp(res->cmd_keyword, "gro"))
4009 setup_gro(res->cmd_onoff, res->cmd_pid);
4012 cmdline_parse_token_string_t cmd_gro_enable_set =
4013 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4015 cmdline_parse_token_string_t cmd_gro_enable_port =
4016 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4017 cmd_keyword, "port");
4018 cmdline_parse_token_num_t cmd_gro_enable_pid =
4019 TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result,
4021 cmdline_parse_token_string_t cmd_gro_enable_keyword =
4022 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4023 cmd_keyword, "gro");
4024 cmdline_parse_token_string_t cmd_gro_enable_onoff =
4025 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4026 cmd_onoff, "on#off");
4028 cmdline_parse_inst_t cmd_gro_enable = {
4029 .f = cmd_gro_enable_parsed,
4031 .help_str = "set port <port_id> gro on|off",
4033 (void *)&cmd_gro_enable_set,
4034 (void *)&cmd_gro_enable_port,
4035 (void *)&cmd_gro_enable_pid,
4036 (void *)&cmd_gro_enable_keyword,
4037 (void *)&cmd_gro_enable_onoff,
4042 /* *** DISPLAY GRO CONFIGURATION *** */
4043 struct cmd_gro_show_result {
4044 cmdline_fixed_string_t cmd_show;
4045 cmdline_fixed_string_t cmd_port;
4046 cmdline_fixed_string_t cmd_keyword;
4051 cmd_gro_show_parsed(void *parsed_result,
4052 __attribute__((unused)) struct cmdline *cl,
4053 __attribute__((unused)) void *data)
4055 struct cmd_gro_show_result *res;
4057 res = parsed_result;
4058 if (!strcmp(res->cmd_keyword, "gro"))
4059 show_gro(res->cmd_pid);
4062 cmdline_parse_token_string_t cmd_gro_show_show =
4063 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4065 cmdline_parse_token_string_t cmd_gro_show_port =
4066 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4068 cmdline_parse_token_num_t cmd_gro_show_pid =
4069 TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result,
4071 cmdline_parse_token_string_t cmd_gro_show_keyword =
4072 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4073 cmd_keyword, "gro");
4075 cmdline_parse_inst_t cmd_gro_show = {
4076 .f = cmd_gro_show_parsed,
4078 .help_str = "show port <port_id> gro",
4080 (void *)&cmd_gro_show_show,
4081 (void *)&cmd_gro_show_port,
4082 (void *)&cmd_gro_show_pid,
4083 (void *)&cmd_gro_show_keyword,
4088 /* *** SET FLUSH CYCLES FOR GRO *** */
4089 struct cmd_gro_flush_result {
4090 cmdline_fixed_string_t cmd_set;
4091 cmdline_fixed_string_t cmd_keyword;
4092 cmdline_fixed_string_t cmd_flush;
4097 cmd_gro_flush_parsed(void *parsed_result,
4098 __attribute__((unused)) struct cmdline *cl,
4099 __attribute__((unused)) void *data)
4101 struct cmd_gro_flush_result *res;
4103 res = parsed_result;
4104 if ((!strcmp(res->cmd_keyword, "gro")) &&
4105 (!strcmp(res->cmd_flush, "flush")))
4106 setup_gro_flush_cycles(res->cmd_cycles);
4109 cmdline_parse_token_string_t cmd_gro_flush_set =
4110 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4112 cmdline_parse_token_string_t cmd_gro_flush_keyword =
4113 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4114 cmd_keyword, "gro");
4115 cmdline_parse_token_string_t cmd_gro_flush_flush =
4116 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4117 cmd_flush, "flush");
4118 cmdline_parse_token_num_t cmd_gro_flush_cycles =
4119 TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result,
4122 cmdline_parse_inst_t cmd_gro_flush = {
4123 .f = cmd_gro_flush_parsed,
4125 .help_str = "set gro flush <cycles>",
4127 (void *)&cmd_gro_flush_set,
4128 (void *)&cmd_gro_flush_keyword,
4129 (void *)&cmd_gro_flush_flush,
4130 (void *)&cmd_gro_flush_cycles,
4135 /* *** ENABLE/DISABLE GSO *** */
4136 struct cmd_gso_enable_result {
4137 cmdline_fixed_string_t cmd_set;
4138 cmdline_fixed_string_t cmd_port;
4139 cmdline_fixed_string_t cmd_keyword;
4140 cmdline_fixed_string_t cmd_mode;
4145 cmd_gso_enable_parsed(void *parsed_result,
4146 __attribute__((unused)) struct cmdline *cl,
4147 __attribute__((unused)) void *data)
4149 struct cmd_gso_enable_result *res;
4151 res = parsed_result;
4152 if (!strcmp(res->cmd_keyword, "gso"))
4153 setup_gso(res->cmd_mode, res->cmd_pid);
4156 cmdline_parse_token_string_t cmd_gso_enable_set =
4157 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4159 cmdline_parse_token_string_t cmd_gso_enable_port =
4160 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4162 cmdline_parse_token_string_t cmd_gso_enable_keyword =
4163 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4164 cmd_keyword, "gso");
4165 cmdline_parse_token_string_t cmd_gso_enable_mode =
4166 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4167 cmd_mode, "on#off");
4168 cmdline_parse_token_num_t cmd_gso_enable_pid =
4169 TOKEN_NUM_INITIALIZER(struct cmd_gso_enable_result,
4172 cmdline_parse_inst_t cmd_gso_enable = {
4173 .f = cmd_gso_enable_parsed,
4175 .help_str = "set port <port_id> gso on|off",
4177 (void *)&cmd_gso_enable_set,
4178 (void *)&cmd_gso_enable_port,
4179 (void *)&cmd_gso_enable_pid,
4180 (void *)&cmd_gso_enable_keyword,
4181 (void *)&cmd_gso_enable_mode,
4186 /* *** SET MAX PACKET LENGTH FOR GSO SEGMENTS *** */
4187 struct cmd_gso_size_result {
4188 cmdline_fixed_string_t cmd_set;
4189 cmdline_fixed_string_t cmd_keyword;
4190 cmdline_fixed_string_t cmd_segsz;
4195 cmd_gso_size_parsed(void *parsed_result,
4196 __attribute__((unused)) struct cmdline *cl,
4197 __attribute__((unused)) void *data)
4199 struct cmd_gso_size_result *res = parsed_result;
4201 if (test_done == 0) {
4202 printf("Before setting GSO segsz, please first"
4203 " stop fowarding\n");
4207 if (!strcmp(res->cmd_keyword, "gso") &&
4208 !strcmp(res->cmd_segsz, "segsz")) {
4209 if (res->cmd_size < RTE_GSO_SEG_SIZE_MIN)
4210 printf("gso_size should be larger than %zu."
4211 " Please input a legal value\n",
4212 RTE_GSO_SEG_SIZE_MIN);
4214 gso_max_segment_size = res->cmd_size;
4218 cmdline_parse_token_string_t cmd_gso_size_set =
4219 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
4221 cmdline_parse_token_string_t cmd_gso_size_keyword =
4222 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
4223 cmd_keyword, "gso");
4224 cmdline_parse_token_string_t cmd_gso_size_segsz =
4225 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
4226 cmd_segsz, "segsz");
4227 cmdline_parse_token_num_t cmd_gso_size_size =
4228 TOKEN_NUM_INITIALIZER(struct cmd_gso_size_result,
4231 cmdline_parse_inst_t cmd_gso_size = {
4232 .f = cmd_gso_size_parsed,
4234 .help_str = "set gso segsz <length>",
4236 (void *)&cmd_gso_size_set,
4237 (void *)&cmd_gso_size_keyword,
4238 (void *)&cmd_gso_size_segsz,
4239 (void *)&cmd_gso_size_size,
4244 /* *** SHOW GSO CONFIGURATION *** */
4245 struct cmd_gso_show_result {
4246 cmdline_fixed_string_t cmd_show;
4247 cmdline_fixed_string_t cmd_port;
4248 cmdline_fixed_string_t cmd_keyword;
4253 cmd_gso_show_parsed(void *parsed_result,
4254 __attribute__((unused)) struct cmdline *cl,
4255 __attribute__((unused)) void *data)
4257 struct cmd_gso_show_result *res = parsed_result;
4259 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
4260 printf("invalid port id %u\n", res->cmd_pid);
4263 if (!strcmp(res->cmd_keyword, "gso")) {
4264 if (gso_ports[res->cmd_pid].enable) {
4265 printf("Max GSO'd packet size: %uB\n"
4266 "Supported GSO types: TCP/IPv4, "
4267 "VxLAN with inner TCP/IPv4 packet, "
4268 "GRE with inner TCP/IPv4 packet\n",
4269 gso_max_segment_size);
4271 printf("GSO is not enabled on Port %u\n", res->cmd_pid);
4275 cmdline_parse_token_string_t cmd_gso_show_show =
4276 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
4278 cmdline_parse_token_string_t cmd_gso_show_port =
4279 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
4281 cmdline_parse_token_string_t cmd_gso_show_keyword =
4282 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
4283 cmd_keyword, "gso");
4284 cmdline_parse_token_num_t cmd_gso_show_pid =
4285 TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result,
4288 cmdline_parse_inst_t cmd_gso_show = {
4289 .f = cmd_gso_show_parsed,
4291 .help_str = "show port <port_id> gso",
4293 (void *)&cmd_gso_show_show,
4294 (void *)&cmd_gso_show_port,
4295 (void *)&cmd_gso_show_pid,
4296 (void *)&cmd_gso_show_keyword,
4301 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
4302 struct cmd_set_flush_rx {
4303 cmdline_fixed_string_t set;
4304 cmdline_fixed_string_t flush_rx;
4305 cmdline_fixed_string_t mode;
4309 cmd_set_flush_rx_parsed(void *parsed_result,
4310 __attribute__((unused)) struct cmdline *cl,
4311 __attribute__((unused)) void *data)
4313 struct cmd_set_flush_rx *res = parsed_result;
4314 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
4317 cmdline_parse_token_string_t cmd_setflushrx_set =
4318 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
4320 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
4321 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
4322 flush_rx, "flush_rx");
4323 cmdline_parse_token_string_t cmd_setflushrx_mode =
4324 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
4328 cmdline_parse_inst_t cmd_set_flush_rx = {
4329 .f = cmd_set_flush_rx_parsed,
4330 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
4333 (void *)&cmd_setflushrx_set,
4334 (void *)&cmd_setflushrx_flush_rx,
4335 (void *)&cmd_setflushrx_mode,
4340 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
4341 struct cmd_set_link_check {
4342 cmdline_fixed_string_t set;
4343 cmdline_fixed_string_t link_check;
4344 cmdline_fixed_string_t mode;
4348 cmd_set_link_check_parsed(void *parsed_result,
4349 __attribute__((unused)) struct cmdline *cl,
4350 __attribute__((unused)) void *data)
4352 struct cmd_set_link_check *res = parsed_result;
4353 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
4356 cmdline_parse_token_string_t cmd_setlinkcheck_set =
4357 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
4359 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
4360 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
4361 link_check, "link_check");
4362 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
4363 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
4367 cmdline_parse_inst_t cmd_set_link_check = {
4368 .f = cmd_set_link_check_parsed,
4369 .help_str = "set link_check on|off: Enable/Disable link status check "
4370 "when starting/stopping a port",
4373 (void *)&cmd_setlinkcheck_set,
4374 (void *)&cmd_setlinkcheck_link_check,
4375 (void *)&cmd_setlinkcheck_mode,
4380 /* *** SET NIC BYPASS MODE *** */
4381 struct cmd_set_bypass_mode_result {
4382 cmdline_fixed_string_t set;
4383 cmdline_fixed_string_t bypass;
4384 cmdline_fixed_string_t mode;
4385 cmdline_fixed_string_t value;
4390 cmd_set_bypass_mode_parsed(void *parsed_result,
4391 __attribute__((unused)) struct cmdline *cl,
4392 __attribute__((unused)) void *data)
4394 struct cmd_set_bypass_mode_result *res = parsed_result;
4395 portid_t port_id = res->port_id;
4396 int32_t rc = -EINVAL;
4398 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4399 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4401 if (!strcmp(res->value, "bypass"))
4402 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
4403 else if (!strcmp(res->value, "isolate"))
4404 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
4406 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4408 /* Set the bypass mode for the relevant port. */
4409 rc = rte_pmd_ixgbe_bypass_state_set(port_id, &bypass_mode);
4412 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
4415 cmdline_parse_token_string_t cmd_setbypass_mode_set =
4416 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4418 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
4419 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4421 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
4422 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4424 cmdline_parse_token_string_t cmd_setbypass_mode_value =
4425 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4426 value, "normal#bypass#isolate");
4427 cmdline_parse_token_num_t cmd_setbypass_mode_port =
4428 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
4431 cmdline_parse_inst_t cmd_set_bypass_mode = {
4432 .f = cmd_set_bypass_mode_parsed,
4433 .help_str = "set bypass mode normal|bypass|isolate <port_id>: "
4434 "Set the NIC bypass mode for port_id",
4437 (void *)&cmd_setbypass_mode_set,
4438 (void *)&cmd_setbypass_mode_bypass,
4439 (void *)&cmd_setbypass_mode_mode,
4440 (void *)&cmd_setbypass_mode_value,
4441 (void *)&cmd_setbypass_mode_port,
4446 /* *** SET NIC BYPASS EVENT *** */
4447 struct cmd_set_bypass_event_result {
4448 cmdline_fixed_string_t set;
4449 cmdline_fixed_string_t bypass;
4450 cmdline_fixed_string_t event;
4451 cmdline_fixed_string_t event_value;
4452 cmdline_fixed_string_t mode;
4453 cmdline_fixed_string_t mode_value;
4458 cmd_set_bypass_event_parsed(void *parsed_result,
4459 __attribute__((unused)) struct cmdline *cl,
4460 __attribute__((unused)) void *data)
4462 int32_t rc = -EINVAL;
4463 struct cmd_set_bypass_event_result *res = parsed_result;
4464 portid_t port_id = res->port_id;
4466 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4467 uint32_t bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
4468 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4470 if (!strcmp(res->event_value, "timeout"))
4471 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT;
4472 else if (!strcmp(res->event_value, "os_on"))
4473 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_ON;
4474 else if (!strcmp(res->event_value, "os_off"))
4475 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_OFF;
4476 else if (!strcmp(res->event_value, "power_on"))
4477 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_ON;
4478 else if (!strcmp(res->event_value, "power_off"))
4479 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_OFF;
4481 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
4483 if (!strcmp(res->mode_value, "bypass"))
4484 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
4485 else if (!strcmp(res->mode_value, "isolate"))
4486 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
4488 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4490 /* Set the watchdog timeout. */
4491 if (bypass_event == RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT) {
4494 if (RTE_PMD_IXGBE_BYPASS_TMT_VALID(bypass_timeout)) {
4495 rc = rte_pmd_ixgbe_bypass_wd_timeout_store(port_id,
4499 printf("Failed to set timeout value %u "
4500 "for port %d, errto code: %d.\n",
4501 bypass_timeout, port_id, rc);
4505 /* Set the bypass event to transition to bypass mode. */
4506 rc = rte_pmd_ixgbe_bypass_event_store(port_id, bypass_event,
4511 printf("\t Failed to set bypass event for port = %d.\n",
4515 cmdline_parse_token_string_t cmd_setbypass_event_set =
4516 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4518 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
4519 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4521 cmdline_parse_token_string_t cmd_setbypass_event_event =
4522 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4524 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
4525 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4526 event_value, "none#timeout#os_off#os_on#power_on#power_off");
4527 cmdline_parse_token_string_t cmd_setbypass_event_mode =
4528 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4530 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
4531 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4532 mode_value, "normal#bypass#isolate");
4533 cmdline_parse_token_num_t cmd_setbypass_event_port =
4534 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
4537 cmdline_parse_inst_t cmd_set_bypass_event = {
4538 .f = cmd_set_bypass_event_parsed,
4539 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
4540 "power_off mode normal|bypass|isolate <port_id>: "
4541 "Set the NIC bypass event mode for port_id",
4544 (void *)&cmd_setbypass_event_set,
4545 (void *)&cmd_setbypass_event_bypass,
4546 (void *)&cmd_setbypass_event_event,
4547 (void *)&cmd_setbypass_event_event_value,
4548 (void *)&cmd_setbypass_event_mode,
4549 (void *)&cmd_setbypass_event_mode_value,
4550 (void *)&cmd_setbypass_event_port,
4556 /* *** SET NIC BYPASS TIMEOUT *** */
4557 struct cmd_set_bypass_timeout_result {
4558 cmdline_fixed_string_t set;
4559 cmdline_fixed_string_t bypass;
4560 cmdline_fixed_string_t timeout;
4561 cmdline_fixed_string_t value;
4565 cmd_set_bypass_timeout_parsed(void *parsed_result,
4566 __attribute__((unused)) struct cmdline *cl,
4567 __attribute__((unused)) void *data)
4569 __rte_unused struct cmd_set_bypass_timeout_result *res = parsed_result;
4571 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4572 if (!strcmp(res->value, "1.5"))
4573 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_1_5_SEC;
4574 else if (!strcmp(res->value, "2"))
4575 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_2_SEC;
4576 else if (!strcmp(res->value, "3"))
4577 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_3_SEC;
4578 else if (!strcmp(res->value, "4"))
4579 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_4_SEC;
4580 else if (!strcmp(res->value, "8"))
4581 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_8_SEC;
4582 else if (!strcmp(res->value, "16"))
4583 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_16_SEC;
4584 else if (!strcmp(res->value, "32"))
4585 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_32_SEC;
4587 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
4591 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
4592 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4594 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
4595 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4597 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
4598 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4599 timeout, "timeout");
4600 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
4601 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4602 value, "0#1.5#2#3#4#8#16#32");
4604 cmdline_parse_inst_t cmd_set_bypass_timeout = {
4605 .f = cmd_set_bypass_timeout_parsed,
4606 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
4607 "Set the NIC bypass watchdog timeout in seconds",
4610 (void *)&cmd_setbypass_timeout_set,
4611 (void *)&cmd_setbypass_timeout_bypass,
4612 (void *)&cmd_setbypass_timeout_timeout,
4613 (void *)&cmd_setbypass_timeout_value,
4618 /* *** SHOW NIC BYPASS MODE *** */
4619 struct cmd_show_bypass_config_result {
4620 cmdline_fixed_string_t show;
4621 cmdline_fixed_string_t bypass;
4622 cmdline_fixed_string_t config;
4627 cmd_show_bypass_config_parsed(void *parsed_result,
4628 __attribute__((unused)) struct cmdline *cl,
4629 __attribute__((unused)) void *data)
4631 struct cmd_show_bypass_config_result *res = parsed_result;
4632 portid_t port_id = res->port_id;
4634 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4635 uint32_t event_mode;
4636 uint32_t bypass_mode;
4637 uint32_t timeout = bypass_timeout;
4640 static const char * const timeouts[RTE_PMD_IXGBE_BYPASS_TMT_NUM] =
4641 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
4642 static const char * const modes[RTE_PMD_IXGBE_BYPASS_MODE_NUM] =
4643 {"UNKNOWN", "normal", "bypass", "isolate"};
4644 static const char * const events[RTE_PMD_IXGBE_BYPASS_EVENT_NUM] = {
4651 int num_events = (sizeof events) / (sizeof events[0]);
4653 /* Display the bypass mode.*/
4654 if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) != 0) {
4655 printf("\tFailed to get bypass mode for port = %d\n", port_id);
4659 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(bypass_mode))
4660 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
4662 printf("\tbypass mode = %s\n", modes[bypass_mode]);
4665 /* Display the bypass timeout.*/
4666 if (!RTE_PMD_IXGBE_BYPASS_TMT_VALID(timeout))
4667 timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
4669 printf("\tbypass timeout = %s\n", timeouts[timeout]);
4671 /* Display the bypass events and associated modes. */
4672 for (i = RTE_PMD_IXGBE_BYPASS_EVENT_START; i < num_events; i++) {
4674 if (rte_pmd_ixgbe_bypass_event_show(port_id, i, &event_mode)) {
4675 printf("\tFailed to get bypass mode for event = %s\n",
4678 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(event_mode))
4679 event_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
4681 printf("\tbypass event: %-16s = %s\n", events[i],
4687 printf("\tFailed to get bypass configuration for port = %d\n",
4691 cmdline_parse_token_string_t cmd_showbypass_config_show =
4692 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4694 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
4695 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4697 cmdline_parse_token_string_t cmd_showbypass_config_config =
4698 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4700 cmdline_parse_token_num_t cmd_showbypass_config_port =
4701 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
4704 cmdline_parse_inst_t cmd_show_bypass_config = {
4705 .f = cmd_show_bypass_config_parsed,
4706 .help_str = "show bypass config <port_id>: "
4707 "Show the NIC bypass config for port_id",
4710 (void *)&cmd_showbypass_config_show,
4711 (void *)&cmd_showbypass_config_bypass,
4712 (void *)&cmd_showbypass_config_config,
4713 (void *)&cmd_showbypass_config_port,
4718 #ifdef RTE_LIBRTE_PMD_BOND
4719 /* *** SET BONDING MODE *** */
4720 struct cmd_set_bonding_mode_result {
4721 cmdline_fixed_string_t set;
4722 cmdline_fixed_string_t bonding;
4723 cmdline_fixed_string_t mode;
4728 static void cmd_set_bonding_mode_parsed(void *parsed_result,
4729 __attribute__((unused)) struct cmdline *cl,
4730 __attribute__((unused)) void *data)
4732 struct cmd_set_bonding_mode_result *res = parsed_result;
4733 portid_t port_id = res->port_id;
4735 /* Set the bonding mode for the relevant port. */
4736 if (0 != rte_eth_bond_mode_set(port_id, res->value))
4737 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
4740 cmdline_parse_token_string_t cmd_setbonding_mode_set =
4741 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4743 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
4744 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4745 bonding, "bonding");
4746 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
4747 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4749 cmdline_parse_token_num_t cmd_setbonding_mode_value =
4750 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
4752 cmdline_parse_token_num_t cmd_setbonding_mode_port =
4753 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
4756 cmdline_parse_inst_t cmd_set_bonding_mode = {
4757 .f = cmd_set_bonding_mode_parsed,
4758 .help_str = "set bonding mode <mode_value> <port_id>: "
4759 "Set the bonding mode for port_id",
4762 (void *) &cmd_setbonding_mode_set,
4763 (void *) &cmd_setbonding_mode_bonding,
4764 (void *) &cmd_setbonding_mode_mode,
4765 (void *) &cmd_setbonding_mode_value,
4766 (void *) &cmd_setbonding_mode_port,
4771 /* *** SET BONDING SLOW_QUEUE SW/HW *** */
4772 struct cmd_set_bonding_lacp_dedicated_queues_result {
4773 cmdline_fixed_string_t set;
4774 cmdline_fixed_string_t bonding;
4775 cmdline_fixed_string_t lacp;
4776 cmdline_fixed_string_t dedicated_queues;
4778 cmdline_fixed_string_t mode;
4781 static void cmd_set_bonding_lacp_dedicated_queues_parsed(void *parsed_result,
4782 __attribute__((unused)) struct cmdline *cl,
4783 __attribute__((unused)) void *data)
4785 struct cmd_set_bonding_lacp_dedicated_queues_result *res = parsed_result;
4786 portid_t port_id = res->port_id;
4787 struct rte_port *port;
4789 port = &ports[port_id];
4791 /** Check if the port is not started **/
4792 if (port->port_status != RTE_PORT_STOPPED) {
4793 printf("Please stop port %d first\n", port_id);
4797 if (!strcmp(res->mode, "enable")) {
4798 if (rte_eth_bond_8023ad_dedicated_queues_enable(port_id) == 0)
4799 printf("Dedicate queues for LACP control packets"
4802 printf("Enabling dedicate queues for LACP control "
4803 "packets on port %d failed\n", port_id);
4804 } else if (!strcmp(res->mode, "disable")) {
4805 if (rte_eth_bond_8023ad_dedicated_queues_disable(port_id) == 0)
4806 printf("Dedicated queues for LACP control packets "
4809 printf("Disabling dedicated queues for LACP control "
4810 "traffic on port %d failed\n", port_id);
4814 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_set =
4815 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4817 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_bonding =
4818 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4819 bonding, "bonding");
4820 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_lacp =
4821 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4823 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_dedicated_queues =
4824 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4825 dedicated_queues, "dedicated_queues");
4826 cmdline_parse_token_num_t cmd_setbonding_lacp_dedicated_queues_port_id =
4827 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4829 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_mode =
4830 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4831 mode, "enable#disable");
4833 cmdline_parse_inst_t cmd_set_lacp_dedicated_queues = {
4834 .f = cmd_set_bonding_lacp_dedicated_queues_parsed,
4835 .help_str = "set bonding lacp dedicated_queues <port_id> "
4837 "Enable/disable dedicated queues for LACP control traffic for port_id",
4840 (void *)&cmd_setbonding_lacp_dedicated_queues_set,
4841 (void *)&cmd_setbonding_lacp_dedicated_queues_bonding,
4842 (void *)&cmd_setbonding_lacp_dedicated_queues_lacp,
4843 (void *)&cmd_setbonding_lacp_dedicated_queues_dedicated_queues,
4844 (void *)&cmd_setbonding_lacp_dedicated_queues_port_id,
4845 (void *)&cmd_setbonding_lacp_dedicated_queues_mode,
4850 /* *** SET BALANCE XMIT POLICY *** */
4851 struct cmd_set_bonding_balance_xmit_policy_result {
4852 cmdline_fixed_string_t set;
4853 cmdline_fixed_string_t bonding;
4854 cmdline_fixed_string_t balance_xmit_policy;
4856 cmdline_fixed_string_t policy;
4859 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
4860 __attribute__((unused)) struct cmdline *cl,
4861 __attribute__((unused)) void *data)
4863 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
4864 portid_t port_id = res->port_id;
4867 if (!strcmp(res->policy, "l2")) {
4868 policy = BALANCE_XMIT_POLICY_LAYER2;
4869 } else if (!strcmp(res->policy, "l23")) {
4870 policy = BALANCE_XMIT_POLICY_LAYER23;
4871 } else if (!strcmp(res->policy, "l34")) {
4872 policy = BALANCE_XMIT_POLICY_LAYER34;
4874 printf("\t Invalid xmit policy selection");
4878 /* Set the bonding mode for the relevant port. */
4879 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
4880 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
4885 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
4886 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4888 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
4889 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4890 bonding, "bonding");
4891 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
4892 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4893 balance_xmit_policy, "balance_xmit_policy");
4894 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
4895 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4897 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
4898 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4899 policy, "l2#l23#l34");
4901 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
4902 .f = cmd_set_bonding_balance_xmit_policy_parsed,
4903 .help_str = "set bonding balance_xmit_policy <port_id> "
4905 "Set the bonding balance_xmit_policy for port_id",
4908 (void *)&cmd_setbonding_balance_xmit_policy_set,
4909 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
4910 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
4911 (void *)&cmd_setbonding_balance_xmit_policy_port,
4912 (void *)&cmd_setbonding_balance_xmit_policy_policy,
4917 /* *** SHOW NIC BONDING CONFIGURATION *** */
4918 struct cmd_show_bonding_config_result {
4919 cmdline_fixed_string_t show;
4920 cmdline_fixed_string_t bonding;
4921 cmdline_fixed_string_t config;
4925 static void cmd_show_bonding_config_parsed(void *parsed_result,
4926 __attribute__((unused)) struct cmdline *cl,
4927 __attribute__((unused)) void *data)
4929 struct cmd_show_bonding_config_result *res = parsed_result;
4930 int bonding_mode, agg_mode;
4931 portid_t slaves[RTE_MAX_ETHPORTS];
4932 int num_slaves, num_active_slaves;
4935 portid_t port_id = res->port_id;
4937 /* Display the bonding mode.*/
4938 bonding_mode = rte_eth_bond_mode_get(port_id);
4939 if (bonding_mode < 0) {
4940 printf("\tFailed to get bonding mode for port = %d\n", port_id);
4943 printf("\tBonding mode: %d\n", bonding_mode);
4945 if (bonding_mode == BONDING_MODE_BALANCE) {
4946 int balance_xmit_policy;
4948 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
4949 if (balance_xmit_policy < 0) {
4950 printf("\tFailed to get balance xmit policy for port = %d\n",
4954 printf("\tBalance Xmit Policy: ");
4956 switch (balance_xmit_policy) {
4957 case BALANCE_XMIT_POLICY_LAYER2:
4958 printf("BALANCE_XMIT_POLICY_LAYER2");
4960 case BALANCE_XMIT_POLICY_LAYER23:
4961 printf("BALANCE_XMIT_POLICY_LAYER23");
4963 case BALANCE_XMIT_POLICY_LAYER34:
4964 printf("BALANCE_XMIT_POLICY_LAYER34");
4971 if (bonding_mode == BONDING_MODE_8023AD) {
4972 agg_mode = rte_eth_bond_8023ad_agg_selection_get(port_id);
4973 printf("\tIEEE802.3AD Aggregator Mode: ");
4976 printf("bandwidth");
4988 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
4990 if (num_slaves < 0) {
4991 printf("\tFailed to get slave list for port = %d\n", port_id);
4994 if (num_slaves > 0) {
4995 printf("\tSlaves (%d): [", num_slaves);
4996 for (i = 0; i < num_slaves - 1; i++)
4997 printf("%d ", slaves[i]);
4999 printf("%d]\n", slaves[num_slaves - 1]);
5001 printf("\tSlaves: []\n");
5005 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
5008 if (num_active_slaves < 0) {
5009 printf("\tFailed to get active slave list for port = %d\n", port_id);
5012 if (num_active_slaves > 0) {
5013 printf("\tActive Slaves (%d): [", num_active_slaves);
5014 for (i = 0; i < num_active_slaves - 1; i++)
5015 printf("%d ", slaves[i]);
5017 printf("%d]\n", slaves[num_active_slaves - 1]);
5020 printf("\tActive Slaves: []\n");
5024 primary_id = rte_eth_bond_primary_get(port_id);
5025 if (primary_id < 0) {
5026 printf("\tFailed to get primary slave for port = %d\n", port_id);
5029 printf("\tPrimary: [%d]\n", primary_id);
5033 cmdline_parse_token_string_t cmd_showbonding_config_show =
5034 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5036 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
5037 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5038 bonding, "bonding");
5039 cmdline_parse_token_string_t cmd_showbonding_config_config =
5040 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5042 cmdline_parse_token_num_t cmd_showbonding_config_port =
5043 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
5046 cmdline_parse_inst_t cmd_show_bonding_config = {
5047 .f = cmd_show_bonding_config_parsed,
5048 .help_str = "show bonding config <port_id>: "
5049 "Show the bonding config for port_id",
5052 (void *)&cmd_showbonding_config_show,
5053 (void *)&cmd_showbonding_config_bonding,
5054 (void *)&cmd_showbonding_config_config,
5055 (void *)&cmd_showbonding_config_port,
5060 /* *** SET BONDING PRIMARY *** */
5061 struct cmd_set_bonding_primary_result {
5062 cmdline_fixed_string_t set;
5063 cmdline_fixed_string_t bonding;
5064 cmdline_fixed_string_t primary;
5069 static void cmd_set_bonding_primary_parsed(void *parsed_result,
5070 __attribute__((unused)) struct cmdline *cl,
5071 __attribute__((unused)) void *data)
5073 struct cmd_set_bonding_primary_result *res = parsed_result;
5074 portid_t master_port_id = res->port_id;
5075 portid_t slave_port_id = res->slave_id;
5077 /* Set the primary slave for a bonded device. */
5078 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
5079 printf("\t Failed to set primary slave for port = %d.\n",
5086 cmdline_parse_token_string_t cmd_setbonding_primary_set =
5087 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5089 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
5090 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5091 bonding, "bonding");
5092 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
5093 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5094 primary, "primary");
5095 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
5096 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
5098 cmdline_parse_token_num_t cmd_setbonding_primary_port =
5099 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
5102 cmdline_parse_inst_t cmd_set_bonding_primary = {
5103 .f = cmd_set_bonding_primary_parsed,
5104 .help_str = "set bonding primary <slave_id> <port_id>: "
5105 "Set the primary slave for port_id",
5108 (void *)&cmd_setbonding_primary_set,
5109 (void *)&cmd_setbonding_primary_bonding,
5110 (void *)&cmd_setbonding_primary_primary,
5111 (void *)&cmd_setbonding_primary_slave,
5112 (void *)&cmd_setbonding_primary_port,
5117 /* *** ADD SLAVE *** */
5118 struct cmd_add_bonding_slave_result {
5119 cmdline_fixed_string_t add;
5120 cmdline_fixed_string_t bonding;
5121 cmdline_fixed_string_t slave;
5126 static void cmd_add_bonding_slave_parsed(void *parsed_result,
5127 __attribute__((unused)) struct cmdline *cl,
5128 __attribute__((unused)) void *data)
5130 struct cmd_add_bonding_slave_result *res = parsed_result;
5131 portid_t master_port_id = res->port_id;
5132 portid_t slave_port_id = res->slave_id;
5134 /* add the slave for a bonded device. */
5135 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
5136 printf("\t Failed to add slave %d to master port = %d.\n",
5137 slave_port_id, master_port_id);
5141 set_port_slave_flag(slave_port_id);
5144 cmdline_parse_token_string_t cmd_addbonding_slave_add =
5145 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5147 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
5148 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5149 bonding, "bonding");
5150 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
5151 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5153 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
5154 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
5156 cmdline_parse_token_num_t cmd_addbonding_slave_port =
5157 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
5160 cmdline_parse_inst_t cmd_add_bonding_slave = {
5161 .f = cmd_add_bonding_slave_parsed,
5162 .help_str = "add bonding slave <slave_id> <port_id>: "
5163 "Add a slave device to a bonded device",
5166 (void *)&cmd_addbonding_slave_add,
5167 (void *)&cmd_addbonding_slave_bonding,
5168 (void *)&cmd_addbonding_slave_slave,
5169 (void *)&cmd_addbonding_slave_slaveid,
5170 (void *)&cmd_addbonding_slave_port,
5175 /* *** REMOVE SLAVE *** */
5176 struct cmd_remove_bonding_slave_result {
5177 cmdline_fixed_string_t remove;
5178 cmdline_fixed_string_t bonding;
5179 cmdline_fixed_string_t slave;
5184 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
5185 __attribute__((unused)) struct cmdline *cl,
5186 __attribute__((unused)) void *data)
5188 struct cmd_remove_bonding_slave_result *res = parsed_result;
5189 portid_t master_port_id = res->port_id;
5190 portid_t slave_port_id = res->slave_id;
5192 /* remove the slave from a bonded device. */
5193 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
5194 printf("\t Failed to remove slave %d from master port = %d.\n",
5195 slave_port_id, master_port_id);
5199 clear_port_slave_flag(slave_port_id);
5202 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
5203 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
5205 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
5206 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
5207 bonding, "bonding");
5208 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
5209 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
5211 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
5212 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
5214 cmdline_parse_token_num_t cmd_removebonding_slave_port =
5215 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
5218 cmdline_parse_inst_t cmd_remove_bonding_slave = {
5219 .f = cmd_remove_bonding_slave_parsed,
5220 .help_str = "remove bonding slave <slave_id> <port_id>: "
5221 "Remove a slave device from a bonded device",
5224 (void *)&cmd_removebonding_slave_remove,
5225 (void *)&cmd_removebonding_slave_bonding,
5226 (void *)&cmd_removebonding_slave_slave,
5227 (void *)&cmd_removebonding_slave_slaveid,
5228 (void *)&cmd_removebonding_slave_port,
5233 /* *** CREATE BONDED DEVICE *** */
5234 struct cmd_create_bonded_device_result {
5235 cmdline_fixed_string_t create;
5236 cmdline_fixed_string_t bonded;
5237 cmdline_fixed_string_t device;
5242 static int bond_dev_num = 0;
5244 static void cmd_create_bonded_device_parsed(void *parsed_result,
5245 __attribute__((unused)) struct cmdline *cl,
5246 __attribute__((unused)) void *data)
5248 struct cmd_create_bonded_device_result *res = parsed_result;
5249 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
5252 if (test_done == 0) {
5253 printf("Please stop forwarding first\n");
5257 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bonding_testpmd_%d",
5260 /* Create a new bonded device. */
5261 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
5263 printf("\t Failed to create bonded device.\n");
5266 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
5269 /* Update number of ports */
5270 nb_ports = rte_eth_dev_count();
5271 reconfig(port_id, res->socket);
5272 rte_eth_promiscuous_enable(port_id);
5277 cmdline_parse_token_string_t cmd_createbonded_device_create =
5278 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
5280 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
5281 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
5283 cmdline_parse_token_string_t cmd_createbonded_device_device =
5284 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
5286 cmdline_parse_token_num_t cmd_createbonded_device_mode =
5287 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
5289 cmdline_parse_token_num_t cmd_createbonded_device_socket =
5290 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
5293 cmdline_parse_inst_t cmd_create_bonded_device = {
5294 .f = cmd_create_bonded_device_parsed,
5295 .help_str = "create bonded device <mode> <socket>: "
5296 "Create a new bonded device with specific bonding mode and socket",
5299 (void *)&cmd_createbonded_device_create,
5300 (void *)&cmd_createbonded_device_bonded,
5301 (void *)&cmd_createbonded_device_device,
5302 (void *)&cmd_createbonded_device_mode,
5303 (void *)&cmd_createbonded_device_socket,
5308 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
5309 struct cmd_set_bond_mac_addr_result {
5310 cmdline_fixed_string_t set;
5311 cmdline_fixed_string_t bonding;
5312 cmdline_fixed_string_t mac_addr;
5314 struct ether_addr address;
5317 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
5318 __attribute__((unused)) struct cmdline *cl,
5319 __attribute__((unused)) void *data)
5321 struct cmd_set_bond_mac_addr_result *res = parsed_result;
5324 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
5327 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
5329 /* check the return value and print it if is < 0 */
5331 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
5334 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
5335 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
5336 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
5337 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
5339 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
5340 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
5342 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
5343 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result,
5345 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
5346 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
5348 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
5349 .f = cmd_set_bond_mac_addr_parsed,
5351 .help_str = "set bonding mac_addr <port_id> <mac_addr>",
5353 (void *)&cmd_set_bond_mac_addr_set,
5354 (void *)&cmd_set_bond_mac_addr_bonding,
5355 (void *)&cmd_set_bond_mac_addr_mac,
5356 (void *)&cmd_set_bond_mac_addr_portnum,
5357 (void *)&cmd_set_bond_mac_addr_addr,
5363 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
5364 struct cmd_set_bond_mon_period_result {
5365 cmdline_fixed_string_t set;
5366 cmdline_fixed_string_t bonding;
5367 cmdline_fixed_string_t mon_period;
5372 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
5373 __attribute__((unused)) struct cmdline *cl,
5374 __attribute__((unused)) void *data)
5376 struct cmd_set_bond_mon_period_result *res = parsed_result;
5379 if (res->port_num >= nb_ports) {
5380 printf("Port id %d must be less than %d\n", res->port_num, nb_ports);
5384 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
5386 /* check the return value and print it if is < 0 */
5388 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
5391 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
5392 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
5394 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
5395 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
5396 bonding, "bonding");
5397 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
5398 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
5399 mon_period, "mon_period");
5400 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
5401 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
5403 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
5404 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
5407 cmdline_parse_inst_t cmd_set_bond_mon_period = {
5408 .f = cmd_set_bond_mon_period_parsed,
5410 .help_str = "set bonding mon_period <port_id> <period_ms>",
5412 (void *)&cmd_set_bond_mon_period_set,
5413 (void *)&cmd_set_bond_mon_period_bonding,
5414 (void *)&cmd_set_bond_mon_period_mon_period,
5415 (void *)&cmd_set_bond_mon_period_portnum,
5416 (void *)&cmd_set_bond_mon_period_period_ms,
5423 struct cmd_set_bonding_agg_mode_policy_result {
5424 cmdline_fixed_string_t set;
5425 cmdline_fixed_string_t bonding;
5426 cmdline_fixed_string_t agg_mode;
5428 cmdline_fixed_string_t policy;
5433 cmd_set_bonding_agg_mode(void *parsed_result,
5434 __attribute__((unused)) struct cmdline *cl,
5435 __attribute__((unused)) void *data)
5437 struct cmd_set_bonding_agg_mode_policy_result *res = parsed_result;
5438 uint8_t policy = AGG_BANDWIDTH;
5440 if (res->port_num >= nb_ports) {
5441 printf("Port id %d must be less than %d\n",
5442 res->port_num, nb_ports);
5446 if (!strcmp(res->policy, "bandwidth"))
5447 policy = AGG_BANDWIDTH;
5448 else if (!strcmp(res->policy, "stable"))
5449 policy = AGG_STABLE;
5450 else if (!strcmp(res->policy, "count"))
5453 rte_eth_bond_8023ad_agg_selection_set(res->port_num, policy);
5457 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_set =
5458 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5460 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_bonding =
5461 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5462 bonding, "bonding");
5464 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_agg_mode =
5465 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5466 agg_mode, "agg_mode");
5468 cmdline_parse_token_num_t cmd_set_bonding_agg_mode_portnum =
5469 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5472 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_policy_string =
5473 TOKEN_STRING_INITIALIZER(
5474 struct cmd_set_bonding_balance_xmit_policy_result,
5475 policy, "stable#bandwidth#count");
5477 cmdline_parse_inst_t cmd_set_bonding_agg_mode_policy = {
5478 .f = cmd_set_bonding_agg_mode,
5480 .help_str = "set bonding mode IEEE802.3AD aggregator policy <port_id> <agg_name>",
5482 (void *)&cmd_set_bonding_agg_mode_set,
5483 (void *)&cmd_set_bonding_agg_mode_bonding,
5484 (void *)&cmd_set_bonding_agg_mode_agg_mode,
5485 (void *)&cmd_set_bonding_agg_mode_portnum,
5486 (void *)&cmd_set_bonding_agg_mode_policy_string,
5492 #endif /* RTE_LIBRTE_PMD_BOND */
5494 /* *** SET FORWARDING MODE *** */
5495 struct cmd_set_fwd_mode_result {
5496 cmdline_fixed_string_t set;
5497 cmdline_fixed_string_t fwd;
5498 cmdline_fixed_string_t mode;
5501 static void cmd_set_fwd_mode_parsed(void *parsed_result,
5502 __attribute__((unused)) struct cmdline *cl,
5503 __attribute__((unused)) void *data)
5505 struct cmd_set_fwd_mode_result *res = parsed_result;
5508 set_pkt_forwarding_mode(res->mode);
5511 cmdline_parse_token_string_t cmd_setfwd_set =
5512 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
5513 cmdline_parse_token_string_t cmd_setfwd_fwd =
5514 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
5515 cmdline_parse_token_string_t cmd_setfwd_mode =
5516 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
5517 "" /* defined at init */);
5519 cmdline_parse_inst_t cmd_set_fwd_mode = {
5520 .f = cmd_set_fwd_mode_parsed,
5522 .help_str = NULL, /* defined at init */
5524 (void *)&cmd_setfwd_set,
5525 (void *)&cmd_setfwd_fwd,
5526 (void *)&cmd_setfwd_mode,
5531 static void cmd_set_fwd_mode_init(void)
5534 static char token[128];
5535 static char help[256];
5536 cmdline_parse_token_string_t *token_struct;
5538 modes = list_pkt_forwarding_modes();
5539 snprintf(help, sizeof(help), "set fwd %s: "
5540 "Set packet forwarding mode", modes);
5541 cmd_set_fwd_mode.help_str = help;
5543 /* string token separator is # */
5544 for (c = token; *modes != '\0'; modes++)
5549 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
5550 token_struct->string_data.str = token;
5553 /* *** SET RETRY FORWARDING MODE *** */
5554 struct cmd_set_fwd_retry_mode_result {
5555 cmdline_fixed_string_t set;
5556 cmdline_fixed_string_t fwd;
5557 cmdline_fixed_string_t mode;
5558 cmdline_fixed_string_t retry;
5561 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
5562 __attribute__((unused)) struct cmdline *cl,
5563 __attribute__((unused)) void *data)
5565 struct cmd_set_fwd_retry_mode_result *res = parsed_result;
5568 set_pkt_forwarding_mode(res->mode);
5571 cmdline_parse_token_string_t cmd_setfwd_retry_set =
5572 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
5574 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
5575 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
5577 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
5578 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
5580 "" /* defined at init */);
5581 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
5582 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
5585 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
5586 .f = cmd_set_fwd_retry_mode_parsed,
5588 .help_str = NULL, /* defined at init */
5590 (void *)&cmd_setfwd_retry_set,
5591 (void *)&cmd_setfwd_retry_fwd,
5592 (void *)&cmd_setfwd_retry_mode,
5593 (void *)&cmd_setfwd_retry_retry,
5598 static void cmd_set_fwd_retry_mode_init(void)
5601 static char token[128];
5602 static char help[256];
5603 cmdline_parse_token_string_t *token_struct;
5605 modes = list_pkt_forwarding_retry_modes();
5606 snprintf(help, sizeof(help), "set fwd %s retry: "
5607 "Set packet forwarding mode with retry", modes);
5608 cmd_set_fwd_retry_mode.help_str = help;
5610 /* string token separator is # */
5611 for (c = token; *modes != '\0'; modes++)
5616 token_struct = (cmdline_parse_token_string_t *)
5617 cmd_set_fwd_retry_mode.tokens[2];
5618 token_struct->string_data.str = token;
5621 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
5622 struct cmd_set_burst_tx_retry_result {
5623 cmdline_fixed_string_t set;
5624 cmdline_fixed_string_t burst;
5625 cmdline_fixed_string_t tx;
5626 cmdline_fixed_string_t delay;
5628 cmdline_fixed_string_t retry;
5632 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
5633 __attribute__((unused)) struct cmdline *cl,
5634 __attribute__((unused)) void *data)
5636 struct cmd_set_burst_tx_retry_result *res = parsed_result;
5638 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
5639 && !strcmp(res->tx, "tx")) {
5640 if (!strcmp(res->delay, "delay"))
5641 burst_tx_delay_time = res->time;
5642 if (!strcmp(res->retry, "retry"))
5643 burst_tx_retry_num = res->retry_num;
5648 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
5649 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
5650 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
5651 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
5653 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
5654 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
5655 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
5656 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
5657 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
5658 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
5659 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
5660 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
5661 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
5662 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
5664 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
5665 .f = cmd_set_burst_tx_retry_parsed,
5666 .help_str = "set burst tx delay <delay_usec> retry <num_retry>",
5668 (void *)&cmd_set_burst_tx_retry_set,
5669 (void *)&cmd_set_burst_tx_retry_burst,
5670 (void *)&cmd_set_burst_tx_retry_tx,
5671 (void *)&cmd_set_burst_tx_retry_delay,
5672 (void *)&cmd_set_burst_tx_retry_time,
5673 (void *)&cmd_set_burst_tx_retry_retry,
5674 (void *)&cmd_set_burst_tx_retry_retry_num,
5679 /* *** SET PROMISC MODE *** */
5680 struct cmd_set_promisc_mode_result {
5681 cmdline_fixed_string_t set;
5682 cmdline_fixed_string_t promisc;
5683 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
5684 uint16_t port_num; /* valid if "allports" argument == 0 */
5685 cmdline_fixed_string_t mode;
5688 static void cmd_set_promisc_mode_parsed(void *parsed_result,
5689 __attribute__((unused)) struct cmdline *cl,
5692 struct cmd_set_promisc_mode_result *res = parsed_result;
5696 if (!strcmp(res->mode, "on"))
5703 RTE_ETH_FOREACH_DEV(i) {
5705 rte_eth_promiscuous_enable(i);
5707 rte_eth_promiscuous_disable(i);
5712 rte_eth_promiscuous_enable(res->port_num);
5714 rte_eth_promiscuous_disable(res->port_num);
5718 cmdline_parse_token_string_t cmd_setpromisc_set =
5719 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
5720 cmdline_parse_token_string_t cmd_setpromisc_promisc =
5721 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
5723 cmdline_parse_token_string_t cmd_setpromisc_portall =
5724 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
5726 cmdline_parse_token_num_t cmd_setpromisc_portnum =
5727 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
5729 cmdline_parse_token_string_t cmd_setpromisc_mode =
5730 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
5733 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
5734 .f = cmd_set_promisc_mode_parsed,
5736 .help_str = "set promisc all on|off: Set promisc mode for all ports",
5738 (void *)&cmd_setpromisc_set,
5739 (void *)&cmd_setpromisc_promisc,
5740 (void *)&cmd_setpromisc_portall,
5741 (void *)&cmd_setpromisc_mode,
5746 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
5747 .f = cmd_set_promisc_mode_parsed,
5749 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
5751 (void *)&cmd_setpromisc_set,
5752 (void *)&cmd_setpromisc_promisc,
5753 (void *)&cmd_setpromisc_portnum,
5754 (void *)&cmd_setpromisc_mode,
5759 /* *** SET ALLMULTI MODE *** */
5760 struct cmd_set_allmulti_mode_result {
5761 cmdline_fixed_string_t set;
5762 cmdline_fixed_string_t allmulti;
5763 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
5764 uint16_t port_num; /* valid if "allports" argument == 0 */
5765 cmdline_fixed_string_t mode;
5768 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
5769 __attribute__((unused)) struct cmdline *cl,
5772 struct cmd_set_allmulti_mode_result *res = parsed_result;
5776 if (!strcmp(res->mode, "on"))
5783 RTE_ETH_FOREACH_DEV(i) {
5785 rte_eth_allmulticast_enable(i);
5787 rte_eth_allmulticast_disable(i);
5792 rte_eth_allmulticast_enable(res->port_num);
5794 rte_eth_allmulticast_disable(res->port_num);
5798 cmdline_parse_token_string_t cmd_setallmulti_set =
5799 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
5800 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
5801 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
5803 cmdline_parse_token_string_t cmd_setallmulti_portall =
5804 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
5806 cmdline_parse_token_num_t cmd_setallmulti_portnum =
5807 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
5809 cmdline_parse_token_string_t cmd_setallmulti_mode =
5810 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
5813 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
5814 .f = cmd_set_allmulti_mode_parsed,
5816 .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
5818 (void *)&cmd_setallmulti_set,
5819 (void *)&cmd_setallmulti_allmulti,
5820 (void *)&cmd_setallmulti_portall,
5821 (void *)&cmd_setallmulti_mode,
5826 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
5827 .f = cmd_set_allmulti_mode_parsed,
5829 .help_str = "set allmulti <port_id> on|off: "
5830 "Set allmulti mode on port_id",
5832 (void *)&cmd_setallmulti_set,
5833 (void *)&cmd_setallmulti_allmulti,
5834 (void *)&cmd_setallmulti_portnum,
5835 (void *)&cmd_setallmulti_mode,
5840 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
5841 struct cmd_link_flow_ctrl_set_result {
5842 cmdline_fixed_string_t set;
5843 cmdline_fixed_string_t flow_ctrl;
5844 cmdline_fixed_string_t rx;
5845 cmdline_fixed_string_t rx_lfc_mode;
5846 cmdline_fixed_string_t tx;
5847 cmdline_fixed_string_t tx_lfc_mode;
5848 cmdline_fixed_string_t mac_ctrl_frame_fwd;
5849 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
5850 cmdline_fixed_string_t autoneg_str;
5851 cmdline_fixed_string_t autoneg;
5852 cmdline_fixed_string_t hw_str;
5853 uint32_t high_water;
5854 cmdline_fixed_string_t lw_str;
5856 cmdline_fixed_string_t pt_str;
5857 uint16_t pause_time;
5858 cmdline_fixed_string_t xon_str;
5863 cmdline_parse_token_string_t cmd_lfc_set_set =
5864 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5866 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
5867 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5868 flow_ctrl, "flow_ctrl");
5869 cmdline_parse_token_string_t cmd_lfc_set_rx =
5870 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5872 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
5873 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5874 rx_lfc_mode, "on#off");
5875 cmdline_parse_token_string_t cmd_lfc_set_tx =
5876 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5878 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
5879 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5880 tx_lfc_mode, "on#off");
5881 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
5882 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5883 hw_str, "high_water");
5884 cmdline_parse_token_num_t cmd_lfc_set_high_water =
5885 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5886 high_water, UINT32);
5887 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
5888 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5889 lw_str, "low_water");
5890 cmdline_parse_token_num_t cmd_lfc_set_low_water =
5891 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5893 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
5894 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5895 pt_str, "pause_time");
5896 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
5897 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5898 pause_time, UINT16);
5899 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
5900 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5901 xon_str, "send_xon");
5902 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
5903 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5905 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
5906 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5907 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
5908 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
5909 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5910 mac_ctrl_frame_fwd_mode, "on#off");
5911 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
5912 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5913 autoneg_str, "autoneg");
5914 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
5915 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5917 cmdline_parse_token_num_t cmd_lfc_set_portid =
5918 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5921 /* forward declaration */
5923 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
5926 cmdline_parse_inst_t cmd_link_flow_control_set = {
5927 .f = cmd_link_flow_ctrl_set_parsed,
5929 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
5930 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
5931 "autoneg on|off <port_id>: Configure the Ethernet flow control",
5933 (void *)&cmd_lfc_set_set,
5934 (void *)&cmd_lfc_set_flow_ctrl,
5935 (void *)&cmd_lfc_set_rx,
5936 (void *)&cmd_lfc_set_rx_mode,
5937 (void *)&cmd_lfc_set_tx,
5938 (void *)&cmd_lfc_set_tx_mode,
5939 (void *)&cmd_lfc_set_high_water,
5940 (void *)&cmd_lfc_set_low_water,
5941 (void *)&cmd_lfc_set_pause_time,
5942 (void *)&cmd_lfc_set_send_xon,
5943 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
5944 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
5945 (void *)&cmd_lfc_set_autoneg_str,
5946 (void *)&cmd_lfc_set_autoneg,
5947 (void *)&cmd_lfc_set_portid,
5952 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
5953 .f = cmd_link_flow_ctrl_set_parsed,
5954 .data = (void *)&cmd_link_flow_control_set_rx,
5955 .help_str = "set flow_ctrl rx on|off <port_id>: "
5956 "Change rx flow control parameter",
5958 (void *)&cmd_lfc_set_set,
5959 (void *)&cmd_lfc_set_flow_ctrl,
5960 (void *)&cmd_lfc_set_rx,
5961 (void *)&cmd_lfc_set_rx_mode,
5962 (void *)&cmd_lfc_set_portid,
5967 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
5968 .f = cmd_link_flow_ctrl_set_parsed,
5969 .data = (void *)&cmd_link_flow_control_set_tx,
5970 .help_str = "set flow_ctrl tx on|off <port_id>: "
5971 "Change tx flow control parameter",
5973 (void *)&cmd_lfc_set_set,
5974 (void *)&cmd_lfc_set_flow_ctrl,
5975 (void *)&cmd_lfc_set_tx,
5976 (void *)&cmd_lfc_set_tx_mode,
5977 (void *)&cmd_lfc_set_portid,
5982 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
5983 .f = cmd_link_flow_ctrl_set_parsed,
5984 .data = (void *)&cmd_link_flow_control_set_hw,
5985 .help_str = "set flow_ctrl high_water <value> <port_id>: "
5986 "Change high water flow control parameter",
5988 (void *)&cmd_lfc_set_set,
5989 (void *)&cmd_lfc_set_flow_ctrl,
5990 (void *)&cmd_lfc_set_high_water_str,
5991 (void *)&cmd_lfc_set_high_water,
5992 (void *)&cmd_lfc_set_portid,
5997 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
5998 .f = cmd_link_flow_ctrl_set_parsed,
5999 .data = (void *)&cmd_link_flow_control_set_lw,
6000 .help_str = "set flow_ctrl low_water <value> <port_id>: "
6001 "Change low water flow control parameter",
6003 (void *)&cmd_lfc_set_set,
6004 (void *)&cmd_lfc_set_flow_ctrl,
6005 (void *)&cmd_lfc_set_low_water_str,
6006 (void *)&cmd_lfc_set_low_water,
6007 (void *)&cmd_lfc_set_portid,
6012 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
6013 .f = cmd_link_flow_ctrl_set_parsed,
6014 .data = (void *)&cmd_link_flow_control_set_pt,
6015 .help_str = "set flow_ctrl pause_time <value> <port_id>: "
6016 "Change pause time flow control parameter",
6018 (void *)&cmd_lfc_set_set,
6019 (void *)&cmd_lfc_set_flow_ctrl,
6020 (void *)&cmd_lfc_set_pause_time_str,
6021 (void *)&cmd_lfc_set_pause_time,
6022 (void *)&cmd_lfc_set_portid,
6027 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
6028 .f = cmd_link_flow_ctrl_set_parsed,
6029 .data = (void *)&cmd_link_flow_control_set_xon,
6030 .help_str = "set flow_ctrl send_xon <value> <port_id>: "
6031 "Change send_xon flow control parameter",
6033 (void *)&cmd_lfc_set_set,
6034 (void *)&cmd_lfc_set_flow_ctrl,
6035 (void *)&cmd_lfc_set_send_xon_str,
6036 (void *)&cmd_lfc_set_send_xon,
6037 (void *)&cmd_lfc_set_portid,
6042 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
6043 .f = cmd_link_flow_ctrl_set_parsed,
6044 .data = (void *)&cmd_link_flow_control_set_macfwd,
6045 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
6046 "Change mac ctrl fwd flow control parameter",
6048 (void *)&cmd_lfc_set_set,
6049 (void *)&cmd_lfc_set_flow_ctrl,
6050 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6051 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6052 (void *)&cmd_lfc_set_portid,
6057 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
6058 .f = cmd_link_flow_ctrl_set_parsed,
6059 .data = (void *)&cmd_link_flow_control_set_autoneg,
6060 .help_str = "set flow_ctrl autoneg on|off <port_id>: "
6061 "Change autoneg flow control parameter",
6063 (void *)&cmd_lfc_set_set,
6064 (void *)&cmd_lfc_set_flow_ctrl,
6065 (void *)&cmd_lfc_set_autoneg_str,
6066 (void *)&cmd_lfc_set_autoneg,
6067 (void *)&cmd_lfc_set_portid,
6073 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
6074 __attribute__((unused)) struct cmdline *cl,
6077 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
6078 cmdline_parse_inst_t *cmd = data;
6079 struct rte_eth_fc_conf fc_conf;
6085 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
6086 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
6087 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
6088 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
6090 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
6091 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
6094 /* Partial command line, retrieve current configuration */
6096 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
6098 printf("cannot get current flow ctrl parameters, return"
6099 "code = %d\n", ret);
6103 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
6104 (fc_conf.mode == RTE_FC_FULL))
6106 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
6107 (fc_conf.mode == RTE_FC_FULL))
6111 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
6112 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
6114 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
6115 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
6117 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
6119 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
6120 fc_conf.high_water = res->high_water;
6122 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
6123 fc_conf.low_water = res->low_water;
6125 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
6126 fc_conf.pause_time = res->pause_time;
6128 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
6129 fc_conf.send_xon = res->send_xon;
6131 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
6132 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
6133 fc_conf.mac_ctrl_frame_fwd = 1;
6135 fc_conf.mac_ctrl_frame_fwd = 0;
6138 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
6139 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
6141 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
6143 printf("bad flow contrl parameter, return code = %d \n", ret);
6146 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
6147 struct cmd_priority_flow_ctrl_set_result {
6148 cmdline_fixed_string_t set;
6149 cmdline_fixed_string_t pfc_ctrl;
6150 cmdline_fixed_string_t rx;
6151 cmdline_fixed_string_t rx_pfc_mode;
6152 cmdline_fixed_string_t tx;
6153 cmdline_fixed_string_t tx_pfc_mode;
6154 uint32_t high_water;
6156 uint16_t pause_time;
6162 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
6163 __attribute__((unused)) struct cmdline *cl,
6164 __attribute__((unused)) void *data)
6166 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
6167 struct rte_eth_pfc_conf pfc_conf;
6168 int rx_fc_enable, tx_fc_enable;
6172 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
6173 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
6174 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
6175 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
6177 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
6178 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
6181 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
6182 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
6183 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
6184 pfc_conf.fc.high_water = res->high_water;
6185 pfc_conf.fc.low_water = res->low_water;
6186 pfc_conf.fc.pause_time = res->pause_time;
6187 pfc_conf.priority = res->priority;
6189 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
6191 printf("bad priority flow contrl parameter, return code = %d \n", ret);
6194 cmdline_parse_token_string_t cmd_pfc_set_set =
6195 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6197 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
6198 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6199 pfc_ctrl, "pfc_ctrl");
6200 cmdline_parse_token_string_t cmd_pfc_set_rx =
6201 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6203 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
6204 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6205 rx_pfc_mode, "on#off");
6206 cmdline_parse_token_string_t cmd_pfc_set_tx =
6207 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6209 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
6210 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6211 tx_pfc_mode, "on#off");
6212 cmdline_parse_token_num_t cmd_pfc_set_high_water =
6213 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6214 high_water, UINT32);
6215 cmdline_parse_token_num_t cmd_pfc_set_low_water =
6216 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6218 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
6219 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6220 pause_time, UINT16);
6221 cmdline_parse_token_num_t cmd_pfc_set_priority =
6222 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6224 cmdline_parse_token_num_t cmd_pfc_set_portid =
6225 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6228 cmdline_parse_inst_t cmd_priority_flow_control_set = {
6229 .f = cmd_priority_flow_ctrl_set_parsed,
6231 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
6232 "<pause_time> <priority> <port_id>: "
6233 "Configure the Ethernet priority flow control",
6235 (void *)&cmd_pfc_set_set,
6236 (void *)&cmd_pfc_set_flow_ctrl,
6237 (void *)&cmd_pfc_set_rx,
6238 (void *)&cmd_pfc_set_rx_mode,
6239 (void *)&cmd_pfc_set_tx,
6240 (void *)&cmd_pfc_set_tx_mode,
6241 (void *)&cmd_pfc_set_high_water,
6242 (void *)&cmd_pfc_set_low_water,
6243 (void *)&cmd_pfc_set_pause_time,
6244 (void *)&cmd_pfc_set_priority,
6245 (void *)&cmd_pfc_set_portid,
6250 /* *** RESET CONFIGURATION *** */
6251 struct cmd_reset_result {
6252 cmdline_fixed_string_t reset;
6253 cmdline_fixed_string_t def;
6256 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
6258 __attribute__((unused)) void *data)
6260 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
6261 set_def_fwd_config();
6264 cmdline_parse_token_string_t cmd_reset_set =
6265 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
6266 cmdline_parse_token_string_t cmd_reset_def =
6267 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
6270 cmdline_parse_inst_t cmd_reset = {
6271 .f = cmd_reset_parsed,
6273 .help_str = "set default: Reset default forwarding configuration",
6275 (void *)&cmd_reset_set,
6276 (void *)&cmd_reset_def,
6281 /* *** START FORWARDING *** */
6282 struct cmd_start_result {
6283 cmdline_fixed_string_t start;
6286 cmdline_parse_token_string_t cmd_start_start =
6287 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
6289 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
6290 __attribute__((unused)) struct cmdline *cl,
6291 __attribute__((unused)) void *data)
6293 start_packet_forwarding(0);
6296 cmdline_parse_inst_t cmd_start = {
6297 .f = cmd_start_parsed,
6299 .help_str = "start: Start packet forwarding",
6301 (void *)&cmd_start_start,
6306 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
6307 struct cmd_start_tx_first_result {
6308 cmdline_fixed_string_t start;
6309 cmdline_fixed_string_t tx_first;
6313 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
6314 __attribute__((unused)) struct cmdline *cl,
6315 __attribute__((unused)) void *data)
6317 start_packet_forwarding(1);
6320 cmdline_parse_token_string_t cmd_start_tx_first_start =
6321 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
6323 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
6324 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
6325 tx_first, "tx_first");
6327 cmdline_parse_inst_t cmd_start_tx_first = {
6328 .f = cmd_start_tx_first_parsed,
6330 .help_str = "start tx_first: Start packet forwarding, "
6331 "after sending 1 burst of packets",
6333 (void *)&cmd_start_tx_first_start,
6334 (void *)&cmd_start_tx_first_tx_first,
6339 /* *** START FORWARDING WITH N TX BURST FIRST *** */
6340 struct cmd_start_tx_first_n_result {
6341 cmdline_fixed_string_t start;
6342 cmdline_fixed_string_t tx_first;
6347 cmd_start_tx_first_n_parsed(void *parsed_result,
6348 __attribute__((unused)) struct cmdline *cl,
6349 __attribute__((unused)) void *data)
6351 struct cmd_start_tx_first_n_result *res = parsed_result;
6353 start_packet_forwarding(res->tx_num);
6356 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
6357 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
6359 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
6360 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
6361 tx_first, "tx_first");
6362 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
6363 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
6366 cmdline_parse_inst_t cmd_start_tx_first_n = {
6367 .f = cmd_start_tx_first_n_parsed,
6369 .help_str = "start tx_first <num>: "
6370 "packet forwarding, after sending <num> bursts of packets",
6372 (void *)&cmd_start_tx_first_n_start,
6373 (void *)&cmd_start_tx_first_n_tx_first,
6374 (void *)&cmd_start_tx_first_n_tx_num,
6379 /* *** SET LINK UP *** */
6380 struct cmd_set_link_up_result {
6381 cmdline_fixed_string_t set;
6382 cmdline_fixed_string_t link_up;
6383 cmdline_fixed_string_t port;
6387 cmdline_parse_token_string_t cmd_set_link_up_set =
6388 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
6389 cmdline_parse_token_string_t cmd_set_link_up_link_up =
6390 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
6392 cmdline_parse_token_string_t cmd_set_link_up_port =
6393 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
6394 cmdline_parse_token_num_t cmd_set_link_up_port_id =
6395 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT16);
6397 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result,
6398 __attribute__((unused)) struct cmdline *cl,
6399 __attribute__((unused)) void *data)
6401 struct cmd_set_link_up_result *res = parsed_result;
6402 dev_set_link_up(res->port_id);
6405 cmdline_parse_inst_t cmd_set_link_up = {
6406 .f = cmd_set_link_up_parsed,
6408 .help_str = "set link-up port <port id>",
6410 (void *)&cmd_set_link_up_set,
6411 (void *)&cmd_set_link_up_link_up,
6412 (void *)&cmd_set_link_up_port,
6413 (void *)&cmd_set_link_up_port_id,
6418 /* *** SET LINK DOWN *** */
6419 struct cmd_set_link_down_result {
6420 cmdline_fixed_string_t set;
6421 cmdline_fixed_string_t link_down;
6422 cmdline_fixed_string_t port;
6426 cmdline_parse_token_string_t cmd_set_link_down_set =
6427 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
6428 cmdline_parse_token_string_t cmd_set_link_down_link_down =
6429 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
6431 cmdline_parse_token_string_t cmd_set_link_down_port =
6432 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
6433 cmdline_parse_token_num_t cmd_set_link_down_port_id =
6434 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT16);
6436 static void cmd_set_link_down_parsed(
6437 __attribute__((unused)) void *parsed_result,
6438 __attribute__((unused)) struct cmdline *cl,
6439 __attribute__((unused)) void *data)
6441 struct cmd_set_link_down_result *res = parsed_result;
6442 dev_set_link_down(res->port_id);
6445 cmdline_parse_inst_t cmd_set_link_down = {
6446 .f = cmd_set_link_down_parsed,
6448 .help_str = "set link-down port <port id>",
6450 (void *)&cmd_set_link_down_set,
6451 (void *)&cmd_set_link_down_link_down,
6452 (void *)&cmd_set_link_down_port,
6453 (void *)&cmd_set_link_down_port_id,
6458 /* *** SHOW CFG *** */
6459 struct cmd_showcfg_result {
6460 cmdline_fixed_string_t show;
6461 cmdline_fixed_string_t cfg;
6462 cmdline_fixed_string_t what;
6465 static void cmd_showcfg_parsed(void *parsed_result,
6466 __attribute__((unused)) struct cmdline *cl,
6467 __attribute__((unused)) void *data)
6469 struct cmd_showcfg_result *res = parsed_result;
6470 if (!strcmp(res->what, "rxtx"))
6471 rxtx_config_display();
6472 else if (!strcmp(res->what, "cores"))
6473 fwd_lcores_config_display();
6474 else if (!strcmp(res->what, "fwd"))
6475 pkt_fwd_config_display(&cur_fwd_config);
6476 else if (!strcmp(res->what, "txpkts"))
6477 show_tx_pkt_segments();
6480 cmdline_parse_token_string_t cmd_showcfg_show =
6481 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
6482 cmdline_parse_token_string_t cmd_showcfg_port =
6483 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
6484 cmdline_parse_token_string_t cmd_showcfg_what =
6485 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
6486 "rxtx#cores#fwd#txpkts");
6488 cmdline_parse_inst_t cmd_showcfg = {
6489 .f = cmd_showcfg_parsed,
6491 .help_str = "show config rxtx|cores|fwd|txpkts",
6493 (void *)&cmd_showcfg_show,
6494 (void *)&cmd_showcfg_port,
6495 (void *)&cmd_showcfg_what,
6500 /* *** SHOW ALL PORT INFO *** */
6501 struct cmd_showportall_result {
6502 cmdline_fixed_string_t show;
6503 cmdline_fixed_string_t port;
6504 cmdline_fixed_string_t what;
6505 cmdline_fixed_string_t all;
6508 static void cmd_showportall_parsed(void *parsed_result,
6509 __attribute__((unused)) struct cmdline *cl,
6510 __attribute__((unused)) void *data)
6514 struct cmd_showportall_result *res = parsed_result;
6515 if (!strcmp(res->show, "clear")) {
6516 if (!strcmp(res->what, "stats"))
6517 RTE_ETH_FOREACH_DEV(i)
6519 else if (!strcmp(res->what, "xstats"))
6520 RTE_ETH_FOREACH_DEV(i)
6521 nic_xstats_clear(i);
6522 } else if (!strcmp(res->what, "info"))
6523 RTE_ETH_FOREACH_DEV(i)
6524 port_infos_display(i);
6525 else if (!strcmp(res->what, "stats"))
6526 RTE_ETH_FOREACH_DEV(i)
6527 nic_stats_display(i);
6528 else if (!strcmp(res->what, "xstats"))
6529 RTE_ETH_FOREACH_DEV(i)
6530 nic_xstats_display(i);
6531 else if (!strcmp(res->what, "fdir"))
6532 RTE_ETH_FOREACH_DEV(i)
6534 else if (!strcmp(res->what, "stat_qmap"))
6535 RTE_ETH_FOREACH_DEV(i)
6536 nic_stats_mapping_display(i);
6537 else if (!strcmp(res->what, "dcb_tc"))
6538 RTE_ETH_FOREACH_DEV(i)
6539 port_dcb_info_display(i);
6540 else if (!strcmp(res->what, "cap"))
6541 RTE_ETH_FOREACH_DEV(i)
6542 port_offload_cap_display(i);
6545 cmdline_parse_token_string_t cmd_showportall_show =
6546 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
6548 cmdline_parse_token_string_t cmd_showportall_port =
6549 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
6550 cmdline_parse_token_string_t cmd_showportall_what =
6551 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
6552 "info#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
6553 cmdline_parse_token_string_t cmd_showportall_all =
6554 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
6555 cmdline_parse_inst_t cmd_showportall = {
6556 .f = cmd_showportall_parsed,
6558 .help_str = "show|clear port "
6559 "info|stats|xstats|fdir|stat_qmap|dcb_tc|cap all",
6561 (void *)&cmd_showportall_show,
6562 (void *)&cmd_showportall_port,
6563 (void *)&cmd_showportall_what,
6564 (void *)&cmd_showportall_all,
6569 /* *** SHOW PORT INFO *** */
6570 struct cmd_showport_result {
6571 cmdline_fixed_string_t show;
6572 cmdline_fixed_string_t port;
6573 cmdline_fixed_string_t what;
6577 static void cmd_showport_parsed(void *parsed_result,
6578 __attribute__((unused)) struct cmdline *cl,
6579 __attribute__((unused)) void *data)
6581 struct cmd_showport_result *res = parsed_result;
6582 if (!strcmp(res->show, "clear")) {
6583 if (!strcmp(res->what, "stats"))
6584 nic_stats_clear(res->portnum);
6585 else if (!strcmp(res->what, "xstats"))
6586 nic_xstats_clear(res->portnum);
6587 } else if (!strcmp(res->what, "info"))
6588 port_infos_display(res->portnum);
6589 else if (!strcmp(res->what, "stats"))
6590 nic_stats_display(res->portnum);
6591 else if (!strcmp(res->what, "xstats"))
6592 nic_xstats_display(res->portnum);
6593 else if (!strcmp(res->what, "fdir"))
6594 fdir_get_infos(res->portnum);
6595 else if (!strcmp(res->what, "stat_qmap"))
6596 nic_stats_mapping_display(res->portnum);
6597 else if (!strcmp(res->what, "dcb_tc"))
6598 port_dcb_info_display(res->portnum);
6599 else if (!strcmp(res->what, "cap"))
6600 port_offload_cap_display(res->portnum);
6603 cmdline_parse_token_string_t cmd_showport_show =
6604 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
6606 cmdline_parse_token_string_t cmd_showport_port =
6607 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
6608 cmdline_parse_token_string_t cmd_showport_what =
6609 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
6610 "info#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
6611 cmdline_parse_token_num_t cmd_showport_portnum =
6612 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT16);
6614 cmdline_parse_inst_t cmd_showport = {
6615 .f = cmd_showport_parsed,
6617 .help_str = "show|clear port "
6618 "info|stats|xstats|fdir|stat_qmap|dcb_tc|cap "
6621 (void *)&cmd_showport_show,
6622 (void *)&cmd_showport_port,
6623 (void *)&cmd_showport_what,
6624 (void *)&cmd_showport_portnum,
6629 /* *** SHOW QUEUE INFO *** */
6630 struct cmd_showqueue_result {
6631 cmdline_fixed_string_t show;
6632 cmdline_fixed_string_t type;
6633 cmdline_fixed_string_t what;
6639 cmd_showqueue_parsed(void *parsed_result,
6640 __attribute__((unused)) struct cmdline *cl,
6641 __attribute__((unused)) void *data)
6643 struct cmd_showqueue_result *res = parsed_result;
6645 if (!strcmp(res->type, "rxq"))
6646 rx_queue_infos_display(res->portnum, res->queuenum);
6647 else if (!strcmp(res->type, "txq"))
6648 tx_queue_infos_display(res->portnum, res->queuenum);
6651 cmdline_parse_token_string_t cmd_showqueue_show =
6652 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
6653 cmdline_parse_token_string_t cmd_showqueue_type =
6654 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
6655 cmdline_parse_token_string_t cmd_showqueue_what =
6656 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
6657 cmdline_parse_token_num_t cmd_showqueue_portnum =
6658 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, UINT16);
6659 cmdline_parse_token_num_t cmd_showqueue_queuenum =
6660 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, UINT16);
6662 cmdline_parse_inst_t cmd_showqueue = {
6663 .f = cmd_showqueue_parsed,
6665 .help_str = "show rxq|txq info <port_id> <queue_id>",
6667 (void *)&cmd_showqueue_show,
6668 (void *)&cmd_showqueue_type,
6669 (void *)&cmd_showqueue_what,
6670 (void *)&cmd_showqueue_portnum,
6671 (void *)&cmd_showqueue_queuenum,
6676 /* *** READ PORT REGISTER *** */
6677 struct cmd_read_reg_result {
6678 cmdline_fixed_string_t read;
6679 cmdline_fixed_string_t reg;
6685 cmd_read_reg_parsed(void *parsed_result,
6686 __attribute__((unused)) struct cmdline *cl,
6687 __attribute__((unused)) void *data)
6689 struct cmd_read_reg_result *res = parsed_result;
6690 port_reg_display(res->port_id, res->reg_off);
6693 cmdline_parse_token_string_t cmd_read_reg_read =
6694 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
6695 cmdline_parse_token_string_t cmd_read_reg_reg =
6696 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
6697 cmdline_parse_token_num_t cmd_read_reg_port_id =
6698 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT16);
6699 cmdline_parse_token_num_t cmd_read_reg_reg_off =
6700 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
6702 cmdline_parse_inst_t cmd_read_reg = {
6703 .f = cmd_read_reg_parsed,
6705 .help_str = "read reg <port_id> <reg_off>",
6707 (void *)&cmd_read_reg_read,
6708 (void *)&cmd_read_reg_reg,
6709 (void *)&cmd_read_reg_port_id,
6710 (void *)&cmd_read_reg_reg_off,
6715 /* *** READ PORT REGISTER BIT FIELD *** */
6716 struct cmd_read_reg_bit_field_result {
6717 cmdline_fixed_string_t read;
6718 cmdline_fixed_string_t regfield;
6726 cmd_read_reg_bit_field_parsed(void *parsed_result,
6727 __attribute__((unused)) struct cmdline *cl,
6728 __attribute__((unused)) void *data)
6730 struct cmd_read_reg_bit_field_result *res = parsed_result;
6731 port_reg_bit_field_display(res->port_id, res->reg_off,
6732 res->bit1_pos, res->bit2_pos);
6735 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
6736 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
6738 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
6739 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
6740 regfield, "regfield");
6741 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
6742 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
6744 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
6745 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
6747 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
6748 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
6750 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
6751 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
6754 cmdline_parse_inst_t cmd_read_reg_bit_field = {
6755 .f = cmd_read_reg_bit_field_parsed,
6757 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
6758 "Read register bit field between bit_x and bit_y included",
6760 (void *)&cmd_read_reg_bit_field_read,
6761 (void *)&cmd_read_reg_bit_field_regfield,
6762 (void *)&cmd_read_reg_bit_field_port_id,
6763 (void *)&cmd_read_reg_bit_field_reg_off,
6764 (void *)&cmd_read_reg_bit_field_bit1_pos,
6765 (void *)&cmd_read_reg_bit_field_bit2_pos,
6770 /* *** READ PORT REGISTER BIT *** */
6771 struct cmd_read_reg_bit_result {
6772 cmdline_fixed_string_t read;
6773 cmdline_fixed_string_t regbit;
6780 cmd_read_reg_bit_parsed(void *parsed_result,
6781 __attribute__((unused)) struct cmdline *cl,
6782 __attribute__((unused)) void *data)
6784 struct cmd_read_reg_bit_result *res = parsed_result;
6785 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
6788 cmdline_parse_token_string_t cmd_read_reg_bit_read =
6789 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
6790 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
6791 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
6793 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
6794 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT16);
6795 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
6796 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
6797 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
6798 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
6800 cmdline_parse_inst_t cmd_read_reg_bit = {
6801 .f = cmd_read_reg_bit_parsed,
6803 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
6805 (void *)&cmd_read_reg_bit_read,
6806 (void *)&cmd_read_reg_bit_regbit,
6807 (void *)&cmd_read_reg_bit_port_id,
6808 (void *)&cmd_read_reg_bit_reg_off,
6809 (void *)&cmd_read_reg_bit_bit_pos,
6814 /* *** WRITE PORT REGISTER *** */
6815 struct cmd_write_reg_result {
6816 cmdline_fixed_string_t write;
6817 cmdline_fixed_string_t reg;
6824 cmd_write_reg_parsed(void *parsed_result,
6825 __attribute__((unused)) struct cmdline *cl,
6826 __attribute__((unused)) void *data)
6828 struct cmd_write_reg_result *res = parsed_result;
6829 port_reg_set(res->port_id, res->reg_off, res->value);
6832 cmdline_parse_token_string_t cmd_write_reg_write =
6833 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
6834 cmdline_parse_token_string_t cmd_write_reg_reg =
6835 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
6836 cmdline_parse_token_num_t cmd_write_reg_port_id =
6837 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT16);
6838 cmdline_parse_token_num_t cmd_write_reg_reg_off =
6839 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
6840 cmdline_parse_token_num_t cmd_write_reg_value =
6841 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
6843 cmdline_parse_inst_t cmd_write_reg = {
6844 .f = cmd_write_reg_parsed,
6846 .help_str = "write reg <port_id> <reg_off> <reg_value>",
6848 (void *)&cmd_write_reg_write,
6849 (void *)&cmd_write_reg_reg,
6850 (void *)&cmd_write_reg_port_id,
6851 (void *)&cmd_write_reg_reg_off,
6852 (void *)&cmd_write_reg_value,
6857 /* *** WRITE PORT REGISTER BIT FIELD *** */
6858 struct cmd_write_reg_bit_field_result {
6859 cmdline_fixed_string_t write;
6860 cmdline_fixed_string_t regfield;
6869 cmd_write_reg_bit_field_parsed(void *parsed_result,
6870 __attribute__((unused)) struct cmdline *cl,
6871 __attribute__((unused)) void *data)
6873 struct cmd_write_reg_bit_field_result *res = parsed_result;
6874 port_reg_bit_field_set(res->port_id, res->reg_off,
6875 res->bit1_pos, res->bit2_pos, res->value);
6878 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
6879 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
6881 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
6882 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
6883 regfield, "regfield");
6884 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
6885 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
6887 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
6888 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
6890 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
6891 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
6893 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
6894 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
6896 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
6897 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
6900 cmdline_parse_inst_t cmd_write_reg_bit_field = {
6901 .f = cmd_write_reg_bit_field_parsed,
6903 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
6905 "Set register bit field between bit_x and bit_y included",
6907 (void *)&cmd_write_reg_bit_field_write,
6908 (void *)&cmd_write_reg_bit_field_regfield,
6909 (void *)&cmd_write_reg_bit_field_port_id,
6910 (void *)&cmd_write_reg_bit_field_reg_off,
6911 (void *)&cmd_write_reg_bit_field_bit1_pos,
6912 (void *)&cmd_write_reg_bit_field_bit2_pos,
6913 (void *)&cmd_write_reg_bit_field_value,
6918 /* *** WRITE PORT REGISTER BIT *** */
6919 struct cmd_write_reg_bit_result {
6920 cmdline_fixed_string_t write;
6921 cmdline_fixed_string_t regbit;
6929 cmd_write_reg_bit_parsed(void *parsed_result,
6930 __attribute__((unused)) struct cmdline *cl,
6931 __attribute__((unused)) void *data)
6933 struct cmd_write_reg_bit_result *res = parsed_result;
6934 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
6937 cmdline_parse_token_string_t cmd_write_reg_bit_write =
6938 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
6940 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
6941 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
6943 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
6944 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT16);
6945 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
6946 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
6947 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
6948 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
6949 cmdline_parse_token_num_t cmd_write_reg_bit_value =
6950 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
6952 cmdline_parse_inst_t cmd_write_reg_bit = {
6953 .f = cmd_write_reg_bit_parsed,
6955 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
6958 (void *)&cmd_write_reg_bit_write,
6959 (void *)&cmd_write_reg_bit_regbit,
6960 (void *)&cmd_write_reg_bit_port_id,
6961 (void *)&cmd_write_reg_bit_reg_off,
6962 (void *)&cmd_write_reg_bit_bit_pos,
6963 (void *)&cmd_write_reg_bit_value,
6968 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
6969 struct cmd_read_rxd_txd_result {
6970 cmdline_fixed_string_t read;
6971 cmdline_fixed_string_t rxd_txd;
6978 cmd_read_rxd_txd_parsed(void *parsed_result,
6979 __attribute__((unused)) struct cmdline *cl,
6980 __attribute__((unused)) void *data)
6982 struct cmd_read_rxd_txd_result *res = parsed_result;
6984 if (!strcmp(res->rxd_txd, "rxd"))
6985 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
6986 else if (!strcmp(res->rxd_txd, "txd"))
6987 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
6990 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
6991 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
6992 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
6993 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
6995 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
6996 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT16);
6997 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
6998 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
6999 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
7000 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
7002 cmdline_parse_inst_t cmd_read_rxd_txd = {
7003 .f = cmd_read_rxd_txd_parsed,
7005 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
7007 (void *)&cmd_read_rxd_txd_read,
7008 (void *)&cmd_read_rxd_txd_rxd_txd,
7009 (void *)&cmd_read_rxd_txd_port_id,
7010 (void *)&cmd_read_rxd_txd_queue_id,
7011 (void *)&cmd_read_rxd_txd_desc_id,
7017 struct cmd_quit_result {
7018 cmdline_fixed_string_t quit;
7021 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
7023 __attribute__((unused)) void *data)
7029 cmdline_parse_token_string_t cmd_quit_quit =
7030 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
7032 cmdline_parse_inst_t cmd_quit = {
7033 .f = cmd_quit_parsed,
7035 .help_str = "quit: Exit application",
7037 (void *)&cmd_quit_quit,
7042 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
7043 struct cmd_mac_addr_result {
7044 cmdline_fixed_string_t mac_addr_cmd;
7045 cmdline_fixed_string_t what;
7047 struct ether_addr address;
7050 static void cmd_mac_addr_parsed(void *parsed_result,
7051 __attribute__((unused)) struct cmdline *cl,
7052 __attribute__((unused)) void *data)
7054 struct cmd_mac_addr_result *res = parsed_result;
7057 if (strcmp(res->what, "add") == 0)
7058 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
7059 else if (strcmp(res->what, "set") == 0)
7060 ret = rte_eth_dev_default_mac_addr_set(res->port_num,
7063 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
7065 /* check the return value and print it if is < 0 */
7067 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
7071 cmdline_parse_token_string_t cmd_mac_addr_cmd =
7072 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
7074 cmdline_parse_token_string_t cmd_mac_addr_what =
7075 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
7077 cmdline_parse_token_num_t cmd_mac_addr_portnum =
7078 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num,
7080 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
7081 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
7083 cmdline_parse_inst_t cmd_mac_addr = {
7084 .f = cmd_mac_addr_parsed,
7086 .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
7087 "Add/Remove/Set MAC address on port_id",
7089 (void *)&cmd_mac_addr_cmd,
7090 (void *)&cmd_mac_addr_what,
7091 (void *)&cmd_mac_addr_portnum,
7092 (void *)&cmd_mac_addr_addr,
7098 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
7099 struct cmd_set_qmap_result {
7100 cmdline_fixed_string_t set;
7101 cmdline_fixed_string_t qmap;
7102 cmdline_fixed_string_t what;
7109 cmd_set_qmap_parsed(void *parsed_result,
7110 __attribute__((unused)) struct cmdline *cl,
7111 __attribute__((unused)) void *data)
7113 struct cmd_set_qmap_result *res = parsed_result;
7114 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
7116 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
7119 cmdline_parse_token_string_t cmd_setqmap_set =
7120 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7122 cmdline_parse_token_string_t cmd_setqmap_qmap =
7123 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7125 cmdline_parse_token_string_t cmd_setqmap_what =
7126 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7128 cmdline_parse_token_num_t cmd_setqmap_portid =
7129 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7131 cmdline_parse_token_num_t cmd_setqmap_queueid =
7132 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7134 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
7135 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7138 cmdline_parse_inst_t cmd_set_qmap = {
7139 .f = cmd_set_qmap_parsed,
7141 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
7142 "Set statistics mapping value on tx|rx queue_id of port_id",
7144 (void *)&cmd_setqmap_set,
7145 (void *)&cmd_setqmap_qmap,
7146 (void *)&cmd_setqmap_what,
7147 (void *)&cmd_setqmap_portid,
7148 (void *)&cmd_setqmap_queueid,
7149 (void *)&cmd_setqmap_mapvalue,
7154 /* *** CONFIGURE UNICAST HASH TABLE *** */
7155 struct cmd_set_uc_hash_table {
7156 cmdline_fixed_string_t set;
7157 cmdline_fixed_string_t port;
7159 cmdline_fixed_string_t what;
7160 struct ether_addr address;
7161 cmdline_fixed_string_t mode;
7165 cmd_set_uc_hash_parsed(void *parsed_result,
7166 __attribute__((unused)) struct cmdline *cl,
7167 __attribute__((unused)) void *data)
7170 struct cmd_set_uc_hash_table *res = parsed_result;
7172 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7174 if (strcmp(res->what, "uta") == 0)
7175 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
7176 &res->address,(uint8_t)is_on);
7178 printf("bad unicast hash table parameter, return code = %d \n", ret);
7182 cmdline_parse_token_string_t cmd_set_uc_hash_set =
7183 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7185 cmdline_parse_token_string_t cmd_set_uc_hash_port =
7186 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7188 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
7189 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
7191 cmdline_parse_token_string_t cmd_set_uc_hash_what =
7192 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7194 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
7195 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
7197 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
7198 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7201 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
7202 .f = cmd_set_uc_hash_parsed,
7204 .help_str = "set port <port_id> uta <mac_addr> on|off)",
7206 (void *)&cmd_set_uc_hash_set,
7207 (void *)&cmd_set_uc_hash_port,
7208 (void *)&cmd_set_uc_hash_portid,
7209 (void *)&cmd_set_uc_hash_what,
7210 (void *)&cmd_set_uc_hash_mac,
7211 (void *)&cmd_set_uc_hash_mode,
7216 struct cmd_set_uc_all_hash_table {
7217 cmdline_fixed_string_t set;
7218 cmdline_fixed_string_t port;
7220 cmdline_fixed_string_t what;
7221 cmdline_fixed_string_t value;
7222 cmdline_fixed_string_t mode;
7226 cmd_set_uc_all_hash_parsed(void *parsed_result,
7227 __attribute__((unused)) struct cmdline *cl,
7228 __attribute__((unused)) void *data)
7231 struct cmd_set_uc_all_hash_table *res = parsed_result;
7233 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7235 if ((strcmp(res->what, "uta") == 0) &&
7236 (strcmp(res->value, "all") == 0))
7237 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
7239 printf("bad unicast hash table parameter,"
7240 "return code = %d \n", ret);
7243 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
7244 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7246 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
7247 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7249 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
7250 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
7252 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
7253 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7255 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
7256 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7258 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
7259 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7262 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
7263 .f = cmd_set_uc_all_hash_parsed,
7265 .help_str = "set port <port_id> uta all on|off",
7267 (void *)&cmd_set_uc_all_hash_set,
7268 (void *)&cmd_set_uc_all_hash_port,
7269 (void *)&cmd_set_uc_all_hash_portid,
7270 (void *)&cmd_set_uc_all_hash_what,
7271 (void *)&cmd_set_uc_all_hash_value,
7272 (void *)&cmd_set_uc_all_hash_mode,
7277 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
7278 struct cmd_set_vf_macvlan_filter {
7279 cmdline_fixed_string_t set;
7280 cmdline_fixed_string_t port;
7282 cmdline_fixed_string_t vf;
7284 struct ether_addr address;
7285 cmdline_fixed_string_t filter_type;
7286 cmdline_fixed_string_t mode;
7290 cmd_set_vf_macvlan_parsed(void *parsed_result,
7291 __attribute__((unused)) struct cmdline *cl,
7292 __attribute__((unused)) void *data)
7295 struct cmd_set_vf_macvlan_filter *res = parsed_result;
7296 struct rte_eth_mac_filter filter;
7298 memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
7300 rte_memcpy(&filter.mac_addr, &res->address, ETHER_ADDR_LEN);
7302 /* set VF MAC filter */
7306 filter.dst_id = res->vf_id;
7308 if (!strcmp(res->filter_type, "exact-mac"))
7309 filter.filter_type = RTE_MAC_PERFECT_MATCH;
7310 else if (!strcmp(res->filter_type, "exact-mac-vlan"))
7311 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
7312 else if (!strcmp(res->filter_type, "hashmac"))
7313 filter.filter_type = RTE_MAC_HASH_MATCH;
7314 else if (!strcmp(res->filter_type, "hashmac-vlan"))
7315 filter.filter_type = RTE_MACVLAN_HASH_MATCH;
7317 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7320 ret = rte_eth_dev_filter_ctrl(res->port_id,
7321 RTE_ETH_FILTER_MACVLAN,
7325 ret = rte_eth_dev_filter_ctrl(res->port_id,
7326 RTE_ETH_FILTER_MACVLAN,
7327 RTE_ETH_FILTER_DELETE,
7331 printf("bad set MAC hash parameter, return code = %d\n", ret);
7335 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
7336 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7338 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
7339 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7341 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
7342 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7344 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
7345 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7347 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
7348 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7350 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
7351 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7353 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
7354 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7355 filter_type, "exact-mac#exact-mac-vlan"
7356 "#hashmac#hashmac-vlan");
7357 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
7358 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7361 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
7362 .f = cmd_set_vf_macvlan_parsed,
7364 .help_str = "set port <port_id> vf <vf_id> <mac_addr> "
7365 "exact-mac|exact-mac-vlan|hashmac|hashmac-vlan on|off: "
7366 "Exact match rule: exact match of MAC or MAC and VLAN; "
7367 "hash match rule: hash match of MAC and exact match of VLAN",
7369 (void *)&cmd_set_vf_macvlan_set,
7370 (void *)&cmd_set_vf_macvlan_port,
7371 (void *)&cmd_set_vf_macvlan_portid,
7372 (void *)&cmd_set_vf_macvlan_vf,
7373 (void *)&cmd_set_vf_macvlan_vf_id,
7374 (void *)&cmd_set_vf_macvlan_mac,
7375 (void *)&cmd_set_vf_macvlan_filter_type,
7376 (void *)&cmd_set_vf_macvlan_mode,
7381 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
7382 struct cmd_set_vf_traffic {
7383 cmdline_fixed_string_t set;
7384 cmdline_fixed_string_t port;
7386 cmdline_fixed_string_t vf;
7388 cmdline_fixed_string_t what;
7389 cmdline_fixed_string_t mode;
7393 cmd_set_vf_traffic_parsed(void *parsed_result,
7394 __attribute__((unused)) struct cmdline *cl,
7395 __attribute__((unused)) void *data)
7397 struct cmd_set_vf_traffic *res = parsed_result;
7398 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
7399 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7401 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
7404 cmdline_parse_token_string_t cmd_setvf_traffic_set =
7405 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7407 cmdline_parse_token_string_t cmd_setvf_traffic_port =
7408 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7410 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
7411 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
7413 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
7414 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7416 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
7417 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
7419 cmdline_parse_token_string_t cmd_setvf_traffic_what =
7420 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7422 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
7423 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7426 cmdline_parse_inst_t cmd_set_vf_traffic = {
7427 .f = cmd_set_vf_traffic_parsed,
7429 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
7431 (void *)&cmd_setvf_traffic_set,
7432 (void *)&cmd_setvf_traffic_port,
7433 (void *)&cmd_setvf_traffic_portid,
7434 (void *)&cmd_setvf_traffic_vf,
7435 (void *)&cmd_setvf_traffic_vfid,
7436 (void *)&cmd_setvf_traffic_what,
7437 (void *)&cmd_setvf_traffic_mode,
7442 /* *** CONFIGURE VF RECEIVE MODE *** */
7443 struct cmd_set_vf_rxmode {
7444 cmdline_fixed_string_t set;
7445 cmdline_fixed_string_t port;
7447 cmdline_fixed_string_t vf;
7449 cmdline_fixed_string_t what;
7450 cmdline_fixed_string_t mode;
7451 cmdline_fixed_string_t on;
7455 cmd_set_vf_rxmode_parsed(void *parsed_result,
7456 __attribute__((unused)) struct cmdline *cl,
7457 __attribute__((unused)) void *data)
7460 uint16_t rx_mode = 0;
7461 struct cmd_set_vf_rxmode *res = parsed_result;
7463 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
7464 if (!strcmp(res->what,"rxmode")) {
7465 if (!strcmp(res->mode, "AUPE"))
7466 rx_mode |= ETH_VMDQ_ACCEPT_UNTAG;
7467 else if (!strcmp(res->mode, "ROPE"))
7468 rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC;
7469 else if (!strcmp(res->mode, "BAM"))
7470 rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST;
7471 else if (!strncmp(res->mode, "MPE",3))
7472 rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST;
7475 #ifdef RTE_LIBRTE_IXGBE_PMD
7476 if (ret == -ENOTSUP)
7477 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id,
7478 rx_mode, (uint8_t)is_on);
7480 #ifdef RTE_LIBRTE_BNXT_PMD
7481 if (ret == -ENOTSUP)
7482 ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id,
7483 rx_mode, (uint8_t)is_on);
7486 printf("bad VF receive mode parameter, return code = %d \n",
7490 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
7491 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7493 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
7494 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7496 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
7497 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
7499 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
7500 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7502 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
7503 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
7505 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
7506 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7508 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
7509 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7510 mode, "AUPE#ROPE#BAM#MPE");
7511 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
7512 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7515 cmdline_parse_inst_t cmd_set_vf_rxmode = {
7516 .f = cmd_set_vf_rxmode_parsed,
7518 .help_str = "set port <port_id> vf <vf_id> rxmode "
7519 "AUPE|ROPE|BAM|MPE on|off",
7521 (void *)&cmd_set_vf_rxmode_set,
7522 (void *)&cmd_set_vf_rxmode_port,
7523 (void *)&cmd_set_vf_rxmode_portid,
7524 (void *)&cmd_set_vf_rxmode_vf,
7525 (void *)&cmd_set_vf_rxmode_vfid,
7526 (void *)&cmd_set_vf_rxmode_what,
7527 (void *)&cmd_set_vf_rxmode_mode,
7528 (void *)&cmd_set_vf_rxmode_on,
7533 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
7534 struct cmd_vf_mac_addr_result {
7535 cmdline_fixed_string_t mac_addr_cmd;
7536 cmdline_fixed_string_t what;
7537 cmdline_fixed_string_t port;
7539 cmdline_fixed_string_t vf;
7541 struct ether_addr address;
7544 static void cmd_vf_mac_addr_parsed(void *parsed_result,
7545 __attribute__((unused)) struct cmdline *cl,
7546 __attribute__((unused)) void *data)
7548 struct cmd_vf_mac_addr_result *res = parsed_result;
7551 if (strcmp(res->what, "add") != 0)
7554 #ifdef RTE_LIBRTE_I40E_PMD
7555 if (ret == -ENOTSUP)
7556 ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num,
7559 #ifdef RTE_LIBRTE_BNXT_PMD
7560 if (ret == -ENOTSUP)
7561 ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address,
7566 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
7570 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
7571 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7572 mac_addr_cmd,"mac_addr");
7573 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
7574 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7576 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
7577 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7579 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
7580 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
7582 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
7583 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7585 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
7586 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
7588 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
7589 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
7592 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
7593 .f = cmd_vf_mac_addr_parsed,
7595 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
7596 "Add MAC address filtering for a VF on port_id",
7598 (void *)&cmd_vf_mac_addr_cmd,
7599 (void *)&cmd_vf_mac_addr_what,
7600 (void *)&cmd_vf_mac_addr_port,
7601 (void *)&cmd_vf_mac_addr_portnum,
7602 (void *)&cmd_vf_mac_addr_vf,
7603 (void *)&cmd_vf_mac_addr_vfnum,
7604 (void *)&cmd_vf_mac_addr_addr,
7609 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
7610 struct cmd_vf_rx_vlan_filter {
7611 cmdline_fixed_string_t rx_vlan;
7612 cmdline_fixed_string_t what;
7614 cmdline_fixed_string_t port;
7616 cmdline_fixed_string_t vf;
7621 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
7622 __attribute__((unused)) struct cmdline *cl,
7623 __attribute__((unused)) void *data)
7625 struct cmd_vf_rx_vlan_filter *res = parsed_result;
7628 __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
7630 #ifdef RTE_LIBRTE_IXGBE_PMD
7631 if (ret == -ENOTSUP)
7632 ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
7633 res->vlan_id, res->vf_mask, is_add);
7635 #ifdef RTE_LIBRTE_I40E_PMD
7636 if (ret == -ENOTSUP)
7637 ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
7638 res->vlan_id, res->vf_mask, is_add);
7640 #ifdef RTE_LIBRTE_BNXT_PMD
7641 if (ret == -ENOTSUP)
7642 ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id,
7643 res->vlan_id, res->vf_mask, is_add);
7650 printf("invalid vlan_id %d or vf_mask %"PRIu64"\n",
7651 res->vlan_id, res->vf_mask);
7654 printf("invalid port_id %d\n", res->port_id);
7657 printf("function not implemented or supported\n");
7660 printf("programming error: (%s)\n", strerror(-ret));
7664 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
7665 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7666 rx_vlan, "rx_vlan");
7667 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
7668 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7670 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
7671 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7673 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
7674 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7676 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
7677 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7679 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
7680 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7682 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
7683 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7686 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
7687 .f = cmd_vf_rx_vlan_filter_parsed,
7689 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
7690 "(vf_mask = hexadecimal VF mask)",
7692 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
7693 (void *)&cmd_vf_rx_vlan_filter_what,
7694 (void *)&cmd_vf_rx_vlan_filter_vlanid,
7695 (void *)&cmd_vf_rx_vlan_filter_port,
7696 (void *)&cmd_vf_rx_vlan_filter_portid,
7697 (void *)&cmd_vf_rx_vlan_filter_vf,
7698 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
7703 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
7704 struct cmd_queue_rate_limit_result {
7705 cmdline_fixed_string_t set;
7706 cmdline_fixed_string_t port;
7708 cmdline_fixed_string_t queue;
7710 cmdline_fixed_string_t rate;
7714 static void cmd_queue_rate_limit_parsed(void *parsed_result,
7715 __attribute__((unused)) struct cmdline *cl,
7716 __attribute__((unused)) void *data)
7718 struct cmd_queue_rate_limit_result *res = parsed_result;
7721 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
7722 && (strcmp(res->queue, "queue") == 0)
7723 && (strcmp(res->rate, "rate") == 0))
7724 ret = set_queue_rate_limit(res->port_num, res->queue_num,
7727 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
7731 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
7732 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7734 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
7735 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7737 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
7738 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
7740 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
7741 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7743 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
7744 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
7746 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
7747 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7749 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
7750 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
7753 cmdline_parse_inst_t cmd_queue_rate_limit = {
7754 .f = cmd_queue_rate_limit_parsed,
7756 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
7757 "Set rate limit for a queue on port_id",
7759 (void *)&cmd_queue_rate_limit_set,
7760 (void *)&cmd_queue_rate_limit_port,
7761 (void *)&cmd_queue_rate_limit_portnum,
7762 (void *)&cmd_queue_rate_limit_queue,
7763 (void *)&cmd_queue_rate_limit_queuenum,
7764 (void *)&cmd_queue_rate_limit_rate,
7765 (void *)&cmd_queue_rate_limit_ratenum,
7770 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
7771 struct cmd_vf_rate_limit_result {
7772 cmdline_fixed_string_t set;
7773 cmdline_fixed_string_t port;
7775 cmdline_fixed_string_t vf;
7777 cmdline_fixed_string_t rate;
7779 cmdline_fixed_string_t q_msk;
7783 static void cmd_vf_rate_limit_parsed(void *parsed_result,
7784 __attribute__((unused)) struct cmdline *cl,
7785 __attribute__((unused)) void *data)
7787 struct cmd_vf_rate_limit_result *res = parsed_result;
7790 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
7791 && (strcmp(res->vf, "vf") == 0)
7792 && (strcmp(res->rate, "rate") == 0)
7793 && (strcmp(res->q_msk, "queue_mask") == 0))
7794 ret = set_vf_rate_limit(res->port_num, res->vf_num,
7795 res->rate_num, res->q_msk_val);
7797 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
7801 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
7802 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7804 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
7805 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7807 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
7808 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7810 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
7811 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7813 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
7814 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7816 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
7817 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7819 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
7820 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7822 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
7823 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7824 q_msk, "queue_mask");
7825 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
7826 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7829 cmdline_parse_inst_t cmd_vf_rate_limit = {
7830 .f = cmd_vf_rate_limit_parsed,
7832 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
7833 "queue_mask <queue_mask_value>: "
7834 "Set rate limit for queues of VF on port_id",
7836 (void *)&cmd_vf_rate_limit_set,
7837 (void *)&cmd_vf_rate_limit_port,
7838 (void *)&cmd_vf_rate_limit_portnum,
7839 (void *)&cmd_vf_rate_limit_vf,
7840 (void *)&cmd_vf_rate_limit_vfnum,
7841 (void *)&cmd_vf_rate_limit_rate,
7842 (void *)&cmd_vf_rate_limit_ratenum,
7843 (void *)&cmd_vf_rate_limit_q_msk,
7844 (void *)&cmd_vf_rate_limit_q_msk_val,
7849 /* *** ADD TUNNEL FILTER OF A PORT *** */
7850 struct cmd_tunnel_filter_result {
7851 cmdline_fixed_string_t cmd;
7852 cmdline_fixed_string_t what;
7854 struct ether_addr outer_mac;
7855 struct ether_addr inner_mac;
7856 cmdline_ipaddr_t ip_value;
7857 uint16_t inner_vlan;
7858 cmdline_fixed_string_t tunnel_type;
7859 cmdline_fixed_string_t filter_type;
7865 cmd_tunnel_filter_parsed(void *parsed_result,
7866 __attribute__((unused)) struct cmdline *cl,
7867 __attribute__((unused)) void *data)
7869 struct cmd_tunnel_filter_result *res = parsed_result;
7870 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
7873 memset(&tunnel_filter_conf, 0, sizeof(tunnel_filter_conf));
7875 ether_addr_copy(&res->outer_mac, &tunnel_filter_conf.outer_mac);
7876 ether_addr_copy(&res->inner_mac, &tunnel_filter_conf.inner_mac);
7877 tunnel_filter_conf.inner_vlan = res->inner_vlan;
7879 if (res->ip_value.family == AF_INET) {
7880 tunnel_filter_conf.ip_addr.ipv4_addr =
7881 res->ip_value.addr.ipv4.s_addr;
7882 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
7884 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
7885 &(res->ip_value.addr.ipv6),
7886 sizeof(struct in6_addr));
7887 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
7890 if (!strcmp(res->filter_type, "imac-ivlan"))
7891 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
7892 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
7893 tunnel_filter_conf.filter_type =
7894 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
7895 else if (!strcmp(res->filter_type, "imac-tenid"))
7896 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
7897 else if (!strcmp(res->filter_type, "imac"))
7898 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
7899 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
7900 tunnel_filter_conf.filter_type =
7901 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
7902 else if (!strcmp(res->filter_type, "oip"))
7903 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_OIP;
7904 else if (!strcmp(res->filter_type, "iip"))
7905 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IIP;
7907 printf("The filter type is not supported");
7911 if (!strcmp(res->tunnel_type, "vxlan"))
7912 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
7913 else if (!strcmp(res->tunnel_type, "nvgre"))
7914 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE;
7915 else if (!strcmp(res->tunnel_type, "ipingre"))
7916 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_IP_IN_GRE;
7918 printf("The tunnel type %s not supported.\n", res->tunnel_type);
7922 tunnel_filter_conf.tenant_id = res->tenant_id;
7923 tunnel_filter_conf.queue_id = res->queue_num;
7924 if (!strcmp(res->what, "add"))
7925 ret = rte_eth_dev_filter_ctrl(res->port_id,
7926 RTE_ETH_FILTER_TUNNEL,
7928 &tunnel_filter_conf);
7930 ret = rte_eth_dev_filter_ctrl(res->port_id,
7931 RTE_ETH_FILTER_TUNNEL,
7932 RTE_ETH_FILTER_DELETE,
7933 &tunnel_filter_conf);
7935 printf("cmd_tunnel_filter_parsed error: (%s)\n",
7939 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
7940 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7941 cmd, "tunnel_filter");
7942 cmdline_parse_token_string_t cmd_tunnel_filter_what =
7943 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7945 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
7946 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7948 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
7949 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
7951 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
7952 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
7954 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
7955 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7956 inner_vlan, UINT16);
7957 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
7958 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
7960 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
7961 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7962 tunnel_type, "vxlan#nvgre#ipingre");
7964 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
7965 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7966 filter_type, "oip#iip#imac-ivlan#imac-ivlan-tenid#imac-tenid#"
7967 "imac#omac-imac-tenid");
7968 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
7969 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7971 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
7972 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7975 cmdline_parse_inst_t cmd_tunnel_filter = {
7976 .f = cmd_tunnel_filter_parsed,
7978 .help_str = "tunnel_filter add|rm <port_id> <outer_mac> <inner_mac> "
7979 "<ip> <inner_vlan> vxlan|nvgre|ipingre oip|iip|imac-ivlan|"
7980 "imac-ivlan-tenid|imac-tenid|imac|omac-imac-tenid <tenant_id> "
7981 "<queue_id>: Add/Rm tunnel filter of a port",
7983 (void *)&cmd_tunnel_filter_cmd,
7984 (void *)&cmd_tunnel_filter_what,
7985 (void *)&cmd_tunnel_filter_port_id,
7986 (void *)&cmd_tunnel_filter_outer_mac,
7987 (void *)&cmd_tunnel_filter_inner_mac,
7988 (void *)&cmd_tunnel_filter_ip_value,
7989 (void *)&cmd_tunnel_filter_innner_vlan,
7990 (void *)&cmd_tunnel_filter_tunnel_type,
7991 (void *)&cmd_tunnel_filter_filter_type,
7992 (void *)&cmd_tunnel_filter_tenant_id,
7993 (void *)&cmd_tunnel_filter_queue_num,
7998 /* *** CONFIGURE TUNNEL UDP PORT *** */
7999 struct cmd_tunnel_udp_config {
8000 cmdline_fixed_string_t cmd;
8001 cmdline_fixed_string_t what;
8007 cmd_tunnel_udp_config_parsed(void *parsed_result,
8008 __attribute__((unused)) struct cmdline *cl,
8009 __attribute__((unused)) void *data)
8011 struct cmd_tunnel_udp_config *res = parsed_result;
8012 struct rte_eth_udp_tunnel tunnel_udp;
8015 tunnel_udp.udp_port = res->udp_port;
8017 if (!strcmp(res->cmd, "rx_vxlan_port"))
8018 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
8020 if (!strcmp(res->what, "add"))
8021 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
8024 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
8028 printf("udp tunneling add error: (%s)\n", strerror(-ret));
8031 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
8032 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
8033 cmd, "rx_vxlan_port");
8034 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
8035 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
8037 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
8038 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
8040 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
8041 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
8044 cmdline_parse_inst_t cmd_tunnel_udp_config = {
8045 .f = cmd_tunnel_udp_config_parsed,
8047 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
8048 "Add/Remove a tunneling UDP port filter",
8050 (void *)&cmd_tunnel_udp_config_cmd,
8051 (void *)&cmd_tunnel_udp_config_what,
8052 (void *)&cmd_tunnel_udp_config_udp_port,
8053 (void *)&cmd_tunnel_udp_config_port_id,
8058 /* *** GLOBAL CONFIG *** */
8059 struct cmd_global_config_result {
8060 cmdline_fixed_string_t cmd;
8062 cmdline_fixed_string_t cfg_type;
8067 cmd_global_config_parsed(void *parsed_result,
8068 __attribute__((unused)) struct cmdline *cl,
8069 __attribute__((unused)) void *data)
8071 struct cmd_global_config_result *res = parsed_result;
8072 struct rte_eth_global_cfg conf;
8075 memset(&conf, 0, sizeof(conf));
8076 conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN;
8077 conf.cfg.gre_key_len = res->len;
8078 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE,
8079 RTE_ETH_FILTER_SET, &conf);
8081 printf("Global config error\n");
8084 cmdline_parse_token_string_t cmd_global_config_cmd =
8085 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd,
8087 cmdline_parse_token_num_t cmd_global_config_port_id =
8088 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id,
8090 cmdline_parse_token_string_t cmd_global_config_type =
8091 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result,
8092 cfg_type, "gre-key-len");
8093 cmdline_parse_token_num_t cmd_global_config_gre_key_len =
8094 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result,
8097 cmdline_parse_inst_t cmd_global_config = {
8098 .f = cmd_global_config_parsed,
8099 .data = (void *)NULL,
8100 .help_str = "global_config <port_id> gre-key-len <key_len>",
8102 (void *)&cmd_global_config_cmd,
8103 (void *)&cmd_global_config_port_id,
8104 (void *)&cmd_global_config_type,
8105 (void *)&cmd_global_config_gre_key_len,
8110 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
8111 struct cmd_set_mirror_mask_result {
8112 cmdline_fixed_string_t set;
8113 cmdline_fixed_string_t port;
8115 cmdline_fixed_string_t mirror;
8117 cmdline_fixed_string_t what;
8118 cmdline_fixed_string_t value;
8119 cmdline_fixed_string_t dstpool;
8121 cmdline_fixed_string_t on;
8124 cmdline_parse_token_string_t cmd_mirror_mask_set =
8125 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8127 cmdline_parse_token_string_t cmd_mirror_mask_port =
8128 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8130 cmdline_parse_token_num_t cmd_mirror_mask_portid =
8131 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
8133 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
8134 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8135 mirror, "mirror-rule");
8136 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
8137 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
8139 cmdline_parse_token_string_t cmd_mirror_mask_what =
8140 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8141 what, "pool-mirror-up#pool-mirror-down"
8143 cmdline_parse_token_string_t cmd_mirror_mask_value =
8144 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8146 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
8147 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8148 dstpool, "dst-pool");
8149 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
8150 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
8152 cmdline_parse_token_string_t cmd_mirror_mask_on =
8153 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8157 cmd_set_mirror_mask_parsed(void *parsed_result,
8158 __attribute__((unused)) struct cmdline *cl,
8159 __attribute__((unused)) void *data)
8162 struct cmd_set_mirror_mask_result *res = parsed_result;
8163 struct rte_eth_mirror_conf mr_conf;
8165 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
8167 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
8169 mr_conf.dst_pool = res->dstpool_id;
8171 if (!strcmp(res->what, "pool-mirror-up")) {
8172 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
8173 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
8174 } else if (!strcmp(res->what, "pool-mirror-down")) {
8175 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
8176 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
8177 } else if (!strcmp(res->what, "vlan-mirror")) {
8178 mr_conf.rule_type = ETH_MIRROR_VLAN;
8179 nb_item = parse_item_list(res->value, "vlan",
8180 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
8184 for (i = 0; i < nb_item; i++) {
8185 if (vlan_list[i] > ETHER_MAX_VLAN_ID) {
8186 printf("Invalid vlan_id: must be < 4096\n");
8190 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
8191 mr_conf.vlan.vlan_mask |= 1ULL << i;
8195 if (!strcmp(res->on, "on"))
8196 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8199 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8202 printf("mirror rule add error: (%s)\n", strerror(-ret));
8205 cmdline_parse_inst_t cmd_set_mirror_mask = {
8206 .f = cmd_set_mirror_mask_parsed,
8208 .help_str = "set port <port_id> mirror-rule <rule_id> "
8209 "pool-mirror-up|pool-mirror-down|vlan-mirror "
8210 "<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off",
8212 (void *)&cmd_mirror_mask_set,
8213 (void *)&cmd_mirror_mask_port,
8214 (void *)&cmd_mirror_mask_portid,
8215 (void *)&cmd_mirror_mask_mirror,
8216 (void *)&cmd_mirror_mask_ruleid,
8217 (void *)&cmd_mirror_mask_what,
8218 (void *)&cmd_mirror_mask_value,
8219 (void *)&cmd_mirror_mask_dstpool,
8220 (void *)&cmd_mirror_mask_poolid,
8221 (void *)&cmd_mirror_mask_on,
8226 /* *** CONFIGURE VM MIRROR UPLINK/DOWNLINK RULE *** */
8227 struct cmd_set_mirror_link_result {
8228 cmdline_fixed_string_t set;
8229 cmdline_fixed_string_t port;
8231 cmdline_fixed_string_t mirror;
8233 cmdline_fixed_string_t what;
8234 cmdline_fixed_string_t dstpool;
8236 cmdline_fixed_string_t on;
8239 cmdline_parse_token_string_t cmd_mirror_link_set =
8240 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8242 cmdline_parse_token_string_t cmd_mirror_link_port =
8243 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8245 cmdline_parse_token_num_t cmd_mirror_link_portid =
8246 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
8248 cmdline_parse_token_string_t cmd_mirror_link_mirror =
8249 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8250 mirror, "mirror-rule");
8251 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
8252 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
8254 cmdline_parse_token_string_t cmd_mirror_link_what =
8255 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8256 what, "uplink-mirror#downlink-mirror");
8257 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
8258 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8259 dstpool, "dst-pool");
8260 cmdline_parse_token_num_t cmd_mirror_link_poolid =
8261 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
8263 cmdline_parse_token_string_t cmd_mirror_link_on =
8264 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8268 cmd_set_mirror_link_parsed(void *parsed_result,
8269 __attribute__((unused)) struct cmdline *cl,
8270 __attribute__((unused)) void *data)
8273 struct cmd_set_mirror_link_result *res = parsed_result;
8274 struct rte_eth_mirror_conf mr_conf;
8276 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
8277 if (!strcmp(res->what, "uplink-mirror"))
8278 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
8280 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
8282 mr_conf.dst_pool = res->dstpool_id;
8284 if (!strcmp(res->on, "on"))
8285 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8288 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8291 /* check the return value and print it if is < 0 */
8293 printf("mirror rule add error: (%s)\n", strerror(-ret));
8297 cmdline_parse_inst_t cmd_set_mirror_link = {
8298 .f = cmd_set_mirror_link_parsed,
8300 .help_str = "set port <port_id> mirror-rule <rule_id> "
8301 "uplink-mirror|downlink-mirror dst-pool <pool_id> on|off",
8303 (void *)&cmd_mirror_link_set,
8304 (void *)&cmd_mirror_link_port,
8305 (void *)&cmd_mirror_link_portid,
8306 (void *)&cmd_mirror_link_mirror,
8307 (void *)&cmd_mirror_link_ruleid,
8308 (void *)&cmd_mirror_link_what,
8309 (void *)&cmd_mirror_link_dstpool,
8310 (void *)&cmd_mirror_link_poolid,
8311 (void *)&cmd_mirror_link_on,
8316 /* *** RESET VM MIRROR RULE *** */
8317 struct cmd_rm_mirror_rule_result {
8318 cmdline_fixed_string_t reset;
8319 cmdline_fixed_string_t port;
8321 cmdline_fixed_string_t mirror;
8325 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
8326 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
8328 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
8329 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
8331 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
8332 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
8334 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
8335 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
8336 mirror, "mirror-rule");
8337 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
8338 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
8342 cmd_reset_mirror_rule_parsed(void *parsed_result,
8343 __attribute__((unused)) struct cmdline *cl,
8344 __attribute__((unused)) void *data)
8347 struct cmd_set_mirror_link_result *res = parsed_result;
8349 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
8351 printf("mirror rule remove error: (%s)\n", strerror(-ret));
8354 cmdline_parse_inst_t cmd_reset_mirror_rule = {
8355 .f = cmd_reset_mirror_rule_parsed,
8357 .help_str = "reset port <port_id> mirror-rule <rule_id>",
8359 (void *)&cmd_rm_mirror_rule_reset,
8360 (void *)&cmd_rm_mirror_rule_port,
8361 (void *)&cmd_rm_mirror_rule_portid,
8362 (void *)&cmd_rm_mirror_rule_mirror,
8363 (void *)&cmd_rm_mirror_rule_ruleid,
8368 /* ******************************************************************************** */
8370 struct cmd_dump_result {
8371 cmdline_fixed_string_t dump;
8375 dump_struct_sizes(void)
8377 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
8378 DUMP_SIZE(struct rte_mbuf);
8379 DUMP_SIZE(struct rte_mempool);
8380 DUMP_SIZE(struct rte_ring);
8384 static void cmd_dump_parsed(void *parsed_result,
8385 __attribute__((unused)) struct cmdline *cl,
8386 __attribute__((unused)) void *data)
8388 struct cmd_dump_result *res = parsed_result;
8390 if (!strcmp(res->dump, "dump_physmem"))
8391 rte_dump_physmem_layout(stdout);
8392 else if (!strcmp(res->dump, "dump_memzone"))
8393 rte_memzone_dump(stdout);
8394 else if (!strcmp(res->dump, "dump_struct_sizes"))
8395 dump_struct_sizes();
8396 else if (!strcmp(res->dump, "dump_ring"))
8397 rte_ring_list_dump(stdout);
8398 else if (!strcmp(res->dump, "dump_mempool"))
8399 rte_mempool_list_dump(stdout);
8400 else if (!strcmp(res->dump, "dump_devargs"))
8401 rte_eal_devargs_dump(stdout);
8402 else if (!strcmp(res->dump, "dump_log_types"))
8403 rte_log_dump(stdout);
8406 cmdline_parse_token_string_t cmd_dump_dump =
8407 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
8410 "dump_struct_sizes#"
8416 cmdline_parse_inst_t cmd_dump = {
8417 .f = cmd_dump_parsed, /* function to call */
8418 .data = NULL, /* 2nd arg of func */
8419 .help_str = "Dump status",
8420 .tokens = { /* token list, NULL terminated */
8421 (void *)&cmd_dump_dump,
8426 /* ******************************************************************************** */
8428 struct cmd_dump_one_result {
8429 cmdline_fixed_string_t dump;
8430 cmdline_fixed_string_t name;
8433 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
8434 __attribute__((unused)) void *data)
8436 struct cmd_dump_one_result *res = parsed_result;
8438 if (!strcmp(res->dump, "dump_ring")) {
8440 r = rte_ring_lookup(res->name);
8442 cmdline_printf(cl, "Cannot find ring\n");
8445 rte_ring_dump(stdout, r);
8446 } else if (!strcmp(res->dump, "dump_mempool")) {
8447 struct rte_mempool *mp;
8448 mp = rte_mempool_lookup(res->name);
8450 cmdline_printf(cl, "Cannot find mempool\n");
8453 rte_mempool_dump(stdout, mp);
8457 cmdline_parse_token_string_t cmd_dump_one_dump =
8458 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
8459 "dump_ring#dump_mempool");
8461 cmdline_parse_token_string_t cmd_dump_one_name =
8462 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
8464 cmdline_parse_inst_t cmd_dump_one = {
8465 .f = cmd_dump_one_parsed, /* function to call */
8466 .data = NULL, /* 2nd arg of func */
8467 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
8468 .tokens = { /* token list, NULL terminated */
8469 (void *)&cmd_dump_one_dump,
8470 (void *)&cmd_dump_one_name,
8475 /* *** Add/Del syn filter *** */
8476 struct cmd_syn_filter_result {
8477 cmdline_fixed_string_t filter;
8479 cmdline_fixed_string_t ops;
8480 cmdline_fixed_string_t priority;
8481 cmdline_fixed_string_t high;
8482 cmdline_fixed_string_t queue;
8487 cmd_syn_filter_parsed(void *parsed_result,
8488 __attribute__((unused)) struct cmdline *cl,
8489 __attribute__((unused)) void *data)
8491 struct cmd_syn_filter_result *res = parsed_result;
8492 struct rte_eth_syn_filter syn_filter;
8495 ret = rte_eth_dev_filter_supported(res->port_id,
8496 RTE_ETH_FILTER_SYN);
8498 printf("syn filter is not supported on port %u.\n",
8503 memset(&syn_filter, 0, sizeof(syn_filter));
8505 if (!strcmp(res->ops, "add")) {
8506 if (!strcmp(res->high, "high"))
8507 syn_filter.hig_pri = 1;
8509 syn_filter.hig_pri = 0;
8511 syn_filter.queue = res->queue_id;
8512 ret = rte_eth_dev_filter_ctrl(res->port_id,
8517 ret = rte_eth_dev_filter_ctrl(res->port_id,
8519 RTE_ETH_FILTER_DELETE,
8523 printf("syn filter programming error: (%s)\n",
8527 cmdline_parse_token_string_t cmd_syn_filter_filter =
8528 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8529 filter, "syn_filter");
8530 cmdline_parse_token_num_t cmd_syn_filter_port_id =
8531 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
8533 cmdline_parse_token_string_t cmd_syn_filter_ops =
8534 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8536 cmdline_parse_token_string_t cmd_syn_filter_priority =
8537 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8538 priority, "priority");
8539 cmdline_parse_token_string_t cmd_syn_filter_high =
8540 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8542 cmdline_parse_token_string_t cmd_syn_filter_queue =
8543 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8545 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
8546 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
8549 cmdline_parse_inst_t cmd_syn_filter = {
8550 .f = cmd_syn_filter_parsed,
8552 .help_str = "syn_filter <port_id> add|del priority high|low queue "
8553 "<queue_id>: Add/Delete syn filter",
8555 (void *)&cmd_syn_filter_filter,
8556 (void *)&cmd_syn_filter_port_id,
8557 (void *)&cmd_syn_filter_ops,
8558 (void *)&cmd_syn_filter_priority,
8559 (void *)&cmd_syn_filter_high,
8560 (void *)&cmd_syn_filter_queue,
8561 (void *)&cmd_syn_filter_queue_id,
8566 /* *** queue region set *** */
8567 struct cmd_queue_region_result {
8568 cmdline_fixed_string_t set;
8569 cmdline_fixed_string_t port;
8571 cmdline_fixed_string_t cmd;
8572 cmdline_fixed_string_t region;
8574 cmdline_fixed_string_t queue_start_index;
8576 cmdline_fixed_string_t queue_num;
8577 uint8_t queue_num_value;
8581 cmd_queue_region_parsed(void *parsed_result,
8582 __attribute__((unused)) struct cmdline *cl,
8583 __attribute__((unused)) void *data)
8585 struct cmd_queue_region_result *res = parsed_result;
8587 #ifdef RTE_LIBRTE_I40E_PMD
8588 struct rte_pmd_i40e_queue_region_conf region_conf;
8589 enum rte_pmd_i40e_queue_region_op op_type;
8592 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
8595 #ifdef RTE_LIBRTE_I40E_PMD
8596 memset(®ion_conf, 0, sizeof(region_conf));
8597 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_SET;
8598 region_conf.region_id = res->region_id;
8599 region_conf.queue_num = res->queue_num_value;
8600 region_conf.queue_start_index = res->queue_id;
8602 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
8603 op_type, ®ion_conf);
8610 printf("function not implemented or supported\n");
8613 printf("queue region config error: (%s)\n", strerror(-ret));
8617 cmdline_parse_token_string_t cmd_queue_region_set =
8618 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
8620 cmdline_parse_token_string_t cmd_queue_region_port =
8621 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, port, "port");
8622 cmdline_parse_token_num_t cmd_queue_region_port_id =
8623 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
8625 cmdline_parse_token_string_t cmd_queue_region_cmd =
8626 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
8627 cmd, "queue-region");
8628 cmdline_parse_token_string_t cmd_queue_region_id =
8629 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
8630 region, "region_id");
8631 cmdline_parse_token_num_t cmd_queue_region_index =
8632 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
8634 cmdline_parse_token_string_t cmd_queue_region_queue_start_index =
8635 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
8636 queue_start_index, "queue_start_index");
8637 cmdline_parse_token_num_t cmd_queue_region_queue_id =
8638 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
8640 cmdline_parse_token_string_t cmd_queue_region_queue_num =
8641 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
8642 queue_num, "queue_num");
8643 cmdline_parse_token_num_t cmd_queue_region_queue_num_value =
8644 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
8645 queue_num_value, UINT8);
8647 cmdline_parse_inst_t cmd_queue_region = {
8648 .f = cmd_queue_region_parsed,
8650 .help_str = "set port <port_id> queue-region region_id <value> "
8651 "queue_start_index <value> queue_num <value>: Set a queue region",
8653 (void *)&cmd_queue_region_set,
8654 (void *)&cmd_queue_region_port,
8655 (void *)&cmd_queue_region_port_id,
8656 (void *)&cmd_queue_region_cmd,
8657 (void *)&cmd_queue_region_id,
8658 (void *)&cmd_queue_region_index,
8659 (void *)&cmd_queue_region_queue_start_index,
8660 (void *)&cmd_queue_region_queue_id,
8661 (void *)&cmd_queue_region_queue_num,
8662 (void *)&cmd_queue_region_queue_num_value,
8667 /* *** queue region and flowtype set *** */
8668 struct cmd_region_flowtype_result {
8669 cmdline_fixed_string_t set;
8670 cmdline_fixed_string_t port;
8672 cmdline_fixed_string_t cmd;
8673 cmdline_fixed_string_t region;
8675 cmdline_fixed_string_t flowtype;
8676 uint8_t flowtype_id;
8680 cmd_region_flowtype_parsed(void *parsed_result,
8681 __attribute__((unused)) struct cmdline *cl,
8682 __attribute__((unused)) void *data)
8684 struct cmd_region_flowtype_result *res = parsed_result;
8686 #ifdef RTE_LIBRTE_I40E_PMD
8687 struct rte_pmd_i40e_queue_region_conf region_conf;
8688 enum rte_pmd_i40e_queue_region_op op_type;
8691 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
8694 #ifdef RTE_LIBRTE_I40E_PMD
8695 memset(®ion_conf, 0, sizeof(region_conf));
8697 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_FLOWTYPE_SET;
8698 region_conf.region_id = res->region_id;
8699 region_conf.hw_flowtype = res->flowtype_id;
8701 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
8702 op_type, ®ion_conf);
8709 printf("function not implemented or supported\n");
8712 printf("region flowtype config error: (%s)\n", strerror(-ret));
8716 cmdline_parse_token_string_t cmd_region_flowtype_set =
8717 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
8719 cmdline_parse_token_string_t cmd_region_flowtype_port =
8720 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
8722 cmdline_parse_token_num_t cmd_region_flowtype_port_index =
8723 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
8725 cmdline_parse_token_string_t cmd_region_flowtype_cmd =
8726 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
8727 cmd, "queue-region");
8728 cmdline_parse_token_string_t cmd_region_flowtype_index =
8729 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
8730 region, "region_id");
8731 cmdline_parse_token_num_t cmd_region_flowtype_id =
8732 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
8734 cmdline_parse_token_string_t cmd_region_flowtype_flow_index =
8735 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
8736 flowtype, "flowtype");
8737 cmdline_parse_token_num_t cmd_region_flowtype_flow_id =
8738 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
8739 flowtype_id, UINT8);
8740 cmdline_parse_inst_t cmd_region_flowtype = {
8741 .f = cmd_region_flowtype_parsed,
8743 .help_str = "set port <port_id> queue-region region_id <value> "
8744 "flowtype <value>: Set a flowtype region index",
8746 (void *)&cmd_region_flowtype_set,
8747 (void *)&cmd_region_flowtype_port,
8748 (void *)&cmd_region_flowtype_port_index,
8749 (void *)&cmd_region_flowtype_cmd,
8750 (void *)&cmd_region_flowtype_index,
8751 (void *)&cmd_region_flowtype_id,
8752 (void *)&cmd_region_flowtype_flow_index,
8753 (void *)&cmd_region_flowtype_flow_id,
8758 /* *** User Priority (UP) to queue region (region_id) set *** */
8759 struct cmd_user_priority_region_result {
8760 cmdline_fixed_string_t set;
8761 cmdline_fixed_string_t port;
8763 cmdline_fixed_string_t cmd;
8764 cmdline_fixed_string_t user_priority;
8765 uint8_t user_priority_id;
8766 cmdline_fixed_string_t region;
8771 cmd_user_priority_region_parsed(void *parsed_result,
8772 __attribute__((unused)) struct cmdline *cl,
8773 __attribute__((unused)) void *data)
8775 struct cmd_user_priority_region_result *res = parsed_result;
8777 #ifdef RTE_LIBRTE_I40E_PMD
8778 struct rte_pmd_i40e_queue_region_conf region_conf;
8779 enum rte_pmd_i40e_queue_region_op op_type;
8782 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
8785 #ifdef RTE_LIBRTE_I40E_PMD
8786 memset(®ion_conf, 0, sizeof(region_conf));
8787 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_USER_PRIORITY_SET;
8788 region_conf.user_priority = res->user_priority_id;
8789 region_conf.region_id = res->region_id;
8791 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
8792 op_type, ®ion_conf);
8799 printf("function not implemented or supported\n");
8802 printf("user_priority region config error: (%s)\n",
8807 cmdline_parse_token_string_t cmd_user_priority_region_set =
8808 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
8810 cmdline_parse_token_string_t cmd_user_priority_region_port =
8811 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
8813 cmdline_parse_token_num_t cmd_user_priority_region_port_index =
8814 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
8816 cmdline_parse_token_string_t cmd_user_priority_region_cmd =
8817 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
8818 cmd, "queue-region");
8819 cmdline_parse_token_string_t cmd_user_priority_region_UP =
8820 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
8821 user_priority, "UP");
8822 cmdline_parse_token_num_t cmd_user_priority_region_UP_id =
8823 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
8824 user_priority_id, UINT8);
8825 cmdline_parse_token_string_t cmd_user_priority_region_region =
8826 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
8827 region, "region_id");
8828 cmdline_parse_token_num_t cmd_user_priority_region_region_id =
8829 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
8832 cmdline_parse_inst_t cmd_user_priority_region = {
8833 .f = cmd_user_priority_region_parsed,
8835 .help_str = "set port <port_id> queue-region UP <value> "
8836 "region_id <value>: Set the mapping of User Priority (UP) "
8837 "to queue region (region_id) ",
8839 (void *)&cmd_user_priority_region_set,
8840 (void *)&cmd_user_priority_region_port,
8841 (void *)&cmd_user_priority_region_port_index,
8842 (void *)&cmd_user_priority_region_cmd,
8843 (void *)&cmd_user_priority_region_UP,
8844 (void *)&cmd_user_priority_region_UP_id,
8845 (void *)&cmd_user_priority_region_region,
8846 (void *)&cmd_user_priority_region_region_id,
8851 /* *** flush all queue region related configuration *** */
8852 struct cmd_flush_queue_region_result {
8853 cmdline_fixed_string_t set;
8854 cmdline_fixed_string_t port;
8856 cmdline_fixed_string_t cmd;
8857 cmdline_fixed_string_t flush;
8858 cmdline_fixed_string_t what;
8862 cmd_flush_queue_region_parsed(void *parsed_result,
8863 __attribute__((unused)) struct cmdline *cl,
8864 __attribute__((unused)) void *data)
8866 struct cmd_flush_queue_region_result *res = parsed_result;
8868 #ifdef RTE_LIBRTE_I40E_PMD
8869 struct rte_pmd_i40e_queue_region_conf region_conf;
8870 enum rte_pmd_i40e_queue_region_op op_type;
8873 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
8876 #ifdef RTE_LIBRTE_I40E_PMD
8877 memset(®ion_conf, 0, sizeof(region_conf));
8879 if (strcmp(res->what, "on") == 0)
8880 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_ON;
8882 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_OFF;
8884 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
8885 op_type, ®ion_conf);
8892 printf("function not implemented or supported\n");
8895 printf("queue region config flush error: (%s)\n",
8900 cmdline_parse_token_string_t cmd_flush_queue_region_set =
8901 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
8903 cmdline_parse_token_string_t cmd_flush_queue_region_port =
8904 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
8906 cmdline_parse_token_num_t cmd_flush_queue_region_port_index =
8907 TOKEN_NUM_INITIALIZER(struct cmd_flush_queue_region_result,
8909 cmdline_parse_token_string_t cmd_flush_queue_region_cmd =
8910 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
8911 cmd, "queue-region");
8912 cmdline_parse_token_string_t cmd_flush_queue_region_flush =
8913 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
8915 cmdline_parse_token_string_t cmd_flush_queue_region_what =
8916 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
8919 cmdline_parse_inst_t cmd_flush_queue_region = {
8920 .f = cmd_flush_queue_region_parsed,
8922 .help_str = "set port <port_id> queue-region flush on|off"
8923 ": flush all queue region related configuration",
8925 (void *)&cmd_flush_queue_region_set,
8926 (void *)&cmd_flush_queue_region_port,
8927 (void *)&cmd_flush_queue_region_port_index,
8928 (void *)&cmd_flush_queue_region_cmd,
8929 (void *)&cmd_flush_queue_region_flush,
8930 (void *)&cmd_flush_queue_region_what,
8935 /* *** get all queue region related configuration info *** */
8936 struct cmd_show_queue_region_info {
8937 cmdline_fixed_string_t show;
8938 cmdline_fixed_string_t port;
8940 cmdline_fixed_string_t cmd;
8944 cmd_show_queue_region_info_parsed(void *parsed_result,
8945 __attribute__((unused)) struct cmdline *cl,
8946 __attribute__((unused)) void *data)
8948 struct cmd_show_queue_region_info *res = parsed_result;
8950 #ifdef RTE_LIBRTE_I40E_PMD
8951 struct rte_pmd_i40e_queue_regions rte_pmd_regions;
8952 enum rte_pmd_i40e_queue_region_op op_type;
8955 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
8958 #ifdef RTE_LIBRTE_I40E_PMD
8959 memset(&rte_pmd_regions, 0, sizeof(rte_pmd_regions));
8961 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_INFO_GET;
8963 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
8964 op_type, &rte_pmd_regions);
8966 port_queue_region_info_display(res->port_id, &rte_pmd_regions);
8973 printf("function not implemented or supported\n");
8976 printf("queue region config info show error: (%s)\n",
8981 cmdline_parse_token_string_t cmd_show_queue_region_info_get =
8982 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
8984 cmdline_parse_token_string_t cmd_show_queue_region_info_port =
8985 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
8987 cmdline_parse_token_num_t cmd_show_queue_region_info_port_index =
8988 TOKEN_NUM_INITIALIZER(struct cmd_show_queue_region_info,
8990 cmdline_parse_token_string_t cmd_show_queue_region_info_cmd =
8991 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
8992 cmd, "queue-region");
8994 cmdline_parse_inst_t cmd_show_queue_region_info_all = {
8995 .f = cmd_show_queue_region_info_parsed,
8997 .help_str = "show port <port_id> queue-region"
8998 ": show all queue region related configuration info",
9000 (void *)&cmd_show_queue_region_info_get,
9001 (void *)&cmd_show_queue_region_info_port,
9002 (void *)&cmd_show_queue_region_info_port_index,
9003 (void *)&cmd_show_queue_region_info_cmd,
9008 /* *** ADD/REMOVE A 2tuple FILTER *** */
9009 struct cmd_2tuple_filter_result {
9010 cmdline_fixed_string_t filter;
9012 cmdline_fixed_string_t ops;
9013 cmdline_fixed_string_t dst_port;
9014 uint16_t dst_port_value;
9015 cmdline_fixed_string_t protocol;
9016 uint8_t protocol_value;
9017 cmdline_fixed_string_t mask;
9019 cmdline_fixed_string_t tcp_flags;
9020 uint8_t tcp_flags_value;
9021 cmdline_fixed_string_t priority;
9022 uint8_t priority_value;
9023 cmdline_fixed_string_t queue;
9028 cmd_2tuple_filter_parsed(void *parsed_result,
9029 __attribute__((unused)) struct cmdline *cl,
9030 __attribute__((unused)) void *data)
9032 struct rte_eth_ntuple_filter filter;
9033 struct cmd_2tuple_filter_result *res = parsed_result;
9036 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
9038 printf("ntuple filter is not supported on port %u.\n",
9043 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
9045 filter.flags = RTE_2TUPLE_FLAGS;
9046 filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
9047 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
9048 filter.proto = res->protocol_value;
9049 filter.priority = res->priority_value;
9050 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
9051 printf("nonzero tcp_flags is only meaningful"
9052 " when protocol is TCP.\n");
9055 if (res->tcp_flags_value > TCP_FLAG_ALL) {
9056 printf("invalid TCP flags.\n");
9060 if (res->tcp_flags_value != 0) {
9061 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
9062 filter.tcp_flags = res->tcp_flags_value;
9065 /* need convert to big endian. */
9066 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
9067 filter.queue = res->queue_id;
9069 if (!strcmp(res->ops, "add"))
9070 ret = rte_eth_dev_filter_ctrl(res->port_id,
9071 RTE_ETH_FILTER_NTUPLE,
9075 ret = rte_eth_dev_filter_ctrl(res->port_id,
9076 RTE_ETH_FILTER_NTUPLE,
9077 RTE_ETH_FILTER_DELETE,
9080 printf("2tuple filter programming error: (%s)\n",
9085 cmdline_parse_token_string_t cmd_2tuple_filter_filter =
9086 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9087 filter, "2tuple_filter");
9088 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
9089 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9091 cmdline_parse_token_string_t cmd_2tuple_filter_ops =
9092 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9094 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
9095 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9096 dst_port, "dst_port");
9097 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
9098 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9099 dst_port_value, UINT16);
9100 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
9101 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9102 protocol, "protocol");
9103 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
9104 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9105 protocol_value, UINT8);
9106 cmdline_parse_token_string_t cmd_2tuple_filter_mask =
9107 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9109 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value =
9110 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9112 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags =
9113 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9114 tcp_flags, "tcp_flags");
9115 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value =
9116 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9117 tcp_flags_value, UINT8);
9118 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
9119 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9120 priority, "priority");
9121 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
9122 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9123 priority_value, UINT8);
9124 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
9125 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9127 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
9128 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9131 cmdline_parse_inst_t cmd_2tuple_filter = {
9132 .f = cmd_2tuple_filter_parsed,
9134 .help_str = "2tuple_filter <port_id> add|del dst_port <value> protocol "
9135 "<value> mask <value> tcp_flags <value> priority <value> queue "
9136 "<queue_id>: Add a 2tuple filter",
9138 (void *)&cmd_2tuple_filter_filter,
9139 (void *)&cmd_2tuple_filter_port_id,
9140 (void *)&cmd_2tuple_filter_ops,
9141 (void *)&cmd_2tuple_filter_dst_port,
9142 (void *)&cmd_2tuple_filter_dst_port_value,
9143 (void *)&cmd_2tuple_filter_protocol,
9144 (void *)&cmd_2tuple_filter_protocol_value,
9145 (void *)&cmd_2tuple_filter_mask,
9146 (void *)&cmd_2tuple_filter_mask_value,
9147 (void *)&cmd_2tuple_filter_tcp_flags,
9148 (void *)&cmd_2tuple_filter_tcp_flags_value,
9149 (void *)&cmd_2tuple_filter_priority,
9150 (void *)&cmd_2tuple_filter_priority_value,
9151 (void *)&cmd_2tuple_filter_queue,
9152 (void *)&cmd_2tuple_filter_queue_id,
9157 /* *** ADD/REMOVE A 5tuple FILTER *** */
9158 struct cmd_5tuple_filter_result {
9159 cmdline_fixed_string_t filter;
9161 cmdline_fixed_string_t ops;
9162 cmdline_fixed_string_t dst_ip;
9163 cmdline_ipaddr_t dst_ip_value;
9164 cmdline_fixed_string_t src_ip;
9165 cmdline_ipaddr_t src_ip_value;
9166 cmdline_fixed_string_t dst_port;
9167 uint16_t dst_port_value;
9168 cmdline_fixed_string_t src_port;
9169 uint16_t src_port_value;
9170 cmdline_fixed_string_t protocol;
9171 uint8_t protocol_value;
9172 cmdline_fixed_string_t mask;
9174 cmdline_fixed_string_t tcp_flags;
9175 uint8_t tcp_flags_value;
9176 cmdline_fixed_string_t priority;
9177 uint8_t priority_value;
9178 cmdline_fixed_string_t queue;
9183 cmd_5tuple_filter_parsed(void *parsed_result,
9184 __attribute__((unused)) struct cmdline *cl,
9185 __attribute__((unused)) void *data)
9187 struct rte_eth_ntuple_filter filter;
9188 struct cmd_5tuple_filter_result *res = parsed_result;
9191 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
9193 printf("ntuple filter is not supported on port %u.\n",
9198 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
9200 filter.flags = RTE_5TUPLE_FLAGS;
9201 filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0;
9202 filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0;
9203 filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0;
9204 filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
9205 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
9206 filter.proto = res->protocol_value;
9207 filter.priority = res->priority_value;
9208 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
9209 printf("nonzero tcp_flags is only meaningful"
9210 " when protocol is TCP.\n");
9213 if (res->tcp_flags_value > TCP_FLAG_ALL) {
9214 printf("invalid TCP flags.\n");
9218 if (res->tcp_flags_value != 0) {
9219 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
9220 filter.tcp_flags = res->tcp_flags_value;
9223 if (res->dst_ip_value.family == AF_INET)
9224 /* no need to convert, already big endian. */
9225 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
9227 if (filter.dst_ip_mask == 0) {
9228 printf("can not support ipv6 involved compare.\n");
9234 if (res->src_ip_value.family == AF_INET)
9235 /* no need to convert, already big endian. */
9236 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
9238 if (filter.src_ip_mask == 0) {
9239 printf("can not support ipv6 involved compare.\n");
9244 /* need convert to big endian. */
9245 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
9246 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
9247 filter.queue = res->queue_id;
9249 if (!strcmp(res->ops, "add"))
9250 ret = rte_eth_dev_filter_ctrl(res->port_id,
9251 RTE_ETH_FILTER_NTUPLE,
9255 ret = rte_eth_dev_filter_ctrl(res->port_id,
9256 RTE_ETH_FILTER_NTUPLE,
9257 RTE_ETH_FILTER_DELETE,
9260 printf("5tuple filter programming error: (%s)\n",
9264 cmdline_parse_token_string_t cmd_5tuple_filter_filter =
9265 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9266 filter, "5tuple_filter");
9267 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
9268 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9270 cmdline_parse_token_string_t cmd_5tuple_filter_ops =
9271 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9273 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
9274 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9276 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
9277 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
9279 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
9280 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9282 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
9283 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
9285 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
9286 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9287 dst_port, "dst_port");
9288 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
9289 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9290 dst_port_value, UINT16);
9291 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
9292 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9293 src_port, "src_port");
9294 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
9295 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9296 src_port_value, UINT16);
9297 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
9298 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9299 protocol, "protocol");
9300 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
9301 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9302 protocol_value, UINT8);
9303 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
9304 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9306 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
9307 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9309 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags =
9310 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9311 tcp_flags, "tcp_flags");
9312 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value =
9313 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9314 tcp_flags_value, UINT8);
9315 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
9316 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9317 priority, "priority");
9318 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
9319 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9320 priority_value, UINT8);
9321 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
9322 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9324 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
9325 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9328 cmdline_parse_inst_t cmd_5tuple_filter = {
9329 .f = cmd_5tuple_filter_parsed,
9331 .help_str = "5tuple_filter <port_id> add|del dst_ip <value> "
9332 "src_ip <value> dst_port <value> src_port <value> "
9333 "protocol <value> mask <value> tcp_flags <value> "
9334 "priority <value> queue <queue_id>: Add/Del a 5tuple filter",
9336 (void *)&cmd_5tuple_filter_filter,
9337 (void *)&cmd_5tuple_filter_port_id,
9338 (void *)&cmd_5tuple_filter_ops,
9339 (void *)&cmd_5tuple_filter_dst_ip,
9340 (void *)&cmd_5tuple_filter_dst_ip_value,
9341 (void *)&cmd_5tuple_filter_src_ip,
9342 (void *)&cmd_5tuple_filter_src_ip_value,
9343 (void *)&cmd_5tuple_filter_dst_port,
9344 (void *)&cmd_5tuple_filter_dst_port_value,
9345 (void *)&cmd_5tuple_filter_src_port,
9346 (void *)&cmd_5tuple_filter_src_port_value,
9347 (void *)&cmd_5tuple_filter_protocol,
9348 (void *)&cmd_5tuple_filter_protocol_value,
9349 (void *)&cmd_5tuple_filter_mask,
9350 (void *)&cmd_5tuple_filter_mask_value,
9351 (void *)&cmd_5tuple_filter_tcp_flags,
9352 (void *)&cmd_5tuple_filter_tcp_flags_value,
9353 (void *)&cmd_5tuple_filter_priority,
9354 (void *)&cmd_5tuple_filter_priority_value,
9355 (void *)&cmd_5tuple_filter_queue,
9356 (void *)&cmd_5tuple_filter_queue_id,
9361 /* *** ADD/REMOVE A flex FILTER *** */
9362 struct cmd_flex_filter_result {
9363 cmdline_fixed_string_t filter;
9364 cmdline_fixed_string_t ops;
9366 cmdline_fixed_string_t len;
9368 cmdline_fixed_string_t bytes;
9369 cmdline_fixed_string_t bytes_value;
9370 cmdline_fixed_string_t mask;
9371 cmdline_fixed_string_t mask_value;
9372 cmdline_fixed_string_t priority;
9373 uint8_t priority_value;
9374 cmdline_fixed_string_t queue;
9378 static int xdigit2val(unsigned char c)
9383 else if (isupper(c))
9391 cmd_flex_filter_parsed(void *parsed_result,
9392 __attribute__((unused)) struct cmdline *cl,
9393 __attribute__((unused)) void *data)
9396 struct rte_eth_flex_filter filter;
9397 struct cmd_flex_filter_result *res = parsed_result;
9398 char *bytes_ptr, *mask_ptr;
9399 uint16_t len, i, j = 0;
9404 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) {
9405 printf("the len exceed the max length 128\n");
9408 memset(&filter, 0, sizeof(struct rte_eth_flex_filter));
9409 filter.len = res->len_value;
9410 filter.priority = res->priority_value;
9411 filter.queue = res->queue_id;
9412 bytes_ptr = res->bytes_value;
9413 mask_ptr = res->mask_value;
9415 /* translate bytes string to array. */
9416 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
9417 (bytes_ptr[1] == 'X')))
9419 len = strnlen(bytes_ptr, res->len_value * 2);
9420 if (len == 0 || (len % 8 != 0)) {
9421 printf("please check len and bytes input\n");
9424 for (i = 0; i < len; i++) {
9426 if (isxdigit(c) == 0) {
9427 /* invalid characters. */
9428 printf("invalid input\n");
9431 val = xdigit2val(c);
9434 filter.bytes[j] = byte;
9435 printf("bytes[%d]:%02x ", j, filter.bytes[j]);
9442 /* translate mask string to uint8_t array. */
9443 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
9444 (mask_ptr[1] == 'X')))
9446 len = strnlen(mask_ptr, (res->len_value + 3) / 4);
9448 printf("invalid input\n");
9453 for (i = 0; i < len; i++) {
9455 if (isxdigit(c) == 0) {
9456 /* invalid characters. */
9457 printf("invalid input\n");
9460 val = xdigit2val(c);
9463 filter.mask[j] = byte;
9464 printf("mask[%d]:%02x ", j, filter.mask[j]);
9472 if (!strcmp(res->ops, "add"))
9473 ret = rte_eth_dev_filter_ctrl(res->port_id,
9474 RTE_ETH_FILTER_FLEXIBLE,
9478 ret = rte_eth_dev_filter_ctrl(res->port_id,
9479 RTE_ETH_FILTER_FLEXIBLE,
9480 RTE_ETH_FILTER_DELETE,
9484 printf("flex filter setting error: (%s)\n", strerror(-ret));
9487 cmdline_parse_token_string_t cmd_flex_filter_filter =
9488 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9489 filter, "flex_filter");
9490 cmdline_parse_token_num_t cmd_flex_filter_port_id =
9491 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
9493 cmdline_parse_token_string_t cmd_flex_filter_ops =
9494 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9496 cmdline_parse_token_string_t cmd_flex_filter_len =
9497 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9499 cmdline_parse_token_num_t cmd_flex_filter_len_value =
9500 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
9502 cmdline_parse_token_string_t cmd_flex_filter_bytes =
9503 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9505 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
9506 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9508 cmdline_parse_token_string_t cmd_flex_filter_mask =
9509 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9511 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
9512 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9514 cmdline_parse_token_string_t cmd_flex_filter_priority =
9515 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9516 priority, "priority");
9517 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
9518 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
9519 priority_value, UINT8);
9520 cmdline_parse_token_string_t cmd_flex_filter_queue =
9521 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9523 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
9524 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
9526 cmdline_parse_inst_t cmd_flex_filter = {
9527 .f = cmd_flex_filter_parsed,
9529 .help_str = "flex_filter <port_id> add|del len <value> bytes "
9530 "<value> mask <value> priority <value> queue <queue_id>: "
9531 "Add/Del a flex filter",
9533 (void *)&cmd_flex_filter_filter,
9534 (void *)&cmd_flex_filter_port_id,
9535 (void *)&cmd_flex_filter_ops,
9536 (void *)&cmd_flex_filter_len,
9537 (void *)&cmd_flex_filter_len_value,
9538 (void *)&cmd_flex_filter_bytes,
9539 (void *)&cmd_flex_filter_bytes_value,
9540 (void *)&cmd_flex_filter_mask,
9541 (void *)&cmd_flex_filter_mask_value,
9542 (void *)&cmd_flex_filter_priority,
9543 (void *)&cmd_flex_filter_priority_value,
9544 (void *)&cmd_flex_filter_queue,
9545 (void *)&cmd_flex_filter_queue_id,
9550 /* *** Filters Control *** */
9552 /* *** deal with ethertype filter *** */
9553 struct cmd_ethertype_filter_result {
9554 cmdline_fixed_string_t filter;
9556 cmdline_fixed_string_t ops;
9557 cmdline_fixed_string_t mac;
9558 struct ether_addr mac_addr;
9559 cmdline_fixed_string_t ethertype;
9560 uint16_t ethertype_value;
9561 cmdline_fixed_string_t drop;
9562 cmdline_fixed_string_t queue;
9566 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
9567 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9568 filter, "ethertype_filter");
9569 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
9570 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
9572 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
9573 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9575 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
9576 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9577 mac, "mac_addr#mac_ignr");
9578 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
9579 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
9581 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
9582 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9583 ethertype, "ethertype");
9584 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
9585 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
9586 ethertype_value, UINT16);
9587 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
9588 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9590 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
9591 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9593 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
9594 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
9598 cmd_ethertype_filter_parsed(void *parsed_result,
9599 __attribute__((unused)) struct cmdline *cl,
9600 __attribute__((unused)) void *data)
9602 struct cmd_ethertype_filter_result *res = parsed_result;
9603 struct rte_eth_ethertype_filter filter;
9606 ret = rte_eth_dev_filter_supported(res->port_id,
9607 RTE_ETH_FILTER_ETHERTYPE);
9609 printf("ethertype filter is not supported on port %u.\n",
9614 memset(&filter, 0, sizeof(filter));
9615 if (!strcmp(res->mac, "mac_addr")) {
9616 filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
9617 rte_memcpy(&filter.mac_addr, &res->mac_addr,
9618 sizeof(struct ether_addr));
9620 if (!strcmp(res->drop, "drop"))
9621 filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
9622 filter.ether_type = res->ethertype_value;
9623 filter.queue = res->queue_id;
9625 if (!strcmp(res->ops, "add"))
9626 ret = rte_eth_dev_filter_ctrl(res->port_id,
9627 RTE_ETH_FILTER_ETHERTYPE,
9631 ret = rte_eth_dev_filter_ctrl(res->port_id,
9632 RTE_ETH_FILTER_ETHERTYPE,
9633 RTE_ETH_FILTER_DELETE,
9636 printf("ethertype filter programming error: (%s)\n",
9640 cmdline_parse_inst_t cmd_ethertype_filter = {
9641 .f = cmd_ethertype_filter_parsed,
9643 .help_str = "ethertype_filter <port_id> add|del mac_addr|mac_ignr "
9644 "<mac_addr> ethertype <value> drop|fw queue <queue_id>: "
9645 "Add or delete an ethertype filter entry",
9647 (void *)&cmd_ethertype_filter_filter,
9648 (void *)&cmd_ethertype_filter_port_id,
9649 (void *)&cmd_ethertype_filter_ops,
9650 (void *)&cmd_ethertype_filter_mac,
9651 (void *)&cmd_ethertype_filter_mac_addr,
9652 (void *)&cmd_ethertype_filter_ethertype,
9653 (void *)&cmd_ethertype_filter_ethertype_value,
9654 (void *)&cmd_ethertype_filter_drop,
9655 (void *)&cmd_ethertype_filter_queue,
9656 (void *)&cmd_ethertype_filter_queue_id,
9661 /* *** deal with flow director filter *** */
9662 struct cmd_flow_director_result {
9663 cmdline_fixed_string_t flow_director_filter;
9665 cmdline_fixed_string_t mode;
9666 cmdline_fixed_string_t mode_value;
9667 cmdline_fixed_string_t ops;
9668 cmdline_fixed_string_t flow;
9669 cmdline_fixed_string_t flow_type;
9670 cmdline_fixed_string_t ether;
9671 uint16_t ether_type;
9672 cmdline_fixed_string_t src;
9673 cmdline_ipaddr_t ip_src;
9675 cmdline_fixed_string_t dst;
9676 cmdline_ipaddr_t ip_dst;
9678 cmdline_fixed_string_t verify_tag;
9679 uint32_t verify_tag_value;
9680 cmdline_ipaddr_t tos;
9682 cmdline_ipaddr_t proto;
9683 uint8_t proto_value;
9684 cmdline_ipaddr_t ttl;
9686 cmdline_fixed_string_t vlan;
9687 uint16_t vlan_value;
9688 cmdline_fixed_string_t flexbytes;
9689 cmdline_fixed_string_t flexbytes_value;
9690 cmdline_fixed_string_t pf_vf;
9691 cmdline_fixed_string_t drop;
9692 cmdline_fixed_string_t queue;
9694 cmdline_fixed_string_t fd_id;
9695 uint32_t fd_id_value;
9696 cmdline_fixed_string_t mac;
9697 struct ether_addr mac_addr;
9698 cmdline_fixed_string_t tunnel;
9699 cmdline_fixed_string_t tunnel_type;
9700 cmdline_fixed_string_t tunnel_id;
9701 uint32_t tunnel_id_value;
9705 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
9708 const char *p, *p0 = q_arg;
9710 unsigned long int_fld;
9711 char *str_fld[max_num];
9716 p = strchr(p0, '(');
9720 p0 = strchr(p, ')');
9725 if (size >= sizeof(s))
9728 snprintf(s, sizeof(s), "%.*s", size, p);
9729 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
9730 if (ret < 0 || ret > max_num)
9732 for (i = 0; i < ret; i++) {
9734 int_fld = strtoul(str_fld[i], &end, 0);
9735 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
9737 flexbytes[i] = (uint8_t)int_fld;
9743 str2flowtype(char *string)
9746 static const struct {
9749 } flowtype_str[] = {
9750 {"raw", RTE_ETH_FLOW_RAW},
9751 {"ipv4", RTE_ETH_FLOW_IPV4},
9752 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
9753 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
9754 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
9755 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
9756 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
9757 {"ipv6", RTE_ETH_FLOW_IPV6},
9758 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
9759 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
9760 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
9761 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
9762 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
9763 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
9766 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
9767 if (!strcmp(flowtype_str[i].str, string))
9768 return flowtype_str[i].type;
9771 if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64)
9772 return (uint16_t)atoi(string);
9774 return RTE_ETH_FLOW_UNKNOWN;
9777 static enum rte_eth_fdir_tunnel_type
9778 str2fdir_tunneltype(char *string)
9782 static const struct {
9784 enum rte_eth_fdir_tunnel_type type;
9785 } tunneltype_str[] = {
9786 {"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE},
9787 {"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN},
9790 for (i = 0; i < RTE_DIM(tunneltype_str); i++) {
9791 if (!strcmp(tunneltype_str[i].str, string))
9792 return tunneltype_str[i].type;
9794 return RTE_FDIR_TUNNEL_TYPE_UNKNOWN;
9797 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
9799 if ((ip_addr).family == AF_INET) \
9800 (ip) = (ip_addr).addr.ipv4.s_addr; \
9802 printf("invalid parameter.\n"); \
9807 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
9809 if ((ip_addr).family == AF_INET6) \
9811 &((ip_addr).addr.ipv6), \
9812 sizeof(struct in6_addr)); \
9814 printf("invalid parameter.\n"); \
9820 cmd_flow_director_filter_parsed(void *parsed_result,
9821 __attribute__((unused)) struct cmdline *cl,
9822 __attribute__((unused)) void *data)
9824 struct cmd_flow_director_result *res = parsed_result;
9825 struct rte_eth_fdir_filter entry;
9826 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
9828 unsigned long vf_id;
9831 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
9833 printf("flow director is not supported on port %u.\n",
9837 memset(flexbytes, 0, sizeof(flexbytes));
9838 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
9840 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
9841 if (strcmp(res->mode_value, "MAC-VLAN")) {
9842 printf("Please set mode to MAC-VLAN.\n");
9845 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
9846 if (strcmp(res->mode_value, "Tunnel")) {
9847 printf("Please set mode to Tunnel.\n");
9851 if (strcmp(res->mode_value, "IP")) {
9852 printf("Please set mode to IP.\n");
9855 entry.input.flow_type = str2flowtype(res->flow_type);
9858 ret = parse_flexbytes(res->flexbytes_value,
9860 RTE_ETH_FDIR_MAX_FLEXLEN);
9862 printf("error: Cannot parse flexbytes input.\n");
9866 switch (entry.input.flow_type) {
9867 case RTE_ETH_FLOW_FRAG_IPV4:
9868 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
9869 entry.input.flow.ip4_flow.proto = res->proto_value;
9871 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
9872 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
9873 IPV4_ADDR_TO_UINT(res->ip_dst,
9874 entry.input.flow.ip4_flow.dst_ip);
9875 IPV4_ADDR_TO_UINT(res->ip_src,
9876 entry.input.flow.ip4_flow.src_ip);
9877 entry.input.flow.ip4_flow.tos = res->tos_value;
9878 entry.input.flow.ip4_flow.ttl = res->ttl_value;
9879 /* need convert to big endian. */
9880 entry.input.flow.udp4_flow.dst_port =
9881 rte_cpu_to_be_16(res->port_dst);
9882 entry.input.flow.udp4_flow.src_port =
9883 rte_cpu_to_be_16(res->port_src);
9885 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
9886 IPV4_ADDR_TO_UINT(res->ip_dst,
9887 entry.input.flow.sctp4_flow.ip.dst_ip);
9888 IPV4_ADDR_TO_UINT(res->ip_src,
9889 entry.input.flow.sctp4_flow.ip.src_ip);
9890 entry.input.flow.ip4_flow.tos = res->tos_value;
9891 entry.input.flow.ip4_flow.ttl = res->ttl_value;
9892 /* need convert to big endian. */
9893 entry.input.flow.sctp4_flow.dst_port =
9894 rte_cpu_to_be_16(res->port_dst);
9895 entry.input.flow.sctp4_flow.src_port =
9896 rte_cpu_to_be_16(res->port_src);
9897 entry.input.flow.sctp4_flow.verify_tag =
9898 rte_cpu_to_be_32(res->verify_tag_value);
9900 case RTE_ETH_FLOW_FRAG_IPV6:
9901 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
9902 entry.input.flow.ipv6_flow.proto = res->proto_value;
9904 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
9905 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
9906 IPV6_ADDR_TO_ARRAY(res->ip_dst,
9907 entry.input.flow.ipv6_flow.dst_ip);
9908 IPV6_ADDR_TO_ARRAY(res->ip_src,
9909 entry.input.flow.ipv6_flow.src_ip);
9910 entry.input.flow.ipv6_flow.tc = res->tos_value;
9911 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
9912 /* need convert to big endian. */
9913 entry.input.flow.udp6_flow.dst_port =
9914 rte_cpu_to_be_16(res->port_dst);
9915 entry.input.flow.udp6_flow.src_port =
9916 rte_cpu_to_be_16(res->port_src);
9918 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
9919 IPV6_ADDR_TO_ARRAY(res->ip_dst,
9920 entry.input.flow.sctp6_flow.ip.dst_ip);
9921 IPV6_ADDR_TO_ARRAY(res->ip_src,
9922 entry.input.flow.sctp6_flow.ip.src_ip);
9923 entry.input.flow.ipv6_flow.tc = res->tos_value;
9924 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
9925 /* need convert to big endian. */
9926 entry.input.flow.sctp6_flow.dst_port =
9927 rte_cpu_to_be_16(res->port_dst);
9928 entry.input.flow.sctp6_flow.src_port =
9929 rte_cpu_to_be_16(res->port_src);
9930 entry.input.flow.sctp6_flow.verify_tag =
9931 rte_cpu_to_be_32(res->verify_tag_value);
9933 case RTE_ETH_FLOW_L2_PAYLOAD:
9934 entry.input.flow.l2_flow.ether_type =
9935 rte_cpu_to_be_16(res->ether_type);
9941 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN)
9942 rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr,
9944 sizeof(struct ether_addr));
9946 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
9947 rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr,
9949 sizeof(struct ether_addr));
9950 entry.input.flow.tunnel_flow.tunnel_type =
9951 str2fdir_tunneltype(res->tunnel_type);
9952 entry.input.flow.tunnel_flow.tunnel_id =
9953 rte_cpu_to_be_32(res->tunnel_id_value);
9956 rte_memcpy(entry.input.flow_ext.flexbytes,
9958 RTE_ETH_FDIR_MAX_FLEXLEN);
9960 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
9962 entry.action.flex_off = 0; /*use 0 by default */
9963 if (!strcmp(res->drop, "drop"))
9964 entry.action.behavior = RTE_ETH_FDIR_REJECT;
9966 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
9968 if (fdir_conf.mode != RTE_FDIR_MODE_PERFECT_MAC_VLAN &&
9969 fdir_conf.mode != RTE_FDIR_MODE_PERFECT_TUNNEL) {
9970 if (!strcmp(res->pf_vf, "pf"))
9971 entry.input.flow_ext.is_vf = 0;
9972 else if (!strncmp(res->pf_vf, "vf", 2)) {
9973 struct rte_eth_dev_info dev_info;
9975 memset(&dev_info, 0, sizeof(dev_info));
9976 rte_eth_dev_info_get(res->port_id, &dev_info);
9978 vf_id = strtoul(res->pf_vf + 2, &end, 10);
9979 if (errno != 0 || *end != '\0' ||
9980 vf_id >= dev_info.max_vfs) {
9981 printf("invalid parameter %s.\n", res->pf_vf);
9984 entry.input.flow_ext.is_vf = 1;
9985 entry.input.flow_ext.dst_id = (uint16_t)vf_id;
9987 printf("invalid parameter %s.\n", res->pf_vf);
9992 /* set to report FD ID by default */
9993 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
9994 entry.action.rx_queue = res->queue_id;
9995 entry.soft_id = res->fd_id_value;
9996 if (!strcmp(res->ops, "add"))
9997 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
9998 RTE_ETH_FILTER_ADD, &entry);
9999 else if (!strcmp(res->ops, "del"))
10000 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10001 RTE_ETH_FILTER_DELETE, &entry);
10003 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10004 RTE_ETH_FILTER_UPDATE, &entry);
10006 printf("flow director programming error: (%s)\n",
10010 cmdline_parse_token_string_t cmd_flow_director_filter =
10011 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10012 flow_director_filter, "flow_director_filter");
10013 cmdline_parse_token_num_t cmd_flow_director_port_id =
10014 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10016 cmdline_parse_token_string_t cmd_flow_director_ops =
10017 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10018 ops, "add#del#update");
10019 cmdline_parse_token_string_t cmd_flow_director_flow =
10020 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10022 cmdline_parse_token_string_t cmd_flow_director_flow_type =
10023 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10024 flow_type, "ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
10025 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload");
10026 cmdline_parse_token_string_t cmd_flow_director_ether =
10027 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10029 cmdline_parse_token_num_t cmd_flow_director_ether_type =
10030 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10031 ether_type, UINT16);
10032 cmdline_parse_token_string_t cmd_flow_director_src =
10033 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10035 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
10036 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
10038 cmdline_parse_token_num_t cmd_flow_director_port_src =
10039 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10041 cmdline_parse_token_string_t cmd_flow_director_dst =
10042 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10044 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
10045 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
10047 cmdline_parse_token_num_t cmd_flow_director_port_dst =
10048 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10050 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
10051 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10052 verify_tag, "verify_tag");
10053 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
10054 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10055 verify_tag_value, UINT32);
10056 cmdline_parse_token_string_t cmd_flow_director_tos =
10057 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10059 cmdline_parse_token_num_t cmd_flow_director_tos_value =
10060 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10062 cmdline_parse_token_string_t cmd_flow_director_proto =
10063 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10065 cmdline_parse_token_num_t cmd_flow_director_proto_value =
10066 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10067 proto_value, UINT8);
10068 cmdline_parse_token_string_t cmd_flow_director_ttl =
10069 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10071 cmdline_parse_token_num_t cmd_flow_director_ttl_value =
10072 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10074 cmdline_parse_token_string_t cmd_flow_director_vlan =
10075 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10077 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
10078 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10079 vlan_value, UINT16);
10080 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
10081 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10082 flexbytes, "flexbytes");
10083 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
10084 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10085 flexbytes_value, NULL);
10086 cmdline_parse_token_string_t cmd_flow_director_drop =
10087 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10089 cmdline_parse_token_string_t cmd_flow_director_pf_vf =
10090 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10092 cmdline_parse_token_string_t cmd_flow_director_queue =
10093 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10095 cmdline_parse_token_num_t cmd_flow_director_queue_id =
10096 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10098 cmdline_parse_token_string_t cmd_flow_director_fd_id =
10099 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10101 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
10102 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10103 fd_id_value, UINT32);
10105 cmdline_parse_token_string_t cmd_flow_director_mode =
10106 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10108 cmdline_parse_token_string_t cmd_flow_director_mode_ip =
10109 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10111 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan =
10112 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10113 mode_value, "MAC-VLAN");
10114 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel =
10115 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10116 mode_value, "Tunnel");
10117 cmdline_parse_token_string_t cmd_flow_director_mac =
10118 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10120 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr =
10121 TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result,
10123 cmdline_parse_token_string_t cmd_flow_director_tunnel =
10124 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10126 cmdline_parse_token_string_t cmd_flow_director_tunnel_type =
10127 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10128 tunnel_type, "NVGRE#VxLAN");
10129 cmdline_parse_token_string_t cmd_flow_director_tunnel_id =
10130 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10131 tunnel_id, "tunnel-id");
10132 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value =
10133 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10134 tunnel_id_value, UINT32);
10136 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
10137 .f = cmd_flow_director_filter_parsed,
10139 .help_str = "flow_director_filter <port_id> mode IP add|del|update flow"
10140 " ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
10141 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
10142 "l2_payload src <src_ip> dst <dst_ip> tos <tos_value> "
10143 "proto <proto_value> ttl <ttl_value> vlan <vlan_value> "
10144 "flexbytes <flexbyte_vaues> drop|fw <pf_vf> queue <queue_id> "
10145 "fd_id <fd_id_value>: "
10146 "Add or delete an ip flow director entry on NIC",
10148 (void *)&cmd_flow_director_filter,
10149 (void *)&cmd_flow_director_port_id,
10150 (void *)&cmd_flow_director_mode,
10151 (void *)&cmd_flow_director_mode_ip,
10152 (void *)&cmd_flow_director_ops,
10153 (void *)&cmd_flow_director_flow,
10154 (void *)&cmd_flow_director_flow_type,
10155 (void *)&cmd_flow_director_src,
10156 (void *)&cmd_flow_director_ip_src,
10157 (void *)&cmd_flow_director_dst,
10158 (void *)&cmd_flow_director_ip_dst,
10159 (void *)&cmd_flow_director_tos,
10160 (void *)&cmd_flow_director_tos_value,
10161 (void *)&cmd_flow_director_proto,
10162 (void *)&cmd_flow_director_proto_value,
10163 (void *)&cmd_flow_director_ttl,
10164 (void *)&cmd_flow_director_ttl_value,
10165 (void *)&cmd_flow_director_vlan,
10166 (void *)&cmd_flow_director_vlan_value,
10167 (void *)&cmd_flow_director_flexbytes,
10168 (void *)&cmd_flow_director_flexbytes_value,
10169 (void *)&cmd_flow_director_drop,
10170 (void *)&cmd_flow_director_pf_vf,
10171 (void *)&cmd_flow_director_queue,
10172 (void *)&cmd_flow_director_queue_id,
10173 (void *)&cmd_flow_director_fd_id,
10174 (void *)&cmd_flow_director_fd_id_value,
10179 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
10180 .f = cmd_flow_director_filter_parsed,
10182 .help_str = "flow_director_filter ... : Add or delete an udp/tcp flow "
10183 "director entry on NIC",
10185 (void *)&cmd_flow_director_filter,
10186 (void *)&cmd_flow_director_port_id,
10187 (void *)&cmd_flow_director_mode,
10188 (void *)&cmd_flow_director_mode_ip,
10189 (void *)&cmd_flow_director_ops,
10190 (void *)&cmd_flow_director_flow,
10191 (void *)&cmd_flow_director_flow_type,
10192 (void *)&cmd_flow_director_src,
10193 (void *)&cmd_flow_director_ip_src,
10194 (void *)&cmd_flow_director_port_src,
10195 (void *)&cmd_flow_director_dst,
10196 (void *)&cmd_flow_director_ip_dst,
10197 (void *)&cmd_flow_director_port_dst,
10198 (void *)&cmd_flow_director_tos,
10199 (void *)&cmd_flow_director_tos_value,
10200 (void *)&cmd_flow_director_ttl,
10201 (void *)&cmd_flow_director_ttl_value,
10202 (void *)&cmd_flow_director_vlan,
10203 (void *)&cmd_flow_director_vlan_value,
10204 (void *)&cmd_flow_director_flexbytes,
10205 (void *)&cmd_flow_director_flexbytes_value,
10206 (void *)&cmd_flow_director_drop,
10207 (void *)&cmd_flow_director_pf_vf,
10208 (void *)&cmd_flow_director_queue,
10209 (void *)&cmd_flow_director_queue_id,
10210 (void *)&cmd_flow_director_fd_id,
10211 (void *)&cmd_flow_director_fd_id_value,
10216 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
10217 .f = cmd_flow_director_filter_parsed,
10219 .help_str = "flow_director_filter ... : Add or delete a sctp flow "
10220 "director entry on NIC",
10222 (void *)&cmd_flow_director_filter,
10223 (void *)&cmd_flow_director_port_id,
10224 (void *)&cmd_flow_director_mode,
10225 (void *)&cmd_flow_director_mode_ip,
10226 (void *)&cmd_flow_director_ops,
10227 (void *)&cmd_flow_director_flow,
10228 (void *)&cmd_flow_director_flow_type,
10229 (void *)&cmd_flow_director_src,
10230 (void *)&cmd_flow_director_ip_src,
10231 (void *)&cmd_flow_director_port_dst,
10232 (void *)&cmd_flow_director_dst,
10233 (void *)&cmd_flow_director_ip_dst,
10234 (void *)&cmd_flow_director_port_dst,
10235 (void *)&cmd_flow_director_verify_tag,
10236 (void *)&cmd_flow_director_verify_tag_value,
10237 (void *)&cmd_flow_director_tos,
10238 (void *)&cmd_flow_director_tos_value,
10239 (void *)&cmd_flow_director_ttl,
10240 (void *)&cmd_flow_director_ttl_value,
10241 (void *)&cmd_flow_director_vlan,
10242 (void *)&cmd_flow_director_vlan_value,
10243 (void *)&cmd_flow_director_flexbytes,
10244 (void *)&cmd_flow_director_flexbytes_value,
10245 (void *)&cmd_flow_director_drop,
10246 (void *)&cmd_flow_director_pf_vf,
10247 (void *)&cmd_flow_director_queue,
10248 (void *)&cmd_flow_director_queue_id,
10249 (void *)&cmd_flow_director_fd_id,
10250 (void *)&cmd_flow_director_fd_id_value,
10255 cmdline_parse_inst_t cmd_add_del_l2_flow_director = {
10256 .f = cmd_flow_director_filter_parsed,
10258 .help_str = "flow_director_filter ... : Add or delete a L2 flow "
10259 "director entry on NIC",
10261 (void *)&cmd_flow_director_filter,
10262 (void *)&cmd_flow_director_port_id,
10263 (void *)&cmd_flow_director_mode,
10264 (void *)&cmd_flow_director_mode_ip,
10265 (void *)&cmd_flow_director_ops,
10266 (void *)&cmd_flow_director_flow,
10267 (void *)&cmd_flow_director_flow_type,
10268 (void *)&cmd_flow_director_ether,
10269 (void *)&cmd_flow_director_ether_type,
10270 (void *)&cmd_flow_director_flexbytes,
10271 (void *)&cmd_flow_director_flexbytes_value,
10272 (void *)&cmd_flow_director_drop,
10273 (void *)&cmd_flow_director_pf_vf,
10274 (void *)&cmd_flow_director_queue,
10275 (void *)&cmd_flow_director_queue_id,
10276 (void *)&cmd_flow_director_fd_id,
10277 (void *)&cmd_flow_director_fd_id_value,
10282 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = {
10283 .f = cmd_flow_director_filter_parsed,
10285 .help_str = "flow_director_filter ... : Add or delete a MAC VLAN flow "
10286 "director entry on NIC",
10288 (void *)&cmd_flow_director_filter,
10289 (void *)&cmd_flow_director_port_id,
10290 (void *)&cmd_flow_director_mode,
10291 (void *)&cmd_flow_director_mode_mac_vlan,
10292 (void *)&cmd_flow_director_ops,
10293 (void *)&cmd_flow_director_mac,
10294 (void *)&cmd_flow_director_mac_addr,
10295 (void *)&cmd_flow_director_vlan,
10296 (void *)&cmd_flow_director_vlan_value,
10297 (void *)&cmd_flow_director_flexbytes,
10298 (void *)&cmd_flow_director_flexbytes_value,
10299 (void *)&cmd_flow_director_drop,
10300 (void *)&cmd_flow_director_queue,
10301 (void *)&cmd_flow_director_queue_id,
10302 (void *)&cmd_flow_director_fd_id,
10303 (void *)&cmd_flow_director_fd_id_value,
10308 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = {
10309 .f = cmd_flow_director_filter_parsed,
10311 .help_str = "flow_director_filter ... : Add or delete a tunnel flow "
10312 "director entry on NIC",
10314 (void *)&cmd_flow_director_filter,
10315 (void *)&cmd_flow_director_port_id,
10316 (void *)&cmd_flow_director_mode,
10317 (void *)&cmd_flow_director_mode_tunnel,
10318 (void *)&cmd_flow_director_ops,
10319 (void *)&cmd_flow_director_mac,
10320 (void *)&cmd_flow_director_mac_addr,
10321 (void *)&cmd_flow_director_vlan,
10322 (void *)&cmd_flow_director_vlan_value,
10323 (void *)&cmd_flow_director_tunnel,
10324 (void *)&cmd_flow_director_tunnel_type,
10325 (void *)&cmd_flow_director_tunnel_id,
10326 (void *)&cmd_flow_director_tunnel_id_value,
10327 (void *)&cmd_flow_director_flexbytes,
10328 (void *)&cmd_flow_director_flexbytes_value,
10329 (void *)&cmd_flow_director_drop,
10330 (void *)&cmd_flow_director_queue,
10331 (void *)&cmd_flow_director_queue_id,
10332 (void *)&cmd_flow_director_fd_id,
10333 (void *)&cmd_flow_director_fd_id_value,
10338 struct cmd_flush_flow_director_result {
10339 cmdline_fixed_string_t flush_flow_director;
10343 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
10344 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
10345 flush_flow_director, "flush_flow_director");
10346 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
10347 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
10351 cmd_flush_flow_director_parsed(void *parsed_result,
10352 __attribute__((unused)) struct cmdline *cl,
10353 __attribute__((unused)) void *data)
10355 struct cmd_flow_director_result *res = parsed_result;
10358 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
10360 printf("flow director is not supported on port %u.\n",
10365 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10366 RTE_ETH_FILTER_FLUSH, NULL);
10368 printf("flow director table flushing error: (%s)\n",
10372 cmdline_parse_inst_t cmd_flush_flow_director = {
10373 .f = cmd_flush_flow_director_parsed,
10375 .help_str = "flush_flow_director <port_id>: "
10376 "Flush all flow director entries of a device on NIC",
10378 (void *)&cmd_flush_flow_director_flush,
10379 (void *)&cmd_flush_flow_director_port_id,
10384 /* *** deal with flow director mask *** */
10385 struct cmd_flow_director_mask_result {
10386 cmdline_fixed_string_t flow_director_mask;
10388 cmdline_fixed_string_t mode;
10389 cmdline_fixed_string_t mode_value;
10390 cmdline_fixed_string_t vlan;
10391 uint16_t vlan_mask;
10392 cmdline_fixed_string_t src_mask;
10393 cmdline_ipaddr_t ipv4_src;
10394 cmdline_ipaddr_t ipv6_src;
10396 cmdline_fixed_string_t dst_mask;
10397 cmdline_ipaddr_t ipv4_dst;
10398 cmdline_ipaddr_t ipv6_dst;
10400 cmdline_fixed_string_t mac;
10401 uint8_t mac_addr_byte_mask;
10402 cmdline_fixed_string_t tunnel_id;
10403 uint32_t tunnel_id_mask;
10404 cmdline_fixed_string_t tunnel_type;
10405 uint8_t tunnel_type_mask;
10409 cmd_flow_director_mask_parsed(void *parsed_result,
10410 __attribute__((unused)) struct cmdline *cl,
10411 __attribute__((unused)) void *data)
10413 struct cmd_flow_director_mask_result *res = parsed_result;
10414 struct rte_eth_fdir_masks *mask;
10415 struct rte_port *port;
10417 if (res->port_id > nb_ports) {
10418 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
10422 port = &ports[res->port_id];
10423 /** Check if the port is not started **/
10424 if (port->port_status != RTE_PORT_STOPPED) {
10425 printf("Please stop port %d first\n", res->port_id);
10429 mask = &port->dev_conf.fdir_conf.mask;
10431 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
10432 if (strcmp(res->mode_value, "MAC-VLAN")) {
10433 printf("Please set mode to MAC-VLAN.\n");
10437 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10438 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
10439 if (strcmp(res->mode_value, "Tunnel")) {
10440 printf("Please set mode to Tunnel.\n");
10444 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10445 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
10446 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
10447 mask->tunnel_type_mask = res->tunnel_type_mask;
10449 if (strcmp(res->mode_value, "IP")) {
10450 printf("Please set mode to IP.\n");
10454 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10455 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
10456 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
10457 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
10458 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
10459 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
10460 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
10463 cmd_reconfig_device_queue(res->port_id, 1, 1);
10466 cmdline_parse_token_string_t cmd_flow_director_mask =
10467 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10468 flow_director_mask, "flow_director_mask");
10469 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
10470 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10472 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
10473 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10475 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
10476 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10477 vlan_mask, UINT16);
10478 cmdline_parse_token_string_t cmd_flow_director_mask_src =
10479 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10480 src_mask, "src_mask");
10481 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
10482 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10484 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
10485 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10487 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
10488 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10490 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
10491 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10492 dst_mask, "dst_mask");
10493 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
10494 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10496 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
10497 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10499 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
10500 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10503 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
10504 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10506 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
10507 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10509 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
10510 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10511 mode_value, "MAC-VLAN");
10512 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
10513 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10514 mode_value, "Tunnel");
10515 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
10516 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10518 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
10519 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10520 mac_addr_byte_mask, UINT8);
10521 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
10522 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10523 tunnel_type, "tunnel-type");
10524 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
10525 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10526 tunnel_type_mask, UINT8);
10527 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
10528 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10529 tunnel_id, "tunnel-id");
10530 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
10531 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10532 tunnel_id_mask, UINT32);
10534 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
10535 .f = cmd_flow_director_mask_parsed,
10537 .help_str = "flow_director_mask ... : "
10538 "Set IP mode flow director's mask on NIC",
10540 (void *)&cmd_flow_director_mask,
10541 (void *)&cmd_flow_director_mask_port_id,
10542 (void *)&cmd_flow_director_mask_mode,
10543 (void *)&cmd_flow_director_mask_mode_ip,
10544 (void *)&cmd_flow_director_mask_vlan,
10545 (void *)&cmd_flow_director_mask_vlan_value,
10546 (void *)&cmd_flow_director_mask_src,
10547 (void *)&cmd_flow_director_mask_ipv4_src,
10548 (void *)&cmd_flow_director_mask_ipv6_src,
10549 (void *)&cmd_flow_director_mask_port_src,
10550 (void *)&cmd_flow_director_mask_dst,
10551 (void *)&cmd_flow_director_mask_ipv4_dst,
10552 (void *)&cmd_flow_director_mask_ipv6_dst,
10553 (void *)&cmd_flow_director_mask_port_dst,
10558 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
10559 .f = cmd_flow_director_mask_parsed,
10561 .help_str = "flow_director_mask ... : Set MAC VLAN mode "
10562 "flow director's mask on NIC",
10564 (void *)&cmd_flow_director_mask,
10565 (void *)&cmd_flow_director_mask_port_id,
10566 (void *)&cmd_flow_director_mask_mode,
10567 (void *)&cmd_flow_director_mask_mode_mac_vlan,
10568 (void *)&cmd_flow_director_mask_vlan,
10569 (void *)&cmd_flow_director_mask_vlan_value,
10574 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
10575 .f = cmd_flow_director_mask_parsed,
10577 .help_str = "flow_director_mask ... : Set tunnel mode "
10578 "flow director's mask on NIC",
10580 (void *)&cmd_flow_director_mask,
10581 (void *)&cmd_flow_director_mask_port_id,
10582 (void *)&cmd_flow_director_mask_mode,
10583 (void *)&cmd_flow_director_mask_mode_tunnel,
10584 (void *)&cmd_flow_director_mask_vlan,
10585 (void *)&cmd_flow_director_mask_vlan_value,
10586 (void *)&cmd_flow_director_mask_mac,
10587 (void *)&cmd_flow_director_mask_mac_value,
10588 (void *)&cmd_flow_director_mask_tunnel_type,
10589 (void *)&cmd_flow_director_mask_tunnel_type_value,
10590 (void *)&cmd_flow_director_mask_tunnel_id,
10591 (void *)&cmd_flow_director_mask_tunnel_id_value,
10596 /* *** deal with flow director mask on flexible payload *** */
10597 struct cmd_flow_director_flex_mask_result {
10598 cmdline_fixed_string_t flow_director_flexmask;
10600 cmdline_fixed_string_t flow;
10601 cmdline_fixed_string_t flow_type;
10602 cmdline_fixed_string_t mask;
10606 cmd_flow_director_flex_mask_parsed(void *parsed_result,
10607 __attribute__((unused)) struct cmdline *cl,
10608 __attribute__((unused)) void *data)
10610 struct cmd_flow_director_flex_mask_result *res = parsed_result;
10611 struct rte_eth_fdir_info fdir_info;
10612 struct rte_eth_fdir_flex_mask flex_mask;
10613 struct rte_port *port;
10614 uint32_t flow_type_mask;
10618 if (res->port_id > nb_ports) {
10619 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
10623 port = &ports[res->port_id];
10624 /** Check if the port is not started **/
10625 if (port->port_status != RTE_PORT_STOPPED) {
10626 printf("Please stop port %d first\n", res->port_id);
10630 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
10631 ret = parse_flexbytes(res->mask,
10633 RTE_ETH_FDIR_MAX_FLEXLEN);
10635 printf("error: Cannot parse mask input.\n");
10639 memset(&fdir_info, 0, sizeof(fdir_info));
10640 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10641 RTE_ETH_FILTER_INFO, &fdir_info);
10643 printf("Cannot get FDir filter info\n");
10647 if (!strcmp(res->flow_type, "none")) {
10648 /* means don't specify the flow type */
10649 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN;
10650 for (i = 0; i < RTE_ETH_FLOW_MAX; i++)
10651 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i],
10652 0, sizeof(struct rte_eth_fdir_flex_mask));
10653 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1;
10654 rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0],
10656 sizeof(struct rte_eth_fdir_flex_mask));
10657 cmd_reconfig_device_queue(res->port_id, 1, 1);
10660 flow_type_mask = fdir_info.flow_types_mask[0];
10661 if (!strcmp(res->flow_type, "all")) {
10662 if (!flow_type_mask) {
10663 printf("No flow type supported\n");
10666 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
10667 if (flow_type_mask & (1 << i)) {
10668 flex_mask.flow_type = i;
10669 fdir_set_flex_mask(res->port_id, &flex_mask);
10672 cmd_reconfig_device_queue(res->port_id, 1, 1);
10675 flex_mask.flow_type = str2flowtype(res->flow_type);
10676 if (!(flow_type_mask & (1 << flex_mask.flow_type))) {
10677 printf("Flow type %s not supported on port %d\n",
10678 res->flow_type, res->port_id);
10681 fdir_set_flex_mask(res->port_id, &flex_mask);
10682 cmd_reconfig_device_queue(res->port_id, 1, 1);
10685 cmdline_parse_token_string_t cmd_flow_director_flexmask =
10686 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
10687 flow_director_flexmask,
10688 "flow_director_flex_mask");
10689 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
10690 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
10692 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
10693 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
10695 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
10696 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
10697 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
10698 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all");
10699 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
10700 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
10703 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
10704 .f = cmd_flow_director_flex_mask_parsed,
10706 .help_str = "flow_director_flex_mask ... : "
10707 "Set flow director's flex mask on NIC",
10709 (void *)&cmd_flow_director_flexmask,
10710 (void *)&cmd_flow_director_flexmask_port_id,
10711 (void *)&cmd_flow_director_flexmask_flow,
10712 (void *)&cmd_flow_director_flexmask_flow_type,
10713 (void *)&cmd_flow_director_flexmask_mask,
10718 /* *** deal with flow director flexible payload configuration *** */
10719 struct cmd_flow_director_flexpayload_result {
10720 cmdline_fixed_string_t flow_director_flexpayload;
10722 cmdline_fixed_string_t payload_layer;
10723 cmdline_fixed_string_t payload_cfg;
10727 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
10730 const char *p, *p0 = q_arg;
10732 unsigned long int_fld;
10733 char *str_fld[max_num];
10738 p = strchr(p0, '(');
10742 p0 = strchr(p, ')');
10747 if (size >= sizeof(s))
10750 snprintf(s, sizeof(s), "%.*s", size, p);
10751 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
10752 if (ret < 0 || ret > max_num)
10754 for (i = 0; i < ret; i++) {
10756 int_fld = strtoul(str_fld[i], &end, 0);
10757 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
10759 offsets[i] = (uint16_t)int_fld;
10765 cmd_flow_director_flxpld_parsed(void *parsed_result,
10766 __attribute__((unused)) struct cmdline *cl,
10767 __attribute__((unused)) void *data)
10769 struct cmd_flow_director_flexpayload_result *res = parsed_result;
10770 struct rte_eth_flex_payload_cfg flex_cfg;
10771 struct rte_port *port;
10774 if (res->port_id > nb_ports) {
10775 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
10779 port = &ports[res->port_id];
10780 /** Check if the port is not started **/
10781 if (port->port_status != RTE_PORT_STOPPED) {
10782 printf("Please stop port %d first\n", res->port_id);
10786 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
10788 if (!strcmp(res->payload_layer, "raw"))
10789 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
10790 else if (!strcmp(res->payload_layer, "l2"))
10791 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
10792 else if (!strcmp(res->payload_layer, "l3"))
10793 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
10794 else if (!strcmp(res->payload_layer, "l4"))
10795 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
10797 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
10798 RTE_ETH_FDIR_MAX_FLEXLEN);
10800 printf("error: Cannot parse flex payload input.\n");
10804 fdir_set_flex_payload(res->port_id, &flex_cfg);
10805 cmd_reconfig_device_queue(res->port_id, 1, 1);
10808 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
10809 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10810 flow_director_flexpayload,
10811 "flow_director_flex_payload");
10812 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
10813 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10815 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
10816 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10817 payload_layer, "raw#l2#l3#l4");
10818 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
10819 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10820 payload_cfg, NULL);
10822 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
10823 .f = cmd_flow_director_flxpld_parsed,
10825 .help_str = "flow_director_flexpayload ... : "
10826 "Set flow director's flex payload on NIC",
10828 (void *)&cmd_flow_director_flexpayload,
10829 (void *)&cmd_flow_director_flexpayload_port_id,
10830 (void *)&cmd_flow_director_flexpayload_payload_layer,
10831 (void *)&cmd_flow_director_flexpayload_payload_cfg,
10836 /* Generic flow interface command. */
10837 extern cmdline_parse_inst_t cmd_flow;
10839 /* *** Classification Filters Control *** */
10840 /* *** Get symmetric hash enable per port *** */
10841 struct cmd_get_sym_hash_ena_per_port_result {
10842 cmdline_fixed_string_t get_sym_hash_ena_per_port;
10847 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
10848 __rte_unused struct cmdline *cl,
10849 __rte_unused void *data)
10851 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
10852 struct rte_eth_hash_filter_info info;
10855 if (rte_eth_dev_filter_supported(res->port_id,
10856 RTE_ETH_FILTER_HASH) < 0) {
10857 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
10862 memset(&info, 0, sizeof(info));
10863 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
10864 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
10865 RTE_ETH_FILTER_GET, &info);
10868 printf("Cannot get symmetric hash enable per port "
10869 "on port %u\n", res->port_id);
10873 printf("Symmetric hash is %s on port %u\n", info.info.enable ?
10874 "enabled" : "disabled", res->port_id);
10877 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
10878 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
10879 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
10880 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
10881 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
10884 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
10885 .f = cmd_get_sym_hash_per_port_parsed,
10887 .help_str = "get_sym_hash_ena_per_port <port_id>",
10889 (void *)&cmd_get_sym_hash_ena_per_port_all,
10890 (void *)&cmd_get_sym_hash_ena_per_port_port_id,
10895 /* *** Set symmetric hash enable per port *** */
10896 struct cmd_set_sym_hash_ena_per_port_result {
10897 cmdline_fixed_string_t set_sym_hash_ena_per_port;
10898 cmdline_fixed_string_t enable;
10903 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
10904 __rte_unused struct cmdline *cl,
10905 __rte_unused void *data)
10907 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
10908 struct rte_eth_hash_filter_info info;
10911 if (rte_eth_dev_filter_supported(res->port_id,
10912 RTE_ETH_FILTER_HASH) < 0) {
10913 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
10918 memset(&info, 0, sizeof(info));
10919 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
10920 if (!strcmp(res->enable, "enable"))
10921 info.info.enable = 1;
10922 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
10923 RTE_ETH_FILTER_SET, &info);
10925 printf("Cannot set symmetric hash enable per port on "
10926 "port %u\n", res->port_id);
10929 printf("Symmetric hash has been set to %s on port %u\n",
10930 res->enable, res->port_id);
10933 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
10934 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
10935 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
10936 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
10937 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
10939 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
10940 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
10941 enable, "enable#disable");
10943 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
10944 .f = cmd_set_sym_hash_per_port_parsed,
10946 .help_str = "set_sym_hash_ena_per_port <port_id> enable|disable",
10948 (void *)&cmd_set_sym_hash_ena_per_port_all,
10949 (void *)&cmd_set_sym_hash_ena_per_port_port_id,
10950 (void *)&cmd_set_sym_hash_ena_per_port_enable,
10955 /* Get global config of hash function */
10956 struct cmd_get_hash_global_config_result {
10957 cmdline_fixed_string_t get_hash_global_config;
10962 flowtype_to_str(uint16_t ftype)
10968 } ftype_table[] = {
10969 {"ipv4", RTE_ETH_FLOW_IPV4},
10970 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
10971 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
10972 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
10973 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
10974 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
10975 {"ipv6", RTE_ETH_FLOW_IPV6},
10976 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
10977 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
10978 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
10979 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
10980 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
10981 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
10982 {"port", RTE_ETH_FLOW_PORT},
10983 {"vxlan", RTE_ETH_FLOW_VXLAN},
10984 {"geneve", RTE_ETH_FLOW_GENEVE},
10985 {"nvgre", RTE_ETH_FLOW_NVGRE},
10988 for (i = 0; i < RTE_DIM(ftype_table); i++) {
10989 if (ftype_table[i].ftype == ftype)
10990 return ftype_table[i].str;
10997 cmd_get_hash_global_config_parsed(void *parsed_result,
10998 __rte_unused struct cmdline *cl,
10999 __rte_unused void *data)
11001 struct cmd_get_hash_global_config_result *res = parsed_result;
11002 struct rte_eth_hash_filter_info info;
11003 uint32_t idx, offset;
11008 if (rte_eth_dev_filter_supported(res->port_id,
11009 RTE_ETH_FILTER_HASH) < 0) {
11010 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
11015 memset(&info, 0, sizeof(info));
11016 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
11017 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11018 RTE_ETH_FILTER_GET, &info);
11020 printf("Cannot get hash global configurations by port %d\n",
11025 switch (info.info.global_conf.hash_func) {
11026 case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
11027 printf("Hash function is Toeplitz\n");
11029 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
11030 printf("Hash function is Simple XOR\n");
11033 printf("Unknown hash function\n");
11037 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) {
11038 idx = i / UINT32_BIT;
11039 offset = i % UINT32_BIT;
11040 if (!(info.info.global_conf.valid_bit_mask[idx] &
11043 str = flowtype_to_str(i);
11046 printf("Symmetric hash is %s globally for flow type %s "
11048 ((info.info.global_conf.sym_hash_enable_mask[idx] &
11049 (1UL << offset)) ? "enabled" : "disabled"), str,
11054 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
11055 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
11056 get_hash_global_config, "get_hash_global_config");
11057 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
11058 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
11061 cmdline_parse_inst_t cmd_get_hash_global_config = {
11062 .f = cmd_get_hash_global_config_parsed,
11064 .help_str = "get_hash_global_config <port_id>",
11066 (void *)&cmd_get_hash_global_config_all,
11067 (void *)&cmd_get_hash_global_config_port_id,
11072 /* Set global config of hash function */
11073 struct cmd_set_hash_global_config_result {
11074 cmdline_fixed_string_t set_hash_global_config;
11076 cmdline_fixed_string_t hash_func;
11077 cmdline_fixed_string_t flow_type;
11078 cmdline_fixed_string_t enable;
11082 cmd_set_hash_global_config_parsed(void *parsed_result,
11083 __rte_unused struct cmdline *cl,
11084 __rte_unused void *data)
11086 struct cmd_set_hash_global_config_result *res = parsed_result;
11087 struct rte_eth_hash_filter_info info;
11088 uint32_t ftype, idx, offset;
11091 if (rte_eth_dev_filter_supported(res->port_id,
11092 RTE_ETH_FILTER_HASH) < 0) {
11093 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
11097 memset(&info, 0, sizeof(info));
11098 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
11099 if (!strcmp(res->hash_func, "toeplitz"))
11100 info.info.global_conf.hash_func =
11101 RTE_ETH_HASH_FUNCTION_TOEPLITZ;
11102 else if (!strcmp(res->hash_func, "simple_xor"))
11103 info.info.global_conf.hash_func =
11104 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
11105 else if (!strcmp(res->hash_func, "default"))
11106 info.info.global_conf.hash_func =
11107 RTE_ETH_HASH_FUNCTION_DEFAULT;
11109 ftype = str2flowtype(res->flow_type);
11110 idx = ftype / (CHAR_BIT * sizeof(uint32_t));
11111 offset = ftype % (CHAR_BIT * sizeof(uint32_t));
11112 info.info.global_conf.valid_bit_mask[idx] |= (1UL << offset);
11113 if (!strcmp(res->enable, "enable"))
11114 info.info.global_conf.sym_hash_enable_mask[idx] |=
11116 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11117 RTE_ETH_FILTER_SET, &info);
11119 printf("Cannot set global hash configurations by port %d\n",
11122 printf("Global hash configurations have been set "
11123 "succcessfully by port %d\n", res->port_id);
11126 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
11127 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11128 set_hash_global_config, "set_hash_global_config");
11129 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
11130 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
11132 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
11133 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11134 hash_func, "toeplitz#simple_xor#default");
11135 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
11136 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11138 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
11139 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
11140 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
11141 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11142 enable, "enable#disable");
11144 cmdline_parse_inst_t cmd_set_hash_global_config = {
11145 .f = cmd_set_hash_global_config_parsed,
11147 .help_str = "set_hash_global_config <port_id> "
11148 "toeplitz|simple_xor|default "
11149 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
11150 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
11151 "l2_payload enable|disable",
11153 (void *)&cmd_set_hash_global_config_all,
11154 (void *)&cmd_set_hash_global_config_port_id,
11155 (void *)&cmd_set_hash_global_config_hash_func,
11156 (void *)&cmd_set_hash_global_config_flow_type,
11157 (void *)&cmd_set_hash_global_config_enable,
11162 /* Set hash input set */
11163 struct cmd_set_hash_input_set_result {
11164 cmdline_fixed_string_t set_hash_input_set;
11166 cmdline_fixed_string_t flow_type;
11167 cmdline_fixed_string_t inset_field;
11168 cmdline_fixed_string_t select;
11171 static enum rte_eth_input_set_field
11172 str2inset(char *string)
11176 static const struct {
11178 enum rte_eth_input_set_field inset;
11179 } inset_table[] = {
11180 {"ethertype", RTE_ETH_INPUT_SET_L2_ETHERTYPE},
11181 {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN},
11182 {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN},
11183 {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4},
11184 {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4},
11185 {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS},
11186 {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO},
11187 {"ipv4-ttl", RTE_ETH_INPUT_SET_L3_IP4_TTL},
11188 {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6},
11189 {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6},
11190 {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC},
11191 {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER},
11192 {"ipv6-hop-limits", RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS},
11193 {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT},
11194 {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT},
11195 {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT},
11196 {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT},
11197 {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT},
11198 {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT},
11199 {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG},
11200 {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY},
11201 {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY},
11202 {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD},
11203 {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD},
11204 {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD},
11205 {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD},
11206 {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD},
11207 {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD},
11208 {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD},
11209 {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD},
11210 {"none", RTE_ETH_INPUT_SET_NONE},
11213 for (i = 0; i < RTE_DIM(inset_table); i++) {
11214 if (!strcmp(string, inset_table[i].str))
11215 return inset_table[i].inset;
11218 return RTE_ETH_INPUT_SET_UNKNOWN;
11222 cmd_set_hash_input_set_parsed(void *parsed_result,
11223 __rte_unused struct cmdline *cl,
11224 __rte_unused void *data)
11226 struct cmd_set_hash_input_set_result *res = parsed_result;
11227 struct rte_eth_hash_filter_info info;
11229 memset(&info, 0, sizeof(info));
11230 info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT;
11231 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
11232 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
11233 info.info.input_set_conf.inset_size = 1;
11234 if (!strcmp(res->select, "select"))
11235 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
11236 else if (!strcmp(res->select, "add"))
11237 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
11238 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11239 RTE_ETH_FILTER_SET, &info);
11242 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd =
11243 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
11244 set_hash_input_set, "set_hash_input_set");
11245 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id =
11246 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result,
11248 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type =
11249 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
11251 cmdline_parse_token_string_t cmd_set_hash_input_set_field =
11252 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
11254 "ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
11255 "ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#"
11256 "udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#"
11257 "sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#"
11258 "fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#"
11260 cmdline_parse_token_string_t cmd_set_hash_input_set_select =
11261 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
11262 select, "select#add");
11264 cmdline_parse_inst_t cmd_set_hash_input_set = {
11265 .f = cmd_set_hash_input_set_parsed,
11267 .help_str = "set_hash_input_set <port_id> "
11268 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
11269 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload|<flowtype_id> "
11270 "ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|"
11271 "ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|"
11272 "tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|"
11273 "gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
11274 "fld-7th|fld-8th|none select|add",
11276 (void *)&cmd_set_hash_input_set_cmd,
11277 (void *)&cmd_set_hash_input_set_port_id,
11278 (void *)&cmd_set_hash_input_set_flow_type,
11279 (void *)&cmd_set_hash_input_set_field,
11280 (void *)&cmd_set_hash_input_set_select,
11285 /* Set flow director input set */
11286 struct cmd_set_fdir_input_set_result {
11287 cmdline_fixed_string_t set_fdir_input_set;
11289 cmdline_fixed_string_t flow_type;
11290 cmdline_fixed_string_t inset_field;
11291 cmdline_fixed_string_t select;
11295 cmd_set_fdir_input_set_parsed(void *parsed_result,
11296 __rte_unused struct cmdline *cl,
11297 __rte_unused void *data)
11299 struct cmd_set_fdir_input_set_result *res = parsed_result;
11300 struct rte_eth_fdir_filter_info info;
11302 memset(&info, 0, sizeof(info));
11303 info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT;
11304 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
11305 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
11306 info.info.input_set_conf.inset_size = 1;
11307 if (!strcmp(res->select, "select"))
11308 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
11309 else if (!strcmp(res->select, "add"))
11310 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
11311 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11312 RTE_ETH_FILTER_SET, &info);
11315 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd =
11316 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
11317 set_fdir_input_set, "set_fdir_input_set");
11318 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id =
11319 TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result,
11321 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type =
11322 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
11324 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
11325 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
11326 cmdline_parse_token_string_t cmd_set_fdir_input_set_field =
11327 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
11329 "ivlan#ethertype#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
11330 "ipv4-tos#ipv4-proto#ipv4-ttl#ipv6-tc#ipv6-next-header#"
11331 "ipv6-hop-limits#udp-src-port#udp-dst-port#"
11332 "tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#"
11333 "sctp-veri-tag#none");
11334 cmdline_parse_token_string_t cmd_set_fdir_input_set_select =
11335 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
11336 select, "select#add");
11338 cmdline_parse_inst_t cmd_set_fdir_input_set = {
11339 .f = cmd_set_fdir_input_set_parsed,
11341 .help_str = "set_fdir_input_set <port_id> "
11342 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
11343 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
11344 "ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|"
11345 "ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|ipv6-next-header|"
11346 "ipv6-hop-limits|udp-src-port|udp-dst-port|"
11347 "tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|"
11348 "sctp-veri-tag|none select|add",
11350 (void *)&cmd_set_fdir_input_set_cmd,
11351 (void *)&cmd_set_fdir_input_set_port_id,
11352 (void *)&cmd_set_fdir_input_set_flow_type,
11353 (void *)&cmd_set_fdir_input_set_field,
11354 (void *)&cmd_set_fdir_input_set_select,
11359 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
11360 struct cmd_mcast_addr_result {
11361 cmdline_fixed_string_t mcast_addr_cmd;
11362 cmdline_fixed_string_t what;
11364 struct ether_addr mc_addr;
11367 static void cmd_mcast_addr_parsed(void *parsed_result,
11368 __attribute__((unused)) struct cmdline *cl,
11369 __attribute__((unused)) void *data)
11371 struct cmd_mcast_addr_result *res = parsed_result;
11373 if (!is_multicast_ether_addr(&res->mc_addr)) {
11374 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
11375 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
11376 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
11377 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
11380 if (strcmp(res->what, "add") == 0)
11381 mcast_addr_add(res->port_num, &res->mc_addr);
11383 mcast_addr_remove(res->port_num, &res->mc_addr);
11386 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
11387 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
11388 mcast_addr_cmd, "mcast_addr");
11389 cmdline_parse_token_string_t cmd_mcast_addr_what =
11390 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
11392 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
11393 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT16);
11394 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
11395 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
11397 cmdline_parse_inst_t cmd_mcast_addr = {
11398 .f = cmd_mcast_addr_parsed,
11400 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
11401 "Add/Remove multicast MAC address on port_id",
11403 (void *)&cmd_mcast_addr_cmd,
11404 (void *)&cmd_mcast_addr_what,
11405 (void *)&cmd_mcast_addr_portnum,
11406 (void *)&cmd_mcast_addr_addr,
11411 /* l2 tunnel config
11412 * only support E-tag now.
11415 /* Ether type config */
11416 struct cmd_config_l2_tunnel_eth_type_result {
11417 cmdline_fixed_string_t port;
11418 cmdline_fixed_string_t config;
11419 cmdline_fixed_string_t all;
11421 cmdline_fixed_string_t l2_tunnel;
11422 cmdline_fixed_string_t l2_tunnel_type;
11423 cmdline_fixed_string_t eth_type;
11424 uint16_t eth_type_val;
11427 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port =
11428 TOKEN_STRING_INITIALIZER
11429 (struct cmd_config_l2_tunnel_eth_type_result,
11431 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config =
11432 TOKEN_STRING_INITIALIZER
11433 (struct cmd_config_l2_tunnel_eth_type_result,
11435 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str =
11436 TOKEN_STRING_INITIALIZER
11437 (struct cmd_config_l2_tunnel_eth_type_result,
11439 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id =
11440 TOKEN_NUM_INITIALIZER
11441 (struct cmd_config_l2_tunnel_eth_type_result,
11443 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel =
11444 TOKEN_STRING_INITIALIZER
11445 (struct cmd_config_l2_tunnel_eth_type_result,
11446 l2_tunnel, "l2-tunnel");
11447 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type =
11448 TOKEN_STRING_INITIALIZER
11449 (struct cmd_config_l2_tunnel_eth_type_result,
11450 l2_tunnel_type, "E-tag");
11451 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type =
11452 TOKEN_STRING_INITIALIZER
11453 (struct cmd_config_l2_tunnel_eth_type_result,
11454 eth_type, "ether-type");
11455 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val =
11456 TOKEN_NUM_INITIALIZER
11457 (struct cmd_config_l2_tunnel_eth_type_result,
11458 eth_type_val, UINT16);
11460 static enum rte_eth_tunnel_type
11461 str2fdir_l2_tunnel_type(char *string)
11465 static const struct {
11467 enum rte_eth_tunnel_type type;
11468 } l2_tunnel_type_str[] = {
11469 {"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG},
11472 for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) {
11473 if (!strcmp(l2_tunnel_type_str[i].str, string))
11474 return l2_tunnel_type_str[i].type;
11476 return RTE_TUNNEL_TYPE_NONE;
11479 /* ether type config for all ports */
11481 cmd_config_l2_tunnel_eth_type_all_parsed
11482 (void *parsed_result,
11483 __attribute__((unused)) struct cmdline *cl,
11484 __attribute__((unused)) void *data)
11486 struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result;
11487 struct rte_eth_l2_tunnel_conf entry;
11490 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
11491 entry.ether_type = res->eth_type_val;
11493 RTE_ETH_FOREACH_DEV(pid) {
11494 rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry);
11498 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = {
11499 .f = cmd_config_l2_tunnel_eth_type_all_parsed,
11501 .help_str = "port config all l2-tunnel E-tag ether-type <value>",
11503 (void *)&cmd_config_l2_tunnel_eth_type_port,
11504 (void *)&cmd_config_l2_tunnel_eth_type_config,
11505 (void *)&cmd_config_l2_tunnel_eth_type_all_str,
11506 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
11507 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
11508 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
11509 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
11514 /* ether type config for a specific port */
11516 cmd_config_l2_tunnel_eth_type_specific_parsed(
11517 void *parsed_result,
11518 __attribute__((unused)) struct cmdline *cl,
11519 __attribute__((unused)) void *data)
11521 struct cmd_config_l2_tunnel_eth_type_result *res =
11523 struct rte_eth_l2_tunnel_conf entry;
11525 if (port_id_is_invalid(res->id, ENABLED_WARN))
11528 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
11529 entry.ether_type = res->eth_type_val;
11531 rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry);
11534 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = {
11535 .f = cmd_config_l2_tunnel_eth_type_specific_parsed,
11537 .help_str = "port config <port_id> l2-tunnel E-tag ether-type <value>",
11539 (void *)&cmd_config_l2_tunnel_eth_type_port,
11540 (void *)&cmd_config_l2_tunnel_eth_type_config,
11541 (void *)&cmd_config_l2_tunnel_eth_type_id,
11542 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
11543 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
11544 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
11545 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
11550 /* Enable/disable l2 tunnel */
11551 struct cmd_config_l2_tunnel_en_dis_result {
11552 cmdline_fixed_string_t port;
11553 cmdline_fixed_string_t config;
11554 cmdline_fixed_string_t all;
11556 cmdline_fixed_string_t l2_tunnel;
11557 cmdline_fixed_string_t l2_tunnel_type;
11558 cmdline_fixed_string_t en_dis;
11561 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port =
11562 TOKEN_STRING_INITIALIZER
11563 (struct cmd_config_l2_tunnel_en_dis_result,
11565 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config =
11566 TOKEN_STRING_INITIALIZER
11567 (struct cmd_config_l2_tunnel_en_dis_result,
11569 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str =
11570 TOKEN_STRING_INITIALIZER
11571 (struct cmd_config_l2_tunnel_en_dis_result,
11573 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id =
11574 TOKEN_NUM_INITIALIZER
11575 (struct cmd_config_l2_tunnel_en_dis_result,
11577 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel =
11578 TOKEN_STRING_INITIALIZER
11579 (struct cmd_config_l2_tunnel_en_dis_result,
11580 l2_tunnel, "l2-tunnel");
11581 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type =
11582 TOKEN_STRING_INITIALIZER
11583 (struct cmd_config_l2_tunnel_en_dis_result,
11584 l2_tunnel_type, "E-tag");
11585 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis =
11586 TOKEN_STRING_INITIALIZER
11587 (struct cmd_config_l2_tunnel_en_dis_result,
11588 en_dis, "enable#disable");
11590 /* enable/disable l2 tunnel for all ports */
11592 cmd_config_l2_tunnel_en_dis_all_parsed(
11593 void *parsed_result,
11594 __attribute__((unused)) struct cmdline *cl,
11595 __attribute__((unused)) void *data)
11597 struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result;
11598 struct rte_eth_l2_tunnel_conf entry;
11602 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
11604 if (!strcmp("enable", res->en_dis))
11609 RTE_ETH_FOREACH_DEV(pid) {
11610 rte_eth_dev_l2_tunnel_offload_set(pid,
11612 ETH_L2_TUNNEL_ENABLE_MASK,
11617 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = {
11618 .f = cmd_config_l2_tunnel_en_dis_all_parsed,
11620 .help_str = "port config all l2-tunnel E-tag enable|disable",
11622 (void *)&cmd_config_l2_tunnel_en_dis_port,
11623 (void *)&cmd_config_l2_tunnel_en_dis_config,
11624 (void *)&cmd_config_l2_tunnel_en_dis_all_str,
11625 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
11626 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
11627 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
11632 /* enable/disable l2 tunnel for a port */
11634 cmd_config_l2_tunnel_en_dis_specific_parsed(
11635 void *parsed_result,
11636 __attribute__((unused)) struct cmdline *cl,
11637 __attribute__((unused)) void *data)
11639 struct cmd_config_l2_tunnel_en_dis_result *res =
11641 struct rte_eth_l2_tunnel_conf entry;
11643 if (port_id_is_invalid(res->id, ENABLED_WARN))
11646 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
11648 if (!strcmp("enable", res->en_dis))
11649 rte_eth_dev_l2_tunnel_offload_set(res->id,
11651 ETH_L2_TUNNEL_ENABLE_MASK,
11654 rte_eth_dev_l2_tunnel_offload_set(res->id,
11656 ETH_L2_TUNNEL_ENABLE_MASK,
11660 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = {
11661 .f = cmd_config_l2_tunnel_en_dis_specific_parsed,
11663 .help_str = "port config <port_id> l2-tunnel E-tag enable|disable",
11665 (void *)&cmd_config_l2_tunnel_en_dis_port,
11666 (void *)&cmd_config_l2_tunnel_en_dis_config,
11667 (void *)&cmd_config_l2_tunnel_en_dis_id,
11668 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
11669 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
11670 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
11675 /* E-tag configuration */
11677 /* Common result structure for all E-tag configuration */
11678 struct cmd_config_e_tag_result {
11679 cmdline_fixed_string_t e_tag;
11680 cmdline_fixed_string_t set;
11681 cmdline_fixed_string_t insertion;
11682 cmdline_fixed_string_t stripping;
11683 cmdline_fixed_string_t forwarding;
11684 cmdline_fixed_string_t filter;
11685 cmdline_fixed_string_t add;
11686 cmdline_fixed_string_t del;
11687 cmdline_fixed_string_t on;
11688 cmdline_fixed_string_t off;
11689 cmdline_fixed_string_t on_off;
11690 cmdline_fixed_string_t port_tag_id;
11691 uint32_t port_tag_id_val;
11692 cmdline_fixed_string_t e_tag_id;
11693 uint16_t e_tag_id_val;
11694 cmdline_fixed_string_t dst_pool;
11695 uint8_t dst_pool_val;
11696 cmdline_fixed_string_t port;
11698 cmdline_fixed_string_t vf;
11702 /* Common CLI fields for all E-tag configuration */
11703 cmdline_parse_token_string_t cmd_config_e_tag_e_tag =
11704 TOKEN_STRING_INITIALIZER
11705 (struct cmd_config_e_tag_result,
11707 cmdline_parse_token_string_t cmd_config_e_tag_set =
11708 TOKEN_STRING_INITIALIZER
11709 (struct cmd_config_e_tag_result,
11711 cmdline_parse_token_string_t cmd_config_e_tag_insertion =
11712 TOKEN_STRING_INITIALIZER
11713 (struct cmd_config_e_tag_result,
11714 insertion, "insertion");
11715 cmdline_parse_token_string_t cmd_config_e_tag_stripping =
11716 TOKEN_STRING_INITIALIZER
11717 (struct cmd_config_e_tag_result,
11718 stripping, "stripping");
11719 cmdline_parse_token_string_t cmd_config_e_tag_forwarding =
11720 TOKEN_STRING_INITIALIZER
11721 (struct cmd_config_e_tag_result,
11722 forwarding, "forwarding");
11723 cmdline_parse_token_string_t cmd_config_e_tag_filter =
11724 TOKEN_STRING_INITIALIZER
11725 (struct cmd_config_e_tag_result,
11727 cmdline_parse_token_string_t cmd_config_e_tag_add =
11728 TOKEN_STRING_INITIALIZER
11729 (struct cmd_config_e_tag_result,
11731 cmdline_parse_token_string_t cmd_config_e_tag_del =
11732 TOKEN_STRING_INITIALIZER
11733 (struct cmd_config_e_tag_result,
11735 cmdline_parse_token_string_t cmd_config_e_tag_on =
11736 TOKEN_STRING_INITIALIZER
11737 (struct cmd_config_e_tag_result,
11739 cmdline_parse_token_string_t cmd_config_e_tag_off =
11740 TOKEN_STRING_INITIALIZER
11741 (struct cmd_config_e_tag_result,
11743 cmdline_parse_token_string_t cmd_config_e_tag_on_off =
11744 TOKEN_STRING_INITIALIZER
11745 (struct cmd_config_e_tag_result,
11747 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id =
11748 TOKEN_STRING_INITIALIZER
11749 (struct cmd_config_e_tag_result,
11750 port_tag_id, "port-tag-id");
11751 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val =
11752 TOKEN_NUM_INITIALIZER
11753 (struct cmd_config_e_tag_result,
11754 port_tag_id_val, UINT32);
11755 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id =
11756 TOKEN_STRING_INITIALIZER
11757 (struct cmd_config_e_tag_result,
11758 e_tag_id, "e-tag-id");
11759 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val =
11760 TOKEN_NUM_INITIALIZER
11761 (struct cmd_config_e_tag_result,
11762 e_tag_id_val, UINT16);
11763 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool =
11764 TOKEN_STRING_INITIALIZER
11765 (struct cmd_config_e_tag_result,
11766 dst_pool, "dst-pool");
11767 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val =
11768 TOKEN_NUM_INITIALIZER
11769 (struct cmd_config_e_tag_result,
11770 dst_pool_val, UINT8);
11771 cmdline_parse_token_string_t cmd_config_e_tag_port =
11772 TOKEN_STRING_INITIALIZER
11773 (struct cmd_config_e_tag_result,
11775 cmdline_parse_token_num_t cmd_config_e_tag_port_id =
11776 TOKEN_NUM_INITIALIZER
11777 (struct cmd_config_e_tag_result,
11779 cmdline_parse_token_string_t cmd_config_e_tag_vf =
11780 TOKEN_STRING_INITIALIZER
11781 (struct cmd_config_e_tag_result,
11783 cmdline_parse_token_num_t cmd_config_e_tag_vf_id =
11784 TOKEN_NUM_INITIALIZER
11785 (struct cmd_config_e_tag_result,
11788 /* E-tag insertion configuration */
11790 cmd_config_e_tag_insertion_en_parsed(
11791 void *parsed_result,
11792 __attribute__((unused)) struct cmdline *cl,
11793 __attribute__((unused)) void *data)
11795 struct cmd_config_e_tag_result *res =
11797 struct rte_eth_l2_tunnel_conf entry;
11799 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11802 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
11803 entry.tunnel_id = res->port_tag_id_val;
11804 entry.vf_id = res->vf_id;
11805 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
11807 ETH_L2_TUNNEL_INSERTION_MASK,
11812 cmd_config_e_tag_insertion_dis_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.vf_id = res->vf_id;
11827 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
11829 ETH_L2_TUNNEL_INSERTION_MASK,
11833 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = {
11834 .f = cmd_config_e_tag_insertion_en_parsed,
11836 .help_str = "E-tag ... : E-tag insertion enable",
11838 (void *)&cmd_config_e_tag_e_tag,
11839 (void *)&cmd_config_e_tag_set,
11840 (void *)&cmd_config_e_tag_insertion,
11841 (void *)&cmd_config_e_tag_on,
11842 (void *)&cmd_config_e_tag_port_tag_id,
11843 (void *)&cmd_config_e_tag_port_tag_id_val,
11844 (void *)&cmd_config_e_tag_port,
11845 (void *)&cmd_config_e_tag_port_id,
11846 (void *)&cmd_config_e_tag_vf,
11847 (void *)&cmd_config_e_tag_vf_id,
11852 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = {
11853 .f = cmd_config_e_tag_insertion_dis_parsed,
11855 .help_str = "E-tag ... : E-tag insertion disable",
11857 (void *)&cmd_config_e_tag_e_tag,
11858 (void *)&cmd_config_e_tag_set,
11859 (void *)&cmd_config_e_tag_insertion,
11860 (void *)&cmd_config_e_tag_off,
11861 (void *)&cmd_config_e_tag_port,
11862 (void *)&cmd_config_e_tag_port_id,
11863 (void *)&cmd_config_e_tag_vf,
11864 (void *)&cmd_config_e_tag_vf_id,
11869 /* E-tag stripping configuration */
11871 cmd_config_e_tag_stripping_parsed(
11872 void *parsed_result,
11873 __attribute__((unused)) struct cmdline *cl,
11874 __attribute__((unused)) void *data)
11876 struct cmd_config_e_tag_result *res =
11878 struct rte_eth_l2_tunnel_conf entry;
11880 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11883 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
11885 if (!strcmp(res->on_off, "on"))
11886 rte_eth_dev_l2_tunnel_offload_set
11889 ETH_L2_TUNNEL_STRIPPING_MASK,
11892 rte_eth_dev_l2_tunnel_offload_set
11895 ETH_L2_TUNNEL_STRIPPING_MASK,
11899 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = {
11900 .f = cmd_config_e_tag_stripping_parsed,
11902 .help_str = "E-tag ... : E-tag stripping enable/disable",
11904 (void *)&cmd_config_e_tag_e_tag,
11905 (void *)&cmd_config_e_tag_set,
11906 (void *)&cmd_config_e_tag_stripping,
11907 (void *)&cmd_config_e_tag_on_off,
11908 (void *)&cmd_config_e_tag_port,
11909 (void *)&cmd_config_e_tag_port_id,
11914 /* E-tag forwarding configuration */
11916 cmd_config_e_tag_forwarding_parsed(
11917 void *parsed_result,
11918 __attribute__((unused)) struct cmdline *cl,
11919 __attribute__((unused)) void *data)
11921 struct cmd_config_e_tag_result *res = parsed_result;
11922 struct rte_eth_l2_tunnel_conf entry;
11924 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11927 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
11929 if (!strcmp(res->on_off, "on"))
11930 rte_eth_dev_l2_tunnel_offload_set
11933 ETH_L2_TUNNEL_FORWARDING_MASK,
11936 rte_eth_dev_l2_tunnel_offload_set
11939 ETH_L2_TUNNEL_FORWARDING_MASK,
11943 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = {
11944 .f = cmd_config_e_tag_forwarding_parsed,
11946 .help_str = "E-tag ... : E-tag forwarding enable/disable",
11948 (void *)&cmd_config_e_tag_e_tag,
11949 (void *)&cmd_config_e_tag_set,
11950 (void *)&cmd_config_e_tag_forwarding,
11951 (void *)&cmd_config_e_tag_on_off,
11952 (void *)&cmd_config_e_tag_port,
11953 (void *)&cmd_config_e_tag_port_id,
11958 /* E-tag filter configuration */
11960 cmd_config_e_tag_filter_add_parsed(
11961 void *parsed_result,
11962 __attribute__((unused)) struct cmdline *cl,
11963 __attribute__((unused)) void *data)
11965 struct cmd_config_e_tag_result *res = parsed_result;
11966 struct rte_eth_l2_tunnel_conf entry;
11969 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11972 if (res->e_tag_id_val > 0x3fff) {
11973 printf("e-tag-id must be equal or less than 0x3fff.\n");
11977 ret = rte_eth_dev_filter_supported(res->port_id,
11978 RTE_ETH_FILTER_L2_TUNNEL);
11980 printf("E-tag filter is not supported on port %u.\n",
11985 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
11986 entry.tunnel_id = res->e_tag_id_val;
11987 entry.pool = res->dst_pool_val;
11989 ret = rte_eth_dev_filter_ctrl(res->port_id,
11990 RTE_ETH_FILTER_L2_TUNNEL,
11991 RTE_ETH_FILTER_ADD,
11994 printf("E-tag filter programming error: (%s)\n",
11998 cmdline_parse_inst_t cmd_config_e_tag_filter_add = {
11999 .f = cmd_config_e_tag_filter_add_parsed,
12001 .help_str = "E-tag ... : E-tag filter add",
12003 (void *)&cmd_config_e_tag_e_tag,
12004 (void *)&cmd_config_e_tag_set,
12005 (void *)&cmd_config_e_tag_filter,
12006 (void *)&cmd_config_e_tag_add,
12007 (void *)&cmd_config_e_tag_e_tag_id,
12008 (void *)&cmd_config_e_tag_e_tag_id_val,
12009 (void *)&cmd_config_e_tag_dst_pool,
12010 (void *)&cmd_config_e_tag_dst_pool_val,
12011 (void *)&cmd_config_e_tag_port,
12012 (void *)&cmd_config_e_tag_port_id,
12018 cmd_config_e_tag_filter_del_parsed(
12019 void *parsed_result,
12020 __attribute__((unused)) struct cmdline *cl,
12021 __attribute__((unused)) void *data)
12023 struct cmd_config_e_tag_result *res = parsed_result;
12024 struct rte_eth_l2_tunnel_conf entry;
12027 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12030 if (res->e_tag_id_val > 0x3fff) {
12031 printf("e-tag-id must be less than 0x3fff.\n");
12035 ret = rte_eth_dev_filter_supported(res->port_id,
12036 RTE_ETH_FILTER_L2_TUNNEL);
12038 printf("E-tag filter is not supported on port %u.\n",
12043 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12044 entry.tunnel_id = res->e_tag_id_val;
12046 ret = rte_eth_dev_filter_ctrl(res->port_id,
12047 RTE_ETH_FILTER_L2_TUNNEL,
12048 RTE_ETH_FILTER_DELETE,
12051 printf("E-tag filter programming error: (%s)\n",
12055 cmdline_parse_inst_t cmd_config_e_tag_filter_del = {
12056 .f = cmd_config_e_tag_filter_del_parsed,
12058 .help_str = "E-tag ... : E-tag filter delete",
12060 (void *)&cmd_config_e_tag_e_tag,
12061 (void *)&cmd_config_e_tag_set,
12062 (void *)&cmd_config_e_tag_filter,
12063 (void *)&cmd_config_e_tag_del,
12064 (void *)&cmd_config_e_tag_e_tag_id,
12065 (void *)&cmd_config_e_tag_e_tag_id_val,
12066 (void *)&cmd_config_e_tag_port,
12067 (void *)&cmd_config_e_tag_port_id,
12072 /* vf vlan anti spoof configuration */
12074 /* Common result structure for vf vlan anti spoof */
12075 struct cmd_vf_vlan_anti_spoof_result {
12076 cmdline_fixed_string_t set;
12077 cmdline_fixed_string_t vf;
12078 cmdline_fixed_string_t vlan;
12079 cmdline_fixed_string_t antispoof;
12082 cmdline_fixed_string_t on_off;
12085 /* Common CLI fields for vf vlan anti spoof enable disable */
12086 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
12087 TOKEN_STRING_INITIALIZER
12088 (struct cmd_vf_vlan_anti_spoof_result,
12090 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
12091 TOKEN_STRING_INITIALIZER
12092 (struct cmd_vf_vlan_anti_spoof_result,
12094 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
12095 TOKEN_STRING_INITIALIZER
12096 (struct cmd_vf_vlan_anti_spoof_result,
12098 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
12099 TOKEN_STRING_INITIALIZER
12100 (struct cmd_vf_vlan_anti_spoof_result,
12101 antispoof, "antispoof");
12102 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
12103 TOKEN_NUM_INITIALIZER
12104 (struct cmd_vf_vlan_anti_spoof_result,
12106 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
12107 TOKEN_NUM_INITIALIZER
12108 (struct cmd_vf_vlan_anti_spoof_result,
12110 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
12111 TOKEN_STRING_INITIALIZER
12112 (struct cmd_vf_vlan_anti_spoof_result,
12116 cmd_set_vf_vlan_anti_spoof_parsed(
12117 void *parsed_result,
12118 __attribute__((unused)) struct cmdline *cl,
12119 __attribute__((unused)) void *data)
12121 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
12122 int ret = -ENOTSUP;
12124 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12126 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12129 #ifdef RTE_LIBRTE_IXGBE_PMD
12130 if (ret == -ENOTSUP)
12131 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
12132 res->vf_id, is_on);
12134 #ifdef RTE_LIBRTE_I40E_PMD
12135 if (ret == -ENOTSUP)
12136 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
12137 res->vf_id, is_on);
12139 #ifdef RTE_LIBRTE_BNXT_PMD
12140 if (ret == -ENOTSUP)
12141 ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
12142 res->vf_id, is_on);
12149 printf("invalid vf_id %d\n", res->vf_id);
12152 printf("invalid port_id %d\n", res->port_id);
12155 printf("function not implemented\n");
12158 printf("programming error: (%s)\n", strerror(-ret));
12162 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
12163 .f = cmd_set_vf_vlan_anti_spoof_parsed,
12165 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
12167 (void *)&cmd_vf_vlan_anti_spoof_set,
12168 (void *)&cmd_vf_vlan_anti_spoof_vf,
12169 (void *)&cmd_vf_vlan_anti_spoof_vlan,
12170 (void *)&cmd_vf_vlan_anti_spoof_antispoof,
12171 (void *)&cmd_vf_vlan_anti_spoof_port_id,
12172 (void *)&cmd_vf_vlan_anti_spoof_vf_id,
12173 (void *)&cmd_vf_vlan_anti_spoof_on_off,
12178 /* vf mac anti spoof configuration */
12180 /* Common result structure for vf mac anti spoof */
12181 struct cmd_vf_mac_anti_spoof_result {
12182 cmdline_fixed_string_t set;
12183 cmdline_fixed_string_t vf;
12184 cmdline_fixed_string_t mac;
12185 cmdline_fixed_string_t antispoof;
12188 cmdline_fixed_string_t on_off;
12191 /* Common CLI fields for vf mac anti spoof enable disable */
12192 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
12193 TOKEN_STRING_INITIALIZER
12194 (struct cmd_vf_mac_anti_spoof_result,
12196 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
12197 TOKEN_STRING_INITIALIZER
12198 (struct cmd_vf_mac_anti_spoof_result,
12200 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
12201 TOKEN_STRING_INITIALIZER
12202 (struct cmd_vf_mac_anti_spoof_result,
12204 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
12205 TOKEN_STRING_INITIALIZER
12206 (struct cmd_vf_mac_anti_spoof_result,
12207 antispoof, "antispoof");
12208 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
12209 TOKEN_NUM_INITIALIZER
12210 (struct cmd_vf_mac_anti_spoof_result,
12212 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
12213 TOKEN_NUM_INITIALIZER
12214 (struct cmd_vf_mac_anti_spoof_result,
12216 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
12217 TOKEN_STRING_INITIALIZER
12218 (struct cmd_vf_mac_anti_spoof_result,
12222 cmd_set_vf_mac_anti_spoof_parsed(
12223 void *parsed_result,
12224 __attribute__((unused)) struct cmdline *cl,
12225 __attribute__((unused)) void *data)
12227 struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
12228 int ret = -ENOTSUP;
12230 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12232 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12235 #ifdef RTE_LIBRTE_IXGBE_PMD
12236 if (ret == -ENOTSUP)
12237 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
12238 res->vf_id, is_on);
12240 #ifdef RTE_LIBRTE_I40E_PMD
12241 if (ret == -ENOTSUP)
12242 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
12243 res->vf_id, is_on);
12245 #ifdef RTE_LIBRTE_BNXT_PMD
12246 if (ret == -ENOTSUP)
12247 ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
12248 res->vf_id, is_on);
12255 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12258 printf("invalid port_id %d\n", res->port_id);
12261 printf("function not implemented\n");
12264 printf("programming error: (%s)\n", strerror(-ret));
12268 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
12269 .f = cmd_set_vf_mac_anti_spoof_parsed,
12271 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
12273 (void *)&cmd_vf_mac_anti_spoof_set,
12274 (void *)&cmd_vf_mac_anti_spoof_vf,
12275 (void *)&cmd_vf_mac_anti_spoof_mac,
12276 (void *)&cmd_vf_mac_anti_spoof_antispoof,
12277 (void *)&cmd_vf_mac_anti_spoof_port_id,
12278 (void *)&cmd_vf_mac_anti_spoof_vf_id,
12279 (void *)&cmd_vf_mac_anti_spoof_on_off,
12284 /* vf vlan strip queue configuration */
12286 /* Common result structure for vf mac anti spoof */
12287 struct cmd_vf_vlan_stripq_result {
12288 cmdline_fixed_string_t set;
12289 cmdline_fixed_string_t vf;
12290 cmdline_fixed_string_t vlan;
12291 cmdline_fixed_string_t stripq;
12294 cmdline_fixed_string_t on_off;
12297 /* Common CLI fields for vf vlan strip enable disable */
12298 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
12299 TOKEN_STRING_INITIALIZER
12300 (struct cmd_vf_vlan_stripq_result,
12302 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
12303 TOKEN_STRING_INITIALIZER
12304 (struct cmd_vf_vlan_stripq_result,
12306 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
12307 TOKEN_STRING_INITIALIZER
12308 (struct cmd_vf_vlan_stripq_result,
12310 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
12311 TOKEN_STRING_INITIALIZER
12312 (struct cmd_vf_vlan_stripq_result,
12314 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
12315 TOKEN_NUM_INITIALIZER
12316 (struct cmd_vf_vlan_stripq_result,
12318 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
12319 TOKEN_NUM_INITIALIZER
12320 (struct cmd_vf_vlan_stripq_result,
12322 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
12323 TOKEN_STRING_INITIALIZER
12324 (struct cmd_vf_vlan_stripq_result,
12328 cmd_set_vf_vlan_stripq_parsed(
12329 void *parsed_result,
12330 __attribute__((unused)) struct cmdline *cl,
12331 __attribute__((unused)) void *data)
12333 struct cmd_vf_vlan_stripq_result *res = parsed_result;
12334 int ret = -ENOTSUP;
12336 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12338 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12341 #ifdef RTE_LIBRTE_IXGBE_PMD
12342 if (ret == -ENOTSUP)
12343 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
12344 res->vf_id, is_on);
12346 #ifdef RTE_LIBRTE_I40E_PMD
12347 if (ret == -ENOTSUP)
12348 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
12349 res->vf_id, is_on);
12351 #ifdef RTE_LIBRTE_BNXT_PMD
12352 if (ret == -ENOTSUP)
12353 ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
12354 res->vf_id, is_on);
12361 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12364 printf("invalid port_id %d\n", res->port_id);
12367 printf("function not implemented\n");
12370 printf("programming error: (%s)\n", strerror(-ret));
12374 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
12375 .f = cmd_set_vf_vlan_stripq_parsed,
12377 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
12379 (void *)&cmd_vf_vlan_stripq_set,
12380 (void *)&cmd_vf_vlan_stripq_vf,
12381 (void *)&cmd_vf_vlan_stripq_vlan,
12382 (void *)&cmd_vf_vlan_stripq_stripq,
12383 (void *)&cmd_vf_vlan_stripq_port_id,
12384 (void *)&cmd_vf_vlan_stripq_vf_id,
12385 (void *)&cmd_vf_vlan_stripq_on_off,
12390 /* vf vlan insert configuration */
12392 /* Common result structure for vf vlan insert */
12393 struct cmd_vf_vlan_insert_result {
12394 cmdline_fixed_string_t set;
12395 cmdline_fixed_string_t vf;
12396 cmdline_fixed_string_t vlan;
12397 cmdline_fixed_string_t insert;
12403 /* Common CLI fields for vf vlan insert enable disable */
12404 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
12405 TOKEN_STRING_INITIALIZER
12406 (struct cmd_vf_vlan_insert_result,
12408 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
12409 TOKEN_STRING_INITIALIZER
12410 (struct cmd_vf_vlan_insert_result,
12412 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
12413 TOKEN_STRING_INITIALIZER
12414 (struct cmd_vf_vlan_insert_result,
12416 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
12417 TOKEN_STRING_INITIALIZER
12418 (struct cmd_vf_vlan_insert_result,
12420 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
12421 TOKEN_NUM_INITIALIZER
12422 (struct cmd_vf_vlan_insert_result,
12424 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
12425 TOKEN_NUM_INITIALIZER
12426 (struct cmd_vf_vlan_insert_result,
12428 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
12429 TOKEN_NUM_INITIALIZER
12430 (struct cmd_vf_vlan_insert_result,
12434 cmd_set_vf_vlan_insert_parsed(
12435 void *parsed_result,
12436 __attribute__((unused)) struct cmdline *cl,
12437 __attribute__((unused)) void *data)
12439 struct cmd_vf_vlan_insert_result *res = parsed_result;
12440 int ret = -ENOTSUP;
12442 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12445 #ifdef RTE_LIBRTE_IXGBE_PMD
12446 if (ret == -ENOTSUP)
12447 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
12450 #ifdef RTE_LIBRTE_I40E_PMD
12451 if (ret == -ENOTSUP)
12452 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
12455 #ifdef RTE_LIBRTE_BNXT_PMD
12456 if (ret == -ENOTSUP)
12457 ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
12465 printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id);
12468 printf("invalid port_id %d\n", res->port_id);
12471 printf("function not implemented\n");
12474 printf("programming error: (%s)\n", strerror(-ret));
12478 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
12479 .f = cmd_set_vf_vlan_insert_parsed,
12481 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
12483 (void *)&cmd_vf_vlan_insert_set,
12484 (void *)&cmd_vf_vlan_insert_vf,
12485 (void *)&cmd_vf_vlan_insert_vlan,
12486 (void *)&cmd_vf_vlan_insert_insert,
12487 (void *)&cmd_vf_vlan_insert_port_id,
12488 (void *)&cmd_vf_vlan_insert_vf_id,
12489 (void *)&cmd_vf_vlan_insert_vlan_id,
12494 /* tx loopback configuration */
12496 /* Common result structure for tx loopback */
12497 struct cmd_tx_loopback_result {
12498 cmdline_fixed_string_t set;
12499 cmdline_fixed_string_t tx;
12500 cmdline_fixed_string_t loopback;
12502 cmdline_fixed_string_t on_off;
12505 /* Common CLI fields for tx loopback enable disable */
12506 cmdline_parse_token_string_t cmd_tx_loopback_set =
12507 TOKEN_STRING_INITIALIZER
12508 (struct cmd_tx_loopback_result,
12510 cmdline_parse_token_string_t cmd_tx_loopback_tx =
12511 TOKEN_STRING_INITIALIZER
12512 (struct cmd_tx_loopback_result,
12514 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
12515 TOKEN_STRING_INITIALIZER
12516 (struct cmd_tx_loopback_result,
12517 loopback, "loopback");
12518 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
12519 TOKEN_NUM_INITIALIZER
12520 (struct cmd_tx_loopback_result,
12522 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
12523 TOKEN_STRING_INITIALIZER
12524 (struct cmd_tx_loopback_result,
12528 cmd_set_tx_loopback_parsed(
12529 void *parsed_result,
12530 __attribute__((unused)) struct cmdline *cl,
12531 __attribute__((unused)) void *data)
12533 struct cmd_tx_loopback_result *res = parsed_result;
12534 int ret = -ENOTSUP;
12536 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12538 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12541 #ifdef RTE_LIBRTE_IXGBE_PMD
12542 if (ret == -ENOTSUP)
12543 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
12545 #ifdef RTE_LIBRTE_I40E_PMD
12546 if (ret == -ENOTSUP)
12547 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
12549 #ifdef RTE_LIBRTE_BNXT_PMD
12550 if (ret == -ENOTSUP)
12551 ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
12558 printf("invalid is_on %d\n", is_on);
12561 printf("invalid port_id %d\n", res->port_id);
12564 printf("function not implemented\n");
12567 printf("programming error: (%s)\n", strerror(-ret));
12571 cmdline_parse_inst_t cmd_set_tx_loopback = {
12572 .f = cmd_set_tx_loopback_parsed,
12574 .help_str = "set tx loopback <port_id> on|off",
12576 (void *)&cmd_tx_loopback_set,
12577 (void *)&cmd_tx_loopback_tx,
12578 (void *)&cmd_tx_loopback_loopback,
12579 (void *)&cmd_tx_loopback_port_id,
12580 (void *)&cmd_tx_loopback_on_off,
12585 /* all queues drop enable configuration */
12587 /* Common result structure for all queues drop enable */
12588 struct cmd_all_queues_drop_en_result {
12589 cmdline_fixed_string_t set;
12590 cmdline_fixed_string_t all;
12591 cmdline_fixed_string_t queues;
12592 cmdline_fixed_string_t drop;
12594 cmdline_fixed_string_t on_off;
12597 /* Common CLI fields for tx loopback enable disable */
12598 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
12599 TOKEN_STRING_INITIALIZER
12600 (struct cmd_all_queues_drop_en_result,
12602 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
12603 TOKEN_STRING_INITIALIZER
12604 (struct cmd_all_queues_drop_en_result,
12606 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
12607 TOKEN_STRING_INITIALIZER
12608 (struct cmd_all_queues_drop_en_result,
12610 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
12611 TOKEN_STRING_INITIALIZER
12612 (struct cmd_all_queues_drop_en_result,
12614 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
12615 TOKEN_NUM_INITIALIZER
12616 (struct cmd_all_queues_drop_en_result,
12618 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
12619 TOKEN_STRING_INITIALIZER
12620 (struct cmd_all_queues_drop_en_result,
12624 cmd_set_all_queues_drop_en_parsed(
12625 void *parsed_result,
12626 __attribute__((unused)) struct cmdline *cl,
12627 __attribute__((unused)) void *data)
12629 struct cmd_all_queues_drop_en_result *res = parsed_result;
12630 int ret = -ENOTSUP;
12631 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12633 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12636 #ifdef RTE_LIBRTE_IXGBE_PMD
12637 if (ret == -ENOTSUP)
12638 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
12640 #ifdef RTE_LIBRTE_BNXT_PMD
12641 if (ret == -ENOTSUP)
12642 ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
12648 printf("invalid is_on %d\n", is_on);
12651 printf("invalid port_id %d\n", res->port_id);
12654 printf("function not implemented\n");
12657 printf("programming error: (%s)\n", strerror(-ret));
12661 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
12662 .f = cmd_set_all_queues_drop_en_parsed,
12664 .help_str = "set all queues drop <port_id> on|off",
12666 (void *)&cmd_all_queues_drop_en_set,
12667 (void *)&cmd_all_queues_drop_en_all,
12668 (void *)&cmd_all_queues_drop_en_queues,
12669 (void *)&cmd_all_queues_drop_en_drop,
12670 (void *)&cmd_all_queues_drop_en_port_id,
12671 (void *)&cmd_all_queues_drop_en_on_off,
12676 /* vf split drop enable configuration */
12678 /* Common result structure for vf split drop enable */
12679 struct cmd_vf_split_drop_en_result {
12680 cmdline_fixed_string_t set;
12681 cmdline_fixed_string_t vf;
12682 cmdline_fixed_string_t split;
12683 cmdline_fixed_string_t drop;
12686 cmdline_fixed_string_t on_off;
12689 /* Common CLI fields for vf split drop enable disable */
12690 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
12691 TOKEN_STRING_INITIALIZER
12692 (struct cmd_vf_split_drop_en_result,
12694 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
12695 TOKEN_STRING_INITIALIZER
12696 (struct cmd_vf_split_drop_en_result,
12698 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
12699 TOKEN_STRING_INITIALIZER
12700 (struct cmd_vf_split_drop_en_result,
12702 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
12703 TOKEN_STRING_INITIALIZER
12704 (struct cmd_vf_split_drop_en_result,
12706 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
12707 TOKEN_NUM_INITIALIZER
12708 (struct cmd_vf_split_drop_en_result,
12710 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
12711 TOKEN_NUM_INITIALIZER
12712 (struct cmd_vf_split_drop_en_result,
12714 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
12715 TOKEN_STRING_INITIALIZER
12716 (struct cmd_vf_split_drop_en_result,
12720 cmd_set_vf_split_drop_en_parsed(
12721 void *parsed_result,
12722 __attribute__((unused)) struct cmdline *cl,
12723 __attribute__((unused)) void *data)
12725 struct cmd_vf_split_drop_en_result *res = parsed_result;
12726 int ret = -ENOTSUP;
12727 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12729 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12732 #ifdef RTE_LIBRTE_IXGBE_PMD
12733 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
12740 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12743 printf("invalid port_id %d\n", res->port_id);
12746 printf("not supported on port %d\n", res->port_id);
12749 printf("programming error: (%s)\n", strerror(-ret));
12753 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
12754 .f = cmd_set_vf_split_drop_en_parsed,
12756 .help_str = "set vf split drop <port_id> <vf_id> on|off",
12758 (void *)&cmd_vf_split_drop_en_set,
12759 (void *)&cmd_vf_split_drop_en_vf,
12760 (void *)&cmd_vf_split_drop_en_split,
12761 (void *)&cmd_vf_split_drop_en_drop,
12762 (void *)&cmd_vf_split_drop_en_port_id,
12763 (void *)&cmd_vf_split_drop_en_vf_id,
12764 (void *)&cmd_vf_split_drop_en_on_off,
12769 /* vf mac address configuration */
12771 /* Common result structure for vf mac address */
12772 struct cmd_set_vf_mac_addr_result {
12773 cmdline_fixed_string_t set;
12774 cmdline_fixed_string_t vf;
12775 cmdline_fixed_string_t mac;
12776 cmdline_fixed_string_t addr;
12779 struct ether_addr mac_addr;
12783 /* Common CLI fields for vf split drop enable disable */
12784 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
12785 TOKEN_STRING_INITIALIZER
12786 (struct cmd_set_vf_mac_addr_result,
12788 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
12789 TOKEN_STRING_INITIALIZER
12790 (struct cmd_set_vf_mac_addr_result,
12792 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
12793 TOKEN_STRING_INITIALIZER
12794 (struct cmd_set_vf_mac_addr_result,
12796 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
12797 TOKEN_STRING_INITIALIZER
12798 (struct cmd_set_vf_mac_addr_result,
12800 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
12801 TOKEN_NUM_INITIALIZER
12802 (struct cmd_set_vf_mac_addr_result,
12804 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
12805 TOKEN_NUM_INITIALIZER
12806 (struct cmd_set_vf_mac_addr_result,
12808 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
12809 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
12813 cmd_set_vf_mac_addr_parsed(
12814 void *parsed_result,
12815 __attribute__((unused)) struct cmdline *cl,
12816 __attribute__((unused)) void *data)
12818 struct cmd_set_vf_mac_addr_result *res = parsed_result;
12819 int ret = -ENOTSUP;
12821 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12824 #ifdef RTE_LIBRTE_IXGBE_PMD
12825 if (ret == -ENOTSUP)
12826 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
12829 #ifdef RTE_LIBRTE_I40E_PMD
12830 if (ret == -ENOTSUP)
12831 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
12834 #ifdef RTE_LIBRTE_BNXT_PMD
12835 if (ret == -ENOTSUP)
12836 ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
12844 printf("invalid vf_id %d or mac_addr\n", res->vf_id);
12847 printf("invalid port_id %d\n", res->port_id);
12850 printf("function not implemented\n");
12853 printf("programming error: (%s)\n", strerror(-ret));
12857 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
12858 .f = cmd_set_vf_mac_addr_parsed,
12860 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
12862 (void *)&cmd_set_vf_mac_addr_set,
12863 (void *)&cmd_set_vf_mac_addr_vf,
12864 (void *)&cmd_set_vf_mac_addr_mac,
12865 (void *)&cmd_set_vf_mac_addr_addr,
12866 (void *)&cmd_set_vf_mac_addr_port_id,
12867 (void *)&cmd_set_vf_mac_addr_vf_id,
12868 (void *)&cmd_set_vf_mac_addr_mac_addr,
12873 /* MACsec configuration */
12875 /* Common result structure for MACsec offload enable */
12876 struct cmd_macsec_offload_on_result {
12877 cmdline_fixed_string_t set;
12878 cmdline_fixed_string_t macsec;
12879 cmdline_fixed_string_t offload;
12881 cmdline_fixed_string_t on;
12882 cmdline_fixed_string_t encrypt;
12883 cmdline_fixed_string_t en_on_off;
12884 cmdline_fixed_string_t replay_protect;
12885 cmdline_fixed_string_t rp_on_off;
12888 /* Common CLI fields for MACsec offload disable */
12889 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
12890 TOKEN_STRING_INITIALIZER
12891 (struct cmd_macsec_offload_on_result,
12893 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
12894 TOKEN_STRING_INITIALIZER
12895 (struct cmd_macsec_offload_on_result,
12897 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
12898 TOKEN_STRING_INITIALIZER
12899 (struct cmd_macsec_offload_on_result,
12900 offload, "offload");
12901 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
12902 TOKEN_NUM_INITIALIZER
12903 (struct cmd_macsec_offload_on_result,
12905 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
12906 TOKEN_STRING_INITIALIZER
12907 (struct cmd_macsec_offload_on_result,
12909 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
12910 TOKEN_STRING_INITIALIZER
12911 (struct cmd_macsec_offload_on_result,
12912 encrypt, "encrypt");
12913 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
12914 TOKEN_STRING_INITIALIZER
12915 (struct cmd_macsec_offload_on_result,
12916 en_on_off, "on#off");
12917 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
12918 TOKEN_STRING_INITIALIZER
12919 (struct cmd_macsec_offload_on_result,
12920 replay_protect, "replay-protect");
12921 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
12922 TOKEN_STRING_INITIALIZER
12923 (struct cmd_macsec_offload_on_result,
12924 rp_on_off, "on#off");
12927 cmd_set_macsec_offload_on_parsed(
12928 void *parsed_result,
12929 __attribute__((unused)) struct cmdline *cl,
12930 __attribute__((unused)) void *data)
12932 struct cmd_macsec_offload_on_result *res = parsed_result;
12933 int ret = -ENOTSUP;
12934 portid_t port_id = res->port_id;
12935 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
12936 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
12938 if (port_id_is_invalid(port_id, ENABLED_WARN))
12941 ports[port_id].tx_ol_flags |= TESTPMD_TX_OFFLOAD_MACSEC;
12942 #ifdef RTE_LIBRTE_IXGBE_PMD
12943 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
12952 printf("invalid port_id %d\n", port_id);
12955 printf("not supported on port %d\n", port_id);
12958 printf("programming error: (%s)\n", strerror(-ret));
12962 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
12963 .f = cmd_set_macsec_offload_on_parsed,
12965 .help_str = "set macsec offload <port_id> on "
12966 "encrypt on|off replay-protect on|off",
12968 (void *)&cmd_macsec_offload_on_set,
12969 (void *)&cmd_macsec_offload_on_macsec,
12970 (void *)&cmd_macsec_offload_on_offload,
12971 (void *)&cmd_macsec_offload_on_port_id,
12972 (void *)&cmd_macsec_offload_on_on,
12973 (void *)&cmd_macsec_offload_on_encrypt,
12974 (void *)&cmd_macsec_offload_on_en_on_off,
12975 (void *)&cmd_macsec_offload_on_replay_protect,
12976 (void *)&cmd_macsec_offload_on_rp_on_off,
12981 /* Common result structure for MACsec offload disable */
12982 struct cmd_macsec_offload_off_result {
12983 cmdline_fixed_string_t set;
12984 cmdline_fixed_string_t macsec;
12985 cmdline_fixed_string_t offload;
12987 cmdline_fixed_string_t off;
12990 /* Common CLI fields for MACsec offload disable */
12991 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
12992 TOKEN_STRING_INITIALIZER
12993 (struct cmd_macsec_offload_off_result,
12995 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
12996 TOKEN_STRING_INITIALIZER
12997 (struct cmd_macsec_offload_off_result,
12999 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
13000 TOKEN_STRING_INITIALIZER
13001 (struct cmd_macsec_offload_off_result,
13002 offload, "offload");
13003 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
13004 TOKEN_NUM_INITIALIZER
13005 (struct cmd_macsec_offload_off_result,
13007 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
13008 TOKEN_STRING_INITIALIZER
13009 (struct cmd_macsec_offload_off_result,
13013 cmd_set_macsec_offload_off_parsed(
13014 void *parsed_result,
13015 __attribute__((unused)) struct cmdline *cl,
13016 __attribute__((unused)) void *data)
13018 struct cmd_macsec_offload_off_result *res = parsed_result;
13019 int ret = -ENOTSUP;
13020 portid_t port_id = res->port_id;
13022 if (port_id_is_invalid(port_id, ENABLED_WARN))
13025 ports[port_id].tx_ol_flags &= ~TESTPMD_TX_OFFLOAD_MACSEC;
13026 #ifdef RTE_LIBRTE_IXGBE_PMD
13027 ret = rte_pmd_ixgbe_macsec_disable(port_id);
13034 printf("invalid port_id %d\n", port_id);
13037 printf("not supported on port %d\n", port_id);
13040 printf("programming error: (%s)\n", strerror(-ret));
13044 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
13045 .f = cmd_set_macsec_offload_off_parsed,
13047 .help_str = "set macsec offload <port_id> off",
13049 (void *)&cmd_macsec_offload_off_set,
13050 (void *)&cmd_macsec_offload_off_macsec,
13051 (void *)&cmd_macsec_offload_off_offload,
13052 (void *)&cmd_macsec_offload_off_port_id,
13053 (void *)&cmd_macsec_offload_off_off,
13058 /* Common result structure for MACsec secure connection configure */
13059 struct cmd_macsec_sc_result {
13060 cmdline_fixed_string_t set;
13061 cmdline_fixed_string_t macsec;
13062 cmdline_fixed_string_t sc;
13063 cmdline_fixed_string_t tx_rx;
13065 struct ether_addr mac;
13069 /* Common CLI fields for MACsec secure connection configure */
13070 cmdline_parse_token_string_t cmd_macsec_sc_set =
13071 TOKEN_STRING_INITIALIZER
13072 (struct cmd_macsec_sc_result,
13074 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
13075 TOKEN_STRING_INITIALIZER
13076 (struct cmd_macsec_sc_result,
13078 cmdline_parse_token_string_t cmd_macsec_sc_sc =
13079 TOKEN_STRING_INITIALIZER
13080 (struct cmd_macsec_sc_result,
13082 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
13083 TOKEN_STRING_INITIALIZER
13084 (struct cmd_macsec_sc_result,
13086 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
13087 TOKEN_NUM_INITIALIZER
13088 (struct cmd_macsec_sc_result,
13090 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
13091 TOKEN_ETHERADDR_INITIALIZER
13092 (struct cmd_macsec_sc_result,
13094 cmdline_parse_token_num_t cmd_macsec_sc_pi =
13095 TOKEN_NUM_INITIALIZER
13096 (struct cmd_macsec_sc_result,
13100 cmd_set_macsec_sc_parsed(
13101 void *parsed_result,
13102 __attribute__((unused)) struct cmdline *cl,
13103 __attribute__((unused)) void *data)
13105 struct cmd_macsec_sc_result *res = parsed_result;
13106 int ret = -ENOTSUP;
13107 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
13109 #ifdef RTE_LIBRTE_IXGBE_PMD
13111 rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
13112 res->mac.addr_bytes) :
13113 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
13114 res->mac.addr_bytes, res->pi);
13116 RTE_SET_USED(is_tx);
13122 printf("invalid port_id %d\n", res->port_id);
13125 printf("not supported on port %d\n", res->port_id);
13128 printf("programming error: (%s)\n", strerror(-ret));
13132 cmdline_parse_inst_t cmd_set_macsec_sc = {
13133 .f = cmd_set_macsec_sc_parsed,
13135 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
13137 (void *)&cmd_macsec_sc_set,
13138 (void *)&cmd_macsec_sc_macsec,
13139 (void *)&cmd_macsec_sc_sc,
13140 (void *)&cmd_macsec_sc_tx_rx,
13141 (void *)&cmd_macsec_sc_port_id,
13142 (void *)&cmd_macsec_sc_mac,
13143 (void *)&cmd_macsec_sc_pi,
13148 /* Common result structure for MACsec secure connection configure */
13149 struct cmd_macsec_sa_result {
13150 cmdline_fixed_string_t set;
13151 cmdline_fixed_string_t macsec;
13152 cmdline_fixed_string_t sa;
13153 cmdline_fixed_string_t tx_rx;
13158 cmdline_fixed_string_t key;
13161 /* Common CLI fields for MACsec secure connection configure */
13162 cmdline_parse_token_string_t cmd_macsec_sa_set =
13163 TOKEN_STRING_INITIALIZER
13164 (struct cmd_macsec_sa_result,
13166 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
13167 TOKEN_STRING_INITIALIZER
13168 (struct cmd_macsec_sa_result,
13170 cmdline_parse_token_string_t cmd_macsec_sa_sa =
13171 TOKEN_STRING_INITIALIZER
13172 (struct cmd_macsec_sa_result,
13174 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
13175 TOKEN_STRING_INITIALIZER
13176 (struct cmd_macsec_sa_result,
13178 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
13179 TOKEN_NUM_INITIALIZER
13180 (struct cmd_macsec_sa_result,
13182 cmdline_parse_token_num_t cmd_macsec_sa_idx =
13183 TOKEN_NUM_INITIALIZER
13184 (struct cmd_macsec_sa_result,
13186 cmdline_parse_token_num_t cmd_macsec_sa_an =
13187 TOKEN_NUM_INITIALIZER
13188 (struct cmd_macsec_sa_result,
13190 cmdline_parse_token_num_t cmd_macsec_sa_pn =
13191 TOKEN_NUM_INITIALIZER
13192 (struct cmd_macsec_sa_result,
13194 cmdline_parse_token_string_t cmd_macsec_sa_key =
13195 TOKEN_STRING_INITIALIZER
13196 (struct cmd_macsec_sa_result,
13200 cmd_set_macsec_sa_parsed(
13201 void *parsed_result,
13202 __attribute__((unused)) struct cmdline *cl,
13203 __attribute__((unused)) void *data)
13205 struct cmd_macsec_sa_result *res = parsed_result;
13206 int ret = -ENOTSUP;
13207 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
13208 uint8_t key[16] = { 0 };
13214 key_len = strlen(res->key) / 2;
13218 for (i = 0; i < key_len; i++) {
13219 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
13222 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
13225 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
13228 #ifdef RTE_LIBRTE_IXGBE_PMD
13230 rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
13231 res->idx, res->an, res->pn, key) :
13232 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
13233 res->idx, res->an, res->pn, key);
13235 RTE_SET_USED(is_tx);
13242 printf("invalid idx %d or an %d\n", res->idx, res->an);
13245 printf("invalid port_id %d\n", res->port_id);
13248 printf("not supported on port %d\n", res->port_id);
13251 printf("programming error: (%s)\n", strerror(-ret));
13255 cmdline_parse_inst_t cmd_set_macsec_sa = {
13256 .f = cmd_set_macsec_sa_parsed,
13258 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
13260 (void *)&cmd_macsec_sa_set,
13261 (void *)&cmd_macsec_sa_macsec,
13262 (void *)&cmd_macsec_sa_sa,
13263 (void *)&cmd_macsec_sa_tx_rx,
13264 (void *)&cmd_macsec_sa_port_id,
13265 (void *)&cmd_macsec_sa_idx,
13266 (void *)&cmd_macsec_sa_an,
13267 (void *)&cmd_macsec_sa_pn,
13268 (void *)&cmd_macsec_sa_key,
13273 /* VF unicast promiscuous mode configuration */
13275 /* Common result structure for VF unicast promiscuous mode */
13276 struct cmd_vf_promisc_result {
13277 cmdline_fixed_string_t set;
13278 cmdline_fixed_string_t vf;
13279 cmdline_fixed_string_t promisc;
13282 cmdline_fixed_string_t on_off;
13285 /* Common CLI fields for VF unicast promiscuous mode enable disable */
13286 cmdline_parse_token_string_t cmd_vf_promisc_set =
13287 TOKEN_STRING_INITIALIZER
13288 (struct cmd_vf_promisc_result,
13290 cmdline_parse_token_string_t cmd_vf_promisc_vf =
13291 TOKEN_STRING_INITIALIZER
13292 (struct cmd_vf_promisc_result,
13294 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
13295 TOKEN_STRING_INITIALIZER
13296 (struct cmd_vf_promisc_result,
13297 promisc, "promisc");
13298 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
13299 TOKEN_NUM_INITIALIZER
13300 (struct cmd_vf_promisc_result,
13302 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
13303 TOKEN_NUM_INITIALIZER
13304 (struct cmd_vf_promisc_result,
13306 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
13307 TOKEN_STRING_INITIALIZER
13308 (struct cmd_vf_promisc_result,
13312 cmd_set_vf_promisc_parsed(
13313 void *parsed_result,
13314 __attribute__((unused)) struct cmdline *cl,
13315 __attribute__((unused)) void *data)
13317 struct cmd_vf_promisc_result *res = parsed_result;
13318 int ret = -ENOTSUP;
13320 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13322 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13325 #ifdef RTE_LIBRTE_I40E_PMD
13326 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
13327 res->vf_id, is_on);
13334 printf("invalid vf_id %d\n", res->vf_id);
13337 printf("invalid port_id %d\n", res->port_id);
13340 printf("function not implemented\n");
13343 printf("programming error: (%s)\n", strerror(-ret));
13347 cmdline_parse_inst_t cmd_set_vf_promisc = {
13348 .f = cmd_set_vf_promisc_parsed,
13350 .help_str = "set vf promisc <port_id> <vf_id> on|off: "
13351 "Set unicast promiscuous mode for a VF from the PF",
13353 (void *)&cmd_vf_promisc_set,
13354 (void *)&cmd_vf_promisc_vf,
13355 (void *)&cmd_vf_promisc_promisc,
13356 (void *)&cmd_vf_promisc_port_id,
13357 (void *)&cmd_vf_promisc_vf_id,
13358 (void *)&cmd_vf_promisc_on_off,
13363 /* VF multicast promiscuous mode configuration */
13365 /* Common result structure for VF multicast promiscuous mode */
13366 struct cmd_vf_allmulti_result {
13367 cmdline_fixed_string_t set;
13368 cmdline_fixed_string_t vf;
13369 cmdline_fixed_string_t allmulti;
13372 cmdline_fixed_string_t on_off;
13375 /* Common CLI fields for VF multicast promiscuous mode enable disable */
13376 cmdline_parse_token_string_t cmd_vf_allmulti_set =
13377 TOKEN_STRING_INITIALIZER
13378 (struct cmd_vf_allmulti_result,
13380 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
13381 TOKEN_STRING_INITIALIZER
13382 (struct cmd_vf_allmulti_result,
13384 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
13385 TOKEN_STRING_INITIALIZER
13386 (struct cmd_vf_allmulti_result,
13387 allmulti, "allmulti");
13388 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
13389 TOKEN_NUM_INITIALIZER
13390 (struct cmd_vf_allmulti_result,
13392 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
13393 TOKEN_NUM_INITIALIZER
13394 (struct cmd_vf_allmulti_result,
13396 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
13397 TOKEN_STRING_INITIALIZER
13398 (struct cmd_vf_allmulti_result,
13402 cmd_set_vf_allmulti_parsed(
13403 void *parsed_result,
13404 __attribute__((unused)) struct cmdline *cl,
13405 __attribute__((unused)) void *data)
13407 struct cmd_vf_allmulti_result *res = parsed_result;
13408 int ret = -ENOTSUP;
13410 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13412 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13415 #ifdef RTE_LIBRTE_I40E_PMD
13416 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
13417 res->vf_id, is_on);
13424 printf("invalid vf_id %d\n", res->vf_id);
13427 printf("invalid port_id %d\n", res->port_id);
13430 printf("function not implemented\n");
13433 printf("programming error: (%s)\n", strerror(-ret));
13437 cmdline_parse_inst_t cmd_set_vf_allmulti = {
13438 .f = cmd_set_vf_allmulti_parsed,
13440 .help_str = "set vf allmulti <port_id> <vf_id> on|off: "
13441 "Set multicast promiscuous mode for a VF from the PF",
13443 (void *)&cmd_vf_allmulti_set,
13444 (void *)&cmd_vf_allmulti_vf,
13445 (void *)&cmd_vf_allmulti_allmulti,
13446 (void *)&cmd_vf_allmulti_port_id,
13447 (void *)&cmd_vf_allmulti_vf_id,
13448 (void *)&cmd_vf_allmulti_on_off,
13453 /* vf broadcast mode configuration */
13455 /* Common result structure for vf broadcast */
13456 struct cmd_set_vf_broadcast_result {
13457 cmdline_fixed_string_t set;
13458 cmdline_fixed_string_t vf;
13459 cmdline_fixed_string_t broadcast;
13462 cmdline_fixed_string_t on_off;
13465 /* Common CLI fields for vf broadcast enable disable */
13466 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
13467 TOKEN_STRING_INITIALIZER
13468 (struct cmd_set_vf_broadcast_result,
13470 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
13471 TOKEN_STRING_INITIALIZER
13472 (struct cmd_set_vf_broadcast_result,
13474 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
13475 TOKEN_STRING_INITIALIZER
13476 (struct cmd_set_vf_broadcast_result,
13477 broadcast, "broadcast");
13478 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
13479 TOKEN_NUM_INITIALIZER
13480 (struct cmd_set_vf_broadcast_result,
13482 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
13483 TOKEN_NUM_INITIALIZER
13484 (struct cmd_set_vf_broadcast_result,
13486 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
13487 TOKEN_STRING_INITIALIZER
13488 (struct cmd_set_vf_broadcast_result,
13492 cmd_set_vf_broadcast_parsed(
13493 void *parsed_result,
13494 __attribute__((unused)) struct cmdline *cl,
13495 __attribute__((unused)) void *data)
13497 struct cmd_set_vf_broadcast_result *res = parsed_result;
13498 int ret = -ENOTSUP;
13500 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13502 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13505 #ifdef RTE_LIBRTE_I40E_PMD
13506 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
13507 res->vf_id, is_on);
13514 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13517 printf("invalid port_id %d\n", res->port_id);
13520 printf("function not implemented\n");
13523 printf("programming error: (%s)\n", strerror(-ret));
13527 cmdline_parse_inst_t cmd_set_vf_broadcast = {
13528 .f = cmd_set_vf_broadcast_parsed,
13530 .help_str = "set vf broadcast <port_id> <vf_id> on|off",
13532 (void *)&cmd_set_vf_broadcast_set,
13533 (void *)&cmd_set_vf_broadcast_vf,
13534 (void *)&cmd_set_vf_broadcast_broadcast,
13535 (void *)&cmd_set_vf_broadcast_port_id,
13536 (void *)&cmd_set_vf_broadcast_vf_id,
13537 (void *)&cmd_set_vf_broadcast_on_off,
13542 /* vf vlan tag configuration */
13544 /* Common result structure for vf vlan tag */
13545 struct cmd_set_vf_vlan_tag_result {
13546 cmdline_fixed_string_t set;
13547 cmdline_fixed_string_t vf;
13548 cmdline_fixed_string_t vlan;
13549 cmdline_fixed_string_t tag;
13552 cmdline_fixed_string_t on_off;
13555 /* Common CLI fields for vf vlan tag enable disable */
13556 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
13557 TOKEN_STRING_INITIALIZER
13558 (struct cmd_set_vf_vlan_tag_result,
13560 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
13561 TOKEN_STRING_INITIALIZER
13562 (struct cmd_set_vf_vlan_tag_result,
13564 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
13565 TOKEN_STRING_INITIALIZER
13566 (struct cmd_set_vf_vlan_tag_result,
13568 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
13569 TOKEN_STRING_INITIALIZER
13570 (struct cmd_set_vf_vlan_tag_result,
13572 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
13573 TOKEN_NUM_INITIALIZER
13574 (struct cmd_set_vf_vlan_tag_result,
13576 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
13577 TOKEN_NUM_INITIALIZER
13578 (struct cmd_set_vf_vlan_tag_result,
13580 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
13581 TOKEN_STRING_INITIALIZER
13582 (struct cmd_set_vf_vlan_tag_result,
13586 cmd_set_vf_vlan_tag_parsed(
13587 void *parsed_result,
13588 __attribute__((unused)) struct cmdline *cl,
13589 __attribute__((unused)) void *data)
13591 struct cmd_set_vf_vlan_tag_result *res = parsed_result;
13592 int ret = -ENOTSUP;
13594 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13596 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13599 #ifdef RTE_LIBRTE_I40E_PMD
13600 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
13601 res->vf_id, is_on);
13608 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13611 printf("invalid port_id %d\n", res->port_id);
13614 printf("function not implemented\n");
13617 printf("programming error: (%s)\n", strerror(-ret));
13621 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
13622 .f = cmd_set_vf_vlan_tag_parsed,
13624 .help_str = "set vf vlan tag <port_id> <vf_id> on|off",
13626 (void *)&cmd_set_vf_vlan_tag_set,
13627 (void *)&cmd_set_vf_vlan_tag_vf,
13628 (void *)&cmd_set_vf_vlan_tag_vlan,
13629 (void *)&cmd_set_vf_vlan_tag_tag,
13630 (void *)&cmd_set_vf_vlan_tag_port_id,
13631 (void *)&cmd_set_vf_vlan_tag_vf_id,
13632 (void *)&cmd_set_vf_vlan_tag_on_off,
13637 /* Common definition of VF and TC TX bandwidth configuration */
13638 struct cmd_vf_tc_bw_result {
13639 cmdline_fixed_string_t set;
13640 cmdline_fixed_string_t vf;
13641 cmdline_fixed_string_t tc;
13642 cmdline_fixed_string_t tx;
13643 cmdline_fixed_string_t min_bw;
13644 cmdline_fixed_string_t max_bw;
13645 cmdline_fixed_string_t strict_link_prio;
13650 cmdline_fixed_string_t bw_list;
13654 cmdline_parse_token_string_t cmd_vf_tc_bw_set =
13655 TOKEN_STRING_INITIALIZER
13656 (struct cmd_vf_tc_bw_result,
13658 cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
13659 TOKEN_STRING_INITIALIZER
13660 (struct cmd_vf_tc_bw_result,
13662 cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
13663 TOKEN_STRING_INITIALIZER
13664 (struct cmd_vf_tc_bw_result,
13666 cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
13667 TOKEN_STRING_INITIALIZER
13668 (struct cmd_vf_tc_bw_result,
13670 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio =
13671 TOKEN_STRING_INITIALIZER
13672 (struct cmd_vf_tc_bw_result,
13673 strict_link_prio, "strict-link-priority");
13674 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw =
13675 TOKEN_STRING_INITIALIZER
13676 (struct cmd_vf_tc_bw_result,
13677 min_bw, "min-bandwidth");
13678 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
13679 TOKEN_STRING_INITIALIZER
13680 (struct cmd_vf_tc_bw_result,
13681 max_bw, "max-bandwidth");
13682 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
13683 TOKEN_NUM_INITIALIZER
13684 (struct cmd_vf_tc_bw_result,
13686 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
13687 TOKEN_NUM_INITIALIZER
13688 (struct cmd_vf_tc_bw_result,
13690 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no =
13691 TOKEN_NUM_INITIALIZER
13692 (struct cmd_vf_tc_bw_result,
13694 cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
13695 TOKEN_NUM_INITIALIZER
13696 (struct cmd_vf_tc_bw_result,
13698 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
13699 TOKEN_STRING_INITIALIZER
13700 (struct cmd_vf_tc_bw_result,
13702 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map =
13703 TOKEN_NUM_INITIALIZER
13704 (struct cmd_vf_tc_bw_result,
13707 /* VF max bandwidth setting */
13709 cmd_vf_max_bw_parsed(
13710 void *parsed_result,
13711 __attribute__((unused)) struct cmdline *cl,
13712 __attribute__((unused)) void *data)
13714 struct cmd_vf_tc_bw_result *res = parsed_result;
13715 int ret = -ENOTSUP;
13717 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13720 #ifdef RTE_LIBRTE_I40E_PMD
13721 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id,
13722 res->vf_id, res->bw);
13729 printf("invalid vf_id %d or bandwidth %d\n",
13730 res->vf_id, res->bw);
13733 printf("invalid port_id %d\n", res->port_id);
13736 printf("function not implemented\n");
13739 printf("programming error: (%s)\n", strerror(-ret));
13743 cmdline_parse_inst_t cmd_vf_max_bw = {
13744 .f = cmd_vf_max_bw_parsed,
13746 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
13748 (void *)&cmd_vf_tc_bw_set,
13749 (void *)&cmd_vf_tc_bw_vf,
13750 (void *)&cmd_vf_tc_bw_tx,
13751 (void *)&cmd_vf_tc_bw_max_bw,
13752 (void *)&cmd_vf_tc_bw_port_id,
13753 (void *)&cmd_vf_tc_bw_vf_id,
13754 (void *)&cmd_vf_tc_bw_bw,
13760 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
13765 const char *p, *p0 = str;
13772 p = strchr(p0, '(');
13774 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
13778 p0 = strchr(p, ')');
13780 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
13784 if (size >= sizeof(s)) {
13785 printf("The string size exceeds the internal buffer size\n");
13788 snprintf(s, sizeof(s), "%.*s", size, p);
13789 ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
13791 printf("Failed to get the bandwidth list. ");
13795 for (i = 0; i < ret; i++)
13796 bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
13801 /* TC min bandwidth setting */
13803 cmd_vf_tc_min_bw_parsed(
13804 void *parsed_result,
13805 __attribute__((unused)) struct cmdline *cl,
13806 __attribute__((unused)) void *data)
13808 struct cmd_vf_tc_bw_result *res = parsed_result;
13811 int ret = -ENOTSUP;
13813 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13816 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
13820 #ifdef RTE_LIBRTE_I40E_PMD
13821 ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
13829 printf("invalid vf_id %d or bandwidth\n", res->vf_id);
13832 printf("invalid port_id %d\n", res->port_id);
13835 printf("function not implemented\n");
13838 printf("programming error: (%s)\n", strerror(-ret));
13842 cmdline_parse_inst_t cmd_vf_tc_min_bw = {
13843 .f = cmd_vf_tc_min_bw_parsed,
13845 .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
13846 " <bw1, bw2, ...>",
13848 (void *)&cmd_vf_tc_bw_set,
13849 (void *)&cmd_vf_tc_bw_vf,
13850 (void *)&cmd_vf_tc_bw_tc,
13851 (void *)&cmd_vf_tc_bw_tx,
13852 (void *)&cmd_vf_tc_bw_min_bw,
13853 (void *)&cmd_vf_tc_bw_port_id,
13854 (void *)&cmd_vf_tc_bw_vf_id,
13855 (void *)&cmd_vf_tc_bw_bw_list,
13861 cmd_tc_min_bw_parsed(
13862 void *parsed_result,
13863 __attribute__((unused)) struct cmdline *cl,
13864 __attribute__((unused)) void *data)
13866 struct cmd_vf_tc_bw_result *res = parsed_result;
13867 struct rte_port *port;
13870 int ret = -ENOTSUP;
13872 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13875 port = &ports[res->port_id];
13876 /** Check if the port is not started **/
13877 if (port->port_status != RTE_PORT_STOPPED) {
13878 printf("Please stop port %d first\n", res->port_id);
13882 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
13886 #ifdef RTE_LIBRTE_IXGBE_PMD
13887 ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw);
13894 printf("invalid bandwidth\n");
13897 printf("invalid port_id %d\n", res->port_id);
13900 printf("function not implemented\n");
13903 printf("programming error: (%s)\n", strerror(-ret));
13907 cmdline_parse_inst_t cmd_tc_min_bw = {
13908 .f = cmd_tc_min_bw_parsed,
13910 .help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>",
13912 (void *)&cmd_vf_tc_bw_set,
13913 (void *)&cmd_vf_tc_bw_tc,
13914 (void *)&cmd_vf_tc_bw_tx,
13915 (void *)&cmd_vf_tc_bw_min_bw,
13916 (void *)&cmd_vf_tc_bw_port_id,
13917 (void *)&cmd_vf_tc_bw_bw_list,
13922 /* TC max bandwidth setting */
13924 cmd_vf_tc_max_bw_parsed(
13925 void *parsed_result,
13926 __attribute__((unused)) struct cmdline *cl,
13927 __attribute__((unused)) void *data)
13929 struct cmd_vf_tc_bw_result *res = parsed_result;
13930 int ret = -ENOTSUP;
13932 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13935 #ifdef RTE_LIBRTE_I40E_PMD
13936 ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id,
13937 res->tc_no, res->bw);
13944 printf("invalid vf_id %d, tc_no %d or bandwidth %d\n",
13945 res->vf_id, res->tc_no, res->bw);
13948 printf("invalid port_id %d\n", res->port_id);
13951 printf("function not implemented\n");
13954 printf("programming error: (%s)\n", strerror(-ret));
13958 cmdline_parse_inst_t cmd_vf_tc_max_bw = {
13959 .f = cmd_vf_tc_max_bw_parsed,
13961 .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>"
13964 (void *)&cmd_vf_tc_bw_set,
13965 (void *)&cmd_vf_tc_bw_vf,
13966 (void *)&cmd_vf_tc_bw_tc,
13967 (void *)&cmd_vf_tc_bw_tx,
13968 (void *)&cmd_vf_tc_bw_max_bw,
13969 (void *)&cmd_vf_tc_bw_port_id,
13970 (void *)&cmd_vf_tc_bw_vf_id,
13971 (void *)&cmd_vf_tc_bw_tc_no,
13972 (void *)&cmd_vf_tc_bw_bw,
13978 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
13980 /* *** Set Port default Traffic Management Hierarchy *** */
13981 struct cmd_set_port_tm_hierarchy_default_result {
13982 cmdline_fixed_string_t set;
13983 cmdline_fixed_string_t port;
13984 cmdline_fixed_string_t tm;
13985 cmdline_fixed_string_t hierarchy;
13986 cmdline_fixed_string_t def;
13990 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_set =
13991 TOKEN_STRING_INITIALIZER(
13992 struct cmd_set_port_tm_hierarchy_default_result, set, "set");
13993 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_port =
13994 TOKEN_STRING_INITIALIZER(
13995 struct cmd_set_port_tm_hierarchy_default_result, port, "port");
13996 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_tm =
13997 TOKEN_STRING_INITIALIZER(
13998 struct cmd_set_port_tm_hierarchy_default_result, tm, "tm");
13999 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_hierarchy =
14000 TOKEN_STRING_INITIALIZER(
14001 struct cmd_set_port_tm_hierarchy_default_result,
14002 hierarchy, "hierarchy");
14003 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_default =
14004 TOKEN_STRING_INITIALIZER(
14005 struct cmd_set_port_tm_hierarchy_default_result,
14007 cmdline_parse_token_num_t cmd_set_port_tm_hierarchy_default_port_id =
14008 TOKEN_NUM_INITIALIZER(
14009 struct cmd_set_port_tm_hierarchy_default_result,
14012 static void cmd_set_port_tm_hierarchy_default_parsed(void *parsed_result,
14013 __attribute__((unused)) struct cmdline *cl,
14014 __attribute__((unused)) void *data)
14016 struct cmd_set_port_tm_hierarchy_default_result *res = parsed_result;
14017 struct rte_port *p;
14018 portid_t port_id = res->port_id;
14020 if (port_id_is_invalid(port_id, ENABLED_WARN))
14023 p = &ports[port_id];
14026 if (p->softport.tm_flag == 0) {
14027 printf(" tm not enabled on port %u (error)\n", port_id);
14031 /* Forward mode: tm */
14032 if (strcmp(cur_fwd_config.fwd_eng->fwd_mode_name, "tm")) {
14033 printf(" tm mode not enabled(error)\n");
14037 /* Set the default tm hierarchy */
14038 p->softport.tm.default_hierarchy_enable = 1;
14041 cmdline_parse_inst_t cmd_set_port_tm_hierarchy_default = {
14042 .f = cmd_set_port_tm_hierarchy_default_parsed,
14044 .help_str = "set port tm hierarchy default <port_id>",
14046 (void *)&cmd_set_port_tm_hierarchy_default_set,
14047 (void *)&cmd_set_port_tm_hierarchy_default_port,
14048 (void *)&cmd_set_port_tm_hierarchy_default_tm,
14049 (void *)&cmd_set_port_tm_hierarchy_default_hierarchy,
14050 (void *)&cmd_set_port_tm_hierarchy_default_default,
14051 (void *)&cmd_set_port_tm_hierarchy_default_port_id,
14057 /* Strict link priority scheduling mode setting */
14059 cmd_strict_link_prio_parsed(
14060 void *parsed_result,
14061 __attribute__((unused)) struct cmdline *cl,
14062 __attribute__((unused)) void *data)
14064 struct cmd_vf_tc_bw_result *res = parsed_result;
14065 int ret = -ENOTSUP;
14067 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14070 #ifdef RTE_LIBRTE_I40E_PMD
14071 ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map);
14078 printf("invalid tc_bitmap 0x%x\n", res->tc_map);
14081 printf("invalid port_id %d\n", res->port_id);
14084 printf("function not implemented\n");
14087 printf("programming error: (%s)\n", strerror(-ret));
14091 cmdline_parse_inst_t cmd_strict_link_prio = {
14092 .f = cmd_strict_link_prio_parsed,
14094 .help_str = "set tx strict-link-priority <port_id> <tc_bitmap>",
14096 (void *)&cmd_vf_tc_bw_set,
14097 (void *)&cmd_vf_tc_bw_tx,
14098 (void *)&cmd_vf_tc_bw_strict_link_prio,
14099 (void *)&cmd_vf_tc_bw_port_id,
14100 (void *)&cmd_vf_tc_bw_tc_map,
14105 /* Load dynamic device personalization*/
14106 struct cmd_ddp_add_result {
14107 cmdline_fixed_string_t ddp;
14108 cmdline_fixed_string_t add;
14113 cmdline_parse_token_string_t cmd_ddp_add_ddp =
14114 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp");
14115 cmdline_parse_token_string_t cmd_ddp_add_add =
14116 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add");
14117 cmdline_parse_token_num_t cmd_ddp_add_port_id =
14118 TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id, UINT16);
14119 cmdline_parse_token_string_t cmd_ddp_add_filepath =
14120 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL);
14123 cmd_ddp_add_parsed(
14124 void *parsed_result,
14125 __attribute__((unused)) struct cmdline *cl,
14126 __attribute__((unused)) void *data)
14128 struct cmd_ddp_add_result *res = parsed_result;
14134 int ret = -ENOTSUP;
14136 if (res->port_id > nb_ports) {
14137 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
14141 if (!all_ports_stopped()) {
14142 printf("Please stop all ports first\n");
14146 filepath = strdup(res->filepath);
14147 if (filepath == NULL) {
14148 printf("Failed to allocate memory\n");
14151 file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ',');
14153 buff = open_ddp_package_file(file_fld[0], &size);
14155 free((void *)filepath);
14159 #ifdef RTE_LIBRTE_I40E_PMD
14160 if (ret == -ENOTSUP)
14161 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
14163 RTE_PMD_I40E_PKG_OP_WR_ADD);
14166 if (ret == -EEXIST)
14167 printf("Profile has already existed.\n");
14169 printf("Failed to load profile.\n");
14170 else if (file_num == 2)
14171 save_ddp_package_file(file_fld[1], buff, size);
14173 close_ddp_package_file(buff);
14174 free((void *)filepath);
14177 cmdline_parse_inst_t cmd_ddp_add = {
14178 .f = cmd_ddp_add_parsed,
14180 .help_str = "ddp add <port_id> <profile_path[,output_path]>",
14182 (void *)&cmd_ddp_add_ddp,
14183 (void *)&cmd_ddp_add_add,
14184 (void *)&cmd_ddp_add_port_id,
14185 (void *)&cmd_ddp_add_filepath,
14190 /* Delete dynamic device personalization*/
14191 struct cmd_ddp_del_result {
14192 cmdline_fixed_string_t ddp;
14193 cmdline_fixed_string_t del;
14198 cmdline_parse_token_string_t cmd_ddp_del_ddp =
14199 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp");
14200 cmdline_parse_token_string_t cmd_ddp_del_del =
14201 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del");
14202 cmdline_parse_token_num_t cmd_ddp_del_port_id =
14203 TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, UINT16);
14204 cmdline_parse_token_string_t cmd_ddp_del_filepath =
14205 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL);
14208 cmd_ddp_del_parsed(
14209 void *parsed_result,
14210 __attribute__((unused)) struct cmdline *cl,
14211 __attribute__((unused)) void *data)
14213 struct cmd_ddp_del_result *res = parsed_result;
14216 int ret = -ENOTSUP;
14218 if (res->port_id > nb_ports) {
14219 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
14223 if (!all_ports_stopped()) {
14224 printf("Please stop all ports first\n");
14228 buff = open_ddp_package_file(res->filepath, &size);
14232 #ifdef RTE_LIBRTE_I40E_PMD
14233 if (ret == -ENOTSUP)
14234 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
14236 RTE_PMD_I40E_PKG_OP_WR_DEL);
14239 if (ret == -EACCES)
14240 printf("Profile does not exist.\n");
14242 printf("Failed to delete profile.\n");
14244 close_ddp_package_file(buff);
14247 cmdline_parse_inst_t cmd_ddp_del = {
14248 .f = cmd_ddp_del_parsed,
14250 .help_str = "ddp del <port_id> <profile_path>",
14252 (void *)&cmd_ddp_del_ddp,
14253 (void *)&cmd_ddp_del_del,
14254 (void *)&cmd_ddp_del_port_id,
14255 (void *)&cmd_ddp_del_filepath,
14260 /* Get dynamic device personalization profile info */
14261 struct cmd_ddp_info_result {
14262 cmdline_fixed_string_t ddp;
14263 cmdline_fixed_string_t get;
14264 cmdline_fixed_string_t info;
14268 cmdline_parse_token_string_t cmd_ddp_info_ddp =
14269 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp");
14270 cmdline_parse_token_string_t cmd_ddp_info_get =
14271 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get");
14272 cmdline_parse_token_string_t cmd_ddp_info_info =
14273 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info");
14274 cmdline_parse_token_string_t cmd_ddp_info_filepath =
14275 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL);
14278 cmd_ddp_info_parsed(
14279 void *parsed_result,
14280 __attribute__((unused)) struct cmdline *cl,
14281 __attribute__((unused)) void *data)
14283 struct cmd_ddp_info_result *res = parsed_result;
14286 int ret = -ENOTSUP;
14287 #ifdef RTE_LIBRTE_I40E_PMD
14290 uint32_t buff_size = 0;
14291 struct rte_pmd_i40e_profile_info info;
14292 uint32_t dev_num = 0;
14293 struct rte_pmd_i40e_ddp_device_id *devs;
14294 uint32_t proto_num = 0;
14295 struct rte_pmd_i40e_proto_info *proto;
14296 uint32_t pctype_num = 0;
14297 struct rte_pmd_i40e_ptype_info *pctype;
14298 uint32_t ptype_num = 0;
14299 struct rte_pmd_i40e_ptype_info *ptype;
14304 pkg = open_ddp_package_file(res->filepath, &pkg_size);
14308 #ifdef RTE_LIBRTE_I40E_PMD
14309 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14310 (uint8_t *)&info, sizeof(info),
14311 RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER);
14313 printf("Global Track id: 0x%x\n", info.track_id);
14314 printf("Global Version: %d.%d.%d.%d\n",
14315 info.version.major,
14316 info.version.minor,
14317 info.version.update,
14318 info.version.draft);
14319 printf("Global Package name: %s\n\n", info.name);
14322 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14323 (uint8_t *)&info, sizeof(info),
14324 RTE_PMD_I40E_PKG_INFO_HEADER);
14326 printf("i40e Profile Track id: 0x%x\n", info.track_id);
14327 printf("i40e Profile Version: %d.%d.%d.%d\n",
14328 info.version.major,
14329 info.version.minor,
14330 info.version.update,
14331 info.version.draft);
14332 printf("i40e Profile name: %s\n\n", info.name);
14335 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14336 (uint8_t *)&buff_size, sizeof(buff_size),
14337 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE);
14338 if (!ret && buff_size) {
14339 buff = (uint8_t *)malloc(buff_size);
14341 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14343 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES);
14345 printf("Package Notes:\n%s\n\n", buff);
14350 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14351 (uint8_t *)&dev_num, sizeof(dev_num),
14352 RTE_PMD_I40E_PKG_INFO_DEVID_NUM);
14353 if (!ret && dev_num) {
14354 buff_size = dev_num * sizeof(struct rte_pmd_i40e_ddp_device_id);
14355 devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(buff_size);
14357 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14358 (uint8_t *)devs, buff_size,
14359 RTE_PMD_I40E_PKG_INFO_DEVID_LIST);
14361 printf("List of supported devices:\n");
14362 for (i = 0; i < dev_num; i++) {
14363 printf(" %04X:%04X %04X:%04X\n",
14364 devs[i].vendor_dev_id >> 16,
14365 devs[i].vendor_dev_id & 0xFFFF,
14366 devs[i].sub_vendor_dev_id >> 16,
14367 devs[i].sub_vendor_dev_id & 0xFFFF);
14375 /* get information about protocols and packet types */
14376 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14377 (uint8_t *)&proto_num, sizeof(proto_num),
14378 RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM);
14379 if (ret || !proto_num)
14380 goto no_print_return;
14382 buff_size = proto_num * sizeof(struct rte_pmd_i40e_proto_info);
14383 proto = (struct rte_pmd_i40e_proto_info *)malloc(buff_size);
14385 goto no_print_return;
14387 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)proto,
14389 RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST);
14391 printf("List of used protocols:\n");
14392 for (i = 0; i < proto_num; i++)
14393 printf(" %2u: %s\n", proto[i].proto_id,
14397 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14398 (uint8_t *)&pctype_num, sizeof(pctype_num),
14399 RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM);
14400 if (ret || !pctype_num)
14401 goto no_print_pctypes;
14403 buff_size = pctype_num * sizeof(struct rte_pmd_i40e_ptype_info);
14404 pctype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
14406 goto no_print_pctypes;
14408 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)pctype,
14410 RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST);
14413 goto no_print_pctypes;
14416 printf("List of defined packet classification types:\n");
14417 for (i = 0; i < pctype_num; i++) {
14418 printf(" %2u:", pctype[i].ptype_id);
14419 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
14420 proto_id = pctype[i].protocols[j];
14421 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
14422 for (n = 0; n < proto_num; n++) {
14423 if (proto[n].proto_id == proto_id) {
14424 printf(" %s", proto[n].name);
14437 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)&ptype_num,
14439 RTE_PMD_I40E_PKG_INFO_PTYPE_NUM);
14440 if (ret || !ptype_num)
14441 goto no_print_return;
14443 buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_info);
14444 ptype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
14446 goto no_print_return;
14448 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)ptype,
14450 RTE_PMD_I40E_PKG_INFO_PTYPE_LIST);
14453 goto no_print_return;
14455 printf("List of defined packet types:\n");
14456 for (i = 0; i < ptype_num; i++) {
14457 printf(" %2u:", ptype[i].ptype_id);
14458 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
14459 proto_id = ptype[i].protocols[j];
14460 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
14461 for (n = 0; n < proto_num; n++) {
14462 if (proto[n].proto_id == proto_id) {
14463 printf(" %s", proto[n].name);
14478 if (ret == -ENOTSUP)
14479 printf("Function not supported in PMD driver\n");
14480 close_ddp_package_file(pkg);
14483 cmdline_parse_inst_t cmd_ddp_get_info = {
14484 .f = cmd_ddp_info_parsed,
14486 .help_str = "ddp get info <profile_path>",
14488 (void *)&cmd_ddp_info_ddp,
14489 (void *)&cmd_ddp_info_get,
14490 (void *)&cmd_ddp_info_info,
14491 (void *)&cmd_ddp_info_filepath,
14496 /* Get dynamic device personalization profile info list*/
14497 #define PROFILE_INFO_SIZE 48
14498 #define MAX_PROFILE_NUM 16
14500 struct cmd_ddp_get_list_result {
14501 cmdline_fixed_string_t ddp;
14502 cmdline_fixed_string_t get;
14503 cmdline_fixed_string_t list;
14507 cmdline_parse_token_string_t cmd_ddp_get_list_ddp =
14508 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp");
14509 cmdline_parse_token_string_t cmd_ddp_get_list_get =
14510 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get");
14511 cmdline_parse_token_string_t cmd_ddp_get_list_list =
14512 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list");
14513 cmdline_parse_token_num_t cmd_ddp_get_list_port_id =
14514 TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id, UINT16);
14517 cmd_ddp_get_list_parsed(
14518 void *parsed_result,
14519 __attribute__((unused)) struct cmdline *cl,
14520 __attribute__((unused)) void *data)
14522 struct cmd_ddp_get_list_result *res = parsed_result;
14523 #ifdef RTE_LIBRTE_I40E_PMD
14524 struct rte_pmd_i40e_profile_list *p_list;
14525 struct rte_pmd_i40e_profile_info *p_info;
14530 int ret = -ENOTSUP;
14532 if (res->port_id > nb_ports) {
14533 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
14537 #ifdef RTE_LIBRTE_I40E_PMD
14538 size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4;
14539 p_list = (struct rte_pmd_i40e_profile_list *)malloc(size);
14541 printf("%s: Failed to malloc buffer\n", __func__);
14543 if (ret == -ENOTSUP)
14544 ret = rte_pmd_i40e_get_ddp_list(res->port_id,
14545 (uint8_t *)p_list, size);
14548 p_num = p_list->p_count;
14549 printf("Profile number is: %d\n\n", p_num);
14551 for (i = 0; i < p_num; i++) {
14552 p_info = &p_list->p_info[i];
14553 printf("Profile %d:\n", i);
14554 printf("Track id: 0x%x\n", p_info->track_id);
14555 printf("Version: %d.%d.%d.%d\n",
14556 p_info->version.major,
14557 p_info->version.minor,
14558 p_info->version.update,
14559 p_info->version.draft);
14560 printf("Profile name: %s\n\n", p_info->name);
14568 printf("Failed to get ddp list\n");
14571 cmdline_parse_inst_t cmd_ddp_get_list = {
14572 .f = cmd_ddp_get_list_parsed,
14574 .help_str = "ddp get list <port_id>",
14576 (void *)&cmd_ddp_get_list_ddp,
14577 (void *)&cmd_ddp_get_list_get,
14578 (void *)&cmd_ddp_get_list_list,
14579 (void *)&cmd_ddp_get_list_port_id,
14584 /* show vf stats */
14586 /* Common result structure for show vf stats */
14587 struct cmd_show_vf_stats_result {
14588 cmdline_fixed_string_t show;
14589 cmdline_fixed_string_t vf;
14590 cmdline_fixed_string_t stats;
14595 /* Common CLI fields show vf stats*/
14596 cmdline_parse_token_string_t cmd_show_vf_stats_show =
14597 TOKEN_STRING_INITIALIZER
14598 (struct cmd_show_vf_stats_result,
14600 cmdline_parse_token_string_t cmd_show_vf_stats_vf =
14601 TOKEN_STRING_INITIALIZER
14602 (struct cmd_show_vf_stats_result,
14604 cmdline_parse_token_string_t cmd_show_vf_stats_stats =
14605 TOKEN_STRING_INITIALIZER
14606 (struct cmd_show_vf_stats_result,
14608 cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
14609 TOKEN_NUM_INITIALIZER
14610 (struct cmd_show_vf_stats_result,
14612 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
14613 TOKEN_NUM_INITIALIZER
14614 (struct cmd_show_vf_stats_result,
14618 cmd_show_vf_stats_parsed(
14619 void *parsed_result,
14620 __attribute__((unused)) struct cmdline *cl,
14621 __attribute__((unused)) void *data)
14623 struct cmd_show_vf_stats_result *res = parsed_result;
14624 struct rte_eth_stats stats;
14625 int ret = -ENOTSUP;
14626 static const char *nic_stats_border = "########################";
14628 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14631 memset(&stats, 0, sizeof(stats));
14633 #ifdef RTE_LIBRTE_I40E_PMD
14634 if (ret == -ENOTSUP)
14635 ret = rte_pmd_i40e_get_vf_stats(res->port_id,
14639 #ifdef RTE_LIBRTE_BNXT_PMD
14640 if (ret == -ENOTSUP)
14641 ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
14650 printf("invalid vf_id %d\n", res->vf_id);
14653 printf("invalid port_id %d\n", res->port_id);
14656 printf("function not implemented\n");
14659 printf("programming error: (%s)\n", strerror(-ret));
14662 printf("\n %s NIC statistics for port %-2d vf %-2d %s\n",
14663 nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
14665 printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: "
14667 stats.ipackets, stats.imissed, stats.ibytes);
14668 printf(" RX-errors: %-"PRIu64"\n", stats.ierrors);
14669 printf(" RX-nombuf: %-10"PRIu64"\n",
14671 printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: "
14673 stats.opackets, stats.oerrors, stats.obytes);
14675 printf(" %s############################%s\n",
14676 nic_stats_border, nic_stats_border);
14679 cmdline_parse_inst_t cmd_show_vf_stats = {
14680 .f = cmd_show_vf_stats_parsed,
14682 .help_str = "show vf stats <port_id> <vf_id>",
14684 (void *)&cmd_show_vf_stats_show,
14685 (void *)&cmd_show_vf_stats_vf,
14686 (void *)&cmd_show_vf_stats_stats,
14687 (void *)&cmd_show_vf_stats_port_id,
14688 (void *)&cmd_show_vf_stats_vf_id,
14693 /* clear vf stats */
14695 /* Common result structure for clear vf stats */
14696 struct cmd_clear_vf_stats_result {
14697 cmdline_fixed_string_t clear;
14698 cmdline_fixed_string_t vf;
14699 cmdline_fixed_string_t stats;
14704 /* Common CLI fields clear vf stats*/
14705 cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
14706 TOKEN_STRING_INITIALIZER
14707 (struct cmd_clear_vf_stats_result,
14709 cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
14710 TOKEN_STRING_INITIALIZER
14711 (struct cmd_clear_vf_stats_result,
14713 cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
14714 TOKEN_STRING_INITIALIZER
14715 (struct cmd_clear_vf_stats_result,
14717 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
14718 TOKEN_NUM_INITIALIZER
14719 (struct cmd_clear_vf_stats_result,
14721 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
14722 TOKEN_NUM_INITIALIZER
14723 (struct cmd_clear_vf_stats_result,
14727 cmd_clear_vf_stats_parsed(
14728 void *parsed_result,
14729 __attribute__((unused)) struct cmdline *cl,
14730 __attribute__((unused)) void *data)
14732 struct cmd_clear_vf_stats_result *res = parsed_result;
14733 int ret = -ENOTSUP;
14735 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14738 #ifdef RTE_LIBRTE_I40E_PMD
14739 if (ret == -ENOTSUP)
14740 ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
14743 #ifdef RTE_LIBRTE_BNXT_PMD
14744 if (ret == -ENOTSUP)
14745 ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
14753 printf("invalid vf_id %d\n", res->vf_id);
14756 printf("invalid port_id %d\n", res->port_id);
14759 printf("function not implemented\n");
14762 printf("programming error: (%s)\n", strerror(-ret));
14766 cmdline_parse_inst_t cmd_clear_vf_stats = {
14767 .f = cmd_clear_vf_stats_parsed,
14769 .help_str = "clear vf stats <port_id> <vf_id>",
14771 (void *)&cmd_clear_vf_stats_clear,
14772 (void *)&cmd_clear_vf_stats_vf,
14773 (void *)&cmd_clear_vf_stats_stats,
14774 (void *)&cmd_clear_vf_stats_port_id,
14775 (void *)&cmd_clear_vf_stats_vf_id,
14780 /* port config pctype mapping reset */
14782 /* Common result structure for port config pctype mapping reset */
14783 struct cmd_pctype_mapping_reset_result {
14784 cmdline_fixed_string_t port;
14785 cmdline_fixed_string_t config;
14787 cmdline_fixed_string_t pctype;
14788 cmdline_fixed_string_t mapping;
14789 cmdline_fixed_string_t reset;
14792 /* Common CLI fields for port config pctype mapping reset*/
14793 cmdline_parse_token_string_t cmd_pctype_mapping_reset_port =
14794 TOKEN_STRING_INITIALIZER
14795 (struct cmd_pctype_mapping_reset_result,
14797 cmdline_parse_token_string_t cmd_pctype_mapping_reset_config =
14798 TOKEN_STRING_INITIALIZER
14799 (struct cmd_pctype_mapping_reset_result,
14801 cmdline_parse_token_num_t cmd_pctype_mapping_reset_port_id =
14802 TOKEN_NUM_INITIALIZER
14803 (struct cmd_pctype_mapping_reset_result,
14805 cmdline_parse_token_string_t cmd_pctype_mapping_reset_pctype =
14806 TOKEN_STRING_INITIALIZER
14807 (struct cmd_pctype_mapping_reset_result,
14809 cmdline_parse_token_string_t cmd_pctype_mapping_reset_mapping =
14810 TOKEN_STRING_INITIALIZER
14811 (struct cmd_pctype_mapping_reset_result,
14812 mapping, "mapping");
14813 cmdline_parse_token_string_t cmd_pctype_mapping_reset_reset =
14814 TOKEN_STRING_INITIALIZER
14815 (struct cmd_pctype_mapping_reset_result,
14819 cmd_pctype_mapping_reset_parsed(
14820 void *parsed_result,
14821 __attribute__((unused)) struct cmdline *cl,
14822 __attribute__((unused)) void *data)
14824 struct cmd_pctype_mapping_reset_result *res = parsed_result;
14825 int ret = -ENOTSUP;
14827 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14830 #ifdef RTE_LIBRTE_I40E_PMD
14831 ret = rte_pmd_i40e_flow_type_mapping_reset(res->port_id);
14838 printf("invalid port_id %d\n", res->port_id);
14841 printf("function not implemented\n");
14844 printf("programming error: (%s)\n", strerror(-ret));
14848 cmdline_parse_inst_t cmd_pctype_mapping_reset = {
14849 .f = cmd_pctype_mapping_reset_parsed,
14851 .help_str = "port config <port_id> pctype mapping reset",
14853 (void *)&cmd_pctype_mapping_reset_port,
14854 (void *)&cmd_pctype_mapping_reset_config,
14855 (void *)&cmd_pctype_mapping_reset_port_id,
14856 (void *)&cmd_pctype_mapping_reset_pctype,
14857 (void *)&cmd_pctype_mapping_reset_mapping,
14858 (void *)&cmd_pctype_mapping_reset_reset,
14863 /* show port pctype mapping */
14865 /* Common result structure for show port pctype mapping */
14866 struct cmd_pctype_mapping_get_result {
14867 cmdline_fixed_string_t show;
14868 cmdline_fixed_string_t port;
14870 cmdline_fixed_string_t pctype;
14871 cmdline_fixed_string_t mapping;
14874 /* Common CLI fields for pctype mapping get */
14875 cmdline_parse_token_string_t cmd_pctype_mapping_get_show =
14876 TOKEN_STRING_INITIALIZER
14877 (struct cmd_pctype_mapping_get_result,
14879 cmdline_parse_token_string_t cmd_pctype_mapping_get_port =
14880 TOKEN_STRING_INITIALIZER
14881 (struct cmd_pctype_mapping_get_result,
14883 cmdline_parse_token_num_t cmd_pctype_mapping_get_port_id =
14884 TOKEN_NUM_INITIALIZER
14885 (struct cmd_pctype_mapping_get_result,
14887 cmdline_parse_token_string_t cmd_pctype_mapping_get_pctype =
14888 TOKEN_STRING_INITIALIZER
14889 (struct cmd_pctype_mapping_get_result,
14891 cmdline_parse_token_string_t cmd_pctype_mapping_get_mapping =
14892 TOKEN_STRING_INITIALIZER
14893 (struct cmd_pctype_mapping_get_result,
14894 mapping, "mapping");
14897 cmd_pctype_mapping_get_parsed(
14898 void *parsed_result,
14899 __attribute__((unused)) struct cmdline *cl,
14900 __attribute__((unused)) void *data)
14902 struct cmd_pctype_mapping_get_result *res = parsed_result;
14903 int ret = -ENOTSUP;
14904 #ifdef RTE_LIBRTE_I40E_PMD
14905 struct rte_pmd_i40e_flow_type_mapping
14906 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
14907 int i, j, first_pctype;
14910 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14913 #ifdef RTE_LIBRTE_I40E_PMD
14914 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, mapping);
14921 printf("invalid port_id %d\n", res->port_id);
14924 printf("function not implemented\n");
14927 printf("programming error: (%s)\n", strerror(-ret));
14931 #ifdef RTE_LIBRTE_I40E_PMD
14932 for (i = 0; i < RTE_PMD_I40E_FLOW_TYPE_MAX; i++) {
14933 if (mapping[i].pctype != 0ULL) {
14936 printf("pctype: ");
14937 for (j = 0; j < RTE_PMD_I40E_PCTYPE_MAX; j++) {
14938 if (mapping[i].pctype & (1ULL << j)) {
14939 printf(first_pctype ?
14940 "%02d" : ",%02d", j);
14944 printf(" -> flowtype: %02d\n", mapping[i].flow_type);
14950 cmdline_parse_inst_t cmd_pctype_mapping_get = {
14951 .f = cmd_pctype_mapping_get_parsed,
14953 .help_str = "show port <port_id> pctype mapping",
14955 (void *)&cmd_pctype_mapping_get_show,
14956 (void *)&cmd_pctype_mapping_get_port,
14957 (void *)&cmd_pctype_mapping_get_port_id,
14958 (void *)&cmd_pctype_mapping_get_pctype,
14959 (void *)&cmd_pctype_mapping_get_mapping,
14964 /* port config pctype mapping update */
14966 /* Common result structure for port config pctype mapping update */
14967 struct cmd_pctype_mapping_update_result {
14968 cmdline_fixed_string_t port;
14969 cmdline_fixed_string_t config;
14971 cmdline_fixed_string_t pctype;
14972 cmdline_fixed_string_t mapping;
14973 cmdline_fixed_string_t update;
14974 cmdline_fixed_string_t pctype_list;
14975 uint16_t flow_type;
14978 /* Common CLI fields for pctype mapping update*/
14979 cmdline_parse_token_string_t cmd_pctype_mapping_update_port =
14980 TOKEN_STRING_INITIALIZER
14981 (struct cmd_pctype_mapping_update_result,
14983 cmdline_parse_token_string_t cmd_pctype_mapping_update_config =
14984 TOKEN_STRING_INITIALIZER
14985 (struct cmd_pctype_mapping_update_result,
14987 cmdline_parse_token_num_t cmd_pctype_mapping_update_port_id =
14988 TOKEN_NUM_INITIALIZER
14989 (struct cmd_pctype_mapping_update_result,
14991 cmdline_parse_token_string_t cmd_pctype_mapping_update_pctype =
14992 TOKEN_STRING_INITIALIZER
14993 (struct cmd_pctype_mapping_update_result,
14995 cmdline_parse_token_string_t cmd_pctype_mapping_update_mapping =
14996 TOKEN_STRING_INITIALIZER
14997 (struct cmd_pctype_mapping_update_result,
14998 mapping, "mapping");
14999 cmdline_parse_token_string_t cmd_pctype_mapping_update_update =
15000 TOKEN_STRING_INITIALIZER
15001 (struct cmd_pctype_mapping_update_result,
15003 cmdline_parse_token_string_t cmd_pctype_mapping_update_pc_type =
15004 TOKEN_STRING_INITIALIZER
15005 (struct cmd_pctype_mapping_update_result,
15006 pctype_list, NULL);
15007 cmdline_parse_token_num_t cmd_pctype_mapping_update_flow_type =
15008 TOKEN_NUM_INITIALIZER
15009 (struct cmd_pctype_mapping_update_result,
15010 flow_type, UINT16);
15013 cmd_pctype_mapping_update_parsed(
15014 void *parsed_result,
15015 __attribute__((unused)) struct cmdline *cl,
15016 __attribute__((unused)) void *data)
15018 struct cmd_pctype_mapping_update_result *res = parsed_result;
15019 int ret = -ENOTSUP;
15020 #ifdef RTE_LIBRTE_I40E_PMD
15021 struct rte_pmd_i40e_flow_type_mapping mapping;
15023 unsigned int nb_item;
15024 unsigned int pctype_list[RTE_PMD_I40E_PCTYPE_MAX];
15027 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15030 #ifdef RTE_LIBRTE_I40E_PMD
15031 nb_item = parse_item_list(res->pctype_list, "pctypes",
15032 RTE_PMD_I40E_PCTYPE_MAX, pctype_list, 1);
15033 mapping.flow_type = res->flow_type;
15034 for (i = 0, mapping.pctype = 0ULL; i < nb_item; i++)
15035 mapping.pctype |= (1ULL << pctype_list[i]);
15036 ret = rte_pmd_i40e_flow_type_mapping_update(res->port_id,
15046 printf("invalid pctype or flow type\n");
15049 printf("invalid port_id %d\n", res->port_id);
15052 printf("function not implemented\n");
15055 printf("programming error: (%s)\n", strerror(-ret));
15059 cmdline_parse_inst_t cmd_pctype_mapping_update = {
15060 .f = cmd_pctype_mapping_update_parsed,
15062 .help_str = "port config <port_id> pctype mapping update"
15063 " <pctype_id_0,[pctype_id_1]*> <flowtype_id>",
15065 (void *)&cmd_pctype_mapping_update_port,
15066 (void *)&cmd_pctype_mapping_update_config,
15067 (void *)&cmd_pctype_mapping_update_port_id,
15068 (void *)&cmd_pctype_mapping_update_pctype,
15069 (void *)&cmd_pctype_mapping_update_mapping,
15070 (void *)&cmd_pctype_mapping_update_update,
15071 (void *)&cmd_pctype_mapping_update_pc_type,
15072 (void *)&cmd_pctype_mapping_update_flow_type,
15077 /* ptype mapping get */
15079 /* Common result structure for ptype mapping get */
15080 struct cmd_ptype_mapping_get_result {
15081 cmdline_fixed_string_t ptype;
15082 cmdline_fixed_string_t mapping;
15083 cmdline_fixed_string_t get;
15085 uint8_t valid_only;
15088 /* Common CLI fields for ptype mapping get */
15089 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype =
15090 TOKEN_STRING_INITIALIZER
15091 (struct cmd_ptype_mapping_get_result,
15093 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping =
15094 TOKEN_STRING_INITIALIZER
15095 (struct cmd_ptype_mapping_get_result,
15096 mapping, "mapping");
15097 cmdline_parse_token_string_t cmd_ptype_mapping_get_get =
15098 TOKEN_STRING_INITIALIZER
15099 (struct cmd_ptype_mapping_get_result,
15101 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id =
15102 TOKEN_NUM_INITIALIZER
15103 (struct cmd_ptype_mapping_get_result,
15105 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only =
15106 TOKEN_NUM_INITIALIZER
15107 (struct cmd_ptype_mapping_get_result,
15108 valid_only, UINT8);
15111 cmd_ptype_mapping_get_parsed(
15112 void *parsed_result,
15113 __attribute__((unused)) struct cmdline *cl,
15114 __attribute__((unused)) void *data)
15116 struct cmd_ptype_mapping_get_result *res = parsed_result;
15117 int ret = -ENOTSUP;
15118 #ifdef RTE_LIBRTE_I40E_PMD
15119 int max_ptype_num = 256;
15120 struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num];
15125 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15128 #ifdef RTE_LIBRTE_I40E_PMD
15129 ret = rte_pmd_i40e_ptype_mapping_get(res->port_id,
15140 printf("invalid port_id %d\n", res->port_id);
15143 printf("function not implemented\n");
15146 printf("programming error: (%s)\n", strerror(-ret));
15149 #ifdef RTE_LIBRTE_I40E_PMD
15151 for (i = 0; i < count; i++)
15152 printf("%3d\t0x%08x\n",
15153 mapping[i].hw_ptype, mapping[i].sw_ptype);
15158 cmdline_parse_inst_t cmd_ptype_mapping_get = {
15159 .f = cmd_ptype_mapping_get_parsed,
15161 .help_str = "ptype mapping get <port_id> <valid_only>",
15163 (void *)&cmd_ptype_mapping_get_ptype,
15164 (void *)&cmd_ptype_mapping_get_mapping,
15165 (void *)&cmd_ptype_mapping_get_get,
15166 (void *)&cmd_ptype_mapping_get_port_id,
15167 (void *)&cmd_ptype_mapping_get_valid_only,
15172 /* ptype mapping replace */
15174 /* Common result structure for ptype mapping replace */
15175 struct cmd_ptype_mapping_replace_result {
15176 cmdline_fixed_string_t ptype;
15177 cmdline_fixed_string_t mapping;
15178 cmdline_fixed_string_t replace;
15185 /* Common CLI fields for ptype mapping replace */
15186 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype =
15187 TOKEN_STRING_INITIALIZER
15188 (struct cmd_ptype_mapping_replace_result,
15190 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping =
15191 TOKEN_STRING_INITIALIZER
15192 (struct cmd_ptype_mapping_replace_result,
15193 mapping, "mapping");
15194 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace =
15195 TOKEN_STRING_INITIALIZER
15196 (struct cmd_ptype_mapping_replace_result,
15197 replace, "replace");
15198 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id =
15199 TOKEN_NUM_INITIALIZER
15200 (struct cmd_ptype_mapping_replace_result,
15202 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target =
15203 TOKEN_NUM_INITIALIZER
15204 (struct cmd_ptype_mapping_replace_result,
15206 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask =
15207 TOKEN_NUM_INITIALIZER
15208 (struct cmd_ptype_mapping_replace_result,
15210 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type =
15211 TOKEN_NUM_INITIALIZER
15212 (struct cmd_ptype_mapping_replace_result,
15216 cmd_ptype_mapping_replace_parsed(
15217 void *parsed_result,
15218 __attribute__((unused)) struct cmdline *cl,
15219 __attribute__((unused)) void *data)
15221 struct cmd_ptype_mapping_replace_result *res = parsed_result;
15222 int ret = -ENOTSUP;
15224 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15227 #ifdef RTE_LIBRTE_I40E_PMD
15228 ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id,
15238 printf("invalid ptype 0x%8x or 0x%8x\n",
15239 res->target, res->pkt_type);
15242 printf("invalid port_id %d\n", res->port_id);
15245 printf("function not implemented\n");
15248 printf("programming error: (%s)\n", strerror(-ret));
15252 cmdline_parse_inst_t cmd_ptype_mapping_replace = {
15253 .f = cmd_ptype_mapping_replace_parsed,
15256 "ptype mapping replace <port_id> <target> <mask> <pkt_type>",
15258 (void *)&cmd_ptype_mapping_replace_ptype,
15259 (void *)&cmd_ptype_mapping_replace_mapping,
15260 (void *)&cmd_ptype_mapping_replace_replace,
15261 (void *)&cmd_ptype_mapping_replace_port_id,
15262 (void *)&cmd_ptype_mapping_replace_target,
15263 (void *)&cmd_ptype_mapping_replace_mask,
15264 (void *)&cmd_ptype_mapping_replace_pkt_type,
15269 /* ptype mapping reset */
15271 /* Common result structure for ptype mapping reset */
15272 struct cmd_ptype_mapping_reset_result {
15273 cmdline_fixed_string_t ptype;
15274 cmdline_fixed_string_t mapping;
15275 cmdline_fixed_string_t reset;
15279 /* Common CLI fields for ptype mapping reset*/
15280 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype =
15281 TOKEN_STRING_INITIALIZER
15282 (struct cmd_ptype_mapping_reset_result,
15284 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping =
15285 TOKEN_STRING_INITIALIZER
15286 (struct cmd_ptype_mapping_reset_result,
15287 mapping, "mapping");
15288 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset =
15289 TOKEN_STRING_INITIALIZER
15290 (struct cmd_ptype_mapping_reset_result,
15292 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id =
15293 TOKEN_NUM_INITIALIZER
15294 (struct cmd_ptype_mapping_reset_result,
15298 cmd_ptype_mapping_reset_parsed(
15299 void *parsed_result,
15300 __attribute__((unused)) struct cmdline *cl,
15301 __attribute__((unused)) void *data)
15303 struct cmd_ptype_mapping_reset_result *res = parsed_result;
15304 int ret = -ENOTSUP;
15306 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15309 #ifdef RTE_LIBRTE_I40E_PMD
15310 ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id);
15317 printf("invalid port_id %d\n", res->port_id);
15320 printf("function not implemented\n");
15323 printf("programming error: (%s)\n", strerror(-ret));
15327 cmdline_parse_inst_t cmd_ptype_mapping_reset = {
15328 .f = cmd_ptype_mapping_reset_parsed,
15330 .help_str = "ptype mapping reset <port_id>",
15332 (void *)&cmd_ptype_mapping_reset_ptype,
15333 (void *)&cmd_ptype_mapping_reset_mapping,
15334 (void *)&cmd_ptype_mapping_reset_reset,
15335 (void *)&cmd_ptype_mapping_reset_port_id,
15340 /* ptype mapping update */
15342 /* Common result structure for ptype mapping update */
15343 struct cmd_ptype_mapping_update_result {
15344 cmdline_fixed_string_t ptype;
15345 cmdline_fixed_string_t mapping;
15346 cmdline_fixed_string_t reset;
15352 /* Common CLI fields for ptype mapping update*/
15353 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype =
15354 TOKEN_STRING_INITIALIZER
15355 (struct cmd_ptype_mapping_update_result,
15357 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping =
15358 TOKEN_STRING_INITIALIZER
15359 (struct cmd_ptype_mapping_update_result,
15360 mapping, "mapping");
15361 cmdline_parse_token_string_t cmd_ptype_mapping_update_update =
15362 TOKEN_STRING_INITIALIZER
15363 (struct cmd_ptype_mapping_update_result,
15365 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id =
15366 TOKEN_NUM_INITIALIZER
15367 (struct cmd_ptype_mapping_update_result,
15369 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype =
15370 TOKEN_NUM_INITIALIZER
15371 (struct cmd_ptype_mapping_update_result,
15373 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype =
15374 TOKEN_NUM_INITIALIZER
15375 (struct cmd_ptype_mapping_update_result,
15379 cmd_ptype_mapping_update_parsed(
15380 void *parsed_result,
15381 __attribute__((unused)) struct cmdline *cl,
15382 __attribute__((unused)) void *data)
15384 struct cmd_ptype_mapping_update_result *res = parsed_result;
15385 int ret = -ENOTSUP;
15386 #ifdef RTE_LIBRTE_I40E_PMD
15387 struct rte_pmd_i40e_ptype_mapping mapping;
15389 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15392 #ifdef RTE_LIBRTE_I40E_PMD
15393 mapping.hw_ptype = res->hw_ptype;
15394 mapping.sw_ptype = res->sw_ptype;
15395 ret = rte_pmd_i40e_ptype_mapping_update(res->port_id,
15405 printf("invalid ptype 0x%8x\n", res->sw_ptype);
15408 printf("invalid port_id %d\n", res->port_id);
15411 printf("function not implemented\n");
15414 printf("programming error: (%s)\n", strerror(-ret));
15418 cmdline_parse_inst_t cmd_ptype_mapping_update = {
15419 .f = cmd_ptype_mapping_update_parsed,
15421 .help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>",
15423 (void *)&cmd_ptype_mapping_update_ptype,
15424 (void *)&cmd_ptype_mapping_update_mapping,
15425 (void *)&cmd_ptype_mapping_update_update,
15426 (void *)&cmd_ptype_mapping_update_port_id,
15427 (void *)&cmd_ptype_mapping_update_hw_ptype,
15428 (void *)&cmd_ptype_mapping_update_sw_ptype,
15433 /* Common result structure for file commands */
15434 struct cmd_cmdfile_result {
15435 cmdline_fixed_string_t load;
15436 cmdline_fixed_string_t filename;
15439 /* Common CLI fields for file commands */
15440 cmdline_parse_token_string_t cmd_load_cmdfile =
15441 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
15442 cmdline_parse_token_string_t cmd_load_cmdfile_filename =
15443 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
15446 cmd_load_from_file_parsed(
15447 void *parsed_result,
15448 __attribute__((unused)) struct cmdline *cl,
15449 __attribute__((unused)) void *data)
15451 struct cmd_cmdfile_result *res = parsed_result;
15453 cmdline_read_from_file(res->filename);
15456 cmdline_parse_inst_t cmd_load_from_file = {
15457 .f = cmd_load_from_file_parsed,
15459 .help_str = "load <filename>",
15461 (void *)&cmd_load_cmdfile,
15462 (void *)&cmd_load_cmdfile_filename,
15467 /* ******************************************************************************** */
15469 /* list of instructions */
15470 cmdline_parse_ctx_t main_ctx[] = {
15471 (cmdline_parse_inst_t *)&cmd_help_brief,
15472 (cmdline_parse_inst_t *)&cmd_help_long,
15473 (cmdline_parse_inst_t *)&cmd_quit,
15474 (cmdline_parse_inst_t *)&cmd_load_from_file,
15475 (cmdline_parse_inst_t *)&cmd_showport,
15476 (cmdline_parse_inst_t *)&cmd_showqueue,
15477 (cmdline_parse_inst_t *)&cmd_showportall,
15478 (cmdline_parse_inst_t *)&cmd_showcfg,
15479 (cmdline_parse_inst_t *)&cmd_start,
15480 (cmdline_parse_inst_t *)&cmd_start_tx_first,
15481 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
15482 (cmdline_parse_inst_t *)&cmd_set_link_up,
15483 (cmdline_parse_inst_t *)&cmd_set_link_down,
15484 (cmdline_parse_inst_t *)&cmd_reset,
15485 (cmdline_parse_inst_t *)&cmd_set_numbers,
15486 (cmdline_parse_inst_t *)&cmd_set_txpkts,
15487 (cmdline_parse_inst_t *)&cmd_set_txsplit,
15488 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
15489 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
15490 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
15491 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
15492 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
15493 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
15494 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
15495 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
15496 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
15497 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
15498 (cmdline_parse_inst_t *)&cmd_set_link_check,
15499 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
15500 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
15501 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
15502 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
15503 #ifdef RTE_LIBRTE_PMD_BOND
15504 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
15505 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
15506 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
15507 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
15508 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
15509 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
15510 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
15511 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
15512 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
15513 (cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues,
15514 (cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy,
15516 (cmdline_parse_inst_t *)&cmd_vlan_offload,
15517 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
15518 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
15519 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
15520 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
15521 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
15522 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
15523 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
15524 (cmdline_parse_inst_t *)&cmd_csum_set,
15525 (cmdline_parse_inst_t *)&cmd_csum_show,
15526 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
15527 (cmdline_parse_inst_t *)&cmd_tso_set,
15528 (cmdline_parse_inst_t *)&cmd_tso_show,
15529 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
15530 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
15531 (cmdline_parse_inst_t *)&cmd_gro_enable,
15532 (cmdline_parse_inst_t *)&cmd_gro_flush,
15533 (cmdline_parse_inst_t *)&cmd_gro_show,
15534 (cmdline_parse_inst_t *)&cmd_gso_enable,
15535 (cmdline_parse_inst_t *)&cmd_gso_size,
15536 (cmdline_parse_inst_t *)&cmd_gso_show,
15537 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
15538 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
15539 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
15540 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
15541 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
15542 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
15543 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
15544 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
15545 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
15546 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
15547 (cmdline_parse_inst_t *)&cmd_config_dcb,
15548 (cmdline_parse_inst_t *)&cmd_read_reg,
15549 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
15550 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
15551 (cmdline_parse_inst_t *)&cmd_write_reg,
15552 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
15553 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
15554 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
15555 (cmdline_parse_inst_t *)&cmd_stop,
15556 (cmdline_parse_inst_t *)&cmd_mac_addr,
15557 (cmdline_parse_inst_t *)&cmd_set_qmap,
15558 (cmdline_parse_inst_t *)&cmd_operate_port,
15559 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
15560 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
15561 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
15562 (cmdline_parse_inst_t *)&cmd_config_speed_all,
15563 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
15564 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
15565 (cmdline_parse_inst_t *)&cmd_config_mtu,
15566 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
15567 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
15568 (cmdline_parse_inst_t *)&cmd_config_rss,
15569 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
15570 (cmdline_parse_inst_t *)&cmd_config_txqflags,
15571 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
15572 (cmdline_parse_inst_t *)&cmd_showport_reta,
15573 (cmdline_parse_inst_t *)&cmd_config_burst,
15574 (cmdline_parse_inst_t *)&cmd_config_thresh,
15575 (cmdline_parse_inst_t *)&cmd_config_threshold,
15576 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
15577 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
15578 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
15579 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
15580 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
15581 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
15582 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
15583 (cmdline_parse_inst_t *)&cmd_global_config,
15584 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
15585 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
15586 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
15587 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
15588 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
15589 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
15590 (cmdline_parse_inst_t *)&cmd_dump,
15591 (cmdline_parse_inst_t *)&cmd_dump_one,
15592 (cmdline_parse_inst_t *)&cmd_ethertype_filter,
15593 (cmdline_parse_inst_t *)&cmd_syn_filter,
15594 (cmdline_parse_inst_t *)&cmd_2tuple_filter,
15595 (cmdline_parse_inst_t *)&cmd_5tuple_filter,
15596 (cmdline_parse_inst_t *)&cmd_flex_filter,
15597 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
15598 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
15599 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
15600 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director,
15601 (cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director,
15602 (cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director,
15603 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
15604 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
15605 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
15606 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
15607 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
15608 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
15609 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
15610 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
15611 (cmdline_parse_inst_t *)&cmd_get_hash_global_config,
15612 (cmdline_parse_inst_t *)&cmd_set_hash_global_config,
15613 (cmdline_parse_inst_t *)&cmd_set_hash_input_set,
15614 (cmdline_parse_inst_t *)&cmd_set_fdir_input_set,
15615 (cmdline_parse_inst_t *)&cmd_flow,
15616 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm,
15617 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm,
15618 (cmdline_parse_inst_t *)&cmd_del_port_meter_profile,
15619 (cmdline_parse_inst_t *)&cmd_set_port_meter,
15620 (cmdline_parse_inst_t *)&cmd_del_port_meter,
15621 (cmdline_parse_inst_t *)&cmd_set_port_meter_profile,
15622 (cmdline_parse_inst_t *)&cmd_set_port_meter_policer_action,
15623 (cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask,
15624 (cmdline_parse_inst_t *)&cmd_show_port_meter_stats,
15625 (cmdline_parse_inst_t *)&cmd_mcast_addr,
15626 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all,
15627 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific,
15628 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all,
15629 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific,
15630 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_en,
15631 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_dis,
15632 (cmdline_parse_inst_t *)&cmd_config_e_tag_stripping_en_dis,
15633 (cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis,
15634 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_add,
15635 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_del,
15636 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
15637 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
15638 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
15639 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
15640 (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
15641 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
15642 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
15643 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
15644 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
15645 (cmdline_parse_inst_t *)&cmd_set_macsec_sc,
15646 (cmdline_parse_inst_t *)&cmd_set_macsec_sa,
15647 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
15648 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
15649 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
15650 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
15651 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
15652 (cmdline_parse_inst_t *)&cmd_set_vf_promisc,
15653 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
15654 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
15655 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
15656 (cmdline_parse_inst_t *)&cmd_vf_max_bw,
15657 (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
15658 (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
15659 (cmdline_parse_inst_t *)&cmd_strict_link_prio,
15660 (cmdline_parse_inst_t *)&cmd_tc_min_bw,
15661 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
15662 (cmdline_parse_inst_t *)&cmd_set_port_tm_hierarchy_default,
15664 (cmdline_parse_inst_t *)&cmd_ddp_add,
15665 (cmdline_parse_inst_t *)&cmd_ddp_del,
15666 (cmdline_parse_inst_t *)&cmd_ddp_get_list,
15667 (cmdline_parse_inst_t *)&cmd_ddp_get_info,
15668 (cmdline_parse_inst_t *)&cmd_show_vf_stats,
15669 (cmdline_parse_inst_t *)&cmd_clear_vf_stats,
15670 (cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
15671 (cmdline_parse_inst_t *)&cmd_ptype_mapping_replace,
15672 (cmdline_parse_inst_t *)&cmd_ptype_mapping_reset,
15673 (cmdline_parse_inst_t *)&cmd_ptype_mapping_update,
15675 (cmdline_parse_inst_t *)&cmd_pctype_mapping_get,
15676 (cmdline_parse_inst_t *)&cmd_pctype_mapping_reset,
15677 (cmdline_parse_inst_t *)&cmd_pctype_mapping_update,
15678 (cmdline_parse_inst_t *)&cmd_queue_region,
15679 (cmdline_parse_inst_t *)&cmd_region_flowtype,
15680 (cmdline_parse_inst_t *)&cmd_user_priority_region,
15681 (cmdline_parse_inst_t *)&cmd_flush_queue_region,
15682 (cmdline_parse_inst_t *)&cmd_show_queue_region_info_all,
15683 (cmdline_parse_inst_t *)&cmd_show_port_tm_cap,
15684 (cmdline_parse_inst_t *)&cmd_show_port_tm_level_cap,
15685 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_cap,
15686 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_type,
15687 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_stats,
15688 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shaper_profile,
15689 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shaper_profile,
15690 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shared_shaper,
15691 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shared_shaper,
15692 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_wred_profile,
15693 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_wred_profile,
15694 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_shaper_profile,
15698 /* read cmdline commands from file */
15700 cmdline_read_from_file(const char *filename)
15702 struct cmdline *cl;
15704 cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
15706 printf("Failed to create file based cmdline context: %s\n",
15711 cmdline_interact(cl);
15716 printf("Read CLI commands from %s\n", filename);
15719 /* prompt function, called from main on MASTER lcore */
15723 /* initialize non-constant commands */
15724 cmd_set_fwd_mode_init();
15725 cmd_set_fwd_retry_mode_init();
15727 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
15728 if (testpmd_cl == NULL)
15730 cmdline_interact(testpmd_cl);
15731 cmdline_stdin_exit(testpmd_cl);
15737 if (testpmd_cl != NULL)
15738 cmdline_quit(testpmd_cl);
15742 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
15744 if (id == (portid_t)RTE_PORT_ALL) {
15747 RTE_ETH_FOREACH_DEV(pid) {
15748 /* check if need_reconfig has been set to 1 */
15749 if (ports[pid].need_reconfig == 0)
15750 ports[pid].need_reconfig = dev;
15751 /* check if need_reconfig_queues has been set to 1 */
15752 if (ports[pid].need_reconfig_queues == 0)
15753 ports[pid].need_reconfig_queues = queue;
15755 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
15756 /* check if need_reconfig has been set to 1 */
15757 if (ports[id].need_reconfig == 0)
15758 ports[id].need_reconfig = dev;
15759 /* check if need_reconfig_queues has been set to 1 */
15760 if (ports[id].need_reconfig_queues == 0)
15761 ports[id].need_reconfig_queues = queue;