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 , list_pkt_forwarding_modes()
731 if (show_all || !strcmp(res->section, "ports")) {
737 "----------------\n\n"
739 "port start (port_id|all)\n"
740 " Start all ports or port_id.\n\n"
742 "port stop (port_id|all)\n"
743 " Stop all ports or port_id.\n\n"
745 "port close (port_id|all)\n"
746 " Close all ports or port_id.\n\n"
748 "port attach (ident)\n"
749 " Attach physical or virtual dev by pci address or virtual device name\n\n"
751 "port detach (port_id)\n"
752 " Detach physical or virtual dev by port_id\n\n"
754 "port config (port_id|all)"
755 " speed (10|100|1000|10000|25000|40000|50000|100000|auto)"
756 " duplex (half|full|auto)\n"
757 " Set speed and duplex for all ports or port_id\n\n"
759 "port config all (rxq|txq|rxd|txd) (value)\n"
760 " Set number for rxq/txq/rxd/txd.\n\n"
762 "port config all max-pkt-len (value)\n"
763 " Set the max packet length.\n\n"
765 "port config all (crc-strip|scatter|rx-cksum|rx-timestamp|hw-vlan|hw-vlan-filter|"
766 "hw-vlan-strip|hw-vlan-extend|drop-en)"
768 " Set crc-strip/scatter/rx-checksum/hardware-vlan/drop_en"
771 "port config all rss (all|ip|tcp|udp|sctp|ether|port|vxlan|"
772 "geneve|nvgre|none|<flowtype_id>)\n"
773 " Set the RSS mode.\n\n"
775 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
776 " Set the RSS redirection table.\n\n"
778 "port config (port_id) dcb vt (on|off) (traffic_class)"
780 " Set the DCB mode.\n\n"
782 "port config all burst (value)\n"
783 " Set the number of packets per burst.\n\n"
785 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
787 " Set the ring prefetch/host/writeback threshold"
788 " for tx/rx queue.\n\n"
790 "port config all (txfreet|txrst|rxfreet) (value)\n"
791 " Set free threshold for rx/tx, or set"
792 " tx rs bit threshold.\n\n"
793 "port config mtu X value\n"
794 " Set the MTU of port X to a given value\n\n"
796 "port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
797 " Start/stop a rx/tx queue of port X. Only take effect"
798 " when port X is started\n\n"
800 "port config (port_id|all) l2-tunnel E-tag ether-type"
802 " Set the value of E-tag ether-type.\n\n"
804 "port config (port_id|all) l2-tunnel E-tag"
805 " (enable|disable)\n"
806 " Enable/disable the E-tag support.\n\n"
808 "port config (port_id) pctype mapping reset\n"
809 " Reset flow type to pctype mapping on a port\n\n"
811 "port config (port_id) pctype mapping update"
812 " (pctype_id_0[,pctype_id_1]*) (flow_type_id)\n"
813 " Update a flow type to pctype mapping item on a port\n\n"
817 if (show_all || !strcmp(res->section, "registers")) {
825 "read reg (port_id) (address)\n"
826 " Display value of a port register.\n\n"
828 "read regfield (port_id) (address) (bit_x) (bit_y)\n"
829 " Display a port register bit field.\n\n"
831 "read regbit (port_id) (address) (bit_x)\n"
832 " Display a single port register bit.\n\n"
834 "write reg (port_id) (address) (value)\n"
835 " Set value of a port register.\n\n"
837 "write regfield (port_id) (address) (bit_x) (bit_y)"
839 " Set bit field of a port register.\n\n"
841 "write regbit (port_id) (address) (bit_x) (value)\n"
842 " Set single bit value of a port register.\n\n"
845 if (show_all || !strcmp(res->section, "filters")) {
853 "ethertype_filter (port_id) (add|del)"
854 " (mac_addr|mac_ignr) (mac_address) ethertype"
855 " (ether_type) (drop|fwd) queue (queue_id)\n"
856 " Add/Del an ethertype filter.\n\n"
858 "2tuple_filter (port_id) (add|del)"
859 " dst_port (dst_port_value) protocol (protocol_value)"
860 " mask (mask_value) tcp_flags (tcp_flags_value)"
861 " priority (prio_value) queue (queue_id)\n"
862 " Add/Del a 2tuple filter.\n\n"
864 "5tuple_filter (port_id) (add|del)"
865 " dst_ip (dst_address) src_ip (src_address)"
866 " dst_port (dst_port_value) src_port (src_port_value)"
867 " protocol (protocol_value)"
868 " mask (mask_value) tcp_flags (tcp_flags_value)"
869 " priority (prio_value) queue (queue_id)\n"
870 " Add/Del a 5tuple filter.\n\n"
872 "syn_filter (port_id) (add|del) priority (high|low) queue (queue_id)"
873 " Add/Del syn filter.\n\n"
875 "flex_filter (port_id) (add|del) len (len_value)"
876 " bytes (bytes_value) mask (mask_value)"
877 " priority (prio_value) queue (queue_id)\n"
878 " Add/Del a flex filter.\n\n"
880 "flow_director_filter (port_id) mode IP (add|del|update)"
881 " flow (ipv4-other|ipv4-frag|ipv6-other|ipv6-frag)"
882 " src (src_ip_address) dst (dst_ip_address)"
883 " tos (tos_value) proto (proto_value) ttl (ttl_value)"
884 " vlan (vlan_value) flexbytes (flexbytes_value)"
885 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
886 " fd_id (fd_id_value)\n"
887 " Add/Del an IP type flow director filter.\n\n"
889 "flow_director_filter (port_id) mode IP (add|del|update)"
890 " flow (ipv4-tcp|ipv4-udp|ipv6-tcp|ipv6-udp)"
891 " src (src_ip_address) (src_port)"
892 " dst (dst_ip_address) (dst_port)"
893 " tos (tos_value) ttl (ttl_value)"
894 " vlan (vlan_value) flexbytes (flexbytes_value)"
895 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
896 " fd_id (fd_id_value)\n"
897 " Add/Del an UDP/TCP type flow director filter.\n\n"
899 "flow_director_filter (port_id) mode IP (add|del|update)"
900 " flow (ipv4-sctp|ipv6-sctp)"
901 " src (src_ip_address) (src_port)"
902 " dst (dst_ip_address) (dst_port)"
903 " tag (verification_tag) "
904 " tos (tos_value) ttl (ttl_value)"
906 " flexbytes (flexbytes_value) (drop|fwd)"
907 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
908 " Add/Del a SCTP type flow director filter.\n\n"
910 "flow_director_filter (port_id) mode IP (add|del|update)"
911 " flow l2_payload ether (ethertype)"
912 " flexbytes (flexbytes_value) (drop|fwd)"
913 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
914 " Add/Del a l2 payload type flow director filter.\n\n"
916 "flow_director_filter (port_id) mode MAC-VLAN (add|del|update)"
917 " mac (mac_address) vlan (vlan_value)"
918 " flexbytes (flexbytes_value) (drop|fwd)"
919 " queue (queue_id) fd_id (fd_id_value)\n"
920 " Add/Del a MAC-VLAN flow director filter.\n\n"
922 "flow_director_filter (port_id) mode Tunnel (add|del|update)"
923 " mac (mac_address) vlan (vlan_value)"
924 " tunnel (NVGRE|VxLAN) tunnel-id (tunnel_id_value)"
925 " flexbytes (flexbytes_value) (drop|fwd)"
926 " queue (queue_id) fd_id (fd_id_value)\n"
927 " Add/Del a Tunnel flow director filter.\n\n"
929 "flush_flow_director (port_id)\n"
930 " Flush all flow director entries of a device.\n\n"
932 "flow_director_mask (port_id) mode IP vlan (vlan_value)"
933 " src_mask (ipv4_src) (ipv6_src) (src_port)"
934 " dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n"
935 " Set flow director IP mask.\n\n"
937 "flow_director_mask (port_id) mode MAC-VLAN"
938 " vlan (vlan_value)\n"
939 " Set flow director MAC-VLAN mask.\n\n"
941 "flow_director_mask (port_id) mode Tunnel"
942 " vlan (vlan_value) mac (mac_value)"
943 " tunnel-type (tunnel_type_value)"
944 " tunnel-id (tunnel_id_value)\n"
945 " Set flow director Tunnel mask.\n\n"
947 "flow_director_flex_mask (port_id)"
948 " flow (none|ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
949 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|l2_payload|all)"
951 " Configure mask of flex payload.\n\n"
953 "flow_director_flex_payload (port_id)"
954 " (raw|l2|l3|l4) (config)\n"
955 " Configure flex payload selection.\n\n"
957 "get_sym_hash_ena_per_port (port_id)\n"
958 " get symmetric hash enable configuration per port.\n\n"
960 "set_sym_hash_ena_per_port (port_id) (enable|disable)\n"
961 " set symmetric hash enable configuration per port"
962 " to enable or disable.\n\n"
964 "get_hash_global_config (port_id)\n"
965 " Get the global configurations of hash filters.\n\n"
967 "set_hash_global_config (port_id) (toeplitz|simple_xor|default)"
968 " (ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
969 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload)"
970 " (enable|disable)\n"
971 " Set the global configurations of hash filters.\n\n"
973 "set_hash_input_set (port_id) (ipv4|ipv4-frag|"
974 "ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
975 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
976 "l2_payload|<flowtype_id>) (ovlan|ivlan|src-ipv4|dst-ipv4|"
977 "src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|ipv6-tc|"
978 "ipv6-next-header|udp-src-port|udp-dst-port|"
979 "tcp-src-port|tcp-dst-port|sctp-src-port|"
980 "sctp-dst-port|sctp-veri-tag|udp-key|gre-key|fld-1st|"
981 "fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|fld-7th|"
982 "fld-8th|none) (select|add)\n"
983 " Set the input set for hash.\n\n"
985 "set_fdir_input_set (port_id) "
986 "(ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
987 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
988 "l2_payload) (ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|"
989 "dst-ipv6|ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|"
990 "ipv6-next-header|ipv6-hop-limits|udp-src-port|"
991 "udp-dst-port|tcp-src-port|tcp-dst-port|"
992 "sctp-src-port|sctp-dst-port|sctp-veri-tag|none)"
994 " Set the input set for FDir.\n\n"
996 "flow validate {port_id}"
997 " [group {group_id}] [priority {level}]"
998 " [ingress] [egress]"
999 " pattern {item} [/ {item} [...]] / end"
1000 " actions {action} [/ {action} [...]] / end\n"
1001 " Check whether a flow rule can be created.\n\n"
1003 "flow create {port_id}"
1004 " [group {group_id}] [priority {level}]"
1005 " [ingress] [egress]"
1006 " pattern {item} [/ {item} [...]] / end"
1007 " actions {action} [/ {action} [...]] / end\n"
1008 " Create a flow rule.\n\n"
1010 "flow destroy {port_id} rule {rule_id} [...]\n"
1011 " Destroy specific flow rules.\n\n"
1013 "flow flush {port_id}\n"
1014 " Destroy all flow rules.\n\n"
1016 "flow query {port_id} {rule_id} {action}\n"
1017 " Query an existing flow rule.\n\n"
1019 "flow list {port_id} [group {group_id}] [...]\n"
1020 " List existing flow rules sorted by priority,"
1021 " filtered by group identifiers.\n\n"
1023 "flow isolate {port_id} {boolean}\n"
1024 " Restrict ingress traffic to the defined"
1030 cmdline_parse_token_string_t cmd_help_long_help =
1031 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
1033 cmdline_parse_token_string_t cmd_help_long_section =
1034 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
1035 "all#control#display#config#"
1036 "ports#registers#filters");
1038 cmdline_parse_inst_t cmd_help_long = {
1039 .f = cmd_help_long_parsed,
1041 .help_str = "help all|control|display|config|ports|register|filters: "
1044 (void *)&cmd_help_long_help,
1045 (void *)&cmd_help_long_section,
1051 /* *** start/stop/close all ports *** */
1052 struct cmd_operate_port_result {
1053 cmdline_fixed_string_t keyword;
1054 cmdline_fixed_string_t name;
1055 cmdline_fixed_string_t value;
1058 static void cmd_operate_port_parsed(void *parsed_result,
1059 __attribute__((unused)) struct cmdline *cl,
1060 __attribute__((unused)) void *data)
1062 struct cmd_operate_port_result *res = parsed_result;
1064 if (!strcmp(res->name, "start"))
1065 start_port(RTE_PORT_ALL);
1066 else if (!strcmp(res->name, "stop"))
1067 stop_port(RTE_PORT_ALL);
1068 else if (!strcmp(res->name, "close"))
1069 close_port(RTE_PORT_ALL);
1070 else if (!strcmp(res->name, "reset"))
1071 reset_port(RTE_PORT_ALL);
1073 printf("Unknown parameter\n");
1076 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
1077 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
1079 cmdline_parse_token_string_t cmd_operate_port_all_port =
1080 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
1081 "start#stop#close#reset");
1082 cmdline_parse_token_string_t cmd_operate_port_all_all =
1083 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
1085 cmdline_parse_inst_t cmd_operate_port = {
1086 .f = cmd_operate_port_parsed,
1088 .help_str = "port start|stop|close all: Start/Stop/Close/Reset all ports",
1090 (void *)&cmd_operate_port_all_cmd,
1091 (void *)&cmd_operate_port_all_port,
1092 (void *)&cmd_operate_port_all_all,
1097 /* *** start/stop/close specific port *** */
1098 struct cmd_operate_specific_port_result {
1099 cmdline_fixed_string_t keyword;
1100 cmdline_fixed_string_t name;
1104 static void cmd_operate_specific_port_parsed(void *parsed_result,
1105 __attribute__((unused)) struct cmdline *cl,
1106 __attribute__((unused)) void *data)
1108 struct cmd_operate_specific_port_result *res = parsed_result;
1110 if (!strcmp(res->name, "start"))
1111 start_port(res->value);
1112 else if (!strcmp(res->name, "stop"))
1113 stop_port(res->value);
1114 else if (!strcmp(res->name, "close"))
1115 close_port(res->value);
1116 else if (!strcmp(res->name, "reset"))
1117 reset_port(res->value);
1119 printf("Unknown parameter\n");
1122 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
1123 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1125 cmdline_parse_token_string_t cmd_operate_specific_port_port =
1126 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1127 name, "start#stop#close#reset");
1128 cmdline_parse_token_num_t cmd_operate_specific_port_id =
1129 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
1132 cmdline_parse_inst_t cmd_operate_specific_port = {
1133 .f = cmd_operate_specific_port_parsed,
1135 .help_str = "port start|stop|close <port_id>: Start/Stop/Close/Reset port_id",
1137 (void *)&cmd_operate_specific_port_cmd,
1138 (void *)&cmd_operate_specific_port_port,
1139 (void *)&cmd_operate_specific_port_id,
1144 /* *** attach a specified port *** */
1145 struct cmd_operate_attach_port_result {
1146 cmdline_fixed_string_t port;
1147 cmdline_fixed_string_t keyword;
1148 cmdline_fixed_string_t identifier;
1151 static void cmd_operate_attach_port_parsed(void *parsed_result,
1152 __attribute__((unused)) struct cmdline *cl,
1153 __attribute__((unused)) void *data)
1155 struct cmd_operate_attach_port_result *res = parsed_result;
1157 if (!strcmp(res->keyword, "attach"))
1158 attach_port(res->identifier);
1160 printf("Unknown parameter\n");
1163 cmdline_parse_token_string_t cmd_operate_attach_port_port =
1164 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1166 cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
1167 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1169 cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
1170 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1173 cmdline_parse_inst_t cmd_operate_attach_port = {
1174 .f = cmd_operate_attach_port_parsed,
1176 .help_str = "port attach <identifier>: "
1177 "(identifier: pci address or virtual dev name)",
1179 (void *)&cmd_operate_attach_port_port,
1180 (void *)&cmd_operate_attach_port_keyword,
1181 (void *)&cmd_operate_attach_port_identifier,
1186 /* *** detach a specified port *** */
1187 struct cmd_operate_detach_port_result {
1188 cmdline_fixed_string_t port;
1189 cmdline_fixed_string_t keyword;
1193 static void cmd_operate_detach_port_parsed(void *parsed_result,
1194 __attribute__((unused)) struct cmdline *cl,
1195 __attribute__((unused)) void *data)
1197 struct cmd_operate_detach_port_result *res = parsed_result;
1199 if (!strcmp(res->keyword, "detach"))
1200 detach_port(res->port_id);
1202 printf("Unknown parameter\n");
1205 cmdline_parse_token_string_t cmd_operate_detach_port_port =
1206 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1208 cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
1209 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1211 cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
1212 TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
1215 cmdline_parse_inst_t cmd_operate_detach_port = {
1216 .f = cmd_operate_detach_port_parsed,
1218 .help_str = "port detach <port_id>",
1220 (void *)&cmd_operate_detach_port_port,
1221 (void *)&cmd_operate_detach_port_keyword,
1222 (void *)&cmd_operate_detach_port_port_id,
1227 /* *** configure speed for all ports *** */
1228 struct cmd_config_speed_all {
1229 cmdline_fixed_string_t port;
1230 cmdline_fixed_string_t keyword;
1231 cmdline_fixed_string_t all;
1232 cmdline_fixed_string_t item1;
1233 cmdline_fixed_string_t item2;
1234 cmdline_fixed_string_t value1;
1235 cmdline_fixed_string_t value2;
1239 parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed)
1244 if (!strcmp(duplexstr, "half")) {
1245 duplex = ETH_LINK_HALF_DUPLEX;
1246 } else if (!strcmp(duplexstr, "full")) {
1247 duplex = ETH_LINK_FULL_DUPLEX;
1248 } else if (!strcmp(duplexstr, "auto")) {
1249 duplex = ETH_LINK_FULL_DUPLEX;
1251 printf("Unknown duplex parameter\n");
1255 if (!strcmp(speedstr, "10")) {
1256 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1257 ETH_LINK_SPEED_10M_HD : ETH_LINK_SPEED_10M;
1258 } else if (!strcmp(speedstr, "100")) {
1259 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1260 ETH_LINK_SPEED_100M_HD : ETH_LINK_SPEED_100M;
1262 if (duplex != ETH_LINK_FULL_DUPLEX) {
1263 printf("Invalid speed/duplex parameters\n");
1266 if (!strcmp(speedstr, "1000")) {
1267 *speed = ETH_LINK_SPEED_1G;
1268 } else if (!strcmp(speedstr, "10000")) {
1269 *speed = ETH_LINK_SPEED_10G;
1270 } else if (!strcmp(speedstr, "25000")) {
1271 *speed = ETH_LINK_SPEED_25G;
1272 } else if (!strcmp(speedstr, "40000")) {
1273 *speed = ETH_LINK_SPEED_40G;
1274 } else if (!strcmp(speedstr, "50000")) {
1275 *speed = ETH_LINK_SPEED_50G;
1276 } else if (!strcmp(speedstr, "100000")) {
1277 *speed = ETH_LINK_SPEED_100G;
1278 } else if (!strcmp(speedstr, "auto")) {
1279 *speed = ETH_LINK_SPEED_AUTONEG;
1281 printf("Unknown speed parameter\n");
1290 cmd_config_speed_all_parsed(void *parsed_result,
1291 __attribute__((unused)) struct cmdline *cl,
1292 __attribute__((unused)) void *data)
1294 struct cmd_config_speed_all *res = parsed_result;
1295 uint32_t link_speed;
1298 if (!all_ports_stopped()) {
1299 printf("Please stop all ports first\n");
1303 if (parse_and_check_speed_duplex(res->value1, res->value2,
1307 RTE_ETH_FOREACH_DEV(pid) {
1308 ports[pid].dev_conf.link_speeds = link_speed;
1311 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1314 cmdline_parse_token_string_t cmd_config_speed_all_port =
1315 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1316 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1317 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1319 cmdline_parse_token_string_t cmd_config_speed_all_all =
1320 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1321 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1322 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1323 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1324 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1325 "10#100#1000#10000#25000#40000#50000#100000#auto");
1326 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1327 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1328 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1329 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1332 cmdline_parse_inst_t cmd_config_speed_all = {
1333 .f = cmd_config_speed_all_parsed,
1335 .help_str = "port config all speed "
1336 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1339 (void *)&cmd_config_speed_all_port,
1340 (void *)&cmd_config_speed_all_keyword,
1341 (void *)&cmd_config_speed_all_all,
1342 (void *)&cmd_config_speed_all_item1,
1343 (void *)&cmd_config_speed_all_value1,
1344 (void *)&cmd_config_speed_all_item2,
1345 (void *)&cmd_config_speed_all_value2,
1350 /* *** configure speed for specific port *** */
1351 struct cmd_config_speed_specific {
1352 cmdline_fixed_string_t port;
1353 cmdline_fixed_string_t keyword;
1355 cmdline_fixed_string_t item1;
1356 cmdline_fixed_string_t item2;
1357 cmdline_fixed_string_t value1;
1358 cmdline_fixed_string_t value2;
1362 cmd_config_speed_specific_parsed(void *parsed_result,
1363 __attribute__((unused)) struct cmdline *cl,
1364 __attribute__((unused)) void *data)
1366 struct cmd_config_speed_specific *res = parsed_result;
1367 uint32_t link_speed;
1369 if (!all_ports_stopped()) {
1370 printf("Please stop all ports first\n");
1374 if (port_id_is_invalid(res->id, ENABLED_WARN))
1377 if (parse_and_check_speed_duplex(res->value1, res->value2,
1381 ports[res->id].dev_conf.link_speeds = link_speed;
1383 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1387 cmdline_parse_token_string_t cmd_config_speed_specific_port =
1388 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1390 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1391 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1393 cmdline_parse_token_num_t cmd_config_speed_specific_id =
1394 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT8);
1395 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1396 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1398 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1399 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1400 "10#100#1000#10000#25000#40000#50000#100000#auto");
1401 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1402 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1404 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1405 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1408 cmdline_parse_inst_t cmd_config_speed_specific = {
1409 .f = cmd_config_speed_specific_parsed,
1411 .help_str = "port config <port_id> speed "
1412 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1415 (void *)&cmd_config_speed_specific_port,
1416 (void *)&cmd_config_speed_specific_keyword,
1417 (void *)&cmd_config_speed_specific_id,
1418 (void *)&cmd_config_speed_specific_item1,
1419 (void *)&cmd_config_speed_specific_value1,
1420 (void *)&cmd_config_speed_specific_item2,
1421 (void *)&cmd_config_speed_specific_value2,
1426 /* *** configure txq/rxq, txd/rxd *** */
1427 struct cmd_config_rx_tx {
1428 cmdline_fixed_string_t port;
1429 cmdline_fixed_string_t keyword;
1430 cmdline_fixed_string_t all;
1431 cmdline_fixed_string_t name;
1436 cmd_config_rx_tx_parsed(void *parsed_result,
1437 __attribute__((unused)) struct cmdline *cl,
1438 __attribute__((unused)) void *data)
1440 struct cmd_config_rx_tx *res = parsed_result;
1442 if (!all_ports_stopped()) {
1443 printf("Please stop all ports first\n");
1446 if (!strcmp(res->name, "rxq")) {
1447 if (!res->value && !nb_txq) {
1448 printf("Warning: Either rx or tx queues should be non zero\n");
1451 nb_rxq = res->value;
1453 else if (!strcmp(res->name, "txq")) {
1454 if (!res->value && !nb_rxq) {
1455 printf("Warning: Either rx or tx queues should be non zero\n");
1458 nb_txq = res->value;
1460 else if (!strcmp(res->name, "rxd")) {
1461 if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) {
1462 printf("rxd %d invalid - must be > 0 && <= %d\n",
1463 res->value, RTE_TEST_RX_DESC_MAX);
1466 nb_rxd = res->value;
1467 } else if (!strcmp(res->name, "txd")) {
1468 if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) {
1469 printf("txd %d invalid - must be > 0 && <= %d\n",
1470 res->value, RTE_TEST_TX_DESC_MAX);
1473 nb_txd = res->value;
1475 printf("Unknown parameter\n");
1483 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1486 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1487 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1488 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1489 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1490 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1491 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1492 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1493 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1495 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1496 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
1498 cmdline_parse_inst_t cmd_config_rx_tx = {
1499 .f = cmd_config_rx_tx_parsed,
1501 .help_str = "port config all rxq|txq|rxd|txd <value>",
1503 (void *)&cmd_config_rx_tx_port,
1504 (void *)&cmd_config_rx_tx_keyword,
1505 (void *)&cmd_config_rx_tx_all,
1506 (void *)&cmd_config_rx_tx_name,
1507 (void *)&cmd_config_rx_tx_value,
1512 /* *** config max packet length *** */
1513 struct cmd_config_max_pkt_len_result {
1514 cmdline_fixed_string_t port;
1515 cmdline_fixed_string_t keyword;
1516 cmdline_fixed_string_t all;
1517 cmdline_fixed_string_t name;
1522 cmd_config_max_pkt_len_parsed(void *parsed_result,
1523 __attribute__((unused)) struct cmdline *cl,
1524 __attribute__((unused)) void *data)
1526 struct cmd_config_max_pkt_len_result *res = parsed_result;
1528 if (!all_ports_stopped()) {
1529 printf("Please stop all ports first\n");
1533 if (!strcmp(res->name, "max-pkt-len")) {
1534 if (res->value < ETHER_MIN_LEN) {
1535 printf("max-pkt-len can not be less than %d\n",
1539 if (res->value == rx_mode.max_rx_pkt_len)
1542 rx_mode.max_rx_pkt_len = res->value;
1543 if (res->value > ETHER_MAX_LEN)
1544 rx_mode.jumbo_frame = 1;
1546 rx_mode.jumbo_frame = 0;
1548 printf("Unknown parameter\n");
1554 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1557 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
1558 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
1560 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
1561 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
1563 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
1564 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
1566 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
1567 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
1569 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1570 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1573 cmdline_parse_inst_t cmd_config_max_pkt_len = {
1574 .f = cmd_config_max_pkt_len_parsed,
1576 .help_str = "port config all max-pkt-len <value>",
1578 (void *)&cmd_config_max_pkt_len_port,
1579 (void *)&cmd_config_max_pkt_len_keyword,
1580 (void *)&cmd_config_max_pkt_len_all,
1581 (void *)&cmd_config_max_pkt_len_name,
1582 (void *)&cmd_config_max_pkt_len_value,
1587 /* *** configure port MTU *** */
1588 struct cmd_config_mtu_result {
1589 cmdline_fixed_string_t port;
1590 cmdline_fixed_string_t keyword;
1591 cmdline_fixed_string_t mtu;
1597 cmd_config_mtu_parsed(void *parsed_result,
1598 __attribute__((unused)) struct cmdline *cl,
1599 __attribute__((unused)) void *data)
1601 struct cmd_config_mtu_result *res = parsed_result;
1603 if (res->value < ETHER_MIN_LEN) {
1604 printf("mtu cannot be less than %d\n", ETHER_MIN_LEN);
1607 port_mtu_set(res->port_id, res->value);
1610 cmdline_parse_token_string_t cmd_config_mtu_port =
1611 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
1613 cmdline_parse_token_string_t cmd_config_mtu_keyword =
1614 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1616 cmdline_parse_token_string_t cmd_config_mtu_mtu =
1617 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1619 cmdline_parse_token_num_t cmd_config_mtu_port_id =
1620 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT16);
1621 cmdline_parse_token_num_t cmd_config_mtu_value =
1622 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
1624 cmdline_parse_inst_t cmd_config_mtu = {
1625 .f = cmd_config_mtu_parsed,
1627 .help_str = "port config mtu <port_id> <value>",
1629 (void *)&cmd_config_mtu_port,
1630 (void *)&cmd_config_mtu_keyword,
1631 (void *)&cmd_config_mtu_mtu,
1632 (void *)&cmd_config_mtu_port_id,
1633 (void *)&cmd_config_mtu_value,
1638 /* *** configure rx mode *** */
1639 struct cmd_config_rx_mode_flag {
1640 cmdline_fixed_string_t port;
1641 cmdline_fixed_string_t keyword;
1642 cmdline_fixed_string_t all;
1643 cmdline_fixed_string_t name;
1644 cmdline_fixed_string_t value;
1648 cmd_config_rx_mode_flag_parsed(void *parsed_result,
1649 __attribute__((unused)) struct cmdline *cl,
1650 __attribute__((unused)) void *data)
1652 struct cmd_config_rx_mode_flag *res = parsed_result;
1654 if (!all_ports_stopped()) {
1655 printf("Please stop all ports first\n");
1659 if (!strcmp(res->name, "crc-strip")) {
1660 if (!strcmp(res->value, "on"))
1661 rx_mode.hw_strip_crc = 1;
1662 else if (!strcmp(res->value, "off"))
1663 rx_mode.hw_strip_crc = 0;
1665 printf("Unknown parameter\n");
1668 } else if (!strcmp(res->name, "scatter")) {
1669 if (!strcmp(res->value, "on"))
1670 rx_mode.enable_scatter = 1;
1671 else if (!strcmp(res->value, "off"))
1672 rx_mode.enable_scatter = 0;
1674 printf("Unknown parameter\n");
1677 } else if (!strcmp(res->name, "rx-cksum")) {
1678 if (!strcmp(res->value, "on"))
1679 rx_mode.hw_ip_checksum = 1;
1680 else if (!strcmp(res->value, "off"))
1681 rx_mode.hw_ip_checksum = 0;
1683 printf("Unknown parameter\n");
1686 } else if (!strcmp(res->name, "rx-timestamp")) {
1687 if (!strcmp(res->value, "on"))
1688 rx_mode.hw_timestamp = 1;
1689 else if (!strcmp(res->value, "off"))
1690 rx_mode.hw_timestamp = 0;
1692 printf("Unknown parameter\n");
1695 } else if (!strcmp(res->name, "hw-vlan")) {
1696 if (!strcmp(res->value, "on")) {
1697 rx_mode.hw_vlan_filter = 1;
1698 rx_mode.hw_vlan_strip = 1;
1700 else if (!strcmp(res->value, "off")) {
1701 rx_mode.hw_vlan_filter = 0;
1702 rx_mode.hw_vlan_strip = 0;
1705 printf("Unknown parameter\n");
1708 } else if (!strcmp(res->name, "hw-vlan-filter")) {
1709 if (!strcmp(res->value, "on"))
1710 rx_mode.hw_vlan_filter = 1;
1711 else if (!strcmp(res->value, "off"))
1712 rx_mode.hw_vlan_filter = 0;
1714 printf("Unknown parameter\n");
1717 } else if (!strcmp(res->name, "hw-vlan-strip")) {
1718 if (!strcmp(res->value, "on"))
1719 rx_mode.hw_vlan_strip = 1;
1720 else if (!strcmp(res->value, "off"))
1721 rx_mode.hw_vlan_strip = 0;
1723 printf("Unknown parameter\n");
1726 } else if (!strcmp(res->name, "hw-vlan-extend")) {
1727 if (!strcmp(res->value, "on"))
1728 rx_mode.hw_vlan_extend = 1;
1729 else if (!strcmp(res->value, "off"))
1730 rx_mode.hw_vlan_extend = 0;
1732 printf("Unknown parameter\n");
1735 } else if (!strcmp(res->name, "drop-en")) {
1736 if (!strcmp(res->value, "on"))
1738 else if (!strcmp(res->value, "off"))
1741 printf("Unknown parameter\n");
1745 printf("Unknown parameter\n");
1751 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1754 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
1755 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
1756 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
1757 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
1759 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
1760 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
1761 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
1762 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
1763 "crc-strip#scatter#rx-cksum#rx-timestamp#hw-vlan#"
1764 "hw-vlan-filter#hw-vlan-strip#hw-vlan-extend");
1765 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
1766 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
1769 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
1770 .f = cmd_config_rx_mode_flag_parsed,
1772 .help_str = "port config all crc-strip|scatter|rx-cksum|rx-timestamp|hw-vlan|"
1773 "hw-vlan-filter|hw-vlan-strip|hw-vlan-extend on|off",
1775 (void *)&cmd_config_rx_mode_flag_port,
1776 (void *)&cmd_config_rx_mode_flag_keyword,
1777 (void *)&cmd_config_rx_mode_flag_all,
1778 (void *)&cmd_config_rx_mode_flag_name,
1779 (void *)&cmd_config_rx_mode_flag_value,
1784 /* *** configure rss *** */
1785 struct cmd_config_rss {
1786 cmdline_fixed_string_t port;
1787 cmdline_fixed_string_t keyword;
1788 cmdline_fixed_string_t all;
1789 cmdline_fixed_string_t name;
1790 cmdline_fixed_string_t value;
1794 cmd_config_rss_parsed(void *parsed_result,
1795 __attribute__((unused)) struct cmdline *cl,
1796 __attribute__((unused)) void *data)
1798 struct cmd_config_rss *res = parsed_result;
1799 struct rte_eth_rss_conf rss_conf;
1803 if (!strcmp(res->value, "all"))
1804 rss_conf.rss_hf = ETH_RSS_IP | ETH_RSS_TCP |
1805 ETH_RSS_UDP | ETH_RSS_SCTP |
1807 else if (!strcmp(res->value, "ip"))
1808 rss_conf.rss_hf = ETH_RSS_IP;
1809 else if (!strcmp(res->value, "udp"))
1810 rss_conf.rss_hf = ETH_RSS_UDP;
1811 else if (!strcmp(res->value, "tcp"))
1812 rss_conf.rss_hf = ETH_RSS_TCP;
1813 else if (!strcmp(res->value, "sctp"))
1814 rss_conf.rss_hf = ETH_RSS_SCTP;
1815 else if (!strcmp(res->value, "ether"))
1816 rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD;
1817 else if (!strcmp(res->value, "port"))
1818 rss_conf.rss_hf = ETH_RSS_PORT;
1819 else if (!strcmp(res->value, "vxlan"))
1820 rss_conf.rss_hf = ETH_RSS_VXLAN;
1821 else if (!strcmp(res->value, "geneve"))
1822 rss_conf.rss_hf = ETH_RSS_GENEVE;
1823 else if (!strcmp(res->value, "nvgre"))
1824 rss_conf.rss_hf = ETH_RSS_NVGRE;
1825 else if (!strcmp(res->value, "none"))
1826 rss_conf.rss_hf = 0;
1827 else if (isdigit(res->value[0]) && atoi(res->value) > 0 &&
1828 atoi(res->value) < 64)
1829 rss_conf.rss_hf = 1ULL << atoi(res->value);
1831 printf("Unknown parameter\n");
1834 rss_conf.rss_key = NULL;
1835 for (i = 0; i < rte_eth_dev_count(); i++) {
1836 diag = rte_eth_dev_rss_hash_update(i, &rss_conf);
1838 printf("Configuration of RSS hash at ethernet port %d "
1839 "failed with error (%d): %s.\n",
1840 i, -diag, strerror(-diag));
1844 cmdline_parse_token_string_t cmd_config_rss_port =
1845 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
1846 cmdline_parse_token_string_t cmd_config_rss_keyword =
1847 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
1848 cmdline_parse_token_string_t cmd_config_rss_all =
1849 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
1850 cmdline_parse_token_string_t cmd_config_rss_name =
1851 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
1852 cmdline_parse_token_string_t cmd_config_rss_value =
1853 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, NULL);
1855 cmdline_parse_inst_t cmd_config_rss = {
1856 .f = cmd_config_rss_parsed,
1858 .help_str = "port config all rss "
1859 "all|ip|tcp|udp|sctp|ether|port|vxlan|geneve|nvgre|none|<flowtype_id>",
1861 (void *)&cmd_config_rss_port,
1862 (void *)&cmd_config_rss_keyword,
1863 (void *)&cmd_config_rss_all,
1864 (void *)&cmd_config_rss_name,
1865 (void *)&cmd_config_rss_value,
1870 /* *** configure rss hash key *** */
1871 struct cmd_config_rss_hash_key {
1872 cmdline_fixed_string_t port;
1873 cmdline_fixed_string_t config;
1875 cmdline_fixed_string_t rss_hash_key;
1876 cmdline_fixed_string_t rss_type;
1877 cmdline_fixed_string_t key;
1881 hexa_digit_to_value(char hexa_digit)
1883 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
1884 return (uint8_t) (hexa_digit - '0');
1885 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
1886 return (uint8_t) ((hexa_digit - 'a') + 10);
1887 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
1888 return (uint8_t) ((hexa_digit - 'A') + 10);
1889 /* Invalid hexa digit */
1894 parse_and_check_key_hexa_digit(char *key, int idx)
1898 hexa_v = hexa_digit_to_value(key[idx]);
1900 printf("invalid key: character %c at position %d is not a "
1901 "valid hexa digit\n", key[idx], idx);
1906 cmd_config_rss_hash_key_parsed(void *parsed_result,
1907 __attribute__((unused)) struct cmdline *cl,
1908 __attribute__((unused)) void *data)
1910 struct cmd_config_rss_hash_key *res = parsed_result;
1911 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
1915 struct rte_eth_dev_info dev_info;
1916 uint8_t hash_key_size;
1919 memset(&dev_info, 0, sizeof(dev_info));
1920 rte_eth_dev_info_get(res->port_id, &dev_info);
1921 if (dev_info.hash_key_size > 0 &&
1922 dev_info.hash_key_size <= sizeof(hash_key))
1923 hash_key_size = dev_info.hash_key_size;
1925 printf("dev_info did not provide a valid hash key size\n");
1928 /* Check the length of the RSS hash key */
1929 key_len = strlen(res->key);
1930 if (key_len != (hash_key_size * 2)) {
1931 printf("key length: %d invalid - key must be a string of %d"
1932 " hexa-decimal numbers\n",
1933 (int) key_len, hash_key_size * 2);
1936 /* Translate RSS hash key into binary representation */
1937 for (i = 0; i < hash_key_size; i++) {
1938 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
1941 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
1944 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
1946 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
1950 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
1951 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
1952 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
1953 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
1955 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
1956 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT16);
1957 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
1958 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
1959 rss_hash_key, "rss-hash-key");
1960 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
1961 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
1962 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
1963 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
1964 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
1965 "ipv6-tcp-ex#ipv6-udp-ex");
1966 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
1967 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
1969 cmdline_parse_inst_t cmd_config_rss_hash_key = {
1970 .f = cmd_config_rss_hash_key_parsed,
1972 .help_str = "port config <port_id> rss-hash-key "
1973 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
1974 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1975 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex "
1976 "<string of hex digits (variable length, NIC dependent)>",
1978 (void *)&cmd_config_rss_hash_key_port,
1979 (void *)&cmd_config_rss_hash_key_config,
1980 (void *)&cmd_config_rss_hash_key_port_id,
1981 (void *)&cmd_config_rss_hash_key_rss_hash_key,
1982 (void *)&cmd_config_rss_hash_key_rss_type,
1983 (void *)&cmd_config_rss_hash_key_value,
1988 /* *** configure port rxq/txq start/stop *** */
1989 struct cmd_config_rxtx_queue {
1990 cmdline_fixed_string_t port;
1992 cmdline_fixed_string_t rxtxq;
1994 cmdline_fixed_string_t opname;
1998 cmd_config_rxtx_queue_parsed(void *parsed_result,
1999 __attribute__((unused)) struct cmdline *cl,
2000 __attribute__((unused)) void *data)
2002 struct cmd_config_rxtx_queue *res = parsed_result;
2007 if (test_done == 0) {
2008 printf("Please stop forwarding first\n");
2012 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2015 if (port_is_started(res->portid) != 1) {
2016 printf("Please start port %u first\n", res->portid);
2020 if (!strcmp(res->rxtxq, "rxq"))
2022 else if (!strcmp(res->rxtxq, "txq"))
2025 printf("Unknown parameter\n");
2029 if (isrx && rx_queue_id_is_invalid(res->qid))
2031 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2034 if (!strcmp(res->opname, "start"))
2036 else if (!strcmp(res->opname, "stop"))
2039 printf("Unknown parameter\n");
2043 if (isstart && isrx)
2044 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
2045 else if (!isstart && isrx)
2046 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
2047 else if (isstart && !isrx)
2048 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
2050 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
2052 if (ret == -ENOTSUP)
2053 printf("Function not supported in PMD driver\n");
2056 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
2057 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
2058 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
2059 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT16);
2060 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
2061 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
2062 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
2063 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
2064 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
2065 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
2068 cmdline_parse_inst_t cmd_config_rxtx_queue = {
2069 .f = cmd_config_rxtx_queue_parsed,
2071 .help_str = "port <port_id> rxq|txq <queue_id> start|stop",
2073 (void *)&cmd_config_speed_all_port,
2074 (void *)&cmd_config_rxtx_queue_portid,
2075 (void *)&cmd_config_rxtx_queue_rxtxq,
2076 (void *)&cmd_config_rxtx_queue_qid,
2077 (void *)&cmd_config_rxtx_queue_opname,
2082 /* *** Configure RSS RETA *** */
2083 struct cmd_config_rss_reta {
2084 cmdline_fixed_string_t port;
2085 cmdline_fixed_string_t keyword;
2087 cmdline_fixed_string_t name;
2088 cmdline_fixed_string_t list_name;
2089 cmdline_fixed_string_t list_of_items;
2093 parse_reta_config(const char *str,
2094 struct rte_eth_rss_reta_entry64 *reta_conf,
2095 uint16_t nb_entries)
2099 uint16_t hash_index, idx, shift;
2102 const char *p, *p0 = str;
2109 unsigned long int_fld[_NUM_FLD];
2110 char *str_fld[_NUM_FLD];
2112 while ((p = strchr(p0,'(')) != NULL) {
2114 if((p0 = strchr(p,')')) == NULL)
2118 if(size >= sizeof(s))
2121 snprintf(s, sizeof(s), "%.*s", size, p);
2122 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
2124 for (i = 0; i < _NUM_FLD; i++) {
2126 int_fld[i] = strtoul(str_fld[i], &end, 0);
2127 if (errno != 0 || end == str_fld[i] ||
2132 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
2133 nb_queue = (uint16_t)int_fld[FLD_QUEUE];
2135 if (hash_index >= nb_entries) {
2136 printf("Invalid RETA hash index=%d\n", hash_index);
2140 idx = hash_index / RTE_RETA_GROUP_SIZE;
2141 shift = hash_index % RTE_RETA_GROUP_SIZE;
2142 reta_conf[idx].mask |= (1ULL << shift);
2143 reta_conf[idx].reta[shift] = nb_queue;
2150 cmd_set_rss_reta_parsed(void *parsed_result,
2151 __attribute__((unused)) struct cmdline *cl,
2152 __attribute__((unused)) void *data)
2155 struct rte_eth_dev_info dev_info;
2156 struct rte_eth_rss_reta_entry64 reta_conf[8];
2157 struct cmd_config_rss_reta *res = parsed_result;
2159 memset(&dev_info, 0, sizeof(dev_info));
2160 rte_eth_dev_info_get(res->port_id, &dev_info);
2161 if (dev_info.reta_size == 0) {
2162 printf("Redirection table size is 0 which is "
2163 "invalid for RSS\n");
2166 printf("The reta size of port %d is %u\n",
2167 res->port_id, dev_info.reta_size);
2168 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
2169 printf("Currently do not support more than %u entries of "
2170 "redirection table\n", ETH_RSS_RETA_SIZE_512);
2174 memset(reta_conf, 0, sizeof(reta_conf));
2175 if (!strcmp(res->list_name, "reta")) {
2176 if (parse_reta_config(res->list_of_items, reta_conf,
2177 dev_info.reta_size)) {
2178 printf("Invalid RSS Redirection Table "
2179 "config entered\n");
2182 ret = rte_eth_dev_rss_reta_update(res->port_id,
2183 reta_conf, dev_info.reta_size);
2185 printf("Bad redirection table parameter, "
2186 "return code = %d \n", ret);
2190 cmdline_parse_token_string_t cmd_config_rss_reta_port =
2191 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
2192 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
2193 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
2194 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
2195 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT16);
2196 cmdline_parse_token_string_t cmd_config_rss_reta_name =
2197 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
2198 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
2199 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
2200 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
2201 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
2203 cmdline_parse_inst_t cmd_config_rss_reta = {
2204 .f = cmd_set_rss_reta_parsed,
2206 .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
2208 (void *)&cmd_config_rss_reta_port,
2209 (void *)&cmd_config_rss_reta_keyword,
2210 (void *)&cmd_config_rss_reta_port_id,
2211 (void *)&cmd_config_rss_reta_name,
2212 (void *)&cmd_config_rss_reta_list_name,
2213 (void *)&cmd_config_rss_reta_list_of_items,
2218 /* *** SHOW PORT RETA INFO *** */
2219 struct cmd_showport_reta {
2220 cmdline_fixed_string_t show;
2221 cmdline_fixed_string_t port;
2223 cmdline_fixed_string_t rss;
2224 cmdline_fixed_string_t reta;
2226 cmdline_fixed_string_t list_of_items;
2230 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
2231 uint16_t nb_entries,
2235 const char *p, *p0 = str;
2240 uint16_t num = (nb_entries + RTE_RETA_GROUP_SIZE - 1) /
2241 RTE_RETA_GROUP_SIZE;
2244 p = strchr(p0, '(');
2248 p0 = strchr(p, ')');
2252 if (size >= sizeof(s)) {
2253 printf("The string size exceeds the internal buffer size\n");
2256 snprintf(s, sizeof(s), "%.*s", size, p);
2257 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
2258 if (ret <= 0 || ret != num) {
2259 printf("The bits of masks do not match the number of "
2260 "reta entries: %u\n", num);
2263 for (i = 0; i < ret; i++)
2264 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
2270 cmd_showport_reta_parsed(void *parsed_result,
2271 __attribute__((unused)) struct cmdline *cl,
2272 __attribute__((unused)) void *data)
2274 struct cmd_showport_reta *res = parsed_result;
2275 struct rte_eth_rss_reta_entry64 reta_conf[8];
2276 struct rte_eth_dev_info dev_info;
2277 uint16_t max_reta_size;
2279 memset(&dev_info, 0, sizeof(dev_info));
2280 rte_eth_dev_info_get(res->port_id, &dev_info);
2281 max_reta_size = RTE_MIN(dev_info.reta_size, ETH_RSS_RETA_SIZE_512);
2282 if (res->size == 0 || res->size > max_reta_size) {
2283 printf("Invalid redirection table size: %u (1-%u)\n",
2284 res->size, max_reta_size);
2288 memset(reta_conf, 0, sizeof(reta_conf));
2289 if (showport_parse_reta_config(reta_conf, res->size,
2290 res->list_of_items) < 0) {
2291 printf("Invalid string: %s for reta masks\n",
2292 res->list_of_items);
2295 port_rss_reta_info(res->port_id, reta_conf, res->size);
2298 cmdline_parse_token_string_t cmd_showport_reta_show =
2299 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
2300 cmdline_parse_token_string_t cmd_showport_reta_port =
2301 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
2302 cmdline_parse_token_num_t cmd_showport_reta_port_id =
2303 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT16);
2304 cmdline_parse_token_string_t cmd_showport_reta_rss =
2305 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
2306 cmdline_parse_token_string_t cmd_showport_reta_reta =
2307 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
2308 cmdline_parse_token_num_t cmd_showport_reta_size =
2309 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16);
2310 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
2311 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
2312 list_of_items, NULL);
2314 cmdline_parse_inst_t cmd_showport_reta = {
2315 .f = cmd_showport_reta_parsed,
2317 .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
2319 (void *)&cmd_showport_reta_show,
2320 (void *)&cmd_showport_reta_port,
2321 (void *)&cmd_showport_reta_port_id,
2322 (void *)&cmd_showport_reta_rss,
2323 (void *)&cmd_showport_reta_reta,
2324 (void *)&cmd_showport_reta_size,
2325 (void *)&cmd_showport_reta_list_of_items,
2330 /* *** Show RSS hash configuration *** */
2331 struct cmd_showport_rss_hash {
2332 cmdline_fixed_string_t show;
2333 cmdline_fixed_string_t port;
2335 cmdline_fixed_string_t rss_hash;
2336 cmdline_fixed_string_t rss_type;
2337 cmdline_fixed_string_t key; /* optional argument */
2340 static void cmd_showport_rss_hash_parsed(void *parsed_result,
2341 __attribute__((unused)) struct cmdline *cl,
2344 struct cmd_showport_rss_hash *res = parsed_result;
2346 port_rss_hash_conf_show(res->port_id, res->rss_type,
2347 show_rss_key != NULL);
2350 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
2351 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
2352 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
2353 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
2354 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
2355 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT16);
2356 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
2357 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
2359 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash_info =
2360 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_type,
2361 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2362 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2363 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2364 "ipv6-tcp-ex#ipv6-udp-ex");
2365 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
2366 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
2368 cmdline_parse_inst_t cmd_showport_rss_hash = {
2369 .f = cmd_showport_rss_hash_parsed,
2371 .help_str = "show port <port_id> rss-hash "
2372 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2373 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2374 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex",
2376 (void *)&cmd_showport_rss_hash_show,
2377 (void *)&cmd_showport_rss_hash_port,
2378 (void *)&cmd_showport_rss_hash_port_id,
2379 (void *)&cmd_showport_rss_hash_rss_hash,
2380 (void *)&cmd_showport_rss_hash_rss_hash_info,
2385 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
2386 .f = cmd_showport_rss_hash_parsed,
2388 .help_str = "show port <port_id> rss-hash "
2389 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2390 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2391 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex key",
2393 (void *)&cmd_showport_rss_hash_show,
2394 (void *)&cmd_showport_rss_hash_port,
2395 (void *)&cmd_showport_rss_hash_port_id,
2396 (void *)&cmd_showport_rss_hash_rss_hash,
2397 (void *)&cmd_showport_rss_hash_rss_hash_info,
2398 (void *)&cmd_showport_rss_hash_rss_key,
2403 /* *** Configure DCB *** */
2404 struct cmd_config_dcb {
2405 cmdline_fixed_string_t port;
2406 cmdline_fixed_string_t config;
2408 cmdline_fixed_string_t dcb;
2409 cmdline_fixed_string_t vt;
2410 cmdline_fixed_string_t vt_en;
2412 cmdline_fixed_string_t pfc;
2413 cmdline_fixed_string_t pfc_en;
2417 cmd_config_dcb_parsed(void *parsed_result,
2418 __attribute__((unused)) struct cmdline *cl,
2419 __attribute__((unused)) void *data)
2421 struct cmd_config_dcb *res = parsed_result;
2422 portid_t port_id = res->port_id;
2423 struct rte_port *port;
2427 port = &ports[port_id];
2428 /** Check if the port is not started **/
2429 if (port->port_status != RTE_PORT_STOPPED) {
2430 printf("Please stop port %d first\n", port_id);
2434 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
2435 printf("The invalid number of traffic class,"
2436 " only 4 or 8 allowed.\n");
2440 if (nb_fwd_lcores < res->num_tcs) {
2441 printf("nb_cores shouldn't be less than number of TCs.\n");
2444 if (!strncmp(res->pfc_en, "on", 2))
2449 /* DCB in VT mode */
2450 if (!strncmp(res->vt_en, "on", 2))
2451 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
2452 (enum rte_eth_nb_tcs)res->num_tcs,
2455 ret = init_port_dcb_config(port_id, DCB_ENABLED,
2456 (enum rte_eth_nb_tcs)res->num_tcs,
2461 printf("Cannot initialize network ports.\n");
2465 cmd_reconfig_device_queue(port_id, 1, 1);
2468 cmdline_parse_token_string_t cmd_config_dcb_port =
2469 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
2470 cmdline_parse_token_string_t cmd_config_dcb_config =
2471 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
2472 cmdline_parse_token_num_t cmd_config_dcb_port_id =
2473 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT16);
2474 cmdline_parse_token_string_t cmd_config_dcb_dcb =
2475 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
2476 cmdline_parse_token_string_t cmd_config_dcb_vt =
2477 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
2478 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
2479 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
2480 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
2481 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
2482 cmdline_parse_token_string_t cmd_config_dcb_pfc=
2483 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
2484 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
2485 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
2487 cmdline_parse_inst_t cmd_config_dcb = {
2488 .f = cmd_config_dcb_parsed,
2490 .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
2492 (void *)&cmd_config_dcb_port,
2493 (void *)&cmd_config_dcb_config,
2494 (void *)&cmd_config_dcb_port_id,
2495 (void *)&cmd_config_dcb_dcb,
2496 (void *)&cmd_config_dcb_vt,
2497 (void *)&cmd_config_dcb_vt_en,
2498 (void *)&cmd_config_dcb_num_tcs,
2499 (void *)&cmd_config_dcb_pfc,
2500 (void *)&cmd_config_dcb_pfc_en,
2505 /* *** configure number of packets per burst *** */
2506 struct cmd_config_burst {
2507 cmdline_fixed_string_t port;
2508 cmdline_fixed_string_t keyword;
2509 cmdline_fixed_string_t all;
2510 cmdline_fixed_string_t name;
2515 cmd_config_burst_parsed(void *parsed_result,
2516 __attribute__((unused)) struct cmdline *cl,
2517 __attribute__((unused)) void *data)
2519 struct cmd_config_burst *res = parsed_result;
2521 if (!all_ports_stopped()) {
2522 printf("Please stop all ports first\n");
2526 if (!strcmp(res->name, "burst")) {
2527 if (res->value < 1 || res->value > MAX_PKT_BURST) {
2528 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
2531 nb_pkt_per_burst = res->value;
2533 printf("Unknown parameter\n");
2539 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2542 cmdline_parse_token_string_t cmd_config_burst_port =
2543 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
2544 cmdline_parse_token_string_t cmd_config_burst_keyword =
2545 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
2546 cmdline_parse_token_string_t cmd_config_burst_all =
2547 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
2548 cmdline_parse_token_string_t cmd_config_burst_name =
2549 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
2550 cmdline_parse_token_num_t cmd_config_burst_value =
2551 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
2553 cmdline_parse_inst_t cmd_config_burst = {
2554 .f = cmd_config_burst_parsed,
2556 .help_str = "port config all burst <value>",
2558 (void *)&cmd_config_burst_port,
2559 (void *)&cmd_config_burst_keyword,
2560 (void *)&cmd_config_burst_all,
2561 (void *)&cmd_config_burst_name,
2562 (void *)&cmd_config_burst_value,
2567 /* *** configure rx/tx queues *** */
2568 struct cmd_config_thresh {
2569 cmdline_fixed_string_t port;
2570 cmdline_fixed_string_t keyword;
2571 cmdline_fixed_string_t all;
2572 cmdline_fixed_string_t name;
2577 cmd_config_thresh_parsed(void *parsed_result,
2578 __attribute__((unused)) struct cmdline *cl,
2579 __attribute__((unused)) void *data)
2581 struct cmd_config_thresh *res = parsed_result;
2583 if (!all_ports_stopped()) {
2584 printf("Please stop all ports first\n");
2588 if (!strcmp(res->name, "txpt"))
2589 tx_pthresh = res->value;
2590 else if(!strcmp(res->name, "txht"))
2591 tx_hthresh = res->value;
2592 else if(!strcmp(res->name, "txwt"))
2593 tx_wthresh = res->value;
2594 else if(!strcmp(res->name, "rxpt"))
2595 rx_pthresh = res->value;
2596 else if(!strcmp(res->name, "rxht"))
2597 rx_hthresh = res->value;
2598 else if(!strcmp(res->name, "rxwt"))
2599 rx_wthresh = res->value;
2601 printf("Unknown parameter\n");
2607 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2610 cmdline_parse_token_string_t cmd_config_thresh_port =
2611 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
2612 cmdline_parse_token_string_t cmd_config_thresh_keyword =
2613 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
2614 cmdline_parse_token_string_t cmd_config_thresh_all =
2615 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
2616 cmdline_parse_token_string_t cmd_config_thresh_name =
2617 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
2618 "txpt#txht#txwt#rxpt#rxht#rxwt");
2619 cmdline_parse_token_num_t cmd_config_thresh_value =
2620 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
2622 cmdline_parse_inst_t cmd_config_thresh = {
2623 .f = cmd_config_thresh_parsed,
2625 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
2627 (void *)&cmd_config_thresh_port,
2628 (void *)&cmd_config_thresh_keyword,
2629 (void *)&cmd_config_thresh_all,
2630 (void *)&cmd_config_thresh_name,
2631 (void *)&cmd_config_thresh_value,
2636 /* *** configure free/rs threshold *** */
2637 struct cmd_config_threshold {
2638 cmdline_fixed_string_t port;
2639 cmdline_fixed_string_t keyword;
2640 cmdline_fixed_string_t all;
2641 cmdline_fixed_string_t name;
2646 cmd_config_threshold_parsed(void *parsed_result,
2647 __attribute__((unused)) struct cmdline *cl,
2648 __attribute__((unused)) void *data)
2650 struct cmd_config_threshold *res = parsed_result;
2652 if (!all_ports_stopped()) {
2653 printf("Please stop all ports first\n");
2657 if (!strcmp(res->name, "txfreet"))
2658 tx_free_thresh = res->value;
2659 else if (!strcmp(res->name, "txrst"))
2660 tx_rs_thresh = res->value;
2661 else if (!strcmp(res->name, "rxfreet"))
2662 rx_free_thresh = res->value;
2664 printf("Unknown parameter\n");
2670 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2673 cmdline_parse_token_string_t cmd_config_threshold_port =
2674 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
2675 cmdline_parse_token_string_t cmd_config_threshold_keyword =
2676 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
2678 cmdline_parse_token_string_t cmd_config_threshold_all =
2679 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
2680 cmdline_parse_token_string_t cmd_config_threshold_name =
2681 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
2682 "txfreet#txrst#rxfreet");
2683 cmdline_parse_token_num_t cmd_config_threshold_value =
2684 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
2686 cmdline_parse_inst_t cmd_config_threshold = {
2687 .f = cmd_config_threshold_parsed,
2689 .help_str = "port config all txfreet|txrst|rxfreet <value>",
2691 (void *)&cmd_config_threshold_port,
2692 (void *)&cmd_config_threshold_keyword,
2693 (void *)&cmd_config_threshold_all,
2694 (void *)&cmd_config_threshold_name,
2695 (void *)&cmd_config_threshold_value,
2701 struct cmd_stop_result {
2702 cmdline_fixed_string_t stop;
2705 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
2706 __attribute__((unused)) struct cmdline *cl,
2707 __attribute__((unused)) void *data)
2709 stop_packet_forwarding();
2712 cmdline_parse_token_string_t cmd_stop_stop =
2713 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
2715 cmdline_parse_inst_t cmd_stop = {
2716 .f = cmd_stop_parsed,
2718 .help_str = "stop: Stop packet forwarding",
2720 (void *)&cmd_stop_stop,
2725 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
2728 parse_item_list(char* str, const char* item_name, unsigned int max_items,
2729 unsigned int *parsed_items, int check_unique_values)
2731 unsigned int nb_item;
2739 * First parse all items in the list and store their value.
2744 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
2746 if ((c >= '0') && (c <= '9')) {
2747 value = (unsigned int) (value * 10 + (c - '0'));
2752 printf("character %c is not a decimal digit\n", c);
2756 printf("No valid value before comma\n");
2759 if (nb_item < max_items) {
2760 parsed_items[nb_item] = value;
2766 if (nb_item >= max_items) {
2767 printf("Number of %s = %u > %u (maximum items)\n",
2768 item_name, nb_item + 1, max_items);
2771 parsed_items[nb_item++] = value;
2772 if (! check_unique_values)
2776 * Then, check that all values in the list are differents.
2777 * No optimization here...
2779 for (i = 0; i < nb_item; i++) {
2780 for (j = i + 1; j < nb_item; j++) {
2781 if (parsed_items[j] == parsed_items[i]) {
2782 printf("duplicated %s %u at index %u and %u\n",
2783 item_name, parsed_items[i], i, j);
2791 struct cmd_set_list_result {
2792 cmdline_fixed_string_t cmd_keyword;
2793 cmdline_fixed_string_t list_name;
2794 cmdline_fixed_string_t list_of_items;
2797 static void cmd_set_list_parsed(void *parsed_result,
2798 __attribute__((unused)) struct cmdline *cl,
2799 __attribute__((unused)) void *data)
2801 struct cmd_set_list_result *res;
2803 unsigned int lcorelist[RTE_MAX_LCORE];
2804 unsigned int portlist[RTE_MAX_ETHPORTS];
2806 unsigned int nb_item;
2808 if (test_done == 0) {
2809 printf("Please stop forwarding first\n");
2813 res = parsed_result;
2814 if (!strcmp(res->list_name, "corelist")) {
2815 nb_item = parse_item_list(res->list_of_items, "core",
2817 parsed_items.lcorelist, 1);
2819 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
2824 if (!strcmp(res->list_name, "portlist")) {
2825 nb_item = parse_item_list(res->list_of_items, "port",
2827 parsed_items.portlist, 1);
2829 set_fwd_ports_list(parsed_items.portlist, nb_item);
2835 cmdline_parse_token_string_t cmd_set_list_keyword =
2836 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
2838 cmdline_parse_token_string_t cmd_set_list_name =
2839 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
2840 "corelist#portlist");
2841 cmdline_parse_token_string_t cmd_set_list_of_items =
2842 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
2845 cmdline_parse_inst_t cmd_set_fwd_list = {
2846 .f = cmd_set_list_parsed,
2848 .help_str = "set corelist|portlist <list0[,list1]*>",
2850 (void *)&cmd_set_list_keyword,
2851 (void *)&cmd_set_list_name,
2852 (void *)&cmd_set_list_of_items,
2857 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
2859 struct cmd_setmask_result {
2860 cmdline_fixed_string_t set;
2861 cmdline_fixed_string_t mask;
2865 static void cmd_set_mask_parsed(void *parsed_result,
2866 __attribute__((unused)) struct cmdline *cl,
2867 __attribute__((unused)) void *data)
2869 struct cmd_setmask_result *res = parsed_result;
2871 if (test_done == 0) {
2872 printf("Please stop forwarding first\n");
2875 if (!strcmp(res->mask, "coremask")) {
2876 set_fwd_lcores_mask(res->hexavalue);
2878 } else if (!strcmp(res->mask, "portmask")) {
2879 set_fwd_ports_mask(res->hexavalue);
2884 cmdline_parse_token_string_t cmd_setmask_set =
2885 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
2886 cmdline_parse_token_string_t cmd_setmask_mask =
2887 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
2888 "coremask#portmask");
2889 cmdline_parse_token_num_t cmd_setmask_value =
2890 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
2892 cmdline_parse_inst_t cmd_set_fwd_mask = {
2893 .f = cmd_set_mask_parsed,
2895 .help_str = "set coremask|portmask <hexadecimal value>",
2897 (void *)&cmd_setmask_set,
2898 (void *)&cmd_setmask_mask,
2899 (void *)&cmd_setmask_value,
2905 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
2907 struct cmd_set_result {
2908 cmdline_fixed_string_t set;
2909 cmdline_fixed_string_t what;
2913 static void cmd_set_parsed(void *parsed_result,
2914 __attribute__((unused)) struct cmdline *cl,
2915 __attribute__((unused)) void *data)
2917 struct cmd_set_result *res = parsed_result;
2918 if (!strcmp(res->what, "nbport")) {
2919 set_fwd_ports_number(res->value);
2921 } else if (!strcmp(res->what, "nbcore")) {
2922 set_fwd_lcores_number(res->value);
2924 } else if (!strcmp(res->what, "burst"))
2925 set_nb_pkt_per_burst(res->value);
2926 else if (!strcmp(res->what, "verbose"))
2927 set_verbose_level(res->value);
2930 cmdline_parse_token_string_t cmd_set_set =
2931 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
2932 cmdline_parse_token_string_t cmd_set_what =
2933 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
2934 "nbport#nbcore#burst#verbose");
2935 cmdline_parse_token_num_t cmd_set_value =
2936 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
2938 cmdline_parse_inst_t cmd_set_numbers = {
2939 .f = cmd_set_parsed,
2941 .help_str = "set nbport|nbcore|burst|verbose <value>",
2943 (void *)&cmd_set_set,
2944 (void *)&cmd_set_what,
2945 (void *)&cmd_set_value,
2950 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
2952 struct cmd_set_txpkts_result {
2953 cmdline_fixed_string_t cmd_keyword;
2954 cmdline_fixed_string_t txpkts;
2955 cmdline_fixed_string_t seg_lengths;
2959 cmd_set_txpkts_parsed(void *parsed_result,
2960 __attribute__((unused)) struct cmdline *cl,
2961 __attribute__((unused)) void *data)
2963 struct cmd_set_txpkts_result *res;
2964 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
2965 unsigned int nb_segs;
2967 res = parsed_result;
2968 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
2969 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
2971 set_tx_pkt_segments(seg_lengths, nb_segs);
2974 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
2975 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2976 cmd_keyword, "set");
2977 cmdline_parse_token_string_t cmd_set_txpkts_name =
2978 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2980 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
2981 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
2984 cmdline_parse_inst_t cmd_set_txpkts = {
2985 .f = cmd_set_txpkts_parsed,
2987 .help_str = "set txpkts <len0[,len1]*>",
2989 (void *)&cmd_set_txpkts_keyword,
2990 (void *)&cmd_set_txpkts_name,
2991 (void *)&cmd_set_txpkts_lengths,
2996 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
2998 struct cmd_set_txsplit_result {
2999 cmdline_fixed_string_t cmd_keyword;
3000 cmdline_fixed_string_t txsplit;
3001 cmdline_fixed_string_t mode;
3005 cmd_set_txsplit_parsed(void *parsed_result,
3006 __attribute__((unused)) struct cmdline *cl,
3007 __attribute__((unused)) void *data)
3009 struct cmd_set_txsplit_result *res;
3011 res = parsed_result;
3012 set_tx_pkt_split(res->mode);
3015 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
3016 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3017 cmd_keyword, "set");
3018 cmdline_parse_token_string_t cmd_set_txsplit_name =
3019 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3020 txsplit, "txsplit");
3021 cmdline_parse_token_string_t cmd_set_txsplit_mode =
3022 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3025 cmdline_parse_inst_t cmd_set_txsplit = {
3026 .f = cmd_set_txsplit_parsed,
3028 .help_str = "set txsplit on|off|rand",
3030 (void *)&cmd_set_txsplit_keyword,
3031 (void *)&cmd_set_txsplit_name,
3032 (void *)&cmd_set_txsplit_mode,
3037 /* *** CONFIG TX QUEUE FLAGS *** */
3039 struct cmd_config_txqflags_result {
3040 cmdline_fixed_string_t port;
3041 cmdline_fixed_string_t config;
3042 cmdline_fixed_string_t all;
3043 cmdline_fixed_string_t what;
3047 static void cmd_config_txqflags_parsed(void *parsed_result,
3048 __attribute__((unused)) struct cmdline *cl,
3049 __attribute__((unused)) void *data)
3051 struct cmd_config_txqflags_result *res = parsed_result;
3053 if (!all_ports_stopped()) {
3054 printf("Please stop all ports first\n");
3058 if (strcmp(res->what, "txqflags")) {
3059 printf("Unknown parameter\n");
3063 if (res->hexvalue >= 0) {
3064 txq_flags = res->hexvalue;
3066 printf("txqflags must be >= 0\n");
3072 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3075 cmdline_parse_token_string_t cmd_config_txqflags_port =
3076 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, port,
3078 cmdline_parse_token_string_t cmd_config_txqflags_config =
3079 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, config,
3081 cmdline_parse_token_string_t cmd_config_txqflags_all =
3082 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, all,
3084 cmdline_parse_token_string_t cmd_config_txqflags_what =
3085 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, what,
3087 cmdline_parse_token_num_t cmd_config_txqflags_value =
3088 TOKEN_NUM_INITIALIZER(struct cmd_config_txqflags_result,
3091 cmdline_parse_inst_t cmd_config_txqflags = {
3092 .f = cmd_config_txqflags_parsed,
3094 .help_str = "port config all txqflags <value>",
3096 (void *)&cmd_config_txqflags_port,
3097 (void *)&cmd_config_txqflags_config,
3098 (void *)&cmd_config_txqflags_all,
3099 (void *)&cmd_config_txqflags_what,
3100 (void *)&cmd_config_txqflags_value,
3105 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
3106 struct cmd_rx_vlan_filter_all_result {
3107 cmdline_fixed_string_t rx_vlan;
3108 cmdline_fixed_string_t what;
3109 cmdline_fixed_string_t all;
3114 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
3115 __attribute__((unused)) struct cmdline *cl,
3116 __attribute__((unused)) void *data)
3118 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
3120 if (!strcmp(res->what, "add"))
3121 rx_vlan_all_filter_set(res->port_id, 1);
3123 rx_vlan_all_filter_set(res->port_id, 0);
3126 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
3127 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3128 rx_vlan, "rx_vlan");
3129 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
3130 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3132 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
3133 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3135 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
3136 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3139 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
3140 .f = cmd_rx_vlan_filter_all_parsed,
3142 .help_str = "rx_vlan add|rm all <port_id>: "
3143 "Add/Remove all identifiers to/from the set of VLAN "
3144 "identifiers filtered by a port",
3146 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
3147 (void *)&cmd_rx_vlan_filter_all_what,
3148 (void *)&cmd_rx_vlan_filter_all_all,
3149 (void *)&cmd_rx_vlan_filter_all_portid,
3154 /* *** VLAN OFFLOAD SET ON A PORT *** */
3155 struct cmd_vlan_offload_result {
3156 cmdline_fixed_string_t vlan;
3157 cmdline_fixed_string_t set;
3158 cmdline_fixed_string_t vlan_type;
3159 cmdline_fixed_string_t what;
3160 cmdline_fixed_string_t on;
3161 cmdline_fixed_string_t port_id;
3165 cmd_vlan_offload_parsed(void *parsed_result,
3166 __attribute__((unused)) struct cmdline *cl,
3167 __attribute__((unused)) void *data)
3170 struct cmd_vlan_offload_result *res = parsed_result;
3173 portid_t port_id = 0;
3177 len = strnlen(str, STR_TOKEN_SIZE);
3179 /* Get port_id first */
3187 tmp = strtoul(str, NULL, 0);
3188 /* If port_id greater that what portid_t can represent, return */
3189 if(tmp >= RTE_MAX_ETHPORTS)
3191 port_id = (portid_t)tmp;
3193 if (!strcmp(res->on, "on"))
3198 if (!strcmp(res->what, "strip"))
3199 rx_vlan_strip_set(port_id, on);
3200 else if(!strcmp(res->what, "stripq")){
3201 uint16_t queue_id = 0;
3203 /* No queue_id, return */
3205 printf("must specify (port,queue_id)\n");
3208 tmp = strtoul(str + i + 1, NULL, 0);
3209 /* If queue_id greater that what 16-bits can represent, return */
3213 queue_id = (uint16_t)tmp;
3214 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
3216 else if (!strcmp(res->what, "filter"))
3217 rx_vlan_filter_set(port_id, on);
3219 vlan_extend_set(port_id, on);
3224 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
3225 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3227 cmdline_parse_token_string_t cmd_vlan_offload_set =
3228 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3230 cmdline_parse_token_string_t cmd_vlan_offload_what =
3231 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3232 what, "strip#filter#qinq#stripq");
3233 cmdline_parse_token_string_t cmd_vlan_offload_on =
3234 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3236 cmdline_parse_token_string_t cmd_vlan_offload_portid =
3237 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3240 cmdline_parse_inst_t cmd_vlan_offload = {
3241 .f = cmd_vlan_offload_parsed,
3243 .help_str = "vlan set strip|filter|qinq|stripq on|off "
3244 "<port_id[,queue_id]>: "
3245 "Filter/Strip for rx side qinq(extended) for both rx/tx sides",
3247 (void *)&cmd_vlan_offload_vlan,
3248 (void *)&cmd_vlan_offload_set,
3249 (void *)&cmd_vlan_offload_what,
3250 (void *)&cmd_vlan_offload_on,
3251 (void *)&cmd_vlan_offload_portid,
3256 /* *** VLAN TPID SET ON A PORT *** */
3257 struct cmd_vlan_tpid_result {
3258 cmdline_fixed_string_t vlan;
3259 cmdline_fixed_string_t set;
3260 cmdline_fixed_string_t vlan_type;
3261 cmdline_fixed_string_t what;
3267 cmd_vlan_tpid_parsed(void *parsed_result,
3268 __attribute__((unused)) struct cmdline *cl,
3269 __attribute__((unused)) void *data)
3271 struct cmd_vlan_tpid_result *res = parsed_result;
3272 enum rte_vlan_type vlan_type;
3274 if (!strcmp(res->vlan_type, "inner"))
3275 vlan_type = ETH_VLAN_TYPE_INNER;
3276 else if (!strcmp(res->vlan_type, "outer"))
3277 vlan_type = ETH_VLAN_TYPE_OUTER;
3279 printf("Unknown vlan type\n");
3282 vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
3285 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
3286 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3288 cmdline_parse_token_string_t cmd_vlan_tpid_set =
3289 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3291 cmdline_parse_token_string_t cmd_vlan_type =
3292 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3293 vlan_type, "inner#outer");
3294 cmdline_parse_token_string_t cmd_vlan_tpid_what =
3295 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3297 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
3298 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3300 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
3301 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3304 cmdline_parse_inst_t cmd_vlan_tpid = {
3305 .f = cmd_vlan_tpid_parsed,
3307 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
3308 "Set the VLAN Ether type",
3310 (void *)&cmd_vlan_tpid_vlan,
3311 (void *)&cmd_vlan_tpid_set,
3312 (void *)&cmd_vlan_type,
3313 (void *)&cmd_vlan_tpid_what,
3314 (void *)&cmd_vlan_tpid_tpid,
3315 (void *)&cmd_vlan_tpid_portid,
3320 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
3321 struct cmd_rx_vlan_filter_result {
3322 cmdline_fixed_string_t rx_vlan;
3323 cmdline_fixed_string_t what;
3329 cmd_rx_vlan_filter_parsed(void *parsed_result,
3330 __attribute__((unused)) struct cmdline *cl,
3331 __attribute__((unused)) void *data)
3333 struct cmd_rx_vlan_filter_result *res = parsed_result;
3335 if (!strcmp(res->what, "add"))
3336 rx_vft_set(res->port_id, res->vlan_id, 1);
3338 rx_vft_set(res->port_id, res->vlan_id, 0);
3341 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
3342 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3343 rx_vlan, "rx_vlan");
3344 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
3345 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3347 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
3348 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3350 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
3351 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3354 cmdline_parse_inst_t cmd_rx_vlan_filter = {
3355 .f = cmd_rx_vlan_filter_parsed,
3357 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
3358 "Add/Remove a VLAN identifier to/from the set of VLAN "
3359 "identifiers filtered by a port",
3361 (void *)&cmd_rx_vlan_filter_rx_vlan,
3362 (void *)&cmd_rx_vlan_filter_what,
3363 (void *)&cmd_rx_vlan_filter_vlanid,
3364 (void *)&cmd_rx_vlan_filter_portid,
3369 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3370 struct cmd_tx_vlan_set_result {
3371 cmdline_fixed_string_t tx_vlan;
3372 cmdline_fixed_string_t set;
3378 cmd_tx_vlan_set_parsed(void *parsed_result,
3379 __attribute__((unused)) struct cmdline *cl,
3380 __attribute__((unused)) void *data)
3382 struct cmd_tx_vlan_set_result *res = parsed_result;
3384 tx_vlan_set(res->port_id, res->vlan_id);
3387 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
3388 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3389 tx_vlan, "tx_vlan");
3390 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
3391 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3393 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
3394 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3396 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
3397 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3400 cmdline_parse_inst_t cmd_tx_vlan_set = {
3401 .f = cmd_tx_vlan_set_parsed,
3403 .help_str = "tx_vlan set <port_id> <vlan_id>: "
3404 "Enable hardware insertion of a single VLAN header "
3405 "with a given TAG Identifier in packets sent on a port",
3407 (void *)&cmd_tx_vlan_set_tx_vlan,
3408 (void *)&cmd_tx_vlan_set_set,
3409 (void *)&cmd_tx_vlan_set_portid,
3410 (void *)&cmd_tx_vlan_set_vlanid,
3415 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
3416 struct cmd_tx_vlan_set_qinq_result {
3417 cmdline_fixed_string_t tx_vlan;
3418 cmdline_fixed_string_t set;
3421 uint16_t vlan_id_outer;
3425 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
3426 __attribute__((unused)) struct cmdline *cl,
3427 __attribute__((unused)) void *data)
3429 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
3431 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
3434 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
3435 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3436 tx_vlan, "tx_vlan");
3437 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
3438 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3440 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
3441 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3443 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
3444 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3446 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
3447 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3448 vlan_id_outer, UINT16);
3450 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
3451 .f = cmd_tx_vlan_set_qinq_parsed,
3453 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
3454 "Enable hardware insertion of double VLAN header "
3455 "with given TAG Identifiers in packets sent on a port",
3457 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
3458 (void *)&cmd_tx_vlan_set_qinq_set,
3459 (void *)&cmd_tx_vlan_set_qinq_portid,
3460 (void *)&cmd_tx_vlan_set_qinq_vlanid,
3461 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
3466 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
3467 struct cmd_tx_vlan_set_pvid_result {
3468 cmdline_fixed_string_t tx_vlan;
3469 cmdline_fixed_string_t set;
3470 cmdline_fixed_string_t pvid;
3473 cmdline_fixed_string_t mode;
3477 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
3478 __attribute__((unused)) struct cmdline *cl,
3479 __attribute__((unused)) void *data)
3481 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
3483 if (strcmp(res->mode, "on") == 0)
3484 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
3486 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
3489 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
3490 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3491 tx_vlan, "tx_vlan");
3492 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
3493 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3495 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
3496 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3498 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
3499 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3501 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
3502 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3504 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
3505 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3508 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
3509 .f = cmd_tx_vlan_set_pvid_parsed,
3511 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
3513 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
3514 (void *)&cmd_tx_vlan_set_pvid_set,
3515 (void *)&cmd_tx_vlan_set_pvid_pvid,
3516 (void *)&cmd_tx_vlan_set_pvid_port_id,
3517 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
3518 (void *)&cmd_tx_vlan_set_pvid_mode,
3523 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3524 struct cmd_tx_vlan_reset_result {
3525 cmdline_fixed_string_t tx_vlan;
3526 cmdline_fixed_string_t reset;
3531 cmd_tx_vlan_reset_parsed(void *parsed_result,
3532 __attribute__((unused)) struct cmdline *cl,
3533 __attribute__((unused)) void *data)
3535 struct cmd_tx_vlan_reset_result *res = parsed_result;
3537 tx_vlan_reset(res->port_id);
3540 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
3541 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
3542 tx_vlan, "tx_vlan");
3543 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
3544 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
3546 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
3547 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
3550 cmdline_parse_inst_t cmd_tx_vlan_reset = {
3551 .f = cmd_tx_vlan_reset_parsed,
3553 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
3554 "VLAN header in packets sent on a port",
3556 (void *)&cmd_tx_vlan_reset_tx_vlan,
3557 (void *)&cmd_tx_vlan_reset_reset,
3558 (void *)&cmd_tx_vlan_reset_portid,
3564 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
3565 struct cmd_csum_result {
3566 cmdline_fixed_string_t csum;
3567 cmdline_fixed_string_t mode;
3568 cmdline_fixed_string_t proto;
3569 cmdline_fixed_string_t hwsw;
3574 csum_show(int port_id)
3576 struct rte_eth_dev_info dev_info;
3579 ol_flags = ports[port_id].tx_ol_flags;
3580 printf("Parse tunnel is %s\n",
3581 (ol_flags & TESTPMD_TX_OFFLOAD_PARSE_TUNNEL) ? "on" : "off");
3582 printf("IP checksum offload is %s\n",
3583 (ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) ? "hw" : "sw");
3584 printf("UDP checksum offload is %s\n",
3585 (ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
3586 printf("TCP checksum offload is %s\n",
3587 (ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
3588 printf("SCTP checksum offload is %s\n",
3589 (ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
3590 printf("Outer-Ip checksum offload is %s\n",
3591 (ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) ? "hw" : "sw");
3593 /* display warnings if configuration is not supported by the NIC */
3594 rte_eth_dev_info_get(port_id, &dev_info);
3595 if ((ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) &&
3596 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
3597 printf("Warning: hardware IP checksum enabled but not "
3598 "supported by port %d\n", port_id);
3600 if ((ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) &&
3601 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
3602 printf("Warning: hardware UDP checksum enabled but not "
3603 "supported by port %d\n", port_id);
3605 if ((ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) &&
3606 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
3607 printf("Warning: hardware TCP checksum enabled but not "
3608 "supported by port %d\n", port_id);
3610 if ((ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) &&
3611 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
3612 printf("Warning: hardware SCTP checksum enabled but not "
3613 "supported by port %d\n", port_id);
3615 if ((ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) &&
3616 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
3617 printf("Warning: hardware outer IP checksum enabled but not "
3618 "supported by port %d\n", port_id);
3623 cmd_csum_parsed(void *parsed_result,
3624 __attribute__((unused)) struct cmdline *cl,
3625 __attribute__((unused)) void *data)
3627 struct cmd_csum_result *res = parsed_result;
3631 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
3632 printf("invalid port %d\n", res->port_id);
3636 if (!strcmp(res->mode, "set")) {
3638 if (!strcmp(res->hwsw, "hw"))
3641 if (!strcmp(res->proto, "ip")) {
3642 mask = TESTPMD_TX_OFFLOAD_IP_CKSUM;
3643 } else if (!strcmp(res->proto, "udp")) {
3644 mask = TESTPMD_TX_OFFLOAD_UDP_CKSUM;
3645 } else if (!strcmp(res->proto, "tcp")) {
3646 mask = TESTPMD_TX_OFFLOAD_TCP_CKSUM;
3647 } else if (!strcmp(res->proto, "sctp")) {
3648 mask = TESTPMD_TX_OFFLOAD_SCTP_CKSUM;
3649 } else if (!strcmp(res->proto, "outer-ip")) {
3650 mask = TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM;
3654 ports[res->port_id].tx_ol_flags |= mask;
3656 ports[res->port_id].tx_ol_flags &= (~mask);
3658 csum_show(res->port_id);
3661 cmdline_parse_token_string_t cmd_csum_csum =
3662 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3664 cmdline_parse_token_string_t cmd_csum_mode =
3665 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3667 cmdline_parse_token_string_t cmd_csum_proto =
3668 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3669 proto, "ip#tcp#udp#sctp#outer-ip");
3670 cmdline_parse_token_string_t cmd_csum_hwsw =
3671 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3673 cmdline_parse_token_num_t cmd_csum_portid =
3674 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
3677 cmdline_parse_inst_t cmd_csum_set = {
3678 .f = cmd_csum_parsed,
3680 .help_str = "csum set ip|tcp|udp|sctp|outer-ip hw|sw <port_id>: "
3681 "Enable/Disable hardware calculation of L3/L4 checksum when "
3682 "using csum forward engine",
3684 (void *)&cmd_csum_csum,
3685 (void *)&cmd_csum_mode,
3686 (void *)&cmd_csum_proto,
3687 (void *)&cmd_csum_hwsw,
3688 (void *)&cmd_csum_portid,
3693 cmdline_parse_token_string_t cmd_csum_mode_show =
3694 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3697 cmdline_parse_inst_t cmd_csum_show = {
3698 .f = cmd_csum_parsed,
3700 .help_str = "csum show <port_id>: Show checksum offload configuration",
3702 (void *)&cmd_csum_csum,
3703 (void *)&cmd_csum_mode_show,
3704 (void *)&cmd_csum_portid,
3709 /* Enable/disable tunnel parsing */
3710 struct cmd_csum_tunnel_result {
3711 cmdline_fixed_string_t csum;
3712 cmdline_fixed_string_t parse;
3713 cmdline_fixed_string_t onoff;
3718 cmd_csum_tunnel_parsed(void *parsed_result,
3719 __attribute__((unused)) struct cmdline *cl,
3720 __attribute__((unused)) void *data)
3722 struct cmd_csum_tunnel_result *res = parsed_result;
3724 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3727 if (!strcmp(res->onoff, "on"))
3728 ports[res->port_id].tx_ol_flags |=
3729 TESTPMD_TX_OFFLOAD_PARSE_TUNNEL;
3731 ports[res->port_id].tx_ol_flags &=
3732 (~TESTPMD_TX_OFFLOAD_PARSE_TUNNEL);
3734 csum_show(res->port_id);
3737 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
3738 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3740 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
3741 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3742 parse, "parse_tunnel");
3743 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
3744 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3746 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
3747 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
3750 cmdline_parse_inst_t cmd_csum_tunnel = {
3751 .f = cmd_csum_tunnel_parsed,
3753 .help_str = "csum parse_tunnel on|off <port_id>: "
3754 "Enable/Disable parsing of tunnels for csum engine",
3756 (void *)&cmd_csum_tunnel_csum,
3757 (void *)&cmd_csum_tunnel_parse,
3758 (void *)&cmd_csum_tunnel_onoff,
3759 (void *)&cmd_csum_tunnel_portid,
3764 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
3765 struct cmd_tso_set_result {
3766 cmdline_fixed_string_t tso;
3767 cmdline_fixed_string_t mode;
3773 cmd_tso_set_parsed(void *parsed_result,
3774 __attribute__((unused)) struct cmdline *cl,
3775 __attribute__((unused)) void *data)
3777 struct cmd_tso_set_result *res = parsed_result;
3778 struct rte_eth_dev_info dev_info;
3780 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3783 if (!strcmp(res->mode, "set"))
3784 ports[res->port_id].tso_segsz = res->tso_segsz;
3786 if (ports[res->port_id].tso_segsz == 0)
3787 printf("TSO for non-tunneled packets is disabled\n");
3789 printf("TSO segment size for non-tunneled packets is %d\n",
3790 ports[res->port_id].tso_segsz);
3792 /* display warnings if configuration is not supported by the NIC */
3793 rte_eth_dev_info_get(res->port_id, &dev_info);
3794 if ((ports[res->port_id].tso_segsz != 0) &&
3795 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
3796 printf("Warning: TSO enabled but not "
3797 "supported by port %d\n", res->port_id);
3801 cmdline_parse_token_string_t cmd_tso_set_tso =
3802 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3804 cmdline_parse_token_string_t cmd_tso_set_mode =
3805 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3807 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
3808 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3810 cmdline_parse_token_num_t cmd_tso_set_portid =
3811 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3814 cmdline_parse_inst_t cmd_tso_set = {
3815 .f = cmd_tso_set_parsed,
3817 .help_str = "tso set <tso_segsz> <port_id>: "
3818 "Set TSO segment size of non-tunneled packets for csum engine "
3821 (void *)&cmd_tso_set_tso,
3822 (void *)&cmd_tso_set_mode,
3823 (void *)&cmd_tso_set_tso_segsz,
3824 (void *)&cmd_tso_set_portid,
3829 cmdline_parse_token_string_t cmd_tso_show_mode =
3830 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3834 cmdline_parse_inst_t cmd_tso_show = {
3835 .f = cmd_tso_set_parsed,
3837 .help_str = "tso show <port_id>: "
3838 "Show TSO segment size of non-tunneled packets for csum engine",
3840 (void *)&cmd_tso_set_tso,
3841 (void *)&cmd_tso_show_mode,
3842 (void *)&cmd_tso_set_portid,
3847 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
3848 struct cmd_tunnel_tso_set_result {
3849 cmdline_fixed_string_t tso;
3850 cmdline_fixed_string_t mode;
3856 check_tunnel_tso_nic_support(portid_t port_id)
3858 struct rte_eth_dev_info dev_info;
3860 rte_eth_dev_info_get(port_id, &dev_info);
3861 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO))
3862 printf("Warning: TSO enabled but VXLAN TUNNEL TSO not "
3863 "supported by port %d\n", port_id);
3864 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO))
3865 printf("Warning: TSO enabled but GRE TUNNEL TSO not "
3866 "supported by port %d\n", port_id);
3867 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO))
3868 printf("Warning: TSO enabled but IPIP TUNNEL TSO not "
3869 "supported by port %d\n", port_id);
3870 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
3871 printf("Warning: TSO enabled but GENEVE TUNNEL TSO not "
3872 "supported by port %d\n", port_id);
3876 cmd_tunnel_tso_set_parsed(void *parsed_result,
3877 __attribute__((unused)) struct cmdline *cl,
3878 __attribute__((unused)) void *data)
3880 struct cmd_tunnel_tso_set_result *res = parsed_result;
3882 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3885 if (!strcmp(res->mode, "set"))
3886 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
3888 if (ports[res->port_id].tunnel_tso_segsz == 0)
3889 printf("TSO for tunneled packets is disabled\n");
3891 printf("TSO segment size for tunneled packets is %d\n",
3892 ports[res->port_id].tunnel_tso_segsz);
3894 /* Below conditions are needed to make it work:
3895 * (1) tunnel TSO is supported by the NIC;
3896 * (2) "csum parse_tunnel" must be set so that tunneled pkts
3898 * (3) for tunneled pkts with outer L3 of IPv4,
3899 * "csum set outer-ip" must be set to hw, because after tso,
3900 * total_len of outer IP header is changed, and the checksum
3901 * of outer IP header calculated by sw should be wrong; that
3902 * is not necessary for IPv6 tunneled pkts because there's no
3903 * checksum in IP header anymore.
3905 check_tunnel_tso_nic_support(res->port_id);
3907 if (!(ports[res->port_id].tx_ol_flags &
3908 TESTPMD_TX_OFFLOAD_PARSE_TUNNEL))
3909 printf("Warning: csum parse_tunnel must be set "
3910 "so that tunneled packets are recognized\n");
3911 if (!(ports[res->port_id].tx_ol_flags &
3912 TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM))
3913 printf("Warning: csum set outer-ip must be set to hw "
3914 "if outer L3 is IPv4; not necessary for IPv6\n");
3918 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
3919 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
3921 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
3922 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
3924 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
3925 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
3927 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
3928 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
3931 cmdline_parse_inst_t cmd_tunnel_tso_set = {
3932 .f = cmd_tunnel_tso_set_parsed,
3934 .help_str = "tunnel_tso set <tso_segsz> <port_id>: "
3935 "Set TSO segment size of tunneled packets for csum engine "
3938 (void *)&cmd_tunnel_tso_set_tso,
3939 (void *)&cmd_tunnel_tso_set_mode,
3940 (void *)&cmd_tunnel_tso_set_tso_segsz,
3941 (void *)&cmd_tunnel_tso_set_portid,
3946 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
3947 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
3951 cmdline_parse_inst_t cmd_tunnel_tso_show = {
3952 .f = cmd_tunnel_tso_set_parsed,
3954 .help_str = "tunnel_tso show <port_id> "
3955 "Show TSO segment size of tunneled packets for csum engine",
3957 (void *)&cmd_tunnel_tso_set_tso,
3958 (void *)&cmd_tunnel_tso_show_mode,
3959 (void *)&cmd_tunnel_tso_set_portid,
3964 /* *** SET GRO FOR A PORT *** */
3965 struct cmd_gro_enable_result {
3966 cmdline_fixed_string_t cmd_set;
3967 cmdline_fixed_string_t cmd_port;
3968 cmdline_fixed_string_t cmd_keyword;
3969 cmdline_fixed_string_t cmd_onoff;
3974 cmd_gro_enable_parsed(void *parsed_result,
3975 __attribute__((unused)) struct cmdline *cl,
3976 __attribute__((unused)) void *data)
3978 struct cmd_gro_enable_result *res;
3980 res = parsed_result;
3981 if (!strcmp(res->cmd_keyword, "gro"))
3982 setup_gro(res->cmd_onoff, res->cmd_pid);
3985 cmdline_parse_token_string_t cmd_gro_enable_set =
3986 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
3988 cmdline_parse_token_string_t cmd_gro_enable_port =
3989 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
3990 cmd_keyword, "port");
3991 cmdline_parse_token_num_t cmd_gro_enable_pid =
3992 TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result,
3994 cmdline_parse_token_string_t cmd_gro_enable_keyword =
3995 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
3996 cmd_keyword, "gro");
3997 cmdline_parse_token_string_t cmd_gro_enable_onoff =
3998 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
3999 cmd_onoff, "on#off");
4001 cmdline_parse_inst_t cmd_gro_enable = {
4002 .f = cmd_gro_enable_parsed,
4004 .help_str = "set port <port_id> gro on|off",
4006 (void *)&cmd_gro_enable_set,
4007 (void *)&cmd_gro_enable_port,
4008 (void *)&cmd_gro_enable_pid,
4009 (void *)&cmd_gro_enable_keyword,
4010 (void *)&cmd_gro_enable_onoff,
4015 /* *** DISPLAY GRO CONFIGURATION *** */
4016 struct cmd_gro_show_result {
4017 cmdline_fixed_string_t cmd_show;
4018 cmdline_fixed_string_t cmd_port;
4019 cmdline_fixed_string_t cmd_keyword;
4024 cmd_gro_show_parsed(void *parsed_result,
4025 __attribute__((unused)) struct cmdline *cl,
4026 __attribute__((unused)) void *data)
4028 struct cmd_gro_show_result *res;
4030 res = parsed_result;
4031 if (!strcmp(res->cmd_keyword, "gro"))
4032 show_gro(res->cmd_pid);
4035 cmdline_parse_token_string_t cmd_gro_show_show =
4036 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4038 cmdline_parse_token_string_t cmd_gro_show_port =
4039 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4041 cmdline_parse_token_num_t cmd_gro_show_pid =
4042 TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result,
4044 cmdline_parse_token_string_t cmd_gro_show_keyword =
4045 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4046 cmd_keyword, "gro");
4048 cmdline_parse_inst_t cmd_gro_show = {
4049 .f = cmd_gro_show_parsed,
4051 .help_str = "show port <port_id> gro",
4053 (void *)&cmd_gro_show_show,
4054 (void *)&cmd_gro_show_port,
4055 (void *)&cmd_gro_show_pid,
4056 (void *)&cmd_gro_show_keyword,
4061 /* *** SET FLUSH CYCLES FOR GRO *** */
4062 struct cmd_gro_flush_result {
4063 cmdline_fixed_string_t cmd_set;
4064 cmdline_fixed_string_t cmd_keyword;
4065 cmdline_fixed_string_t cmd_flush;
4070 cmd_gro_flush_parsed(void *parsed_result,
4071 __attribute__((unused)) struct cmdline *cl,
4072 __attribute__((unused)) void *data)
4074 struct cmd_gro_flush_result *res;
4076 res = parsed_result;
4077 if ((!strcmp(res->cmd_keyword, "gro")) &&
4078 (!strcmp(res->cmd_flush, "flush")))
4079 setup_gro_flush_cycles(res->cmd_cycles);
4082 cmdline_parse_token_string_t cmd_gro_flush_set =
4083 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4085 cmdline_parse_token_string_t cmd_gro_flush_keyword =
4086 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4087 cmd_keyword, "gro");
4088 cmdline_parse_token_string_t cmd_gro_flush_flush =
4089 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4090 cmd_flush, "flush");
4091 cmdline_parse_token_num_t cmd_gro_flush_cycles =
4092 TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result,
4095 cmdline_parse_inst_t cmd_gro_flush = {
4096 .f = cmd_gro_flush_parsed,
4098 .help_str = "set gro flush <cycles>",
4100 (void *)&cmd_gro_flush_set,
4101 (void *)&cmd_gro_flush_keyword,
4102 (void *)&cmd_gro_flush_flush,
4103 (void *)&cmd_gro_flush_cycles,
4108 /* *** ENABLE/DISABLE GSO *** */
4109 struct cmd_gso_enable_result {
4110 cmdline_fixed_string_t cmd_set;
4111 cmdline_fixed_string_t cmd_port;
4112 cmdline_fixed_string_t cmd_keyword;
4113 cmdline_fixed_string_t cmd_mode;
4118 cmd_gso_enable_parsed(void *parsed_result,
4119 __attribute__((unused)) struct cmdline *cl,
4120 __attribute__((unused)) void *data)
4122 struct cmd_gso_enable_result *res;
4124 res = parsed_result;
4125 if (!strcmp(res->cmd_keyword, "gso"))
4126 setup_gso(res->cmd_mode, res->cmd_pid);
4129 cmdline_parse_token_string_t cmd_gso_enable_set =
4130 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4132 cmdline_parse_token_string_t cmd_gso_enable_port =
4133 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4135 cmdline_parse_token_string_t cmd_gso_enable_keyword =
4136 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4137 cmd_keyword, "gso");
4138 cmdline_parse_token_string_t cmd_gso_enable_mode =
4139 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4140 cmd_mode, "on#off");
4141 cmdline_parse_token_num_t cmd_gso_enable_pid =
4142 TOKEN_NUM_INITIALIZER(struct cmd_gso_enable_result,
4145 cmdline_parse_inst_t cmd_gso_enable = {
4146 .f = cmd_gso_enable_parsed,
4148 .help_str = "set port <port_id> gso on|off",
4150 (void *)&cmd_gso_enable_set,
4151 (void *)&cmd_gso_enable_port,
4152 (void *)&cmd_gso_enable_pid,
4153 (void *)&cmd_gso_enable_keyword,
4154 (void *)&cmd_gso_enable_mode,
4159 /* *** SET MAX PACKET LENGTH FOR GSO SEGMENTS *** */
4160 struct cmd_gso_size_result {
4161 cmdline_fixed_string_t cmd_set;
4162 cmdline_fixed_string_t cmd_keyword;
4163 cmdline_fixed_string_t cmd_segsz;
4168 cmd_gso_size_parsed(void *parsed_result,
4169 __attribute__((unused)) struct cmdline *cl,
4170 __attribute__((unused)) void *data)
4172 struct cmd_gso_size_result *res = parsed_result;
4174 if (test_done == 0) {
4175 printf("Before setting GSO segsz, please first"
4176 " stop fowarding\n");
4180 if (!strcmp(res->cmd_keyword, "gso") &&
4181 !strcmp(res->cmd_segsz, "segsz")) {
4182 if (res->cmd_size < RTE_GSO_SEG_SIZE_MIN)
4183 printf("gso_size should be larger than %zu."
4184 " Please input a legal value\n",
4185 RTE_GSO_SEG_SIZE_MIN);
4187 gso_max_segment_size = res->cmd_size;
4191 cmdline_parse_token_string_t cmd_gso_size_set =
4192 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
4194 cmdline_parse_token_string_t cmd_gso_size_keyword =
4195 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
4196 cmd_keyword, "gso");
4197 cmdline_parse_token_string_t cmd_gso_size_segsz =
4198 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
4199 cmd_segsz, "segsz");
4200 cmdline_parse_token_num_t cmd_gso_size_size =
4201 TOKEN_NUM_INITIALIZER(struct cmd_gso_size_result,
4204 cmdline_parse_inst_t cmd_gso_size = {
4205 .f = cmd_gso_size_parsed,
4207 .help_str = "set gso segsz <length>",
4209 (void *)&cmd_gso_size_set,
4210 (void *)&cmd_gso_size_keyword,
4211 (void *)&cmd_gso_size_segsz,
4212 (void *)&cmd_gso_size_size,
4217 /* *** SHOW GSO CONFIGURATION *** */
4218 struct cmd_gso_show_result {
4219 cmdline_fixed_string_t cmd_show;
4220 cmdline_fixed_string_t cmd_port;
4221 cmdline_fixed_string_t cmd_keyword;
4226 cmd_gso_show_parsed(void *parsed_result,
4227 __attribute__((unused)) struct cmdline *cl,
4228 __attribute__((unused)) void *data)
4230 struct cmd_gso_show_result *res = parsed_result;
4232 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
4233 printf("invalid port id %u\n", res->cmd_pid);
4236 if (!strcmp(res->cmd_keyword, "gso")) {
4237 if (gso_ports[res->cmd_pid].enable) {
4238 printf("Max GSO'd packet size: %uB\n"
4239 "Supported GSO types: TCP/IPv4, "
4240 "VxLAN with inner TCP/IPv4 packet, "
4241 "GRE with inner TCP/IPv4 packet\n",
4242 gso_max_segment_size);
4244 printf("GSO is not enabled on Port %u\n", res->cmd_pid);
4248 cmdline_parse_token_string_t cmd_gso_show_show =
4249 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
4251 cmdline_parse_token_string_t cmd_gso_show_port =
4252 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
4254 cmdline_parse_token_string_t cmd_gso_show_keyword =
4255 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
4256 cmd_keyword, "gso");
4257 cmdline_parse_token_num_t cmd_gso_show_pid =
4258 TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result,
4261 cmdline_parse_inst_t cmd_gso_show = {
4262 .f = cmd_gso_show_parsed,
4264 .help_str = "show port <port_id> gso",
4266 (void *)&cmd_gso_show_show,
4267 (void *)&cmd_gso_show_port,
4268 (void *)&cmd_gso_show_pid,
4269 (void *)&cmd_gso_show_keyword,
4274 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
4275 struct cmd_set_flush_rx {
4276 cmdline_fixed_string_t set;
4277 cmdline_fixed_string_t flush_rx;
4278 cmdline_fixed_string_t mode;
4282 cmd_set_flush_rx_parsed(void *parsed_result,
4283 __attribute__((unused)) struct cmdline *cl,
4284 __attribute__((unused)) void *data)
4286 struct cmd_set_flush_rx *res = parsed_result;
4287 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
4290 cmdline_parse_token_string_t cmd_setflushrx_set =
4291 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
4293 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
4294 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
4295 flush_rx, "flush_rx");
4296 cmdline_parse_token_string_t cmd_setflushrx_mode =
4297 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
4301 cmdline_parse_inst_t cmd_set_flush_rx = {
4302 .f = cmd_set_flush_rx_parsed,
4303 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
4306 (void *)&cmd_setflushrx_set,
4307 (void *)&cmd_setflushrx_flush_rx,
4308 (void *)&cmd_setflushrx_mode,
4313 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
4314 struct cmd_set_link_check {
4315 cmdline_fixed_string_t set;
4316 cmdline_fixed_string_t link_check;
4317 cmdline_fixed_string_t mode;
4321 cmd_set_link_check_parsed(void *parsed_result,
4322 __attribute__((unused)) struct cmdline *cl,
4323 __attribute__((unused)) void *data)
4325 struct cmd_set_link_check *res = parsed_result;
4326 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
4329 cmdline_parse_token_string_t cmd_setlinkcheck_set =
4330 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
4332 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
4333 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
4334 link_check, "link_check");
4335 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
4336 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
4340 cmdline_parse_inst_t cmd_set_link_check = {
4341 .f = cmd_set_link_check_parsed,
4342 .help_str = "set link_check on|off: Enable/Disable link status check "
4343 "when starting/stopping a port",
4346 (void *)&cmd_setlinkcheck_set,
4347 (void *)&cmd_setlinkcheck_link_check,
4348 (void *)&cmd_setlinkcheck_mode,
4353 /* *** SET NIC BYPASS MODE *** */
4354 struct cmd_set_bypass_mode_result {
4355 cmdline_fixed_string_t set;
4356 cmdline_fixed_string_t bypass;
4357 cmdline_fixed_string_t mode;
4358 cmdline_fixed_string_t value;
4363 cmd_set_bypass_mode_parsed(void *parsed_result,
4364 __attribute__((unused)) struct cmdline *cl,
4365 __attribute__((unused)) void *data)
4367 struct cmd_set_bypass_mode_result *res = parsed_result;
4368 portid_t port_id = res->port_id;
4369 int32_t rc = -EINVAL;
4371 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4372 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4374 if (!strcmp(res->value, "bypass"))
4375 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
4376 else if (!strcmp(res->value, "isolate"))
4377 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
4379 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4381 /* Set the bypass mode for the relevant port. */
4382 rc = rte_pmd_ixgbe_bypass_state_set(port_id, &bypass_mode);
4385 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
4388 cmdline_parse_token_string_t cmd_setbypass_mode_set =
4389 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4391 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
4392 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4394 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
4395 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4397 cmdline_parse_token_string_t cmd_setbypass_mode_value =
4398 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4399 value, "normal#bypass#isolate");
4400 cmdline_parse_token_num_t cmd_setbypass_mode_port =
4401 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
4404 cmdline_parse_inst_t cmd_set_bypass_mode = {
4405 .f = cmd_set_bypass_mode_parsed,
4406 .help_str = "set bypass mode normal|bypass|isolate <port_id>: "
4407 "Set the NIC bypass mode for port_id",
4410 (void *)&cmd_setbypass_mode_set,
4411 (void *)&cmd_setbypass_mode_bypass,
4412 (void *)&cmd_setbypass_mode_mode,
4413 (void *)&cmd_setbypass_mode_value,
4414 (void *)&cmd_setbypass_mode_port,
4419 /* *** SET NIC BYPASS EVENT *** */
4420 struct cmd_set_bypass_event_result {
4421 cmdline_fixed_string_t set;
4422 cmdline_fixed_string_t bypass;
4423 cmdline_fixed_string_t event;
4424 cmdline_fixed_string_t event_value;
4425 cmdline_fixed_string_t mode;
4426 cmdline_fixed_string_t mode_value;
4431 cmd_set_bypass_event_parsed(void *parsed_result,
4432 __attribute__((unused)) struct cmdline *cl,
4433 __attribute__((unused)) void *data)
4435 int32_t rc = -EINVAL;
4436 struct cmd_set_bypass_event_result *res = parsed_result;
4437 portid_t port_id = res->port_id;
4439 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4440 uint32_t bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
4441 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4443 if (!strcmp(res->event_value, "timeout"))
4444 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT;
4445 else if (!strcmp(res->event_value, "os_on"))
4446 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_ON;
4447 else if (!strcmp(res->event_value, "os_off"))
4448 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_OFF;
4449 else if (!strcmp(res->event_value, "power_on"))
4450 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_ON;
4451 else if (!strcmp(res->event_value, "power_off"))
4452 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_OFF;
4454 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
4456 if (!strcmp(res->mode_value, "bypass"))
4457 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
4458 else if (!strcmp(res->mode_value, "isolate"))
4459 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
4461 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4463 /* Set the watchdog timeout. */
4464 if (bypass_event == RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT) {
4467 if (RTE_PMD_IXGBE_BYPASS_TMT_VALID(bypass_timeout)) {
4468 rc = rte_pmd_ixgbe_bypass_wd_timeout_store(port_id,
4472 printf("Failed to set timeout value %u "
4473 "for port %d, errto code: %d.\n",
4474 bypass_timeout, port_id, rc);
4478 /* Set the bypass event to transition to bypass mode. */
4479 rc = rte_pmd_ixgbe_bypass_event_store(port_id, bypass_event,
4484 printf("\t Failed to set bypass event for port = %d.\n",
4488 cmdline_parse_token_string_t cmd_setbypass_event_set =
4489 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4491 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
4492 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4494 cmdline_parse_token_string_t cmd_setbypass_event_event =
4495 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4497 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
4498 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4499 event_value, "none#timeout#os_off#os_on#power_on#power_off");
4500 cmdline_parse_token_string_t cmd_setbypass_event_mode =
4501 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4503 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
4504 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4505 mode_value, "normal#bypass#isolate");
4506 cmdline_parse_token_num_t cmd_setbypass_event_port =
4507 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
4510 cmdline_parse_inst_t cmd_set_bypass_event = {
4511 .f = cmd_set_bypass_event_parsed,
4512 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
4513 "power_off mode normal|bypass|isolate <port_id>: "
4514 "Set the NIC bypass event mode for port_id",
4517 (void *)&cmd_setbypass_event_set,
4518 (void *)&cmd_setbypass_event_bypass,
4519 (void *)&cmd_setbypass_event_event,
4520 (void *)&cmd_setbypass_event_event_value,
4521 (void *)&cmd_setbypass_event_mode,
4522 (void *)&cmd_setbypass_event_mode_value,
4523 (void *)&cmd_setbypass_event_port,
4529 /* *** SET NIC BYPASS TIMEOUT *** */
4530 struct cmd_set_bypass_timeout_result {
4531 cmdline_fixed_string_t set;
4532 cmdline_fixed_string_t bypass;
4533 cmdline_fixed_string_t timeout;
4534 cmdline_fixed_string_t value;
4538 cmd_set_bypass_timeout_parsed(void *parsed_result,
4539 __attribute__((unused)) struct cmdline *cl,
4540 __attribute__((unused)) void *data)
4542 __rte_unused struct cmd_set_bypass_timeout_result *res = parsed_result;
4544 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4545 if (!strcmp(res->value, "1.5"))
4546 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_1_5_SEC;
4547 else if (!strcmp(res->value, "2"))
4548 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_2_SEC;
4549 else if (!strcmp(res->value, "3"))
4550 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_3_SEC;
4551 else if (!strcmp(res->value, "4"))
4552 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_4_SEC;
4553 else if (!strcmp(res->value, "8"))
4554 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_8_SEC;
4555 else if (!strcmp(res->value, "16"))
4556 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_16_SEC;
4557 else if (!strcmp(res->value, "32"))
4558 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_32_SEC;
4560 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
4564 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
4565 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4567 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
4568 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4570 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
4571 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4572 timeout, "timeout");
4573 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
4574 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4575 value, "0#1.5#2#3#4#8#16#32");
4577 cmdline_parse_inst_t cmd_set_bypass_timeout = {
4578 .f = cmd_set_bypass_timeout_parsed,
4579 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
4580 "Set the NIC bypass watchdog timeout in seconds",
4583 (void *)&cmd_setbypass_timeout_set,
4584 (void *)&cmd_setbypass_timeout_bypass,
4585 (void *)&cmd_setbypass_timeout_timeout,
4586 (void *)&cmd_setbypass_timeout_value,
4591 /* *** SHOW NIC BYPASS MODE *** */
4592 struct cmd_show_bypass_config_result {
4593 cmdline_fixed_string_t show;
4594 cmdline_fixed_string_t bypass;
4595 cmdline_fixed_string_t config;
4600 cmd_show_bypass_config_parsed(void *parsed_result,
4601 __attribute__((unused)) struct cmdline *cl,
4602 __attribute__((unused)) void *data)
4604 struct cmd_show_bypass_config_result *res = parsed_result;
4605 portid_t port_id = res->port_id;
4607 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4608 uint32_t event_mode;
4609 uint32_t bypass_mode;
4610 uint32_t timeout = bypass_timeout;
4613 static const char * const timeouts[RTE_PMD_IXGBE_BYPASS_TMT_NUM] =
4614 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
4615 static const char * const modes[RTE_PMD_IXGBE_BYPASS_MODE_NUM] =
4616 {"UNKNOWN", "normal", "bypass", "isolate"};
4617 static const char * const events[RTE_PMD_IXGBE_BYPASS_EVENT_NUM] = {
4624 int num_events = (sizeof events) / (sizeof events[0]);
4626 /* Display the bypass mode.*/
4627 if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) != 0) {
4628 printf("\tFailed to get bypass mode for port = %d\n", port_id);
4632 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(bypass_mode))
4633 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
4635 printf("\tbypass mode = %s\n", modes[bypass_mode]);
4638 /* Display the bypass timeout.*/
4639 if (!RTE_PMD_IXGBE_BYPASS_TMT_VALID(timeout))
4640 timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
4642 printf("\tbypass timeout = %s\n", timeouts[timeout]);
4644 /* Display the bypass events and associated modes. */
4645 for (i = RTE_PMD_IXGBE_BYPASS_EVENT_START; i < num_events; i++) {
4647 if (rte_pmd_ixgbe_bypass_event_show(port_id, i, &event_mode)) {
4648 printf("\tFailed to get bypass mode for event = %s\n",
4651 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(event_mode))
4652 event_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
4654 printf("\tbypass event: %-16s = %s\n", events[i],
4660 printf("\tFailed to get bypass configuration for port = %d\n",
4664 cmdline_parse_token_string_t cmd_showbypass_config_show =
4665 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4667 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
4668 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4670 cmdline_parse_token_string_t cmd_showbypass_config_config =
4671 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4673 cmdline_parse_token_num_t cmd_showbypass_config_port =
4674 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
4677 cmdline_parse_inst_t cmd_show_bypass_config = {
4678 .f = cmd_show_bypass_config_parsed,
4679 .help_str = "show bypass config <port_id>: "
4680 "Show the NIC bypass config for port_id",
4683 (void *)&cmd_showbypass_config_show,
4684 (void *)&cmd_showbypass_config_bypass,
4685 (void *)&cmd_showbypass_config_config,
4686 (void *)&cmd_showbypass_config_port,
4691 #ifdef RTE_LIBRTE_PMD_BOND
4692 /* *** SET BONDING MODE *** */
4693 struct cmd_set_bonding_mode_result {
4694 cmdline_fixed_string_t set;
4695 cmdline_fixed_string_t bonding;
4696 cmdline_fixed_string_t mode;
4701 static void cmd_set_bonding_mode_parsed(void *parsed_result,
4702 __attribute__((unused)) struct cmdline *cl,
4703 __attribute__((unused)) void *data)
4705 struct cmd_set_bonding_mode_result *res = parsed_result;
4706 portid_t port_id = res->port_id;
4708 /* Set the bonding mode for the relevant port. */
4709 if (0 != rte_eth_bond_mode_set(port_id, res->value))
4710 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
4713 cmdline_parse_token_string_t cmd_setbonding_mode_set =
4714 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4716 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
4717 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4718 bonding, "bonding");
4719 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
4720 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4722 cmdline_parse_token_num_t cmd_setbonding_mode_value =
4723 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
4725 cmdline_parse_token_num_t cmd_setbonding_mode_port =
4726 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
4729 cmdline_parse_inst_t cmd_set_bonding_mode = {
4730 .f = cmd_set_bonding_mode_parsed,
4731 .help_str = "set bonding mode <mode_value> <port_id>: "
4732 "Set the bonding mode for port_id",
4735 (void *) &cmd_setbonding_mode_set,
4736 (void *) &cmd_setbonding_mode_bonding,
4737 (void *) &cmd_setbonding_mode_mode,
4738 (void *) &cmd_setbonding_mode_value,
4739 (void *) &cmd_setbonding_mode_port,
4744 /* *** SET BONDING SLOW_QUEUE SW/HW *** */
4745 struct cmd_set_bonding_lacp_dedicated_queues_result {
4746 cmdline_fixed_string_t set;
4747 cmdline_fixed_string_t bonding;
4748 cmdline_fixed_string_t lacp;
4749 cmdline_fixed_string_t dedicated_queues;
4751 cmdline_fixed_string_t mode;
4754 static void cmd_set_bonding_lacp_dedicated_queues_parsed(void *parsed_result,
4755 __attribute__((unused)) struct cmdline *cl,
4756 __attribute__((unused)) void *data)
4758 struct cmd_set_bonding_lacp_dedicated_queues_result *res = parsed_result;
4759 portid_t port_id = res->port_id;
4760 struct rte_port *port;
4762 port = &ports[port_id];
4764 /** Check if the port is not started **/
4765 if (port->port_status != RTE_PORT_STOPPED) {
4766 printf("Please stop port %d first\n", port_id);
4770 if (!strcmp(res->mode, "enable")) {
4771 if (rte_eth_bond_8023ad_dedicated_queues_enable(port_id) == 0)
4772 printf("Dedicate queues for LACP control packets"
4775 printf("Enabling dedicate queues for LACP control "
4776 "packets on port %d failed\n", port_id);
4777 } else if (!strcmp(res->mode, "disable")) {
4778 if (rte_eth_bond_8023ad_dedicated_queues_disable(port_id) == 0)
4779 printf("Dedicated queues for LACP control packets "
4782 printf("Disabling dedicated queues for LACP control "
4783 "traffic on port %d failed\n", port_id);
4787 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_set =
4788 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4790 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_bonding =
4791 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4792 bonding, "bonding");
4793 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_lacp =
4794 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4796 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_dedicated_queues =
4797 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4798 dedicated_queues, "dedicated_queues");
4799 cmdline_parse_token_num_t cmd_setbonding_lacp_dedicated_queues_port_id =
4800 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4802 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_mode =
4803 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4804 mode, "enable#disable");
4806 cmdline_parse_inst_t cmd_set_lacp_dedicated_queues = {
4807 .f = cmd_set_bonding_lacp_dedicated_queues_parsed,
4808 .help_str = "set bonding lacp dedicated_queues <port_id> "
4810 "Enable/disable dedicated queues for LACP control traffic for port_id",
4813 (void *)&cmd_setbonding_lacp_dedicated_queues_set,
4814 (void *)&cmd_setbonding_lacp_dedicated_queues_bonding,
4815 (void *)&cmd_setbonding_lacp_dedicated_queues_lacp,
4816 (void *)&cmd_setbonding_lacp_dedicated_queues_dedicated_queues,
4817 (void *)&cmd_setbonding_lacp_dedicated_queues_port_id,
4818 (void *)&cmd_setbonding_lacp_dedicated_queues_mode,
4823 /* *** SET BALANCE XMIT POLICY *** */
4824 struct cmd_set_bonding_balance_xmit_policy_result {
4825 cmdline_fixed_string_t set;
4826 cmdline_fixed_string_t bonding;
4827 cmdline_fixed_string_t balance_xmit_policy;
4829 cmdline_fixed_string_t policy;
4832 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
4833 __attribute__((unused)) struct cmdline *cl,
4834 __attribute__((unused)) void *data)
4836 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
4837 portid_t port_id = res->port_id;
4840 if (!strcmp(res->policy, "l2")) {
4841 policy = BALANCE_XMIT_POLICY_LAYER2;
4842 } else if (!strcmp(res->policy, "l23")) {
4843 policy = BALANCE_XMIT_POLICY_LAYER23;
4844 } else if (!strcmp(res->policy, "l34")) {
4845 policy = BALANCE_XMIT_POLICY_LAYER34;
4847 printf("\t Invalid xmit policy selection");
4851 /* Set the bonding mode for the relevant port. */
4852 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
4853 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
4858 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
4859 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4861 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
4862 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4863 bonding, "bonding");
4864 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
4865 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4866 balance_xmit_policy, "balance_xmit_policy");
4867 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
4868 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4870 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
4871 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4872 policy, "l2#l23#l34");
4874 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
4875 .f = cmd_set_bonding_balance_xmit_policy_parsed,
4876 .help_str = "set bonding balance_xmit_policy <port_id> "
4878 "Set the bonding balance_xmit_policy for port_id",
4881 (void *)&cmd_setbonding_balance_xmit_policy_set,
4882 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
4883 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
4884 (void *)&cmd_setbonding_balance_xmit_policy_port,
4885 (void *)&cmd_setbonding_balance_xmit_policy_policy,
4890 /* *** SHOW NIC BONDING CONFIGURATION *** */
4891 struct cmd_show_bonding_config_result {
4892 cmdline_fixed_string_t show;
4893 cmdline_fixed_string_t bonding;
4894 cmdline_fixed_string_t config;
4898 static void cmd_show_bonding_config_parsed(void *parsed_result,
4899 __attribute__((unused)) struct cmdline *cl,
4900 __attribute__((unused)) void *data)
4902 struct cmd_show_bonding_config_result *res = parsed_result;
4903 int bonding_mode, agg_mode;
4904 portid_t slaves[RTE_MAX_ETHPORTS];
4905 int num_slaves, num_active_slaves;
4908 portid_t port_id = res->port_id;
4910 /* Display the bonding mode.*/
4911 bonding_mode = rte_eth_bond_mode_get(port_id);
4912 if (bonding_mode < 0) {
4913 printf("\tFailed to get bonding mode for port = %d\n", port_id);
4916 printf("\tBonding mode: %d\n", bonding_mode);
4918 if (bonding_mode == BONDING_MODE_BALANCE) {
4919 int balance_xmit_policy;
4921 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
4922 if (balance_xmit_policy < 0) {
4923 printf("\tFailed to get balance xmit policy for port = %d\n",
4927 printf("\tBalance Xmit Policy: ");
4929 switch (balance_xmit_policy) {
4930 case BALANCE_XMIT_POLICY_LAYER2:
4931 printf("BALANCE_XMIT_POLICY_LAYER2");
4933 case BALANCE_XMIT_POLICY_LAYER23:
4934 printf("BALANCE_XMIT_POLICY_LAYER23");
4936 case BALANCE_XMIT_POLICY_LAYER34:
4937 printf("BALANCE_XMIT_POLICY_LAYER34");
4944 if (bonding_mode == BONDING_MODE_8023AD) {
4945 agg_mode = rte_eth_bond_8023ad_agg_selection_get(port_id);
4946 printf("\tIEEE802.3AD Aggregator Mode: ");
4949 printf("bandwidth");
4961 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
4963 if (num_slaves < 0) {
4964 printf("\tFailed to get slave list for port = %d\n", port_id);
4967 if (num_slaves > 0) {
4968 printf("\tSlaves (%d): [", num_slaves);
4969 for (i = 0; i < num_slaves - 1; i++)
4970 printf("%d ", slaves[i]);
4972 printf("%d]\n", slaves[num_slaves - 1]);
4974 printf("\tSlaves: []\n");
4978 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
4981 if (num_active_slaves < 0) {
4982 printf("\tFailed to get active slave list for port = %d\n", port_id);
4985 if (num_active_slaves > 0) {
4986 printf("\tActive Slaves (%d): [", num_active_slaves);
4987 for (i = 0; i < num_active_slaves - 1; i++)
4988 printf("%d ", slaves[i]);
4990 printf("%d]\n", slaves[num_active_slaves - 1]);
4993 printf("\tActive Slaves: []\n");
4997 primary_id = rte_eth_bond_primary_get(port_id);
4998 if (primary_id < 0) {
4999 printf("\tFailed to get primary slave for port = %d\n", port_id);
5002 printf("\tPrimary: [%d]\n", primary_id);
5006 cmdline_parse_token_string_t cmd_showbonding_config_show =
5007 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5009 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
5010 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5011 bonding, "bonding");
5012 cmdline_parse_token_string_t cmd_showbonding_config_config =
5013 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5015 cmdline_parse_token_num_t cmd_showbonding_config_port =
5016 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
5019 cmdline_parse_inst_t cmd_show_bonding_config = {
5020 .f = cmd_show_bonding_config_parsed,
5021 .help_str = "show bonding config <port_id>: "
5022 "Show the bonding config for port_id",
5025 (void *)&cmd_showbonding_config_show,
5026 (void *)&cmd_showbonding_config_bonding,
5027 (void *)&cmd_showbonding_config_config,
5028 (void *)&cmd_showbonding_config_port,
5033 /* *** SET BONDING PRIMARY *** */
5034 struct cmd_set_bonding_primary_result {
5035 cmdline_fixed_string_t set;
5036 cmdline_fixed_string_t bonding;
5037 cmdline_fixed_string_t primary;
5042 static void cmd_set_bonding_primary_parsed(void *parsed_result,
5043 __attribute__((unused)) struct cmdline *cl,
5044 __attribute__((unused)) void *data)
5046 struct cmd_set_bonding_primary_result *res = parsed_result;
5047 portid_t master_port_id = res->port_id;
5048 portid_t slave_port_id = res->slave_id;
5050 /* Set the primary slave for a bonded device. */
5051 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
5052 printf("\t Failed to set primary slave for port = %d.\n",
5059 cmdline_parse_token_string_t cmd_setbonding_primary_set =
5060 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5062 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
5063 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5064 bonding, "bonding");
5065 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
5066 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5067 primary, "primary");
5068 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
5069 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
5071 cmdline_parse_token_num_t cmd_setbonding_primary_port =
5072 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
5075 cmdline_parse_inst_t cmd_set_bonding_primary = {
5076 .f = cmd_set_bonding_primary_parsed,
5077 .help_str = "set bonding primary <slave_id> <port_id>: "
5078 "Set the primary slave for port_id",
5081 (void *)&cmd_setbonding_primary_set,
5082 (void *)&cmd_setbonding_primary_bonding,
5083 (void *)&cmd_setbonding_primary_primary,
5084 (void *)&cmd_setbonding_primary_slave,
5085 (void *)&cmd_setbonding_primary_port,
5090 /* *** ADD SLAVE *** */
5091 struct cmd_add_bonding_slave_result {
5092 cmdline_fixed_string_t add;
5093 cmdline_fixed_string_t bonding;
5094 cmdline_fixed_string_t slave;
5099 static void cmd_add_bonding_slave_parsed(void *parsed_result,
5100 __attribute__((unused)) struct cmdline *cl,
5101 __attribute__((unused)) void *data)
5103 struct cmd_add_bonding_slave_result *res = parsed_result;
5104 portid_t master_port_id = res->port_id;
5105 portid_t slave_port_id = res->slave_id;
5107 /* add the slave for a bonded device. */
5108 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
5109 printf("\t Failed to add slave %d to master port = %d.\n",
5110 slave_port_id, master_port_id);
5114 set_port_slave_flag(slave_port_id);
5117 cmdline_parse_token_string_t cmd_addbonding_slave_add =
5118 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5120 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
5121 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5122 bonding, "bonding");
5123 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
5124 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5126 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
5127 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
5129 cmdline_parse_token_num_t cmd_addbonding_slave_port =
5130 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
5133 cmdline_parse_inst_t cmd_add_bonding_slave = {
5134 .f = cmd_add_bonding_slave_parsed,
5135 .help_str = "add bonding slave <slave_id> <port_id>: "
5136 "Add a slave device to a bonded device",
5139 (void *)&cmd_addbonding_slave_add,
5140 (void *)&cmd_addbonding_slave_bonding,
5141 (void *)&cmd_addbonding_slave_slave,
5142 (void *)&cmd_addbonding_slave_slaveid,
5143 (void *)&cmd_addbonding_slave_port,
5148 /* *** REMOVE SLAVE *** */
5149 struct cmd_remove_bonding_slave_result {
5150 cmdline_fixed_string_t remove;
5151 cmdline_fixed_string_t bonding;
5152 cmdline_fixed_string_t slave;
5157 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
5158 __attribute__((unused)) struct cmdline *cl,
5159 __attribute__((unused)) void *data)
5161 struct cmd_remove_bonding_slave_result *res = parsed_result;
5162 portid_t master_port_id = res->port_id;
5163 portid_t slave_port_id = res->slave_id;
5165 /* remove the slave from a bonded device. */
5166 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
5167 printf("\t Failed to remove slave %d from master port = %d.\n",
5168 slave_port_id, master_port_id);
5172 clear_port_slave_flag(slave_port_id);
5175 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
5176 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
5178 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
5179 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
5180 bonding, "bonding");
5181 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
5182 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
5184 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
5185 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
5187 cmdline_parse_token_num_t cmd_removebonding_slave_port =
5188 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
5191 cmdline_parse_inst_t cmd_remove_bonding_slave = {
5192 .f = cmd_remove_bonding_slave_parsed,
5193 .help_str = "remove bonding slave <slave_id> <port_id>: "
5194 "Remove a slave device from a bonded device",
5197 (void *)&cmd_removebonding_slave_remove,
5198 (void *)&cmd_removebonding_slave_bonding,
5199 (void *)&cmd_removebonding_slave_slave,
5200 (void *)&cmd_removebonding_slave_slaveid,
5201 (void *)&cmd_removebonding_slave_port,
5206 /* *** CREATE BONDED DEVICE *** */
5207 struct cmd_create_bonded_device_result {
5208 cmdline_fixed_string_t create;
5209 cmdline_fixed_string_t bonded;
5210 cmdline_fixed_string_t device;
5215 static int bond_dev_num = 0;
5217 static void cmd_create_bonded_device_parsed(void *parsed_result,
5218 __attribute__((unused)) struct cmdline *cl,
5219 __attribute__((unused)) void *data)
5221 struct cmd_create_bonded_device_result *res = parsed_result;
5222 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
5225 if (test_done == 0) {
5226 printf("Please stop forwarding first\n");
5230 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bonding_testpmd_%d",
5233 /* Create a new bonded device. */
5234 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
5236 printf("\t Failed to create bonded device.\n");
5239 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
5242 /* Update number of ports */
5243 nb_ports = rte_eth_dev_count();
5244 reconfig(port_id, res->socket);
5245 rte_eth_promiscuous_enable(port_id);
5250 cmdline_parse_token_string_t cmd_createbonded_device_create =
5251 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
5253 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
5254 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
5256 cmdline_parse_token_string_t cmd_createbonded_device_device =
5257 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
5259 cmdline_parse_token_num_t cmd_createbonded_device_mode =
5260 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
5262 cmdline_parse_token_num_t cmd_createbonded_device_socket =
5263 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
5266 cmdline_parse_inst_t cmd_create_bonded_device = {
5267 .f = cmd_create_bonded_device_parsed,
5268 .help_str = "create bonded device <mode> <socket>: "
5269 "Create a new bonded device with specific bonding mode and socket",
5272 (void *)&cmd_createbonded_device_create,
5273 (void *)&cmd_createbonded_device_bonded,
5274 (void *)&cmd_createbonded_device_device,
5275 (void *)&cmd_createbonded_device_mode,
5276 (void *)&cmd_createbonded_device_socket,
5281 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
5282 struct cmd_set_bond_mac_addr_result {
5283 cmdline_fixed_string_t set;
5284 cmdline_fixed_string_t bonding;
5285 cmdline_fixed_string_t mac_addr;
5287 struct ether_addr address;
5290 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
5291 __attribute__((unused)) struct cmdline *cl,
5292 __attribute__((unused)) void *data)
5294 struct cmd_set_bond_mac_addr_result *res = parsed_result;
5297 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
5300 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
5302 /* check the return value and print it if is < 0 */
5304 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
5307 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
5308 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
5309 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
5310 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
5312 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
5313 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
5315 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
5316 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result,
5318 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
5319 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
5321 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
5322 .f = cmd_set_bond_mac_addr_parsed,
5324 .help_str = "set bonding mac_addr <port_id> <mac_addr>",
5326 (void *)&cmd_set_bond_mac_addr_set,
5327 (void *)&cmd_set_bond_mac_addr_bonding,
5328 (void *)&cmd_set_bond_mac_addr_mac,
5329 (void *)&cmd_set_bond_mac_addr_portnum,
5330 (void *)&cmd_set_bond_mac_addr_addr,
5336 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
5337 struct cmd_set_bond_mon_period_result {
5338 cmdline_fixed_string_t set;
5339 cmdline_fixed_string_t bonding;
5340 cmdline_fixed_string_t mon_period;
5345 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
5346 __attribute__((unused)) struct cmdline *cl,
5347 __attribute__((unused)) void *data)
5349 struct cmd_set_bond_mon_period_result *res = parsed_result;
5352 if (res->port_num >= nb_ports) {
5353 printf("Port id %d must be less than %d\n", res->port_num, nb_ports);
5357 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
5359 /* check the return value and print it if is < 0 */
5361 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
5364 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
5365 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
5367 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
5368 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
5369 bonding, "bonding");
5370 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
5371 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
5372 mon_period, "mon_period");
5373 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
5374 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
5376 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
5377 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
5380 cmdline_parse_inst_t cmd_set_bond_mon_period = {
5381 .f = cmd_set_bond_mon_period_parsed,
5383 .help_str = "set bonding mon_period <port_id> <period_ms>",
5385 (void *)&cmd_set_bond_mon_period_set,
5386 (void *)&cmd_set_bond_mon_period_bonding,
5387 (void *)&cmd_set_bond_mon_period_mon_period,
5388 (void *)&cmd_set_bond_mon_period_portnum,
5389 (void *)&cmd_set_bond_mon_period_period_ms,
5396 struct cmd_set_bonding_agg_mode_policy_result {
5397 cmdline_fixed_string_t set;
5398 cmdline_fixed_string_t bonding;
5399 cmdline_fixed_string_t agg_mode;
5401 cmdline_fixed_string_t policy;
5406 cmd_set_bonding_agg_mode(void *parsed_result,
5407 __attribute__((unused)) struct cmdline *cl,
5408 __attribute__((unused)) void *data)
5410 struct cmd_set_bonding_agg_mode_policy_result *res = parsed_result;
5411 uint8_t policy = AGG_BANDWIDTH;
5413 if (res->port_num >= nb_ports) {
5414 printf("Port id %d must be less than %d\n",
5415 res->port_num, nb_ports);
5419 if (!strcmp(res->policy, "bandwidth"))
5420 policy = AGG_BANDWIDTH;
5421 else if (!strcmp(res->policy, "stable"))
5422 policy = AGG_STABLE;
5423 else if (!strcmp(res->policy, "count"))
5426 rte_eth_bond_8023ad_agg_selection_set(res->port_num, policy);
5430 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_set =
5431 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5433 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_bonding =
5434 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5435 bonding, "bonding");
5437 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_agg_mode =
5438 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5439 agg_mode, "agg_mode");
5441 cmdline_parse_token_num_t cmd_set_bonding_agg_mode_portnum =
5442 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5445 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_policy_string =
5446 TOKEN_STRING_INITIALIZER(
5447 struct cmd_set_bonding_balance_xmit_policy_result,
5448 policy, "stable#bandwidth#count");
5450 cmdline_parse_inst_t cmd_set_bonding_agg_mode_policy = {
5451 .f = cmd_set_bonding_agg_mode,
5453 .help_str = "set bonding mode IEEE802.3AD aggregator policy <port_id> <agg_name>",
5455 (void *)&cmd_set_bonding_agg_mode_set,
5456 (void *)&cmd_set_bonding_agg_mode_bonding,
5457 (void *)&cmd_set_bonding_agg_mode_agg_mode,
5458 (void *)&cmd_set_bonding_agg_mode_portnum,
5459 (void *)&cmd_set_bonding_agg_mode_policy_string,
5465 #endif /* RTE_LIBRTE_PMD_BOND */
5467 /* *** SET FORWARDING MODE *** */
5468 struct cmd_set_fwd_mode_result {
5469 cmdline_fixed_string_t set;
5470 cmdline_fixed_string_t fwd;
5471 cmdline_fixed_string_t mode;
5474 static void cmd_set_fwd_mode_parsed(void *parsed_result,
5475 __attribute__((unused)) struct cmdline *cl,
5476 __attribute__((unused)) void *data)
5478 struct cmd_set_fwd_mode_result *res = parsed_result;
5481 set_pkt_forwarding_mode(res->mode);
5484 cmdline_parse_token_string_t cmd_setfwd_set =
5485 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
5486 cmdline_parse_token_string_t cmd_setfwd_fwd =
5487 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
5488 cmdline_parse_token_string_t cmd_setfwd_mode =
5489 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
5490 "" /* defined at init */);
5492 cmdline_parse_inst_t cmd_set_fwd_mode = {
5493 .f = cmd_set_fwd_mode_parsed,
5495 .help_str = NULL, /* defined at init */
5497 (void *)&cmd_setfwd_set,
5498 (void *)&cmd_setfwd_fwd,
5499 (void *)&cmd_setfwd_mode,
5504 static void cmd_set_fwd_mode_init(void)
5507 static char token[128];
5508 static char help[256];
5509 cmdline_parse_token_string_t *token_struct;
5511 modes = list_pkt_forwarding_modes();
5512 snprintf(help, sizeof(help), "set fwd %s: "
5513 "Set packet forwarding mode", modes);
5514 cmd_set_fwd_mode.help_str = help;
5516 /* string token separator is # */
5517 for (c = token; *modes != '\0'; modes++)
5522 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
5523 token_struct->string_data.str = token;
5526 /* *** SET RETRY FORWARDING MODE *** */
5527 struct cmd_set_fwd_retry_mode_result {
5528 cmdline_fixed_string_t set;
5529 cmdline_fixed_string_t fwd;
5530 cmdline_fixed_string_t mode;
5531 cmdline_fixed_string_t retry;
5534 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
5535 __attribute__((unused)) struct cmdline *cl,
5536 __attribute__((unused)) void *data)
5538 struct cmd_set_fwd_retry_mode_result *res = parsed_result;
5541 set_pkt_forwarding_mode(res->mode);
5544 cmdline_parse_token_string_t cmd_setfwd_retry_set =
5545 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
5547 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
5548 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
5550 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
5551 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
5553 "" /* defined at init */);
5554 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
5555 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
5558 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
5559 .f = cmd_set_fwd_retry_mode_parsed,
5561 .help_str = NULL, /* defined at init */
5563 (void *)&cmd_setfwd_retry_set,
5564 (void *)&cmd_setfwd_retry_fwd,
5565 (void *)&cmd_setfwd_retry_mode,
5566 (void *)&cmd_setfwd_retry_retry,
5571 static void cmd_set_fwd_retry_mode_init(void)
5574 static char token[128];
5575 static char help[256];
5576 cmdline_parse_token_string_t *token_struct;
5578 modes = list_pkt_forwarding_retry_modes();
5579 snprintf(help, sizeof(help), "set fwd %s retry: "
5580 "Set packet forwarding mode with retry", modes);
5581 cmd_set_fwd_retry_mode.help_str = help;
5583 /* string token separator is # */
5584 for (c = token; *modes != '\0'; modes++)
5589 token_struct = (cmdline_parse_token_string_t *)
5590 cmd_set_fwd_retry_mode.tokens[2];
5591 token_struct->string_data.str = token;
5594 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
5595 struct cmd_set_burst_tx_retry_result {
5596 cmdline_fixed_string_t set;
5597 cmdline_fixed_string_t burst;
5598 cmdline_fixed_string_t tx;
5599 cmdline_fixed_string_t delay;
5601 cmdline_fixed_string_t retry;
5605 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
5606 __attribute__((unused)) struct cmdline *cl,
5607 __attribute__((unused)) void *data)
5609 struct cmd_set_burst_tx_retry_result *res = parsed_result;
5611 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
5612 && !strcmp(res->tx, "tx")) {
5613 if (!strcmp(res->delay, "delay"))
5614 burst_tx_delay_time = res->time;
5615 if (!strcmp(res->retry, "retry"))
5616 burst_tx_retry_num = res->retry_num;
5621 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
5622 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
5623 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
5624 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
5626 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
5627 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
5628 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
5629 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
5630 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
5631 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
5632 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
5633 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
5634 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
5635 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
5637 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
5638 .f = cmd_set_burst_tx_retry_parsed,
5639 .help_str = "set burst tx delay <delay_usec> retry <num_retry>",
5641 (void *)&cmd_set_burst_tx_retry_set,
5642 (void *)&cmd_set_burst_tx_retry_burst,
5643 (void *)&cmd_set_burst_tx_retry_tx,
5644 (void *)&cmd_set_burst_tx_retry_delay,
5645 (void *)&cmd_set_burst_tx_retry_time,
5646 (void *)&cmd_set_burst_tx_retry_retry,
5647 (void *)&cmd_set_burst_tx_retry_retry_num,
5652 /* *** SET PROMISC MODE *** */
5653 struct cmd_set_promisc_mode_result {
5654 cmdline_fixed_string_t set;
5655 cmdline_fixed_string_t promisc;
5656 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
5657 uint16_t port_num; /* valid if "allports" argument == 0 */
5658 cmdline_fixed_string_t mode;
5661 static void cmd_set_promisc_mode_parsed(void *parsed_result,
5662 __attribute__((unused)) struct cmdline *cl,
5665 struct cmd_set_promisc_mode_result *res = parsed_result;
5669 if (!strcmp(res->mode, "on"))
5676 RTE_ETH_FOREACH_DEV(i) {
5678 rte_eth_promiscuous_enable(i);
5680 rte_eth_promiscuous_disable(i);
5685 rte_eth_promiscuous_enable(res->port_num);
5687 rte_eth_promiscuous_disable(res->port_num);
5691 cmdline_parse_token_string_t cmd_setpromisc_set =
5692 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
5693 cmdline_parse_token_string_t cmd_setpromisc_promisc =
5694 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
5696 cmdline_parse_token_string_t cmd_setpromisc_portall =
5697 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
5699 cmdline_parse_token_num_t cmd_setpromisc_portnum =
5700 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
5702 cmdline_parse_token_string_t cmd_setpromisc_mode =
5703 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
5706 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
5707 .f = cmd_set_promisc_mode_parsed,
5709 .help_str = "set promisc all on|off: Set promisc mode for all ports",
5711 (void *)&cmd_setpromisc_set,
5712 (void *)&cmd_setpromisc_promisc,
5713 (void *)&cmd_setpromisc_portall,
5714 (void *)&cmd_setpromisc_mode,
5719 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
5720 .f = cmd_set_promisc_mode_parsed,
5722 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
5724 (void *)&cmd_setpromisc_set,
5725 (void *)&cmd_setpromisc_promisc,
5726 (void *)&cmd_setpromisc_portnum,
5727 (void *)&cmd_setpromisc_mode,
5732 /* *** SET ALLMULTI MODE *** */
5733 struct cmd_set_allmulti_mode_result {
5734 cmdline_fixed_string_t set;
5735 cmdline_fixed_string_t allmulti;
5736 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
5737 uint16_t port_num; /* valid if "allports" argument == 0 */
5738 cmdline_fixed_string_t mode;
5741 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
5742 __attribute__((unused)) struct cmdline *cl,
5745 struct cmd_set_allmulti_mode_result *res = parsed_result;
5749 if (!strcmp(res->mode, "on"))
5756 RTE_ETH_FOREACH_DEV(i) {
5758 rte_eth_allmulticast_enable(i);
5760 rte_eth_allmulticast_disable(i);
5765 rte_eth_allmulticast_enable(res->port_num);
5767 rte_eth_allmulticast_disable(res->port_num);
5771 cmdline_parse_token_string_t cmd_setallmulti_set =
5772 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
5773 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
5774 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
5776 cmdline_parse_token_string_t cmd_setallmulti_portall =
5777 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
5779 cmdline_parse_token_num_t cmd_setallmulti_portnum =
5780 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
5782 cmdline_parse_token_string_t cmd_setallmulti_mode =
5783 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
5786 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
5787 .f = cmd_set_allmulti_mode_parsed,
5789 .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
5791 (void *)&cmd_setallmulti_set,
5792 (void *)&cmd_setallmulti_allmulti,
5793 (void *)&cmd_setallmulti_portall,
5794 (void *)&cmd_setallmulti_mode,
5799 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
5800 .f = cmd_set_allmulti_mode_parsed,
5802 .help_str = "set allmulti <port_id> on|off: "
5803 "Set allmulti mode on port_id",
5805 (void *)&cmd_setallmulti_set,
5806 (void *)&cmd_setallmulti_allmulti,
5807 (void *)&cmd_setallmulti_portnum,
5808 (void *)&cmd_setallmulti_mode,
5813 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
5814 struct cmd_link_flow_ctrl_set_result {
5815 cmdline_fixed_string_t set;
5816 cmdline_fixed_string_t flow_ctrl;
5817 cmdline_fixed_string_t rx;
5818 cmdline_fixed_string_t rx_lfc_mode;
5819 cmdline_fixed_string_t tx;
5820 cmdline_fixed_string_t tx_lfc_mode;
5821 cmdline_fixed_string_t mac_ctrl_frame_fwd;
5822 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
5823 cmdline_fixed_string_t autoneg_str;
5824 cmdline_fixed_string_t autoneg;
5825 cmdline_fixed_string_t hw_str;
5826 uint32_t high_water;
5827 cmdline_fixed_string_t lw_str;
5829 cmdline_fixed_string_t pt_str;
5830 uint16_t pause_time;
5831 cmdline_fixed_string_t xon_str;
5836 cmdline_parse_token_string_t cmd_lfc_set_set =
5837 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5839 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
5840 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5841 flow_ctrl, "flow_ctrl");
5842 cmdline_parse_token_string_t cmd_lfc_set_rx =
5843 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5845 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
5846 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5847 rx_lfc_mode, "on#off");
5848 cmdline_parse_token_string_t cmd_lfc_set_tx =
5849 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5851 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
5852 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5853 tx_lfc_mode, "on#off");
5854 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
5855 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5856 hw_str, "high_water");
5857 cmdline_parse_token_num_t cmd_lfc_set_high_water =
5858 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5859 high_water, UINT32);
5860 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
5861 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5862 lw_str, "low_water");
5863 cmdline_parse_token_num_t cmd_lfc_set_low_water =
5864 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5866 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
5867 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5868 pt_str, "pause_time");
5869 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
5870 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5871 pause_time, UINT16);
5872 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
5873 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5874 xon_str, "send_xon");
5875 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
5876 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5878 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
5879 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5880 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
5881 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
5882 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5883 mac_ctrl_frame_fwd_mode, "on#off");
5884 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
5885 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5886 autoneg_str, "autoneg");
5887 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
5888 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5890 cmdline_parse_token_num_t cmd_lfc_set_portid =
5891 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5894 /* forward declaration */
5896 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
5899 cmdline_parse_inst_t cmd_link_flow_control_set = {
5900 .f = cmd_link_flow_ctrl_set_parsed,
5902 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
5903 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
5904 "autoneg on|off <port_id>: Configure the Ethernet flow control",
5906 (void *)&cmd_lfc_set_set,
5907 (void *)&cmd_lfc_set_flow_ctrl,
5908 (void *)&cmd_lfc_set_rx,
5909 (void *)&cmd_lfc_set_rx_mode,
5910 (void *)&cmd_lfc_set_tx,
5911 (void *)&cmd_lfc_set_tx_mode,
5912 (void *)&cmd_lfc_set_high_water,
5913 (void *)&cmd_lfc_set_low_water,
5914 (void *)&cmd_lfc_set_pause_time,
5915 (void *)&cmd_lfc_set_send_xon,
5916 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
5917 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
5918 (void *)&cmd_lfc_set_autoneg_str,
5919 (void *)&cmd_lfc_set_autoneg,
5920 (void *)&cmd_lfc_set_portid,
5925 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
5926 .f = cmd_link_flow_ctrl_set_parsed,
5927 .data = (void *)&cmd_link_flow_control_set_rx,
5928 .help_str = "set flow_ctrl rx on|off <port_id>: "
5929 "Change rx flow control parameter",
5931 (void *)&cmd_lfc_set_set,
5932 (void *)&cmd_lfc_set_flow_ctrl,
5933 (void *)&cmd_lfc_set_rx,
5934 (void *)&cmd_lfc_set_rx_mode,
5935 (void *)&cmd_lfc_set_portid,
5940 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
5941 .f = cmd_link_flow_ctrl_set_parsed,
5942 .data = (void *)&cmd_link_flow_control_set_tx,
5943 .help_str = "set flow_ctrl tx on|off <port_id>: "
5944 "Change tx flow control parameter",
5946 (void *)&cmd_lfc_set_set,
5947 (void *)&cmd_lfc_set_flow_ctrl,
5948 (void *)&cmd_lfc_set_tx,
5949 (void *)&cmd_lfc_set_tx_mode,
5950 (void *)&cmd_lfc_set_portid,
5955 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
5956 .f = cmd_link_flow_ctrl_set_parsed,
5957 .data = (void *)&cmd_link_flow_control_set_hw,
5958 .help_str = "set flow_ctrl high_water <value> <port_id>: "
5959 "Change high water flow control parameter",
5961 (void *)&cmd_lfc_set_set,
5962 (void *)&cmd_lfc_set_flow_ctrl,
5963 (void *)&cmd_lfc_set_high_water_str,
5964 (void *)&cmd_lfc_set_high_water,
5965 (void *)&cmd_lfc_set_portid,
5970 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
5971 .f = cmd_link_flow_ctrl_set_parsed,
5972 .data = (void *)&cmd_link_flow_control_set_lw,
5973 .help_str = "set flow_ctrl low_water <value> <port_id>: "
5974 "Change low water flow control parameter",
5976 (void *)&cmd_lfc_set_set,
5977 (void *)&cmd_lfc_set_flow_ctrl,
5978 (void *)&cmd_lfc_set_low_water_str,
5979 (void *)&cmd_lfc_set_low_water,
5980 (void *)&cmd_lfc_set_portid,
5985 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
5986 .f = cmd_link_flow_ctrl_set_parsed,
5987 .data = (void *)&cmd_link_flow_control_set_pt,
5988 .help_str = "set flow_ctrl pause_time <value> <port_id>: "
5989 "Change pause time flow control parameter",
5991 (void *)&cmd_lfc_set_set,
5992 (void *)&cmd_lfc_set_flow_ctrl,
5993 (void *)&cmd_lfc_set_pause_time_str,
5994 (void *)&cmd_lfc_set_pause_time,
5995 (void *)&cmd_lfc_set_portid,
6000 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
6001 .f = cmd_link_flow_ctrl_set_parsed,
6002 .data = (void *)&cmd_link_flow_control_set_xon,
6003 .help_str = "set flow_ctrl send_xon <value> <port_id>: "
6004 "Change send_xon flow control parameter",
6006 (void *)&cmd_lfc_set_set,
6007 (void *)&cmd_lfc_set_flow_ctrl,
6008 (void *)&cmd_lfc_set_send_xon_str,
6009 (void *)&cmd_lfc_set_send_xon,
6010 (void *)&cmd_lfc_set_portid,
6015 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
6016 .f = cmd_link_flow_ctrl_set_parsed,
6017 .data = (void *)&cmd_link_flow_control_set_macfwd,
6018 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
6019 "Change mac ctrl fwd flow control parameter",
6021 (void *)&cmd_lfc_set_set,
6022 (void *)&cmd_lfc_set_flow_ctrl,
6023 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6024 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6025 (void *)&cmd_lfc_set_portid,
6030 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
6031 .f = cmd_link_flow_ctrl_set_parsed,
6032 .data = (void *)&cmd_link_flow_control_set_autoneg,
6033 .help_str = "set flow_ctrl autoneg on|off <port_id>: "
6034 "Change autoneg flow control parameter",
6036 (void *)&cmd_lfc_set_set,
6037 (void *)&cmd_lfc_set_flow_ctrl,
6038 (void *)&cmd_lfc_set_autoneg_str,
6039 (void *)&cmd_lfc_set_autoneg,
6040 (void *)&cmd_lfc_set_portid,
6046 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
6047 __attribute__((unused)) struct cmdline *cl,
6050 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
6051 cmdline_parse_inst_t *cmd = data;
6052 struct rte_eth_fc_conf fc_conf;
6058 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
6059 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
6060 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
6061 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
6063 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
6064 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
6067 /* Partial command line, retrieve current configuration */
6069 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
6071 printf("cannot get current flow ctrl parameters, return"
6072 "code = %d\n", ret);
6076 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
6077 (fc_conf.mode == RTE_FC_FULL))
6079 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
6080 (fc_conf.mode == RTE_FC_FULL))
6084 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
6085 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
6087 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
6088 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
6090 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
6092 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
6093 fc_conf.high_water = res->high_water;
6095 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
6096 fc_conf.low_water = res->low_water;
6098 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
6099 fc_conf.pause_time = res->pause_time;
6101 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
6102 fc_conf.send_xon = res->send_xon;
6104 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
6105 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
6106 fc_conf.mac_ctrl_frame_fwd = 1;
6108 fc_conf.mac_ctrl_frame_fwd = 0;
6111 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
6112 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
6114 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
6116 printf("bad flow contrl parameter, return code = %d \n", ret);
6119 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
6120 struct cmd_priority_flow_ctrl_set_result {
6121 cmdline_fixed_string_t set;
6122 cmdline_fixed_string_t pfc_ctrl;
6123 cmdline_fixed_string_t rx;
6124 cmdline_fixed_string_t rx_pfc_mode;
6125 cmdline_fixed_string_t tx;
6126 cmdline_fixed_string_t tx_pfc_mode;
6127 uint32_t high_water;
6129 uint16_t pause_time;
6135 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
6136 __attribute__((unused)) struct cmdline *cl,
6137 __attribute__((unused)) void *data)
6139 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
6140 struct rte_eth_pfc_conf pfc_conf;
6141 int rx_fc_enable, tx_fc_enable;
6145 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
6146 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
6147 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
6148 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
6150 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
6151 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
6154 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
6155 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
6156 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
6157 pfc_conf.fc.high_water = res->high_water;
6158 pfc_conf.fc.low_water = res->low_water;
6159 pfc_conf.fc.pause_time = res->pause_time;
6160 pfc_conf.priority = res->priority;
6162 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
6164 printf("bad priority flow contrl parameter, return code = %d \n", ret);
6167 cmdline_parse_token_string_t cmd_pfc_set_set =
6168 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6170 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
6171 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6172 pfc_ctrl, "pfc_ctrl");
6173 cmdline_parse_token_string_t cmd_pfc_set_rx =
6174 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6176 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
6177 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6178 rx_pfc_mode, "on#off");
6179 cmdline_parse_token_string_t cmd_pfc_set_tx =
6180 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6182 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
6183 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6184 tx_pfc_mode, "on#off");
6185 cmdline_parse_token_num_t cmd_pfc_set_high_water =
6186 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6187 high_water, UINT32);
6188 cmdline_parse_token_num_t cmd_pfc_set_low_water =
6189 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6191 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
6192 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6193 pause_time, UINT16);
6194 cmdline_parse_token_num_t cmd_pfc_set_priority =
6195 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6197 cmdline_parse_token_num_t cmd_pfc_set_portid =
6198 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6201 cmdline_parse_inst_t cmd_priority_flow_control_set = {
6202 .f = cmd_priority_flow_ctrl_set_parsed,
6204 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
6205 "<pause_time> <priority> <port_id>: "
6206 "Configure the Ethernet priority flow control",
6208 (void *)&cmd_pfc_set_set,
6209 (void *)&cmd_pfc_set_flow_ctrl,
6210 (void *)&cmd_pfc_set_rx,
6211 (void *)&cmd_pfc_set_rx_mode,
6212 (void *)&cmd_pfc_set_tx,
6213 (void *)&cmd_pfc_set_tx_mode,
6214 (void *)&cmd_pfc_set_high_water,
6215 (void *)&cmd_pfc_set_low_water,
6216 (void *)&cmd_pfc_set_pause_time,
6217 (void *)&cmd_pfc_set_priority,
6218 (void *)&cmd_pfc_set_portid,
6223 /* *** RESET CONFIGURATION *** */
6224 struct cmd_reset_result {
6225 cmdline_fixed_string_t reset;
6226 cmdline_fixed_string_t def;
6229 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
6231 __attribute__((unused)) void *data)
6233 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
6234 set_def_fwd_config();
6237 cmdline_parse_token_string_t cmd_reset_set =
6238 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
6239 cmdline_parse_token_string_t cmd_reset_def =
6240 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
6243 cmdline_parse_inst_t cmd_reset = {
6244 .f = cmd_reset_parsed,
6246 .help_str = "set default: Reset default forwarding configuration",
6248 (void *)&cmd_reset_set,
6249 (void *)&cmd_reset_def,
6254 /* *** START FORWARDING *** */
6255 struct cmd_start_result {
6256 cmdline_fixed_string_t start;
6259 cmdline_parse_token_string_t cmd_start_start =
6260 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
6262 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
6263 __attribute__((unused)) struct cmdline *cl,
6264 __attribute__((unused)) void *data)
6266 start_packet_forwarding(0);
6269 cmdline_parse_inst_t cmd_start = {
6270 .f = cmd_start_parsed,
6272 .help_str = "start: Start packet forwarding",
6274 (void *)&cmd_start_start,
6279 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
6280 struct cmd_start_tx_first_result {
6281 cmdline_fixed_string_t start;
6282 cmdline_fixed_string_t tx_first;
6286 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
6287 __attribute__((unused)) struct cmdline *cl,
6288 __attribute__((unused)) void *data)
6290 start_packet_forwarding(1);
6293 cmdline_parse_token_string_t cmd_start_tx_first_start =
6294 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
6296 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
6297 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
6298 tx_first, "tx_first");
6300 cmdline_parse_inst_t cmd_start_tx_first = {
6301 .f = cmd_start_tx_first_parsed,
6303 .help_str = "start tx_first: Start packet forwarding, "
6304 "after sending 1 burst of packets",
6306 (void *)&cmd_start_tx_first_start,
6307 (void *)&cmd_start_tx_first_tx_first,
6312 /* *** START FORWARDING WITH N TX BURST FIRST *** */
6313 struct cmd_start_tx_first_n_result {
6314 cmdline_fixed_string_t start;
6315 cmdline_fixed_string_t tx_first;
6320 cmd_start_tx_first_n_parsed(void *parsed_result,
6321 __attribute__((unused)) struct cmdline *cl,
6322 __attribute__((unused)) void *data)
6324 struct cmd_start_tx_first_n_result *res = parsed_result;
6326 start_packet_forwarding(res->tx_num);
6329 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
6330 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
6332 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
6333 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
6334 tx_first, "tx_first");
6335 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
6336 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
6339 cmdline_parse_inst_t cmd_start_tx_first_n = {
6340 .f = cmd_start_tx_first_n_parsed,
6342 .help_str = "start tx_first <num>: "
6343 "packet forwarding, after sending <num> bursts of packets",
6345 (void *)&cmd_start_tx_first_n_start,
6346 (void *)&cmd_start_tx_first_n_tx_first,
6347 (void *)&cmd_start_tx_first_n_tx_num,
6352 /* *** SET LINK UP *** */
6353 struct cmd_set_link_up_result {
6354 cmdline_fixed_string_t set;
6355 cmdline_fixed_string_t link_up;
6356 cmdline_fixed_string_t port;
6360 cmdline_parse_token_string_t cmd_set_link_up_set =
6361 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
6362 cmdline_parse_token_string_t cmd_set_link_up_link_up =
6363 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
6365 cmdline_parse_token_string_t cmd_set_link_up_port =
6366 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
6367 cmdline_parse_token_num_t cmd_set_link_up_port_id =
6368 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT16);
6370 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result,
6371 __attribute__((unused)) struct cmdline *cl,
6372 __attribute__((unused)) void *data)
6374 struct cmd_set_link_up_result *res = parsed_result;
6375 dev_set_link_up(res->port_id);
6378 cmdline_parse_inst_t cmd_set_link_up = {
6379 .f = cmd_set_link_up_parsed,
6381 .help_str = "set link-up port <port id>",
6383 (void *)&cmd_set_link_up_set,
6384 (void *)&cmd_set_link_up_link_up,
6385 (void *)&cmd_set_link_up_port,
6386 (void *)&cmd_set_link_up_port_id,
6391 /* *** SET LINK DOWN *** */
6392 struct cmd_set_link_down_result {
6393 cmdline_fixed_string_t set;
6394 cmdline_fixed_string_t link_down;
6395 cmdline_fixed_string_t port;
6399 cmdline_parse_token_string_t cmd_set_link_down_set =
6400 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
6401 cmdline_parse_token_string_t cmd_set_link_down_link_down =
6402 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
6404 cmdline_parse_token_string_t cmd_set_link_down_port =
6405 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
6406 cmdline_parse_token_num_t cmd_set_link_down_port_id =
6407 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT16);
6409 static void cmd_set_link_down_parsed(
6410 __attribute__((unused)) void *parsed_result,
6411 __attribute__((unused)) struct cmdline *cl,
6412 __attribute__((unused)) void *data)
6414 struct cmd_set_link_down_result *res = parsed_result;
6415 dev_set_link_down(res->port_id);
6418 cmdline_parse_inst_t cmd_set_link_down = {
6419 .f = cmd_set_link_down_parsed,
6421 .help_str = "set link-down port <port id>",
6423 (void *)&cmd_set_link_down_set,
6424 (void *)&cmd_set_link_down_link_down,
6425 (void *)&cmd_set_link_down_port,
6426 (void *)&cmd_set_link_down_port_id,
6431 /* *** SHOW CFG *** */
6432 struct cmd_showcfg_result {
6433 cmdline_fixed_string_t show;
6434 cmdline_fixed_string_t cfg;
6435 cmdline_fixed_string_t what;
6438 static void cmd_showcfg_parsed(void *parsed_result,
6439 __attribute__((unused)) struct cmdline *cl,
6440 __attribute__((unused)) void *data)
6442 struct cmd_showcfg_result *res = parsed_result;
6443 if (!strcmp(res->what, "rxtx"))
6444 rxtx_config_display();
6445 else if (!strcmp(res->what, "cores"))
6446 fwd_lcores_config_display();
6447 else if (!strcmp(res->what, "fwd"))
6448 pkt_fwd_config_display(&cur_fwd_config);
6449 else if (!strcmp(res->what, "txpkts"))
6450 show_tx_pkt_segments();
6453 cmdline_parse_token_string_t cmd_showcfg_show =
6454 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
6455 cmdline_parse_token_string_t cmd_showcfg_port =
6456 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
6457 cmdline_parse_token_string_t cmd_showcfg_what =
6458 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
6459 "rxtx#cores#fwd#txpkts");
6461 cmdline_parse_inst_t cmd_showcfg = {
6462 .f = cmd_showcfg_parsed,
6464 .help_str = "show config rxtx|cores|fwd|txpkts",
6466 (void *)&cmd_showcfg_show,
6467 (void *)&cmd_showcfg_port,
6468 (void *)&cmd_showcfg_what,
6473 /* *** SHOW ALL PORT INFO *** */
6474 struct cmd_showportall_result {
6475 cmdline_fixed_string_t show;
6476 cmdline_fixed_string_t port;
6477 cmdline_fixed_string_t what;
6478 cmdline_fixed_string_t all;
6481 static void cmd_showportall_parsed(void *parsed_result,
6482 __attribute__((unused)) struct cmdline *cl,
6483 __attribute__((unused)) void *data)
6487 struct cmd_showportall_result *res = parsed_result;
6488 if (!strcmp(res->show, "clear")) {
6489 if (!strcmp(res->what, "stats"))
6490 RTE_ETH_FOREACH_DEV(i)
6492 else if (!strcmp(res->what, "xstats"))
6493 RTE_ETH_FOREACH_DEV(i)
6494 nic_xstats_clear(i);
6495 } else if (!strcmp(res->what, "info"))
6496 RTE_ETH_FOREACH_DEV(i)
6497 port_infos_display(i);
6498 else if (!strcmp(res->what, "stats"))
6499 RTE_ETH_FOREACH_DEV(i)
6500 nic_stats_display(i);
6501 else if (!strcmp(res->what, "xstats"))
6502 RTE_ETH_FOREACH_DEV(i)
6503 nic_xstats_display(i);
6504 else if (!strcmp(res->what, "fdir"))
6505 RTE_ETH_FOREACH_DEV(i)
6507 else if (!strcmp(res->what, "stat_qmap"))
6508 RTE_ETH_FOREACH_DEV(i)
6509 nic_stats_mapping_display(i);
6510 else if (!strcmp(res->what, "dcb_tc"))
6511 RTE_ETH_FOREACH_DEV(i)
6512 port_dcb_info_display(i);
6513 else if (!strcmp(res->what, "cap"))
6514 RTE_ETH_FOREACH_DEV(i)
6515 port_offload_cap_display(i);
6518 cmdline_parse_token_string_t cmd_showportall_show =
6519 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
6521 cmdline_parse_token_string_t cmd_showportall_port =
6522 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
6523 cmdline_parse_token_string_t cmd_showportall_what =
6524 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
6525 "info#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
6526 cmdline_parse_token_string_t cmd_showportall_all =
6527 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
6528 cmdline_parse_inst_t cmd_showportall = {
6529 .f = cmd_showportall_parsed,
6531 .help_str = "show|clear port "
6532 "info|stats|xstats|fdir|stat_qmap|dcb_tc|cap all",
6534 (void *)&cmd_showportall_show,
6535 (void *)&cmd_showportall_port,
6536 (void *)&cmd_showportall_what,
6537 (void *)&cmd_showportall_all,
6542 /* *** SHOW PORT INFO *** */
6543 struct cmd_showport_result {
6544 cmdline_fixed_string_t show;
6545 cmdline_fixed_string_t port;
6546 cmdline_fixed_string_t what;
6550 static void cmd_showport_parsed(void *parsed_result,
6551 __attribute__((unused)) struct cmdline *cl,
6552 __attribute__((unused)) void *data)
6554 struct cmd_showport_result *res = parsed_result;
6555 if (!strcmp(res->show, "clear")) {
6556 if (!strcmp(res->what, "stats"))
6557 nic_stats_clear(res->portnum);
6558 else if (!strcmp(res->what, "xstats"))
6559 nic_xstats_clear(res->portnum);
6560 } else if (!strcmp(res->what, "info"))
6561 port_infos_display(res->portnum);
6562 else if (!strcmp(res->what, "stats"))
6563 nic_stats_display(res->portnum);
6564 else if (!strcmp(res->what, "xstats"))
6565 nic_xstats_display(res->portnum);
6566 else if (!strcmp(res->what, "fdir"))
6567 fdir_get_infos(res->portnum);
6568 else if (!strcmp(res->what, "stat_qmap"))
6569 nic_stats_mapping_display(res->portnum);
6570 else if (!strcmp(res->what, "dcb_tc"))
6571 port_dcb_info_display(res->portnum);
6572 else if (!strcmp(res->what, "cap"))
6573 port_offload_cap_display(res->portnum);
6576 cmdline_parse_token_string_t cmd_showport_show =
6577 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
6579 cmdline_parse_token_string_t cmd_showport_port =
6580 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
6581 cmdline_parse_token_string_t cmd_showport_what =
6582 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
6583 "info#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
6584 cmdline_parse_token_num_t cmd_showport_portnum =
6585 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT16);
6587 cmdline_parse_inst_t cmd_showport = {
6588 .f = cmd_showport_parsed,
6590 .help_str = "show|clear port "
6591 "info|stats|xstats|fdir|stat_qmap|dcb_tc|cap "
6594 (void *)&cmd_showport_show,
6595 (void *)&cmd_showport_port,
6596 (void *)&cmd_showport_what,
6597 (void *)&cmd_showport_portnum,
6602 /* *** SHOW QUEUE INFO *** */
6603 struct cmd_showqueue_result {
6604 cmdline_fixed_string_t show;
6605 cmdline_fixed_string_t type;
6606 cmdline_fixed_string_t what;
6612 cmd_showqueue_parsed(void *parsed_result,
6613 __attribute__((unused)) struct cmdline *cl,
6614 __attribute__((unused)) void *data)
6616 struct cmd_showqueue_result *res = parsed_result;
6618 if (!strcmp(res->type, "rxq"))
6619 rx_queue_infos_display(res->portnum, res->queuenum);
6620 else if (!strcmp(res->type, "txq"))
6621 tx_queue_infos_display(res->portnum, res->queuenum);
6624 cmdline_parse_token_string_t cmd_showqueue_show =
6625 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
6626 cmdline_parse_token_string_t cmd_showqueue_type =
6627 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
6628 cmdline_parse_token_string_t cmd_showqueue_what =
6629 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
6630 cmdline_parse_token_num_t cmd_showqueue_portnum =
6631 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, UINT16);
6632 cmdline_parse_token_num_t cmd_showqueue_queuenum =
6633 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, UINT16);
6635 cmdline_parse_inst_t cmd_showqueue = {
6636 .f = cmd_showqueue_parsed,
6638 .help_str = "show rxq|txq info <port_id> <queue_id>",
6640 (void *)&cmd_showqueue_show,
6641 (void *)&cmd_showqueue_type,
6642 (void *)&cmd_showqueue_what,
6643 (void *)&cmd_showqueue_portnum,
6644 (void *)&cmd_showqueue_queuenum,
6649 /* *** READ PORT REGISTER *** */
6650 struct cmd_read_reg_result {
6651 cmdline_fixed_string_t read;
6652 cmdline_fixed_string_t reg;
6658 cmd_read_reg_parsed(void *parsed_result,
6659 __attribute__((unused)) struct cmdline *cl,
6660 __attribute__((unused)) void *data)
6662 struct cmd_read_reg_result *res = parsed_result;
6663 port_reg_display(res->port_id, res->reg_off);
6666 cmdline_parse_token_string_t cmd_read_reg_read =
6667 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
6668 cmdline_parse_token_string_t cmd_read_reg_reg =
6669 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
6670 cmdline_parse_token_num_t cmd_read_reg_port_id =
6671 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT16);
6672 cmdline_parse_token_num_t cmd_read_reg_reg_off =
6673 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
6675 cmdline_parse_inst_t cmd_read_reg = {
6676 .f = cmd_read_reg_parsed,
6678 .help_str = "read reg <port_id> <reg_off>",
6680 (void *)&cmd_read_reg_read,
6681 (void *)&cmd_read_reg_reg,
6682 (void *)&cmd_read_reg_port_id,
6683 (void *)&cmd_read_reg_reg_off,
6688 /* *** READ PORT REGISTER BIT FIELD *** */
6689 struct cmd_read_reg_bit_field_result {
6690 cmdline_fixed_string_t read;
6691 cmdline_fixed_string_t regfield;
6699 cmd_read_reg_bit_field_parsed(void *parsed_result,
6700 __attribute__((unused)) struct cmdline *cl,
6701 __attribute__((unused)) void *data)
6703 struct cmd_read_reg_bit_field_result *res = parsed_result;
6704 port_reg_bit_field_display(res->port_id, res->reg_off,
6705 res->bit1_pos, res->bit2_pos);
6708 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
6709 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
6711 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
6712 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
6713 regfield, "regfield");
6714 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
6715 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
6717 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
6718 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
6720 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
6721 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
6723 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
6724 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
6727 cmdline_parse_inst_t cmd_read_reg_bit_field = {
6728 .f = cmd_read_reg_bit_field_parsed,
6730 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
6731 "Read register bit field between bit_x and bit_y included",
6733 (void *)&cmd_read_reg_bit_field_read,
6734 (void *)&cmd_read_reg_bit_field_regfield,
6735 (void *)&cmd_read_reg_bit_field_port_id,
6736 (void *)&cmd_read_reg_bit_field_reg_off,
6737 (void *)&cmd_read_reg_bit_field_bit1_pos,
6738 (void *)&cmd_read_reg_bit_field_bit2_pos,
6743 /* *** READ PORT REGISTER BIT *** */
6744 struct cmd_read_reg_bit_result {
6745 cmdline_fixed_string_t read;
6746 cmdline_fixed_string_t regbit;
6753 cmd_read_reg_bit_parsed(void *parsed_result,
6754 __attribute__((unused)) struct cmdline *cl,
6755 __attribute__((unused)) void *data)
6757 struct cmd_read_reg_bit_result *res = parsed_result;
6758 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
6761 cmdline_parse_token_string_t cmd_read_reg_bit_read =
6762 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
6763 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
6764 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
6766 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
6767 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT16);
6768 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
6769 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
6770 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
6771 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
6773 cmdline_parse_inst_t cmd_read_reg_bit = {
6774 .f = cmd_read_reg_bit_parsed,
6776 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
6778 (void *)&cmd_read_reg_bit_read,
6779 (void *)&cmd_read_reg_bit_regbit,
6780 (void *)&cmd_read_reg_bit_port_id,
6781 (void *)&cmd_read_reg_bit_reg_off,
6782 (void *)&cmd_read_reg_bit_bit_pos,
6787 /* *** WRITE PORT REGISTER *** */
6788 struct cmd_write_reg_result {
6789 cmdline_fixed_string_t write;
6790 cmdline_fixed_string_t reg;
6797 cmd_write_reg_parsed(void *parsed_result,
6798 __attribute__((unused)) struct cmdline *cl,
6799 __attribute__((unused)) void *data)
6801 struct cmd_write_reg_result *res = parsed_result;
6802 port_reg_set(res->port_id, res->reg_off, res->value);
6805 cmdline_parse_token_string_t cmd_write_reg_write =
6806 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
6807 cmdline_parse_token_string_t cmd_write_reg_reg =
6808 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
6809 cmdline_parse_token_num_t cmd_write_reg_port_id =
6810 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT16);
6811 cmdline_parse_token_num_t cmd_write_reg_reg_off =
6812 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
6813 cmdline_parse_token_num_t cmd_write_reg_value =
6814 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
6816 cmdline_parse_inst_t cmd_write_reg = {
6817 .f = cmd_write_reg_parsed,
6819 .help_str = "write reg <port_id> <reg_off> <reg_value>",
6821 (void *)&cmd_write_reg_write,
6822 (void *)&cmd_write_reg_reg,
6823 (void *)&cmd_write_reg_port_id,
6824 (void *)&cmd_write_reg_reg_off,
6825 (void *)&cmd_write_reg_value,
6830 /* *** WRITE PORT REGISTER BIT FIELD *** */
6831 struct cmd_write_reg_bit_field_result {
6832 cmdline_fixed_string_t write;
6833 cmdline_fixed_string_t regfield;
6842 cmd_write_reg_bit_field_parsed(void *parsed_result,
6843 __attribute__((unused)) struct cmdline *cl,
6844 __attribute__((unused)) void *data)
6846 struct cmd_write_reg_bit_field_result *res = parsed_result;
6847 port_reg_bit_field_set(res->port_id, res->reg_off,
6848 res->bit1_pos, res->bit2_pos, res->value);
6851 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
6852 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
6854 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
6855 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
6856 regfield, "regfield");
6857 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
6858 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
6860 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
6861 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
6863 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
6864 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
6866 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
6867 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
6869 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
6870 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
6873 cmdline_parse_inst_t cmd_write_reg_bit_field = {
6874 .f = cmd_write_reg_bit_field_parsed,
6876 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
6878 "Set register bit field between bit_x and bit_y included",
6880 (void *)&cmd_write_reg_bit_field_write,
6881 (void *)&cmd_write_reg_bit_field_regfield,
6882 (void *)&cmd_write_reg_bit_field_port_id,
6883 (void *)&cmd_write_reg_bit_field_reg_off,
6884 (void *)&cmd_write_reg_bit_field_bit1_pos,
6885 (void *)&cmd_write_reg_bit_field_bit2_pos,
6886 (void *)&cmd_write_reg_bit_field_value,
6891 /* *** WRITE PORT REGISTER BIT *** */
6892 struct cmd_write_reg_bit_result {
6893 cmdline_fixed_string_t write;
6894 cmdline_fixed_string_t regbit;
6902 cmd_write_reg_bit_parsed(void *parsed_result,
6903 __attribute__((unused)) struct cmdline *cl,
6904 __attribute__((unused)) void *data)
6906 struct cmd_write_reg_bit_result *res = parsed_result;
6907 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
6910 cmdline_parse_token_string_t cmd_write_reg_bit_write =
6911 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
6913 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
6914 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
6916 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
6917 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT16);
6918 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
6919 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
6920 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
6921 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
6922 cmdline_parse_token_num_t cmd_write_reg_bit_value =
6923 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
6925 cmdline_parse_inst_t cmd_write_reg_bit = {
6926 .f = cmd_write_reg_bit_parsed,
6928 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
6931 (void *)&cmd_write_reg_bit_write,
6932 (void *)&cmd_write_reg_bit_regbit,
6933 (void *)&cmd_write_reg_bit_port_id,
6934 (void *)&cmd_write_reg_bit_reg_off,
6935 (void *)&cmd_write_reg_bit_bit_pos,
6936 (void *)&cmd_write_reg_bit_value,
6941 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
6942 struct cmd_read_rxd_txd_result {
6943 cmdline_fixed_string_t read;
6944 cmdline_fixed_string_t rxd_txd;
6951 cmd_read_rxd_txd_parsed(void *parsed_result,
6952 __attribute__((unused)) struct cmdline *cl,
6953 __attribute__((unused)) void *data)
6955 struct cmd_read_rxd_txd_result *res = parsed_result;
6957 if (!strcmp(res->rxd_txd, "rxd"))
6958 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
6959 else if (!strcmp(res->rxd_txd, "txd"))
6960 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
6963 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
6964 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
6965 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
6966 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
6968 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
6969 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT16);
6970 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
6971 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
6972 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
6973 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
6975 cmdline_parse_inst_t cmd_read_rxd_txd = {
6976 .f = cmd_read_rxd_txd_parsed,
6978 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
6980 (void *)&cmd_read_rxd_txd_read,
6981 (void *)&cmd_read_rxd_txd_rxd_txd,
6982 (void *)&cmd_read_rxd_txd_port_id,
6983 (void *)&cmd_read_rxd_txd_queue_id,
6984 (void *)&cmd_read_rxd_txd_desc_id,
6990 struct cmd_quit_result {
6991 cmdline_fixed_string_t quit;
6994 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
6996 __attribute__((unused)) void *data)
7002 cmdline_parse_token_string_t cmd_quit_quit =
7003 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
7005 cmdline_parse_inst_t cmd_quit = {
7006 .f = cmd_quit_parsed,
7008 .help_str = "quit: Exit application",
7010 (void *)&cmd_quit_quit,
7015 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
7016 struct cmd_mac_addr_result {
7017 cmdline_fixed_string_t mac_addr_cmd;
7018 cmdline_fixed_string_t what;
7020 struct ether_addr address;
7023 static void cmd_mac_addr_parsed(void *parsed_result,
7024 __attribute__((unused)) struct cmdline *cl,
7025 __attribute__((unused)) void *data)
7027 struct cmd_mac_addr_result *res = parsed_result;
7030 if (strcmp(res->what, "add") == 0)
7031 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
7032 else if (strcmp(res->what, "set") == 0)
7033 ret = rte_eth_dev_default_mac_addr_set(res->port_num,
7036 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
7038 /* check the return value and print it if is < 0 */
7040 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
7044 cmdline_parse_token_string_t cmd_mac_addr_cmd =
7045 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
7047 cmdline_parse_token_string_t cmd_mac_addr_what =
7048 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
7050 cmdline_parse_token_num_t cmd_mac_addr_portnum =
7051 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num,
7053 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
7054 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
7056 cmdline_parse_inst_t cmd_mac_addr = {
7057 .f = cmd_mac_addr_parsed,
7059 .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
7060 "Add/Remove/Set MAC address on port_id",
7062 (void *)&cmd_mac_addr_cmd,
7063 (void *)&cmd_mac_addr_what,
7064 (void *)&cmd_mac_addr_portnum,
7065 (void *)&cmd_mac_addr_addr,
7071 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
7072 struct cmd_set_qmap_result {
7073 cmdline_fixed_string_t set;
7074 cmdline_fixed_string_t qmap;
7075 cmdline_fixed_string_t what;
7082 cmd_set_qmap_parsed(void *parsed_result,
7083 __attribute__((unused)) struct cmdline *cl,
7084 __attribute__((unused)) void *data)
7086 struct cmd_set_qmap_result *res = parsed_result;
7087 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
7089 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
7092 cmdline_parse_token_string_t cmd_setqmap_set =
7093 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7095 cmdline_parse_token_string_t cmd_setqmap_qmap =
7096 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7098 cmdline_parse_token_string_t cmd_setqmap_what =
7099 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7101 cmdline_parse_token_num_t cmd_setqmap_portid =
7102 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7104 cmdline_parse_token_num_t cmd_setqmap_queueid =
7105 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7107 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
7108 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7111 cmdline_parse_inst_t cmd_set_qmap = {
7112 .f = cmd_set_qmap_parsed,
7114 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
7115 "Set statistics mapping value on tx|rx queue_id of port_id",
7117 (void *)&cmd_setqmap_set,
7118 (void *)&cmd_setqmap_qmap,
7119 (void *)&cmd_setqmap_what,
7120 (void *)&cmd_setqmap_portid,
7121 (void *)&cmd_setqmap_queueid,
7122 (void *)&cmd_setqmap_mapvalue,
7127 /* *** CONFIGURE UNICAST HASH TABLE *** */
7128 struct cmd_set_uc_hash_table {
7129 cmdline_fixed_string_t set;
7130 cmdline_fixed_string_t port;
7132 cmdline_fixed_string_t what;
7133 struct ether_addr address;
7134 cmdline_fixed_string_t mode;
7138 cmd_set_uc_hash_parsed(void *parsed_result,
7139 __attribute__((unused)) struct cmdline *cl,
7140 __attribute__((unused)) void *data)
7143 struct cmd_set_uc_hash_table *res = parsed_result;
7145 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7147 if (strcmp(res->what, "uta") == 0)
7148 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
7149 &res->address,(uint8_t)is_on);
7151 printf("bad unicast hash table parameter, return code = %d \n", ret);
7155 cmdline_parse_token_string_t cmd_set_uc_hash_set =
7156 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7158 cmdline_parse_token_string_t cmd_set_uc_hash_port =
7159 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7161 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
7162 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
7164 cmdline_parse_token_string_t cmd_set_uc_hash_what =
7165 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7167 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
7168 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
7170 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
7171 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7174 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
7175 .f = cmd_set_uc_hash_parsed,
7177 .help_str = "set port <port_id> uta <mac_addr> on|off)",
7179 (void *)&cmd_set_uc_hash_set,
7180 (void *)&cmd_set_uc_hash_port,
7181 (void *)&cmd_set_uc_hash_portid,
7182 (void *)&cmd_set_uc_hash_what,
7183 (void *)&cmd_set_uc_hash_mac,
7184 (void *)&cmd_set_uc_hash_mode,
7189 struct cmd_set_uc_all_hash_table {
7190 cmdline_fixed_string_t set;
7191 cmdline_fixed_string_t port;
7193 cmdline_fixed_string_t what;
7194 cmdline_fixed_string_t value;
7195 cmdline_fixed_string_t mode;
7199 cmd_set_uc_all_hash_parsed(void *parsed_result,
7200 __attribute__((unused)) struct cmdline *cl,
7201 __attribute__((unused)) void *data)
7204 struct cmd_set_uc_all_hash_table *res = parsed_result;
7206 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7208 if ((strcmp(res->what, "uta") == 0) &&
7209 (strcmp(res->value, "all") == 0))
7210 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
7212 printf("bad unicast hash table parameter,"
7213 "return code = %d \n", ret);
7216 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
7217 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7219 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
7220 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7222 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
7223 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
7225 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
7226 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7228 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
7229 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7231 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
7232 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7235 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
7236 .f = cmd_set_uc_all_hash_parsed,
7238 .help_str = "set port <port_id> uta all on|off",
7240 (void *)&cmd_set_uc_all_hash_set,
7241 (void *)&cmd_set_uc_all_hash_port,
7242 (void *)&cmd_set_uc_all_hash_portid,
7243 (void *)&cmd_set_uc_all_hash_what,
7244 (void *)&cmd_set_uc_all_hash_value,
7245 (void *)&cmd_set_uc_all_hash_mode,
7250 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
7251 struct cmd_set_vf_macvlan_filter {
7252 cmdline_fixed_string_t set;
7253 cmdline_fixed_string_t port;
7255 cmdline_fixed_string_t vf;
7257 struct ether_addr address;
7258 cmdline_fixed_string_t filter_type;
7259 cmdline_fixed_string_t mode;
7263 cmd_set_vf_macvlan_parsed(void *parsed_result,
7264 __attribute__((unused)) struct cmdline *cl,
7265 __attribute__((unused)) void *data)
7268 struct cmd_set_vf_macvlan_filter *res = parsed_result;
7269 struct rte_eth_mac_filter filter;
7271 memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
7273 rte_memcpy(&filter.mac_addr, &res->address, ETHER_ADDR_LEN);
7275 /* set VF MAC filter */
7279 filter.dst_id = res->vf_id;
7281 if (!strcmp(res->filter_type, "exact-mac"))
7282 filter.filter_type = RTE_MAC_PERFECT_MATCH;
7283 else if (!strcmp(res->filter_type, "exact-mac-vlan"))
7284 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
7285 else if (!strcmp(res->filter_type, "hashmac"))
7286 filter.filter_type = RTE_MAC_HASH_MATCH;
7287 else if (!strcmp(res->filter_type, "hashmac-vlan"))
7288 filter.filter_type = RTE_MACVLAN_HASH_MATCH;
7290 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7293 ret = rte_eth_dev_filter_ctrl(res->port_id,
7294 RTE_ETH_FILTER_MACVLAN,
7298 ret = rte_eth_dev_filter_ctrl(res->port_id,
7299 RTE_ETH_FILTER_MACVLAN,
7300 RTE_ETH_FILTER_DELETE,
7304 printf("bad set MAC hash parameter, return code = %d\n", ret);
7308 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
7309 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7311 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
7312 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7314 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
7315 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7317 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
7318 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7320 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
7321 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7323 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
7324 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7326 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
7327 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7328 filter_type, "exact-mac#exact-mac-vlan"
7329 "#hashmac#hashmac-vlan");
7330 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
7331 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7334 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
7335 .f = cmd_set_vf_macvlan_parsed,
7337 .help_str = "set port <port_id> vf <vf_id> <mac_addr> "
7338 "exact-mac|exact-mac-vlan|hashmac|hashmac-vlan on|off: "
7339 "Exact match rule: exact match of MAC or MAC and VLAN; "
7340 "hash match rule: hash match of MAC and exact match of VLAN",
7342 (void *)&cmd_set_vf_macvlan_set,
7343 (void *)&cmd_set_vf_macvlan_port,
7344 (void *)&cmd_set_vf_macvlan_portid,
7345 (void *)&cmd_set_vf_macvlan_vf,
7346 (void *)&cmd_set_vf_macvlan_vf_id,
7347 (void *)&cmd_set_vf_macvlan_mac,
7348 (void *)&cmd_set_vf_macvlan_filter_type,
7349 (void *)&cmd_set_vf_macvlan_mode,
7354 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
7355 struct cmd_set_vf_traffic {
7356 cmdline_fixed_string_t set;
7357 cmdline_fixed_string_t port;
7359 cmdline_fixed_string_t vf;
7361 cmdline_fixed_string_t what;
7362 cmdline_fixed_string_t mode;
7366 cmd_set_vf_traffic_parsed(void *parsed_result,
7367 __attribute__((unused)) struct cmdline *cl,
7368 __attribute__((unused)) void *data)
7370 struct cmd_set_vf_traffic *res = parsed_result;
7371 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
7372 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7374 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
7377 cmdline_parse_token_string_t cmd_setvf_traffic_set =
7378 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7380 cmdline_parse_token_string_t cmd_setvf_traffic_port =
7381 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7383 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
7384 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
7386 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
7387 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7389 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
7390 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
7392 cmdline_parse_token_string_t cmd_setvf_traffic_what =
7393 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7395 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
7396 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7399 cmdline_parse_inst_t cmd_set_vf_traffic = {
7400 .f = cmd_set_vf_traffic_parsed,
7402 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
7404 (void *)&cmd_setvf_traffic_set,
7405 (void *)&cmd_setvf_traffic_port,
7406 (void *)&cmd_setvf_traffic_portid,
7407 (void *)&cmd_setvf_traffic_vf,
7408 (void *)&cmd_setvf_traffic_vfid,
7409 (void *)&cmd_setvf_traffic_what,
7410 (void *)&cmd_setvf_traffic_mode,
7415 /* *** CONFIGURE VF RECEIVE MODE *** */
7416 struct cmd_set_vf_rxmode {
7417 cmdline_fixed_string_t set;
7418 cmdline_fixed_string_t port;
7420 cmdline_fixed_string_t vf;
7422 cmdline_fixed_string_t what;
7423 cmdline_fixed_string_t mode;
7424 cmdline_fixed_string_t on;
7428 cmd_set_vf_rxmode_parsed(void *parsed_result,
7429 __attribute__((unused)) struct cmdline *cl,
7430 __attribute__((unused)) void *data)
7433 uint16_t rx_mode = 0;
7434 struct cmd_set_vf_rxmode *res = parsed_result;
7436 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
7437 if (!strcmp(res->what,"rxmode")) {
7438 if (!strcmp(res->mode, "AUPE"))
7439 rx_mode |= ETH_VMDQ_ACCEPT_UNTAG;
7440 else if (!strcmp(res->mode, "ROPE"))
7441 rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC;
7442 else if (!strcmp(res->mode, "BAM"))
7443 rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST;
7444 else if (!strncmp(res->mode, "MPE",3))
7445 rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST;
7448 #ifdef RTE_LIBRTE_IXGBE_PMD
7449 if (ret == -ENOTSUP)
7450 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id,
7451 rx_mode, (uint8_t)is_on);
7453 #ifdef RTE_LIBRTE_BNXT_PMD
7454 if (ret == -ENOTSUP)
7455 ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id,
7456 rx_mode, (uint8_t)is_on);
7459 printf("bad VF receive mode parameter, return code = %d \n",
7463 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
7464 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7466 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
7467 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7469 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
7470 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
7472 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
7473 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7475 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
7476 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
7478 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
7479 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7481 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
7482 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7483 mode, "AUPE#ROPE#BAM#MPE");
7484 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
7485 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7488 cmdline_parse_inst_t cmd_set_vf_rxmode = {
7489 .f = cmd_set_vf_rxmode_parsed,
7491 .help_str = "set port <port_id> vf <vf_id> rxmode "
7492 "AUPE|ROPE|BAM|MPE on|off",
7494 (void *)&cmd_set_vf_rxmode_set,
7495 (void *)&cmd_set_vf_rxmode_port,
7496 (void *)&cmd_set_vf_rxmode_portid,
7497 (void *)&cmd_set_vf_rxmode_vf,
7498 (void *)&cmd_set_vf_rxmode_vfid,
7499 (void *)&cmd_set_vf_rxmode_what,
7500 (void *)&cmd_set_vf_rxmode_mode,
7501 (void *)&cmd_set_vf_rxmode_on,
7506 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
7507 struct cmd_vf_mac_addr_result {
7508 cmdline_fixed_string_t mac_addr_cmd;
7509 cmdline_fixed_string_t what;
7510 cmdline_fixed_string_t port;
7512 cmdline_fixed_string_t vf;
7514 struct ether_addr address;
7517 static void cmd_vf_mac_addr_parsed(void *parsed_result,
7518 __attribute__((unused)) struct cmdline *cl,
7519 __attribute__((unused)) void *data)
7521 struct cmd_vf_mac_addr_result *res = parsed_result;
7524 if (strcmp(res->what, "add") != 0)
7527 #ifdef RTE_LIBRTE_I40E_PMD
7528 if (ret == -ENOTSUP)
7529 ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num,
7532 #ifdef RTE_LIBRTE_BNXT_PMD
7533 if (ret == -ENOTSUP)
7534 ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address,
7539 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
7543 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
7544 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7545 mac_addr_cmd,"mac_addr");
7546 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
7547 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7549 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
7550 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7552 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
7553 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
7555 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
7556 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7558 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
7559 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
7561 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
7562 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
7565 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
7566 .f = cmd_vf_mac_addr_parsed,
7568 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
7569 "Add MAC address filtering for a VF on port_id",
7571 (void *)&cmd_vf_mac_addr_cmd,
7572 (void *)&cmd_vf_mac_addr_what,
7573 (void *)&cmd_vf_mac_addr_port,
7574 (void *)&cmd_vf_mac_addr_portnum,
7575 (void *)&cmd_vf_mac_addr_vf,
7576 (void *)&cmd_vf_mac_addr_vfnum,
7577 (void *)&cmd_vf_mac_addr_addr,
7582 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
7583 struct cmd_vf_rx_vlan_filter {
7584 cmdline_fixed_string_t rx_vlan;
7585 cmdline_fixed_string_t what;
7587 cmdline_fixed_string_t port;
7589 cmdline_fixed_string_t vf;
7594 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
7595 __attribute__((unused)) struct cmdline *cl,
7596 __attribute__((unused)) void *data)
7598 struct cmd_vf_rx_vlan_filter *res = parsed_result;
7601 __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
7603 #ifdef RTE_LIBRTE_IXGBE_PMD
7604 if (ret == -ENOTSUP)
7605 ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
7606 res->vlan_id, res->vf_mask, is_add);
7608 #ifdef RTE_LIBRTE_I40E_PMD
7609 if (ret == -ENOTSUP)
7610 ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
7611 res->vlan_id, res->vf_mask, is_add);
7613 #ifdef RTE_LIBRTE_BNXT_PMD
7614 if (ret == -ENOTSUP)
7615 ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id,
7616 res->vlan_id, res->vf_mask, is_add);
7623 printf("invalid vlan_id %d or vf_mask %"PRIu64"\n",
7624 res->vlan_id, res->vf_mask);
7627 printf("invalid port_id %d\n", res->port_id);
7630 printf("function not implemented or supported\n");
7633 printf("programming error: (%s)\n", strerror(-ret));
7637 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
7638 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7639 rx_vlan, "rx_vlan");
7640 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
7641 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7643 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
7644 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7646 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
7647 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7649 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
7650 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7652 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
7653 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7655 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
7656 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7659 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
7660 .f = cmd_vf_rx_vlan_filter_parsed,
7662 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
7663 "(vf_mask = hexadecimal VF mask)",
7665 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
7666 (void *)&cmd_vf_rx_vlan_filter_what,
7667 (void *)&cmd_vf_rx_vlan_filter_vlanid,
7668 (void *)&cmd_vf_rx_vlan_filter_port,
7669 (void *)&cmd_vf_rx_vlan_filter_portid,
7670 (void *)&cmd_vf_rx_vlan_filter_vf,
7671 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
7676 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
7677 struct cmd_queue_rate_limit_result {
7678 cmdline_fixed_string_t set;
7679 cmdline_fixed_string_t port;
7681 cmdline_fixed_string_t queue;
7683 cmdline_fixed_string_t rate;
7687 static void cmd_queue_rate_limit_parsed(void *parsed_result,
7688 __attribute__((unused)) struct cmdline *cl,
7689 __attribute__((unused)) void *data)
7691 struct cmd_queue_rate_limit_result *res = parsed_result;
7694 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
7695 && (strcmp(res->queue, "queue") == 0)
7696 && (strcmp(res->rate, "rate") == 0))
7697 ret = set_queue_rate_limit(res->port_num, res->queue_num,
7700 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
7704 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
7705 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7707 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
7708 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7710 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
7711 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
7713 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
7714 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7716 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
7717 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
7719 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
7720 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7722 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
7723 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
7726 cmdline_parse_inst_t cmd_queue_rate_limit = {
7727 .f = cmd_queue_rate_limit_parsed,
7729 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
7730 "Set rate limit for a queue on port_id",
7732 (void *)&cmd_queue_rate_limit_set,
7733 (void *)&cmd_queue_rate_limit_port,
7734 (void *)&cmd_queue_rate_limit_portnum,
7735 (void *)&cmd_queue_rate_limit_queue,
7736 (void *)&cmd_queue_rate_limit_queuenum,
7737 (void *)&cmd_queue_rate_limit_rate,
7738 (void *)&cmd_queue_rate_limit_ratenum,
7743 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
7744 struct cmd_vf_rate_limit_result {
7745 cmdline_fixed_string_t set;
7746 cmdline_fixed_string_t port;
7748 cmdline_fixed_string_t vf;
7750 cmdline_fixed_string_t rate;
7752 cmdline_fixed_string_t q_msk;
7756 static void cmd_vf_rate_limit_parsed(void *parsed_result,
7757 __attribute__((unused)) struct cmdline *cl,
7758 __attribute__((unused)) void *data)
7760 struct cmd_vf_rate_limit_result *res = parsed_result;
7763 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
7764 && (strcmp(res->vf, "vf") == 0)
7765 && (strcmp(res->rate, "rate") == 0)
7766 && (strcmp(res->q_msk, "queue_mask") == 0))
7767 ret = set_vf_rate_limit(res->port_num, res->vf_num,
7768 res->rate_num, res->q_msk_val);
7770 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
7774 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
7775 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7777 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
7778 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7780 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
7781 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7783 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
7784 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7786 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
7787 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7789 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
7790 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7792 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
7793 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7795 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
7796 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7797 q_msk, "queue_mask");
7798 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
7799 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7802 cmdline_parse_inst_t cmd_vf_rate_limit = {
7803 .f = cmd_vf_rate_limit_parsed,
7805 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
7806 "queue_mask <queue_mask_value>: "
7807 "Set rate limit for queues of VF on port_id",
7809 (void *)&cmd_vf_rate_limit_set,
7810 (void *)&cmd_vf_rate_limit_port,
7811 (void *)&cmd_vf_rate_limit_portnum,
7812 (void *)&cmd_vf_rate_limit_vf,
7813 (void *)&cmd_vf_rate_limit_vfnum,
7814 (void *)&cmd_vf_rate_limit_rate,
7815 (void *)&cmd_vf_rate_limit_ratenum,
7816 (void *)&cmd_vf_rate_limit_q_msk,
7817 (void *)&cmd_vf_rate_limit_q_msk_val,
7822 /* *** ADD TUNNEL FILTER OF A PORT *** */
7823 struct cmd_tunnel_filter_result {
7824 cmdline_fixed_string_t cmd;
7825 cmdline_fixed_string_t what;
7827 struct ether_addr outer_mac;
7828 struct ether_addr inner_mac;
7829 cmdline_ipaddr_t ip_value;
7830 uint16_t inner_vlan;
7831 cmdline_fixed_string_t tunnel_type;
7832 cmdline_fixed_string_t filter_type;
7838 cmd_tunnel_filter_parsed(void *parsed_result,
7839 __attribute__((unused)) struct cmdline *cl,
7840 __attribute__((unused)) void *data)
7842 struct cmd_tunnel_filter_result *res = parsed_result;
7843 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
7846 memset(&tunnel_filter_conf, 0, sizeof(tunnel_filter_conf));
7848 ether_addr_copy(&res->outer_mac, &tunnel_filter_conf.outer_mac);
7849 ether_addr_copy(&res->inner_mac, &tunnel_filter_conf.inner_mac);
7850 tunnel_filter_conf.inner_vlan = res->inner_vlan;
7852 if (res->ip_value.family == AF_INET) {
7853 tunnel_filter_conf.ip_addr.ipv4_addr =
7854 res->ip_value.addr.ipv4.s_addr;
7855 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
7857 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
7858 &(res->ip_value.addr.ipv6),
7859 sizeof(struct in6_addr));
7860 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
7863 if (!strcmp(res->filter_type, "imac-ivlan"))
7864 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
7865 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
7866 tunnel_filter_conf.filter_type =
7867 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
7868 else if (!strcmp(res->filter_type, "imac-tenid"))
7869 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
7870 else if (!strcmp(res->filter_type, "imac"))
7871 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
7872 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
7873 tunnel_filter_conf.filter_type =
7874 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
7875 else if (!strcmp(res->filter_type, "oip"))
7876 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_OIP;
7877 else if (!strcmp(res->filter_type, "iip"))
7878 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IIP;
7880 printf("The filter type is not supported");
7884 if (!strcmp(res->tunnel_type, "vxlan"))
7885 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
7886 else if (!strcmp(res->tunnel_type, "nvgre"))
7887 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE;
7888 else if (!strcmp(res->tunnel_type, "ipingre"))
7889 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_IP_IN_GRE;
7891 printf("The tunnel type %s not supported.\n", res->tunnel_type);
7895 tunnel_filter_conf.tenant_id = res->tenant_id;
7896 tunnel_filter_conf.queue_id = res->queue_num;
7897 if (!strcmp(res->what, "add"))
7898 ret = rte_eth_dev_filter_ctrl(res->port_id,
7899 RTE_ETH_FILTER_TUNNEL,
7901 &tunnel_filter_conf);
7903 ret = rte_eth_dev_filter_ctrl(res->port_id,
7904 RTE_ETH_FILTER_TUNNEL,
7905 RTE_ETH_FILTER_DELETE,
7906 &tunnel_filter_conf);
7908 printf("cmd_tunnel_filter_parsed error: (%s)\n",
7912 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
7913 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7914 cmd, "tunnel_filter");
7915 cmdline_parse_token_string_t cmd_tunnel_filter_what =
7916 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7918 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
7919 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7921 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
7922 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
7924 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
7925 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
7927 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
7928 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7929 inner_vlan, UINT16);
7930 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
7931 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
7933 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
7934 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7935 tunnel_type, "vxlan#nvgre#ipingre");
7937 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
7938 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
7939 filter_type, "oip#iip#imac-ivlan#imac-ivlan-tenid#imac-tenid#"
7940 "imac#omac-imac-tenid");
7941 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
7942 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7944 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
7945 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
7948 cmdline_parse_inst_t cmd_tunnel_filter = {
7949 .f = cmd_tunnel_filter_parsed,
7951 .help_str = "tunnel_filter add|rm <port_id> <outer_mac> <inner_mac> "
7952 "<ip> <inner_vlan> vxlan|nvgre|ipingre oip|iip|imac-ivlan|"
7953 "imac-ivlan-tenid|imac-tenid|imac|omac-imac-tenid <tenant_id> "
7954 "<queue_id>: Add/Rm tunnel filter of a port",
7956 (void *)&cmd_tunnel_filter_cmd,
7957 (void *)&cmd_tunnel_filter_what,
7958 (void *)&cmd_tunnel_filter_port_id,
7959 (void *)&cmd_tunnel_filter_outer_mac,
7960 (void *)&cmd_tunnel_filter_inner_mac,
7961 (void *)&cmd_tunnel_filter_ip_value,
7962 (void *)&cmd_tunnel_filter_innner_vlan,
7963 (void *)&cmd_tunnel_filter_tunnel_type,
7964 (void *)&cmd_tunnel_filter_filter_type,
7965 (void *)&cmd_tunnel_filter_tenant_id,
7966 (void *)&cmd_tunnel_filter_queue_num,
7971 /* *** CONFIGURE TUNNEL UDP PORT *** */
7972 struct cmd_tunnel_udp_config {
7973 cmdline_fixed_string_t cmd;
7974 cmdline_fixed_string_t what;
7980 cmd_tunnel_udp_config_parsed(void *parsed_result,
7981 __attribute__((unused)) struct cmdline *cl,
7982 __attribute__((unused)) void *data)
7984 struct cmd_tunnel_udp_config *res = parsed_result;
7985 struct rte_eth_udp_tunnel tunnel_udp;
7988 tunnel_udp.udp_port = res->udp_port;
7990 if (!strcmp(res->cmd, "rx_vxlan_port"))
7991 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
7993 if (!strcmp(res->what, "add"))
7994 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
7997 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
8001 printf("udp tunneling add error: (%s)\n", strerror(-ret));
8004 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
8005 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
8006 cmd, "rx_vxlan_port");
8007 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
8008 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
8010 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
8011 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
8013 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
8014 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
8017 cmdline_parse_inst_t cmd_tunnel_udp_config = {
8018 .f = cmd_tunnel_udp_config_parsed,
8020 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
8021 "Add/Remove a tunneling UDP port filter",
8023 (void *)&cmd_tunnel_udp_config_cmd,
8024 (void *)&cmd_tunnel_udp_config_what,
8025 (void *)&cmd_tunnel_udp_config_udp_port,
8026 (void *)&cmd_tunnel_udp_config_port_id,
8031 /* *** GLOBAL CONFIG *** */
8032 struct cmd_global_config_result {
8033 cmdline_fixed_string_t cmd;
8035 cmdline_fixed_string_t cfg_type;
8040 cmd_global_config_parsed(void *parsed_result,
8041 __attribute__((unused)) struct cmdline *cl,
8042 __attribute__((unused)) void *data)
8044 struct cmd_global_config_result *res = parsed_result;
8045 struct rte_eth_global_cfg conf;
8048 memset(&conf, 0, sizeof(conf));
8049 conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN;
8050 conf.cfg.gre_key_len = res->len;
8051 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE,
8052 RTE_ETH_FILTER_SET, &conf);
8054 printf("Global config error\n");
8057 cmdline_parse_token_string_t cmd_global_config_cmd =
8058 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd,
8060 cmdline_parse_token_num_t cmd_global_config_port_id =
8061 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id,
8063 cmdline_parse_token_string_t cmd_global_config_type =
8064 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result,
8065 cfg_type, "gre-key-len");
8066 cmdline_parse_token_num_t cmd_global_config_gre_key_len =
8067 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result,
8070 cmdline_parse_inst_t cmd_global_config = {
8071 .f = cmd_global_config_parsed,
8072 .data = (void *)NULL,
8073 .help_str = "global_config <port_id> gre-key-len <key_len>",
8075 (void *)&cmd_global_config_cmd,
8076 (void *)&cmd_global_config_port_id,
8077 (void *)&cmd_global_config_type,
8078 (void *)&cmd_global_config_gre_key_len,
8083 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
8084 struct cmd_set_mirror_mask_result {
8085 cmdline_fixed_string_t set;
8086 cmdline_fixed_string_t port;
8088 cmdline_fixed_string_t mirror;
8090 cmdline_fixed_string_t what;
8091 cmdline_fixed_string_t value;
8092 cmdline_fixed_string_t dstpool;
8094 cmdline_fixed_string_t on;
8097 cmdline_parse_token_string_t cmd_mirror_mask_set =
8098 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8100 cmdline_parse_token_string_t cmd_mirror_mask_port =
8101 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8103 cmdline_parse_token_num_t cmd_mirror_mask_portid =
8104 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
8106 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
8107 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8108 mirror, "mirror-rule");
8109 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
8110 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
8112 cmdline_parse_token_string_t cmd_mirror_mask_what =
8113 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8114 what, "pool-mirror-up#pool-mirror-down"
8116 cmdline_parse_token_string_t cmd_mirror_mask_value =
8117 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8119 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
8120 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8121 dstpool, "dst-pool");
8122 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
8123 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
8125 cmdline_parse_token_string_t cmd_mirror_mask_on =
8126 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8130 cmd_set_mirror_mask_parsed(void *parsed_result,
8131 __attribute__((unused)) struct cmdline *cl,
8132 __attribute__((unused)) void *data)
8135 struct cmd_set_mirror_mask_result *res = parsed_result;
8136 struct rte_eth_mirror_conf mr_conf;
8138 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
8140 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
8142 mr_conf.dst_pool = res->dstpool_id;
8144 if (!strcmp(res->what, "pool-mirror-up")) {
8145 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
8146 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
8147 } else if (!strcmp(res->what, "pool-mirror-down")) {
8148 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
8149 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
8150 } else if (!strcmp(res->what, "vlan-mirror")) {
8151 mr_conf.rule_type = ETH_MIRROR_VLAN;
8152 nb_item = parse_item_list(res->value, "vlan",
8153 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
8157 for (i = 0; i < nb_item; i++) {
8158 if (vlan_list[i] > ETHER_MAX_VLAN_ID) {
8159 printf("Invalid vlan_id: must be < 4096\n");
8163 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
8164 mr_conf.vlan.vlan_mask |= 1ULL << i;
8168 if (!strcmp(res->on, "on"))
8169 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8172 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8175 printf("mirror rule add error: (%s)\n", strerror(-ret));
8178 cmdline_parse_inst_t cmd_set_mirror_mask = {
8179 .f = cmd_set_mirror_mask_parsed,
8181 .help_str = "set port <port_id> mirror-rule <rule_id> "
8182 "pool-mirror-up|pool-mirror-down|vlan-mirror "
8183 "<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off",
8185 (void *)&cmd_mirror_mask_set,
8186 (void *)&cmd_mirror_mask_port,
8187 (void *)&cmd_mirror_mask_portid,
8188 (void *)&cmd_mirror_mask_mirror,
8189 (void *)&cmd_mirror_mask_ruleid,
8190 (void *)&cmd_mirror_mask_what,
8191 (void *)&cmd_mirror_mask_value,
8192 (void *)&cmd_mirror_mask_dstpool,
8193 (void *)&cmd_mirror_mask_poolid,
8194 (void *)&cmd_mirror_mask_on,
8199 /* *** CONFIGURE VM MIRROR UPLINK/DOWNLINK RULE *** */
8200 struct cmd_set_mirror_link_result {
8201 cmdline_fixed_string_t set;
8202 cmdline_fixed_string_t port;
8204 cmdline_fixed_string_t mirror;
8206 cmdline_fixed_string_t what;
8207 cmdline_fixed_string_t dstpool;
8209 cmdline_fixed_string_t on;
8212 cmdline_parse_token_string_t cmd_mirror_link_set =
8213 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8215 cmdline_parse_token_string_t cmd_mirror_link_port =
8216 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8218 cmdline_parse_token_num_t cmd_mirror_link_portid =
8219 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
8221 cmdline_parse_token_string_t cmd_mirror_link_mirror =
8222 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8223 mirror, "mirror-rule");
8224 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
8225 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
8227 cmdline_parse_token_string_t cmd_mirror_link_what =
8228 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8229 what, "uplink-mirror#downlink-mirror");
8230 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
8231 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8232 dstpool, "dst-pool");
8233 cmdline_parse_token_num_t cmd_mirror_link_poolid =
8234 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
8236 cmdline_parse_token_string_t cmd_mirror_link_on =
8237 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8241 cmd_set_mirror_link_parsed(void *parsed_result,
8242 __attribute__((unused)) struct cmdline *cl,
8243 __attribute__((unused)) void *data)
8246 struct cmd_set_mirror_link_result *res = parsed_result;
8247 struct rte_eth_mirror_conf mr_conf;
8249 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
8250 if (!strcmp(res->what, "uplink-mirror"))
8251 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
8253 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
8255 mr_conf.dst_pool = res->dstpool_id;
8257 if (!strcmp(res->on, "on"))
8258 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8261 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8264 /* check the return value and print it if is < 0 */
8266 printf("mirror rule add error: (%s)\n", strerror(-ret));
8270 cmdline_parse_inst_t cmd_set_mirror_link = {
8271 .f = cmd_set_mirror_link_parsed,
8273 .help_str = "set port <port_id> mirror-rule <rule_id> "
8274 "uplink-mirror|downlink-mirror dst-pool <pool_id> on|off",
8276 (void *)&cmd_mirror_link_set,
8277 (void *)&cmd_mirror_link_port,
8278 (void *)&cmd_mirror_link_portid,
8279 (void *)&cmd_mirror_link_mirror,
8280 (void *)&cmd_mirror_link_ruleid,
8281 (void *)&cmd_mirror_link_what,
8282 (void *)&cmd_mirror_link_dstpool,
8283 (void *)&cmd_mirror_link_poolid,
8284 (void *)&cmd_mirror_link_on,
8289 /* *** RESET VM MIRROR RULE *** */
8290 struct cmd_rm_mirror_rule_result {
8291 cmdline_fixed_string_t reset;
8292 cmdline_fixed_string_t port;
8294 cmdline_fixed_string_t mirror;
8298 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
8299 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
8301 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
8302 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
8304 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
8305 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
8307 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
8308 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
8309 mirror, "mirror-rule");
8310 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
8311 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
8315 cmd_reset_mirror_rule_parsed(void *parsed_result,
8316 __attribute__((unused)) struct cmdline *cl,
8317 __attribute__((unused)) void *data)
8320 struct cmd_set_mirror_link_result *res = parsed_result;
8322 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
8324 printf("mirror rule remove error: (%s)\n", strerror(-ret));
8327 cmdline_parse_inst_t cmd_reset_mirror_rule = {
8328 .f = cmd_reset_mirror_rule_parsed,
8330 .help_str = "reset port <port_id> mirror-rule <rule_id>",
8332 (void *)&cmd_rm_mirror_rule_reset,
8333 (void *)&cmd_rm_mirror_rule_port,
8334 (void *)&cmd_rm_mirror_rule_portid,
8335 (void *)&cmd_rm_mirror_rule_mirror,
8336 (void *)&cmd_rm_mirror_rule_ruleid,
8341 /* ******************************************************************************** */
8343 struct cmd_dump_result {
8344 cmdline_fixed_string_t dump;
8348 dump_struct_sizes(void)
8350 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
8351 DUMP_SIZE(struct rte_mbuf);
8352 DUMP_SIZE(struct rte_mempool);
8353 DUMP_SIZE(struct rte_ring);
8357 static void cmd_dump_parsed(void *parsed_result,
8358 __attribute__((unused)) struct cmdline *cl,
8359 __attribute__((unused)) void *data)
8361 struct cmd_dump_result *res = parsed_result;
8363 if (!strcmp(res->dump, "dump_physmem"))
8364 rte_dump_physmem_layout(stdout);
8365 else if (!strcmp(res->dump, "dump_memzone"))
8366 rte_memzone_dump(stdout);
8367 else if (!strcmp(res->dump, "dump_struct_sizes"))
8368 dump_struct_sizes();
8369 else if (!strcmp(res->dump, "dump_ring"))
8370 rte_ring_list_dump(stdout);
8371 else if (!strcmp(res->dump, "dump_mempool"))
8372 rte_mempool_list_dump(stdout);
8373 else if (!strcmp(res->dump, "dump_devargs"))
8374 rte_eal_devargs_dump(stdout);
8375 else if (!strcmp(res->dump, "dump_log_types"))
8376 rte_log_dump(stdout);
8379 cmdline_parse_token_string_t cmd_dump_dump =
8380 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
8383 "dump_struct_sizes#"
8389 cmdline_parse_inst_t cmd_dump = {
8390 .f = cmd_dump_parsed, /* function to call */
8391 .data = NULL, /* 2nd arg of func */
8392 .help_str = "Dump status",
8393 .tokens = { /* token list, NULL terminated */
8394 (void *)&cmd_dump_dump,
8399 /* ******************************************************************************** */
8401 struct cmd_dump_one_result {
8402 cmdline_fixed_string_t dump;
8403 cmdline_fixed_string_t name;
8406 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
8407 __attribute__((unused)) void *data)
8409 struct cmd_dump_one_result *res = parsed_result;
8411 if (!strcmp(res->dump, "dump_ring")) {
8413 r = rte_ring_lookup(res->name);
8415 cmdline_printf(cl, "Cannot find ring\n");
8418 rte_ring_dump(stdout, r);
8419 } else if (!strcmp(res->dump, "dump_mempool")) {
8420 struct rte_mempool *mp;
8421 mp = rte_mempool_lookup(res->name);
8423 cmdline_printf(cl, "Cannot find mempool\n");
8426 rte_mempool_dump(stdout, mp);
8430 cmdline_parse_token_string_t cmd_dump_one_dump =
8431 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
8432 "dump_ring#dump_mempool");
8434 cmdline_parse_token_string_t cmd_dump_one_name =
8435 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
8437 cmdline_parse_inst_t cmd_dump_one = {
8438 .f = cmd_dump_one_parsed, /* function to call */
8439 .data = NULL, /* 2nd arg of func */
8440 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
8441 .tokens = { /* token list, NULL terminated */
8442 (void *)&cmd_dump_one_dump,
8443 (void *)&cmd_dump_one_name,
8448 /* *** Add/Del syn filter *** */
8449 struct cmd_syn_filter_result {
8450 cmdline_fixed_string_t filter;
8452 cmdline_fixed_string_t ops;
8453 cmdline_fixed_string_t priority;
8454 cmdline_fixed_string_t high;
8455 cmdline_fixed_string_t queue;
8460 cmd_syn_filter_parsed(void *parsed_result,
8461 __attribute__((unused)) struct cmdline *cl,
8462 __attribute__((unused)) void *data)
8464 struct cmd_syn_filter_result *res = parsed_result;
8465 struct rte_eth_syn_filter syn_filter;
8468 ret = rte_eth_dev_filter_supported(res->port_id,
8469 RTE_ETH_FILTER_SYN);
8471 printf("syn filter is not supported on port %u.\n",
8476 memset(&syn_filter, 0, sizeof(syn_filter));
8478 if (!strcmp(res->ops, "add")) {
8479 if (!strcmp(res->high, "high"))
8480 syn_filter.hig_pri = 1;
8482 syn_filter.hig_pri = 0;
8484 syn_filter.queue = res->queue_id;
8485 ret = rte_eth_dev_filter_ctrl(res->port_id,
8490 ret = rte_eth_dev_filter_ctrl(res->port_id,
8492 RTE_ETH_FILTER_DELETE,
8496 printf("syn filter programming error: (%s)\n",
8500 cmdline_parse_token_string_t cmd_syn_filter_filter =
8501 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8502 filter, "syn_filter");
8503 cmdline_parse_token_num_t cmd_syn_filter_port_id =
8504 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
8506 cmdline_parse_token_string_t cmd_syn_filter_ops =
8507 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8509 cmdline_parse_token_string_t cmd_syn_filter_priority =
8510 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8511 priority, "priority");
8512 cmdline_parse_token_string_t cmd_syn_filter_high =
8513 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8515 cmdline_parse_token_string_t cmd_syn_filter_queue =
8516 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8518 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
8519 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
8522 cmdline_parse_inst_t cmd_syn_filter = {
8523 .f = cmd_syn_filter_parsed,
8525 .help_str = "syn_filter <port_id> add|del priority high|low queue "
8526 "<queue_id>: Add/Delete syn filter",
8528 (void *)&cmd_syn_filter_filter,
8529 (void *)&cmd_syn_filter_port_id,
8530 (void *)&cmd_syn_filter_ops,
8531 (void *)&cmd_syn_filter_priority,
8532 (void *)&cmd_syn_filter_high,
8533 (void *)&cmd_syn_filter_queue,
8534 (void *)&cmd_syn_filter_queue_id,
8539 /* *** queue region set *** */
8540 struct cmd_queue_region_result {
8541 cmdline_fixed_string_t set;
8542 cmdline_fixed_string_t port;
8544 cmdline_fixed_string_t cmd;
8545 cmdline_fixed_string_t region;
8547 cmdline_fixed_string_t queue_start_index;
8549 cmdline_fixed_string_t queue_num;
8550 uint8_t queue_num_value;
8554 cmd_queue_region_parsed(void *parsed_result,
8555 __attribute__((unused)) struct cmdline *cl,
8556 __attribute__((unused)) void *data)
8558 struct cmd_queue_region_result *res = parsed_result;
8560 #ifdef RTE_LIBRTE_I40E_PMD
8561 struct rte_pmd_i40e_queue_region_conf region_conf;
8562 enum rte_pmd_i40e_queue_region_op op_type;
8565 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
8568 #ifdef RTE_LIBRTE_I40E_PMD
8569 memset(®ion_conf, 0, sizeof(region_conf));
8570 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_SET;
8571 region_conf.region_id = res->region_id;
8572 region_conf.queue_num = res->queue_num_value;
8573 region_conf.queue_start_index = res->queue_id;
8575 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
8576 op_type, ®ion_conf);
8583 printf("function not implemented or supported\n");
8586 printf("queue region config error: (%s)\n", strerror(-ret));
8590 cmdline_parse_token_string_t cmd_queue_region_set =
8591 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
8593 cmdline_parse_token_string_t cmd_queue_region_port =
8594 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, port, "port");
8595 cmdline_parse_token_num_t cmd_queue_region_port_id =
8596 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
8598 cmdline_parse_token_string_t cmd_queue_region_cmd =
8599 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
8600 cmd, "queue-region");
8601 cmdline_parse_token_string_t cmd_queue_region_id =
8602 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
8603 region, "region_id");
8604 cmdline_parse_token_num_t cmd_queue_region_index =
8605 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
8607 cmdline_parse_token_string_t cmd_queue_region_queue_start_index =
8608 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
8609 queue_start_index, "queue_start_index");
8610 cmdline_parse_token_num_t cmd_queue_region_queue_id =
8611 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
8613 cmdline_parse_token_string_t cmd_queue_region_queue_num =
8614 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
8615 queue_num, "queue_num");
8616 cmdline_parse_token_num_t cmd_queue_region_queue_num_value =
8617 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
8618 queue_num_value, UINT8);
8620 cmdline_parse_inst_t cmd_queue_region = {
8621 .f = cmd_queue_region_parsed,
8623 .help_str = "set port <port_id> queue-region region_id <value> "
8624 "queue_start_index <value> queue_num <value>: Set a queue region",
8626 (void *)&cmd_queue_region_set,
8627 (void *)&cmd_queue_region_port,
8628 (void *)&cmd_queue_region_port_id,
8629 (void *)&cmd_queue_region_cmd,
8630 (void *)&cmd_queue_region_id,
8631 (void *)&cmd_queue_region_index,
8632 (void *)&cmd_queue_region_queue_start_index,
8633 (void *)&cmd_queue_region_queue_id,
8634 (void *)&cmd_queue_region_queue_num,
8635 (void *)&cmd_queue_region_queue_num_value,
8640 /* *** queue region and flowtype set *** */
8641 struct cmd_region_flowtype_result {
8642 cmdline_fixed_string_t set;
8643 cmdline_fixed_string_t port;
8645 cmdline_fixed_string_t cmd;
8646 cmdline_fixed_string_t region;
8648 cmdline_fixed_string_t flowtype;
8649 uint8_t flowtype_id;
8653 cmd_region_flowtype_parsed(void *parsed_result,
8654 __attribute__((unused)) struct cmdline *cl,
8655 __attribute__((unused)) void *data)
8657 struct cmd_region_flowtype_result *res = parsed_result;
8659 #ifdef RTE_LIBRTE_I40E_PMD
8660 struct rte_pmd_i40e_queue_region_conf region_conf;
8661 enum rte_pmd_i40e_queue_region_op op_type;
8664 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
8667 #ifdef RTE_LIBRTE_I40E_PMD
8668 memset(®ion_conf, 0, sizeof(region_conf));
8670 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_FLOWTYPE_SET;
8671 region_conf.region_id = res->region_id;
8672 region_conf.hw_flowtype = res->flowtype_id;
8674 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
8675 op_type, ®ion_conf);
8682 printf("function not implemented or supported\n");
8685 printf("region flowtype config error: (%s)\n", strerror(-ret));
8689 cmdline_parse_token_string_t cmd_region_flowtype_set =
8690 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
8692 cmdline_parse_token_string_t cmd_region_flowtype_port =
8693 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
8695 cmdline_parse_token_num_t cmd_region_flowtype_port_index =
8696 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
8698 cmdline_parse_token_string_t cmd_region_flowtype_cmd =
8699 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
8700 cmd, "queue-region");
8701 cmdline_parse_token_string_t cmd_region_flowtype_index =
8702 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
8703 region, "region_id");
8704 cmdline_parse_token_num_t cmd_region_flowtype_id =
8705 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
8707 cmdline_parse_token_string_t cmd_region_flowtype_flow_index =
8708 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
8709 flowtype, "flowtype");
8710 cmdline_parse_token_num_t cmd_region_flowtype_flow_id =
8711 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
8712 flowtype_id, UINT8);
8713 cmdline_parse_inst_t cmd_region_flowtype = {
8714 .f = cmd_region_flowtype_parsed,
8716 .help_str = "set port <port_id> queue-region region_id <value> "
8717 "flowtype <value>: Set a flowtype region index",
8719 (void *)&cmd_region_flowtype_set,
8720 (void *)&cmd_region_flowtype_port,
8721 (void *)&cmd_region_flowtype_port_index,
8722 (void *)&cmd_region_flowtype_cmd,
8723 (void *)&cmd_region_flowtype_index,
8724 (void *)&cmd_region_flowtype_id,
8725 (void *)&cmd_region_flowtype_flow_index,
8726 (void *)&cmd_region_flowtype_flow_id,
8731 /* *** User Priority (UP) to queue region (region_id) set *** */
8732 struct cmd_user_priority_region_result {
8733 cmdline_fixed_string_t set;
8734 cmdline_fixed_string_t port;
8736 cmdline_fixed_string_t cmd;
8737 cmdline_fixed_string_t user_priority;
8738 uint8_t user_priority_id;
8739 cmdline_fixed_string_t region;
8744 cmd_user_priority_region_parsed(void *parsed_result,
8745 __attribute__((unused)) struct cmdline *cl,
8746 __attribute__((unused)) void *data)
8748 struct cmd_user_priority_region_result *res = parsed_result;
8750 #ifdef RTE_LIBRTE_I40E_PMD
8751 struct rte_pmd_i40e_queue_region_conf region_conf;
8752 enum rte_pmd_i40e_queue_region_op op_type;
8755 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
8758 #ifdef RTE_LIBRTE_I40E_PMD
8759 memset(®ion_conf, 0, sizeof(region_conf));
8760 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_USER_PRIORITY_SET;
8761 region_conf.user_priority = res->user_priority_id;
8762 region_conf.region_id = res->region_id;
8764 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
8765 op_type, ®ion_conf);
8772 printf("function not implemented or supported\n");
8775 printf("user_priority region config error: (%s)\n",
8780 cmdline_parse_token_string_t cmd_user_priority_region_set =
8781 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
8783 cmdline_parse_token_string_t cmd_user_priority_region_port =
8784 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
8786 cmdline_parse_token_num_t cmd_user_priority_region_port_index =
8787 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
8789 cmdline_parse_token_string_t cmd_user_priority_region_cmd =
8790 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
8791 cmd, "queue-region");
8792 cmdline_parse_token_string_t cmd_user_priority_region_UP =
8793 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
8794 user_priority, "UP");
8795 cmdline_parse_token_num_t cmd_user_priority_region_UP_id =
8796 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
8797 user_priority_id, UINT8);
8798 cmdline_parse_token_string_t cmd_user_priority_region_region =
8799 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
8800 region, "region_id");
8801 cmdline_parse_token_num_t cmd_user_priority_region_region_id =
8802 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
8805 cmdline_parse_inst_t cmd_user_priority_region = {
8806 .f = cmd_user_priority_region_parsed,
8808 .help_str = "set port <port_id> queue-region UP <value> "
8809 "region_id <value>: Set the mapping of User Priority (UP) "
8810 "to queue region (region_id) ",
8812 (void *)&cmd_user_priority_region_set,
8813 (void *)&cmd_user_priority_region_port,
8814 (void *)&cmd_user_priority_region_port_index,
8815 (void *)&cmd_user_priority_region_cmd,
8816 (void *)&cmd_user_priority_region_UP,
8817 (void *)&cmd_user_priority_region_UP_id,
8818 (void *)&cmd_user_priority_region_region,
8819 (void *)&cmd_user_priority_region_region_id,
8824 /* *** flush all queue region related configuration *** */
8825 struct cmd_flush_queue_region_result {
8826 cmdline_fixed_string_t set;
8827 cmdline_fixed_string_t port;
8829 cmdline_fixed_string_t cmd;
8830 cmdline_fixed_string_t flush;
8831 cmdline_fixed_string_t what;
8835 cmd_flush_queue_region_parsed(void *parsed_result,
8836 __attribute__((unused)) struct cmdline *cl,
8837 __attribute__((unused)) void *data)
8839 struct cmd_flush_queue_region_result *res = parsed_result;
8841 #ifdef RTE_LIBRTE_I40E_PMD
8842 struct rte_pmd_i40e_queue_region_conf region_conf;
8843 enum rte_pmd_i40e_queue_region_op op_type;
8846 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
8849 #ifdef RTE_LIBRTE_I40E_PMD
8850 memset(®ion_conf, 0, sizeof(region_conf));
8852 if (strcmp(res->what, "on") == 0)
8853 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_ON;
8855 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_OFF;
8857 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
8858 op_type, ®ion_conf);
8865 printf("function not implemented or supported\n");
8868 printf("queue region config flush error: (%s)\n",
8873 cmdline_parse_token_string_t cmd_flush_queue_region_set =
8874 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
8876 cmdline_parse_token_string_t cmd_flush_queue_region_port =
8877 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
8879 cmdline_parse_token_num_t cmd_flush_queue_region_port_index =
8880 TOKEN_NUM_INITIALIZER(struct cmd_flush_queue_region_result,
8882 cmdline_parse_token_string_t cmd_flush_queue_region_cmd =
8883 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
8884 cmd, "queue-region");
8885 cmdline_parse_token_string_t cmd_flush_queue_region_flush =
8886 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
8888 cmdline_parse_token_string_t cmd_flush_queue_region_what =
8889 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
8892 cmdline_parse_inst_t cmd_flush_queue_region = {
8893 .f = cmd_flush_queue_region_parsed,
8895 .help_str = "set port <port_id> queue-region flush on|off"
8896 ": flush all queue region related configuration",
8898 (void *)&cmd_flush_queue_region_set,
8899 (void *)&cmd_flush_queue_region_port,
8900 (void *)&cmd_flush_queue_region_port_index,
8901 (void *)&cmd_flush_queue_region_cmd,
8902 (void *)&cmd_flush_queue_region_flush,
8903 (void *)&cmd_flush_queue_region_what,
8908 /* *** get all queue region related configuration info *** */
8909 struct cmd_show_queue_region_info {
8910 cmdline_fixed_string_t show;
8911 cmdline_fixed_string_t port;
8913 cmdline_fixed_string_t cmd;
8917 cmd_show_queue_region_info_parsed(void *parsed_result,
8918 __attribute__((unused)) struct cmdline *cl,
8919 __attribute__((unused)) void *data)
8921 struct cmd_show_queue_region_info *res = parsed_result;
8923 #ifdef RTE_LIBRTE_I40E_PMD
8924 struct rte_pmd_i40e_queue_regions rte_pmd_regions;
8925 enum rte_pmd_i40e_queue_region_op op_type;
8928 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
8931 #ifdef RTE_LIBRTE_I40E_PMD
8932 memset(&rte_pmd_regions, 0, sizeof(rte_pmd_regions));
8934 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_INFO_GET;
8936 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
8937 op_type, &rte_pmd_regions);
8939 port_queue_region_info_display(res->port_id, &rte_pmd_regions);
8946 printf("function not implemented or supported\n");
8949 printf("queue region config info show error: (%s)\n",
8954 cmdline_parse_token_string_t cmd_show_queue_region_info_get =
8955 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
8957 cmdline_parse_token_string_t cmd_show_queue_region_info_port =
8958 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
8960 cmdline_parse_token_num_t cmd_show_queue_region_info_port_index =
8961 TOKEN_NUM_INITIALIZER(struct cmd_show_queue_region_info,
8963 cmdline_parse_token_string_t cmd_show_queue_region_info_cmd =
8964 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
8965 cmd, "queue-region");
8967 cmdline_parse_inst_t cmd_show_queue_region_info_all = {
8968 .f = cmd_show_queue_region_info_parsed,
8970 .help_str = "show port <port_id> queue-region"
8971 ": show all queue region related configuration info",
8973 (void *)&cmd_show_queue_region_info_get,
8974 (void *)&cmd_show_queue_region_info_port,
8975 (void *)&cmd_show_queue_region_info_port_index,
8976 (void *)&cmd_show_queue_region_info_cmd,
8981 /* *** ADD/REMOVE A 2tuple FILTER *** */
8982 struct cmd_2tuple_filter_result {
8983 cmdline_fixed_string_t filter;
8985 cmdline_fixed_string_t ops;
8986 cmdline_fixed_string_t dst_port;
8987 uint16_t dst_port_value;
8988 cmdline_fixed_string_t protocol;
8989 uint8_t protocol_value;
8990 cmdline_fixed_string_t mask;
8992 cmdline_fixed_string_t tcp_flags;
8993 uint8_t tcp_flags_value;
8994 cmdline_fixed_string_t priority;
8995 uint8_t priority_value;
8996 cmdline_fixed_string_t queue;
9001 cmd_2tuple_filter_parsed(void *parsed_result,
9002 __attribute__((unused)) struct cmdline *cl,
9003 __attribute__((unused)) void *data)
9005 struct rte_eth_ntuple_filter filter;
9006 struct cmd_2tuple_filter_result *res = parsed_result;
9009 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
9011 printf("ntuple filter is not supported on port %u.\n",
9016 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
9018 filter.flags = RTE_2TUPLE_FLAGS;
9019 filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
9020 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
9021 filter.proto = res->protocol_value;
9022 filter.priority = res->priority_value;
9023 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
9024 printf("nonzero tcp_flags is only meaningful"
9025 " when protocol is TCP.\n");
9028 if (res->tcp_flags_value > TCP_FLAG_ALL) {
9029 printf("invalid TCP flags.\n");
9033 if (res->tcp_flags_value != 0) {
9034 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
9035 filter.tcp_flags = res->tcp_flags_value;
9038 /* need convert to big endian. */
9039 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
9040 filter.queue = res->queue_id;
9042 if (!strcmp(res->ops, "add"))
9043 ret = rte_eth_dev_filter_ctrl(res->port_id,
9044 RTE_ETH_FILTER_NTUPLE,
9048 ret = rte_eth_dev_filter_ctrl(res->port_id,
9049 RTE_ETH_FILTER_NTUPLE,
9050 RTE_ETH_FILTER_DELETE,
9053 printf("2tuple filter programming error: (%s)\n",
9058 cmdline_parse_token_string_t cmd_2tuple_filter_filter =
9059 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9060 filter, "2tuple_filter");
9061 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
9062 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9064 cmdline_parse_token_string_t cmd_2tuple_filter_ops =
9065 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9067 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
9068 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9069 dst_port, "dst_port");
9070 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
9071 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9072 dst_port_value, UINT16);
9073 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
9074 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9075 protocol, "protocol");
9076 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
9077 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9078 protocol_value, UINT8);
9079 cmdline_parse_token_string_t cmd_2tuple_filter_mask =
9080 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9082 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value =
9083 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9085 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags =
9086 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9087 tcp_flags, "tcp_flags");
9088 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value =
9089 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9090 tcp_flags_value, UINT8);
9091 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
9092 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9093 priority, "priority");
9094 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
9095 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9096 priority_value, UINT8);
9097 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
9098 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9100 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
9101 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9104 cmdline_parse_inst_t cmd_2tuple_filter = {
9105 .f = cmd_2tuple_filter_parsed,
9107 .help_str = "2tuple_filter <port_id> add|del dst_port <value> protocol "
9108 "<value> mask <value> tcp_flags <value> priority <value> queue "
9109 "<queue_id>: Add a 2tuple filter",
9111 (void *)&cmd_2tuple_filter_filter,
9112 (void *)&cmd_2tuple_filter_port_id,
9113 (void *)&cmd_2tuple_filter_ops,
9114 (void *)&cmd_2tuple_filter_dst_port,
9115 (void *)&cmd_2tuple_filter_dst_port_value,
9116 (void *)&cmd_2tuple_filter_protocol,
9117 (void *)&cmd_2tuple_filter_protocol_value,
9118 (void *)&cmd_2tuple_filter_mask,
9119 (void *)&cmd_2tuple_filter_mask_value,
9120 (void *)&cmd_2tuple_filter_tcp_flags,
9121 (void *)&cmd_2tuple_filter_tcp_flags_value,
9122 (void *)&cmd_2tuple_filter_priority,
9123 (void *)&cmd_2tuple_filter_priority_value,
9124 (void *)&cmd_2tuple_filter_queue,
9125 (void *)&cmd_2tuple_filter_queue_id,
9130 /* *** ADD/REMOVE A 5tuple FILTER *** */
9131 struct cmd_5tuple_filter_result {
9132 cmdline_fixed_string_t filter;
9134 cmdline_fixed_string_t ops;
9135 cmdline_fixed_string_t dst_ip;
9136 cmdline_ipaddr_t dst_ip_value;
9137 cmdline_fixed_string_t src_ip;
9138 cmdline_ipaddr_t src_ip_value;
9139 cmdline_fixed_string_t dst_port;
9140 uint16_t dst_port_value;
9141 cmdline_fixed_string_t src_port;
9142 uint16_t src_port_value;
9143 cmdline_fixed_string_t protocol;
9144 uint8_t protocol_value;
9145 cmdline_fixed_string_t mask;
9147 cmdline_fixed_string_t tcp_flags;
9148 uint8_t tcp_flags_value;
9149 cmdline_fixed_string_t priority;
9150 uint8_t priority_value;
9151 cmdline_fixed_string_t queue;
9156 cmd_5tuple_filter_parsed(void *parsed_result,
9157 __attribute__((unused)) struct cmdline *cl,
9158 __attribute__((unused)) void *data)
9160 struct rte_eth_ntuple_filter filter;
9161 struct cmd_5tuple_filter_result *res = parsed_result;
9164 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
9166 printf("ntuple filter is not supported on port %u.\n",
9171 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
9173 filter.flags = RTE_5TUPLE_FLAGS;
9174 filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0;
9175 filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0;
9176 filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0;
9177 filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
9178 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
9179 filter.proto = res->protocol_value;
9180 filter.priority = res->priority_value;
9181 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
9182 printf("nonzero tcp_flags is only meaningful"
9183 " when protocol is TCP.\n");
9186 if (res->tcp_flags_value > TCP_FLAG_ALL) {
9187 printf("invalid TCP flags.\n");
9191 if (res->tcp_flags_value != 0) {
9192 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
9193 filter.tcp_flags = res->tcp_flags_value;
9196 if (res->dst_ip_value.family == AF_INET)
9197 /* no need to convert, already big endian. */
9198 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
9200 if (filter.dst_ip_mask == 0) {
9201 printf("can not support ipv6 involved compare.\n");
9207 if (res->src_ip_value.family == AF_INET)
9208 /* no need to convert, already big endian. */
9209 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
9211 if (filter.src_ip_mask == 0) {
9212 printf("can not support ipv6 involved compare.\n");
9217 /* need convert to big endian. */
9218 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
9219 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
9220 filter.queue = res->queue_id;
9222 if (!strcmp(res->ops, "add"))
9223 ret = rte_eth_dev_filter_ctrl(res->port_id,
9224 RTE_ETH_FILTER_NTUPLE,
9228 ret = rte_eth_dev_filter_ctrl(res->port_id,
9229 RTE_ETH_FILTER_NTUPLE,
9230 RTE_ETH_FILTER_DELETE,
9233 printf("5tuple filter programming error: (%s)\n",
9237 cmdline_parse_token_string_t cmd_5tuple_filter_filter =
9238 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9239 filter, "5tuple_filter");
9240 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
9241 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9243 cmdline_parse_token_string_t cmd_5tuple_filter_ops =
9244 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9246 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
9247 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9249 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
9250 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
9252 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
9253 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9255 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
9256 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
9258 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
9259 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9260 dst_port, "dst_port");
9261 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
9262 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9263 dst_port_value, UINT16);
9264 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
9265 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9266 src_port, "src_port");
9267 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
9268 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9269 src_port_value, UINT16);
9270 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
9271 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9272 protocol, "protocol");
9273 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
9274 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9275 protocol_value, UINT8);
9276 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
9277 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9279 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
9280 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9282 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags =
9283 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9284 tcp_flags, "tcp_flags");
9285 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value =
9286 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9287 tcp_flags_value, UINT8);
9288 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
9289 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9290 priority, "priority");
9291 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
9292 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9293 priority_value, UINT8);
9294 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
9295 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9297 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
9298 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9301 cmdline_parse_inst_t cmd_5tuple_filter = {
9302 .f = cmd_5tuple_filter_parsed,
9304 .help_str = "5tuple_filter <port_id> add|del dst_ip <value> "
9305 "src_ip <value> dst_port <value> src_port <value> "
9306 "protocol <value> mask <value> tcp_flags <value> "
9307 "priority <value> queue <queue_id>: Add/Del a 5tuple filter",
9309 (void *)&cmd_5tuple_filter_filter,
9310 (void *)&cmd_5tuple_filter_port_id,
9311 (void *)&cmd_5tuple_filter_ops,
9312 (void *)&cmd_5tuple_filter_dst_ip,
9313 (void *)&cmd_5tuple_filter_dst_ip_value,
9314 (void *)&cmd_5tuple_filter_src_ip,
9315 (void *)&cmd_5tuple_filter_src_ip_value,
9316 (void *)&cmd_5tuple_filter_dst_port,
9317 (void *)&cmd_5tuple_filter_dst_port_value,
9318 (void *)&cmd_5tuple_filter_src_port,
9319 (void *)&cmd_5tuple_filter_src_port_value,
9320 (void *)&cmd_5tuple_filter_protocol,
9321 (void *)&cmd_5tuple_filter_protocol_value,
9322 (void *)&cmd_5tuple_filter_mask,
9323 (void *)&cmd_5tuple_filter_mask_value,
9324 (void *)&cmd_5tuple_filter_tcp_flags,
9325 (void *)&cmd_5tuple_filter_tcp_flags_value,
9326 (void *)&cmd_5tuple_filter_priority,
9327 (void *)&cmd_5tuple_filter_priority_value,
9328 (void *)&cmd_5tuple_filter_queue,
9329 (void *)&cmd_5tuple_filter_queue_id,
9334 /* *** ADD/REMOVE A flex FILTER *** */
9335 struct cmd_flex_filter_result {
9336 cmdline_fixed_string_t filter;
9337 cmdline_fixed_string_t ops;
9339 cmdline_fixed_string_t len;
9341 cmdline_fixed_string_t bytes;
9342 cmdline_fixed_string_t bytes_value;
9343 cmdline_fixed_string_t mask;
9344 cmdline_fixed_string_t mask_value;
9345 cmdline_fixed_string_t priority;
9346 uint8_t priority_value;
9347 cmdline_fixed_string_t queue;
9351 static int xdigit2val(unsigned char c)
9356 else if (isupper(c))
9364 cmd_flex_filter_parsed(void *parsed_result,
9365 __attribute__((unused)) struct cmdline *cl,
9366 __attribute__((unused)) void *data)
9369 struct rte_eth_flex_filter filter;
9370 struct cmd_flex_filter_result *res = parsed_result;
9371 char *bytes_ptr, *mask_ptr;
9372 uint16_t len, i, j = 0;
9377 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) {
9378 printf("the len exceed the max length 128\n");
9381 memset(&filter, 0, sizeof(struct rte_eth_flex_filter));
9382 filter.len = res->len_value;
9383 filter.priority = res->priority_value;
9384 filter.queue = res->queue_id;
9385 bytes_ptr = res->bytes_value;
9386 mask_ptr = res->mask_value;
9388 /* translate bytes string to array. */
9389 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
9390 (bytes_ptr[1] == 'X')))
9392 len = strnlen(bytes_ptr, res->len_value * 2);
9393 if (len == 0 || (len % 8 != 0)) {
9394 printf("please check len and bytes input\n");
9397 for (i = 0; i < len; i++) {
9399 if (isxdigit(c) == 0) {
9400 /* invalid characters. */
9401 printf("invalid input\n");
9404 val = xdigit2val(c);
9407 filter.bytes[j] = byte;
9408 printf("bytes[%d]:%02x ", j, filter.bytes[j]);
9415 /* translate mask string to uint8_t array. */
9416 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
9417 (mask_ptr[1] == 'X')))
9419 len = strnlen(mask_ptr, (res->len_value + 3) / 4);
9421 printf("invalid input\n");
9426 for (i = 0; i < len; i++) {
9428 if (isxdigit(c) == 0) {
9429 /* invalid characters. */
9430 printf("invalid input\n");
9433 val = xdigit2val(c);
9436 filter.mask[j] = byte;
9437 printf("mask[%d]:%02x ", j, filter.mask[j]);
9445 if (!strcmp(res->ops, "add"))
9446 ret = rte_eth_dev_filter_ctrl(res->port_id,
9447 RTE_ETH_FILTER_FLEXIBLE,
9451 ret = rte_eth_dev_filter_ctrl(res->port_id,
9452 RTE_ETH_FILTER_FLEXIBLE,
9453 RTE_ETH_FILTER_DELETE,
9457 printf("flex filter setting error: (%s)\n", strerror(-ret));
9460 cmdline_parse_token_string_t cmd_flex_filter_filter =
9461 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9462 filter, "flex_filter");
9463 cmdline_parse_token_num_t cmd_flex_filter_port_id =
9464 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
9466 cmdline_parse_token_string_t cmd_flex_filter_ops =
9467 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9469 cmdline_parse_token_string_t cmd_flex_filter_len =
9470 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9472 cmdline_parse_token_num_t cmd_flex_filter_len_value =
9473 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
9475 cmdline_parse_token_string_t cmd_flex_filter_bytes =
9476 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9478 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
9479 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9481 cmdline_parse_token_string_t cmd_flex_filter_mask =
9482 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9484 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
9485 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9487 cmdline_parse_token_string_t cmd_flex_filter_priority =
9488 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9489 priority, "priority");
9490 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
9491 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
9492 priority_value, UINT8);
9493 cmdline_parse_token_string_t cmd_flex_filter_queue =
9494 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9496 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
9497 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
9499 cmdline_parse_inst_t cmd_flex_filter = {
9500 .f = cmd_flex_filter_parsed,
9502 .help_str = "flex_filter <port_id> add|del len <value> bytes "
9503 "<value> mask <value> priority <value> queue <queue_id>: "
9504 "Add/Del a flex filter",
9506 (void *)&cmd_flex_filter_filter,
9507 (void *)&cmd_flex_filter_port_id,
9508 (void *)&cmd_flex_filter_ops,
9509 (void *)&cmd_flex_filter_len,
9510 (void *)&cmd_flex_filter_len_value,
9511 (void *)&cmd_flex_filter_bytes,
9512 (void *)&cmd_flex_filter_bytes_value,
9513 (void *)&cmd_flex_filter_mask,
9514 (void *)&cmd_flex_filter_mask_value,
9515 (void *)&cmd_flex_filter_priority,
9516 (void *)&cmd_flex_filter_priority_value,
9517 (void *)&cmd_flex_filter_queue,
9518 (void *)&cmd_flex_filter_queue_id,
9523 /* *** Filters Control *** */
9525 /* *** deal with ethertype filter *** */
9526 struct cmd_ethertype_filter_result {
9527 cmdline_fixed_string_t filter;
9529 cmdline_fixed_string_t ops;
9530 cmdline_fixed_string_t mac;
9531 struct ether_addr mac_addr;
9532 cmdline_fixed_string_t ethertype;
9533 uint16_t ethertype_value;
9534 cmdline_fixed_string_t drop;
9535 cmdline_fixed_string_t queue;
9539 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
9540 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9541 filter, "ethertype_filter");
9542 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
9543 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
9545 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
9546 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9548 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
9549 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9550 mac, "mac_addr#mac_ignr");
9551 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
9552 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
9554 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
9555 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9556 ethertype, "ethertype");
9557 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
9558 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
9559 ethertype_value, UINT16);
9560 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
9561 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9563 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
9564 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9566 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
9567 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
9571 cmd_ethertype_filter_parsed(void *parsed_result,
9572 __attribute__((unused)) struct cmdline *cl,
9573 __attribute__((unused)) void *data)
9575 struct cmd_ethertype_filter_result *res = parsed_result;
9576 struct rte_eth_ethertype_filter filter;
9579 ret = rte_eth_dev_filter_supported(res->port_id,
9580 RTE_ETH_FILTER_ETHERTYPE);
9582 printf("ethertype filter is not supported on port %u.\n",
9587 memset(&filter, 0, sizeof(filter));
9588 if (!strcmp(res->mac, "mac_addr")) {
9589 filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
9590 rte_memcpy(&filter.mac_addr, &res->mac_addr,
9591 sizeof(struct ether_addr));
9593 if (!strcmp(res->drop, "drop"))
9594 filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
9595 filter.ether_type = res->ethertype_value;
9596 filter.queue = res->queue_id;
9598 if (!strcmp(res->ops, "add"))
9599 ret = rte_eth_dev_filter_ctrl(res->port_id,
9600 RTE_ETH_FILTER_ETHERTYPE,
9604 ret = rte_eth_dev_filter_ctrl(res->port_id,
9605 RTE_ETH_FILTER_ETHERTYPE,
9606 RTE_ETH_FILTER_DELETE,
9609 printf("ethertype filter programming error: (%s)\n",
9613 cmdline_parse_inst_t cmd_ethertype_filter = {
9614 .f = cmd_ethertype_filter_parsed,
9616 .help_str = "ethertype_filter <port_id> add|del mac_addr|mac_ignr "
9617 "<mac_addr> ethertype <value> drop|fw queue <queue_id>: "
9618 "Add or delete an ethertype filter entry",
9620 (void *)&cmd_ethertype_filter_filter,
9621 (void *)&cmd_ethertype_filter_port_id,
9622 (void *)&cmd_ethertype_filter_ops,
9623 (void *)&cmd_ethertype_filter_mac,
9624 (void *)&cmd_ethertype_filter_mac_addr,
9625 (void *)&cmd_ethertype_filter_ethertype,
9626 (void *)&cmd_ethertype_filter_ethertype_value,
9627 (void *)&cmd_ethertype_filter_drop,
9628 (void *)&cmd_ethertype_filter_queue,
9629 (void *)&cmd_ethertype_filter_queue_id,
9634 /* *** deal with flow director filter *** */
9635 struct cmd_flow_director_result {
9636 cmdline_fixed_string_t flow_director_filter;
9638 cmdline_fixed_string_t mode;
9639 cmdline_fixed_string_t mode_value;
9640 cmdline_fixed_string_t ops;
9641 cmdline_fixed_string_t flow;
9642 cmdline_fixed_string_t flow_type;
9643 cmdline_fixed_string_t ether;
9644 uint16_t ether_type;
9645 cmdline_fixed_string_t src;
9646 cmdline_ipaddr_t ip_src;
9648 cmdline_fixed_string_t dst;
9649 cmdline_ipaddr_t ip_dst;
9651 cmdline_fixed_string_t verify_tag;
9652 uint32_t verify_tag_value;
9653 cmdline_ipaddr_t tos;
9655 cmdline_ipaddr_t proto;
9656 uint8_t proto_value;
9657 cmdline_ipaddr_t ttl;
9659 cmdline_fixed_string_t vlan;
9660 uint16_t vlan_value;
9661 cmdline_fixed_string_t flexbytes;
9662 cmdline_fixed_string_t flexbytes_value;
9663 cmdline_fixed_string_t pf_vf;
9664 cmdline_fixed_string_t drop;
9665 cmdline_fixed_string_t queue;
9667 cmdline_fixed_string_t fd_id;
9668 uint32_t fd_id_value;
9669 cmdline_fixed_string_t mac;
9670 struct ether_addr mac_addr;
9671 cmdline_fixed_string_t tunnel;
9672 cmdline_fixed_string_t tunnel_type;
9673 cmdline_fixed_string_t tunnel_id;
9674 uint32_t tunnel_id_value;
9678 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
9681 const char *p, *p0 = q_arg;
9683 unsigned long int_fld;
9684 char *str_fld[max_num];
9689 p = strchr(p0, '(');
9693 p0 = strchr(p, ')');
9698 if (size >= sizeof(s))
9701 snprintf(s, sizeof(s), "%.*s", size, p);
9702 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
9703 if (ret < 0 || ret > max_num)
9705 for (i = 0; i < ret; i++) {
9707 int_fld = strtoul(str_fld[i], &end, 0);
9708 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
9710 flexbytes[i] = (uint8_t)int_fld;
9716 str2flowtype(char *string)
9719 static const struct {
9722 } flowtype_str[] = {
9723 {"raw", RTE_ETH_FLOW_RAW},
9724 {"ipv4", RTE_ETH_FLOW_IPV4},
9725 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
9726 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
9727 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
9728 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
9729 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
9730 {"ipv6", RTE_ETH_FLOW_IPV6},
9731 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
9732 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
9733 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
9734 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
9735 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
9736 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
9739 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
9740 if (!strcmp(flowtype_str[i].str, string))
9741 return flowtype_str[i].type;
9744 if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64)
9745 return (uint16_t)atoi(string);
9747 return RTE_ETH_FLOW_UNKNOWN;
9750 static enum rte_eth_fdir_tunnel_type
9751 str2fdir_tunneltype(char *string)
9755 static const struct {
9757 enum rte_eth_fdir_tunnel_type type;
9758 } tunneltype_str[] = {
9759 {"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE},
9760 {"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN},
9763 for (i = 0; i < RTE_DIM(tunneltype_str); i++) {
9764 if (!strcmp(tunneltype_str[i].str, string))
9765 return tunneltype_str[i].type;
9767 return RTE_FDIR_TUNNEL_TYPE_UNKNOWN;
9770 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
9772 if ((ip_addr).family == AF_INET) \
9773 (ip) = (ip_addr).addr.ipv4.s_addr; \
9775 printf("invalid parameter.\n"); \
9780 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
9782 if ((ip_addr).family == AF_INET6) \
9784 &((ip_addr).addr.ipv6), \
9785 sizeof(struct in6_addr)); \
9787 printf("invalid parameter.\n"); \
9793 cmd_flow_director_filter_parsed(void *parsed_result,
9794 __attribute__((unused)) struct cmdline *cl,
9795 __attribute__((unused)) void *data)
9797 struct cmd_flow_director_result *res = parsed_result;
9798 struct rte_eth_fdir_filter entry;
9799 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
9801 unsigned long vf_id;
9804 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
9806 printf("flow director is not supported on port %u.\n",
9810 memset(flexbytes, 0, sizeof(flexbytes));
9811 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
9813 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
9814 if (strcmp(res->mode_value, "MAC-VLAN")) {
9815 printf("Please set mode to MAC-VLAN.\n");
9818 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
9819 if (strcmp(res->mode_value, "Tunnel")) {
9820 printf("Please set mode to Tunnel.\n");
9824 if (strcmp(res->mode_value, "IP")) {
9825 printf("Please set mode to IP.\n");
9828 entry.input.flow_type = str2flowtype(res->flow_type);
9831 ret = parse_flexbytes(res->flexbytes_value,
9833 RTE_ETH_FDIR_MAX_FLEXLEN);
9835 printf("error: Cannot parse flexbytes input.\n");
9839 switch (entry.input.flow_type) {
9840 case RTE_ETH_FLOW_FRAG_IPV4:
9841 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
9842 entry.input.flow.ip4_flow.proto = res->proto_value;
9844 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
9845 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
9846 IPV4_ADDR_TO_UINT(res->ip_dst,
9847 entry.input.flow.ip4_flow.dst_ip);
9848 IPV4_ADDR_TO_UINT(res->ip_src,
9849 entry.input.flow.ip4_flow.src_ip);
9850 entry.input.flow.ip4_flow.tos = res->tos_value;
9851 entry.input.flow.ip4_flow.ttl = res->ttl_value;
9852 /* need convert to big endian. */
9853 entry.input.flow.udp4_flow.dst_port =
9854 rte_cpu_to_be_16(res->port_dst);
9855 entry.input.flow.udp4_flow.src_port =
9856 rte_cpu_to_be_16(res->port_src);
9858 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
9859 IPV4_ADDR_TO_UINT(res->ip_dst,
9860 entry.input.flow.sctp4_flow.ip.dst_ip);
9861 IPV4_ADDR_TO_UINT(res->ip_src,
9862 entry.input.flow.sctp4_flow.ip.src_ip);
9863 entry.input.flow.ip4_flow.tos = res->tos_value;
9864 entry.input.flow.ip4_flow.ttl = res->ttl_value;
9865 /* need convert to big endian. */
9866 entry.input.flow.sctp4_flow.dst_port =
9867 rte_cpu_to_be_16(res->port_dst);
9868 entry.input.flow.sctp4_flow.src_port =
9869 rte_cpu_to_be_16(res->port_src);
9870 entry.input.flow.sctp4_flow.verify_tag =
9871 rte_cpu_to_be_32(res->verify_tag_value);
9873 case RTE_ETH_FLOW_FRAG_IPV6:
9874 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
9875 entry.input.flow.ipv6_flow.proto = res->proto_value;
9877 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
9878 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
9879 IPV6_ADDR_TO_ARRAY(res->ip_dst,
9880 entry.input.flow.ipv6_flow.dst_ip);
9881 IPV6_ADDR_TO_ARRAY(res->ip_src,
9882 entry.input.flow.ipv6_flow.src_ip);
9883 entry.input.flow.ipv6_flow.tc = res->tos_value;
9884 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
9885 /* need convert to big endian. */
9886 entry.input.flow.udp6_flow.dst_port =
9887 rte_cpu_to_be_16(res->port_dst);
9888 entry.input.flow.udp6_flow.src_port =
9889 rte_cpu_to_be_16(res->port_src);
9891 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
9892 IPV6_ADDR_TO_ARRAY(res->ip_dst,
9893 entry.input.flow.sctp6_flow.ip.dst_ip);
9894 IPV6_ADDR_TO_ARRAY(res->ip_src,
9895 entry.input.flow.sctp6_flow.ip.src_ip);
9896 entry.input.flow.ipv6_flow.tc = res->tos_value;
9897 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
9898 /* need convert to big endian. */
9899 entry.input.flow.sctp6_flow.dst_port =
9900 rte_cpu_to_be_16(res->port_dst);
9901 entry.input.flow.sctp6_flow.src_port =
9902 rte_cpu_to_be_16(res->port_src);
9903 entry.input.flow.sctp6_flow.verify_tag =
9904 rte_cpu_to_be_32(res->verify_tag_value);
9906 case RTE_ETH_FLOW_L2_PAYLOAD:
9907 entry.input.flow.l2_flow.ether_type =
9908 rte_cpu_to_be_16(res->ether_type);
9914 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN)
9915 rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr,
9917 sizeof(struct ether_addr));
9919 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
9920 rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr,
9922 sizeof(struct ether_addr));
9923 entry.input.flow.tunnel_flow.tunnel_type =
9924 str2fdir_tunneltype(res->tunnel_type);
9925 entry.input.flow.tunnel_flow.tunnel_id =
9926 rte_cpu_to_be_32(res->tunnel_id_value);
9929 rte_memcpy(entry.input.flow_ext.flexbytes,
9931 RTE_ETH_FDIR_MAX_FLEXLEN);
9933 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
9935 entry.action.flex_off = 0; /*use 0 by default */
9936 if (!strcmp(res->drop, "drop"))
9937 entry.action.behavior = RTE_ETH_FDIR_REJECT;
9939 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
9941 if (fdir_conf.mode != RTE_FDIR_MODE_PERFECT_MAC_VLAN &&
9942 fdir_conf.mode != RTE_FDIR_MODE_PERFECT_TUNNEL) {
9943 if (!strcmp(res->pf_vf, "pf"))
9944 entry.input.flow_ext.is_vf = 0;
9945 else if (!strncmp(res->pf_vf, "vf", 2)) {
9946 struct rte_eth_dev_info dev_info;
9948 memset(&dev_info, 0, sizeof(dev_info));
9949 rte_eth_dev_info_get(res->port_id, &dev_info);
9951 vf_id = strtoul(res->pf_vf + 2, &end, 10);
9952 if (errno != 0 || *end != '\0' ||
9953 vf_id >= dev_info.max_vfs) {
9954 printf("invalid parameter %s.\n", res->pf_vf);
9957 entry.input.flow_ext.is_vf = 1;
9958 entry.input.flow_ext.dst_id = (uint16_t)vf_id;
9960 printf("invalid parameter %s.\n", res->pf_vf);
9965 /* set to report FD ID by default */
9966 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
9967 entry.action.rx_queue = res->queue_id;
9968 entry.soft_id = res->fd_id_value;
9969 if (!strcmp(res->ops, "add"))
9970 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
9971 RTE_ETH_FILTER_ADD, &entry);
9972 else if (!strcmp(res->ops, "del"))
9973 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
9974 RTE_ETH_FILTER_DELETE, &entry);
9976 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
9977 RTE_ETH_FILTER_UPDATE, &entry);
9979 printf("flow director programming error: (%s)\n",
9983 cmdline_parse_token_string_t cmd_flow_director_filter =
9984 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9985 flow_director_filter, "flow_director_filter");
9986 cmdline_parse_token_num_t cmd_flow_director_port_id =
9987 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
9989 cmdline_parse_token_string_t cmd_flow_director_ops =
9990 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9991 ops, "add#del#update");
9992 cmdline_parse_token_string_t cmd_flow_director_flow =
9993 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9995 cmdline_parse_token_string_t cmd_flow_director_flow_type =
9996 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
9997 flow_type, "ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
9998 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload");
9999 cmdline_parse_token_string_t cmd_flow_director_ether =
10000 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10002 cmdline_parse_token_num_t cmd_flow_director_ether_type =
10003 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10004 ether_type, UINT16);
10005 cmdline_parse_token_string_t cmd_flow_director_src =
10006 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10008 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
10009 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
10011 cmdline_parse_token_num_t cmd_flow_director_port_src =
10012 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10014 cmdline_parse_token_string_t cmd_flow_director_dst =
10015 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10017 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
10018 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
10020 cmdline_parse_token_num_t cmd_flow_director_port_dst =
10021 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10023 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
10024 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10025 verify_tag, "verify_tag");
10026 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
10027 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10028 verify_tag_value, UINT32);
10029 cmdline_parse_token_string_t cmd_flow_director_tos =
10030 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10032 cmdline_parse_token_num_t cmd_flow_director_tos_value =
10033 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10035 cmdline_parse_token_string_t cmd_flow_director_proto =
10036 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10038 cmdline_parse_token_num_t cmd_flow_director_proto_value =
10039 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10040 proto_value, UINT8);
10041 cmdline_parse_token_string_t cmd_flow_director_ttl =
10042 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10044 cmdline_parse_token_num_t cmd_flow_director_ttl_value =
10045 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10047 cmdline_parse_token_string_t cmd_flow_director_vlan =
10048 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10050 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
10051 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10052 vlan_value, UINT16);
10053 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
10054 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10055 flexbytes, "flexbytes");
10056 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
10057 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10058 flexbytes_value, NULL);
10059 cmdline_parse_token_string_t cmd_flow_director_drop =
10060 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10062 cmdline_parse_token_string_t cmd_flow_director_pf_vf =
10063 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10065 cmdline_parse_token_string_t cmd_flow_director_queue =
10066 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10068 cmdline_parse_token_num_t cmd_flow_director_queue_id =
10069 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10071 cmdline_parse_token_string_t cmd_flow_director_fd_id =
10072 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10074 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
10075 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10076 fd_id_value, UINT32);
10078 cmdline_parse_token_string_t cmd_flow_director_mode =
10079 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10081 cmdline_parse_token_string_t cmd_flow_director_mode_ip =
10082 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10084 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan =
10085 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10086 mode_value, "MAC-VLAN");
10087 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel =
10088 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10089 mode_value, "Tunnel");
10090 cmdline_parse_token_string_t cmd_flow_director_mac =
10091 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10093 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr =
10094 TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result,
10096 cmdline_parse_token_string_t cmd_flow_director_tunnel =
10097 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10099 cmdline_parse_token_string_t cmd_flow_director_tunnel_type =
10100 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10101 tunnel_type, "NVGRE#VxLAN");
10102 cmdline_parse_token_string_t cmd_flow_director_tunnel_id =
10103 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10104 tunnel_id, "tunnel-id");
10105 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value =
10106 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10107 tunnel_id_value, UINT32);
10109 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
10110 .f = cmd_flow_director_filter_parsed,
10112 .help_str = "flow_director_filter <port_id> mode IP add|del|update flow"
10113 " ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
10114 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
10115 "l2_payload src <src_ip> dst <dst_ip> tos <tos_value> "
10116 "proto <proto_value> ttl <ttl_value> vlan <vlan_value> "
10117 "flexbytes <flexbyte_vaues> drop|fw <pf_vf> queue <queue_id> "
10118 "fd_id <fd_id_value>: "
10119 "Add or delete an ip flow director entry on NIC",
10121 (void *)&cmd_flow_director_filter,
10122 (void *)&cmd_flow_director_port_id,
10123 (void *)&cmd_flow_director_mode,
10124 (void *)&cmd_flow_director_mode_ip,
10125 (void *)&cmd_flow_director_ops,
10126 (void *)&cmd_flow_director_flow,
10127 (void *)&cmd_flow_director_flow_type,
10128 (void *)&cmd_flow_director_src,
10129 (void *)&cmd_flow_director_ip_src,
10130 (void *)&cmd_flow_director_dst,
10131 (void *)&cmd_flow_director_ip_dst,
10132 (void *)&cmd_flow_director_tos,
10133 (void *)&cmd_flow_director_tos_value,
10134 (void *)&cmd_flow_director_proto,
10135 (void *)&cmd_flow_director_proto_value,
10136 (void *)&cmd_flow_director_ttl,
10137 (void *)&cmd_flow_director_ttl_value,
10138 (void *)&cmd_flow_director_vlan,
10139 (void *)&cmd_flow_director_vlan_value,
10140 (void *)&cmd_flow_director_flexbytes,
10141 (void *)&cmd_flow_director_flexbytes_value,
10142 (void *)&cmd_flow_director_drop,
10143 (void *)&cmd_flow_director_pf_vf,
10144 (void *)&cmd_flow_director_queue,
10145 (void *)&cmd_flow_director_queue_id,
10146 (void *)&cmd_flow_director_fd_id,
10147 (void *)&cmd_flow_director_fd_id_value,
10152 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
10153 .f = cmd_flow_director_filter_parsed,
10155 .help_str = "flow_director_filter ... : Add or delete an udp/tcp flow "
10156 "director entry on NIC",
10158 (void *)&cmd_flow_director_filter,
10159 (void *)&cmd_flow_director_port_id,
10160 (void *)&cmd_flow_director_mode,
10161 (void *)&cmd_flow_director_mode_ip,
10162 (void *)&cmd_flow_director_ops,
10163 (void *)&cmd_flow_director_flow,
10164 (void *)&cmd_flow_director_flow_type,
10165 (void *)&cmd_flow_director_src,
10166 (void *)&cmd_flow_director_ip_src,
10167 (void *)&cmd_flow_director_port_src,
10168 (void *)&cmd_flow_director_dst,
10169 (void *)&cmd_flow_director_ip_dst,
10170 (void *)&cmd_flow_director_port_dst,
10171 (void *)&cmd_flow_director_tos,
10172 (void *)&cmd_flow_director_tos_value,
10173 (void *)&cmd_flow_director_ttl,
10174 (void *)&cmd_flow_director_ttl_value,
10175 (void *)&cmd_flow_director_vlan,
10176 (void *)&cmd_flow_director_vlan_value,
10177 (void *)&cmd_flow_director_flexbytes,
10178 (void *)&cmd_flow_director_flexbytes_value,
10179 (void *)&cmd_flow_director_drop,
10180 (void *)&cmd_flow_director_pf_vf,
10181 (void *)&cmd_flow_director_queue,
10182 (void *)&cmd_flow_director_queue_id,
10183 (void *)&cmd_flow_director_fd_id,
10184 (void *)&cmd_flow_director_fd_id_value,
10189 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
10190 .f = cmd_flow_director_filter_parsed,
10192 .help_str = "flow_director_filter ... : Add or delete a sctp flow "
10193 "director entry on NIC",
10195 (void *)&cmd_flow_director_filter,
10196 (void *)&cmd_flow_director_port_id,
10197 (void *)&cmd_flow_director_mode,
10198 (void *)&cmd_flow_director_mode_ip,
10199 (void *)&cmd_flow_director_ops,
10200 (void *)&cmd_flow_director_flow,
10201 (void *)&cmd_flow_director_flow_type,
10202 (void *)&cmd_flow_director_src,
10203 (void *)&cmd_flow_director_ip_src,
10204 (void *)&cmd_flow_director_port_dst,
10205 (void *)&cmd_flow_director_dst,
10206 (void *)&cmd_flow_director_ip_dst,
10207 (void *)&cmd_flow_director_port_dst,
10208 (void *)&cmd_flow_director_verify_tag,
10209 (void *)&cmd_flow_director_verify_tag_value,
10210 (void *)&cmd_flow_director_tos,
10211 (void *)&cmd_flow_director_tos_value,
10212 (void *)&cmd_flow_director_ttl,
10213 (void *)&cmd_flow_director_ttl_value,
10214 (void *)&cmd_flow_director_vlan,
10215 (void *)&cmd_flow_director_vlan_value,
10216 (void *)&cmd_flow_director_flexbytes,
10217 (void *)&cmd_flow_director_flexbytes_value,
10218 (void *)&cmd_flow_director_drop,
10219 (void *)&cmd_flow_director_pf_vf,
10220 (void *)&cmd_flow_director_queue,
10221 (void *)&cmd_flow_director_queue_id,
10222 (void *)&cmd_flow_director_fd_id,
10223 (void *)&cmd_flow_director_fd_id_value,
10228 cmdline_parse_inst_t cmd_add_del_l2_flow_director = {
10229 .f = cmd_flow_director_filter_parsed,
10231 .help_str = "flow_director_filter ... : Add or delete a L2 flow "
10232 "director entry on NIC",
10234 (void *)&cmd_flow_director_filter,
10235 (void *)&cmd_flow_director_port_id,
10236 (void *)&cmd_flow_director_mode,
10237 (void *)&cmd_flow_director_mode_ip,
10238 (void *)&cmd_flow_director_ops,
10239 (void *)&cmd_flow_director_flow,
10240 (void *)&cmd_flow_director_flow_type,
10241 (void *)&cmd_flow_director_ether,
10242 (void *)&cmd_flow_director_ether_type,
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_mac_vlan_flow_director = {
10256 .f = cmd_flow_director_filter_parsed,
10258 .help_str = "flow_director_filter ... : Add or delete a MAC VLAN 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_mac_vlan,
10265 (void *)&cmd_flow_director_ops,
10266 (void *)&cmd_flow_director_mac,
10267 (void *)&cmd_flow_director_mac_addr,
10268 (void *)&cmd_flow_director_vlan,
10269 (void *)&cmd_flow_director_vlan_value,
10270 (void *)&cmd_flow_director_flexbytes,
10271 (void *)&cmd_flow_director_flexbytes_value,
10272 (void *)&cmd_flow_director_drop,
10273 (void *)&cmd_flow_director_queue,
10274 (void *)&cmd_flow_director_queue_id,
10275 (void *)&cmd_flow_director_fd_id,
10276 (void *)&cmd_flow_director_fd_id_value,
10281 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = {
10282 .f = cmd_flow_director_filter_parsed,
10284 .help_str = "flow_director_filter ... : Add or delete a tunnel flow "
10285 "director entry on NIC",
10287 (void *)&cmd_flow_director_filter,
10288 (void *)&cmd_flow_director_port_id,
10289 (void *)&cmd_flow_director_mode,
10290 (void *)&cmd_flow_director_mode_tunnel,
10291 (void *)&cmd_flow_director_ops,
10292 (void *)&cmd_flow_director_mac,
10293 (void *)&cmd_flow_director_mac_addr,
10294 (void *)&cmd_flow_director_vlan,
10295 (void *)&cmd_flow_director_vlan_value,
10296 (void *)&cmd_flow_director_tunnel,
10297 (void *)&cmd_flow_director_tunnel_type,
10298 (void *)&cmd_flow_director_tunnel_id,
10299 (void *)&cmd_flow_director_tunnel_id_value,
10300 (void *)&cmd_flow_director_flexbytes,
10301 (void *)&cmd_flow_director_flexbytes_value,
10302 (void *)&cmd_flow_director_drop,
10303 (void *)&cmd_flow_director_queue,
10304 (void *)&cmd_flow_director_queue_id,
10305 (void *)&cmd_flow_director_fd_id,
10306 (void *)&cmd_flow_director_fd_id_value,
10311 struct cmd_flush_flow_director_result {
10312 cmdline_fixed_string_t flush_flow_director;
10316 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
10317 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
10318 flush_flow_director, "flush_flow_director");
10319 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
10320 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
10324 cmd_flush_flow_director_parsed(void *parsed_result,
10325 __attribute__((unused)) struct cmdline *cl,
10326 __attribute__((unused)) void *data)
10328 struct cmd_flow_director_result *res = parsed_result;
10331 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
10333 printf("flow director is not supported on port %u.\n",
10338 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10339 RTE_ETH_FILTER_FLUSH, NULL);
10341 printf("flow director table flushing error: (%s)\n",
10345 cmdline_parse_inst_t cmd_flush_flow_director = {
10346 .f = cmd_flush_flow_director_parsed,
10348 .help_str = "flush_flow_director <port_id>: "
10349 "Flush all flow director entries of a device on NIC",
10351 (void *)&cmd_flush_flow_director_flush,
10352 (void *)&cmd_flush_flow_director_port_id,
10357 /* *** deal with flow director mask *** */
10358 struct cmd_flow_director_mask_result {
10359 cmdline_fixed_string_t flow_director_mask;
10361 cmdline_fixed_string_t mode;
10362 cmdline_fixed_string_t mode_value;
10363 cmdline_fixed_string_t vlan;
10364 uint16_t vlan_mask;
10365 cmdline_fixed_string_t src_mask;
10366 cmdline_ipaddr_t ipv4_src;
10367 cmdline_ipaddr_t ipv6_src;
10369 cmdline_fixed_string_t dst_mask;
10370 cmdline_ipaddr_t ipv4_dst;
10371 cmdline_ipaddr_t ipv6_dst;
10373 cmdline_fixed_string_t mac;
10374 uint8_t mac_addr_byte_mask;
10375 cmdline_fixed_string_t tunnel_id;
10376 uint32_t tunnel_id_mask;
10377 cmdline_fixed_string_t tunnel_type;
10378 uint8_t tunnel_type_mask;
10382 cmd_flow_director_mask_parsed(void *parsed_result,
10383 __attribute__((unused)) struct cmdline *cl,
10384 __attribute__((unused)) void *data)
10386 struct cmd_flow_director_mask_result *res = parsed_result;
10387 struct rte_eth_fdir_masks *mask;
10388 struct rte_port *port;
10390 if (res->port_id > nb_ports) {
10391 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
10395 port = &ports[res->port_id];
10396 /** Check if the port is not started **/
10397 if (port->port_status != RTE_PORT_STOPPED) {
10398 printf("Please stop port %d first\n", res->port_id);
10402 mask = &port->dev_conf.fdir_conf.mask;
10404 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
10405 if (strcmp(res->mode_value, "MAC-VLAN")) {
10406 printf("Please set mode to MAC-VLAN.\n");
10410 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10411 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
10412 if (strcmp(res->mode_value, "Tunnel")) {
10413 printf("Please set mode to Tunnel.\n");
10417 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10418 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
10419 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
10420 mask->tunnel_type_mask = res->tunnel_type_mask;
10422 if (strcmp(res->mode_value, "IP")) {
10423 printf("Please set mode to IP.\n");
10427 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10428 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
10429 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
10430 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
10431 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
10432 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
10433 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
10436 cmd_reconfig_device_queue(res->port_id, 1, 1);
10439 cmdline_parse_token_string_t cmd_flow_director_mask =
10440 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10441 flow_director_mask, "flow_director_mask");
10442 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
10443 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10445 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
10446 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10448 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
10449 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10450 vlan_mask, UINT16);
10451 cmdline_parse_token_string_t cmd_flow_director_mask_src =
10452 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10453 src_mask, "src_mask");
10454 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
10455 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10457 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
10458 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10460 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
10461 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10463 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
10464 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10465 dst_mask, "dst_mask");
10466 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
10467 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10469 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
10470 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10472 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
10473 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10476 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
10477 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10479 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
10480 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10482 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
10483 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10484 mode_value, "MAC-VLAN");
10485 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
10486 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10487 mode_value, "Tunnel");
10488 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
10489 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10491 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
10492 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10493 mac_addr_byte_mask, UINT8);
10494 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
10495 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10496 tunnel_type, "tunnel-type");
10497 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
10498 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10499 tunnel_type_mask, UINT8);
10500 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
10501 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10502 tunnel_id, "tunnel-id");
10503 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
10504 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10505 tunnel_id_mask, UINT32);
10507 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
10508 .f = cmd_flow_director_mask_parsed,
10510 .help_str = "flow_director_mask ... : "
10511 "Set IP mode flow director's mask on NIC",
10513 (void *)&cmd_flow_director_mask,
10514 (void *)&cmd_flow_director_mask_port_id,
10515 (void *)&cmd_flow_director_mask_mode,
10516 (void *)&cmd_flow_director_mask_mode_ip,
10517 (void *)&cmd_flow_director_mask_vlan,
10518 (void *)&cmd_flow_director_mask_vlan_value,
10519 (void *)&cmd_flow_director_mask_src,
10520 (void *)&cmd_flow_director_mask_ipv4_src,
10521 (void *)&cmd_flow_director_mask_ipv6_src,
10522 (void *)&cmd_flow_director_mask_port_src,
10523 (void *)&cmd_flow_director_mask_dst,
10524 (void *)&cmd_flow_director_mask_ipv4_dst,
10525 (void *)&cmd_flow_director_mask_ipv6_dst,
10526 (void *)&cmd_flow_director_mask_port_dst,
10531 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
10532 .f = cmd_flow_director_mask_parsed,
10534 .help_str = "flow_director_mask ... : Set MAC VLAN mode "
10535 "flow director's mask on NIC",
10537 (void *)&cmd_flow_director_mask,
10538 (void *)&cmd_flow_director_mask_port_id,
10539 (void *)&cmd_flow_director_mask_mode,
10540 (void *)&cmd_flow_director_mask_mode_mac_vlan,
10541 (void *)&cmd_flow_director_mask_vlan,
10542 (void *)&cmd_flow_director_mask_vlan_value,
10547 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
10548 .f = cmd_flow_director_mask_parsed,
10550 .help_str = "flow_director_mask ... : Set tunnel mode "
10551 "flow director's mask on NIC",
10553 (void *)&cmd_flow_director_mask,
10554 (void *)&cmd_flow_director_mask_port_id,
10555 (void *)&cmd_flow_director_mask_mode,
10556 (void *)&cmd_flow_director_mask_mode_tunnel,
10557 (void *)&cmd_flow_director_mask_vlan,
10558 (void *)&cmd_flow_director_mask_vlan_value,
10559 (void *)&cmd_flow_director_mask_mac,
10560 (void *)&cmd_flow_director_mask_mac_value,
10561 (void *)&cmd_flow_director_mask_tunnel_type,
10562 (void *)&cmd_flow_director_mask_tunnel_type_value,
10563 (void *)&cmd_flow_director_mask_tunnel_id,
10564 (void *)&cmd_flow_director_mask_tunnel_id_value,
10569 /* *** deal with flow director mask on flexible payload *** */
10570 struct cmd_flow_director_flex_mask_result {
10571 cmdline_fixed_string_t flow_director_flexmask;
10573 cmdline_fixed_string_t flow;
10574 cmdline_fixed_string_t flow_type;
10575 cmdline_fixed_string_t mask;
10579 cmd_flow_director_flex_mask_parsed(void *parsed_result,
10580 __attribute__((unused)) struct cmdline *cl,
10581 __attribute__((unused)) void *data)
10583 struct cmd_flow_director_flex_mask_result *res = parsed_result;
10584 struct rte_eth_fdir_info fdir_info;
10585 struct rte_eth_fdir_flex_mask flex_mask;
10586 struct rte_port *port;
10587 uint32_t flow_type_mask;
10591 if (res->port_id > nb_ports) {
10592 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
10596 port = &ports[res->port_id];
10597 /** Check if the port is not started **/
10598 if (port->port_status != RTE_PORT_STOPPED) {
10599 printf("Please stop port %d first\n", res->port_id);
10603 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
10604 ret = parse_flexbytes(res->mask,
10606 RTE_ETH_FDIR_MAX_FLEXLEN);
10608 printf("error: Cannot parse mask input.\n");
10612 memset(&fdir_info, 0, sizeof(fdir_info));
10613 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10614 RTE_ETH_FILTER_INFO, &fdir_info);
10616 printf("Cannot get FDir filter info\n");
10620 if (!strcmp(res->flow_type, "none")) {
10621 /* means don't specify the flow type */
10622 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN;
10623 for (i = 0; i < RTE_ETH_FLOW_MAX; i++)
10624 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i],
10625 0, sizeof(struct rte_eth_fdir_flex_mask));
10626 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1;
10627 rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0],
10629 sizeof(struct rte_eth_fdir_flex_mask));
10630 cmd_reconfig_device_queue(res->port_id, 1, 1);
10633 flow_type_mask = fdir_info.flow_types_mask[0];
10634 if (!strcmp(res->flow_type, "all")) {
10635 if (!flow_type_mask) {
10636 printf("No flow type supported\n");
10639 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
10640 if (flow_type_mask & (1 << i)) {
10641 flex_mask.flow_type = i;
10642 fdir_set_flex_mask(res->port_id, &flex_mask);
10645 cmd_reconfig_device_queue(res->port_id, 1, 1);
10648 flex_mask.flow_type = str2flowtype(res->flow_type);
10649 if (!(flow_type_mask & (1 << flex_mask.flow_type))) {
10650 printf("Flow type %s not supported on port %d\n",
10651 res->flow_type, res->port_id);
10654 fdir_set_flex_mask(res->port_id, &flex_mask);
10655 cmd_reconfig_device_queue(res->port_id, 1, 1);
10658 cmdline_parse_token_string_t cmd_flow_director_flexmask =
10659 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
10660 flow_director_flexmask,
10661 "flow_director_flex_mask");
10662 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
10663 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
10665 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
10666 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
10668 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
10669 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
10670 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
10671 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all");
10672 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
10673 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
10676 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
10677 .f = cmd_flow_director_flex_mask_parsed,
10679 .help_str = "flow_director_flex_mask ... : "
10680 "Set flow director's flex mask on NIC",
10682 (void *)&cmd_flow_director_flexmask,
10683 (void *)&cmd_flow_director_flexmask_port_id,
10684 (void *)&cmd_flow_director_flexmask_flow,
10685 (void *)&cmd_flow_director_flexmask_flow_type,
10686 (void *)&cmd_flow_director_flexmask_mask,
10691 /* *** deal with flow director flexible payload configuration *** */
10692 struct cmd_flow_director_flexpayload_result {
10693 cmdline_fixed_string_t flow_director_flexpayload;
10695 cmdline_fixed_string_t payload_layer;
10696 cmdline_fixed_string_t payload_cfg;
10700 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
10703 const char *p, *p0 = q_arg;
10705 unsigned long int_fld;
10706 char *str_fld[max_num];
10711 p = strchr(p0, '(');
10715 p0 = strchr(p, ')');
10720 if (size >= sizeof(s))
10723 snprintf(s, sizeof(s), "%.*s", size, p);
10724 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
10725 if (ret < 0 || ret > max_num)
10727 for (i = 0; i < ret; i++) {
10729 int_fld = strtoul(str_fld[i], &end, 0);
10730 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
10732 offsets[i] = (uint16_t)int_fld;
10738 cmd_flow_director_flxpld_parsed(void *parsed_result,
10739 __attribute__((unused)) struct cmdline *cl,
10740 __attribute__((unused)) void *data)
10742 struct cmd_flow_director_flexpayload_result *res = parsed_result;
10743 struct rte_eth_flex_payload_cfg flex_cfg;
10744 struct rte_port *port;
10747 if (res->port_id > nb_ports) {
10748 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
10752 port = &ports[res->port_id];
10753 /** Check if the port is not started **/
10754 if (port->port_status != RTE_PORT_STOPPED) {
10755 printf("Please stop port %d first\n", res->port_id);
10759 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
10761 if (!strcmp(res->payload_layer, "raw"))
10762 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
10763 else if (!strcmp(res->payload_layer, "l2"))
10764 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
10765 else if (!strcmp(res->payload_layer, "l3"))
10766 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
10767 else if (!strcmp(res->payload_layer, "l4"))
10768 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
10770 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
10771 RTE_ETH_FDIR_MAX_FLEXLEN);
10773 printf("error: Cannot parse flex payload input.\n");
10777 fdir_set_flex_payload(res->port_id, &flex_cfg);
10778 cmd_reconfig_device_queue(res->port_id, 1, 1);
10781 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
10782 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10783 flow_director_flexpayload,
10784 "flow_director_flex_payload");
10785 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
10786 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10788 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
10789 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10790 payload_layer, "raw#l2#l3#l4");
10791 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
10792 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10793 payload_cfg, NULL);
10795 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
10796 .f = cmd_flow_director_flxpld_parsed,
10798 .help_str = "flow_director_flexpayload ... : "
10799 "Set flow director's flex payload on NIC",
10801 (void *)&cmd_flow_director_flexpayload,
10802 (void *)&cmd_flow_director_flexpayload_port_id,
10803 (void *)&cmd_flow_director_flexpayload_payload_layer,
10804 (void *)&cmd_flow_director_flexpayload_payload_cfg,
10809 /* Generic flow interface command. */
10810 extern cmdline_parse_inst_t cmd_flow;
10812 /* *** Classification Filters Control *** */
10813 /* *** Get symmetric hash enable per port *** */
10814 struct cmd_get_sym_hash_ena_per_port_result {
10815 cmdline_fixed_string_t get_sym_hash_ena_per_port;
10820 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
10821 __rte_unused struct cmdline *cl,
10822 __rte_unused void *data)
10824 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
10825 struct rte_eth_hash_filter_info info;
10828 if (rte_eth_dev_filter_supported(res->port_id,
10829 RTE_ETH_FILTER_HASH) < 0) {
10830 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
10835 memset(&info, 0, sizeof(info));
10836 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
10837 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
10838 RTE_ETH_FILTER_GET, &info);
10841 printf("Cannot get symmetric hash enable per port "
10842 "on port %u\n", res->port_id);
10846 printf("Symmetric hash is %s on port %u\n", info.info.enable ?
10847 "enabled" : "disabled", res->port_id);
10850 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
10851 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
10852 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
10853 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
10854 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
10857 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
10858 .f = cmd_get_sym_hash_per_port_parsed,
10860 .help_str = "get_sym_hash_ena_per_port <port_id>",
10862 (void *)&cmd_get_sym_hash_ena_per_port_all,
10863 (void *)&cmd_get_sym_hash_ena_per_port_port_id,
10868 /* *** Set symmetric hash enable per port *** */
10869 struct cmd_set_sym_hash_ena_per_port_result {
10870 cmdline_fixed_string_t set_sym_hash_ena_per_port;
10871 cmdline_fixed_string_t enable;
10876 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
10877 __rte_unused struct cmdline *cl,
10878 __rte_unused void *data)
10880 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
10881 struct rte_eth_hash_filter_info info;
10884 if (rte_eth_dev_filter_supported(res->port_id,
10885 RTE_ETH_FILTER_HASH) < 0) {
10886 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
10891 memset(&info, 0, sizeof(info));
10892 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
10893 if (!strcmp(res->enable, "enable"))
10894 info.info.enable = 1;
10895 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
10896 RTE_ETH_FILTER_SET, &info);
10898 printf("Cannot set symmetric hash enable per port on "
10899 "port %u\n", res->port_id);
10902 printf("Symmetric hash has been set to %s on port %u\n",
10903 res->enable, res->port_id);
10906 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
10907 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
10908 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
10909 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
10910 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
10912 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
10913 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
10914 enable, "enable#disable");
10916 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
10917 .f = cmd_set_sym_hash_per_port_parsed,
10919 .help_str = "set_sym_hash_ena_per_port <port_id> enable|disable",
10921 (void *)&cmd_set_sym_hash_ena_per_port_all,
10922 (void *)&cmd_set_sym_hash_ena_per_port_port_id,
10923 (void *)&cmd_set_sym_hash_ena_per_port_enable,
10928 /* Get global config of hash function */
10929 struct cmd_get_hash_global_config_result {
10930 cmdline_fixed_string_t get_hash_global_config;
10935 flowtype_to_str(uint16_t ftype)
10941 } ftype_table[] = {
10942 {"ipv4", RTE_ETH_FLOW_IPV4},
10943 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
10944 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
10945 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
10946 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
10947 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
10948 {"ipv6", RTE_ETH_FLOW_IPV6},
10949 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
10950 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
10951 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
10952 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
10953 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
10954 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
10955 {"port", RTE_ETH_FLOW_PORT},
10956 {"vxlan", RTE_ETH_FLOW_VXLAN},
10957 {"geneve", RTE_ETH_FLOW_GENEVE},
10958 {"nvgre", RTE_ETH_FLOW_NVGRE},
10961 for (i = 0; i < RTE_DIM(ftype_table); i++) {
10962 if (ftype_table[i].ftype == ftype)
10963 return ftype_table[i].str;
10970 cmd_get_hash_global_config_parsed(void *parsed_result,
10971 __rte_unused struct cmdline *cl,
10972 __rte_unused void *data)
10974 struct cmd_get_hash_global_config_result *res = parsed_result;
10975 struct rte_eth_hash_filter_info info;
10976 uint32_t idx, offset;
10981 if (rte_eth_dev_filter_supported(res->port_id,
10982 RTE_ETH_FILTER_HASH) < 0) {
10983 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
10988 memset(&info, 0, sizeof(info));
10989 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
10990 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
10991 RTE_ETH_FILTER_GET, &info);
10993 printf("Cannot get hash global configurations by port %d\n",
10998 switch (info.info.global_conf.hash_func) {
10999 case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
11000 printf("Hash function is Toeplitz\n");
11002 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
11003 printf("Hash function is Simple XOR\n");
11006 printf("Unknown hash function\n");
11010 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) {
11011 idx = i / UINT32_BIT;
11012 offset = i % UINT32_BIT;
11013 if (!(info.info.global_conf.valid_bit_mask[idx] &
11016 str = flowtype_to_str(i);
11019 printf("Symmetric hash is %s globally for flow type %s "
11021 ((info.info.global_conf.sym_hash_enable_mask[idx] &
11022 (1UL << offset)) ? "enabled" : "disabled"), str,
11027 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
11028 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
11029 get_hash_global_config, "get_hash_global_config");
11030 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
11031 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
11034 cmdline_parse_inst_t cmd_get_hash_global_config = {
11035 .f = cmd_get_hash_global_config_parsed,
11037 .help_str = "get_hash_global_config <port_id>",
11039 (void *)&cmd_get_hash_global_config_all,
11040 (void *)&cmd_get_hash_global_config_port_id,
11045 /* Set global config of hash function */
11046 struct cmd_set_hash_global_config_result {
11047 cmdline_fixed_string_t set_hash_global_config;
11049 cmdline_fixed_string_t hash_func;
11050 cmdline_fixed_string_t flow_type;
11051 cmdline_fixed_string_t enable;
11055 cmd_set_hash_global_config_parsed(void *parsed_result,
11056 __rte_unused struct cmdline *cl,
11057 __rte_unused void *data)
11059 struct cmd_set_hash_global_config_result *res = parsed_result;
11060 struct rte_eth_hash_filter_info info;
11061 uint32_t ftype, idx, offset;
11064 if (rte_eth_dev_filter_supported(res->port_id,
11065 RTE_ETH_FILTER_HASH) < 0) {
11066 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
11070 memset(&info, 0, sizeof(info));
11071 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
11072 if (!strcmp(res->hash_func, "toeplitz"))
11073 info.info.global_conf.hash_func =
11074 RTE_ETH_HASH_FUNCTION_TOEPLITZ;
11075 else if (!strcmp(res->hash_func, "simple_xor"))
11076 info.info.global_conf.hash_func =
11077 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
11078 else if (!strcmp(res->hash_func, "default"))
11079 info.info.global_conf.hash_func =
11080 RTE_ETH_HASH_FUNCTION_DEFAULT;
11082 ftype = str2flowtype(res->flow_type);
11083 idx = ftype / (CHAR_BIT * sizeof(uint32_t));
11084 offset = ftype % (CHAR_BIT * sizeof(uint32_t));
11085 info.info.global_conf.valid_bit_mask[idx] |= (1UL << offset);
11086 if (!strcmp(res->enable, "enable"))
11087 info.info.global_conf.sym_hash_enable_mask[idx] |=
11089 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11090 RTE_ETH_FILTER_SET, &info);
11092 printf("Cannot set global hash configurations by port %d\n",
11095 printf("Global hash configurations have been set "
11096 "succcessfully by port %d\n", res->port_id);
11099 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
11100 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11101 set_hash_global_config, "set_hash_global_config");
11102 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
11103 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
11105 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
11106 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11107 hash_func, "toeplitz#simple_xor#default");
11108 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
11109 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11111 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
11112 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
11113 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
11114 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11115 enable, "enable#disable");
11117 cmdline_parse_inst_t cmd_set_hash_global_config = {
11118 .f = cmd_set_hash_global_config_parsed,
11120 .help_str = "set_hash_global_config <port_id> "
11121 "toeplitz|simple_xor|default "
11122 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
11123 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
11124 "l2_payload enable|disable",
11126 (void *)&cmd_set_hash_global_config_all,
11127 (void *)&cmd_set_hash_global_config_port_id,
11128 (void *)&cmd_set_hash_global_config_hash_func,
11129 (void *)&cmd_set_hash_global_config_flow_type,
11130 (void *)&cmd_set_hash_global_config_enable,
11135 /* Set hash input set */
11136 struct cmd_set_hash_input_set_result {
11137 cmdline_fixed_string_t set_hash_input_set;
11139 cmdline_fixed_string_t flow_type;
11140 cmdline_fixed_string_t inset_field;
11141 cmdline_fixed_string_t select;
11144 static enum rte_eth_input_set_field
11145 str2inset(char *string)
11149 static const struct {
11151 enum rte_eth_input_set_field inset;
11152 } inset_table[] = {
11153 {"ethertype", RTE_ETH_INPUT_SET_L2_ETHERTYPE},
11154 {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN},
11155 {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN},
11156 {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4},
11157 {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4},
11158 {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS},
11159 {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO},
11160 {"ipv4-ttl", RTE_ETH_INPUT_SET_L3_IP4_TTL},
11161 {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6},
11162 {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6},
11163 {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC},
11164 {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER},
11165 {"ipv6-hop-limits", RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS},
11166 {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT},
11167 {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT},
11168 {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT},
11169 {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT},
11170 {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT},
11171 {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT},
11172 {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG},
11173 {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY},
11174 {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY},
11175 {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD},
11176 {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD},
11177 {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD},
11178 {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD},
11179 {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD},
11180 {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD},
11181 {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD},
11182 {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD},
11183 {"none", RTE_ETH_INPUT_SET_NONE},
11186 for (i = 0; i < RTE_DIM(inset_table); i++) {
11187 if (!strcmp(string, inset_table[i].str))
11188 return inset_table[i].inset;
11191 return RTE_ETH_INPUT_SET_UNKNOWN;
11195 cmd_set_hash_input_set_parsed(void *parsed_result,
11196 __rte_unused struct cmdline *cl,
11197 __rte_unused void *data)
11199 struct cmd_set_hash_input_set_result *res = parsed_result;
11200 struct rte_eth_hash_filter_info info;
11202 memset(&info, 0, sizeof(info));
11203 info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT;
11204 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
11205 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
11206 info.info.input_set_conf.inset_size = 1;
11207 if (!strcmp(res->select, "select"))
11208 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
11209 else if (!strcmp(res->select, "add"))
11210 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
11211 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11212 RTE_ETH_FILTER_SET, &info);
11215 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd =
11216 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
11217 set_hash_input_set, "set_hash_input_set");
11218 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id =
11219 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result,
11221 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type =
11222 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
11224 cmdline_parse_token_string_t cmd_set_hash_input_set_field =
11225 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
11227 "ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
11228 "ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#"
11229 "udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#"
11230 "sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#"
11231 "fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#"
11233 cmdline_parse_token_string_t cmd_set_hash_input_set_select =
11234 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
11235 select, "select#add");
11237 cmdline_parse_inst_t cmd_set_hash_input_set = {
11238 .f = cmd_set_hash_input_set_parsed,
11240 .help_str = "set_hash_input_set <port_id> "
11241 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
11242 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload|<flowtype_id> "
11243 "ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|"
11244 "ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|"
11245 "tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|"
11246 "gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
11247 "fld-7th|fld-8th|none select|add",
11249 (void *)&cmd_set_hash_input_set_cmd,
11250 (void *)&cmd_set_hash_input_set_port_id,
11251 (void *)&cmd_set_hash_input_set_flow_type,
11252 (void *)&cmd_set_hash_input_set_field,
11253 (void *)&cmd_set_hash_input_set_select,
11258 /* Set flow director input set */
11259 struct cmd_set_fdir_input_set_result {
11260 cmdline_fixed_string_t set_fdir_input_set;
11262 cmdline_fixed_string_t flow_type;
11263 cmdline_fixed_string_t inset_field;
11264 cmdline_fixed_string_t select;
11268 cmd_set_fdir_input_set_parsed(void *parsed_result,
11269 __rte_unused struct cmdline *cl,
11270 __rte_unused void *data)
11272 struct cmd_set_fdir_input_set_result *res = parsed_result;
11273 struct rte_eth_fdir_filter_info info;
11275 memset(&info, 0, sizeof(info));
11276 info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT;
11277 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
11278 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
11279 info.info.input_set_conf.inset_size = 1;
11280 if (!strcmp(res->select, "select"))
11281 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
11282 else if (!strcmp(res->select, "add"))
11283 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
11284 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11285 RTE_ETH_FILTER_SET, &info);
11288 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd =
11289 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
11290 set_fdir_input_set, "set_fdir_input_set");
11291 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id =
11292 TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result,
11294 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type =
11295 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
11297 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
11298 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
11299 cmdline_parse_token_string_t cmd_set_fdir_input_set_field =
11300 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
11302 "ivlan#ethertype#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
11303 "ipv4-tos#ipv4-proto#ipv4-ttl#ipv6-tc#ipv6-next-header#"
11304 "ipv6-hop-limits#udp-src-port#udp-dst-port#"
11305 "tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#"
11306 "sctp-veri-tag#none");
11307 cmdline_parse_token_string_t cmd_set_fdir_input_set_select =
11308 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
11309 select, "select#add");
11311 cmdline_parse_inst_t cmd_set_fdir_input_set = {
11312 .f = cmd_set_fdir_input_set_parsed,
11314 .help_str = "set_fdir_input_set <port_id> "
11315 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
11316 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
11317 "ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|"
11318 "ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|ipv6-next-header|"
11319 "ipv6-hop-limits|udp-src-port|udp-dst-port|"
11320 "tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|"
11321 "sctp-veri-tag|none select|add",
11323 (void *)&cmd_set_fdir_input_set_cmd,
11324 (void *)&cmd_set_fdir_input_set_port_id,
11325 (void *)&cmd_set_fdir_input_set_flow_type,
11326 (void *)&cmd_set_fdir_input_set_field,
11327 (void *)&cmd_set_fdir_input_set_select,
11332 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
11333 struct cmd_mcast_addr_result {
11334 cmdline_fixed_string_t mcast_addr_cmd;
11335 cmdline_fixed_string_t what;
11337 struct ether_addr mc_addr;
11340 static void cmd_mcast_addr_parsed(void *parsed_result,
11341 __attribute__((unused)) struct cmdline *cl,
11342 __attribute__((unused)) void *data)
11344 struct cmd_mcast_addr_result *res = parsed_result;
11346 if (!is_multicast_ether_addr(&res->mc_addr)) {
11347 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
11348 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
11349 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
11350 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
11353 if (strcmp(res->what, "add") == 0)
11354 mcast_addr_add(res->port_num, &res->mc_addr);
11356 mcast_addr_remove(res->port_num, &res->mc_addr);
11359 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
11360 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
11361 mcast_addr_cmd, "mcast_addr");
11362 cmdline_parse_token_string_t cmd_mcast_addr_what =
11363 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
11365 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
11366 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT16);
11367 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
11368 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
11370 cmdline_parse_inst_t cmd_mcast_addr = {
11371 .f = cmd_mcast_addr_parsed,
11373 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
11374 "Add/Remove multicast MAC address on port_id",
11376 (void *)&cmd_mcast_addr_cmd,
11377 (void *)&cmd_mcast_addr_what,
11378 (void *)&cmd_mcast_addr_portnum,
11379 (void *)&cmd_mcast_addr_addr,
11384 /* l2 tunnel config
11385 * only support E-tag now.
11388 /* Ether type config */
11389 struct cmd_config_l2_tunnel_eth_type_result {
11390 cmdline_fixed_string_t port;
11391 cmdline_fixed_string_t config;
11392 cmdline_fixed_string_t all;
11394 cmdline_fixed_string_t l2_tunnel;
11395 cmdline_fixed_string_t l2_tunnel_type;
11396 cmdline_fixed_string_t eth_type;
11397 uint16_t eth_type_val;
11400 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port =
11401 TOKEN_STRING_INITIALIZER
11402 (struct cmd_config_l2_tunnel_eth_type_result,
11404 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config =
11405 TOKEN_STRING_INITIALIZER
11406 (struct cmd_config_l2_tunnel_eth_type_result,
11408 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str =
11409 TOKEN_STRING_INITIALIZER
11410 (struct cmd_config_l2_tunnel_eth_type_result,
11412 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id =
11413 TOKEN_NUM_INITIALIZER
11414 (struct cmd_config_l2_tunnel_eth_type_result,
11416 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel =
11417 TOKEN_STRING_INITIALIZER
11418 (struct cmd_config_l2_tunnel_eth_type_result,
11419 l2_tunnel, "l2-tunnel");
11420 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type =
11421 TOKEN_STRING_INITIALIZER
11422 (struct cmd_config_l2_tunnel_eth_type_result,
11423 l2_tunnel_type, "E-tag");
11424 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type =
11425 TOKEN_STRING_INITIALIZER
11426 (struct cmd_config_l2_tunnel_eth_type_result,
11427 eth_type, "ether-type");
11428 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val =
11429 TOKEN_NUM_INITIALIZER
11430 (struct cmd_config_l2_tunnel_eth_type_result,
11431 eth_type_val, UINT16);
11433 static enum rte_eth_tunnel_type
11434 str2fdir_l2_tunnel_type(char *string)
11438 static const struct {
11440 enum rte_eth_tunnel_type type;
11441 } l2_tunnel_type_str[] = {
11442 {"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG},
11445 for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) {
11446 if (!strcmp(l2_tunnel_type_str[i].str, string))
11447 return l2_tunnel_type_str[i].type;
11449 return RTE_TUNNEL_TYPE_NONE;
11452 /* ether type config for all ports */
11454 cmd_config_l2_tunnel_eth_type_all_parsed
11455 (void *parsed_result,
11456 __attribute__((unused)) struct cmdline *cl,
11457 __attribute__((unused)) void *data)
11459 struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result;
11460 struct rte_eth_l2_tunnel_conf entry;
11463 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
11464 entry.ether_type = res->eth_type_val;
11466 RTE_ETH_FOREACH_DEV(pid) {
11467 rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry);
11471 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = {
11472 .f = cmd_config_l2_tunnel_eth_type_all_parsed,
11474 .help_str = "port config all l2-tunnel E-tag ether-type <value>",
11476 (void *)&cmd_config_l2_tunnel_eth_type_port,
11477 (void *)&cmd_config_l2_tunnel_eth_type_config,
11478 (void *)&cmd_config_l2_tunnel_eth_type_all_str,
11479 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
11480 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
11481 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
11482 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
11487 /* ether type config for a specific port */
11489 cmd_config_l2_tunnel_eth_type_specific_parsed(
11490 void *parsed_result,
11491 __attribute__((unused)) struct cmdline *cl,
11492 __attribute__((unused)) void *data)
11494 struct cmd_config_l2_tunnel_eth_type_result *res =
11496 struct rte_eth_l2_tunnel_conf entry;
11498 if (port_id_is_invalid(res->id, ENABLED_WARN))
11501 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
11502 entry.ether_type = res->eth_type_val;
11504 rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry);
11507 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = {
11508 .f = cmd_config_l2_tunnel_eth_type_specific_parsed,
11510 .help_str = "port config <port_id> l2-tunnel E-tag ether-type <value>",
11512 (void *)&cmd_config_l2_tunnel_eth_type_port,
11513 (void *)&cmd_config_l2_tunnel_eth_type_config,
11514 (void *)&cmd_config_l2_tunnel_eth_type_id,
11515 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
11516 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
11517 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
11518 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
11523 /* Enable/disable l2 tunnel */
11524 struct cmd_config_l2_tunnel_en_dis_result {
11525 cmdline_fixed_string_t port;
11526 cmdline_fixed_string_t config;
11527 cmdline_fixed_string_t all;
11529 cmdline_fixed_string_t l2_tunnel;
11530 cmdline_fixed_string_t l2_tunnel_type;
11531 cmdline_fixed_string_t en_dis;
11534 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port =
11535 TOKEN_STRING_INITIALIZER
11536 (struct cmd_config_l2_tunnel_en_dis_result,
11538 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config =
11539 TOKEN_STRING_INITIALIZER
11540 (struct cmd_config_l2_tunnel_en_dis_result,
11542 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str =
11543 TOKEN_STRING_INITIALIZER
11544 (struct cmd_config_l2_tunnel_en_dis_result,
11546 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id =
11547 TOKEN_NUM_INITIALIZER
11548 (struct cmd_config_l2_tunnel_en_dis_result,
11550 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel =
11551 TOKEN_STRING_INITIALIZER
11552 (struct cmd_config_l2_tunnel_en_dis_result,
11553 l2_tunnel, "l2-tunnel");
11554 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type =
11555 TOKEN_STRING_INITIALIZER
11556 (struct cmd_config_l2_tunnel_en_dis_result,
11557 l2_tunnel_type, "E-tag");
11558 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis =
11559 TOKEN_STRING_INITIALIZER
11560 (struct cmd_config_l2_tunnel_en_dis_result,
11561 en_dis, "enable#disable");
11563 /* enable/disable l2 tunnel for all ports */
11565 cmd_config_l2_tunnel_en_dis_all_parsed(
11566 void *parsed_result,
11567 __attribute__((unused)) struct cmdline *cl,
11568 __attribute__((unused)) void *data)
11570 struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result;
11571 struct rte_eth_l2_tunnel_conf entry;
11575 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
11577 if (!strcmp("enable", res->en_dis))
11582 RTE_ETH_FOREACH_DEV(pid) {
11583 rte_eth_dev_l2_tunnel_offload_set(pid,
11585 ETH_L2_TUNNEL_ENABLE_MASK,
11590 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = {
11591 .f = cmd_config_l2_tunnel_en_dis_all_parsed,
11593 .help_str = "port config all l2-tunnel E-tag enable|disable",
11595 (void *)&cmd_config_l2_tunnel_en_dis_port,
11596 (void *)&cmd_config_l2_tunnel_en_dis_config,
11597 (void *)&cmd_config_l2_tunnel_en_dis_all_str,
11598 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
11599 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
11600 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
11605 /* enable/disable l2 tunnel for a port */
11607 cmd_config_l2_tunnel_en_dis_specific_parsed(
11608 void *parsed_result,
11609 __attribute__((unused)) struct cmdline *cl,
11610 __attribute__((unused)) void *data)
11612 struct cmd_config_l2_tunnel_en_dis_result *res =
11614 struct rte_eth_l2_tunnel_conf entry;
11616 if (port_id_is_invalid(res->id, ENABLED_WARN))
11619 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
11621 if (!strcmp("enable", res->en_dis))
11622 rte_eth_dev_l2_tunnel_offload_set(res->id,
11624 ETH_L2_TUNNEL_ENABLE_MASK,
11627 rte_eth_dev_l2_tunnel_offload_set(res->id,
11629 ETH_L2_TUNNEL_ENABLE_MASK,
11633 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = {
11634 .f = cmd_config_l2_tunnel_en_dis_specific_parsed,
11636 .help_str = "port config <port_id> l2-tunnel E-tag enable|disable",
11638 (void *)&cmd_config_l2_tunnel_en_dis_port,
11639 (void *)&cmd_config_l2_tunnel_en_dis_config,
11640 (void *)&cmd_config_l2_tunnel_en_dis_id,
11641 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
11642 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
11643 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
11648 /* E-tag configuration */
11650 /* Common result structure for all E-tag configuration */
11651 struct cmd_config_e_tag_result {
11652 cmdline_fixed_string_t e_tag;
11653 cmdline_fixed_string_t set;
11654 cmdline_fixed_string_t insertion;
11655 cmdline_fixed_string_t stripping;
11656 cmdline_fixed_string_t forwarding;
11657 cmdline_fixed_string_t filter;
11658 cmdline_fixed_string_t add;
11659 cmdline_fixed_string_t del;
11660 cmdline_fixed_string_t on;
11661 cmdline_fixed_string_t off;
11662 cmdline_fixed_string_t on_off;
11663 cmdline_fixed_string_t port_tag_id;
11664 uint32_t port_tag_id_val;
11665 cmdline_fixed_string_t e_tag_id;
11666 uint16_t e_tag_id_val;
11667 cmdline_fixed_string_t dst_pool;
11668 uint8_t dst_pool_val;
11669 cmdline_fixed_string_t port;
11671 cmdline_fixed_string_t vf;
11675 /* Common CLI fields for all E-tag configuration */
11676 cmdline_parse_token_string_t cmd_config_e_tag_e_tag =
11677 TOKEN_STRING_INITIALIZER
11678 (struct cmd_config_e_tag_result,
11680 cmdline_parse_token_string_t cmd_config_e_tag_set =
11681 TOKEN_STRING_INITIALIZER
11682 (struct cmd_config_e_tag_result,
11684 cmdline_parse_token_string_t cmd_config_e_tag_insertion =
11685 TOKEN_STRING_INITIALIZER
11686 (struct cmd_config_e_tag_result,
11687 insertion, "insertion");
11688 cmdline_parse_token_string_t cmd_config_e_tag_stripping =
11689 TOKEN_STRING_INITIALIZER
11690 (struct cmd_config_e_tag_result,
11691 stripping, "stripping");
11692 cmdline_parse_token_string_t cmd_config_e_tag_forwarding =
11693 TOKEN_STRING_INITIALIZER
11694 (struct cmd_config_e_tag_result,
11695 forwarding, "forwarding");
11696 cmdline_parse_token_string_t cmd_config_e_tag_filter =
11697 TOKEN_STRING_INITIALIZER
11698 (struct cmd_config_e_tag_result,
11700 cmdline_parse_token_string_t cmd_config_e_tag_add =
11701 TOKEN_STRING_INITIALIZER
11702 (struct cmd_config_e_tag_result,
11704 cmdline_parse_token_string_t cmd_config_e_tag_del =
11705 TOKEN_STRING_INITIALIZER
11706 (struct cmd_config_e_tag_result,
11708 cmdline_parse_token_string_t cmd_config_e_tag_on =
11709 TOKEN_STRING_INITIALIZER
11710 (struct cmd_config_e_tag_result,
11712 cmdline_parse_token_string_t cmd_config_e_tag_off =
11713 TOKEN_STRING_INITIALIZER
11714 (struct cmd_config_e_tag_result,
11716 cmdline_parse_token_string_t cmd_config_e_tag_on_off =
11717 TOKEN_STRING_INITIALIZER
11718 (struct cmd_config_e_tag_result,
11720 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id =
11721 TOKEN_STRING_INITIALIZER
11722 (struct cmd_config_e_tag_result,
11723 port_tag_id, "port-tag-id");
11724 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val =
11725 TOKEN_NUM_INITIALIZER
11726 (struct cmd_config_e_tag_result,
11727 port_tag_id_val, UINT32);
11728 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id =
11729 TOKEN_STRING_INITIALIZER
11730 (struct cmd_config_e_tag_result,
11731 e_tag_id, "e-tag-id");
11732 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val =
11733 TOKEN_NUM_INITIALIZER
11734 (struct cmd_config_e_tag_result,
11735 e_tag_id_val, UINT16);
11736 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool =
11737 TOKEN_STRING_INITIALIZER
11738 (struct cmd_config_e_tag_result,
11739 dst_pool, "dst-pool");
11740 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val =
11741 TOKEN_NUM_INITIALIZER
11742 (struct cmd_config_e_tag_result,
11743 dst_pool_val, UINT8);
11744 cmdline_parse_token_string_t cmd_config_e_tag_port =
11745 TOKEN_STRING_INITIALIZER
11746 (struct cmd_config_e_tag_result,
11748 cmdline_parse_token_num_t cmd_config_e_tag_port_id =
11749 TOKEN_NUM_INITIALIZER
11750 (struct cmd_config_e_tag_result,
11752 cmdline_parse_token_string_t cmd_config_e_tag_vf =
11753 TOKEN_STRING_INITIALIZER
11754 (struct cmd_config_e_tag_result,
11756 cmdline_parse_token_num_t cmd_config_e_tag_vf_id =
11757 TOKEN_NUM_INITIALIZER
11758 (struct cmd_config_e_tag_result,
11761 /* E-tag insertion configuration */
11763 cmd_config_e_tag_insertion_en_parsed(
11764 void *parsed_result,
11765 __attribute__((unused)) struct cmdline *cl,
11766 __attribute__((unused)) void *data)
11768 struct cmd_config_e_tag_result *res =
11770 struct rte_eth_l2_tunnel_conf entry;
11772 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11775 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
11776 entry.tunnel_id = res->port_tag_id_val;
11777 entry.vf_id = res->vf_id;
11778 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
11780 ETH_L2_TUNNEL_INSERTION_MASK,
11785 cmd_config_e_tag_insertion_dis_parsed(
11786 void *parsed_result,
11787 __attribute__((unused)) struct cmdline *cl,
11788 __attribute__((unused)) void *data)
11790 struct cmd_config_e_tag_result *res =
11792 struct rte_eth_l2_tunnel_conf entry;
11794 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11797 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
11798 entry.vf_id = res->vf_id;
11800 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
11802 ETH_L2_TUNNEL_INSERTION_MASK,
11806 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = {
11807 .f = cmd_config_e_tag_insertion_en_parsed,
11809 .help_str = "E-tag ... : E-tag insertion enable",
11811 (void *)&cmd_config_e_tag_e_tag,
11812 (void *)&cmd_config_e_tag_set,
11813 (void *)&cmd_config_e_tag_insertion,
11814 (void *)&cmd_config_e_tag_on,
11815 (void *)&cmd_config_e_tag_port_tag_id,
11816 (void *)&cmd_config_e_tag_port_tag_id_val,
11817 (void *)&cmd_config_e_tag_port,
11818 (void *)&cmd_config_e_tag_port_id,
11819 (void *)&cmd_config_e_tag_vf,
11820 (void *)&cmd_config_e_tag_vf_id,
11825 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = {
11826 .f = cmd_config_e_tag_insertion_dis_parsed,
11828 .help_str = "E-tag ... : E-tag insertion disable",
11830 (void *)&cmd_config_e_tag_e_tag,
11831 (void *)&cmd_config_e_tag_set,
11832 (void *)&cmd_config_e_tag_insertion,
11833 (void *)&cmd_config_e_tag_off,
11834 (void *)&cmd_config_e_tag_port,
11835 (void *)&cmd_config_e_tag_port_id,
11836 (void *)&cmd_config_e_tag_vf,
11837 (void *)&cmd_config_e_tag_vf_id,
11842 /* E-tag stripping configuration */
11844 cmd_config_e_tag_stripping_parsed(
11845 void *parsed_result,
11846 __attribute__((unused)) struct cmdline *cl,
11847 __attribute__((unused)) void *data)
11849 struct cmd_config_e_tag_result *res =
11851 struct rte_eth_l2_tunnel_conf entry;
11853 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11856 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
11858 if (!strcmp(res->on_off, "on"))
11859 rte_eth_dev_l2_tunnel_offload_set
11862 ETH_L2_TUNNEL_STRIPPING_MASK,
11865 rte_eth_dev_l2_tunnel_offload_set
11868 ETH_L2_TUNNEL_STRIPPING_MASK,
11872 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = {
11873 .f = cmd_config_e_tag_stripping_parsed,
11875 .help_str = "E-tag ... : E-tag stripping enable/disable",
11877 (void *)&cmd_config_e_tag_e_tag,
11878 (void *)&cmd_config_e_tag_set,
11879 (void *)&cmd_config_e_tag_stripping,
11880 (void *)&cmd_config_e_tag_on_off,
11881 (void *)&cmd_config_e_tag_port,
11882 (void *)&cmd_config_e_tag_port_id,
11887 /* E-tag forwarding configuration */
11889 cmd_config_e_tag_forwarding_parsed(
11890 void *parsed_result,
11891 __attribute__((unused)) struct cmdline *cl,
11892 __attribute__((unused)) void *data)
11894 struct cmd_config_e_tag_result *res = parsed_result;
11895 struct rte_eth_l2_tunnel_conf entry;
11897 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11900 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
11902 if (!strcmp(res->on_off, "on"))
11903 rte_eth_dev_l2_tunnel_offload_set
11906 ETH_L2_TUNNEL_FORWARDING_MASK,
11909 rte_eth_dev_l2_tunnel_offload_set
11912 ETH_L2_TUNNEL_FORWARDING_MASK,
11916 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = {
11917 .f = cmd_config_e_tag_forwarding_parsed,
11919 .help_str = "E-tag ... : E-tag forwarding enable/disable",
11921 (void *)&cmd_config_e_tag_e_tag,
11922 (void *)&cmd_config_e_tag_set,
11923 (void *)&cmd_config_e_tag_forwarding,
11924 (void *)&cmd_config_e_tag_on_off,
11925 (void *)&cmd_config_e_tag_port,
11926 (void *)&cmd_config_e_tag_port_id,
11931 /* E-tag filter configuration */
11933 cmd_config_e_tag_filter_add_parsed(
11934 void *parsed_result,
11935 __attribute__((unused)) struct cmdline *cl,
11936 __attribute__((unused)) void *data)
11938 struct cmd_config_e_tag_result *res = parsed_result;
11939 struct rte_eth_l2_tunnel_conf entry;
11942 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11945 if (res->e_tag_id_val > 0x3fff) {
11946 printf("e-tag-id must be equal or less than 0x3fff.\n");
11950 ret = rte_eth_dev_filter_supported(res->port_id,
11951 RTE_ETH_FILTER_L2_TUNNEL);
11953 printf("E-tag filter is not supported on port %u.\n",
11958 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
11959 entry.tunnel_id = res->e_tag_id_val;
11960 entry.pool = res->dst_pool_val;
11962 ret = rte_eth_dev_filter_ctrl(res->port_id,
11963 RTE_ETH_FILTER_L2_TUNNEL,
11964 RTE_ETH_FILTER_ADD,
11967 printf("E-tag filter programming error: (%s)\n",
11971 cmdline_parse_inst_t cmd_config_e_tag_filter_add = {
11972 .f = cmd_config_e_tag_filter_add_parsed,
11974 .help_str = "E-tag ... : E-tag filter add",
11976 (void *)&cmd_config_e_tag_e_tag,
11977 (void *)&cmd_config_e_tag_set,
11978 (void *)&cmd_config_e_tag_filter,
11979 (void *)&cmd_config_e_tag_add,
11980 (void *)&cmd_config_e_tag_e_tag_id,
11981 (void *)&cmd_config_e_tag_e_tag_id_val,
11982 (void *)&cmd_config_e_tag_dst_pool,
11983 (void *)&cmd_config_e_tag_dst_pool_val,
11984 (void *)&cmd_config_e_tag_port,
11985 (void *)&cmd_config_e_tag_port_id,
11991 cmd_config_e_tag_filter_del_parsed(
11992 void *parsed_result,
11993 __attribute__((unused)) struct cmdline *cl,
11994 __attribute__((unused)) void *data)
11996 struct cmd_config_e_tag_result *res = parsed_result;
11997 struct rte_eth_l2_tunnel_conf entry;
12000 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12003 if (res->e_tag_id_val > 0x3fff) {
12004 printf("e-tag-id must be less than 0x3fff.\n");
12008 ret = rte_eth_dev_filter_supported(res->port_id,
12009 RTE_ETH_FILTER_L2_TUNNEL);
12011 printf("E-tag filter is not supported on port %u.\n",
12016 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12017 entry.tunnel_id = res->e_tag_id_val;
12019 ret = rte_eth_dev_filter_ctrl(res->port_id,
12020 RTE_ETH_FILTER_L2_TUNNEL,
12021 RTE_ETH_FILTER_DELETE,
12024 printf("E-tag filter programming error: (%s)\n",
12028 cmdline_parse_inst_t cmd_config_e_tag_filter_del = {
12029 .f = cmd_config_e_tag_filter_del_parsed,
12031 .help_str = "E-tag ... : E-tag filter delete",
12033 (void *)&cmd_config_e_tag_e_tag,
12034 (void *)&cmd_config_e_tag_set,
12035 (void *)&cmd_config_e_tag_filter,
12036 (void *)&cmd_config_e_tag_del,
12037 (void *)&cmd_config_e_tag_e_tag_id,
12038 (void *)&cmd_config_e_tag_e_tag_id_val,
12039 (void *)&cmd_config_e_tag_port,
12040 (void *)&cmd_config_e_tag_port_id,
12045 /* vf vlan anti spoof configuration */
12047 /* Common result structure for vf vlan anti spoof */
12048 struct cmd_vf_vlan_anti_spoof_result {
12049 cmdline_fixed_string_t set;
12050 cmdline_fixed_string_t vf;
12051 cmdline_fixed_string_t vlan;
12052 cmdline_fixed_string_t antispoof;
12055 cmdline_fixed_string_t on_off;
12058 /* Common CLI fields for vf vlan anti spoof enable disable */
12059 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
12060 TOKEN_STRING_INITIALIZER
12061 (struct cmd_vf_vlan_anti_spoof_result,
12063 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
12064 TOKEN_STRING_INITIALIZER
12065 (struct cmd_vf_vlan_anti_spoof_result,
12067 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
12068 TOKEN_STRING_INITIALIZER
12069 (struct cmd_vf_vlan_anti_spoof_result,
12071 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
12072 TOKEN_STRING_INITIALIZER
12073 (struct cmd_vf_vlan_anti_spoof_result,
12074 antispoof, "antispoof");
12075 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
12076 TOKEN_NUM_INITIALIZER
12077 (struct cmd_vf_vlan_anti_spoof_result,
12079 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
12080 TOKEN_NUM_INITIALIZER
12081 (struct cmd_vf_vlan_anti_spoof_result,
12083 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
12084 TOKEN_STRING_INITIALIZER
12085 (struct cmd_vf_vlan_anti_spoof_result,
12089 cmd_set_vf_vlan_anti_spoof_parsed(
12090 void *parsed_result,
12091 __attribute__((unused)) struct cmdline *cl,
12092 __attribute__((unused)) void *data)
12094 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
12095 int ret = -ENOTSUP;
12097 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12099 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12102 #ifdef RTE_LIBRTE_IXGBE_PMD
12103 if (ret == -ENOTSUP)
12104 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
12105 res->vf_id, is_on);
12107 #ifdef RTE_LIBRTE_I40E_PMD
12108 if (ret == -ENOTSUP)
12109 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
12110 res->vf_id, is_on);
12112 #ifdef RTE_LIBRTE_BNXT_PMD
12113 if (ret == -ENOTSUP)
12114 ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
12115 res->vf_id, is_on);
12122 printf("invalid vf_id %d\n", res->vf_id);
12125 printf("invalid port_id %d\n", res->port_id);
12128 printf("function not implemented\n");
12131 printf("programming error: (%s)\n", strerror(-ret));
12135 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
12136 .f = cmd_set_vf_vlan_anti_spoof_parsed,
12138 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
12140 (void *)&cmd_vf_vlan_anti_spoof_set,
12141 (void *)&cmd_vf_vlan_anti_spoof_vf,
12142 (void *)&cmd_vf_vlan_anti_spoof_vlan,
12143 (void *)&cmd_vf_vlan_anti_spoof_antispoof,
12144 (void *)&cmd_vf_vlan_anti_spoof_port_id,
12145 (void *)&cmd_vf_vlan_anti_spoof_vf_id,
12146 (void *)&cmd_vf_vlan_anti_spoof_on_off,
12151 /* vf mac anti spoof configuration */
12153 /* Common result structure for vf mac anti spoof */
12154 struct cmd_vf_mac_anti_spoof_result {
12155 cmdline_fixed_string_t set;
12156 cmdline_fixed_string_t vf;
12157 cmdline_fixed_string_t mac;
12158 cmdline_fixed_string_t antispoof;
12161 cmdline_fixed_string_t on_off;
12164 /* Common CLI fields for vf mac anti spoof enable disable */
12165 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
12166 TOKEN_STRING_INITIALIZER
12167 (struct cmd_vf_mac_anti_spoof_result,
12169 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
12170 TOKEN_STRING_INITIALIZER
12171 (struct cmd_vf_mac_anti_spoof_result,
12173 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
12174 TOKEN_STRING_INITIALIZER
12175 (struct cmd_vf_mac_anti_spoof_result,
12177 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
12178 TOKEN_STRING_INITIALIZER
12179 (struct cmd_vf_mac_anti_spoof_result,
12180 antispoof, "antispoof");
12181 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
12182 TOKEN_NUM_INITIALIZER
12183 (struct cmd_vf_mac_anti_spoof_result,
12185 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
12186 TOKEN_NUM_INITIALIZER
12187 (struct cmd_vf_mac_anti_spoof_result,
12189 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
12190 TOKEN_STRING_INITIALIZER
12191 (struct cmd_vf_mac_anti_spoof_result,
12195 cmd_set_vf_mac_anti_spoof_parsed(
12196 void *parsed_result,
12197 __attribute__((unused)) struct cmdline *cl,
12198 __attribute__((unused)) void *data)
12200 struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
12201 int ret = -ENOTSUP;
12203 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12205 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12208 #ifdef RTE_LIBRTE_IXGBE_PMD
12209 if (ret == -ENOTSUP)
12210 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
12211 res->vf_id, is_on);
12213 #ifdef RTE_LIBRTE_I40E_PMD
12214 if (ret == -ENOTSUP)
12215 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
12216 res->vf_id, is_on);
12218 #ifdef RTE_LIBRTE_BNXT_PMD
12219 if (ret == -ENOTSUP)
12220 ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
12221 res->vf_id, is_on);
12228 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12231 printf("invalid port_id %d\n", res->port_id);
12234 printf("function not implemented\n");
12237 printf("programming error: (%s)\n", strerror(-ret));
12241 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
12242 .f = cmd_set_vf_mac_anti_spoof_parsed,
12244 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
12246 (void *)&cmd_vf_mac_anti_spoof_set,
12247 (void *)&cmd_vf_mac_anti_spoof_vf,
12248 (void *)&cmd_vf_mac_anti_spoof_mac,
12249 (void *)&cmd_vf_mac_anti_spoof_antispoof,
12250 (void *)&cmd_vf_mac_anti_spoof_port_id,
12251 (void *)&cmd_vf_mac_anti_spoof_vf_id,
12252 (void *)&cmd_vf_mac_anti_spoof_on_off,
12257 /* vf vlan strip queue configuration */
12259 /* Common result structure for vf mac anti spoof */
12260 struct cmd_vf_vlan_stripq_result {
12261 cmdline_fixed_string_t set;
12262 cmdline_fixed_string_t vf;
12263 cmdline_fixed_string_t vlan;
12264 cmdline_fixed_string_t stripq;
12267 cmdline_fixed_string_t on_off;
12270 /* Common CLI fields for vf vlan strip enable disable */
12271 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
12272 TOKEN_STRING_INITIALIZER
12273 (struct cmd_vf_vlan_stripq_result,
12275 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
12276 TOKEN_STRING_INITIALIZER
12277 (struct cmd_vf_vlan_stripq_result,
12279 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
12280 TOKEN_STRING_INITIALIZER
12281 (struct cmd_vf_vlan_stripq_result,
12283 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
12284 TOKEN_STRING_INITIALIZER
12285 (struct cmd_vf_vlan_stripq_result,
12287 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
12288 TOKEN_NUM_INITIALIZER
12289 (struct cmd_vf_vlan_stripq_result,
12291 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
12292 TOKEN_NUM_INITIALIZER
12293 (struct cmd_vf_vlan_stripq_result,
12295 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
12296 TOKEN_STRING_INITIALIZER
12297 (struct cmd_vf_vlan_stripq_result,
12301 cmd_set_vf_vlan_stripq_parsed(
12302 void *parsed_result,
12303 __attribute__((unused)) struct cmdline *cl,
12304 __attribute__((unused)) void *data)
12306 struct cmd_vf_vlan_stripq_result *res = parsed_result;
12307 int ret = -ENOTSUP;
12309 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12311 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12314 #ifdef RTE_LIBRTE_IXGBE_PMD
12315 if (ret == -ENOTSUP)
12316 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
12317 res->vf_id, is_on);
12319 #ifdef RTE_LIBRTE_I40E_PMD
12320 if (ret == -ENOTSUP)
12321 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
12322 res->vf_id, is_on);
12324 #ifdef RTE_LIBRTE_BNXT_PMD
12325 if (ret == -ENOTSUP)
12326 ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
12327 res->vf_id, is_on);
12334 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12337 printf("invalid port_id %d\n", res->port_id);
12340 printf("function not implemented\n");
12343 printf("programming error: (%s)\n", strerror(-ret));
12347 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
12348 .f = cmd_set_vf_vlan_stripq_parsed,
12350 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
12352 (void *)&cmd_vf_vlan_stripq_set,
12353 (void *)&cmd_vf_vlan_stripq_vf,
12354 (void *)&cmd_vf_vlan_stripq_vlan,
12355 (void *)&cmd_vf_vlan_stripq_stripq,
12356 (void *)&cmd_vf_vlan_stripq_port_id,
12357 (void *)&cmd_vf_vlan_stripq_vf_id,
12358 (void *)&cmd_vf_vlan_stripq_on_off,
12363 /* vf vlan insert configuration */
12365 /* Common result structure for vf vlan insert */
12366 struct cmd_vf_vlan_insert_result {
12367 cmdline_fixed_string_t set;
12368 cmdline_fixed_string_t vf;
12369 cmdline_fixed_string_t vlan;
12370 cmdline_fixed_string_t insert;
12376 /* Common CLI fields for vf vlan insert enable disable */
12377 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
12378 TOKEN_STRING_INITIALIZER
12379 (struct cmd_vf_vlan_insert_result,
12381 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
12382 TOKEN_STRING_INITIALIZER
12383 (struct cmd_vf_vlan_insert_result,
12385 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
12386 TOKEN_STRING_INITIALIZER
12387 (struct cmd_vf_vlan_insert_result,
12389 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
12390 TOKEN_STRING_INITIALIZER
12391 (struct cmd_vf_vlan_insert_result,
12393 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
12394 TOKEN_NUM_INITIALIZER
12395 (struct cmd_vf_vlan_insert_result,
12397 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
12398 TOKEN_NUM_INITIALIZER
12399 (struct cmd_vf_vlan_insert_result,
12401 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
12402 TOKEN_NUM_INITIALIZER
12403 (struct cmd_vf_vlan_insert_result,
12407 cmd_set_vf_vlan_insert_parsed(
12408 void *parsed_result,
12409 __attribute__((unused)) struct cmdline *cl,
12410 __attribute__((unused)) void *data)
12412 struct cmd_vf_vlan_insert_result *res = parsed_result;
12413 int ret = -ENOTSUP;
12415 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12418 #ifdef RTE_LIBRTE_IXGBE_PMD
12419 if (ret == -ENOTSUP)
12420 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
12423 #ifdef RTE_LIBRTE_I40E_PMD
12424 if (ret == -ENOTSUP)
12425 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
12428 #ifdef RTE_LIBRTE_BNXT_PMD
12429 if (ret == -ENOTSUP)
12430 ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
12438 printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id);
12441 printf("invalid port_id %d\n", res->port_id);
12444 printf("function not implemented\n");
12447 printf("programming error: (%s)\n", strerror(-ret));
12451 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
12452 .f = cmd_set_vf_vlan_insert_parsed,
12454 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
12456 (void *)&cmd_vf_vlan_insert_set,
12457 (void *)&cmd_vf_vlan_insert_vf,
12458 (void *)&cmd_vf_vlan_insert_vlan,
12459 (void *)&cmd_vf_vlan_insert_insert,
12460 (void *)&cmd_vf_vlan_insert_port_id,
12461 (void *)&cmd_vf_vlan_insert_vf_id,
12462 (void *)&cmd_vf_vlan_insert_vlan_id,
12467 /* tx loopback configuration */
12469 /* Common result structure for tx loopback */
12470 struct cmd_tx_loopback_result {
12471 cmdline_fixed_string_t set;
12472 cmdline_fixed_string_t tx;
12473 cmdline_fixed_string_t loopback;
12475 cmdline_fixed_string_t on_off;
12478 /* Common CLI fields for tx loopback enable disable */
12479 cmdline_parse_token_string_t cmd_tx_loopback_set =
12480 TOKEN_STRING_INITIALIZER
12481 (struct cmd_tx_loopback_result,
12483 cmdline_parse_token_string_t cmd_tx_loopback_tx =
12484 TOKEN_STRING_INITIALIZER
12485 (struct cmd_tx_loopback_result,
12487 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
12488 TOKEN_STRING_INITIALIZER
12489 (struct cmd_tx_loopback_result,
12490 loopback, "loopback");
12491 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
12492 TOKEN_NUM_INITIALIZER
12493 (struct cmd_tx_loopback_result,
12495 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
12496 TOKEN_STRING_INITIALIZER
12497 (struct cmd_tx_loopback_result,
12501 cmd_set_tx_loopback_parsed(
12502 void *parsed_result,
12503 __attribute__((unused)) struct cmdline *cl,
12504 __attribute__((unused)) void *data)
12506 struct cmd_tx_loopback_result *res = parsed_result;
12507 int ret = -ENOTSUP;
12509 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12511 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12514 #ifdef RTE_LIBRTE_IXGBE_PMD
12515 if (ret == -ENOTSUP)
12516 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
12518 #ifdef RTE_LIBRTE_I40E_PMD
12519 if (ret == -ENOTSUP)
12520 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
12522 #ifdef RTE_LIBRTE_BNXT_PMD
12523 if (ret == -ENOTSUP)
12524 ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
12531 printf("invalid is_on %d\n", is_on);
12534 printf("invalid port_id %d\n", res->port_id);
12537 printf("function not implemented\n");
12540 printf("programming error: (%s)\n", strerror(-ret));
12544 cmdline_parse_inst_t cmd_set_tx_loopback = {
12545 .f = cmd_set_tx_loopback_parsed,
12547 .help_str = "set tx loopback <port_id> on|off",
12549 (void *)&cmd_tx_loopback_set,
12550 (void *)&cmd_tx_loopback_tx,
12551 (void *)&cmd_tx_loopback_loopback,
12552 (void *)&cmd_tx_loopback_port_id,
12553 (void *)&cmd_tx_loopback_on_off,
12558 /* all queues drop enable configuration */
12560 /* Common result structure for all queues drop enable */
12561 struct cmd_all_queues_drop_en_result {
12562 cmdline_fixed_string_t set;
12563 cmdline_fixed_string_t all;
12564 cmdline_fixed_string_t queues;
12565 cmdline_fixed_string_t drop;
12567 cmdline_fixed_string_t on_off;
12570 /* Common CLI fields for tx loopback enable disable */
12571 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
12572 TOKEN_STRING_INITIALIZER
12573 (struct cmd_all_queues_drop_en_result,
12575 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
12576 TOKEN_STRING_INITIALIZER
12577 (struct cmd_all_queues_drop_en_result,
12579 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
12580 TOKEN_STRING_INITIALIZER
12581 (struct cmd_all_queues_drop_en_result,
12583 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
12584 TOKEN_STRING_INITIALIZER
12585 (struct cmd_all_queues_drop_en_result,
12587 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
12588 TOKEN_NUM_INITIALIZER
12589 (struct cmd_all_queues_drop_en_result,
12591 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
12592 TOKEN_STRING_INITIALIZER
12593 (struct cmd_all_queues_drop_en_result,
12597 cmd_set_all_queues_drop_en_parsed(
12598 void *parsed_result,
12599 __attribute__((unused)) struct cmdline *cl,
12600 __attribute__((unused)) void *data)
12602 struct cmd_all_queues_drop_en_result *res = parsed_result;
12603 int ret = -ENOTSUP;
12604 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12606 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12609 #ifdef RTE_LIBRTE_IXGBE_PMD
12610 if (ret == -ENOTSUP)
12611 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
12613 #ifdef RTE_LIBRTE_BNXT_PMD
12614 if (ret == -ENOTSUP)
12615 ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
12621 printf("invalid is_on %d\n", is_on);
12624 printf("invalid port_id %d\n", res->port_id);
12627 printf("function not implemented\n");
12630 printf("programming error: (%s)\n", strerror(-ret));
12634 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
12635 .f = cmd_set_all_queues_drop_en_parsed,
12637 .help_str = "set all queues drop <port_id> on|off",
12639 (void *)&cmd_all_queues_drop_en_set,
12640 (void *)&cmd_all_queues_drop_en_all,
12641 (void *)&cmd_all_queues_drop_en_queues,
12642 (void *)&cmd_all_queues_drop_en_drop,
12643 (void *)&cmd_all_queues_drop_en_port_id,
12644 (void *)&cmd_all_queues_drop_en_on_off,
12649 /* vf split drop enable configuration */
12651 /* Common result structure for vf split drop enable */
12652 struct cmd_vf_split_drop_en_result {
12653 cmdline_fixed_string_t set;
12654 cmdline_fixed_string_t vf;
12655 cmdline_fixed_string_t split;
12656 cmdline_fixed_string_t drop;
12659 cmdline_fixed_string_t on_off;
12662 /* Common CLI fields for vf split drop enable disable */
12663 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
12664 TOKEN_STRING_INITIALIZER
12665 (struct cmd_vf_split_drop_en_result,
12667 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
12668 TOKEN_STRING_INITIALIZER
12669 (struct cmd_vf_split_drop_en_result,
12671 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
12672 TOKEN_STRING_INITIALIZER
12673 (struct cmd_vf_split_drop_en_result,
12675 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
12676 TOKEN_STRING_INITIALIZER
12677 (struct cmd_vf_split_drop_en_result,
12679 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
12680 TOKEN_NUM_INITIALIZER
12681 (struct cmd_vf_split_drop_en_result,
12683 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
12684 TOKEN_NUM_INITIALIZER
12685 (struct cmd_vf_split_drop_en_result,
12687 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
12688 TOKEN_STRING_INITIALIZER
12689 (struct cmd_vf_split_drop_en_result,
12693 cmd_set_vf_split_drop_en_parsed(
12694 void *parsed_result,
12695 __attribute__((unused)) struct cmdline *cl,
12696 __attribute__((unused)) void *data)
12698 struct cmd_vf_split_drop_en_result *res = parsed_result;
12699 int ret = -ENOTSUP;
12700 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12702 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12705 #ifdef RTE_LIBRTE_IXGBE_PMD
12706 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
12713 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12716 printf("invalid port_id %d\n", res->port_id);
12719 printf("not supported on port %d\n", res->port_id);
12722 printf("programming error: (%s)\n", strerror(-ret));
12726 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
12727 .f = cmd_set_vf_split_drop_en_parsed,
12729 .help_str = "set vf split drop <port_id> <vf_id> on|off",
12731 (void *)&cmd_vf_split_drop_en_set,
12732 (void *)&cmd_vf_split_drop_en_vf,
12733 (void *)&cmd_vf_split_drop_en_split,
12734 (void *)&cmd_vf_split_drop_en_drop,
12735 (void *)&cmd_vf_split_drop_en_port_id,
12736 (void *)&cmd_vf_split_drop_en_vf_id,
12737 (void *)&cmd_vf_split_drop_en_on_off,
12742 /* vf mac address configuration */
12744 /* Common result structure for vf mac address */
12745 struct cmd_set_vf_mac_addr_result {
12746 cmdline_fixed_string_t set;
12747 cmdline_fixed_string_t vf;
12748 cmdline_fixed_string_t mac;
12749 cmdline_fixed_string_t addr;
12752 struct ether_addr mac_addr;
12756 /* Common CLI fields for vf split drop enable disable */
12757 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
12758 TOKEN_STRING_INITIALIZER
12759 (struct cmd_set_vf_mac_addr_result,
12761 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
12762 TOKEN_STRING_INITIALIZER
12763 (struct cmd_set_vf_mac_addr_result,
12765 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
12766 TOKEN_STRING_INITIALIZER
12767 (struct cmd_set_vf_mac_addr_result,
12769 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
12770 TOKEN_STRING_INITIALIZER
12771 (struct cmd_set_vf_mac_addr_result,
12773 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
12774 TOKEN_NUM_INITIALIZER
12775 (struct cmd_set_vf_mac_addr_result,
12777 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
12778 TOKEN_NUM_INITIALIZER
12779 (struct cmd_set_vf_mac_addr_result,
12781 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
12782 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
12786 cmd_set_vf_mac_addr_parsed(
12787 void *parsed_result,
12788 __attribute__((unused)) struct cmdline *cl,
12789 __attribute__((unused)) void *data)
12791 struct cmd_set_vf_mac_addr_result *res = parsed_result;
12792 int ret = -ENOTSUP;
12794 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12797 #ifdef RTE_LIBRTE_IXGBE_PMD
12798 if (ret == -ENOTSUP)
12799 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
12802 #ifdef RTE_LIBRTE_I40E_PMD
12803 if (ret == -ENOTSUP)
12804 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
12807 #ifdef RTE_LIBRTE_BNXT_PMD
12808 if (ret == -ENOTSUP)
12809 ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
12817 printf("invalid vf_id %d or mac_addr\n", res->vf_id);
12820 printf("invalid port_id %d\n", res->port_id);
12823 printf("function not implemented\n");
12826 printf("programming error: (%s)\n", strerror(-ret));
12830 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
12831 .f = cmd_set_vf_mac_addr_parsed,
12833 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
12835 (void *)&cmd_set_vf_mac_addr_set,
12836 (void *)&cmd_set_vf_mac_addr_vf,
12837 (void *)&cmd_set_vf_mac_addr_mac,
12838 (void *)&cmd_set_vf_mac_addr_addr,
12839 (void *)&cmd_set_vf_mac_addr_port_id,
12840 (void *)&cmd_set_vf_mac_addr_vf_id,
12841 (void *)&cmd_set_vf_mac_addr_mac_addr,
12846 /* MACsec configuration */
12848 /* Common result structure for MACsec offload enable */
12849 struct cmd_macsec_offload_on_result {
12850 cmdline_fixed_string_t set;
12851 cmdline_fixed_string_t macsec;
12852 cmdline_fixed_string_t offload;
12854 cmdline_fixed_string_t on;
12855 cmdline_fixed_string_t encrypt;
12856 cmdline_fixed_string_t en_on_off;
12857 cmdline_fixed_string_t replay_protect;
12858 cmdline_fixed_string_t rp_on_off;
12861 /* Common CLI fields for MACsec offload disable */
12862 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
12863 TOKEN_STRING_INITIALIZER
12864 (struct cmd_macsec_offload_on_result,
12866 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
12867 TOKEN_STRING_INITIALIZER
12868 (struct cmd_macsec_offload_on_result,
12870 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
12871 TOKEN_STRING_INITIALIZER
12872 (struct cmd_macsec_offload_on_result,
12873 offload, "offload");
12874 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
12875 TOKEN_NUM_INITIALIZER
12876 (struct cmd_macsec_offload_on_result,
12878 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
12879 TOKEN_STRING_INITIALIZER
12880 (struct cmd_macsec_offload_on_result,
12882 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
12883 TOKEN_STRING_INITIALIZER
12884 (struct cmd_macsec_offload_on_result,
12885 encrypt, "encrypt");
12886 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
12887 TOKEN_STRING_INITIALIZER
12888 (struct cmd_macsec_offload_on_result,
12889 en_on_off, "on#off");
12890 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
12891 TOKEN_STRING_INITIALIZER
12892 (struct cmd_macsec_offload_on_result,
12893 replay_protect, "replay-protect");
12894 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
12895 TOKEN_STRING_INITIALIZER
12896 (struct cmd_macsec_offload_on_result,
12897 rp_on_off, "on#off");
12900 cmd_set_macsec_offload_on_parsed(
12901 void *parsed_result,
12902 __attribute__((unused)) struct cmdline *cl,
12903 __attribute__((unused)) void *data)
12905 struct cmd_macsec_offload_on_result *res = parsed_result;
12906 int ret = -ENOTSUP;
12907 portid_t port_id = res->port_id;
12908 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
12909 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
12911 if (port_id_is_invalid(port_id, ENABLED_WARN))
12914 ports[port_id].tx_ol_flags |= TESTPMD_TX_OFFLOAD_MACSEC;
12915 #ifdef RTE_LIBRTE_IXGBE_PMD
12916 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
12925 printf("invalid port_id %d\n", port_id);
12928 printf("not supported on port %d\n", port_id);
12931 printf("programming error: (%s)\n", strerror(-ret));
12935 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
12936 .f = cmd_set_macsec_offload_on_parsed,
12938 .help_str = "set macsec offload <port_id> on "
12939 "encrypt on|off replay-protect on|off",
12941 (void *)&cmd_macsec_offload_on_set,
12942 (void *)&cmd_macsec_offload_on_macsec,
12943 (void *)&cmd_macsec_offload_on_offload,
12944 (void *)&cmd_macsec_offload_on_port_id,
12945 (void *)&cmd_macsec_offload_on_on,
12946 (void *)&cmd_macsec_offload_on_encrypt,
12947 (void *)&cmd_macsec_offload_on_en_on_off,
12948 (void *)&cmd_macsec_offload_on_replay_protect,
12949 (void *)&cmd_macsec_offload_on_rp_on_off,
12954 /* Common result structure for MACsec offload disable */
12955 struct cmd_macsec_offload_off_result {
12956 cmdline_fixed_string_t set;
12957 cmdline_fixed_string_t macsec;
12958 cmdline_fixed_string_t offload;
12960 cmdline_fixed_string_t off;
12963 /* Common CLI fields for MACsec offload disable */
12964 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
12965 TOKEN_STRING_INITIALIZER
12966 (struct cmd_macsec_offload_off_result,
12968 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
12969 TOKEN_STRING_INITIALIZER
12970 (struct cmd_macsec_offload_off_result,
12972 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
12973 TOKEN_STRING_INITIALIZER
12974 (struct cmd_macsec_offload_off_result,
12975 offload, "offload");
12976 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
12977 TOKEN_NUM_INITIALIZER
12978 (struct cmd_macsec_offload_off_result,
12980 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
12981 TOKEN_STRING_INITIALIZER
12982 (struct cmd_macsec_offload_off_result,
12986 cmd_set_macsec_offload_off_parsed(
12987 void *parsed_result,
12988 __attribute__((unused)) struct cmdline *cl,
12989 __attribute__((unused)) void *data)
12991 struct cmd_macsec_offload_off_result *res = parsed_result;
12992 int ret = -ENOTSUP;
12993 portid_t port_id = res->port_id;
12995 if (port_id_is_invalid(port_id, ENABLED_WARN))
12998 ports[port_id].tx_ol_flags &= ~TESTPMD_TX_OFFLOAD_MACSEC;
12999 #ifdef RTE_LIBRTE_IXGBE_PMD
13000 ret = rte_pmd_ixgbe_macsec_disable(port_id);
13007 printf("invalid port_id %d\n", port_id);
13010 printf("not supported on port %d\n", port_id);
13013 printf("programming error: (%s)\n", strerror(-ret));
13017 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
13018 .f = cmd_set_macsec_offload_off_parsed,
13020 .help_str = "set macsec offload <port_id> off",
13022 (void *)&cmd_macsec_offload_off_set,
13023 (void *)&cmd_macsec_offload_off_macsec,
13024 (void *)&cmd_macsec_offload_off_offload,
13025 (void *)&cmd_macsec_offload_off_port_id,
13026 (void *)&cmd_macsec_offload_off_off,
13031 /* Common result structure for MACsec secure connection configure */
13032 struct cmd_macsec_sc_result {
13033 cmdline_fixed_string_t set;
13034 cmdline_fixed_string_t macsec;
13035 cmdline_fixed_string_t sc;
13036 cmdline_fixed_string_t tx_rx;
13038 struct ether_addr mac;
13042 /* Common CLI fields for MACsec secure connection configure */
13043 cmdline_parse_token_string_t cmd_macsec_sc_set =
13044 TOKEN_STRING_INITIALIZER
13045 (struct cmd_macsec_sc_result,
13047 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
13048 TOKEN_STRING_INITIALIZER
13049 (struct cmd_macsec_sc_result,
13051 cmdline_parse_token_string_t cmd_macsec_sc_sc =
13052 TOKEN_STRING_INITIALIZER
13053 (struct cmd_macsec_sc_result,
13055 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
13056 TOKEN_STRING_INITIALIZER
13057 (struct cmd_macsec_sc_result,
13059 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
13060 TOKEN_NUM_INITIALIZER
13061 (struct cmd_macsec_sc_result,
13063 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
13064 TOKEN_ETHERADDR_INITIALIZER
13065 (struct cmd_macsec_sc_result,
13067 cmdline_parse_token_num_t cmd_macsec_sc_pi =
13068 TOKEN_NUM_INITIALIZER
13069 (struct cmd_macsec_sc_result,
13073 cmd_set_macsec_sc_parsed(
13074 void *parsed_result,
13075 __attribute__((unused)) struct cmdline *cl,
13076 __attribute__((unused)) void *data)
13078 struct cmd_macsec_sc_result *res = parsed_result;
13079 int ret = -ENOTSUP;
13080 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
13082 #ifdef RTE_LIBRTE_IXGBE_PMD
13084 rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
13085 res->mac.addr_bytes) :
13086 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
13087 res->mac.addr_bytes, res->pi);
13089 RTE_SET_USED(is_tx);
13095 printf("invalid port_id %d\n", res->port_id);
13098 printf("not supported on port %d\n", res->port_id);
13101 printf("programming error: (%s)\n", strerror(-ret));
13105 cmdline_parse_inst_t cmd_set_macsec_sc = {
13106 .f = cmd_set_macsec_sc_parsed,
13108 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
13110 (void *)&cmd_macsec_sc_set,
13111 (void *)&cmd_macsec_sc_macsec,
13112 (void *)&cmd_macsec_sc_sc,
13113 (void *)&cmd_macsec_sc_tx_rx,
13114 (void *)&cmd_macsec_sc_port_id,
13115 (void *)&cmd_macsec_sc_mac,
13116 (void *)&cmd_macsec_sc_pi,
13121 /* Common result structure for MACsec secure connection configure */
13122 struct cmd_macsec_sa_result {
13123 cmdline_fixed_string_t set;
13124 cmdline_fixed_string_t macsec;
13125 cmdline_fixed_string_t sa;
13126 cmdline_fixed_string_t tx_rx;
13131 cmdline_fixed_string_t key;
13134 /* Common CLI fields for MACsec secure connection configure */
13135 cmdline_parse_token_string_t cmd_macsec_sa_set =
13136 TOKEN_STRING_INITIALIZER
13137 (struct cmd_macsec_sa_result,
13139 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
13140 TOKEN_STRING_INITIALIZER
13141 (struct cmd_macsec_sa_result,
13143 cmdline_parse_token_string_t cmd_macsec_sa_sa =
13144 TOKEN_STRING_INITIALIZER
13145 (struct cmd_macsec_sa_result,
13147 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
13148 TOKEN_STRING_INITIALIZER
13149 (struct cmd_macsec_sa_result,
13151 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
13152 TOKEN_NUM_INITIALIZER
13153 (struct cmd_macsec_sa_result,
13155 cmdline_parse_token_num_t cmd_macsec_sa_idx =
13156 TOKEN_NUM_INITIALIZER
13157 (struct cmd_macsec_sa_result,
13159 cmdline_parse_token_num_t cmd_macsec_sa_an =
13160 TOKEN_NUM_INITIALIZER
13161 (struct cmd_macsec_sa_result,
13163 cmdline_parse_token_num_t cmd_macsec_sa_pn =
13164 TOKEN_NUM_INITIALIZER
13165 (struct cmd_macsec_sa_result,
13167 cmdline_parse_token_string_t cmd_macsec_sa_key =
13168 TOKEN_STRING_INITIALIZER
13169 (struct cmd_macsec_sa_result,
13173 cmd_set_macsec_sa_parsed(
13174 void *parsed_result,
13175 __attribute__((unused)) struct cmdline *cl,
13176 __attribute__((unused)) void *data)
13178 struct cmd_macsec_sa_result *res = parsed_result;
13179 int ret = -ENOTSUP;
13180 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
13181 uint8_t key[16] = { 0 };
13187 key_len = strlen(res->key) / 2;
13191 for (i = 0; i < key_len; i++) {
13192 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
13195 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
13198 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
13201 #ifdef RTE_LIBRTE_IXGBE_PMD
13203 rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
13204 res->idx, res->an, res->pn, key) :
13205 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
13206 res->idx, res->an, res->pn, key);
13208 RTE_SET_USED(is_tx);
13215 printf("invalid idx %d or an %d\n", res->idx, res->an);
13218 printf("invalid port_id %d\n", res->port_id);
13221 printf("not supported on port %d\n", res->port_id);
13224 printf("programming error: (%s)\n", strerror(-ret));
13228 cmdline_parse_inst_t cmd_set_macsec_sa = {
13229 .f = cmd_set_macsec_sa_parsed,
13231 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
13233 (void *)&cmd_macsec_sa_set,
13234 (void *)&cmd_macsec_sa_macsec,
13235 (void *)&cmd_macsec_sa_sa,
13236 (void *)&cmd_macsec_sa_tx_rx,
13237 (void *)&cmd_macsec_sa_port_id,
13238 (void *)&cmd_macsec_sa_idx,
13239 (void *)&cmd_macsec_sa_an,
13240 (void *)&cmd_macsec_sa_pn,
13241 (void *)&cmd_macsec_sa_key,
13246 /* VF unicast promiscuous mode configuration */
13248 /* Common result structure for VF unicast promiscuous mode */
13249 struct cmd_vf_promisc_result {
13250 cmdline_fixed_string_t set;
13251 cmdline_fixed_string_t vf;
13252 cmdline_fixed_string_t promisc;
13255 cmdline_fixed_string_t on_off;
13258 /* Common CLI fields for VF unicast promiscuous mode enable disable */
13259 cmdline_parse_token_string_t cmd_vf_promisc_set =
13260 TOKEN_STRING_INITIALIZER
13261 (struct cmd_vf_promisc_result,
13263 cmdline_parse_token_string_t cmd_vf_promisc_vf =
13264 TOKEN_STRING_INITIALIZER
13265 (struct cmd_vf_promisc_result,
13267 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
13268 TOKEN_STRING_INITIALIZER
13269 (struct cmd_vf_promisc_result,
13270 promisc, "promisc");
13271 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
13272 TOKEN_NUM_INITIALIZER
13273 (struct cmd_vf_promisc_result,
13275 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
13276 TOKEN_NUM_INITIALIZER
13277 (struct cmd_vf_promisc_result,
13279 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
13280 TOKEN_STRING_INITIALIZER
13281 (struct cmd_vf_promisc_result,
13285 cmd_set_vf_promisc_parsed(
13286 void *parsed_result,
13287 __attribute__((unused)) struct cmdline *cl,
13288 __attribute__((unused)) void *data)
13290 struct cmd_vf_promisc_result *res = parsed_result;
13291 int ret = -ENOTSUP;
13293 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13295 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13298 #ifdef RTE_LIBRTE_I40E_PMD
13299 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
13300 res->vf_id, is_on);
13307 printf("invalid vf_id %d\n", res->vf_id);
13310 printf("invalid port_id %d\n", res->port_id);
13313 printf("function not implemented\n");
13316 printf("programming error: (%s)\n", strerror(-ret));
13320 cmdline_parse_inst_t cmd_set_vf_promisc = {
13321 .f = cmd_set_vf_promisc_parsed,
13323 .help_str = "set vf promisc <port_id> <vf_id> on|off: "
13324 "Set unicast promiscuous mode for a VF from the PF",
13326 (void *)&cmd_vf_promisc_set,
13327 (void *)&cmd_vf_promisc_vf,
13328 (void *)&cmd_vf_promisc_promisc,
13329 (void *)&cmd_vf_promisc_port_id,
13330 (void *)&cmd_vf_promisc_vf_id,
13331 (void *)&cmd_vf_promisc_on_off,
13336 /* VF multicast promiscuous mode configuration */
13338 /* Common result structure for VF multicast promiscuous mode */
13339 struct cmd_vf_allmulti_result {
13340 cmdline_fixed_string_t set;
13341 cmdline_fixed_string_t vf;
13342 cmdline_fixed_string_t allmulti;
13345 cmdline_fixed_string_t on_off;
13348 /* Common CLI fields for VF multicast promiscuous mode enable disable */
13349 cmdline_parse_token_string_t cmd_vf_allmulti_set =
13350 TOKEN_STRING_INITIALIZER
13351 (struct cmd_vf_allmulti_result,
13353 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
13354 TOKEN_STRING_INITIALIZER
13355 (struct cmd_vf_allmulti_result,
13357 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
13358 TOKEN_STRING_INITIALIZER
13359 (struct cmd_vf_allmulti_result,
13360 allmulti, "allmulti");
13361 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
13362 TOKEN_NUM_INITIALIZER
13363 (struct cmd_vf_allmulti_result,
13365 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
13366 TOKEN_NUM_INITIALIZER
13367 (struct cmd_vf_allmulti_result,
13369 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
13370 TOKEN_STRING_INITIALIZER
13371 (struct cmd_vf_allmulti_result,
13375 cmd_set_vf_allmulti_parsed(
13376 void *parsed_result,
13377 __attribute__((unused)) struct cmdline *cl,
13378 __attribute__((unused)) void *data)
13380 struct cmd_vf_allmulti_result *res = parsed_result;
13381 int ret = -ENOTSUP;
13383 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13385 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13388 #ifdef RTE_LIBRTE_I40E_PMD
13389 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
13390 res->vf_id, is_on);
13397 printf("invalid vf_id %d\n", res->vf_id);
13400 printf("invalid port_id %d\n", res->port_id);
13403 printf("function not implemented\n");
13406 printf("programming error: (%s)\n", strerror(-ret));
13410 cmdline_parse_inst_t cmd_set_vf_allmulti = {
13411 .f = cmd_set_vf_allmulti_parsed,
13413 .help_str = "set vf allmulti <port_id> <vf_id> on|off: "
13414 "Set multicast promiscuous mode for a VF from the PF",
13416 (void *)&cmd_vf_allmulti_set,
13417 (void *)&cmd_vf_allmulti_vf,
13418 (void *)&cmd_vf_allmulti_allmulti,
13419 (void *)&cmd_vf_allmulti_port_id,
13420 (void *)&cmd_vf_allmulti_vf_id,
13421 (void *)&cmd_vf_allmulti_on_off,
13426 /* vf broadcast mode configuration */
13428 /* Common result structure for vf broadcast */
13429 struct cmd_set_vf_broadcast_result {
13430 cmdline_fixed_string_t set;
13431 cmdline_fixed_string_t vf;
13432 cmdline_fixed_string_t broadcast;
13435 cmdline_fixed_string_t on_off;
13438 /* Common CLI fields for vf broadcast enable disable */
13439 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
13440 TOKEN_STRING_INITIALIZER
13441 (struct cmd_set_vf_broadcast_result,
13443 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
13444 TOKEN_STRING_INITIALIZER
13445 (struct cmd_set_vf_broadcast_result,
13447 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
13448 TOKEN_STRING_INITIALIZER
13449 (struct cmd_set_vf_broadcast_result,
13450 broadcast, "broadcast");
13451 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
13452 TOKEN_NUM_INITIALIZER
13453 (struct cmd_set_vf_broadcast_result,
13455 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
13456 TOKEN_NUM_INITIALIZER
13457 (struct cmd_set_vf_broadcast_result,
13459 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
13460 TOKEN_STRING_INITIALIZER
13461 (struct cmd_set_vf_broadcast_result,
13465 cmd_set_vf_broadcast_parsed(
13466 void *parsed_result,
13467 __attribute__((unused)) struct cmdline *cl,
13468 __attribute__((unused)) void *data)
13470 struct cmd_set_vf_broadcast_result *res = parsed_result;
13471 int ret = -ENOTSUP;
13473 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13475 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13478 #ifdef RTE_LIBRTE_I40E_PMD
13479 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
13480 res->vf_id, is_on);
13487 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13490 printf("invalid port_id %d\n", res->port_id);
13493 printf("function not implemented\n");
13496 printf("programming error: (%s)\n", strerror(-ret));
13500 cmdline_parse_inst_t cmd_set_vf_broadcast = {
13501 .f = cmd_set_vf_broadcast_parsed,
13503 .help_str = "set vf broadcast <port_id> <vf_id> on|off",
13505 (void *)&cmd_set_vf_broadcast_set,
13506 (void *)&cmd_set_vf_broadcast_vf,
13507 (void *)&cmd_set_vf_broadcast_broadcast,
13508 (void *)&cmd_set_vf_broadcast_port_id,
13509 (void *)&cmd_set_vf_broadcast_vf_id,
13510 (void *)&cmd_set_vf_broadcast_on_off,
13515 /* vf vlan tag configuration */
13517 /* Common result structure for vf vlan tag */
13518 struct cmd_set_vf_vlan_tag_result {
13519 cmdline_fixed_string_t set;
13520 cmdline_fixed_string_t vf;
13521 cmdline_fixed_string_t vlan;
13522 cmdline_fixed_string_t tag;
13525 cmdline_fixed_string_t on_off;
13528 /* Common CLI fields for vf vlan tag enable disable */
13529 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
13530 TOKEN_STRING_INITIALIZER
13531 (struct cmd_set_vf_vlan_tag_result,
13533 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
13534 TOKEN_STRING_INITIALIZER
13535 (struct cmd_set_vf_vlan_tag_result,
13537 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
13538 TOKEN_STRING_INITIALIZER
13539 (struct cmd_set_vf_vlan_tag_result,
13541 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
13542 TOKEN_STRING_INITIALIZER
13543 (struct cmd_set_vf_vlan_tag_result,
13545 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
13546 TOKEN_NUM_INITIALIZER
13547 (struct cmd_set_vf_vlan_tag_result,
13549 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
13550 TOKEN_NUM_INITIALIZER
13551 (struct cmd_set_vf_vlan_tag_result,
13553 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
13554 TOKEN_STRING_INITIALIZER
13555 (struct cmd_set_vf_vlan_tag_result,
13559 cmd_set_vf_vlan_tag_parsed(
13560 void *parsed_result,
13561 __attribute__((unused)) struct cmdline *cl,
13562 __attribute__((unused)) void *data)
13564 struct cmd_set_vf_vlan_tag_result *res = parsed_result;
13565 int ret = -ENOTSUP;
13567 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13569 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13572 #ifdef RTE_LIBRTE_I40E_PMD
13573 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
13574 res->vf_id, is_on);
13581 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13584 printf("invalid port_id %d\n", res->port_id);
13587 printf("function not implemented\n");
13590 printf("programming error: (%s)\n", strerror(-ret));
13594 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
13595 .f = cmd_set_vf_vlan_tag_parsed,
13597 .help_str = "set vf vlan tag <port_id> <vf_id> on|off",
13599 (void *)&cmd_set_vf_vlan_tag_set,
13600 (void *)&cmd_set_vf_vlan_tag_vf,
13601 (void *)&cmd_set_vf_vlan_tag_vlan,
13602 (void *)&cmd_set_vf_vlan_tag_tag,
13603 (void *)&cmd_set_vf_vlan_tag_port_id,
13604 (void *)&cmd_set_vf_vlan_tag_vf_id,
13605 (void *)&cmd_set_vf_vlan_tag_on_off,
13610 /* Common definition of VF and TC TX bandwidth configuration */
13611 struct cmd_vf_tc_bw_result {
13612 cmdline_fixed_string_t set;
13613 cmdline_fixed_string_t vf;
13614 cmdline_fixed_string_t tc;
13615 cmdline_fixed_string_t tx;
13616 cmdline_fixed_string_t min_bw;
13617 cmdline_fixed_string_t max_bw;
13618 cmdline_fixed_string_t strict_link_prio;
13623 cmdline_fixed_string_t bw_list;
13627 cmdline_parse_token_string_t cmd_vf_tc_bw_set =
13628 TOKEN_STRING_INITIALIZER
13629 (struct cmd_vf_tc_bw_result,
13631 cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
13632 TOKEN_STRING_INITIALIZER
13633 (struct cmd_vf_tc_bw_result,
13635 cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
13636 TOKEN_STRING_INITIALIZER
13637 (struct cmd_vf_tc_bw_result,
13639 cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
13640 TOKEN_STRING_INITIALIZER
13641 (struct cmd_vf_tc_bw_result,
13643 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio =
13644 TOKEN_STRING_INITIALIZER
13645 (struct cmd_vf_tc_bw_result,
13646 strict_link_prio, "strict-link-priority");
13647 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw =
13648 TOKEN_STRING_INITIALIZER
13649 (struct cmd_vf_tc_bw_result,
13650 min_bw, "min-bandwidth");
13651 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
13652 TOKEN_STRING_INITIALIZER
13653 (struct cmd_vf_tc_bw_result,
13654 max_bw, "max-bandwidth");
13655 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
13656 TOKEN_NUM_INITIALIZER
13657 (struct cmd_vf_tc_bw_result,
13659 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
13660 TOKEN_NUM_INITIALIZER
13661 (struct cmd_vf_tc_bw_result,
13663 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no =
13664 TOKEN_NUM_INITIALIZER
13665 (struct cmd_vf_tc_bw_result,
13667 cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
13668 TOKEN_NUM_INITIALIZER
13669 (struct cmd_vf_tc_bw_result,
13671 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
13672 TOKEN_STRING_INITIALIZER
13673 (struct cmd_vf_tc_bw_result,
13675 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map =
13676 TOKEN_NUM_INITIALIZER
13677 (struct cmd_vf_tc_bw_result,
13680 /* VF max bandwidth setting */
13682 cmd_vf_max_bw_parsed(
13683 void *parsed_result,
13684 __attribute__((unused)) struct cmdline *cl,
13685 __attribute__((unused)) void *data)
13687 struct cmd_vf_tc_bw_result *res = parsed_result;
13688 int ret = -ENOTSUP;
13690 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13693 #ifdef RTE_LIBRTE_I40E_PMD
13694 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id,
13695 res->vf_id, res->bw);
13702 printf("invalid vf_id %d or bandwidth %d\n",
13703 res->vf_id, res->bw);
13706 printf("invalid port_id %d\n", res->port_id);
13709 printf("function not implemented\n");
13712 printf("programming error: (%s)\n", strerror(-ret));
13716 cmdline_parse_inst_t cmd_vf_max_bw = {
13717 .f = cmd_vf_max_bw_parsed,
13719 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
13721 (void *)&cmd_vf_tc_bw_set,
13722 (void *)&cmd_vf_tc_bw_vf,
13723 (void *)&cmd_vf_tc_bw_tx,
13724 (void *)&cmd_vf_tc_bw_max_bw,
13725 (void *)&cmd_vf_tc_bw_port_id,
13726 (void *)&cmd_vf_tc_bw_vf_id,
13727 (void *)&cmd_vf_tc_bw_bw,
13733 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
13738 const char *p, *p0 = str;
13745 p = strchr(p0, '(');
13747 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
13751 p0 = strchr(p, ')');
13753 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
13757 if (size >= sizeof(s)) {
13758 printf("The string size exceeds the internal buffer size\n");
13761 snprintf(s, sizeof(s), "%.*s", size, p);
13762 ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
13764 printf("Failed to get the bandwidth list. ");
13768 for (i = 0; i < ret; i++)
13769 bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
13774 /* TC min bandwidth setting */
13776 cmd_vf_tc_min_bw_parsed(
13777 void *parsed_result,
13778 __attribute__((unused)) struct cmdline *cl,
13779 __attribute__((unused)) void *data)
13781 struct cmd_vf_tc_bw_result *res = parsed_result;
13784 int ret = -ENOTSUP;
13786 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13789 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
13793 #ifdef RTE_LIBRTE_I40E_PMD
13794 ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
13802 printf("invalid vf_id %d or bandwidth\n", res->vf_id);
13805 printf("invalid port_id %d\n", res->port_id);
13808 printf("function not implemented\n");
13811 printf("programming error: (%s)\n", strerror(-ret));
13815 cmdline_parse_inst_t cmd_vf_tc_min_bw = {
13816 .f = cmd_vf_tc_min_bw_parsed,
13818 .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
13819 " <bw1, bw2, ...>",
13821 (void *)&cmd_vf_tc_bw_set,
13822 (void *)&cmd_vf_tc_bw_vf,
13823 (void *)&cmd_vf_tc_bw_tc,
13824 (void *)&cmd_vf_tc_bw_tx,
13825 (void *)&cmd_vf_tc_bw_min_bw,
13826 (void *)&cmd_vf_tc_bw_port_id,
13827 (void *)&cmd_vf_tc_bw_vf_id,
13828 (void *)&cmd_vf_tc_bw_bw_list,
13834 cmd_tc_min_bw_parsed(
13835 void *parsed_result,
13836 __attribute__((unused)) struct cmdline *cl,
13837 __attribute__((unused)) void *data)
13839 struct cmd_vf_tc_bw_result *res = parsed_result;
13840 struct rte_port *port;
13843 int ret = -ENOTSUP;
13845 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13848 port = &ports[res->port_id];
13849 /** Check if the port is not started **/
13850 if (port->port_status != RTE_PORT_STOPPED) {
13851 printf("Please stop port %d first\n", res->port_id);
13855 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
13859 #ifdef RTE_LIBRTE_IXGBE_PMD
13860 ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw);
13867 printf("invalid bandwidth\n");
13870 printf("invalid port_id %d\n", res->port_id);
13873 printf("function not implemented\n");
13876 printf("programming error: (%s)\n", strerror(-ret));
13880 cmdline_parse_inst_t cmd_tc_min_bw = {
13881 .f = cmd_tc_min_bw_parsed,
13883 .help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>",
13885 (void *)&cmd_vf_tc_bw_set,
13886 (void *)&cmd_vf_tc_bw_tc,
13887 (void *)&cmd_vf_tc_bw_tx,
13888 (void *)&cmd_vf_tc_bw_min_bw,
13889 (void *)&cmd_vf_tc_bw_port_id,
13890 (void *)&cmd_vf_tc_bw_bw_list,
13895 /* TC max bandwidth setting */
13897 cmd_vf_tc_max_bw_parsed(
13898 void *parsed_result,
13899 __attribute__((unused)) struct cmdline *cl,
13900 __attribute__((unused)) void *data)
13902 struct cmd_vf_tc_bw_result *res = parsed_result;
13903 int ret = -ENOTSUP;
13905 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13908 #ifdef RTE_LIBRTE_I40E_PMD
13909 ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id,
13910 res->tc_no, res->bw);
13917 printf("invalid vf_id %d, tc_no %d or bandwidth %d\n",
13918 res->vf_id, res->tc_no, res->bw);
13921 printf("invalid port_id %d\n", res->port_id);
13924 printf("function not implemented\n");
13927 printf("programming error: (%s)\n", strerror(-ret));
13931 cmdline_parse_inst_t cmd_vf_tc_max_bw = {
13932 .f = cmd_vf_tc_max_bw_parsed,
13934 .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>"
13937 (void *)&cmd_vf_tc_bw_set,
13938 (void *)&cmd_vf_tc_bw_vf,
13939 (void *)&cmd_vf_tc_bw_tc,
13940 (void *)&cmd_vf_tc_bw_tx,
13941 (void *)&cmd_vf_tc_bw_max_bw,
13942 (void *)&cmd_vf_tc_bw_port_id,
13943 (void *)&cmd_vf_tc_bw_vf_id,
13944 (void *)&cmd_vf_tc_bw_tc_no,
13945 (void *)&cmd_vf_tc_bw_bw,
13951 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
13953 /* *** Set Port default Traffic Management Hierarchy *** */
13954 struct cmd_set_port_tm_hierarchy_default_result {
13955 cmdline_fixed_string_t set;
13956 cmdline_fixed_string_t port;
13957 cmdline_fixed_string_t tm;
13958 cmdline_fixed_string_t hierarchy;
13959 cmdline_fixed_string_t def;
13963 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_set =
13964 TOKEN_STRING_INITIALIZER(
13965 struct cmd_set_port_tm_hierarchy_default_result, set, "set");
13966 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_port =
13967 TOKEN_STRING_INITIALIZER(
13968 struct cmd_set_port_tm_hierarchy_default_result, port, "port");
13969 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_tm =
13970 TOKEN_STRING_INITIALIZER(
13971 struct cmd_set_port_tm_hierarchy_default_result, tm, "tm");
13972 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_hierarchy =
13973 TOKEN_STRING_INITIALIZER(
13974 struct cmd_set_port_tm_hierarchy_default_result,
13975 hierarchy, "hierarchy");
13976 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_default =
13977 TOKEN_STRING_INITIALIZER(
13978 struct cmd_set_port_tm_hierarchy_default_result,
13980 cmdline_parse_token_num_t cmd_set_port_tm_hierarchy_default_port_id =
13981 TOKEN_NUM_INITIALIZER(
13982 struct cmd_set_port_tm_hierarchy_default_result,
13985 static void cmd_set_port_tm_hierarchy_default_parsed(void *parsed_result,
13986 __attribute__((unused)) struct cmdline *cl,
13987 __attribute__((unused)) void *data)
13989 struct cmd_set_port_tm_hierarchy_default_result *res = parsed_result;
13990 struct rte_port *p;
13991 portid_t port_id = res->port_id;
13993 if (port_id_is_invalid(port_id, ENABLED_WARN))
13996 p = &ports[port_id];
13999 if (p->softport.tm_flag == 0) {
14000 printf(" tm not enabled on port %u (error)\n", port_id);
14004 /* Forward mode: tm */
14005 if (strcmp(cur_fwd_config.fwd_eng->fwd_mode_name, "tm")) {
14006 printf(" tm mode not enabled(error)\n");
14010 /* Set the default tm hierarchy */
14011 p->softport.tm.default_hierarchy_enable = 1;
14014 cmdline_parse_inst_t cmd_set_port_tm_hierarchy_default = {
14015 .f = cmd_set_port_tm_hierarchy_default_parsed,
14017 .help_str = "set port tm hierarchy default <port_id>",
14019 (void *)&cmd_set_port_tm_hierarchy_default_set,
14020 (void *)&cmd_set_port_tm_hierarchy_default_port,
14021 (void *)&cmd_set_port_tm_hierarchy_default_tm,
14022 (void *)&cmd_set_port_tm_hierarchy_default_hierarchy,
14023 (void *)&cmd_set_port_tm_hierarchy_default_default,
14024 (void *)&cmd_set_port_tm_hierarchy_default_port_id,
14030 /* Strict link priority scheduling mode setting */
14032 cmd_strict_link_prio_parsed(
14033 void *parsed_result,
14034 __attribute__((unused)) struct cmdline *cl,
14035 __attribute__((unused)) void *data)
14037 struct cmd_vf_tc_bw_result *res = parsed_result;
14038 int ret = -ENOTSUP;
14040 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14043 #ifdef RTE_LIBRTE_I40E_PMD
14044 ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map);
14051 printf("invalid tc_bitmap 0x%x\n", res->tc_map);
14054 printf("invalid port_id %d\n", res->port_id);
14057 printf("function not implemented\n");
14060 printf("programming error: (%s)\n", strerror(-ret));
14064 cmdline_parse_inst_t cmd_strict_link_prio = {
14065 .f = cmd_strict_link_prio_parsed,
14067 .help_str = "set tx strict-link-priority <port_id> <tc_bitmap>",
14069 (void *)&cmd_vf_tc_bw_set,
14070 (void *)&cmd_vf_tc_bw_tx,
14071 (void *)&cmd_vf_tc_bw_strict_link_prio,
14072 (void *)&cmd_vf_tc_bw_port_id,
14073 (void *)&cmd_vf_tc_bw_tc_map,
14078 /* Load dynamic device personalization*/
14079 struct cmd_ddp_add_result {
14080 cmdline_fixed_string_t ddp;
14081 cmdline_fixed_string_t add;
14086 cmdline_parse_token_string_t cmd_ddp_add_ddp =
14087 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp");
14088 cmdline_parse_token_string_t cmd_ddp_add_add =
14089 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add");
14090 cmdline_parse_token_num_t cmd_ddp_add_port_id =
14091 TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id, UINT16);
14092 cmdline_parse_token_string_t cmd_ddp_add_filepath =
14093 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL);
14096 cmd_ddp_add_parsed(
14097 void *parsed_result,
14098 __attribute__((unused)) struct cmdline *cl,
14099 __attribute__((unused)) void *data)
14101 struct cmd_ddp_add_result *res = parsed_result;
14107 int ret = -ENOTSUP;
14109 if (res->port_id > nb_ports) {
14110 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
14114 if (!all_ports_stopped()) {
14115 printf("Please stop all ports first\n");
14119 filepath = strdup(res->filepath);
14120 if (filepath == NULL) {
14121 printf("Failed to allocate memory\n");
14124 file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ',');
14126 buff = open_ddp_package_file(file_fld[0], &size);
14128 free((void *)filepath);
14132 #ifdef RTE_LIBRTE_I40E_PMD
14133 if (ret == -ENOTSUP)
14134 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
14136 RTE_PMD_I40E_PKG_OP_WR_ADD);
14139 if (ret == -EEXIST)
14140 printf("Profile has already existed.\n");
14142 printf("Failed to load profile.\n");
14143 else if (file_num == 2)
14144 save_ddp_package_file(file_fld[1], buff, size);
14146 close_ddp_package_file(buff);
14147 free((void *)filepath);
14150 cmdline_parse_inst_t cmd_ddp_add = {
14151 .f = cmd_ddp_add_parsed,
14153 .help_str = "ddp add <port_id> <profile_path[,output_path]>",
14155 (void *)&cmd_ddp_add_ddp,
14156 (void *)&cmd_ddp_add_add,
14157 (void *)&cmd_ddp_add_port_id,
14158 (void *)&cmd_ddp_add_filepath,
14163 /* Delete dynamic device personalization*/
14164 struct cmd_ddp_del_result {
14165 cmdline_fixed_string_t ddp;
14166 cmdline_fixed_string_t del;
14171 cmdline_parse_token_string_t cmd_ddp_del_ddp =
14172 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp");
14173 cmdline_parse_token_string_t cmd_ddp_del_del =
14174 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del");
14175 cmdline_parse_token_num_t cmd_ddp_del_port_id =
14176 TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, UINT16);
14177 cmdline_parse_token_string_t cmd_ddp_del_filepath =
14178 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL);
14181 cmd_ddp_del_parsed(
14182 void *parsed_result,
14183 __attribute__((unused)) struct cmdline *cl,
14184 __attribute__((unused)) void *data)
14186 struct cmd_ddp_del_result *res = parsed_result;
14189 int ret = -ENOTSUP;
14191 if (res->port_id > nb_ports) {
14192 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
14196 if (!all_ports_stopped()) {
14197 printf("Please stop all ports first\n");
14201 buff = open_ddp_package_file(res->filepath, &size);
14205 #ifdef RTE_LIBRTE_I40E_PMD
14206 if (ret == -ENOTSUP)
14207 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
14209 RTE_PMD_I40E_PKG_OP_WR_DEL);
14212 if (ret == -EACCES)
14213 printf("Profile does not exist.\n");
14215 printf("Failed to delete profile.\n");
14217 close_ddp_package_file(buff);
14220 cmdline_parse_inst_t cmd_ddp_del = {
14221 .f = cmd_ddp_del_parsed,
14223 .help_str = "ddp del <port_id> <profile_path>",
14225 (void *)&cmd_ddp_del_ddp,
14226 (void *)&cmd_ddp_del_del,
14227 (void *)&cmd_ddp_del_port_id,
14228 (void *)&cmd_ddp_del_filepath,
14233 /* Get dynamic device personalization profile info */
14234 struct cmd_ddp_info_result {
14235 cmdline_fixed_string_t ddp;
14236 cmdline_fixed_string_t get;
14237 cmdline_fixed_string_t info;
14241 cmdline_parse_token_string_t cmd_ddp_info_ddp =
14242 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp");
14243 cmdline_parse_token_string_t cmd_ddp_info_get =
14244 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get");
14245 cmdline_parse_token_string_t cmd_ddp_info_info =
14246 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info");
14247 cmdline_parse_token_string_t cmd_ddp_info_filepath =
14248 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL);
14251 cmd_ddp_info_parsed(
14252 void *parsed_result,
14253 __attribute__((unused)) struct cmdline *cl,
14254 __attribute__((unused)) void *data)
14256 struct cmd_ddp_info_result *res = parsed_result;
14259 int ret = -ENOTSUP;
14260 #ifdef RTE_LIBRTE_I40E_PMD
14263 uint32_t buff_size = 0;
14264 struct rte_pmd_i40e_profile_info info;
14265 uint32_t dev_num = 0;
14266 struct rte_pmd_i40e_ddp_device_id *devs;
14267 uint32_t proto_num = 0;
14268 struct rte_pmd_i40e_proto_info *proto;
14269 uint32_t pctype_num = 0;
14270 struct rte_pmd_i40e_ptype_info *pctype;
14271 uint32_t ptype_num = 0;
14272 struct rte_pmd_i40e_ptype_info *ptype;
14277 pkg = open_ddp_package_file(res->filepath, &pkg_size);
14281 #ifdef RTE_LIBRTE_I40E_PMD
14282 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14283 (uint8_t *)&info, sizeof(info),
14284 RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER);
14286 printf("Global Track id: 0x%x\n", info.track_id);
14287 printf("Global Version: %d.%d.%d.%d\n",
14288 info.version.major,
14289 info.version.minor,
14290 info.version.update,
14291 info.version.draft);
14292 printf("Global Package name: %s\n\n", info.name);
14295 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14296 (uint8_t *)&info, sizeof(info),
14297 RTE_PMD_I40E_PKG_INFO_HEADER);
14299 printf("i40e Profile Track id: 0x%x\n", info.track_id);
14300 printf("i40e Profile Version: %d.%d.%d.%d\n",
14301 info.version.major,
14302 info.version.minor,
14303 info.version.update,
14304 info.version.draft);
14305 printf("i40e Profile name: %s\n\n", info.name);
14308 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14309 (uint8_t *)&buff_size, sizeof(buff_size),
14310 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE);
14311 if (!ret && buff_size) {
14312 buff = (uint8_t *)malloc(buff_size);
14314 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14316 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES);
14318 printf("Package Notes:\n%s\n\n", buff);
14323 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14324 (uint8_t *)&dev_num, sizeof(dev_num),
14325 RTE_PMD_I40E_PKG_INFO_DEVID_NUM);
14326 if (!ret && dev_num) {
14327 buff_size = dev_num * sizeof(struct rte_pmd_i40e_ddp_device_id);
14328 devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(buff_size);
14330 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14331 (uint8_t *)devs, buff_size,
14332 RTE_PMD_I40E_PKG_INFO_DEVID_LIST);
14334 printf("List of supported devices:\n");
14335 for (i = 0; i < dev_num; i++) {
14336 printf(" %04X:%04X %04X:%04X\n",
14337 devs[i].vendor_dev_id >> 16,
14338 devs[i].vendor_dev_id & 0xFFFF,
14339 devs[i].sub_vendor_dev_id >> 16,
14340 devs[i].sub_vendor_dev_id & 0xFFFF);
14348 /* get information about protocols and packet types */
14349 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14350 (uint8_t *)&proto_num, sizeof(proto_num),
14351 RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM);
14352 if (ret || !proto_num)
14353 goto no_print_return;
14355 buff_size = proto_num * sizeof(struct rte_pmd_i40e_proto_info);
14356 proto = (struct rte_pmd_i40e_proto_info *)malloc(buff_size);
14358 goto no_print_return;
14360 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)proto,
14362 RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST);
14364 printf("List of used protocols:\n");
14365 for (i = 0; i < proto_num; i++)
14366 printf(" %2u: %s\n", proto[i].proto_id,
14370 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14371 (uint8_t *)&pctype_num, sizeof(pctype_num),
14372 RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM);
14373 if (ret || !pctype_num)
14374 goto no_print_pctypes;
14376 buff_size = pctype_num * sizeof(struct rte_pmd_i40e_ptype_info);
14377 pctype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
14379 goto no_print_pctypes;
14381 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)pctype,
14383 RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST);
14386 goto no_print_pctypes;
14389 printf("List of defined packet classification types:\n");
14390 for (i = 0; i < pctype_num; i++) {
14391 printf(" %2u:", pctype[i].ptype_id);
14392 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
14393 proto_id = pctype[i].protocols[j];
14394 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
14395 for (n = 0; n < proto_num; n++) {
14396 if (proto[n].proto_id == proto_id) {
14397 printf(" %s", proto[n].name);
14410 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)&ptype_num,
14412 RTE_PMD_I40E_PKG_INFO_PTYPE_NUM);
14413 if (ret || !ptype_num)
14414 goto no_print_return;
14416 buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_info);
14417 ptype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
14419 goto no_print_return;
14421 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)ptype,
14423 RTE_PMD_I40E_PKG_INFO_PTYPE_LIST);
14426 goto no_print_return;
14428 printf("List of defined packet types:\n");
14429 for (i = 0; i < ptype_num; i++) {
14430 printf(" %2u:", ptype[i].ptype_id);
14431 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
14432 proto_id = ptype[i].protocols[j];
14433 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
14434 for (n = 0; n < proto_num; n++) {
14435 if (proto[n].proto_id == proto_id) {
14436 printf(" %s", proto[n].name);
14451 if (ret == -ENOTSUP)
14452 printf("Function not supported in PMD driver\n");
14453 close_ddp_package_file(pkg);
14456 cmdline_parse_inst_t cmd_ddp_get_info = {
14457 .f = cmd_ddp_info_parsed,
14459 .help_str = "ddp get info <profile_path>",
14461 (void *)&cmd_ddp_info_ddp,
14462 (void *)&cmd_ddp_info_get,
14463 (void *)&cmd_ddp_info_info,
14464 (void *)&cmd_ddp_info_filepath,
14469 /* Get dynamic device personalization profile info list*/
14470 #define PROFILE_INFO_SIZE 48
14471 #define MAX_PROFILE_NUM 16
14473 struct cmd_ddp_get_list_result {
14474 cmdline_fixed_string_t ddp;
14475 cmdline_fixed_string_t get;
14476 cmdline_fixed_string_t list;
14480 cmdline_parse_token_string_t cmd_ddp_get_list_ddp =
14481 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp");
14482 cmdline_parse_token_string_t cmd_ddp_get_list_get =
14483 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get");
14484 cmdline_parse_token_string_t cmd_ddp_get_list_list =
14485 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list");
14486 cmdline_parse_token_num_t cmd_ddp_get_list_port_id =
14487 TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id, UINT16);
14490 cmd_ddp_get_list_parsed(
14491 void *parsed_result,
14492 __attribute__((unused)) struct cmdline *cl,
14493 __attribute__((unused)) void *data)
14495 struct cmd_ddp_get_list_result *res = parsed_result;
14496 #ifdef RTE_LIBRTE_I40E_PMD
14497 struct rte_pmd_i40e_profile_list *p_list;
14498 struct rte_pmd_i40e_profile_info *p_info;
14503 int ret = -ENOTSUP;
14505 if (res->port_id > nb_ports) {
14506 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
14510 #ifdef RTE_LIBRTE_I40E_PMD
14511 size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4;
14512 p_list = (struct rte_pmd_i40e_profile_list *)malloc(size);
14514 printf("%s: Failed to malloc buffer\n", __func__);
14516 if (ret == -ENOTSUP)
14517 ret = rte_pmd_i40e_get_ddp_list(res->port_id,
14518 (uint8_t *)p_list, size);
14521 p_num = p_list->p_count;
14522 printf("Profile number is: %d\n\n", p_num);
14524 for (i = 0; i < p_num; i++) {
14525 p_info = &p_list->p_info[i];
14526 printf("Profile %d:\n", i);
14527 printf("Track id: 0x%x\n", p_info->track_id);
14528 printf("Version: %d.%d.%d.%d\n",
14529 p_info->version.major,
14530 p_info->version.minor,
14531 p_info->version.update,
14532 p_info->version.draft);
14533 printf("Profile name: %s\n\n", p_info->name);
14541 printf("Failed to get ddp list\n");
14544 cmdline_parse_inst_t cmd_ddp_get_list = {
14545 .f = cmd_ddp_get_list_parsed,
14547 .help_str = "ddp get list <port_id>",
14549 (void *)&cmd_ddp_get_list_ddp,
14550 (void *)&cmd_ddp_get_list_get,
14551 (void *)&cmd_ddp_get_list_list,
14552 (void *)&cmd_ddp_get_list_port_id,
14557 /* show vf stats */
14559 /* Common result structure for show vf stats */
14560 struct cmd_show_vf_stats_result {
14561 cmdline_fixed_string_t show;
14562 cmdline_fixed_string_t vf;
14563 cmdline_fixed_string_t stats;
14568 /* Common CLI fields show vf stats*/
14569 cmdline_parse_token_string_t cmd_show_vf_stats_show =
14570 TOKEN_STRING_INITIALIZER
14571 (struct cmd_show_vf_stats_result,
14573 cmdline_parse_token_string_t cmd_show_vf_stats_vf =
14574 TOKEN_STRING_INITIALIZER
14575 (struct cmd_show_vf_stats_result,
14577 cmdline_parse_token_string_t cmd_show_vf_stats_stats =
14578 TOKEN_STRING_INITIALIZER
14579 (struct cmd_show_vf_stats_result,
14581 cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
14582 TOKEN_NUM_INITIALIZER
14583 (struct cmd_show_vf_stats_result,
14585 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
14586 TOKEN_NUM_INITIALIZER
14587 (struct cmd_show_vf_stats_result,
14591 cmd_show_vf_stats_parsed(
14592 void *parsed_result,
14593 __attribute__((unused)) struct cmdline *cl,
14594 __attribute__((unused)) void *data)
14596 struct cmd_show_vf_stats_result *res = parsed_result;
14597 struct rte_eth_stats stats;
14598 int ret = -ENOTSUP;
14599 static const char *nic_stats_border = "########################";
14601 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14604 memset(&stats, 0, sizeof(stats));
14606 #ifdef RTE_LIBRTE_I40E_PMD
14607 if (ret == -ENOTSUP)
14608 ret = rte_pmd_i40e_get_vf_stats(res->port_id,
14612 #ifdef RTE_LIBRTE_BNXT_PMD
14613 if (ret == -ENOTSUP)
14614 ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
14623 printf("invalid vf_id %d\n", res->vf_id);
14626 printf("invalid port_id %d\n", res->port_id);
14629 printf("function not implemented\n");
14632 printf("programming error: (%s)\n", strerror(-ret));
14635 printf("\n %s NIC statistics for port %-2d vf %-2d %s\n",
14636 nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
14638 printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: "
14640 stats.ipackets, stats.imissed, stats.ibytes);
14641 printf(" RX-errors: %-"PRIu64"\n", stats.ierrors);
14642 printf(" RX-nombuf: %-10"PRIu64"\n",
14644 printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: "
14646 stats.opackets, stats.oerrors, stats.obytes);
14648 printf(" %s############################%s\n",
14649 nic_stats_border, nic_stats_border);
14652 cmdline_parse_inst_t cmd_show_vf_stats = {
14653 .f = cmd_show_vf_stats_parsed,
14655 .help_str = "show vf stats <port_id> <vf_id>",
14657 (void *)&cmd_show_vf_stats_show,
14658 (void *)&cmd_show_vf_stats_vf,
14659 (void *)&cmd_show_vf_stats_stats,
14660 (void *)&cmd_show_vf_stats_port_id,
14661 (void *)&cmd_show_vf_stats_vf_id,
14666 /* clear vf stats */
14668 /* Common result structure for clear vf stats */
14669 struct cmd_clear_vf_stats_result {
14670 cmdline_fixed_string_t clear;
14671 cmdline_fixed_string_t vf;
14672 cmdline_fixed_string_t stats;
14677 /* Common CLI fields clear vf stats*/
14678 cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
14679 TOKEN_STRING_INITIALIZER
14680 (struct cmd_clear_vf_stats_result,
14682 cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
14683 TOKEN_STRING_INITIALIZER
14684 (struct cmd_clear_vf_stats_result,
14686 cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
14687 TOKEN_STRING_INITIALIZER
14688 (struct cmd_clear_vf_stats_result,
14690 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
14691 TOKEN_NUM_INITIALIZER
14692 (struct cmd_clear_vf_stats_result,
14694 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
14695 TOKEN_NUM_INITIALIZER
14696 (struct cmd_clear_vf_stats_result,
14700 cmd_clear_vf_stats_parsed(
14701 void *parsed_result,
14702 __attribute__((unused)) struct cmdline *cl,
14703 __attribute__((unused)) void *data)
14705 struct cmd_clear_vf_stats_result *res = parsed_result;
14706 int ret = -ENOTSUP;
14708 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14711 #ifdef RTE_LIBRTE_I40E_PMD
14712 if (ret == -ENOTSUP)
14713 ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
14716 #ifdef RTE_LIBRTE_BNXT_PMD
14717 if (ret == -ENOTSUP)
14718 ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
14726 printf("invalid vf_id %d\n", res->vf_id);
14729 printf("invalid port_id %d\n", res->port_id);
14732 printf("function not implemented\n");
14735 printf("programming error: (%s)\n", strerror(-ret));
14739 cmdline_parse_inst_t cmd_clear_vf_stats = {
14740 .f = cmd_clear_vf_stats_parsed,
14742 .help_str = "clear vf stats <port_id> <vf_id>",
14744 (void *)&cmd_clear_vf_stats_clear,
14745 (void *)&cmd_clear_vf_stats_vf,
14746 (void *)&cmd_clear_vf_stats_stats,
14747 (void *)&cmd_clear_vf_stats_port_id,
14748 (void *)&cmd_clear_vf_stats_vf_id,
14753 /* port config pctype mapping reset */
14755 /* Common result structure for port config pctype mapping reset */
14756 struct cmd_pctype_mapping_reset_result {
14757 cmdline_fixed_string_t port;
14758 cmdline_fixed_string_t config;
14760 cmdline_fixed_string_t pctype;
14761 cmdline_fixed_string_t mapping;
14762 cmdline_fixed_string_t reset;
14765 /* Common CLI fields for port config pctype mapping reset*/
14766 cmdline_parse_token_string_t cmd_pctype_mapping_reset_port =
14767 TOKEN_STRING_INITIALIZER
14768 (struct cmd_pctype_mapping_reset_result,
14770 cmdline_parse_token_string_t cmd_pctype_mapping_reset_config =
14771 TOKEN_STRING_INITIALIZER
14772 (struct cmd_pctype_mapping_reset_result,
14774 cmdline_parse_token_num_t cmd_pctype_mapping_reset_port_id =
14775 TOKEN_NUM_INITIALIZER
14776 (struct cmd_pctype_mapping_reset_result,
14778 cmdline_parse_token_string_t cmd_pctype_mapping_reset_pctype =
14779 TOKEN_STRING_INITIALIZER
14780 (struct cmd_pctype_mapping_reset_result,
14782 cmdline_parse_token_string_t cmd_pctype_mapping_reset_mapping =
14783 TOKEN_STRING_INITIALIZER
14784 (struct cmd_pctype_mapping_reset_result,
14785 mapping, "mapping");
14786 cmdline_parse_token_string_t cmd_pctype_mapping_reset_reset =
14787 TOKEN_STRING_INITIALIZER
14788 (struct cmd_pctype_mapping_reset_result,
14792 cmd_pctype_mapping_reset_parsed(
14793 void *parsed_result,
14794 __attribute__((unused)) struct cmdline *cl,
14795 __attribute__((unused)) void *data)
14797 struct cmd_pctype_mapping_reset_result *res = parsed_result;
14798 int ret = -ENOTSUP;
14800 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14803 #ifdef RTE_LIBRTE_I40E_PMD
14804 ret = rte_pmd_i40e_flow_type_mapping_reset(res->port_id);
14811 printf("invalid port_id %d\n", res->port_id);
14814 printf("function not implemented\n");
14817 printf("programming error: (%s)\n", strerror(-ret));
14821 cmdline_parse_inst_t cmd_pctype_mapping_reset = {
14822 .f = cmd_pctype_mapping_reset_parsed,
14824 .help_str = "port config <port_id> pctype mapping reset",
14826 (void *)&cmd_pctype_mapping_reset_port,
14827 (void *)&cmd_pctype_mapping_reset_config,
14828 (void *)&cmd_pctype_mapping_reset_port_id,
14829 (void *)&cmd_pctype_mapping_reset_pctype,
14830 (void *)&cmd_pctype_mapping_reset_mapping,
14831 (void *)&cmd_pctype_mapping_reset_reset,
14836 /* show port pctype mapping */
14838 /* Common result structure for show port pctype mapping */
14839 struct cmd_pctype_mapping_get_result {
14840 cmdline_fixed_string_t show;
14841 cmdline_fixed_string_t port;
14843 cmdline_fixed_string_t pctype;
14844 cmdline_fixed_string_t mapping;
14847 /* Common CLI fields for pctype mapping get */
14848 cmdline_parse_token_string_t cmd_pctype_mapping_get_show =
14849 TOKEN_STRING_INITIALIZER
14850 (struct cmd_pctype_mapping_get_result,
14852 cmdline_parse_token_string_t cmd_pctype_mapping_get_port =
14853 TOKEN_STRING_INITIALIZER
14854 (struct cmd_pctype_mapping_get_result,
14856 cmdline_parse_token_num_t cmd_pctype_mapping_get_port_id =
14857 TOKEN_NUM_INITIALIZER
14858 (struct cmd_pctype_mapping_get_result,
14860 cmdline_parse_token_string_t cmd_pctype_mapping_get_pctype =
14861 TOKEN_STRING_INITIALIZER
14862 (struct cmd_pctype_mapping_get_result,
14864 cmdline_parse_token_string_t cmd_pctype_mapping_get_mapping =
14865 TOKEN_STRING_INITIALIZER
14866 (struct cmd_pctype_mapping_get_result,
14867 mapping, "mapping");
14870 cmd_pctype_mapping_get_parsed(
14871 void *parsed_result,
14872 __attribute__((unused)) struct cmdline *cl,
14873 __attribute__((unused)) void *data)
14875 struct cmd_pctype_mapping_get_result *res = parsed_result;
14876 int ret = -ENOTSUP;
14877 #ifdef RTE_LIBRTE_I40E_PMD
14878 struct rte_pmd_i40e_flow_type_mapping
14879 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
14880 int i, j, first_pctype;
14883 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14886 #ifdef RTE_LIBRTE_I40E_PMD
14887 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, mapping);
14894 printf("invalid port_id %d\n", res->port_id);
14897 printf("function not implemented\n");
14900 printf("programming error: (%s)\n", strerror(-ret));
14904 #ifdef RTE_LIBRTE_I40E_PMD
14905 for (i = 0; i < RTE_PMD_I40E_FLOW_TYPE_MAX; i++) {
14906 if (mapping[i].pctype != 0ULL) {
14909 printf("pctype: ");
14910 for (j = 0; j < RTE_PMD_I40E_PCTYPE_MAX; j++) {
14911 if (mapping[i].pctype & (1ULL << j)) {
14912 printf(first_pctype ?
14913 "%02d" : ",%02d", j);
14917 printf(" -> flowtype: %02d\n", mapping[i].flow_type);
14923 cmdline_parse_inst_t cmd_pctype_mapping_get = {
14924 .f = cmd_pctype_mapping_get_parsed,
14926 .help_str = "show port <port_id> pctype mapping",
14928 (void *)&cmd_pctype_mapping_get_show,
14929 (void *)&cmd_pctype_mapping_get_port,
14930 (void *)&cmd_pctype_mapping_get_port_id,
14931 (void *)&cmd_pctype_mapping_get_pctype,
14932 (void *)&cmd_pctype_mapping_get_mapping,
14937 /* port config pctype mapping update */
14939 /* Common result structure for port config pctype mapping update */
14940 struct cmd_pctype_mapping_update_result {
14941 cmdline_fixed_string_t port;
14942 cmdline_fixed_string_t config;
14944 cmdline_fixed_string_t pctype;
14945 cmdline_fixed_string_t mapping;
14946 cmdline_fixed_string_t update;
14947 cmdline_fixed_string_t pctype_list;
14948 uint16_t flow_type;
14951 /* Common CLI fields for pctype mapping update*/
14952 cmdline_parse_token_string_t cmd_pctype_mapping_update_port =
14953 TOKEN_STRING_INITIALIZER
14954 (struct cmd_pctype_mapping_update_result,
14956 cmdline_parse_token_string_t cmd_pctype_mapping_update_config =
14957 TOKEN_STRING_INITIALIZER
14958 (struct cmd_pctype_mapping_update_result,
14960 cmdline_parse_token_num_t cmd_pctype_mapping_update_port_id =
14961 TOKEN_NUM_INITIALIZER
14962 (struct cmd_pctype_mapping_update_result,
14964 cmdline_parse_token_string_t cmd_pctype_mapping_update_pctype =
14965 TOKEN_STRING_INITIALIZER
14966 (struct cmd_pctype_mapping_update_result,
14968 cmdline_parse_token_string_t cmd_pctype_mapping_update_mapping =
14969 TOKEN_STRING_INITIALIZER
14970 (struct cmd_pctype_mapping_update_result,
14971 mapping, "mapping");
14972 cmdline_parse_token_string_t cmd_pctype_mapping_update_update =
14973 TOKEN_STRING_INITIALIZER
14974 (struct cmd_pctype_mapping_update_result,
14976 cmdline_parse_token_string_t cmd_pctype_mapping_update_pc_type =
14977 TOKEN_STRING_INITIALIZER
14978 (struct cmd_pctype_mapping_update_result,
14979 pctype_list, NULL);
14980 cmdline_parse_token_num_t cmd_pctype_mapping_update_flow_type =
14981 TOKEN_NUM_INITIALIZER
14982 (struct cmd_pctype_mapping_update_result,
14983 flow_type, UINT16);
14986 cmd_pctype_mapping_update_parsed(
14987 void *parsed_result,
14988 __attribute__((unused)) struct cmdline *cl,
14989 __attribute__((unused)) void *data)
14991 struct cmd_pctype_mapping_update_result *res = parsed_result;
14992 int ret = -ENOTSUP;
14993 #ifdef RTE_LIBRTE_I40E_PMD
14994 struct rte_pmd_i40e_flow_type_mapping mapping;
14996 unsigned int nb_item;
14997 unsigned int pctype_list[RTE_PMD_I40E_PCTYPE_MAX];
15000 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15003 #ifdef RTE_LIBRTE_I40E_PMD
15004 nb_item = parse_item_list(res->pctype_list, "pctypes",
15005 RTE_PMD_I40E_PCTYPE_MAX, pctype_list, 1);
15006 mapping.flow_type = res->flow_type;
15007 for (i = 0, mapping.pctype = 0ULL; i < nb_item; i++)
15008 mapping.pctype |= (1ULL << pctype_list[i]);
15009 ret = rte_pmd_i40e_flow_type_mapping_update(res->port_id,
15019 printf("invalid pctype or flow type\n");
15022 printf("invalid port_id %d\n", res->port_id);
15025 printf("function not implemented\n");
15028 printf("programming error: (%s)\n", strerror(-ret));
15032 cmdline_parse_inst_t cmd_pctype_mapping_update = {
15033 .f = cmd_pctype_mapping_update_parsed,
15035 .help_str = "port config <port_id> pctype mapping update"
15036 " <pctype_id_0,[pctype_id_1]*> <flowtype_id>",
15038 (void *)&cmd_pctype_mapping_update_port,
15039 (void *)&cmd_pctype_mapping_update_config,
15040 (void *)&cmd_pctype_mapping_update_port_id,
15041 (void *)&cmd_pctype_mapping_update_pctype,
15042 (void *)&cmd_pctype_mapping_update_mapping,
15043 (void *)&cmd_pctype_mapping_update_update,
15044 (void *)&cmd_pctype_mapping_update_pc_type,
15045 (void *)&cmd_pctype_mapping_update_flow_type,
15050 /* ptype mapping get */
15052 /* Common result structure for ptype mapping get */
15053 struct cmd_ptype_mapping_get_result {
15054 cmdline_fixed_string_t ptype;
15055 cmdline_fixed_string_t mapping;
15056 cmdline_fixed_string_t get;
15058 uint8_t valid_only;
15061 /* Common CLI fields for ptype mapping get */
15062 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype =
15063 TOKEN_STRING_INITIALIZER
15064 (struct cmd_ptype_mapping_get_result,
15066 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping =
15067 TOKEN_STRING_INITIALIZER
15068 (struct cmd_ptype_mapping_get_result,
15069 mapping, "mapping");
15070 cmdline_parse_token_string_t cmd_ptype_mapping_get_get =
15071 TOKEN_STRING_INITIALIZER
15072 (struct cmd_ptype_mapping_get_result,
15074 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id =
15075 TOKEN_NUM_INITIALIZER
15076 (struct cmd_ptype_mapping_get_result,
15078 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only =
15079 TOKEN_NUM_INITIALIZER
15080 (struct cmd_ptype_mapping_get_result,
15081 valid_only, UINT8);
15084 cmd_ptype_mapping_get_parsed(
15085 void *parsed_result,
15086 __attribute__((unused)) struct cmdline *cl,
15087 __attribute__((unused)) void *data)
15089 struct cmd_ptype_mapping_get_result *res = parsed_result;
15090 int ret = -ENOTSUP;
15091 #ifdef RTE_LIBRTE_I40E_PMD
15092 int max_ptype_num = 256;
15093 struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num];
15098 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15101 #ifdef RTE_LIBRTE_I40E_PMD
15102 ret = rte_pmd_i40e_ptype_mapping_get(res->port_id,
15113 printf("invalid port_id %d\n", res->port_id);
15116 printf("function not implemented\n");
15119 printf("programming error: (%s)\n", strerror(-ret));
15122 #ifdef RTE_LIBRTE_I40E_PMD
15124 for (i = 0; i < count; i++)
15125 printf("%3d\t0x%08x\n",
15126 mapping[i].hw_ptype, mapping[i].sw_ptype);
15131 cmdline_parse_inst_t cmd_ptype_mapping_get = {
15132 .f = cmd_ptype_mapping_get_parsed,
15134 .help_str = "ptype mapping get <port_id> <valid_only>",
15136 (void *)&cmd_ptype_mapping_get_ptype,
15137 (void *)&cmd_ptype_mapping_get_mapping,
15138 (void *)&cmd_ptype_mapping_get_get,
15139 (void *)&cmd_ptype_mapping_get_port_id,
15140 (void *)&cmd_ptype_mapping_get_valid_only,
15145 /* ptype mapping replace */
15147 /* Common result structure for ptype mapping replace */
15148 struct cmd_ptype_mapping_replace_result {
15149 cmdline_fixed_string_t ptype;
15150 cmdline_fixed_string_t mapping;
15151 cmdline_fixed_string_t replace;
15158 /* Common CLI fields for ptype mapping replace */
15159 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype =
15160 TOKEN_STRING_INITIALIZER
15161 (struct cmd_ptype_mapping_replace_result,
15163 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping =
15164 TOKEN_STRING_INITIALIZER
15165 (struct cmd_ptype_mapping_replace_result,
15166 mapping, "mapping");
15167 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace =
15168 TOKEN_STRING_INITIALIZER
15169 (struct cmd_ptype_mapping_replace_result,
15170 replace, "replace");
15171 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id =
15172 TOKEN_NUM_INITIALIZER
15173 (struct cmd_ptype_mapping_replace_result,
15175 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target =
15176 TOKEN_NUM_INITIALIZER
15177 (struct cmd_ptype_mapping_replace_result,
15179 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask =
15180 TOKEN_NUM_INITIALIZER
15181 (struct cmd_ptype_mapping_replace_result,
15183 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type =
15184 TOKEN_NUM_INITIALIZER
15185 (struct cmd_ptype_mapping_replace_result,
15189 cmd_ptype_mapping_replace_parsed(
15190 void *parsed_result,
15191 __attribute__((unused)) struct cmdline *cl,
15192 __attribute__((unused)) void *data)
15194 struct cmd_ptype_mapping_replace_result *res = parsed_result;
15195 int ret = -ENOTSUP;
15197 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15200 #ifdef RTE_LIBRTE_I40E_PMD
15201 ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id,
15211 printf("invalid ptype 0x%8x or 0x%8x\n",
15212 res->target, res->pkt_type);
15215 printf("invalid port_id %d\n", res->port_id);
15218 printf("function not implemented\n");
15221 printf("programming error: (%s)\n", strerror(-ret));
15225 cmdline_parse_inst_t cmd_ptype_mapping_replace = {
15226 .f = cmd_ptype_mapping_replace_parsed,
15229 "ptype mapping replace <port_id> <target> <mask> <pkt_type>",
15231 (void *)&cmd_ptype_mapping_replace_ptype,
15232 (void *)&cmd_ptype_mapping_replace_mapping,
15233 (void *)&cmd_ptype_mapping_replace_replace,
15234 (void *)&cmd_ptype_mapping_replace_port_id,
15235 (void *)&cmd_ptype_mapping_replace_target,
15236 (void *)&cmd_ptype_mapping_replace_mask,
15237 (void *)&cmd_ptype_mapping_replace_pkt_type,
15242 /* ptype mapping reset */
15244 /* Common result structure for ptype mapping reset */
15245 struct cmd_ptype_mapping_reset_result {
15246 cmdline_fixed_string_t ptype;
15247 cmdline_fixed_string_t mapping;
15248 cmdline_fixed_string_t reset;
15252 /* Common CLI fields for ptype mapping reset*/
15253 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype =
15254 TOKEN_STRING_INITIALIZER
15255 (struct cmd_ptype_mapping_reset_result,
15257 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping =
15258 TOKEN_STRING_INITIALIZER
15259 (struct cmd_ptype_mapping_reset_result,
15260 mapping, "mapping");
15261 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset =
15262 TOKEN_STRING_INITIALIZER
15263 (struct cmd_ptype_mapping_reset_result,
15265 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id =
15266 TOKEN_NUM_INITIALIZER
15267 (struct cmd_ptype_mapping_reset_result,
15271 cmd_ptype_mapping_reset_parsed(
15272 void *parsed_result,
15273 __attribute__((unused)) struct cmdline *cl,
15274 __attribute__((unused)) void *data)
15276 struct cmd_ptype_mapping_reset_result *res = parsed_result;
15277 int ret = -ENOTSUP;
15279 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15282 #ifdef RTE_LIBRTE_I40E_PMD
15283 ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id);
15290 printf("invalid port_id %d\n", res->port_id);
15293 printf("function not implemented\n");
15296 printf("programming error: (%s)\n", strerror(-ret));
15300 cmdline_parse_inst_t cmd_ptype_mapping_reset = {
15301 .f = cmd_ptype_mapping_reset_parsed,
15303 .help_str = "ptype mapping reset <port_id>",
15305 (void *)&cmd_ptype_mapping_reset_ptype,
15306 (void *)&cmd_ptype_mapping_reset_mapping,
15307 (void *)&cmd_ptype_mapping_reset_reset,
15308 (void *)&cmd_ptype_mapping_reset_port_id,
15313 /* ptype mapping update */
15315 /* Common result structure for ptype mapping update */
15316 struct cmd_ptype_mapping_update_result {
15317 cmdline_fixed_string_t ptype;
15318 cmdline_fixed_string_t mapping;
15319 cmdline_fixed_string_t reset;
15325 /* Common CLI fields for ptype mapping update*/
15326 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype =
15327 TOKEN_STRING_INITIALIZER
15328 (struct cmd_ptype_mapping_update_result,
15330 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping =
15331 TOKEN_STRING_INITIALIZER
15332 (struct cmd_ptype_mapping_update_result,
15333 mapping, "mapping");
15334 cmdline_parse_token_string_t cmd_ptype_mapping_update_update =
15335 TOKEN_STRING_INITIALIZER
15336 (struct cmd_ptype_mapping_update_result,
15338 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id =
15339 TOKEN_NUM_INITIALIZER
15340 (struct cmd_ptype_mapping_update_result,
15342 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype =
15343 TOKEN_NUM_INITIALIZER
15344 (struct cmd_ptype_mapping_update_result,
15346 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype =
15347 TOKEN_NUM_INITIALIZER
15348 (struct cmd_ptype_mapping_update_result,
15352 cmd_ptype_mapping_update_parsed(
15353 void *parsed_result,
15354 __attribute__((unused)) struct cmdline *cl,
15355 __attribute__((unused)) void *data)
15357 struct cmd_ptype_mapping_update_result *res = parsed_result;
15358 int ret = -ENOTSUP;
15359 #ifdef RTE_LIBRTE_I40E_PMD
15360 struct rte_pmd_i40e_ptype_mapping mapping;
15362 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15365 #ifdef RTE_LIBRTE_I40E_PMD
15366 mapping.hw_ptype = res->hw_ptype;
15367 mapping.sw_ptype = res->sw_ptype;
15368 ret = rte_pmd_i40e_ptype_mapping_update(res->port_id,
15378 printf("invalid ptype 0x%8x\n", res->sw_ptype);
15381 printf("invalid port_id %d\n", res->port_id);
15384 printf("function not implemented\n");
15387 printf("programming error: (%s)\n", strerror(-ret));
15391 cmdline_parse_inst_t cmd_ptype_mapping_update = {
15392 .f = cmd_ptype_mapping_update_parsed,
15394 .help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>",
15396 (void *)&cmd_ptype_mapping_update_ptype,
15397 (void *)&cmd_ptype_mapping_update_mapping,
15398 (void *)&cmd_ptype_mapping_update_update,
15399 (void *)&cmd_ptype_mapping_update_port_id,
15400 (void *)&cmd_ptype_mapping_update_hw_ptype,
15401 (void *)&cmd_ptype_mapping_update_sw_ptype,
15406 /* Common result structure for file commands */
15407 struct cmd_cmdfile_result {
15408 cmdline_fixed_string_t load;
15409 cmdline_fixed_string_t filename;
15412 /* Common CLI fields for file commands */
15413 cmdline_parse_token_string_t cmd_load_cmdfile =
15414 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
15415 cmdline_parse_token_string_t cmd_load_cmdfile_filename =
15416 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
15419 cmd_load_from_file_parsed(
15420 void *parsed_result,
15421 __attribute__((unused)) struct cmdline *cl,
15422 __attribute__((unused)) void *data)
15424 struct cmd_cmdfile_result *res = parsed_result;
15426 cmdline_read_from_file(res->filename);
15429 cmdline_parse_inst_t cmd_load_from_file = {
15430 .f = cmd_load_from_file_parsed,
15432 .help_str = "load <filename>",
15434 (void *)&cmd_load_cmdfile,
15435 (void *)&cmd_load_cmdfile_filename,
15440 /* ******************************************************************************** */
15442 /* list of instructions */
15443 cmdline_parse_ctx_t main_ctx[] = {
15444 (cmdline_parse_inst_t *)&cmd_help_brief,
15445 (cmdline_parse_inst_t *)&cmd_help_long,
15446 (cmdline_parse_inst_t *)&cmd_quit,
15447 (cmdline_parse_inst_t *)&cmd_load_from_file,
15448 (cmdline_parse_inst_t *)&cmd_showport,
15449 (cmdline_parse_inst_t *)&cmd_showqueue,
15450 (cmdline_parse_inst_t *)&cmd_showportall,
15451 (cmdline_parse_inst_t *)&cmd_showcfg,
15452 (cmdline_parse_inst_t *)&cmd_start,
15453 (cmdline_parse_inst_t *)&cmd_start_tx_first,
15454 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
15455 (cmdline_parse_inst_t *)&cmd_set_link_up,
15456 (cmdline_parse_inst_t *)&cmd_set_link_down,
15457 (cmdline_parse_inst_t *)&cmd_reset,
15458 (cmdline_parse_inst_t *)&cmd_set_numbers,
15459 (cmdline_parse_inst_t *)&cmd_set_txpkts,
15460 (cmdline_parse_inst_t *)&cmd_set_txsplit,
15461 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
15462 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
15463 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
15464 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
15465 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
15466 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
15467 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
15468 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
15469 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
15470 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
15471 (cmdline_parse_inst_t *)&cmd_set_link_check,
15472 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
15473 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
15474 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
15475 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
15476 #ifdef RTE_LIBRTE_PMD_BOND
15477 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
15478 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
15479 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
15480 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
15481 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
15482 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
15483 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
15484 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
15485 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
15486 (cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues,
15487 (cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy,
15489 (cmdline_parse_inst_t *)&cmd_vlan_offload,
15490 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
15491 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
15492 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
15493 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
15494 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
15495 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
15496 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
15497 (cmdline_parse_inst_t *)&cmd_csum_set,
15498 (cmdline_parse_inst_t *)&cmd_csum_show,
15499 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
15500 (cmdline_parse_inst_t *)&cmd_tso_set,
15501 (cmdline_parse_inst_t *)&cmd_tso_show,
15502 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
15503 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
15504 (cmdline_parse_inst_t *)&cmd_gro_enable,
15505 (cmdline_parse_inst_t *)&cmd_gro_flush,
15506 (cmdline_parse_inst_t *)&cmd_gro_show,
15507 (cmdline_parse_inst_t *)&cmd_gso_enable,
15508 (cmdline_parse_inst_t *)&cmd_gso_size,
15509 (cmdline_parse_inst_t *)&cmd_gso_show,
15510 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
15511 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
15512 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
15513 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
15514 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
15515 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
15516 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
15517 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
15518 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
15519 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
15520 (cmdline_parse_inst_t *)&cmd_config_dcb,
15521 (cmdline_parse_inst_t *)&cmd_read_reg,
15522 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
15523 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
15524 (cmdline_parse_inst_t *)&cmd_write_reg,
15525 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
15526 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
15527 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
15528 (cmdline_parse_inst_t *)&cmd_stop,
15529 (cmdline_parse_inst_t *)&cmd_mac_addr,
15530 (cmdline_parse_inst_t *)&cmd_set_qmap,
15531 (cmdline_parse_inst_t *)&cmd_operate_port,
15532 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
15533 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
15534 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
15535 (cmdline_parse_inst_t *)&cmd_config_speed_all,
15536 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
15537 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
15538 (cmdline_parse_inst_t *)&cmd_config_mtu,
15539 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
15540 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
15541 (cmdline_parse_inst_t *)&cmd_config_rss,
15542 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
15543 (cmdline_parse_inst_t *)&cmd_config_txqflags,
15544 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
15545 (cmdline_parse_inst_t *)&cmd_showport_reta,
15546 (cmdline_parse_inst_t *)&cmd_config_burst,
15547 (cmdline_parse_inst_t *)&cmd_config_thresh,
15548 (cmdline_parse_inst_t *)&cmd_config_threshold,
15549 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
15550 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
15551 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
15552 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
15553 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
15554 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
15555 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
15556 (cmdline_parse_inst_t *)&cmd_global_config,
15557 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
15558 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
15559 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
15560 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
15561 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
15562 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
15563 (cmdline_parse_inst_t *)&cmd_dump,
15564 (cmdline_parse_inst_t *)&cmd_dump_one,
15565 (cmdline_parse_inst_t *)&cmd_ethertype_filter,
15566 (cmdline_parse_inst_t *)&cmd_syn_filter,
15567 (cmdline_parse_inst_t *)&cmd_2tuple_filter,
15568 (cmdline_parse_inst_t *)&cmd_5tuple_filter,
15569 (cmdline_parse_inst_t *)&cmd_flex_filter,
15570 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
15571 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
15572 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
15573 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director,
15574 (cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director,
15575 (cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director,
15576 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
15577 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
15578 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
15579 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
15580 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
15581 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
15582 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
15583 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
15584 (cmdline_parse_inst_t *)&cmd_get_hash_global_config,
15585 (cmdline_parse_inst_t *)&cmd_set_hash_global_config,
15586 (cmdline_parse_inst_t *)&cmd_set_hash_input_set,
15587 (cmdline_parse_inst_t *)&cmd_set_fdir_input_set,
15588 (cmdline_parse_inst_t *)&cmd_flow,
15589 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm,
15590 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm,
15591 (cmdline_parse_inst_t *)&cmd_del_port_meter_profile,
15592 (cmdline_parse_inst_t *)&cmd_set_port_meter,
15593 (cmdline_parse_inst_t *)&cmd_del_port_meter,
15594 (cmdline_parse_inst_t *)&cmd_set_port_meter_profile,
15595 (cmdline_parse_inst_t *)&cmd_set_port_meter_policer_action,
15596 (cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask,
15597 (cmdline_parse_inst_t *)&cmd_show_port_meter_stats,
15598 (cmdline_parse_inst_t *)&cmd_mcast_addr,
15599 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all,
15600 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific,
15601 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all,
15602 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific,
15603 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_en,
15604 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_dis,
15605 (cmdline_parse_inst_t *)&cmd_config_e_tag_stripping_en_dis,
15606 (cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis,
15607 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_add,
15608 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_del,
15609 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
15610 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
15611 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
15612 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
15613 (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
15614 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
15615 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
15616 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
15617 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
15618 (cmdline_parse_inst_t *)&cmd_set_macsec_sc,
15619 (cmdline_parse_inst_t *)&cmd_set_macsec_sa,
15620 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
15621 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
15622 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
15623 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
15624 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
15625 (cmdline_parse_inst_t *)&cmd_set_vf_promisc,
15626 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
15627 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
15628 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
15629 (cmdline_parse_inst_t *)&cmd_vf_max_bw,
15630 (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
15631 (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
15632 (cmdline_parse_inst_t *)&cmd_strict_link_prio,
15633 (cmdline_parse_inst_t *)&cmd_tc_min_bw,
15634 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
15635 (cmdline_parse_inst_t *)&cmd_set_port_tm_hierarchy_default,
15637 (cmdline_parse_inst_t *)&cmd_ddp_add,
15638 (cmdline_parse_inst_t *)&cmd_ddp_del,
15639 (cmdline_parse_inst_t *)&cmd_ddp_get_list,
15640 (cmdline_parse_inst_t *)&cmd_ddp_get_info,
15641 (cmdline_parse_inst_t *)&cmd_show_vf_stats,
15642 (cmdline_parse_inst_t *)&cmd_clear_vf_stats,
15643 (cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
15644 (cmdline_parse_inst_t *)&cmd_ptype_mapping_replace,
15645 (cmdline_parse_inst_t *)&cmd_ptype_mapping_reset,
15646 (cmdline_parse_inst_t *)&cmd_ptype_mapping_update,
15648 (cmdline_parse_inst_t *)&cmd_pctype_mapping_get,
15649 (cmdline_parse_inst_t *)&cmd_pctype_mapping_reset,
15650 (cmdline_parse_inst_t *)&cmd_pctype_mapping_update,
15651 (cmdline_parse_inst_t *)&cmd_queue_region,
15652 (cmdline_parse_inst_t *)&cmd_region_flowtype,
15653 (cmdline_parse_inst_t *)&cmd_user_priority_region,
15654 (cmdline_parse_inst_t *)&cmd_flush_queue_region,
15655 (cmdline_parse_inst_t *)&cmd_show_queue_region_info_all,
15656 (cmdline_parse_inst_t *)&cmd_show_port_tm_cap,
15657 (cmdline_parse_inst_t *)&cmd_show_port_tm_level_cap,
15658 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_cap,
15659 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_type,
15660 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_stats,
15664 /* read cmdline commands from file */
15666 cmdline_read_from_file(const char *filename)
15668 struct cmdline *cl;
15670 cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
15672 printf("Failed to create file based cmdline context: %s\n",
15677 cmdline_interact(cl);
15682 printf("Read CLI commands from %s\n", filename);
15685 /* prompt function, called from main on MASTER lcore */
15689 /* initialize non-constant commands */
15690 cmd_set_fwd_mode_init();
15691 cmd_set_fwd_retry_mode_init();
15693 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
15694 if (testpmd_cl == NULL)
15696 cmdline_interact(testpmd_cl);
15697 cmdline_stdin_exit(testpmd_cl);
15703 if (testpmd_cl != NULL)
15704 cmdline_quit(testpmd_cl);
15708 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
15710 if (id == (portid_t)RTE_PORT_ALL) {
15713 RTE_ETH_FOREACH_DEV(pid) {
15714 /* check if need_reconfig has been set to 1 */
15715 if (ports[pid].need_reconfig == 0)
15716 ports[pid].need_reconfig = dev;
15717 /* check if need_reconfig_queues has been set to 1 */
15718 if (ports[pid].need_reconfig_queues == 0)
15719 ports[pid].need_reconfig_queues = queue;
15721 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
15722 /* check if need_reconfig has been set to 1 */
15723 if (ports[id].need_reconfig == 0)
15724 ports[id].need_reconfig = dev;
15725 /* check if need_reconfig_queues has been set to 1 */
15726 if (ports[id].need_reconfig_queues == 0)
15727 ports[id].need_reconfig_queues = queue;