4 * Copyright(c) 2010-2016 Intel Corporation. All rights reserved.
5 * Copyright(c) 2014 6WIND S.A.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
12 * * Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * * Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in
16 * the documentation and/or other materials provided with the
18 * * Neither the name of Intel Corporation nor the names of its
19 * contributors may be used to endorse or promote products derived
20 * from this software without specific prior written permission.
22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
26 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
28 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
45 #include <net/socket.h>
47 #include <sys/socket.h>
50 #include <netinet/in.h>
52 #include <sys/queue.h>
54 #include <rte_common.h>
55 #include <rte_byteorder.h>
57 #include <rte_debug.h>
58 #include <rte_cycles.h>
59 #include <rte_memory.h>
60 #include <rte_memzone.h>
61 #include <rte_malloc.h>
62 #include <rte_launch.h>
64 #include <rte_per_lcore.h>
65 #include <rte_lcore.h>
66 #include <rte_atomic.h>
67 #include <rte_branch_prediction.h>
69 #include <rte_mempool.h>
70 #include <rte_interrupts.h>
72 #include <rte_ether.h>
73 #include <rte_ethdev.h>
74 #include <rte_string_fns.h>
75 #include <rte_devargs.h>
76 #include <rte_eth_ctrl.h>
80 #include <cmdline_rdline.h>
81 #include <cmdline_parse.h>
82 #include <cmdline_parse_num.h>
83 #include <cmdline_parse_string.h>
84 #include <cmdline_parse_ipaddr.h>
85 #include <cmdline_parse_etheraddr.h>
86 #include <cmdline_socket.h>
88 #ifdef RTE_LIBRTE_PMD_BOND
89 #include <rte_eth_bond.h>
90 #include <rte_eth_bond_8023ad.h>
92 #ifdef RTE_LIBRTE_IXGBE_PMD
93 #include <rte_pmd_ixgbe.h>
95 #ifdef RTE_LIBRTE_I40E_PMD
96 #include <rte_pmd_i40e.h>
98 #ifdef RTE_LIBRTE_BNXT_PMD
99 #include <rte_pmd_bnxt.h>
102 #include "cmdline_mtr.h"
103 #include "cmdline_tm.h"
105 static struct cmdline *testpmd_cl;
107 static void cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue);
109 /* *** Help command with introduction. *** */
110 struct cmd_help_brief_result {
111 cmdline_fixed_string_t help;
114 static void cmd_help_brief_parsed(__attribute__((unused)) void *parsed_result,
116 __attribute__((unused)) void *data)
121 "Help is available for the following sections:\n\n"
122 " help control : Start and stop forwarding.\n"
123 " help display : Displaying port, stats and config "
125 " help config : Configuration information.\n"
126 " help ports : Configuring ports.\n"
127 " help registers : Reading and setting port registers.\n"
128 " help filters : Filters configuration help.\n"
129 " help all : All of the above sections.\n\n"
134 cmdline_parse_token_string_t cmd_help_brief_help =
135 TOKEN_STRING_INITIALIZER(struct cmd_help_brief_result, help, "help");
137 cmdline_parse_inst_t cmd_help_brief = {
138 .f = cmd_help_brief_parsed,
140 .help_str = "help: Show help",
142 (void *)&cmd_help_brief_help,
147 /* *** Help command with help sections. *** */
148 struct cmd_help_long_result {
149 cmdline_fixed_string_t help;
150 cmdline_fixed_string_t section;
153 static void cmd_help_long_parsed(void *parsed_result,
155 __attribute__((unused)) void *data)
158 struct cmd_help_long_result *res = parsed_result;
160 if (!strcmp(res->section, "all"))
163 if (show_all || !strcmp(res->section, "control")) {
168 "Control forwarding:\n"
169 "-------------------\n\n"
172 " Start packet forwarding with current configuration.\n\n"
175 " Start packet forwarding with current config"
176 " after sending one burst of packets.\n\n"
179 " Stop packet forwarding, and display accumulated"
183 " Quit to prompt.\n\n"
187 if (show_all || !strcmp(res->section, "display")) {
195 "show port (info|stats|xstats|fdir|stat_qmap|dcb_tc|cap) (port_id|all)\n"
196 " Display information for port_id, or all.\n\n"
198 "show port X rss reta (size) (mask0,mask1,...)\n"
199 " Display the rss redirection table entry indicated"
200 " by masks on port X. size is used to indicate the"
201 " hardware supported reta size\n\n"
203 "show port rss-hash ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|"
204 "ipv4-sctp|ipv4-other|ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
205 "ipv6-other|l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex [key]\n"
206 " Display the RSS hash functions and RSS hash key"
209 "clear port (info|stats|xstats|fdir|stat_qmap) (port_id|all)\n"
210 " Clear information for port_id, or all.\n\n"
212 "show (rxq|txq) info (port_id) (queue_id)\n"
213 " Display information for configured RX/TX queue.\n\n"
215 "show config (rxtx|cores|fwd|txpkts)\n"
216 " Display the given configuration.\n\n"
218 "read rxd (port_id) (queue_id) (rxd_id)\n"
219 " Display an RX descriptor of a port RX queue.\n\n"
221 "read txd (port_id) (queue_id) (txd_id)\n"
222 " Display a TX descriptor of a port TX queue.\n\n"
224 "ddp get list (port_id)\n"
225 " Get ddp profile info list\n\n"
227 "ddp get info (profile_path)\n"
228 " Get ddp profile information.\n\n"
230 "show vf stats (port_id) (vf_id)\n"
231 " Display a VF's statistics.\n\n"
233 "clear vf stats (port_id) (vf_id)\n"
234 " Reset a VF's statistics.\n\n"
236 "show port (port_id) pctype mapping\n"
237 " Get flow ptype to pctype mapping on a port\n\n"
239 "show port meter stats (port_id) (meter_id) (clear)\n"
240 " Get meter stats on a port\n\n"
241 "show port tm cap (port_id)\n"
242 " Display the port TM capability.\n\n"
244 "show port tm level cap (port_id) (level_id)\n"
245 " Display the port TM hierarchical level capability.\n\n"
247 "show port tm node cap (port_id) (node_id)\n"
248 " Display the port TM node capability.\n\n"
250 "show port tm node type (port_id) (node_id)\n"
251 " Display the port TM node type.\n\n"
253 "show port tm node stats (port_id) (node_id) (clear)\n"
254 " Display the port TM node stats.\n\n"
259 if (show_all || !strcmp(res->section, "config")) {
265 "Configuration changes only become active when"
266 " forwarding is started/restarted.\n\n"
269 " Reset forwarding to the default configuration.\n\n"
271 "set verbose (level)\n"
272 " Set the debug verbosity level X.\n\n"
275 " Set number of ports.\n\n"
278 " Set number of cores.\n\n"
280 "set coremask (mask)\n"
281 " Set the forwarding cores hexadecimal mask.\n\n"
283 "set portmask (mask)\n"
284 " Set the forwarding ports hexadecimal mask.\n\n"
287 " Set number of packets per burst.\n\n"
289 "set burst tx delay (microseconds) retry (num)\n"
290 " Set the transmit delay time and number of retries,"
291 " effective when retry is enabled.\n\n"
293 "set txpkts (x[,y]*)\n"
294 " Set the length of each segment of TXONLY"
295 " and optionally CSUM packets.\n\n"
297 "set txsplit (off|on|rand)\n"
298 " Set the split policy for the TX packets."
299 " Right now only applicable for CSUM and TXONLY"
302 "set corelist (x[,y]*)\n"
303 " Set the list of forwarding cores.\n\n"
305 "set portlist (x[,y]*)\n"
306 " Set the list of forwarding ports.\n\n"
308 "set tx loopback (port_id) (on|off)\n"
309 " Enable or disable tx loopback.\n\n"
311 "set all queues drop (port_id) (on|off)\n"
312 " Set drop enable bit for all queues.\n\n"
314 "set vf split drop (port_id) (vf_id) (on|off)\n"
315 " Set split drop enable bit for a VF from the PF.\n\n"
317 "set vf mac antispoof (port_id) (vf_id) (on|off).\n"
318 " Set MAC antispoof for a VF from the PF.\n\n"
320 "set macsec offload (port_id) on encrypt (on|off) replay-protect (on|off)\n"
321 " Enable MACsec offload.\n\n"
323 "set macsec offload (port_id) off\n"
324 " Disable MACsec offload.\n\n"
326 "set macsec sc (tx|rx) (port_id) (mac) (pi)\n"
327 " Configure MACsec secure connection (SC).\n\n"
329 "set macsec sa (tx|rx) (port_id) (idx) (an) (pn) (key)\n"
330 " Configure MACsec secure association (SA).\n\n"
332 "set vf broadcast (port_id) (vf_id) (on|off)\n"
333 " Set VF broadcast for a VF from the PF.\n\n"
335 "vlan set strip (on|off) (port_id)\n"
336 " Set the VLAN strip on a port.\n\n"
338 "vlan set stripq (on|off) (port_id,queue_id)\n"
339 " Set the VLAN strip for a queue on a port.\n\n"
341 "set vf vlan stripq (port_id) (vf_id) (on|off)\n"
342 " Set the VLAN strip for all queues in a pool for a VF from the PF.\n\n"
344 "set vf vlan insert (port_id) (vf_id) (vlan_id)\n"
345 " Set VLAN insert for a VF from the PF.\n\n"
347 "set vf vlan antispoof (port_id) (vf_id) (on|off)\n"
348 " Set VLAN antispoof for a VF from the PF.\n\n"
350 "set vf vlan tag (port_id) (vf_id) (on|off)\n"
351 " Set VLAN tag for a VF from the PF.\n\n"
353 "set vf tx max-bandwidth (port_id) (vf_id) (bandwidth)\n"
354 " Set a VF's max bandwidth(Mbps).\n\n"
356 "set vf tc tx min-bandwidth (port_id) (vf_id) (bw1, bw2, ...)\n"
357 " Set all TCs' min bandwidth(%%) on a VF.\n\n"
359 "set vf tc tx max-bandwidth (port_id) (vf_id) (tc_no) (bandwidth)\n"
360 " Set a TC's max bandwidth(Mbps) on a VF.\n\n"
362 "set tx strict-link-priority (port_id) (tc_bitmap)\n"
363 " Set some TCs' strict link priority mode on a physical port.\n\n"
365 "set tc tx min-bandwidth (port_id) (bw1, bw2, ...)\n"
366 " Set all TCs' min bandwidth(%%) for all PF and VFs.\n\n"
368 "vlan set filter (on|off) (port_id)\n"
369 " Set the VLAN filter on a port.\n\n"
371 "vlan set qinq (on|off) (port_id)\n"
372 " Set the VLAN QinQ (extended queue in queue)"
375 "vlan set (inner|outer) tpid (value) (port_id)\n"
376 " Set the VLAN TPID for Packet Filtering on"
379 "rx_vlan add (vlan_id|all) (port_id)\n"
380 " Add a vlan_id, or all identifiers, to the set"
381 " of VLAN identifiers filtered by port_id.\n\n"
383 "rx_vlan rm (vlan_id|all) (port_id)\n"
384 " Remove a vlan_id, or all identifiers, from the set"
385 " of VLAN identifiers filtered by port_id.\n\n"
387 "rx_vlan add (vlan_id) port (port_id) vf (vf_mask)\n"
388 " Add a vlan_id, to the set of VLAN identifiers"
389 "filtered for VF(s) from port_id.\n\n"
391 "rx_vlan rm (vlan_id) port (port_id) vf (vf_mask)\n"
392 " Remove a vlan_id, to the set of VLAN identifiers"
393 "filtered for VF(s) from port_id.\n\n"
395 "tunnel_filter add (port_id) (outer_mac) (inner_mac) (ip_addr) "
396 "(inner_vlan) (vxlan|nvgre|ipingre) (imac-ivlan|imac-ivlan-tenid|"
397 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n"
398 " add a tunnel filter of a port.\n\n"
400 "tunnel_filter rm (port_id) (outer_mac) (inner_mac) (ip_addr) "
401 "(inner_vlan) (vxlan|nvgre|ipingre) (imac-ivlan|imac-ivlan-tenid|"
402 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n"
403 " remove a tunnel filter of a port.\n\n"
405 "rx_vxlan_port add (udp_port) (port_id)\n"
406 " Add an UDP port for VXLAN packet filter on a port\n\n"
408 "rx_vxlan_port rm (udp_port) (port_id)\n"
409 " Remove an UDP port for VXLAN packet filter on a port\n\n"
411 "tx_vlan set (port_id) vlan_id[, vlan_id_outer]\n"
412 " Set hardware insertion of VLAN IDs (single or double VLAN "
413 "depends on the number of VLAN IDs) in packets sent on a port.\n\n"
415 "tx_vlan set pvid port_id vlan_id (on|off)\n"
416 " Set port based TX VLAN insertion.\n\n"
418 "tx_vlan reset (port_id)\n"
419 " Disable hardware insertion of a VLAN header in"
420 " packets sent on a port.\n\n"
422 "csum set (ip|udp|tcp|sctp|outer-ip) (hw|sw) (port_id)\n"
423 " Select hardware or software calculation of the"
424 " checksum when transmitting a packet using the"
425 " csum forward engine.\n"
426 " ip|udp|tcp|sctp always concern the inner layer.\n"
427 " outer-ip concerns the outer IP layer in"
428 " case the packet is recognized as a tunnel packet by"
429 " the forward engine (vxlan, gre and ipip are supported)\n"
430 " Please check the NIC datasheet for HW limits.\n\n"
432 "csum parse-tunnel (on|off) (tx_port_id)\n"
433 " If disabled, treat tunnel packets as non-tunneled"
434 " packets (treat inner headers as payload). The port\n"
435 " argument is the port used for TX in csum forward"
438 "csum show (port_id)\n"
439 " Display tx checksum offload configuration\n\n"
441 "tso set (segsize) (portid)\n"
442 " Enable TCP Segmentation Offload in csum forward"
444 " Please check the NIC datasheet for HW limits.\n\n"
447 " Display the status of TCP Segmentation Offload.\n\n"
449 "set port (port_id) gro on|off\n"
450 " Enable or disable Generic Receive Offload in"
451 " csum forwarding engine.\n\n"
453 "show port (port_id) gro\n"
454 " Display GRO configuration.\n\n"
456 "set gro flush (cycles)\n"
457 " Set the cycle to flush GROed packets from"
458 " reassembly tables.\n\n"
460 "set port (port_id) gso (on|off)"
461 " Enable or disable Generic Segmentation Offload in"
462 " csum forwarding engine.\n\n"
464 "set gso segsz (length)\n"
465 " Set max packet length for output GSO segments,"
466 " including packet header and payload.\n\n"
468 "show port (port_id) gso\n"
469 " Show GSO configuration.\n\n"
472 " Set packet forwarding mode.\n\n"
474 "mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n"
475 " Add a MAC address on port_id.\n\n"
477 "mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n"
478 " Remove a MAC address from port_id.\n\n"
480 "mac_addr set (port_id) (XX:XX:XX:XX:XX:XX)\n"
481 " Set the default MAC address for port_id.\n\n"
483 "mac_addr add port (port_id) vf (vf_id) (mac_address)\n"
484 " Add a MAC address for a VF on the port.\n\n"
486 "set vf mac addr (port_id) (vf_id) (XX:XX:XX:XX:XX:XX)\n"
487 " Set the MAC address for a VF from the PF.\n\n"
489 "set port (port_id) uta (mac_address|all) (on|off)\n"
490 " Add/Remove a or all unicast hash filter(s)"
493 "set promisc (port_id|all) (on|off)\n"
494 " Set the promiscuous mode on port_id, or all.\n\n"
496 "set allmulti (port_id|all) (on|off)\n"
497 " Set the allmulti mode on port_id, or all.\n\n"
499 "set vf promisc (port_id) (vf_id) (on|off)\n"
500 " Set unicast promiscuous mode for a VF from the PF.\n\n"
502 "set vf allmulti (port_id) (vf_id) (on|off)\n"
503 " Set multicast promiscuous mode for a VF from the PF.\n\n"
505 "set flow_ctrl rx (on|off) tx (on|off) (high_water)"
506 " (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd"
507 " (on|off) autoneg (on|off) (port_id)\n"
508 "set flow_ctrl rx (on|off) (portid)\n"
509 "set flow_ctrl tx (on|off) (portid)\n"
510 "set flow_ctrl high_water (high_water) (portid)\n"
511 "set flow_ctrl low_water (low_water) (portid)\n"
512 "set flow_ctrl pause_time (pause_time) (portid)\n"
513 "set flow_ctrl send_xon (send_xon) (portid)\n"
514 "set flow_ctrl mac_ctrl_frame_fwd (on|off) (portid)\n"
515 "set flow_ctrl autoneg (on|off) (port_id)\n"
516 " Set the link flow control parameter on a port.\n\n"
518 "set pfc_ctrl rx (on|off) tx (on|off) (high_water)"
519 " (low_water) (pause_time) (priority) (port_id)\n"
520 " Set the priority flow control parameter on a"
523 "set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n"
524 " Set statistics mapping (qmapping 0..15) for RX/TX"
526 " e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2"
527 " on port 0 to mapping 5.\n\n"
529 "set xstats-hide-zero on|off\n"
530 " Set the option to hide the zero values"
531 " for xstats display.\n"
533 "set port (port_id) vf (vf_id) rx|tx on|off\n"
534 " Enable/Disable a VF receive/tranmit from a port\n\n"
536 "set port (port_id) vf (vf_id) (mac_addr)"
537 " (exact-mac#exact-mac-vlan#hashmac|hashmac-vlan) on|off\n"
538 " Add/Remove unicast or multicast MAC addr filter"
541 "set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM"
543 " AUPE:accepts untagged VLAN;"
544 "ROPE:accept unicast hash\n\n"
545 " BAM:accepts broadcast packets;"
546 "MPE:accepts all multicast packets\n\n"
547 " Enable/Disable a VF receive mode of a port\n\n"
549 "set port (port_id) queue (queue_id) rate (rate_num)\n"
550 " Set rate limit for a queue of a port\n\n"
552 "set port (port_id) vf (vf_id) rate (rate_num) "
553 "queue_mask (queue_mask_value)\n"
554 " Set rate limit for queues in VF of a port\n\n"
556 "set port (port_id) mirror-rule (rule_id)"
557 " (pool-mirror-up|pool-mirror-down|vlan-mirror)"
558 " (poolmask|vlanid[,vlanid]*) dst-pool (pool_id) (on|off)\n"
559 " Set pool or vlan type mirror rule on a port.\n"
560 " e.g., 'set port 0 mirror-rule 0 vlan-mirror 0,1"
561 " dst-pool 0 on' enable mirror traffic with vlan 0,1"
564 "set port (port_id) mirror-rule (rule_id)"
565 " (uplink-mirror|downlink-mirror) dst-pool"
566 " (pool_id) (on|off)\n"
567 " Set uplink or downlink type mirror rule on a port.\n"
568 " e.g., 'set port 0 mirror-rule 0 uplink-mirror dst-pool"
569 " 0 on' enable mirror income traffic to pool 0.\n\n"
571 "reset port (port_id) mirror-rule (rule_id)\n"
572 " Reset a mirror rule.\n\n"
574 "set flush_rx (on|off)\n"
575 " Flush (default) or don't flush RX streams before"
576 " forwarding. Mainly used with PCAP drivers.\n\n"
578 "set bypass mode (normal|bypass|isolate) (port_id)\n"
579 " Set the bypass mode for the lowest port on bypass enabled"
582 "set bypass event (timeout|os_on|os_off|power_on|power_off) "
583 "mode (normal|bypass|isolate) (port_id)\n"
584 " Set the event required to initiate specified bypass mode for"
585 " the lowest port on a bypass enabled NIC where:\n"
586 " timeout = enable bypass after watchdog timeout.\n"
587 " os_on = enable bypass when OS/board is powered on.\n"
588 " os_off = enable bypass when OS/board is powered off.\n"
589 " power_on = enable bypass when power supply is turned on.\n"
590 " power_off = enable bypass when power supply is turned off."
593 "set bypass timeout (0|1.5|2|3|4|8|16|32)\n"
594 " Set the bypass watchdog timeout to 'n' seconds"
595 " where 0 = instant.\n\n"
597 "show bypass config (port_id)\n"
598 " Show the bypass configuration for a bypass enabled NIC"
599 " using the lowest port on the NIC.\n\n"
601 #ifdef RTE_LIBRTE_PMD_BOND
602 "create bonded device (mode) (socket)\n"
603 " Create a new bonded device with specific bonding mode and socket.\n\n"
605 "add bonding slave (slave_id) (port_id)\n"
606 " Add a slave device to a bonded device.\n\n"
608 "remove bonding slave (slave_id) (port_id)\n"
609 " Remove a slave device from a bonded device.\n\n"
611 "set bonding mode (value) (port_id)\n"
612 " Set the bonding mode on a bonded device.\n\n"
614 "set bonding primary (slave_id) (port_id)\n"
615 " Set the primary slave for a bonded device.\n\n"
617 "show bonding config (port_id)\n"
618 " Show the bonding config for port_id.\n\n"
620 "set bonding mac_addr (port_id) (address)\n"
621 " Set the MAC address of a bonded device.\n\n"
623 "set bonding mode IEEE802.3AD aggregator policy (port_id) (agg_name)"
624 " Set Aggregation mode for IEEE802.3AD (mode 4)"
626 "set bonding xmit_balance_policy (port_id) (l2|l23|l34)\n"
627 " Set the transmit balance policy for bonded device running in balance mode.\n\n"
629 "set bonding mon_period (port_id) (value)\n"
630 " Set the bonding link status monitoring polling period in ms.\n\n"
632 "set bonding lacp dedicated_queues <port_id> (enable|disable)\n"
633 " Enable/disable dedicated queues for LACP control traffic.\n\n"
636 "set link-up port (port_id)\n"
637 " Set link up for a port.\n\n"
639 "set link-down port (port_id)\n"
640 " Set link down for a port.\n\n"
642 "E-tag set insertion on port-tag-id (value)"
643 " port (port_id) vf (vf_id)\n"
644 " Enable E-tag insertion for a VF on a port\n\n"
646 "E-tag set insertion off port (port_id) vf (vf_id)\n"
647 " Disable E-tag insertion for a VF on a port\n\n"
649 "E-tag set stripping (on|off) port (port_id)\n"
650 " Enable/disable E-tag stripping on a port\n\n"
652 "E-tag set forwarding (on|off) port (port_id)\n"
653 " Enable/disable E-tag based forwarding"
656 "E-tag set filter add e-tag-id (value) dst-pool"
657 " (pool_id) port (port_id)\n"
658 " Add an E-tag forwarding filter on a port\n\n"
660 "E-tag set filter del e-tag-id (value) port (port_id)\n"
661 " Delete an E-tag forwarding filter on a port\n\n"
663 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
664 "set port tm hierarchy default (port_id)\n"
665 " Set default traffic Management hierarchy on a port\n\n"
668 "ddp add (port_id) (profile_path[,output_path])\n"
669 " Load a profile package on a port\n\n"
671 "ddp del (port_id) (profile_path)\n"
672 " Delete a profile package from a port\n\n"
674 "ptype mapping get (port_id) (valid_only)\n"
675 " Get ptype mapping on a port\n\n"
677 "ptype mapping replace (port_id) (target) (mask) (pky_type)\n"
678 " Replace target with the pkt_type in ptype mapping\n\n"
680 "ptype mapping reset (port_id)\n"
681 " Reset ptype mapping on a port\n\n"
683 "ptype mapping update (port_id) (hw_ptype) (sw_ptype)\n"
684 " Update a ptype mapping item on a port\n\n"
686 "set port (port_id) queue-region region_id (value) "
687 "queue_start_index (value) queue_num (value)\n"
688 " Set a queue region on a port\n\n"
690 "set port (port_id) queue-region region_id (value) "
692 " Set a flowtype region index on a port\n\n"
694 "set port (port_id) queue-region UP (value) region_id (value)\n"
695 " Set the mapping of User Priority to "
696 "queue region on a port\n\n"
698 "set port (port_id) queue-region flush (on|off)\n"
699 " flush all queue region related configuration\n\n"
701 "show port meter cap (port_id)\n"
702 " Show port meter capability information\n\n"
704 "add port meter profile srtcm_rfc2697 (port_id) (profile_id) (cir) (cbs) (ebs)\n"
705 " meter profile add - srtcm rfc 2697\n\n"
707 "add port meter profile trtcm_rfc2698 (port_id) (profile_id) (cir) (pir) (cbs) (pbs)\n"
708 " meter profile add - trtcm rfc 2698\n\n"
710 "add port meter profile trtcm_rfc4115 (port_id) (profile_id) (cir) (eir) (cbs) (ebs)\n"
711 " meter profile add - trtcm rfc 4115\n\n"
713 "del port meter profile (port_id) (profile_id)\n"
714 " meter profile delete\n\n"
716 "create port meter (port_id) (mtr_id) (profile_id) (meter_enable)\n"
717 "(g_action) (y_action) (r_action) (stats_mask) (shared)\n"
718 "(use_pre_meter_color) [(dscp_tbl_entry0) (dscp_tbl_entry1)...\n"
719 "(dscp_tbl_entry63)]\n"
722 "enable port meter (port_id) (mtr_id)\n"
725 "disable port meter (port_id) (mtr_id)\n"
728 "del port meter (port_id) (mtr_id)\n"
731 "set port meter profile (port_id) (mtr_id) (profile_id)\n"
732 " meter update meter profile\n\n"
734 "set port meter dscp table (port_id) (mtr_id) [(dscp_tbl_entry0)\n"
735 "(dscp_tbl_entry1)...(dscp_tbl_entry63)]\n"
736 " update meter dscp table entries\n\n"
738 "set port meter policer action (port_id) (mtr_id) (action_mask)\n"
739 "(action0) [(action1) (action2)]\n"
740 " meter update policer action\n\n"
742 "set port meter stats mask (port_id) (mtr_id) (stats_mask)\n"
743 " meter update stats\n\n"
745 "show port (port_id) queue-region\n"
746 " show all queue region related configuration info\n\n"
748 "add port tm node shaper profile (port_id) (shaper_profile_id)"
749 " (tb_rate) (tb_size) (packet_length_adjust)\n"
750 " Add port tm node private shaper profile.\n\n"
752 "del port tm node shaper profile (port_id) (shaper_profile_id)\n"
753 " Delete port tm node private shaper profile.\n\n"
755 "add port tm node shared shaper (port_id) (shared_shaper_id)"
756 " (shaper_profile_id)\n"
757 " Add/update port tm node shared shaper.\n\n"
759 "del port tm node shared shaper (port_id) (shared_shaper_id)\n"
760 " Delete port tm node shared shaper.\n\n"
762 "set port tm node shaper profile (port_id) (node_id)"
763 " (shaper_profile_id)\n"
764 " Set port tm node shaper profile.\n\n"
766 "add port tm node wred profile (port_id) (wred_profile_id)"
767 " (color_g) (min_th_g) (max_th_g) (maxp_inv_g) (wq_log2_g)"
768 " (color_y) (min_th_y) (max_th_y) (maxp_inv_y) (wq_log2_y)"
769 " (color_r) (min_th_r) (max_th_r) (maxp_inv_r) (wq_log2_r)\n"
770 " Add port tm node wred profile.\n\n"
772 "del port tm node wred profile (port_id) (wred_profile_id)\n"
773 " Delete port tm node wred profile.\n\n"
775 "add port tm nonleaf node (port_id) (node_id) (parent_node_id)"
776 " (priority) (weight) (level_id) (shaper_profile_id)"
777 " (n_sp_priorities) (stats_mask) (n_shared_shapers)"
778 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
779 " Add port tm nonleaf node.\n\n"
781 "add port tm leaf node (port_id) (node_id) (parent_node_id)"
782 " (priority) (weight) (level_id) (shaper_profile_id)"
783 " (cman_mode) (wred_profile_id) (stats_mask) (n_shared_shapers)"
784 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
785 " Add port tm leaf node.\n\n"
787 "del port tm node (port_id) (node_id)\n"
788 " Delete port tm node.\n\n"
790 "set port tm node parent (port_id) (node_id) (parent_node_id)"
791 " (priority) (weight)\n"
792 " Set port tm node parent.\n\n"
794 "port tm hierarchy commit (port_id) (clean_on_fail)\n"
795 " Commit tm hierarchy.\n\n"
797 , list_pkt_forwarding_modes()
801 if (show_all || !strcmp(res->section, "ports")) {
807 "----------------\n\n"
809 "port start (port_id|all)\n"
810 " Start all ports or port_id.\n\n"
812 "port stop (port_id|all)\n"
813 " Stop all ports or port_id.\n\n"
815 "port close (port_id|all)\n"
816 " Close all ports or port_id.\n\n"
818 "port attach (ident)\n"
819 " Attach physical or virtual dev by pci address or virtual device name\n\n"
821 "port detach (port_id)\n"
822 " Detach physical or virtual dev by port_id\n\n"
824 "port config (port_id|all)"
825 " speed (10|100|1000|10000|25000|40000|50000|100000|auto)"
826 " duplex (half|full|auto)\n"
827 " Set speed and duplex for all ports or port_id\n\n"
829 "port config all (rxq|txq|rxd|txd) (value)\n"
830 " Set number for rxq/txq/rxd/txd.\n\n"
832 "port config all max-pkt-len (value)\n"
833 " Set the max packet length.\n\n"
835 "port config all (crc-strip|scatter|rx-cksum|rx-timestamp|hw-vlan|hw-vlan-filter|"
836 "hw-vlan-strip|hw-vlan-extend|drop-en)"
838 " Set crc-strip/scatter/rx-checksum/hardware-vlan/drop_en"
841 "port config all rss (all|ip|tcp|udp|sctp|ether|port|vxlan|"
842 "geneve|nvgre|none|<flowtype_id>)\n"
843 " Set the RSS mode.\n\n"
845 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
846 " Set the RSS redirection table.\n\n"
848 "port config (port_id) dcb vt (on|off) (traffic_class)"
850 " Set the DCB mode.\n\n"
852 "port config all burst (value)\n"
853 " Set the number of packets per burst.\n\n"
855 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
857 " Set the ring prefetch/host/writeback threshold"
858 " for tx/rx queue.\n\n"
860 "port config all (txfreet|txrst|rxfreet) (value)\n"
861 " Set free threshold for rx/tx, or set"
862 " tx rs bit threshold.\n\n"
863 "port config mtu X value\n"
864 " Set the MTU of port X to a given value\n\n"
866 "port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
867 " Start/stop a rx/tx queue of port X. Only take effect"
868 " when port X is started\n\n"
870 "port config (port_id|all) l2-tunnel E-tag ether-type"
872 " Set the value of E-tag ether-type.\n\n"
874 "port config (port_id|all) l2-tunnel E-tag"
875 " (enable|disable)\n"
876 " Enable/disable the E-tag support.\n\n"
878 "port config (port_id) pctype mapping reset\n"
879 " Reset flow type to pctype mapping on a port\n\n"
881 "port config (port_id) pctype mapping update"
882 " (pctype_id_0[,pctype_id_1]*) (flow_type_id)\n"
883 " Update a flow type to pctype mapping item on a port\n\n"
887 if (show_all || !strcmp(res->section, "registers")) {
895 "read reg (port_id) (address)\n"
896 " Display value of a port register.\n\n"
898 "read regfield (port_id) (address) (bit_x) (bit_y)\n"
899 " Display a port register bit field.\n\n"
901 "read regbit (port_id) (address) (bit_x)\n"
902 " Display a single port register bit.\n\n"
904 "write reg (port_id) (address) (value)\n"
905 " Set value of a port register.\n\n"
907 "write regfield (port_id) (address) (bit_x) (bit_y)"
909 " Set bit field of a port register.\n\n"
911 "write regbit (port_id) (address) (bit_x) (value)\n"
912 " Set single bit value of a port register.\n\n"
915 if (show_all || !strcmp(res->section, "filters")) {
923 "ethertype_filter (port_id) (add|del)"
924 " (mac_addr|mac_ignr) (mac_address) ethertype"
925 " (ether_type) (drop|fwd) queue (queue_id)\n"
926 " Add/Del an ethertype filter.\n\n"
928 "2tuple_filter (port_id) (add|del)"
929 " dst_port (dst_port_value) protocol (protocol_value)"
930 " mask (mask_value) tcp_flags (tcp_flags_value)"
931 " priority (prio_value) queue (queue_id)\n"
932 " Add/Del a 2tuple filter.\n\n"
934 "5tuple_filter (port_id) (add|del)"
935 " dst_ip (dst_address) src_ip (src_address)"
936 " dst_port (dst_port_value) src_port (src_port_value)"
937 " protocol (protocol_value)"
938 " mask (mask_value) tcp_flags (tcp_flags_value)"
939 " priority (prio_value) queue (queue_id)\n"
940 " Add/Del a 5tuple filter.\n\n"
942 "syn_filter (port_id) (add|del) priority (high|low) queue (queue_id)"
943 " Add/Del syn filter.\n\n"
945 "flex_filter (port_id) (add|del) len (len_value)"
946 " bytes (bytes_value) mask (mask_value)"
947 " priority (prio_value) queue (queue_id)\n"
948 " Add/Del a flex filter.\n\n"
950 "flow_director_filter (port_id) mode IP (add|del|update)"
951 " flow (ipv4-other|ipv4-frag|ipv6-other|ipv6-frag)"
952 " src (src_ip_address) dst (dst_ip_address)"
953 " tos (tos_value) proto (proto_value) ttl (ttl_value)"
954 " vlan (vlan_value) flexbytes (flexbytes_value)"
955 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
956 " fd_id (fd_id_value)\n"
957 " Add/Del an IP type flow director filter.\n\n"
959 "flow_director_filter (port_id) mode IP (add|del|update)"
960 " flow (ipv4-tcp|ipv4-udp|ipv6-tcp|ipv6-udp)"
961 " src (src_ip_address) (src_port)"
962 " dst (dst_ip_address) (dst_port)"
963 " tos (tos_value) ttl (ttl_value)"
964 " vlan (vlan_value) flexbytes (flexbytes_value)"
965 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
966 " fd_id (fd_id_value)\n"
967 " Add/Del an UDP/TCP type flow director filter.\n\n"
969 "flow_director_filter (port_id) mode IP (add|del|update)"
970 " flow (ipv4-sctp|ipv6-sctp)"
971 " src (src_ip_address) (src_port)"
972 " dst (dst_ip_address) (dst_port)"
973 " tag (verification_tag) "
974 " tos (tos_value) ttl (ttl_value)"
976 " flexbytes (flexbytes_value) (drop|fwd)"
977 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
978 " Add/Del a SCTP type flow director filter.\n\n"
980 "flow_director_filter (port_id) mode IP (add|del|update)"
981 " flow l2_payload ether (ethertype)"
982 " flexbytes (flexbytes_value) (drop|fwd)"
983 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
984 " Add/Del a l2 payload type flow director filter.\n\n"
986 "flow_director_filter (port_id) mode MAC-VLAN (add|del|update)"
987 " mac (mac_address) vlan (vlan_value)"
988 " flexbytes (flexbytes_value) (drop|fwd)"
989 " queue (queue_id) fd_id (fd_id_value)\n"
990 " Add/Del a MAC-VLAN flow director filter.\n\n"
992 "flow_director_filter (port_id) mode Tunnel (add|del|update)"
993 " mac (mac_address) vlan (vlan_value)"
994 " tunnel (NVGRE|VxLAN) tunnel-id (tunnel_id_value)"
995 " flexbytes (flexbytes_value) (drop|fwd)"
996 " queue (queue_id) fd_id (fd_id_value)\n"
997 " Add/Del a Tunnel flow director filter.\n\n"
999 "flush_flow_director (port_id)\n"
1000 " Flush all flow director entries of a device.\n\n"
1002 "flow_director_mask (port_id) mode IP vlan (vlan_value)"
1003 " src_mask (ipv4_src) (ipv6_src) (src_port)"
1004 " dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n"
1005 " Set flow director IP mask.\n\n"
1007 "flow_director_mask (port_id) mode MAC-VLAN"
1008 " vlan (vlan_value)\n"
1009 " Set flow director MAC-VLAN mask.\n\n"
1011 "flow_director_mask (port_id) mode Tunnel"
1012 " vlan (vlan_value) mac (mac_value)"
1013 " tunnel-type (tunnel_type_value)"
1014 " tunnel-id (tunnel_id_value)\n"
1015 " Set flow director Tunnel mask.\n\n"
1017 "flow_director_flex_mask (port_id)"
1018 " flow (none|ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
1019 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|l2_payload|all)"
1021 " Configure mask of flex payload.\n\n"
1023 "flow_director_flex_payload (port_id)"
1024 " (raw|l2|l3|l4) (config)\n"
1025 " Configure flex payload selection.\n\n"
1027 "get_sym_hash_ena_per_port (port_id)\n"
1028 " get symmetric hash enable configuration per port.\n\n"
1030 "set_sym_hash_ena_per_port (port_id) (enable|disable)\n"
1031 " set symmetric hash enable configuration per port"
1032 " to enable or disable.\n\n"
1034 "get_hash_global_config (port_id)\n"
1035 " Get the global configurations of hash filters.\n\n"
1037 "set_hash_global_config (port_id) (toeplitz|simple_xor|default)"
1038 " (ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
1039 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload)"
1040 " (enable|disable)\n"
1041 " Set the global configurations of hash filters.\n\n"
1043 "set_hash_input_set (port_id) (ipv4|ipv4-frag|"
1044 "ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
1045 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1046 "l2_payload|<flowtype_id>) (ovlan|ivlan|src-ipv4|dst-ipv4|"
1047 "src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|ipv6-tc|"
1048 "ipv6-next-header|udp-src-port|udp-dst-port|"
1049 "tcp-src-port|tcp-dst-port|sctp-src-port|"
1050 "sctp-dst-port|sctp-veri-tag|udp-key|gre-key|fld-1st|"
1051 "fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|fld-7th|"
1052 "fld-8th|none) (select|add)\n"
1053 " Set the input set for hash.\n\n"
1055 "set_fdir_input_set (port_id) "
1056 "(ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
1057 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1058 "l2_payload) (ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|"
1059 "dst-ipv6|ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|"
1060 "ipv6-next-header|ipv6-hop-limits|udp-src-port|"
1061 "udp-dst-port|tcp-src-port|tcp-dst-port|"
1062 "sctp-src-port|sctp-dst-port|sctp-veri-tag|none)"
1064 " Set the input set for FDir.\n\n"
1066 "flow validate {port_id}"
1067 " [group {group_id}] [priority {level}]"
1068 " [ingress] [egress]"
1069 " pattern {item} [/ {item} [...]] / end"
1070 " actions {action} [/ {action} [...]] / end\n"
1071 " Check whether a flow rule can be created.\n\n"
1073 "flow create {port_id}"
1074 " [group {group_id}] [priority {level}]"
1075 " [ingress] [egress]"
1076 " pattern {item} [/ {item} [...]] / end"
1077 " actions {action} [/ {action} [...]] / end\n"
1078 " Create a flow rule.\n\n"
1080 "flow destroy {port_id} rule {rule_id} [...]\n"
1081 " Destroy specific flow rules.\n\n"
1083 "flow flush {port_id}\n"
1084 " Destroy all flow rules.\n\n"
1086 "flow query {port_id} {rule_id} {action}\n"
1087 " Query an existing flow rule.\n\n"
1089 "flow list {port_id} [group {group_id}] [...]\n"
1090 " List existing flow rules sorted by priority,"
1091 " filtered by group identifiers.\n\n"
1093 "flow isolate {port_id} {boolean}\n"
1094 " Restrict ingress traffic to the defined"
1100 cmdline_parse_token_string_t cmd_help_long_help =
1101 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
1103 cmdline_parse_token_string_t cmd_help_long_section =
1104 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
1105 "all#control#display#config#"
1106 "ports#registers#filters");
1108 cmdline_parse_inst_t cmd_help_long = {
1109 .f = cmd_help_long_parsed,
1111 .help_str = "help all|control|display|config|ports|register|filters: "
1114 (void *)&cmd_help_long_help,
1115 (void *)&cmd_help_long_section,
1121 /* *** start/stop/close all ports *** */
1122 struct cmd_operate_port_result {
1123 cmdline_fixed_string_t keyword;
1124 cmdline_fixed_string_t name;
1125 cmdline_fixed_string_t value;
1128 static void cmd_operate_port_parsed(void *parsed_result,
1129 __attribute__((unused)) struct cmdline *cl,
1130 __attribute__((unused)) void *data)
1132 struct cmd_operate_port_result *res = parsed_result;
1134 if (!strcmp(res->name, "start"))
1135 start_port(RTE_PORT_ALL);
1136 else if (!strcmp(res->name, "stop"))
1137 stop_port(RTE_PORT_ALL);
1138 else if (!strcmp(res->name, "close"))
1139 close_port(RTE_PORT_ALL);
1140 else if (!strcmp(res->name, "reset"))
1141 reset_port(RTE_PORT_ALL);
1143 printf("Unknown parameter\n");
1146 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
1147 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
1149 cmdline_parse_token_string_t cmd_operate_port_all_port =
1150 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
1151 "start#stop#close#reset");
1152 cmdline_parse_token_string_t cmd_operate_port_all_all =
1153 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
1155 cmdline_parse_inst_t cmd_operate_port = {
1156 .f = cmd_operate_port_parsed,
1158 .help_str = "port start|stop|close all: Start/Stop/Close/Reset all ports",
1160 (void *)&cmd_operate_port_all_cmd,
1161 (void *)&cmd_operate_port_all_port,
1162 (void *)&cmd_operate_port_all_all,
1167 /* *** start/stop/close specific port *** */
1168 struct cmd_operate_specific_port_result {
1169 cmdline_fixed_string_t keyword;
1170 cmdline_fixed_string_t name;
1174 static void cmd_operate_specific_port_parsed(void *parsed_result,
1175 __attribute__((unused)) struct cmdline *cl,
1176 __attribute__((unused)) void *data)
1178 struct cmd_operate_specific_port_result *res = parsed_result;
1180 if (!strcmp(res->name, "start"))
1181 start_port(res->value);
1182 else if (!strcmp(res->name, "stop"))
1183 stop_port(res->value);
1184 else if (!strcmp(res->name, "close"))
1185 close_port(res->value);
1186 else if (!strcmp(res->name, "reset"))
1187 reset_port(res->value);
1189 printf("Unknown parameter\n");
1192 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
1193 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1195 cmdline_parse_token_string_t cmd_operate_specific_port_port =
1196 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1197 name, "start#stop#close#reset");
1198 cmdline_parse_token_num_t cmd_operate_specific_port_id =
1199 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
1202 cmdline_parse_inst_t cmd_operate_specific_port = {
1203 .f = cmd_operate_specific_port_parsed,
1205 .help_str = "port start|stop|close <port_id>: Start/Stop/Close/Reset port_id",
1207 (void *)&cmd_operate_specific_port_cmd,
1208 (void *)&cmd_operate_specific_port_port,
1209 (void *)&cmd_operate_specific_port_id,
1214 /* *** attach a specified port *** */
1215 struct cmd_operate_attach_port_result {
1216 cmdline_fixed_string_t port;
1217 cmdline_fixed_string_t keyword;
1218 cmdline_fixed_string_t identifier;
1221 static void cmd_operate_attach_port_parsed(void *parsed_result,
1222 __attribute__((unused)) struct cmdline *cl,
1223 __attribute__((unused)) void *data)
1225 struct cmd_operate_attach_port_result *res = parsed_result;
1227 if (!strcmp(res->keyword, "attach"))
1228 attach_port(res->identifier);
1230 printf("Unknown parameter\n");
1233 cmdline_parse_token_string_t cmd_operate_attach_port_port =
1234 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1236 cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
1237 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1239 cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
1240 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1243 cmdline_parse_inst_t cmd_operate_attach_port = {
1244 .f = cmd_operate_attach_port_parsed,
1246 .help_str = "port attach <identifier>: "
1247 "(identifier: pci address or virtual dev name)",
1249 (void *)&cmd_operate_attach_port_port,
1250 (void *)&cmd_operate_attach_port_keyword,
1251 (void *)&cmd_operate_attach_port_identifier,
1256 /* *** detach a specified port *** */
1257 struct cmd_operate_detach_port_result {
1258 cmdline_fixed_string_t port;
1259 cmdline_fixed_string_t keyword;
1263 static void cmd_operate_detach_port_parsed(void *parsed_result,
1264 __attribute__((unused)) struct cmdline *cl,
1265 __attribute__((unused)) void *data)
1267 struct cmd_operate_detach_port_result *res = parsed_result;
1269 if (!strcmp(res->keyword, "detach"))
1270 detach_port(res->port_id);
1272 printf("Unknown parameter\n");
1275 cmdline_parse_token_string_t cmd_operate_detach_port_port =
1276 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1278 cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
1279 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1281 cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
1282 TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
1285 cmdline_parse_inst_t cmd_operate_detach_port = {
1286 .f = cmd_operate_detach_port_parsed,
1288 .help_str = "port detach <port_id>",
1290 (void *)&cmd_operate_detach_port_port,
1291 (void *)&cmd_operate_detach_port_keyword,
1292 (void *)&cmd_operate_detach_port_port_id,
1297 /* *** configure speed for all ports *** */
1298 struct cmd_config_speed_all {
1299 cmdline_fixed_string_t port;
1300 cmdline_fixed_string_t keyword;
1301 cmdline_fixed_string_t all;
1302 cmdline_fixed_string_t item1;
1303 cmdline_fixed_string_t item2;
1304 cmdline_fixed_string_t value1;
1305 cmdline_fixed_string_t value2;
1309 parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed)
1314 if (!strcmp(duplexstr, "half")) {
1315 duplex = ETH_LINK_HALF_DUPLEX;
1316 } else if (!strcmp(duplexstr, "full")) {
1317 duplex = ETH_LINK_FULL_DUPLEX;
1318 } else if (!strcmp(duplexstr, "auto")) {
1319 duplex = ETH_LINK_FULL_DUPLEX;
1321 printf("Unknown duplex parameter\n");
1325 if (!strcmp(speedstr, "10")) {
1326 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1327 ETH_LINK_SPEED_10M_HD : ETH_LINK_SPEED_10M;
1328 } else if (!strcmp(speedstr, "100")) {
1329 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1330 ETH_LINK_SPEED_100M_HD : ETH_LINK_SPEED_100M;
1332 if (duplex != ETH_LINK_FULL_DUPLEX) {
1333 printf("Invalid speed/duplex parameters\n");
1336 if (!strcmp(speedstr, "1000")) {
1337 *speed = ETH_LINK_SPEED_1G;
1338 } else if (!strcmp(speedstr, "10000")) {
1339 *speed = ETH_LINK_SPEED_10G;
1340 } else if (!strcmp(speedstr, "25000")) {
1341 *speed = ETH_LINK_SPEED_25G;
1342 } else if (!strcmp(speedstr, "40000")) {
1343 *speed = ETH_LINK_SPEED_40G;
1344 } else if (!strcmp(speedstr, "50000")) {
1345 *speed = ETH_LINK_SPEED_50G;
1346 } else if (!strcmp(speedstr, "100000")) {
1347 *speed = ETH_LINK_SPEED_100G;
1348 } else if (!strcmp(speedstr, "auto")) {
1349 *speed = ETH_LINK_SPEED_AUTONEG;
1351 printf("Unknown speed parameter\n");
1360 cmd_config_speed_all_parsed(void *parsed_result,
1361 __attribute__((unused)) struct cmdline *cl,
1362 __attribute__((unused)) void *data)
1364 struct cmd_config_speed_all *res = parsed_result;
1365 uint32_t link_speed;
1368 if (!all_ports_stopped()) {
1369 printf("Please stop all ports first\n");
1373 if (parse_and_check_speed_duplex(res->value1, res->value2,
1377 RTE_ETH_FOREACH_DEV(pid) {
1378 ports[pid].dev_conf.link_speeds = link_speed;
1381 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1384 cmdline_parse_token_string_t cmd_config_speed_all_port =
1385 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1386 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1387 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1389 cmdline_parse_token_string_t cmd_config_speed_all_all =
1390 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1391 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1392 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1393 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1394 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1395 "10#100#1000#10000#25000#40000#50000#100000#auto");
1396 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1397 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1398 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1399 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1402 cmdline_parse_inst_t cmd_config_speed_all = {
1403 .f = cmd_config_speed_all_parsed,
1405 .help_str = "port config all speed "
1406 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1409 (void *)&cmd_config_speed_all_port,
1410 (void *)&cmd_config_speed_all_keyword,
1411 (void *)&cmd_config_speed_all_all,
1412 (void *)&cmd_config_speed_all_item1,
1413 (void *)&cmd_config_speed_all_value1,
1414 (void *)&cmd_config_speed_all_item2,
1415 (void *)&cmd_config_speed_all_value2,
1420 /* *** configure speed for specific port *** */
1421 struct cmd_config_speed_specific {
1422 cmdline_fixed_string_t port;
1423 cmdline_fixed_string_t keyword;
1425 cmdline_fixed_string_t item1;
1426 cmdline_fixed_string_t item2;
1427 cmdline_fixed_string_t value1;
1428 cmdline_fixed_string_t value2;
1432 cmd_config_speed_specific_parsed(void *parsed_result,
1433 __attribute__((unused)) struct cmdline *cl,
1434 __attribute__((unused)) void *data)
1436 struct cmd_config_speed_specific *res = parsed_result;
1437 uint32_t link_speed;
1439 if (!all_ports_stopped()) {
1440 printf("Please stop all ports first\n");
1444 if (port_id_is_invalid(res->id, ENABLED_WARN))
1447 if (parse_and_check_speed_duplex(res->value1, res->value2,
1451 ports[res->id].dev_conf.link_speeds = link_speed;
1453 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1457 cmdline_parse_token_string_t cmd_config_speed_specific_port =
1458 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1460 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1461 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1463 cmdline_parse_token_num_t cmd_config_speed_specific_id =
1464 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT8);
1465 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1466 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1468 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1469 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1470 "10#100#1000#10000#25000#40000#50000#100000#auto");
1471 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1472 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1474 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1475 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1478 cmdline_parse_inst_t cmd_config_speed_specific = {
1479 .f = cmd_config_speed_specific_parsed,
1481 .help_str = "port config <port_id> speed "
1482 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1485 (void *)&cmd_config_speed_specific_port,
1486 (void *)&cmd_config_speed_specific_keyword,
1487 (void *)&cmd_config_speed_specific_id,
1488 (void *)&cmd_config_speed_specific_item1,
1489 (void *)&cmd_config_speed_specific_value1,
1490 (void *)&cmd_config_speed_specific_item2,
1491 (void *)&cmd_config_speed_specific_value2,
1496 /* *** configure txq/rxq, txd/rxd *** */
1497 struct cmd_config_rx_tx {
1498 cmdline_fixed_string_t port;
1499 cmdline_fixed_string_t keyword;
1500 cmdline_fixed_string_t all;
1501 cmdline_fixed_string_t name;
1506 cmd_config_rx_tx_parsed(void *parsed_result,
1507 __attribute__((unused)) struct cmdline *cl,
1508 __attribute__((unused)) void *data)
1510 struct cmd_config_rx_tx *res = parsed_result;
1512 if (!all_ports_stopped()) {
1513 printf("Please stop all ports first\n");
1516 if (!strcmp(res->name, "rxq")) {
1517 if (!res->value && !nb_txq) {
1518 printf("Warning: Either rx or tx queues should be non zero\n");
1521 nb_rxq = res->value;
1523 else if (!strcmp(res->name, "txq")) {
1524 if (!res->value && !nb_rxq) {
1525 printf("Warning: Either rx or tx queues should be non zero\n");
1528 nb_txq = res->value;
1530 else if (!strcmp(res->name, "rxd")) {
1531 if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) {
1532 printf("rxd %d invalid - must be > 0 && <= %d\n",
1533 res->value, RTE_TEST_RX_DESC_MAX);
1536 nb_rxd = res->value;
1537 } else if (!strcmp(res->name, "txd")) {
1538 if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) {
1539 printf("txd %d invalid - must be > 0 && <= %d\n",
1540 res->value, RTE_TEST_TX_DESC_MAX);
1543 nb_txd = res->value;
1545 printf("Unknown parameter\n");
1553 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1556 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1557 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1558 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1559 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1560 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1561 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1562 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1563 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1565 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1566 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
1568 cmdline_parse_inst_t cmd_config_rx_tx = {
1569 .f = cmd_config_rx_tx_parsed,
1571 .help_str = "port config all rxq|txq|rxd|txd <value>",
1573 (void *)&cmd_config_rx_tx_port,
1574 (void *)&cmd_config_rx_tx_keyword,
1575 (void *)&cmd_config_rx_tx_all,
1576 (void *)&cmd_config_rx_tx_name,
1577 (void *)&cmd_config_rx_tx_value,
1582 /* *** config max packet length *** */
1583 struct cmd_config_max_pkt_len_result {
1584 cmdline_fixed_string_t port;
1585 cmdline_fixed_string_t keyword;
1586 cmdline_fixed_string_t all;
1587 cmdline_fixed_string_t name;
1592 cmd_config_max_pkt_len_parsed(void *parsed_result,
1593 __attribute__((unused)) struct cmdline *cl,
1594 __attribute__((unused)) void *data)
1596 struct cmd_config_max_pkt_len_result *res = parsed_result;
1597 uint64_t rx_offloads = rx_mode.offloads;
1599 if (!all_ports_stopped()) {
1600 printf("Please stop all ports first\n");
1604 if (!strcmp(res->name, "max-pkt-len")) {
1605 if (res->value < ETHER_MIN_LEN) {
1606 printf("max-pkt-len can not be less than %d\n",
1610 if (res->value == rx_mode.max_rx_pkt_len)
1613 rx_mode.max_rx_pkt_len = res->value;
1614 if (res->value > ETHER_MAX_LEN)
1615 rx_offloads |= DEV_RX_OFFLOAD_JUMBO_FRAME;
1617 rx_offloads &= ~DEV_RX_OFFLOAD_JUMBO_FRAME;
1619 printf("Unknown parameter\n");
1623 rx_mode.offloads = rx_offloads;
1627 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1630 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
1631 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
1633 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
1634 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
1636 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
1637 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
1639 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
1640 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
1642 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1643 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1646 cmdline_parse_inst_t cmd_config_max_pkt_len = {
1647 .f = cmd_config_max_pkt_len_parsed,
1649 .help_str = "port config all max-pkt-len <value>",
1651 (void *)&cmd_config_max_pkt_len_port,
1652 (void *)&cmd_config_max_pkt_len_keyword,
1653 (void *)&cmd_config_max_pkt_len_all,
1654 (void *)&cmd_config_max_pkt_len_name,
1655 (void *)&cmd_config_max_pkt_len_value,
1660 /* *** configure port MTU *** */
1661 struct cmd_config_mtu_result {
1662 cmdline_fixed_string_t port;
1663 cmdline_fixed_string_t keyword;
1664 cmdline_fixed_string_t mtu;
1670 cmd_config_mtu_parsed(void *parsed_result,
1671 __attribute__((unused)) struct cmdline *cl,
1672 __attribute__((unused)) void *data)
1674 struct cmd_config_mtu_result *res = parsed_result;
1676 if (res->value < ETHER_MIN_LEN) {
1677 printf("mtu cannot be less than %d\n", ETHER_MIN_LEN);
1680 port_mtu_set(res->port_id, res->value);
1683 cmdline_parse_token_string_t cmd_config_mtu_port =
1684 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
1686 cmdline_parse_token_string_t cmd_config_mtu_keyword =
1687 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1689 cmdline_parse_token_string_t cmd_config_mtu_mtu =
1690 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1692 cmdline_parse_token_num_t cmd_config_mtu_port_id =
1693 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT16);
1694 cmdline_parse_token_num_t cmd_config_mtu_value =
1695 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
1697 cmdline_parse_inst_t cmd_config_mtu = {
1698 .f = cmd_config_mtu_parsed,
1700 .help_str = "port config mtu <port_id> <value>",
1702 (void *)&cmd_config_mtu_port,
1703 (void *)&cmd_config_mtu_keyword,
1704 (void *)&cmd_config_mtu_mtu,
1705 (void *)&cmd_config_mtu_port_id,
1706 (void *)&cmd_config_mtu_value,
1711 /* *** configure rx mode *** */
1712 struct cmd_config_rx_mode_flag {
1713 cmdline_fixed_string_t port;
1714 cmdline_fixed_string_t keyword;
1715 cmdline_fixed_string_t all;
1716 cmdline_fixed_string_t name;
1717 cmdline_fixed_string_t value;
1721 cmd_config_rx_mode_flag_parsed(void *parsed_result,
1722 __attribute__((unused)) struct cmdline *cl,
1723 __attribute__((unused)) void *data)
1725 struct cmd_config_rx_mode_flag *res = parsed_result;
1726 uint64_t rx_offloads = rx_mode.offloads;
1728 if (!all_ports_stopped()) {
1729 printf("Please stop all ports first\n");
1733 if (!strcmp(res->name, "crc-strip")) {
1734 if (!strcmp(res->value, "on"))
1735 rx_offloads |= DEV_RX_OFFLOAD_CRC_STRIP;
1736 else if (!strcmp(res->value, "off"))
1737 rx_offloads &= ~DEV_RX_OFFLOAD_CRC_STRIP;
1739 printf("Unknown parameter\n");
1742 } else if (!strcmp(res->name, "scatter")) {
1743 if (!strcmp(res->value, "on")) {
1744 rx_offloads |= DEV_RX_OFFLOAD_SCATTER;
1745 } else if (!strcmp(res->value, "off")) {
1746 rx_offloads &= ~DEV_RX_OFFLOAD_SCATTER;
1748 printf("Unknown parameter\n");
1751 } else if (!strcmp(res->name, "rx-cksum")) {
1752 if (!strcmp(res->value, "on"))
1753 rx_offloads |= DEV_RX_OFFLOAD_CHECKSUM;
1754 else if (!strcmp(res->value, "off"))
1755 rx_offloads &= ~DEV_RX_OFFLOAD_CHECKSUM;
1757 printf("Unknown parameter\n");
1760 } else if (!strcmp(res->name, "rx-timestamp")) {
1761 if (!strcmp(res->value, "on"))
1762 rx_offloads |= DEV_RX_OFFLOAD_TIMESTAMP;
1763 else if (!strcmp(res->value, "off"))
1764 rx_offloads &= ~DEV_RX_OFFLOAD_TIMESTAMP;
1766 printf("Unknown parameter\n");
1769 } else if (!strcmp(res->name, "hw-vlan")) {
1770 if (!strcmp(res->value, "on")) {
1771 rx_offloads |= (DEV_RX_OFFLOAD_VLAN_FILTER |
1772 DEV_RX_OFFLOAD_VLAN_STRIP);
1774 else if (!strcmp(res->value, "off")) {
1775 rx_offloads &= ~(DEV_RX_OFFLOAD_VLAN_FILTER |
1776 DEV_RX_OFFLOAD_VLAN_STRIP);
1779 printf("Unknown parameter\n");
1782 } else if (!strcmp(res->name, "hw-vlan-filter")) {
1783 if (!strcmp(res->value, "on"))
1784 rx_offloads |= DEV_RX_OFFLOAD_VLAN_FILTER;
1785 else if (!strcmp(res->value, "off"))
1786 rx_offloads &= ~DEV_RX_OFFLOAD_VLAN_FILTER;
1788 printf("Unknown parameter\n");
1791 } else if (!strcmp(res->name, "hw-vlan-strip")) {
1792 if (!strcmp(res->value, "on"))
1793 rx_offloads |= DEV_RX_OFFLOAD_VLAN_STRIP;
1794 else if (!strcmp(res->value, "off"))
1795 rx_offloads &= ~DEV_RX_OFFLOAD_VLAN_STRIP;
1797 printf("Unknown parameter\n");
1800 } else if (!strcmp(res->name, "hw-vlan-extend")) {
1801 if (!strcmp(res->value, "on"))
1802 rx_offloads |= DEV_RX_OFFLOAD_VLAN_EXTEND;
1803 else if (!strcmp(res->value, "off"))
1804 rx_offloads &= ~DEV_RX_OFFLOAD_VLAN_EXTEND;
1806 printf("Unknown parameter\n");
1809 } else if (!strcmp(res->name, "drop-en")) {
1810 if (!strcmp(res->value, "on"))
1812 else if (!strcmp(res->value, "off"))
1815 printf("Unknown parameter\n");
1819 printf("Unknown parameter\n");
1822 rx_mode.offloads = rx_offloads;
1826 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1829 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
1830 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
1831 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
1832 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
1834 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
1835 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
1836 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
1837 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
1838 "crc-strip#scatter#rx-cksum#rx-timestamp#hw-vlan#"
1839 "hw-vlan-filter#hw-vlan-strip#hw-vlan-extend");
1840 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
1841 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
1844 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
1845 .f = cmd_config_rx_mode_flag_parsed,
1847 .help_str = "port config all crc-strip|scatter|rx-cksum|rx-timestamp|hw-vlan|"
1848 "hw-vlan-filter|hw-vlan-strip|hw-vlan-extend on|off",
1850 (void *)&cmd_config_rx_mode_flag_port,
1851 (void *)&cmd_config_rx_mode_flag_keyword,
1852 (void *)&cmd_config_rx_mode_flag_all,
1853 (void *)&cmd_config_rx_mode_flag_name,
1854 (void *)&cmd_config_rx_mode_flag_value,
1859 /* *** configure rss *** */
1860 struct cmd_config_rss {
1861 cmdline_fixed_string_t port;
1862 cmdline_fixed_string_t keyword;
1863 cmdline_fixed_string_t all;
1864 cmdline_fixed_string_t name;
1865 cmdline_fixed_string_t value;
1869 cmd_config_rss_parsed(void *parsed_result,
1870 __attribute__((unused)) struct cmdline *cl,
1871 __attribute__((unused)) void *data)
1873 struct cmd_config_rss *res = parsed_result;
1874 struct rte_eth_rss_conf rss_conf = { .rss_key_len = 0, };
1878 if (!strcmp(res->value, "all"))
1879 rss_conf.rss_hf = ETH_RSS_IP | ETH_RSS_TCP |
1880 ETH_RSS_UDP | ETH_RSS_SCTP |
1882 else if (!strcmp(res->value, "ip"))
1883 rss_conf.rss_hf = ETH_RSS_IP;
1884 else if (!strcmp(res->value, "udp"))
1885 rss_conf.rss_hf = ETH_RSS_UDP;
1886 else if (!strcmp(res->value, "tcp"))
1887 rss_conf.rss_hf = ETH_RSS_TCP;
1888 else if (!strcmp(res->value, "sctp"))
1889 rss_conf.rss_hf = ETH_RSS_SCTP;
1890 else if (!strcmp(res->value, "ether"))
1891 rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD;
1892 else if (!strcmp(res->value, "port"))
1893 rss_conf.rss_hf = ETH_RSS_PORT;
1894 else if (!strcmp(res->value, "vxlan"))
1895 rss_conf.rss_hf = ETH_RSS_VXLAN;
1896 else if (!strcmp(res->value, "geneve"))
1897 rss_conf.rss_hf = ETH_RSS_GENEVE;
1898 else if (!strcmp(res->value, "nvgre"))
1899 rss_conf.rss_hf = ETH_RSS_NVGRE;
1900 else if (!strcmp(res->value, "none"))
1901 rss_conf.rss_hf = 0;
1902 else if (isdigit(res->value[0]) && atoi(res->value) > 0 &&
1903 atoi(res->value) < 64)
1904 rss_conf.rss_hf = 1ULL << atoi(res->value);
1906 printf("Unknown parameter\n");
1909 rss_conf.rss_key = NULL;
1910 for (i = 0; i < rte_eth_dev_count(); i++) {
1911 diag = rte_eth_dev_rss_hash_update(i, &rss_conf);
1913 printf("Configuration of RSS hash at ethernet port %d "
1914 "failed with error (%d): %s.\n",
1915 i, -diag, strerror(-diag));
1919 cmdline_parse_token_string_t cmd_config_rss_port =
1920 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
1921 cmdline_parse_token_string_t cmd_config_rss_keyword =
1922 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
1923 cmdline_parse_token_string_t cmd_config_rss_all =
1924 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
1925 cmdline_parse_token_string_t cmd_config_rss_name =
1926 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
1927 cmdline_parse_token_string_t cmd_config_rss_value =
1928 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, NULL);
1930 cmdline_parse_inst_t cmd_config_rss = {
1931 .f = cmd_config_rss_parsed,
1933 .help_str = "port config all rss "
1934 "all|ip|tcp|udp|sctp|ether|port|vxlan|geneve|nvgre|none|<flowtype_id>",
1936 (void *)&cmd_config_rss_port,
1937 (void *)&cmd_config_rss_keyword,
1938 (void *)&cmd_config_rss_all,
1939 (void *)&cmd_config_rss_name,
1940 (void *)&cmd_config_rss_value,
1945 /* *** configure rss hash key *** */
1946 struct cmd_config_rss_hash_key {
1947 cmdline_fixed_string_t port;
1948 cmdline_fixed_string_t config;
1950 cmdline_fixed_string_t rss_hash_key;
1951 cmdline_fixed_string_t rss_type;
1952 cmdline_fixed_string_t key;
1956 hexa_digit_to_value(char hexa_digit)
1958 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
1959 return (uint8_t) (hexa_digit - '0');
1960 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
1961 return (uint8_t) ((hexa_digit - 'a') + 10);
1962 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
1963 return (uint8_t) ((hexa_digit - 'A') + 10);
1964 /* Invalid hexa digit */
1969 parse_and_check_key_hexa_digit(char *key, int idx)
1973 hexa_v = hexa_digit_to_value(key[idx]);
1975 printf("invalid key: character %c at position %d is not a "
1976 "valid hexa digit\n", key[idx], idx);
1981 cmd_config_rss_hash_key_parsed(void *parsed_result,
1982 __attribute__((unused)) struct cmdline *cl,
1983 __attribute__((unused)) void *data)
1985 struct cmd_config_rss_hash_key *res = parsed_result;
1986 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
1990 struct rte_eth_dev_info dev_info;
1991 uint8_t hash_key_size;
1994 memset(&dev_info, 0, sizeof(dev_info));
1995 rte_eth_dev_info_get(res->port_id, &dev_info);
1996 if (dev_info.hash_key_size > 0 &&
1997 dev_info.hash_key_size <= sizeof(hash_key))
1998 hash_key_size = dev_info.hash_key_size;
2000 printf("dev_info did not provide a valid hash key size\n");
2003 /* Check the length of the RSS hash key */
2004 key_len = strlen(res->key);
2005 if (key_len != (hash_key_size * 2)) {
2006 printf("key length: %d invalid - key must be a string of %d"
2007 " hexa-decimal numbers\n",
2008 (int) key_len, hash_key_size * 2);
2011 /* Translate RSS hash key into binary representation */
2012 for (i = 0; i < hash_key_size; i++) {
2013 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
2016 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
2019 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
2021 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
2025 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
2026 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
2027 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
2028 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
2030 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
2031 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT16);
2032 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
2033 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
2034 rss_hash_key, "rss-hash-key");
2035 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
2036 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
2037 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2038 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2039 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2040 "ipv6-tcp-ex#ipv6-udp-ex");
2041 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
2042 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
2044 cmdline_parse_inst_t cmd_config_rss_hash_key = {
2045 .f = cmd_config_rss_hash_key_parsed,
2047 .help_str = "port config <port_id> rss-hash-key "
2048 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2049 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2050 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex "
2051 "<string of hex digits (variable length, NIC dependent)>",
2053 (void *)&cmd_config_rss_hash_key_port,
2054 (void *)&cmd_config_rss_hash_key_config,
2055 (void *)&cmd_config_rss_hash_key_port_id,
2056 (void *)&cmd_config_rss_hash_key_rss_hash_key,
2057 (void *)&cmd_config_rss_hash_key_rss_type,
2058 (void *)&cmd_config_rss_hash_key_value,
2063 /* *** configure port rxq/txq start/stop *** */
2064 struct cmd_config_rxtx_queue {
2065 cmdline_fixed_string_t port;
2067 cmdline_fixed_string_t rxtxq;
2069 cmdline_fixed_string_t opname;
2073 cmd_config_rxtx_queue_parsed(void *parsed_result,
2074 __attribute__((unused)) struct cmdline *cl,
2075 __attribute__((unused)) void *data)
2077 struct cmd_config_rxtx_queue *res = parsed_result;
2082 if (test_done == 0) {
2083 printf("Please stop forwarding first\n");
2087 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2090 if (port_is_started(res->portid) != 1) {
2091 printf("Please start port %u first\n", res->portid);
2095 if (!strcmp(res->rxtxq, "rxq"))
2097 else if (!strcmp(res->rxtxq, "txq"))
2100 printf("Unknown parameter\n");
2104 if (isrx && rx_queue_id_is_invalid(res->qid))
2106 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2109 if (!strcmp(res->opname, "start"))
2111 else if (!strcmp(res->opname, "stop"))
2114 printf("Unknown parameter\n");
2118 if (isstart && isrx)
2119 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
2120 else if (!isstart && isrx)
2121 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
2122 else if (isstart && !isrx)
2123 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
2125 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
2127 if (ret == -ENOTSUP)
2128 printf("Function not supported in PMD driver\n");
2131 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
2132 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
2133 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
2134 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT16);
2135 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
2136 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
2137 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
2138 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
2139 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
2140 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
2143 cmdline_parse_inst_t cmd_config_rxtx_queue = {
2144 .f = cmd_config_rxtx_queue_parsed,
2146 .help_str = "port <port_id> rxq|txq <queue_id> start|stop",
2148 (void *)&cmd_config_speed_all_port,
2149 (void *)&cmd_config_rxtx_queue_portid,
2150 (void *)&cmd_config_rxtx_queue_rxtxq,
2151 (void *)&cmd_config_rxtx_queue_qid,
2152 (void *)&cmd_config_rxtx_queue_opname,
2157 /* *** Configure RSS RETA *** */
2158 struct cmd_config_rss_reta {
2159 cmdline_fixed_string_t port;
2160 cmdline_fixed_string_t keyword;
2162 cmdline_fixed_string_t name;
2163 cmdline_fixed_string_t list_name;
2164 cmdline_fixed_string_t list_of_items;
2168 parse_reta_config(const char *str,
2169 struct rte_eth_rss_reta_entry64 *reta_conf,
2170 uint16_t nb_entries)
2174 uint16_t hash_index, idx, shift;
2177 const char *p, *p0 = str;
2184 unsigned long int_fld[_NUM_FLD];
2185 char *str_fld[_NUM_FLD];
2187 while ((p = strchr(p0,'(')) != NULL) {
2189 if((p0 = strchr(p,')')) == NULL)
2193 if(size >= sizeof(s))
2196 snprintf(s, sizeof(s), "%.*s", size, p);
2197 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
2199 for (i = 0; i < _NUM_FLD; i++) {
2201 int_fld[i] = strtoul(str_fld[i], &end, 0);
2202 if (errno != 0 || end == str_fld[i] ||
2207 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
2208 nb_queue = (uint16_t)int_fld[FLD_QUEUE];
2210 if (hash_index >= nb_entries) {
2211 printf("Invalid RETA hash index=%d\n", hash_index);
2215 idx = hash_index / RTE_RETA_GROUP_SIZE;
2216 shift = hash_index % RTE_RETA_GROUP_SIZE;
2217 reta_conf[idx].mask |= (1ULL << shift);
2218 reta_conf[idx].reta[shift] = nb_queue;
2225 cmd_set_rss_reta_parsed(void *parsed_result,
2226 __attribute__((unused)) struct cmdline *cl,
2227 __attribute__((unused)) void *data)
2230 struct rte_eth_dev_info dev_info;
2231 struct rte_eth_rss_reta_entry64 reta_conf[8];
2232 struct cmd_config_rss_reta *res = parsed_result;
2234 memset(&dev_info, 0, sizeof(dev_info));
2235 rte_eth_dev_info_get(res->port_id, &dev_info);
2236 if (dev_info.reta_size == 0) {
2237 printf("Redirection table size is 0 which is "
2238 "invalid for RSS\n");
2241 printf("The reta size of port %d is %u\n",
2242 res->port_id, dev_info.reta_size);
2243 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
2244 printf("Currently do not support more than %u entries of "
2245 "redirection table\n", ETH_RSS_RETA_SIZE_512);
2249 memset(reta_conf, 0, sizeof(reta_conf));
2250 if (!strcmp(res->list_name, "reta")) {
2251 if (parse_reta_config(res->list_of_items, reta_conf,
2252 dev_info.reta_size)) {
2253 printf("Invalid RSS Redirection Table "
2254 "config entered\n");
2257 ret = rte_eth_dev_rss_reta_update(res->port_id,
2258 reta_conf, dev_info.reta_size);
2260 printf("Bad redirection table parameter, "
2261 "return code = %d \n", ret);
2265 cmdline_parse_token_string_t cmd_config_rss_reta_port =
2266 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
2267 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
2268 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
2269 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
2270 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT16);
2271 cmdline_parse_token_string_t cmd_config_rss_reta_name =
2272 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
2273 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
2274 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
2275 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
2276 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
2278 cmdline_parse_inst_t cmd_config_rss_reta = {
2279 .f = cmd_set_rss_reta_parsed,
2281 .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
2283 (void *)&cmd_config_rss_reta_port,
2284 (void *)&cmd_config_rss_reta_keyword,
2285 (void *)&cmd_config_rss_reta_port_id,
2286 (void *)&cmd_config_rss_reta_name,
2287 (void *)&cmd_config_rss_reta_list_name,
2288 (void *)&cmd_config_rss_reta_list_of_items,
2293 /* *** SHOW PORT RETA INFO *** */
2294 struct cmd_showport_reta {
2295 cmdline_fixed_string_t show;
2296 cmdline_fixed_string_t port;
2298 cmdline_fixed_string_t rss;
2299 cmdline_fixed_string_t reta;
2301 cmdline_fixed_string_t list_of_items;
2305 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
2306 uint16_t nb_entries,
2310 const char *p, *p0 = str;
2315 uint16_t num = (nb_entries + RTE_RETA_GROUP_SIZE - 1) /
2316 RTE_RETA_GROUP_SIZE;
2319 p = strchr(p0, '(');
2323 p0 = strchr(p, ')');
2327 if (size >= sizeof(s)) {
2328 printf("The string size exceeds the internal buffer size\n");
2331 snprintf(s, sizeof(s), "%.*s", size, p);
2332 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
2333 if (ret <= 0 || ret != num) {
2334 printf("The bits of masks do not match the number of "
2335 "reta entries: %u\n", num);
2338 for (i = 0; i < ret; i++)
2339 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
2345 cmd_showport_reta_parsed(void *parsed_result,
2346 __attribute__((unused)) struct cmdline *cl,
2347 __attribute__((unused)) void *data)
2349 struct cmd_showport_reta *res = parsed_result;
2350 struct rte_eth_rss_reta_entry64 reta_conf[8];
2351 struct rte_eth_dev_info dev_info;
2352 uint16_t max_reta_size;
2354 memset(&dev_info, 0, sizeof(dev_info));
2355 rte_eth_dev_info_get(res->port_id, &dev_info);
2356 max_reta_size = RTE_MIN(dev_info.reta_size, ETH_RSS_RETA_SIZE_512);
2357 if (res->size == 0 || res->size > max_reta_size) {
2358 printf("Invalid redirection table size: %u (1-%u)\n",
2359 res->size, max_reta_size);
2363 memset(reta_conf, 0, sizeof(reta_conf));
2364 if (showport_parse_reta_config(reta_conf, res->size,
2365 res->list_of_items) < 0) {
2366 printf("Invalid string: %s for reta masks\n",
2367 res->list_of_items);
2370 port_rss_reta_info(res->port_id, reta_conf, res->size);
2373 cmdline_parse_token_string_t cmd_showport_reta_show =
2374 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
2375 cmdline_parse_token_string_t cmd_showport_reta_port =
2376 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
2377 cmdline_parse_token_num_t cmd_showport_reta_port_id =
2378 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT16);
2379 cmdline_parse_token_string_t cmd_showport_reta_rss =
2380 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
2381 cmdline_parse_token_string_t cmd_showport_reta_reta =
2382 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
2383 cmdline_parse_token_num_t cmd_showport_reta_size =
2384 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16);
2385 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
2386 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
2387 list_of_items, NULL);
2389 cmdline_parse_inst_t cmd_showport_reta = {
2390 .f = cmd_showport_reta_parsed,
2392 .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
2394 (void *)&cmd_showport_reta_show,
2395 (void *)&cmd_showport_reta_port,
2396 (void *)&cmd_showport_reta_port_id,
2397 (void *)&cmd_showport_reta_rss,
2398 (void *)&cmd_showport_reta_reta,
2399 (void *)&cmd_showport_reta_size,
2400 (void *)&cmd_showport_reta_list_of_items,
2405 /* *** Show RSS hash configuration *** */
2406 struct cmd_showport_rss_hash {
2407 cmdline_fixed_string_t show;
2408 cmdline_fixed_string_t port;
2410 cmdline_fixed_string_t rss_hash;
2411 cmdline_fixed_string_t rss_type;
2412 cmdline_fixed_string_t key; /* optional argument */
2415 static void cmd_showport_rss_hash_parsed(void *parsed_result,
2416 __attribute__((unused)) struct cmdline *cl,
2419 struct cmd_showport_rss_hash *res = parsed_result;
2421 port_rss_hash_conf_show(res->port_id, res->rss_type,
2422 show_rss_key != NULL);
2425 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
2426 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
2427 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
2428 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
2429 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
2430 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT16);
2431 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
2432 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
2434 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash_info =
2435 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_type,
2436 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2437 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2438 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2439 "ipv6-tcp-ex#ipv6-udp-ex");
2440 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
2441 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
2443 cmdline_parse_inst_t cmd_showport_rss_hash = {
2444 .f = cmd_showport_rss_hash_parsed,
2446 .help_str = "show port <port_id> rss-hash "
2447 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2448 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2449 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex",
2451 (void *)&cmd_showport_rss_hash_show,
2452 (void *)&cmd_showport_rss_hash_port,
2453 (void *)&cmd_showport_rss_hash_port_id,
2454 (void *)&cmd_showport_rss_hash_rss_hash,
2455 (void *)&cmd_showport_rss_hash_rss_hash_info,
2460 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
2461 .f = cmd_showport_rss_hash_parsed,
2463 .help_str = "show port <port_id> rss-hash "
2464 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2465 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2466 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex key",
2468 (void *)&cmd_showport_rss_hash_show,
2469 (void *)&cmd_showport_rss_hash_port,
2470 (void *)&cmd_showport_rss_hash_port_id,
2471 (void *)&cmd_showport_rss_hash_rss_hash,
2472 (void *)&cmd_showport_rss_hash_rss_hash_info,
2473 (void *)&cmd_showport_rss_hash_rss_key,
2478 /* *** Configure DCB *** */
2479 struct cmd_config_dcb {
2480 cmdline_fixed_string_t port;
2481 cmdline_fixed_string_t config;
2483 cmdline_fixed_string_t dcb;
2484 cmdline_fixed_string_t vt;
2485 cmdline_fixed_string_t vt_en;
2487 cmdline_fixed_string_t pfc;
2488 cmdline_fixed_string_t pfc_en;
2492 cmd_config_dcb_parsed(void *parsed_result,
2493 __attribute__((unused)) struct cmdline *cl,
2494 __attribute__((unused)) void *data)
2496 struct cmd_config_dcb *res = parsed_result;
2497 portid_t port_id = res->port_id;
2498 struct rte_port *port;
2502 port = &ports[port_id];
2503 /** Check if the port is not started **/
2504 if (port->port_status != RTE_PORT_STOPPED) {
2505 printf("Please stop port %d first\n", port_id);
2509 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
2510 printf("The invalid number of traffic class,"
2511 " only 4 or 8 allowed.\n");
2515 if (nb_fwd_lcores < res->num_tcs) {
2516 printf("nb_cores shouldn't be less than number of TCs.\n");
2519 if (!strncmp(res->pfc_en, "on", 2))
2524 /* DCB in VT mode */
2525 if (!strncmp(res->vt_en, "on", 2))
2526 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
2527 (enum rte_eth_nb_tcs)res->num_tcs,
2530 ret = init_port_dcb_config(port_id, DCB_ENABLED,
2531 (enum rte_eth_nb_tcs)res->num_tcs,
2536 printf("Cannot initialize network ports.\n");
2540 cmd_reconfig_device_queue(port_id, 1, 1);
2543 cmdline_parse_token_string_t cmd_config_dcb_port =
2544 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
2545 cmdline_parse_token_string_t cmd_config_dcb_config =
2546 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
2547 cmdline_parse_token_num_t cmd_config_dcb_port_id =
2548 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT16);
2549 cmdline_parse_token_string_t cmd_config_dcb_dcb =
2550 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
2551 cmdline_parse_token_string_t cmd_config_dcb_vt =
2552 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
2553 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
2554 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
2555 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
2556 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
2557 cmdline_parse_token_string_t cmd_config_dcb_pfc=
2558 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
2559 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
2560 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
2562 cmdline_parse_inst_t cmd_config_dcb = {
2563 .f = cmd_config_dcb_parsed,
2565 .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
2567 (void *)&cmd_config_dcb_port,
2568 (void *)&cmd_config_dcb_config,
2569 (void *)&cmd_config_dcb_port_id,
2570 (void *)&cmd_config_dcb_dcb,
2571 (void *)&cmd_config_dcb_vt,
2572 (void *)&cmd_config_dcb_vt_en,
2573 (void *)&cmd_config_dcb_num_tcs,
2574 (void *)&cmd_config_dcb_pfc,
2575 (void *)&cmd_config_dcb_pfc_en,
2580 /* *** configure number of packets per burst *** */
2581 struct cmd_config_burst {
2582 cmdline_fixed_string_t port;
2583 cmdline_fixed_string_t keyword;
2584 cmdline_fixed_string_t all;
2585 cmdline_fixed_string_t name;
2590 cmd_config_burst_parsed(void *parsed_result,
2591 __attribute__((unused)) struct cmdline *cl,
2592 __attribute__((unused)) void *data)
2594 struct cmd_config_burst *res = parsed_result;
2596 if (!all_ports_stopped()) {
2597 printf("Please stop all ports first\n");
2601 if (!strcmp(res->name, "burst")) {
2602 if (res->value < 1 || res->value > MAX_PKT_BURST) {
2603 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
2606 nb_pkt_per_burst = res->value;
2608 printf("Unknown parameter\n");
2614 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2617 cmdline_parse_token_string_t cmd_config_burst_port =
2618 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
2619 cmdline_parse_token_string_t cmd_config_burst_keyword =
2620 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
2621 cmdline_parse_token_string_t cmd_config_burst_all =
2622 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
2623 cmdline_parse_token_string_t cmd_config_burst_name =
2624 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
2625 cmdline_parse_token_num_t cmd_config_burst_value =
2626 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
2628 cmdline_parse_inst_t cmd_config_burst = {
2629 .f = cmd_config_burst_parsed,
2631 .help_str = "port config all burst <value>",
2633 (void *)&cmd_config_burst_port,
2634 (void *)&cmd_config_burst_keyword,
2635 (void *)&cmd_config_burst_all,
2636 (void *)&cmd_config_burst_name,
2637 (void *)&cmd_config_burst_value,
2642 /* *** configure rx/tx queues *** */
2643 struct cmd_config_thresh {
2644 cmdline_fixed_string_t port;
2645 cmdline_fixed_string_t keyword;
2646 cmdline_fixed_string_t all;
2647 cmdline_fixed_string_t name;
2652 cmd_config_thresh_parsed(void *parsed_result,
2653 __attribute__((unused)) struct cmdline *cl,
2654 __attribute__((unused)) void *data)
2656 struct cmd_config_thresh *res = parsed_result;
2658 if (!all_ports_stopped()) {
2659 printf("Please stop all ports first\n");
2663 if (!strcmp(res->name, "txpt"))
2664 tx_pthresh = res->value;
2665 else if(!strcmp(res->name, "txht"))
2666 tx_hthresh = res->value;
2667 else if(!strcmp(res->name, "txwt"))
2668 tx_wthresh = res->value;
2669 else if(!strcmp(res->name, "rxpt"))
2670 rx_pthresh = res->value;
2671 else if(!strcmp(res->name, "rxht"))
2672 rx_hthresh = res->value;
2673 else if(!strcmp(res->name, "rxwt"))
2674 rx_wthresh = res->value;
2676 printf("Unknown parameter\n");
2682 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2685 cmdline_parse_token_string_t cmd_config_thresh_port =
2686 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
2687 cmdline_parse_token_string_t cmd_config_thresh_keyword =
2688 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
2689 cmdline_parse_token_string_t cmd_config_thresh_all =
2690 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
2691 cmdline_parse_token_string_t cmd_config_thresh_name =
2692 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
2693 "txpt#txht#txwt#rxpt#rxht#rxwt");
2694 cmdline_parse_token_num_t cmd_config_thresh_value =
2695 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
2697 cmdline_parse_inst_t cmd_config_thresh = {
2698 .f = cmd_config_thresh_parsed,
2700 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
2702 (void *)&cmd_config_thresh_port,
2703 (void *)&cmd_config_thresh_keyword,
2704 (void *)&cmd_config_thresh_all,
2705 (void *)&cmd_config_thresh_name,
2706 (void *)&cmd_config_thresh_value,
2711 /* *** configure free/rs threshold *** */
2712 struct cmd_config_threshold {
2713 cmdline_fixed_string_t port;
2714 cmdline_fixed_string_t keyword;
2715 cmdline_fixed_string_t all;
2716 cmdline_fixed_string_t name;
2721 cmd_config_threshold_parsed(void *parsed_result,
2722 __attribute__((unused)) struct cmdline *cl,
2723 __attribute__((unused)) void *data)
2725 struct cmd_config_threshold *res = parsed_result;
2727 if (!all_ports_stopped()) {
2728 printf("Please stop all ports first\n");
2732 if (!strcmp(res->name, "txfreet"))
2733 tx_free_thresh = res->value;
2734 else if (!strcmp(res->name, "txrst"))
2735 tx_rs_thresh = res->value;
2736 else if (!strcmp(res->name, "rxfreet"))
2737 rx_free_thresh = res->value;
2739 printf("Unknown parameter\n");
2745 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2748 cmdline_parse_token_string_t cmd_config_threshold_port =
2749 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
2750 cmdline_parse_token_string_t cmd_config_threshold_keyword =
2751 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
2753 cmdline_parse_token_string_t cmd_config_threshold_all =
2754 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
2755 cmdline_parse_token_string_t cmd_config_threshold_name =
2756 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
2757 "txfreet#txrst#rxfreet");
2758 cmdline_parse_token_num_t cmd_config_threshold_value =
2759 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
2761 cmdline_parse_inst_t cmd_config_threshold = {
2762 .f = cmd_config_threshold_parsed,
2764 .help_str = "port config all txfreet|txrst|rxfreet <value>",
2766 (void *)&cmd_config_threshold_port,
2767 (void *)&cmd_config_threshold_keyword,
2768 (void *)&cmd_config_threshold_all,
2769 (void *)&cmd_config_threshold_name,
2770 (void *)&cmd_config_threshold_value,
2776 struct cmd_stop_result {
2777 cmdline_fixed_string_t stop;
2780 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
2781 __attribute__((unused)) struct cmdline *cl,
2782 __attribute__((unused)) void *data)
2784 stop_packet_forwarding();
2787 cmdline_parse_token_string_t cmd_stop_stop =
2788 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
2790 cmdline_parse_inst_t cmd_stop = {
2791 .f = cmd_stop_parsed,
2793 .help_str = "stop: Stop packet forwarding",
2795 (void *)&cmd_stop_stop,
2800 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
2803 parse_item_list(char* str, const char* item_name, unsigned int max_items,
2804 unsigned int *parsed_items, int check_unique_values)
2806 unsigned int nb_item;
2814 * First parse all items in the list and store their value.
2819 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
2821 if ((c >= '0') && (c <= '9')) {
2822 value = (unsigned int) (value * 10 + (c - '0'));
2827 printf("character %c is not a decimal digit\n", c);
2831 printf("No valid value before comma\n");
2834 if (nb_item < max_items) {
2835 parsed_items[nb_item] = value;
2841 if (nb_item >= max_items) {
2842 printf("Number of %s = %u > %u (maximum items)\n",
2843 item_name, nb_item + 1, max_items);
2846 parsed_items[nb_item++] = value;
2847 if (! check_unique_values)
2851 * Then, check that all values in the list are differents.
2852 * No optimization here...
2854 for (i = 0; i < nb_item; i++) {
2855 for (j = i + 1; j < nb_item; j++) {
2856 if (parsed_items[j] == parsed_items[i]) {
2857 printf("duplicated %s %u at index %u and %u\n",
2858 item_name, parsed_items[i], i, j);
2866 struct cmd_set_list_result {
2867 cmdline_fixed_string_t cmd_keyword;
2868 cmdline_fixed_string_t list_name;
2869 cmdline_fixed_string_t list_of_items;
2872 static void cmd_set_list_parsed(void *parsed_result,
2873 __attribute__((unused)) struct cmdline *cl,
2874 __attribute__((unused)) void *data)
2876 struct cmd_set_list_result *res;
2878 unsigned int lcorelist[RTE_MAX_LCORE];
2879 unsigned int portlist[RTE_MAX_ETHPORTS];
2881 unsigned int nb_item;
2883 if (test_done == 0) {
2884 printf("Please stop forwarding first\n");
2888 res = parsed_result;
2889 if (!strcmp(res->list_name, "corelist")) {
2890 nb_item = parse_item_list(res->list_of_items, "core",
2892 parsed_items.lcorelist, 1);
2894 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
2899 if (!strcmp(res->list_name, "portlist")) {
2900 nb_item = parse_item_list(res->list_of_items, "port",
2902 parsed_items.portlist, 1);
2904 set_fwd_ports_list(parsed_items.portlist, nb_item);
2910 cmdline_parse_token_string_t cmd_set_list_keyword =
2911 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
2913 cmdline_parse_token_string_t cmd_set_list_name =
2914 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
2915 "corelist#portlist");
2916 cmdline_parse_token_string_t cmd_set_list_of_items =
2917 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
2920 cmdline_parse_inst_t cmd_set_fwd_list = {
2921 .f = cmd_set_list_parsed,
2923 .help_str = "set corelist|portlist <list0[,list1]*>",
2925 (void *)&cmd_set_list_keyword,
2926 (void *)&cmd_set_list_name,
2927 (void *)&cmd_set_list_of_items,
2932 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
2934 struct cmd_setmask_result {
2935 cmdline_fixed_string_t set;
2936 cmdline_fixed_string_t mask;
2940 static void cmd_set_mask_parsed(void *parsed_result,
2941 __attribute__((unused)) struct cmdline *cl,
2942 __attribute__((unused)) void *data)
2944 struct cmd_setmask_result *res = parsed_result;
2946 if (test_done == 0) {
2947 printf("Please stop forwarding first\n");
2950 if (!strcmp(res->mask, "coremask")) {
2951 set_fwd_lcores_mask(res->hexavalue);
2953 } else if (!strcmp(res->mask, "portmask")) {
2954 set_fwd_ports_mask(res->hexavalue);
2959 cmdline_parse_token_string_t cmd_setmask_set =
2960 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
2961 cmdline_parse_token_string_t cmd_setmask_mask =
2962 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
2963 "coremask#portmask");
2964 cmdline_parse_token_num_t cmd_setmask_value =
2965 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
2967 cmdline_parse_inst_t cmd_set_fwd_mask = {
2968 .f = cmd_set_mask_parsed,
2970 .help_str = "set coremask|portmask <hexadecimal value>",
2972 (void *)&cmd_setmask_set,
2973 (void *)&cmd_setmask_mask,
2974 (void *)&cmd_setmask_value,
2980 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
2982 struct cmd_set_result {
2983 cmdline_fixed_string_t set;
2984 cmdline_fixed_string_t what;
2988 static void cmd_set_parsed(void *parsed_result,
2989 __attribute__((unused)) struct cmdline *cl,
2990 __attribute__((unused)) void *data)
2992 struct cmd_set_result *res = parsed_result;
2993 if (!strcmp(res->what, "nbport")) {
2994 set_fwd_ports_number(res->value);
2996 } else if (!strcmp(res->what, "nbcore")) {
2997 set_fwd_lcores_number(res->value);
2999 } else if (!strcmp(res->what, "burst"))
3000 set_nb_pkt_per_burst(res->value);
3001 else if (!strcmp(res->what, "verbose"))
3002 set_verbose_level(res->value);
3005 cmdline_parse_token_string_t cmd_set_set =
3006 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
3007 cmdline_parse_token_string_t cmd_set_what =
3008 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
3009 "nbport#nbcore#burst#verbose");
3010 cmdline_parse_token_num_t cmd_set_value =
3011 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
3013 cmdline_parse_inst_t cmd_set_numbers = {
3014 .f = cmd_set_parsed,
3016 .help_str = "set nbport|nbcore|burst|verbose <value>",
3018 (void *)&cmd_set_set,
3019 (void *)&cmd_set_what,
3020 (void *)&cmd_set_value,
3025 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
3027 struct cmd_set_txpkts_result {
3028 cmdline_fixed_string_t cmd_keyword;
3029 cmdline_fixed_string_t txpkts;
3030 cmdline_fixed_string_t seg_lengths;
3034 cmd_set_txpkts_parsed(void *parsed_result,
3035 __attribute__((unused)) struct cmdline *cl,
3036 __attribute__((unused)) void *data)
3038 struct cmd_set_txpkts_result *res;
3039 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
3040 unsigned int nb_segs;
3042 res = parsed_result;
3043 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
3044 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
3046 set_tx_pkt_segments(seg_lengths, nb_segs);
3049 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
3050 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3051 cmd_keyword, "set");
3052 cmdline_parse_token_string_t cmd_set_txpkts_name =
3053 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3055 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
3056 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3059 cmdline_parse_inst_t cmd_set_txpkts = {
3060 .f = cmd_set_txpkts_parsed,
3062 .help_str = "set txpkts <len0[,len1]*>",
3064 (void *)&cmd_set_txpkts_keyword,
3065 (void *)&cmd_set_txpkts_name,
3066 (void *)&cmd_set_txpkts_lengths,
3071 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
3073 struct cmd_set_txsplit_result {
3074 cmdline_fixed_string_t cmd_keyword;
3075 cmdline_fixed_string_t txsplit;
3076 cmdline_fixed_string_t mode;
3080 cmd_set_txsplit_parsed(void *parsed_result,
3081 __attribute__((unused)) struct cmdline *cl,
3082 __attribute__((unused)) void *data)
3084 struct cmd_set_txsplit_result *res;
3086 res = parsed_result;
3087 set_tx_pkt_split(res->mode);
3090 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
3091 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3092 cmd_keyword, "set");
3093 cmdline_parse_token_string_t cmd_set_txsplit_name =
3094 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3095 txsplit, "txsplit");
3096 cmdline_parse_token_string_t cmd_set_txsplit_mode =
3097 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3100 cmdline_parse_inst_t cmd_set_txsplit = {
3101 .f = cmd_set_txsplit_parsed,
3103 .help_str = "set txsplit on|off|rand",
3105 (void *)&cmd_set_txsplit_keyword,
3106 (void *)&cmd_set_txsplit_name,
3107 (void *)&cmd_set_txsplit_mode,
3112 /* *** CONFIG TX QUEUE FLAGS *** */
3114 struct cmd_config_txqflags_result {
3115 cmdline_fixed_string_t port;
3116 cmdline_fixed_string_t config;
3117 cmdline_fixed_string_t all;
3118 cmdline_fixed_string_t what;
3122 static void cmd_config_txqflags_parsed(void *parsed_result,
3123 __attribute__((unused)) struct cmdline *cl,
3124 __attribute__((unused)) void *data)
3126 struct cmd_config_txqflags_result *res = parsed_result;
3128 if (!all_ports_stopped()) {
3129 printf("Please stop all ports first\n");
3133 if (strcmp(res->what, "txqflags")) {
3134 printf("Unknown parameter\n");
3138 if (res->hexvalue >= 0) {
3139 txq_flags = res->hexvalue;
3141 printf("txqflags must be >= 0\n");
3147 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3150 cmdline_parse_token_string_t cmd_config_txqflags_port =
3151 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, port,
3153 cmdline_parse_token_string_t cmd_config_txqflags_config =
3154 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, config,
3156 cmdline_parse_token_string_t cmd_config_txqflags_all =
3157 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, all,
3159 cmdline_parse_token_string_t cmd_config_txqflags_what =
3160 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, what,
3162 cmdline_parse_token_num_t cmd_config_txqflags_value =
3163 TOKEN_NUM_INITIALIZER(struct cmd_config_txqflags_result,
3166 cmdline_parse_inst_t cmd_config_txqflags = {
3167 .f = cmd_config_txqflags_parsed,
3169 .help_str = "port config all txqflags <value>",
3171 (void *)&cmd_config_txqflags_port,
3172 (void *)&cmd_config_txqflags_config,
3173 (void *)&cmd_config_txqflags_all,
3174 (void *)&cmd_config_txqflags_what,
3175 (void *)&cmd_config_txqflags_value,
3180 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
3181 struct cmd_rx_vlan_filter_all_result {
3182 cmdline_fixed_string_t rx_vlan;
3183 cmdline_fixed_string_t what;
3184 cmdline_fixed_string_t all;
3189 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
3190 __attribute__((unused)) struct cmdline *cl,
3191 __attribute__((unused)) void *data)
3193 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
3195 if (!strcmp(res->what, "add"))
3196 rx_vlan_all_filter_set(res->port_id, 1);
3198 rx_vlan_all_filter_set(res->port_id, 0);
3201 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
3202 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3203 rx_vlan, "rx_vlan");
3204 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
3205 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3207 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
3208 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3210 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
3211 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3214 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
3215 .f = cmd_rx_vlan_filter_all_parsed,
3217 .help_str = "rx_vlan add|rm all <port_id>: "
3218 "Add/Remove all identifiers to/from the set of VLAN "
3219 "identifiers filtered by a port",
3221 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
3222 (void *)&cmd_rx_vlan_filter_all_what,
3223 (void *)&cmd_rx_vlan_filter_all_all,
3224 (void *)&cmd_rx_vlan_filter_all_portid,
3229 /* *** VLAN OFFLOAD SET ON A PORT *** */
3230 struct cmd_vlan_offload_result {
3231 cmdline_fixed_string_t vlan;
3232 cmdline_fixed_string_t set;
3233 cmdline_fixed_string_t vlan_type;
3234 cmdline_fixed_string_t what;
3235 cmdline_fixed_string_t on;
3236 cmdline_fixed_string_t port_id;
3240 cmd_vlan_offload_parsed(void *parsed_result,
3241 __attribute__((unused)) struct cmdline *cl,
3242 __attribute__((unused)) void *data)
3245 struct cmd_vlan_offload_result *res = parsed_result;
3248 portid_t port_id = 0;
3252 len = strnlen(str, STR_TOKEN_SIZE);
3254 /* Get port_id first */
3262 tmp = strtoul(str, NULL, 0);
3263 /* If port_id greater that what portid_t can represent, return */
3264 if(tmp >= RTE_MAX_ETHPORTS)
3266 port_id = (portid_t)tmp;
3268 if (!strcmp(res->on, "on"))
3273 if (!strcmp(res->what, "strip"))
3274 rx_vlan_strip_set(port_id, on);
3275 else if(!strcmp(res->what, "stripq")){
3276 uint16_t queue_id = 0;
3278 /* No queue_id, return */
3280 printf("must specify (port,queue_id)\n");
3283 tmp = strtoul(str + i + 1, NULL, 0);
3284 /* If queue_id greater that what 16-bits can represent, return */
3288 queue_id = (uint16_t)tmp;
3289 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
3291 else if (!strcmp(res->what, "filter"))
3292 rx_vlan_filter_set(port_id, on);
3294 vlan_extend_set(port_id, on);
3299 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
3300 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3302 cmdline_parse_token_string_t cmd_vlan_offload_set =
3303 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3305 cmdline_parse_token_string_t cmd_vlan_offload_what =
3306 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3307 what, "strip#filter#qinq#stripq");
3308 cmdline_parse_token_string_t cmd_vlan_offload_on =
3309 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3311 cmdline_parse_token_string_t cmd_vlan_offload_portid =
3312 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3315 cmdline_parse_inst_t cmd_vlan_offload = {
3316 .f = cmd_vlan_offload_parsed,
3318 .help_str = "vlan set strip|filter|qinq|stripq on|off "
3319 "<port_id[,queue_id]>: "
3320 "Filter/Strip for rx side qinq(extended) for both rx/tx sides",
3322 (void *)&cmd_vlan_offload_vlan,
3323 (void *)&cmd_vlan_offload_set,
3324 (void *)&cmd_vlan_offload_what,
3325 (void *)&cmd_vlan_offload_on,
3326 (void *)&cmd_vlan_offload_portid,
3331 /* *** VLAN TPID SET ON A PORT *** */
3332 struct cmd_vlan_tpid_result {
3333 cmdline_fixed_string_t vlan;
3334 cmdline_fixed_string_t set;
3335 cmdline_fixed_string_t vlan_type;
3336 cmdline_fixed_string_t what;
3342 cmd_vlan_tpid_parsed(void *parsed_result,
3343 __attribute__((unused)) struct cmdline *cl,
3344 __attribute__((unused)) void *data)
3346 struct cmd_vlan_tpid_result *res = parsed_result;
3347 enum rte_vlan_type vlan_type;
3349 if (!strcmp(res->vlan_type, "inner"))
3350 vlan_type = ETH_VLAN_TYPE_INNER;
3351 else if (!strcmp(res->vlan_type, "outer"))
3352 vlan_type = ETH_VLAN_TYPE_OUTER;
3354 printf("Unknown vlan type\n");
3357 vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
3360 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
3361 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3363 cmdline_parse_token_string_t cmd_vlan_tpid_set =
3364 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3366 cmdline_parse_token_string_t cmd_vlan_type =
3367 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3368 vlan_type, "inner#outer");
3369 cmdline_parse_token_string_t cmd_vlan_tpid_what =
3370 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3372 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
3373 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3375 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
3376 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3379 cmdline_parse_inst_t cmd_vlan_tpid = {
3380 .f = cmd_vlan_tpid_parsed,
3382 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
3383 "Set the VLAN Ether type",
3385 (void *)&cmd_vlan_tpid_vlan,
3386 (void *)&cmd_vlan_tpid_set,
3387 (void *)&cmd_vlan_type,
3388 (void *)&cmd_vlan_tpid_what,
3389 (void *)&cmd_vlan_tpid_tpid,
3390 (void *)&cmd_vlan_tpid_portid,
3395 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
3396 struct cmd_rx_vlan_filter_result {
3397 cmdline_fixed_string_t rx_vlan;
3398 cmdline_fixed_string_t what;
3404 cmd_rx_vlan_filter_parsed(void *parsed_result,
3405 __attribute__((unused)) struct cmdline *cl,
3406 __attribute__((unused)) void *data)
3408 struct cmd_rx_vlan_filter_result *res = parsed_result;
3410 if (!strcmp(res->what, "add"))
3411 rx_vft_set(res->port_id, res->vlan_id, 1);
3413 rx_vft_set(res->port_id, res->vlan_id, 0);
3416 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
3417 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3418 rx_vlan, "rx_vlan");
3419 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
3420 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3422 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
3423 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3425 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
3426 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3429 cmdline_parse_inst_t cmd_rx_vlan_filter = {
3430 .f = cmd_rx_vlan_filter_parsed,
3432 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
3433 "Add/Remove a VLAN identifier to/from the set of VLAN "
3434 "identifiers filtered by a port",
3436 (void *)&cmd_rx_vlan_filter_rx_vlan,
3437 (void *)&cmd_rx_vlan_filter_what,
3438 (void *)&cmd_rx_vlan_filter_vlanid,
3439 (void *)&cmd_rx_vlan_filter_portid,
3444 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3445 struct cmd_tx_vlan_set_result {
3446 cmdline_fixed_string_t tx_vlan;
3447 cmdline_fixed_string_t set;
3453 cmd_tx_vlan_set_parsed(void *parsed_result,
3454 __attribute__((unused)) struct cmdline *cl,
3455 __attribute__((unused)) void *data)
3457 struct cmd_tx_vlan_set_result *res = parsed_result;
3459 if (!port_is_stopped(res->port_id)) {
3460 printf("Please stop port %d first\n", res->port_id);
3464 tx_vlan_set(res->port_id, res->vlan_id);
3466 cmd_reconfig_device_queue(res->port_id, 1, 1);
3469 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
3470 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3471 tx_vlan, "tx_vlan");
3472 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
3473 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3475 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
3476 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3478 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
3479 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3482 cmdline_parse_inst_t cmd_tx_vlan_set = {
3483 .f = cmd_tx_vlan_set_parsed,
3485 .help_str = "tx_vlan set <port_id> <vlan_id>: "
3486 "Enable hardware insertion of a single VLAN header "
3487 "with a given TAG Identifier in packets sent on a port",
3489 (void *)&cmd_tx_vlan_set_tx_vlan,
3490 (void *)&cmd_tx_vlan_set_set,
3491 (void *)&cmd_tx_vlan_set_portid,
3492 (void *)&cmd_tx_vlan_set_vlanid,
3497 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
3498 struct cmd_tx_vlan_set_qinq_result {
3499 cmdline_fixed_string_t tx_vlan;
3500 cmdline_fixed_string_t set;
3503 uint16_t vlan_id_outer;
3507 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
3508 __attribute__((unused)) struct cmdline *cl,
3509 __attribute__((unused)) void *data)
3511 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
3513 if (!port_is_stopped(res->port_id)) {
3514 printf("Please stop port %d first\n", res->port_id);
3518 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
3520 cmd_reconfig_device_queue(res->port_id, 1, 1);
3523 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
3524 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3525 tx_vlan, "tx_vlan");
3526 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
3527 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3529 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
3530 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3532 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
3533 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3535 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
3536 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3537 vlan_id_outer, UINT16);
3539 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
3540 .f = cmd_tx_vlan_set_qinq_parsed,
3542 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
3543 "Enable hardware insertion of double VLAN header "
3544 "with given TAG Identifiers in packets sent on a port",
3546 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
3547 (void *)&cmd_tx_vlan_set_qinq_set,
3548 (void *)&cmd_tx_vlan_set_qinq_portid,
3549 (void *)&cmd_tx_vlan_set_qinq_vlanid,
3550 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
3555 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
3556 struct cmd_tx_vlan_set_pvid_result {
3557 cmdline_fixed_string_t tx_vlan;
3558 cmdline_fixed_string_t set;
3559 cmdline_fixed_string_t pvid;
3562 cmdline_fixed_string_t mode;
3566 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
3567 __attribute__((unused)) struct cmdline *cl,
3568 __attribute__((unused)) void *data)
3570 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
3572 if (strcmp(res->mode, "on") == 0)
3573 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
3575 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
3578 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
3579 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3580 tx_vlan, "tx_vlan");
3581 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
3582 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3584 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
3585 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3587 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
3588 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3590 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
3591 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3593 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
3594 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3597 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
3598 .f = cmd_tx_vlan_set_pvid_parsed,
3600 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
3602 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
3603 (void *)&cmd_tx_vlan_set_pvid_set,
3604 (void *)&cmd_tx_vlan_set_pvid_pvid,
3605 (void *)&cmd_tx_vlan_set_pvid_port_id,
3606 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
3607 (void *)&cmd_tx_vlan_set_pvid_mode,
3612 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3613 struct cmd_tx_vlan_reset_result {
3614 cmdline_fixed_string_t tx_vlan;
3615 cmdline_fixed_string_t reset;
3620 cmd_tx_vlan_reset_parsed(void *parsed_result,
3621 __attribute__((unused)) struct cmdline *cl,
3622 __attribute__((unused)) void *data)
3624 struct cmd_tx_vlan_reset_result *res = parsed_result;
3626 if (!port_is_stopped(res->port_id)) {
3627 printf("Please stop port %d first\n", res->port_id);
3631 tx_vlan_reset(res->port_id);
3633 cmd_reconfig_device_queue(res->port_id, 1, 1);
3636 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
3637 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
3638 tx_vlan, "tx_vlan");
3639 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
3640 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
3642 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
3643 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
3646 cmdline_parse_inst_t cmd_tx_vlan_reset = {
3647 .f = cmd_tx_vlan_reset_parsed,
3649 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
3650 "VLAN header in packets sent on a port",
3652 (void *)&cmd_tx_vlan_reset_tx_vlan,
3653 (void *)&cmd_tx_vlan_reset_reset,
3654 (void *)&cmd_tx_vlan_reset_portid,
3660 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
3661 struct cmd_csum_result {
3662 cmdline_fixed_string_t csum;
3663 cmdline_fixed_string_t mode;
3664 cmdline_fixed_string_t proto;
3665 cmdline_fixed_string_t hwsw;
3670 csum_show(int port_id)
3672 struct rte_eth_dev_info dev_info;
3675 ol_flags = ports[port_id].tx_ol_flags;
3676 printf("Parse tunnel is %s\n",
3677 (ol_flags & TESTPMD_TX_OFFLOAD_PARSE_TUNNEL) ? "on" : "off");
3678 printf("IP checksum offload is %s\n",
3679 (ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) ? "hw" : "sw");
3680 printf("UDP checksum offload is %s\n",
3681 (ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
3682 printf("TCP checksum offload is %s\n",
3683 (ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
3684 printf("SCTP checksum offload is %s\n",
3685 (ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
3686 printf("Outer-Ip checksum offload is %s\n",
3687 (ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) ? "hw" : "sw");
3689 /* display warnings if configuration is not supported by the NIC */
3690 rte_eth_dev_info_get(port_id, &dev_info);
3691 if ((ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) &&
3692 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
3693 printf("Warning: hardware IP checksum enabled but not "
3694 "supported by port %d\n", port_id);
3696 if ((ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) &&
3697 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
3698 printf("Warning: hardware UDP checksum enabled but not "
3699 "supported by port %d\n", port_id);
3701 if ((ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) &&
3702 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
3703 printf("Warning: hardware TCP checksum enabled but not "
3704 "supported by port %d\n", port_id);
3706 if ((ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) &&
3707 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
3708 printf("Warning: hardware SCTP checksum enabled but not "
3709 "supported by port %d\n", port_id);
3711 if ((ol_flags & TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM) &&
3712 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
3713 printf("Warning: hardware outer IP checksum enabled but not "
3714 "supported by port %d\n", port_id);
3719 cmd_csum_parsed(void *parsed_result,
3720 __attribute__((unused)) struct cmdline *cl,
3721 __attribute__((unused)) void *data)
3723 struct cmd_csum_result *res = parsed_result;
3726 uint64_t csum_offloads = 0;
3728 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
3729 printf("invalid port %d\n", res->port_id);
3732 if (!port_is_stopped(res->port_id)) {
3733 printf("Please stop port %d first\n", res->port_id);
3737 if (!strcmp(res->mode, "set")) {
3739 if (!strcmp(res->hwsw, "hw"))
3742 if (!strcmp(res->proto, "ip")) {
3743 mask = TESTPMD_TX_OFFLOAD_IP_CKSUM;
3744 csum_offloads |= DEV_TX_OFFLOAD_IPV4_CKSUM;
3745 } else if (!strcmp(res->proto, "udp")) {
3746 mask = TESTPMD_TX_OFFLOAD_UDP_CKSUM;
3747 csum_offloads |= DEV_TX_OFFLOAD_UDP_CKSUM;
3748 } else if (!strcmp(res->proto, "tcp")) {
3749 mask = TESTPMD_TX_OFFLOAD_TCP_CKSUM;
3750 csum_offloads |= DEV_TX_OFFLOAD_TCP_CKSUM;
3751 } else if (!strcmp(res->proto, "sctp")) {
3752 mask = TESTPMD_TX_OFFLOAD_SCTP_CKSUM;
3753 csum_offloads |= DEV_TX_OFFLOAD_SCTP_CKSUM;
3754 } else if (!strcmp(res->proto, "outer-ip")) {
3755 mask = TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM;
3756 csum_offloads |= DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM;
3760 ports[res->port_id].tx_ol_flags |= mask;
3761 ports[res->port_id].dev_conf.txmode.offloads |=
3764 ports[res->port_id].tx_ol_flags &= (~mask);
3765 ports[res->port_id].dev_conf.txmode.offloads &=
3769 csum_show(res->port_id);
3771 cmd_reconfig_device_queue(res->port_id, 1, 1);
3774 cmdline_parse_token_string_t cmd_csum_csum =
3775 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3777 cmdline_parse_token_string_t cmd_csum_mode =
3778 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3780 cmdline_parse_token_string_t cmd_csum_proto =
3781 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3782 proto, "ip#tcp#udp#sctp#outer-ip");
3783 cmdline_parse_token_string_t cmd_csum_hwsw =
3784 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3786 cmdline_parse_token_num_t cmd_csum_portid =
3787 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
3790 cmdline_parse_inst_t cmd_csum_set = {
3791 .f = cmd_csum_parsed,
3793 .help_str = "csum set ip|tcp|udp|sctp|outer-ip hw|sw <port_id>: "
3794 "Enable/Disable hardware calculation of L3/L4 checksum when "
3795 "using csum forward engine",
3797 (void *)&cmd_csum_csum,
3798 (void *)&cmd_csum_mode,
3799 (void *)&cmd_csum_proto,
3800 (void *)&cmd_csum_hwsw,
3801 (void *)&cmd_csum_portid,
3806 cmdline_parse_token_string_t cmd_csum_mode_show =
3807 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3810 cmdline_parse_inst_t cmd_csum_show = {
3811 .f = cmd_csum_parsed,
3813 .help_str = "csum show <port_id>: Show checksum offload configuration",
3815 (void *)&cmd_csum_csum,
3816 (void *)&cmd_csum_mode_show,
3817 (void *)&cmd_csum_portid,
3822 /* Enable/disable tunnel parsing */
3823 struct cmd_csum_tunnel_result {
3824 cmdline_fixed_string_t csum;
3825 cmdline_fixed_string_t parse;
3826 cmdline_fixed_string_t onoff;
3831 cmd_csum_tunnel_parsed(void *parsed_result,
3832 __attribute__((unused)) struct cmdline *cl,
3833 __attribute__((unused)) void *data)
3835 struct cmd_csum_tunnel_result *res = parsed_result;
3837 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3840 if (!strcmp(res->onoff, "on"))
3841 ports[res->port_id].tx_ol_flags |=
3842 TESTPMD_TX_OFFLOAD_PARSE_TUNNEL;
3844 ports[res->port_id].tx_ol_flags &=
3845 (~TESTPMD_TX_OFFLOAD_PARSE_TUNNEL);
3847 csum_show(res->port_id);
3850 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
3851 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3853 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
3854 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3855 parse, "parse_tunnel");
3856 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
3857 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3859 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
3860 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
3863 cmdline_parse_inst_t cmd_csum_tunnel = {
3864 .f = cmd_csum_tunnel_parsed,
3866 .help_str = "csum parse_tunnel on|off <port_id>: "
3867 "Enable/Disable parsing of tunnels for csum engine",
3869 (void *)&cmd_csum_tunnel_csum,
3870 (void *)&cmd_csum_tunnel_parse,
3871 (void *)&cmd_csum_tunnel_onoff,
3872 (void *)&cmd_csum_tunnel_portid,
3877 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
3878 struct cmd_tso_set_result {
3879 cmdline_fixed_string_t tso;
3880 cmdline_fixed_string_t mode;
3886 cmd_tso_set_parsed(void *parsed_result,
3887 __attribute__((unused)) struct cmdline *cl,
3888 __attribute__((unused)) void *data)
3890 struct cmd_tso_set_result *res = parsed_result;
3891 struct rte_eth_dev_info dev_info;
3893 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3895 if (!port_is_stopped(res->port_id)) {
3896 printf("Please stop port %d first\n", res->port_id);
3900 if (!strcmp(res->mode, "set"))
3901 ports[res->port_id].tso_segsz = res->tso_segsz;
3903 if (ports[res->port_id].tso_segsz == 0) {
3904 ports[res->port_id].dev_conf.txmode.offloads &=
3905 ~DEV_TX_OFFLOAD_TCP_TSO;
3906 printf("TSO for non-tunneled packets is disabled\n");
3908 ports[res->port_id].dev_conf.txmode.offloads |=
3909 DEV_TX_OFFLOAD_TCP_TSO;
3910 printf("TSO segment size for non-tunneled packets is %d\n",
3911 ports[res->port_id].tso_segsz);
3914 /* display warnings if configuration is not supported by the NIC */
3915 rte_eth_dev_info_get(res->port_id, &dev_info);
3916 if ((ports[res->port_id].tso_segsz != 0) &&
3917 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
3918 printf("Warning: TSO enabled but not "
3919 "supported by port %d\n", res->port_id);
3922 cmd_reconfig_device_queue(res->port_id, 1, 1);
3925 cmdline_parse_token_string_t cmd_tso_set_tso =
3926 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3928 cmdline_parse_token_string_t cmd_tso_set_mode =
3929 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3931 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
3932 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3934 cmdline_parse_token_num_t cmd_tso_set_portid =
3935 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3938 cmdline_parse_inst_t cmd_tso_set = {
3939 .f = cmd_tso_set_parsed,
3941 .help_str = "tso set <tso_segsz> <port_id>: "
3942 "Set TSO segment size of non-tunneled packets for csum engine "
3945 (void *)&cmd_tso_set_tso,
3946 (void *)&cmd_tso_set_mode,
3947 (void *)&cmd_tso_set_tso_segsz,
3948 (void *)&cmd_tso_set_portid,
3953 cmdline_parse_token_string_t cmd_tso_show_mode =
3954 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3958 cmdline_parse_inst_t cmd_tso_show = {
3959 .f = cmd_tso_set_parsed,
3961 .help_str = "tso show <port_id>: "
3962 "Show TSO segment size of non-tunneled packets for csum engine",
3964 (void *)&cmd_tso_set_tso,
3965 (void *)&cmd_tso_show_mode,
3966 (void *)&cmd_tso_set_portid,
3971 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
3972 struct cmd_tunnel_tso_set_result {
3973 cmdline_fixed_string_t tso;
3974 cmdline_fixed_string_t mode;
3980 check_tunnel_tso_nic_support(portid_t port_id)
3982 struct rte_eth_dev_info dev_info;
3984 rte_eth_dev_info_get(port_id, &dev_info);
3985 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO))
3986 printf("Warning: TSO enabled but VXLAN TUNNEL TSO not "
3987 "supported by port %d\n", port_id);
3988 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO))
3989 printf("Warning: TSO enabled but GRE TUNNEL TSO not "
3990 "supported by port %d\n", port_id);
3991 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO))
3992 printf("Warning: TSO enabled but IPIP TUNNEL TSO not "
3993 "supported by port %d\n", port_id);
3994 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
3995 printf("Warning: TSO enabled but GENEVE TUNNEL TSO not "
3996 "supported by port %d\n", port_id);
4000 cmd_tunnel_tso_set_parsed(void *parsed_result,
4001 __attribute__((unused)) struct cmdline *cl,
4002 __attribute__((unused)) void *data)
4004 struct cmd_tunnel_tso_set_result *res = parsed_result;
4006 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4008 if (!port_is_stopped(res->port_id)) {
4009 printf("Please stop port %d first\n", res->port_id);
4013 if (!strcmp(res->mode, "set"))
4014 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
4016 if (ports[res->port_id].tunnel_tso_segsz == 0) {
4017 ports[res->port_id].dev_conf.txmode.offloads &=
4018 ~(DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4019 DEV_TX_OFFLOAD_GRE_TNL_TSO |
4020 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4021 DEV_TX_OFFLOAD_GENEVE_TNL_TSO);
4022 printf("TSO for tunneled packets is disabled\n");
4024 ports[res->port_id].dev_conf.txmode.offloads |=
4025 (DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4026 DEV_TX_OFFLOAD_GRE_TNL_TSO |
4027 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4028 DEV_TX_OFFLOAD_GENEVE_TNL_TSO);
4029 printf("TSO segment size for tunneled packets is %d\n",
4030 ports[res->port_id].tunnel_tso_segsz);
4032 /* Below conditions are needed to make it work:
4033 * (1) tunnel TSO is supported by the NIC;
4034 * (2) "csum parse_tunnel" must be set so that tunneled pkts
4036 * (3) for tunneled pkts with outer L3 of IPv4,
4037 * "csum set outer-ip" must be set to hw, because after tso,
4038 * total_len of outer IP header is changed, and the checksum
4039 * of outer IP header calculated by sw should be wrong; that
4040 * is not necessary for IPv6 tunneled pkts because there's no
4041 * checksum in IP header anymore.
4043 check_tunnel_tso_nic_support(res->port_id);
4045 if (!(ports[res->port_id].tx_ol_flags &
4046 TESTPMD_TX_OFFLOAD_PARSE_TUNNEL))
4047 printf("Warning: csum parse_tunnel must be set "
4048 "so that tunneled packets are recognized\n");
4049 if (!(ports[res->port_id].tx_ol_flags &
4050 TESTPMD_TX_OFFLOAD_OUTER_IP_CKSUM))
4051 printf("Warning: csum set outer-ip must be set to hw "
4052 "if outer L3 is IPv4; not necessary for IPv6\n");
4055 cmd_reconfig_device_queue(res->port_id, 1, 1);
4058 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
4059 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4061 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
4062 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4064 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
4065 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4067 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
4068 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4071 cmdline_parse_inst_t cmd_tunnel_tso_set = {
4072 .f = cmd_tunnel_tso_set_parsed,
4074 .help_str = "tunnel_tso set <tso_segsz> <port_id>: "
4075 "Set TSO segment size of tunneled packets for csum engine "
4078 (void *)&cmd_tunnel_tso_set_tso,
4079 (void *)&cmd_tunnel_tso_set_mode,
4080 (void *)&cmd_tunnel_tso_set_tso_segsz,
4081 (void *)&cmd_tunnel_tso_set_portid,
4086 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
4087 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4091 cmdline_parse_inst_t cmd_tunnel_tso_show = {
4092 .f = cmd_tunnel_tso_set_parsed,
4094 .help_str = "tunnel_tso show <port_id> "
4095 "Show TSO segment size of tunneled packets for csum engine",
4097 (void *)&cmd_tunnel_tso_set_tso,
4098 (void *)&cmd_tunnel_tso_show_mode,
4099 (void *)&cmd_tunnel_tso_set_portid,
4104 /* *** SET GRO FOR A PORT *** */
4105 struct cmd_gro_enable_result {
4106 cmdline_fixed_string_t cmd_set;
4107 cmdline_fixed_string_t cmd_port;
4108 cmdline_fixed_string_t cmd_keyword;
4109 cmdline_fixed_string_t cmd_onoff;
4114 cmd_gro_enable_parsed(void *parsed_result,
4115 __attribute__((unused)) struct cmdline *cl,
4116 __attribute__((unused)) void *data)
4118 struct cmd_gro_enable_result *res;
4120 res = parsed_result;
4121 if (!strcmp(res->cmd_keyword, "gro"))
4122 setup_gro(res->cmd_onoff, res->cmd_pid);
4125 cmdline_parse_token_string_t cmd_gro_enable_set =
4126 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4128 cmdline_parse_token_string_t cmd_gro_enable_port =
4129 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4130 cmd_keyword, "port");
4131 cmdline_parse_token_num_t cmd_gro_enable_pid =
4132 TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result,
4134 cmdline_parse_token_string_t cmd_gro_enable_keyword =
4135 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4136 cmd_keyword, "gro");
4137 cmdline_parse_token_string_t cmd_gro_enable_onoff =
4138 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4139 cmd_onoff, "on#off");
4141 cmdline_parse_inst_t cmd_gro_enable = {
4142 .f = cmd_gro_enable_parsed,
4144 .help_str = "set port <port_id> gro on|off",
4146 (void *)&cmd_gro_enable_set,
4147 (void *)&cmd_gro_enable_port,
4148 (void *)&cmd_gro_enable_pid,
4149 (void *)&cmd_gro_enable_keyword,
4150 (void *)&cmd_gro_enable_onoff,
4155 /* *** DISPLAY GRO CONFIGURATION *** */
4156 struct cmd_gro_show_result {
4157 cmdline_fixed_string_t cmd_show;
4158 cmdline_fixed_string_t cmd_port;
4159 cmdline_fixed_string_t cmd_keyword;
4164 cmd_gro_show_parsed(void *parsed_result,
4165 __attribute__((unused)) struct cmdline *cl,
4166 __attribute__((unused)) void *data)
4168 struct cmd_gro_show_result *res;
4170 res = parsed_result;
4171 if (!strcmp(res->cmd_keyword, "gro"))
4172 show_gro(res->cmd_pid);
4175 cmdline_parse_token_string_t cmd_gro_show_show =
4176 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4178 cmdline_parse_token_string_t cmd_gro_show_port =
4179 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4181 cmdline_parse_token_num_t cmd_gro_show_pid =
4182 TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result,
4184 cmdline_parse_token_string_t cmd_gro_show_keyword =
4185 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4186 cmd_keyword, "gro");
4188 cmdline_parse_inst_t cmd_gro_show = {
4189 .f = cmd_gro_show_parsed,
4191 .help_str = "show port <port_id> gro",
4193 (void *)&cmd_gro_show_show,
4194 (void *)&cmd_gro_show_port,
4195 (void *)&cmd_gro_show_pid,
4196 (void *)&cmd_gro_show_keyword,
4201 /* *** SET FLUSH CYCLES FOR GRO *** */
4202 struct cmd_gro_flush_result {
4203 cmdline_fixed_string_t cmd_set;
4204 cmdline_fixed_string_t cmd_keyword;
4205 cmdline_fixed_string_t cmd_flush;
4210 cmd_gro_flush_parsed(void *parsed_result,
4211 __attribute__((unused)) struct cmdline *cl,
4212 __attribute__((unused)) void *data)
4214 struct cmd_gro_flush_result *res;
4216 res = parsed_result;
4217 if ((!strcmp(res->cmd_keyword, "gro")) &&
4218 (!strcmp(res->cmd_flush, "flush")))
4219 setup_gro_flush_cycles(res->cmd_cycles);
4222 cmdline_parse_token_string_t cmd_gro_flush_set =
4223 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4225 cmdline_parse_token_string_t cmd_gro_flush_keyword =
4226 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4227 cmd_keyword, "gro");
4228 cmdline_parse_token_string_t cmd_gro_flush_flush =
4229 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4230 cmd_flush, "flush");
4231 cmdline_parse_token_num_t cmd_gro_flush_cycles =
4232 TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result,
4235 cmdline_parse_inst_t cmd_gro_flush = {
4236 .f = cmd_gro_flush_parsed,
4238 .help_str = "set gro flush <cycles>",
4240 (void *)&cmd_gro_flush_set,
4241 (void *)&cmd_gro_flush_keyword,
4242 (void *)&cmd_gro_flush_flush,
4243 (void *)&cmd_gro_flush_cycles,
4248 /* *** ENABLE/DISABLE GSO *** */
4249 struct cmd_gso_enable_result {
4250 cmdline_fixed_string_t cmd_set;
4251 cmdline_fixed_string_t cmd_port;
4252 cmdline_fixed_string_t cmd_keyword;
4253 cmdline_fixed_string_t cmd_mode;
4258 cmd_gso_enable_parsed(void *parsed_result,
4259 __attribute__((unused)) struct cmdline *cl,
4260 __attribute__((unused)) void *data)
4262 struct cmd_gso_enable_result *res;
4264 res = parsed_result;
4265 if (!strcmp(res->cmd_keyword, "gso"))
4266 setup_gso(res->cmd_mode, res->cmd_pid);
4269 cmdline_parse_token_string_t cmd_gso_enable_set =
4270 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4272 cmdline_parse_token_string_t cmd_gso_enable_port =
4273 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4275 cmdline_parse_token_string_t cmd_gso_enable_keyword =
4276 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4277 cmd_keyword, "gso");
4278 cmdline_parse_token_string_t cmd_gso_enable_mode =
4279 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4280 cmd_mode, "on#off");
4281 cmdline_parse_token_num_t cmd_gso_enable_pid =
4282 TOKEN_NUM_INITIALIZER(struct cmd_gso_enable_result,
4285 cmdline_parse_inst_t cmd_gso_enable = {
4286 .f = cmd_gso_enable_parsed,
4288 .help_str = "set port <port_id> gso on|off",
4290 (void *)&cmd_gso_enable_set,
4291 (void *)&cmd_gso_enable_port,
4292 (void *)&cmd_gso_enable_pid,
4293 (void *)&cmd_gso_enable_keyword,
4294 (void *)&cmd_gso_enable_mode,
4299 /* *** SET MAX PACKET LENGTH FOR GSO SEGMENTS *** */
4300 struct cmd_gso_size_result {
4301 cmdline_fixed_string_t cmd_set;
4302 cmdline_fixed_string_t cmd_keyword;
4303 cmdline_fixed_string_t cmd_segsz;
4308 cmd_gso_size_parsed(void *parsed_result,
4309 __attribute__((unused)) struct cmdline *cl,
4310 __attribute__((unused)) void *data)
4312 struct cmd_gso_size_result *res = parsed_result;
4314 if (test_done == 0) {
4315 printf("Before setting GSO segsz, please first"
4316 " stop fowarding\n");
4320 if (!strcmp(res->cmd_keyword, "gso") &&
4321 !strcmp(res->cmd_segsz, "segsz")) {
4322 if (res->cmd_size < RTE_GSO_SEG_SIZE_MIN)
4323 printf("gso_size should be larger than %zu."
4324 " Please input a legal value\n",
4325 RTE_GSO_SEG_SIZE_MIN);
4327 gso_max_segment_size = res->cmd_size;
4331 cmdline_parse_token_string_t cmd_gso_size_set =
4332 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
4334 cmdline_parse_token_string_t cmd_gso_size_keyword =
4335 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
4336 cmd_keyword, "gso");
4337 cmdline_parse_token_string_t cmd_gso_size_segsz =
4338 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
4339 cmd_segsz, "segsz");
4340 cmdline_parse_token_num_t cmd_gso_size_size =
4341 TOKEN_NUM_INITIALIZER(struct cmd_gso_size_result,
4344 cmdline_parse_inst_t cmd_gso_size = {
4345 .f = cmd_gso_size_parsed,
4347 .help_str = "set gso segsz <length>",
4349 (void *)&cmd_gso_size_set,
4350 (void *)&cmd_gso_size_keyword,
4351 (void *)&cmd_gso_size_segsz,
4352 (void *)&cmd_gso_size_size,
4357 /* *** SHOW GSO CONFIGURATION *** */
4358 struct cmd_gso_show_result {
4359 cmdline_fixed_string_t cmd_show;
4360 cmdline_fixed_string_t cmd_port;
4361 cmdline_fixed_string_t cmd_keyword;
4366 cmd_gso_show_parsed(void *parsed_result,
4367 __attribute__((unused)) struct cmdline *cl,
4368 __attribute__((unused)) void *data)
4370 struct cmd_gso_show_result *res = parsed_result;
4372 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
4373 printf("invalid port id %u\n", res->cmd_pid);
4376 if (!strcmp(res->cmd_keyword, "gso")) {
4377 if (gso_ports[res->cmd_pid].enable) {
4378 printf("Max GSO'd packet size: %uB\n"
4379 "Supported GSO types: TCP/IPv4, "
4380 "VxLAN with inner TCP/IPv4 packet, "
4381 "GRE with inner TCP/IPv4 packet\n",
4382 gso_max_segment_size);
4384 printf("GSO is not enabled on Port %u\n", res->cmd_pid);
4388 cmdline_parse_token_string_t cmd_gso_show_show =
4389 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
4391 cmdline_parse_token_string_t cmd_gso_show_port =
4392 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
4394 cmdline_parse_token_string_t cmd_gso_show_keyword =
4395 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
4396 cmd_keyword, "gso");
4397 cmdline_parse_token_num_t cmd_gso_show_pid =
4398 TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result,
4401 cmdline_parse_inst_t cmd_gso_show = {
4402 .f = cmd_gso_show_parsed,
4404 .help_str = "show port <port_id> gso",
4406 (void *)&cmd_gso_show_show,
4407 (void *)&cmd_gso_show_port,
4408 (void *)&cmd_gso_show_pid,
4409 (void *)&cmd_gso_show_keyword,
4414 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
4415 struct cmd_set_flush_rx {
4416 cmdline_fixed_string_t set;
4417 cmdline_fixed_string_t flush_rx;
4418 cmdline_fixed_string_t mode;
4422 cmd_set_flush_rx_parsed(void *parsed_result,
4423 __attribute__((unused)) struct cmdline *cl,
4424 __attribute__((unused)) void *data)
4426 struct cmd_set_flush_rx *res = parsed_result;
4427 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
4430 cmdline_parse_token_string_t cmd_setflushrx_set =
4431 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
4433 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
4434 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
4435 flush_rx, "flush_rx");
4436 cmdline_parse_token_string_t cmd_setflushrx_mode =
4437 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
4441 cmdline_parse_inst_t cmd_set_flush_rx = {
4442 .f = cmd_set_flush_rx_parsed,
4443 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
4446 (void *)&cmd_setflushrx_set,
4447 (void *)&cmd_setflushrx_flush_rx,
4448 (void *)&cmd_setflushrx_mode,
4453 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
4454 struct cmd_set_link_check {
4455 cmdline_fixed_string_t set;
4456 cmdline_fixed_string_t link_check;
4457 cmdline_fixed_string_t mode;
4461 cmd_set_link_check_parsed(void *parsed_result,
4462 __attribute__((unused)) struct cmdline *cl,
4463 __attribute__((unused)) void *data)
4465 struct cmd_set_link_check *res = parsed_result;
4466 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
4469 cmdline_parse_token_string_t cmd_setlinkcheck_set =
4470 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
4472 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
4473 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
4474 link_check, "link_check");
4475 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
4476 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
4480 cmdline_parse_inst_t cmd_set_link_check = {
4481 .f = cmd_set_link_check_parsed,
4482 .help_str = "set link_check on|off: Enable/Disable link status check "
4483 "when starting/stopping a port",
4486 (void *)&cmd_setlinkcheck_set,
4487 (void *)&cmd_setlinkcheck_link_check,
4488 (void *)&cmd_setlinkcheck_mode,
4493 /* *** SET NIC BYPASS MODE *** */
4494 struct cmd_set_bypass_mode_result {
4495 cmdline_fixed_string_t set;
4496 cmdline_fixed_string_t bypass;
4497 cmdline_fixed_string_t mode;
4498 cmdline_fixed_string_t value;
4503 cmd_set_bypass_mode_parsed(void *parsed_result,
4504 __attribute__((unused)) struct cmdline *cl,
4505 __attribute__((unused)) void *data)
4507 struct cmd_set_bypass_mode_result *res = parsed_result;
4508 portid_t port_id = res->port_id;
4509 int32_t rc = -EINVAL;
4511 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4512 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4514 if (!strcmp(res->value, "bypass"))
4515 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
4516 else if (!strcmp(res->value, "isolate"))
4517 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
4519 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4521 /* Set the bypass mode for the relevant port. */
4522 rc = rte_pmd_ixgbe_bypass_state_set(port_id, &bypass_mode);
4525 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
4528 cmdline_parse_token_string_t cmd_setbypass_mode_set =
4529 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4531 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
4532 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4534 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
4535 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4537 cmdline_parse_token_string_t cmd_setbypass_mode_value =
4538 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4539 value, "normal#bypass#isolate");
4540 cmdline_parse_token_num_t cmd_setbypass_mode_port =
4541 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
4544 cmdline_parse_inst_t cmd_set_bypass_mode = {
4545 .f = cmd_set_bypass_mode_parsed,
4546 .help_str = "set bypass mode normal|bypass|isolate <port_id>: "
4547 "Set the NIC bypass mode for port_id",
4550 (void *)&cmd_setbypass_mode_set,
4551 (void *)&cmd_setbypass_mode_bypass,
4552 (void *)&cmd_setbypass_mode_mode,
4553 (void *)&cmd_setbypass_mode_value,
4554 (void *)&cmd_setbypass_mode_port,
4559 /* *** SET NIC BYPASS EVENT *** */
4560 struct cmd_set_bypass_event_result {
4561 cmdline_fixed_string_t set;
4562 cmdline_fixed_string_t bypass;
4563 cmdline_fixed_string_t event;
4564 cmdline_fixed_string_t event_value;
4565 cmdline_fixed_string_t mode;
4566 cmdline_fixed_string_t mode_value;
4571 cmd_set_bypass_event_parsed(void *parsed_result,
4572 __attribute__((unused)) struct cmdline *cl,
4573 __attribute__((unused)) void *data)
4575 int32_t rc = -EINVAL;
4576 struct cmd_set_bypass_event_result *res = parsed_result;
4577 portid_t port_id = res->port_id;
4579 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4580 uint32_t bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
4581 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4583 if (!strcmp(res->event_value, "timeout"))
4584 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT;
4585 else if (!strcmp(res->event_value, "os_on"))
4586 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_ON;
4587 else if (!strcmp(res->event_value, "os_off"))
4588 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_OFF;
4589 else if (!strcmp(res->event_value, "power_on"))
4590 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_ON;
4591 else if (!strcmp(res->event_value, "power_off"))
4592 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_OFF;
4594 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
4596 if (!strcmp(res->mode_value, "bypass"))
4597 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
4598 else if (!strcmp(res->mode_value, "isolate"))
4599 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
4601 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4603 /* Set the watchdog timeout. */
4604 if (bypass_event == RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT) {
4607 if (RTE_PMD_IXGBE_BYPASS_TMT_VALID(bypass_timeout)) {
4608 rc = rte_pmd_ixgbe_bypass_wd_timeout_store(port_id,
4612 printf("Failed to set timeout value %u "
4613 "for port %d, errto code: %d.\n",
4614 bypass_timeout, port_id, rc);
4618 /* Set the bypass event to transition to bypass mode. */
4619 rc = rte_pmd_ixgbe_bypass_event_store(port_id, bypass_event,
4624 printf("\t Failed to set bypass event for port = %d.\n",
4628 cmdline_parse_token_string_t cmd_setbypass_event_set =
4629 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4631 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
4632 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4634 cmdline_parse_token_string_t cmd_setbypass_event_event =
4635 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4637 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
4638 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4639 event_value, "none#timeout#os_off#os_on#power_on#power_off");
4640 cmdline_parse_token_string_t cmd_setbypass_event_mode =
4641 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4643 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
4644 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4645 mode_value, "normal#bypass#isolate");
4646 cmdline_parse_token_num_t cmd_setbypass_event_port =
4647 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
4650 cmdline_parse_inst_t cmd_set_bypass_event = {
4651 .f = cmd_set_bypass_event_parsed,
4652 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
4653 "power_off mode normal|bypass|isolate <port_id>: "
4654 "Set the NIC bypass event mode for port_id",
4657 (void *)&cmd_setbypass_event_set,
4658 (void *)&cmd_setbypass_event_bypass,
4659 (void *)&cmd_setbypass_event_event,
4660 (void *)&cmd_setbypass_event_event_value,
4661 (void *)&cmd_setbypass_event_mode,
4662 (void *)&cmd_setbypass_event_mode_value,
4663 (void *)&cmd_setbypass_event_port,
4669 /* *** SET NIC BYPASS TIMEOUT *** */
4670 struct cmd_set_bypass_timeout_result {
4671 cmdline_fixed_string_t set;
4672 cmdline_fixed_string_t bypass;
4673 cmdline_fixed_string_t timeout;
4674 cmdline_fixed_string_t value;
4678 cmd_set_bypass_timeout_parsed(void *parsed_result,
4679 __attribute__((unused)) struct cmdline *cl,
4680 __attribute__((unused)) void *data)
4682 __rte_unused struct cmd_set_bypass_timeout_result *res = parsed_result;
4684 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4685 if (!strcmp(res->value, "1.5"))
4686 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_1_5_SEC;
4687 else if (!strcmp(res->value, "2"))
4688 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_2_SEC;
4689 else if (!strcmp(res->value, "3"))
4690 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_3_SEC;
4691 else if (!strcmp(res->value, "4"))
4692 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_4_SEC;
4693 else if (!strcmp(res->value, "8"))
4694 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_8_SEC;
4695 else if (!strcmp(res->value, "16"))
4696 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_16_SEC;
4697 else if (!strcmp(res->value, "32"))
4698 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_32_SEC;
4700 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
4704 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
4705 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4707 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
4708 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4710 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
4711 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4712 timeout, "timeout");
4713 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
4714 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4715 value, "0#1.5#2#3#4#8#16#32");
4717 cmdline_parse_inst_t cmd_set_bypass_timeout = {
4718 .f = cmd_set_bypass_timeout_parsed,
4719 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
4720 "Set the NIC bypass watchdog timeout in seconds",
4723 (void *)&cmd_setbypass_timeout_set,
4724 (void *)&cmd_setbypass_timeout_bypass,
4725 (void *)&cmd_setbypass_timeout_timeout,
4726 (void *)&cmd_setbypass_timeout_value,
4731 /* *** SHOW NIC BYPASS MODE *** */
4732 struct cmd_show_bypass_config_result {
4733 cmdline_fixed_string_t show;
4734 cmdline_fixed_string_t bypass;
4735 cmdline_fixed_string_t config;
4740 cmd_show_bypass_config_parsed(void *parsed_result,
4741 __attribute__((unused)) struct cmdline *cl,
4742 __attribute__((unused)) void *data)
4744 struct cmd_show_bypass_config_result *res = parsed_result;
4745 portid_t port_id = res->port_id;
4747 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4748 uint32_t event_mode;
4749 uint32_t bypass_mode;
4750 uint32_t timeout = bypass_timeout;
4753 static const char * const timeouts[RTE_PMD_IXGBE_BYPASS_TMT_NUM] =
4754 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
4755 static const char * const modes[RTE_PMD_IXGBE_BYPASS_MODE_NUM] =
4756 {"UNKNOWN", "normal", "bypass", "isolate"};
4757 static const char * const events[RTE_PMD_IXGBE_BYPASS_EVENT_NUM] = {
4764 int num_events = (sizeof events) / (sizeof events[0]);
4766 /* Display the bypass mode.*/
4767 if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) != 0) {
4768 printf("\tFailed to get bypass mode for port = %d\n", port_id);
4772 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(bypass_mode))
4773 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
4775 printf("\tbypass mode = %s\n", modes[bypass_mode]);
4778 /* Display the bypass timeout.*/
4779 if (!RTE_PMD_IXGBE_BYPASS_TMT_VALID(timeout))
4780 timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
4782 printf("\tbypass timeout = %s\n", timeouts[timeout]);
4784 /* Display the bypass events and associated modes. */
4785 for (i = RTE_PMD_IXGBE_BYPASS_EVENT_START; i < num_events; i++) {
4787 if (rte_pmd_ixgbe_bypass_event_show(port_id, i, &event_mode)) {
4788 printf("\tFailed to get bypass mode for event = %s\n",
4791 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(event_mode))
4792 event_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
4794 printf("\tbypass event: %-16s = %s\n", events[i],
4800 printf("\tFailed to get bypass configuration for port = %d\n",
4804 cmdline_parse_token_string_t cmd_showbypass_config_show =
4805 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4807 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
4808 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4810 cmdline_parse_token_string_t cmd_showbypass_config_config =
4811 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4813 cmdline_parse_token_num_t cmd_showbypass_config_port =
4814 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
4817 cmdline_parse_inst_t cmd_show_bypass_config = {
4818 .f = cmd_show_bypass_config_parsed,
4819 .help_str = "show bypass config <port_id>: "
4820 "Show the NIC bypass config for port_id",
4823 (void *)&cmd_showbypass_config_show,
4824 (void *)&cmd_showbypass_config_bypass,
4825 (void *)&cmd_showbypass_config_config,
4826 (void *)&cmd_showbypass_config_port,
4831 #ifdef RTE_LIBRTE_PMD_BOND
4832 /* *** SET BONDING MODE *** */
4833 struct cmd_set_bonding_mode_result {
4834 cmdline_fixed_string_t set;
4835 cmdline_fixed_string_t bonding;
4836 cmdline_fixed_string_t mode;
4841 static void cmd_set_bonding_mode_parsed(void *parsed_result,
4842 __attribute__((unused)) struct cmdline *cl,
4843 __attribute__((unused)) void *data)
4845 struct cmd_set_bonding_mode_result *res = parsed_result;
4846 portid_t port_id = res->port_id;
4848 /* Set the bonding mode for the relevant port. */
4849 if (0 != rte_eth_bond_mode_set(port_id, res->value))
4850 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
4853 cmdline_parse_token_string_t cmd_setbonding_mode_set =
4854 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4856 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
4857 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4858 bonding, "bonding");
4859 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
4860 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4862 cmdline_parse_token_num_t cmd_setbonding_mode_value =
4863 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
4865 cmdline_parse_token_num_t cmd_setbonding_mode_port =
4866 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
4869 cmdline_parse_inst_t cmd_set_bonding_mode = {
4870 .f = cmd_set_bonding_mode_parsed,
4871 .help_str = "set bonding mode <mode_value> <port_id>: "
4872 "Set the bonding mode for port_id",
4875 (void *) &cmd_setbonding_mode_set,
4876 (void *) &cmd_setbonding_mode_bonding,
4877 (void *) &cmd_setbonding_mode_mode,
4878 (void *) &cmd_setbonding_mode_value,
4879 (void *) &cmd_setbonding_mode_port,
4884 /* *** SET BONDING SLOW_QUEUE SW/HW *** */
4885 struct cmd_set_bonding_lacp_dedicated_queues_result {
4886 cmdline_fixed_string_t set;
4887 cmdline_fixed_string_t bonding;
4888 cmdline_fixed_string_t lacp;
4889 cmdline_fixed_string_t dedicated_queues;
4891 cmdline_fixed_string_t mode;
4894 static void cmd_set_bonding_lacp_dedicated_queues_parsed(void *parsed_result,
4895 __attribute__((unused)) struct cmdline *cl,
4896 __attribute__((unused)) void *data)
4898 struct cmd_set_bonding_lacp_dedicated_queues_result *res = parsed_result;
4899 portid_t port_id = res->port_id;
4900 struct rte_port *port;
4902 port = &ports[port_id];
4904 /** Check if the port is not started **/
4905 if (port->port_status != RTE_PORT_STOPPED) {
4906 printf("Please stop port %d first\n", port_id);
4910 if (!strcmp(res->mode, "enable")) {
4911 if (rte_eth_bond_8023ad_dedicated_queues_enable(port_id) == 0)
4912 printf("Dedicate queues for LACP control packets"
4915 printf("Enabling dedicate queues for LACP control "
4916 "packets on port %d failed\n", port_id);
4917 } else if (!strcmp(res->mode, "disable")) {
4918 if (rte_eth_bond_8023ad_dedicated_queues_disable(port_id) == 0)
4919 printf("Dedicated queues for LACP control packets "
4922 printf("Disabling dedicated queues for LACP control "
4923 "traffic on port %d failed\n", port_id);
4927 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_set =
4928 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4930 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_bonding =
4931 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4932 bonding, "bonding");
4933 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_lacp =
4934 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4936 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_dedicated_queues =
4937 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4938 dedicated_queues, "dedicated_queues");
4939 cmdline_parse_token_num_t cmd_setbonding_lacp_dedicated_queues_port_id =
4940 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4942 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_mode =
4943 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4944 mode, "enable#disable");
4946 cmdline_parse_inst_t cmd_set_lacp_dedicated_queues = {
4947 .f = cmd_set_bonding_lacp_dedicated_queues_parsed,
4948 .help_str = "set bonding lacp dedicated_queues <port_id> "
4950 "Enable/disable dedicated queues for LACP control traffic for port_id",
4953 (void *)&cmd_setbonding_lacp_dedicated_queues_set,
4954 (void *)&cmd_setbonding_lacp_dedicated_queues_bonding,
4955 (void *)&cmd_setbonding_lacp_dedicated_queues_lacp,
4956 (void *)&cmd_setbonding_lacp_dedicated_queues_dedicated_queues,
4957 (void *)&cmd_setbonding_lacp_dedicated_queues_port_id,
4958 (void *)&cmd_setbonding_lacp_dedicated_queues_mode,
4963 /* *** SET BALANCE XMIT POLICY *** */
4964 struct cmd_set_bonding_balance_xmit_policy_result {
4965 cmdline_fixed_string_t set;
4966 cmdline_fixed_string_t bonding;
4967 cmdline_fixed_string_t balance_xmit_policy;
4969 cmdline_fixed_string_t policy;
4972 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
4973 __attribute__((unused)) struct cmdline *cl,
4974 __attribute__((unused)) void *data)
4976 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
4977 portid_t port_id = res->port_id;
4980 if (!strcmp(res->policy, "l2")) {
4981 policy = BALANCE_XMIT_POLICY_LAYER2;
4982 } else if (!strcmp(res->policy, "l23")) {
4983 policy = BALANCE_XMIT_POLICY_LAYER23;
4984 } else if (!strcmp(res->policy, "l34")) {
4985 policy = BALANCE_XMIT_POLICY_LAYER34;
4987 printf("\t Invalid xmit policy selection");
4991 /* Set the bonding mode for the relevant port. */
4992 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
4993 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
4998 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
4999 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5001 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
5002 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5003 bonding, "bonding");
5004 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
5005 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5006 balance_xmit_policy, "balance_xmit_policy");
5007 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
5008 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5010 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
5011 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5012 policy, "l2#l23#l34");
5014 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
5015 .f = cmd_set_bonding_balance_xmit_policy_parsed,
5016 .help_str = "set bonding balance_xmit_policy <port_id> "
5018 "Set the bonding balance_xmit_policy for port_id",
5021 (void *)&cmd_setbonding_balance_xmit_policy_set,
5022 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
5023 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
5024 (void *)&cmd_setbonding_balance_xmit_policy_port,
5025 (void *)&cmd_setbonding_balance_xmit_policy_policy,
5030 /* *** SHOW NIC BONDING CONFIGURATION *** */
5031 struct cmd_show_bonding_config_result {
5032 cmdline_fixed_string_t show;
5033 cmdline_fixed_string_t bonding;
5034 cmdline_fixed_string_t config;
5038 static void cmd_show_bonding_config_parsed(void *parsed_result,
5039 __attribute__((unused)) struct cmdline *cl,
5040 __attribute__((unused)) void *data)
5042 struct cmd_show_bonding_config_result *res = parsed_result;
5043 int bonding_mode, agg_mode;
5044 portid_t slaves[RTE_MAX_ETHPORTS];
5045 int num_slaves, num_active_slaves;
5048 portid_t port_id = res->port_id;
5050 /* Display the bonding mode.*/
5051 bonding_mode = rte_eth_bond_mode_get(port_id);
5052 if (bonding_mode < 0) {
5053 printf("\tFailed to get bonding mode for port = %d\n", port_id);
5056 printf("\tBonding mode: %d\n", bonding_mode);
5058 if (bonding_mode == BONDING_MODE_BALANCE) {
5059 int balance_xmit_policy;
5061 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
5062 if (balance_xmit_policy < 0) {
5063 printf("\tFailed to get balance xmit policy for port = %d\n",
5067 printf("\tBalance Xmit Policy: ");
5069 switch (balance_xmit_policy) {
5070 case BALANCE_XMIT_POLICY_LAYER2:
5071 printf("BALANCE_XMIT_POLICY_LAYER2");
5073 case BALANCE_XMIT_POLICY_LAYER23:
5074 printf("BALANCE_XMIT_POLICY_LAYER23");
5076 case BALANCE_XMIT_POLICY_LAYER34:
5077 printf("BALANCE_XMIT_POLICY_LAYER34");
5084 if (bonding_mode == BONDING_MODE_8023AD) {
5085 agg_mode = rte_eth_bond_8023ad_agg_selection_get(port_id);
5086 printf("\tIEEE802.3AD Aggregator Mode: ");
5089 printf("bandwidth");
5101 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
5103 if (num_slaves < 0) {
5104 printf("\tFailed to get slave list for port = %d\n", port_id);
5107 if (num_slaves > 0) {
5108 printf("\tSlaves (%d): [", num_slaves);
5109 for (i = 0; i < num_slaves - 1; i++)
5110 printf("%d ", slaves[i]);
5112 printf("%d]\n", slaves[num_slaves - 1]);
5114 printf("\tSlaves: []\n");
5118 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
5121 if (num_active_slaves < 0) {
5122 printf("\tFailed to get active slave list for port = %d\n", port_id);
5125 if (num_active_slaves > 0) {
5126 printf("\tActive Slaves (%d): [", num_active_slaves);
5127 for (i = 0; i < num_active_slaves - 1; i++)
5128 printf("%d ", slaves[i]);
5130 printf("%d]\n", slaves[num_active_slaves - 1]);
5133 printf("\tActive Slaves: []\n");
5137 primary_id = rte_eth_bond_primary_get(port_id);
5138 if (primary_id < 0) {
5139 printf("\tFailed to get primary slave for port = %d\n", port_id);
5142 printf("\tPrimary: [%d]\n", primary_id);
5146 cmdline_parse_token_string_t cmd_showbonding_config_show =
5147 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5149 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
5150 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5151 bonding, "bonding");
5152 cmdline_parse_token_string_t cmd_showbonding_config_config =
5153 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5155 cmdline_parse_token_num_t cmd_showbonding_config_port =
5156 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
5159 cmdline_parse_inst_t cmd_show_bonding_config = {
5160 .f = cmd_show_bonding_config_parsed,
5161 .help_str = "show bonding config <port_id>: "
5162 "Show the bonding config for port_id",
5165 (void *)&cmd_showbonding_config_show,
5166 (void *)&cmd_showbonding_config_bonding,
5167 (void *)&cmd_showbonding_config_config,
5168 (void *)&cmd_showbonding_config_port,
5173 /* *** SET BONDING PRIMARY *** */
5174 struct cmd_set_bonding_primary_result {
5175 cmdline_fixed_string_t set;
5176 cmdline_fixed_string_t bonding;
5177 cmdline_fixed_string_t primary;
5182 static void cmd_set_bonding_primary_parsed(void *parsed_result,
5183 __attribute__((unused)) struct cmdline *cl,
5184 __attribute__((unused)) void *data)
5186 struct cmd_set_bonding_primary_result *res = parsed_result;
5187 portid_t master_port_id = res->port_id;
5188 portid_t slave_port_id = res->slave_id;
5190 /* Set the primary slave for a bonded device. */
5191 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
5192 printf("\t Failed to set primary slave for port = %d.\n",
5199 cmdline_parse_token_string_t cmd_setbonding_primary_set =
5200 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5202 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
5203 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5204 bonding, "bonding");
5205 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
5206 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5207 primary, "primary");
5208 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
5209 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
5211 cmdline_parse_token_num_t cmd_setbonding_primary_port =
5212 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
5215 cmdline_parse_inst_t cmd_set_bonding_primary = {
5216 .f = cmd_set_bonding_primary_parsed,
5217 .help_str = "set bonding primary <slave_id> <port_id>: "
5218 "Set the primary slave for port_id",
5221 (void *)&cmd_setbonding_primary_set,
5222 (void *)&cmd_setbonding_primary_bonding,
5223 (void *)&cmd_setbonding_primary_primary,
5224 (void *)&cmd_setbonding_primary_slave,
5225 (void *)&cmd_setbonding_primary_port,
5230 /* *** ADD SLAVE *** */
5231 struct cmd_add_bonding_slave_result {
5232 cmdline_fixed_string_t add;
5233 cmdline_fixed_string_t bonding;
5234 cmdline_fixed_string_t slave;
5239 static void cmd_add_bonding_slave_parsed(void *parsed_result,
5240 __attribute__((unused)) struct cmdline *cl,
5241 __attribute__((unused)) void *data)
5243 struct cmd_add_bonding_slave_result *res = parsed_result;
5244 portid_t master_port_id = res->port_id;
5245 portid_t slave_port_id = res->slave_id;
5247 /* add the slave for a bonded device. */
5248 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
5249 printf("\t Failed to add slave %d to master port = %d.\n",
5250 slave_port_id, master_port_id);
5254 set_port_slave_flag(slave_port_id);
5257 cmdline_parse_token_string_t cmd_addbonding_slave_add =
5258 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5260 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
5261 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5262 bonding, "bonding");
5263 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
5264 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5266 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
5267 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
5269 cmdline_parse_token_num_t cmd_addbonding_slave_port =
5270 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
5273 cmdline_parse_inst_t cmd_add_bonding_slave = {
5274 .f = cmd_add_bonding_slave_parsed,
5275 .help_str = "add bonding slave <slave_id> <port_id>: "
5276 "Add a slave device to a bonded device",
5279 (void *)&cmd_addbonding_slave_add,
5280 (void *)&cmd_addbonding_slave_bonding,
5281 (void *)&cmd_addbonding_slave_slave,
5282 (void *)&cmd_addbonding_slave_slaveid,
5283 (void *)&cmd_addbonding_slave_port,
5288 /* *** REMOVE SLAVE *** */
5289 struct cmd_remove_bonding_slave_result {
5290 cmdline_fixed_string_t remove;
5291 cmdline_fixed_string_t bonding;
5292 cmdline_fixed_string_t slave;
5297 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
5298 __attribute__((unused)) struct cmdline *cl,
5299 __attribute__((unused)) void *data)
5301 struct cmd_remove_bonding_slave_result *res = parsed_result;
5302 portid_t master_port_id = res->port_id;
5303 portid_t slave_port_id = res->slave_id;
5305 /* remove the slave from a bonded device. */
5306 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
5307 printf("\t Failed to remove slave %d from master port = %d.\n",
5308 slave_port_id, master_port_id);
5312 clear_port_slave_flag(slave_port_id);
5315 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
5316 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
5318 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
5319 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
5320 bonding, "bonding");
5321 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
5322 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
5324 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
5325 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
5327 cmdline_parse_token_num_t cmd_removebonding_slave_port =
5328 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
5331 cmdline_parse_inst_t cmd_remove_bonding_slave = {
5332 .f = cmd_remove_bonding_slave_parsed,
5333 .help_str = "remove bonding slave <slave_id> <port_id>: "
5334 "Remove a slave device from a bonded device",
5337 (void *)&cmd_removebonding_slave_remove,
5338 (void *)&cmd_removebonding_slave_bonding,
5339 (void *)&cmd_removebonding_slave_slave,
5340 (void *)&cmd_removebonding_slave_slaveid,
5341 (void *)&cmd_removebonding_slave_port,
5346 /* *** CREATE BONDED DEVICE *** */
5347 struct cmd_create_bonded_device_result {
5348 cmdline_fixed_string_t create;
5349 cmdline_fixed_string_t bonded;
5350 cmdline_fixed_string_t device;
5355 static int bond_dev_num = 0;
5357 static void cmd_create_bonded_device_parsed(void *parsed_result,
5358 __attribute__((unused)) struct cmdline *cl,
5359 __attribute__((unused)) void *data)
5361 struct cmd_create_bonded_device_result *res = parsed_result;
5362 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
5365 if (test_done == 0) {
5366 printf("Please stop forwarding first\n");
5370 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bonding_testpmd_%d",
5373 /* Create a new bonded device. */
5374 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
5376 printf("\t Failed to create bonded device.\n");
5379 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
5382 /* Update number of ports */
5383 nb_ports = rte_eth_dev_count();
5384 reconfig(port_id, res->socket);
5385 rte_eth_promiscuous_enable(port_id);
5390 cmdline_parse_token_string_t cmd_createbonded_device_create =
5391 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
5393 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
5394 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
5396 cmdline_parse_token_string_t cmd_createbonded_device_device =
5397 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
5399 cmdline_parse_token_num_t cmd_createbonded_device_mode =
5400 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
5402 cmdline_parse_token_num_t cmd_createbonded_device_socket =
5403 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
5406 cmdline_parse_inst_t cmd_create_bonded_device = {
5407 .f = cmd_create_bonded_device_parsed,
5408 .help_str = "create bonded device <mode> <socket>: "
5409 "Create a new bonded device with specific bonding mode and socket",
5412 (void *)&cmd_createbonded_device_create,
5413 (void *)&cmd_createbonded_device_bonded,
5414 (void *)&cmd_createbonded_device_device,
5415 (void *)&cmd_createbonded_device_mode,
5416 (void *)&cmd_createbonded_device_socket,
5421 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
5422 struct cmd_set_bond_mac_addr_result {
5423 cmdline_fixed_string_t set;
5424 cmdline_fixed_string_t bonding;
5425 cmdline_fixed_string_t mac_addr;
5427 struct ether_addr address;
5430 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
5431 __attribute__((unused)) struct cmdline *cl,
5432 __attribute__((unused)) void *data)
5434 struct cmd_set_bond_mac_addr_result *res = parsed_result;
5437 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
5440 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
5442 /* check the return value and print it if is < 0 */
5444 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
5447 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
5448 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
5449 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
5450 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
5452 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
5453 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
5455 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
5456 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result,
5458 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
5459 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
5461 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
5462 .f = cmd_set_bond_mac_addr_parsed,
5464 .help_str = "set bonding mac_addr <port_id> <mac_addr>",
5466 (void *)&cmd_set_bond_mac_addr_set,
5467 (void *)&cmd_set_bond_mac_addr_bonding,
5468 (void *)&cmd_set_bond_mac_addr_mac,
5469 (void *)&cmd_set_bond_mac_addr_portnum,
5470 (void *)&cmd_set_bond_mac_addr_addr,
5476 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
5477 struct cmd_set_bond_mon_period_result {
5478 cmdline_fixed_string_t set;
5479 cmdline_fixed_string_t bonding;
5480 cmdline_fixed_string_t mon_period;
5485 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
5486 __attribute__((unused)) struct cmdline *cl,
5487 __attribute__((unused)) void *data)
5489 struct cmd_set_bond_mon_period_result *res = parsed_result;
5492 if (res->port_num >= nb_ports) {
5493 printf("Port id %d must be less than %d\n", res->port_num, nb_ports);
5497 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
5499 /* check the return value and print it if is < 0 */
5501 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
5504 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
5505 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
5507 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
5508 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
5509 bonding, "bonding");
5510 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
5511 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
5512 mon_period, "mon_period");
5513 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
5514 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
5516 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
5517 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
5520 cmdline_parse_inst_t cmd_set_bond_mon_period = {
5521 .f = cmd_set_bond_mon_period_parsed,
5523 .help_str = "set bonding mon_period <port_id> <period_ms>",
5525 (void *)&cmd_set_bond_mon_period_set,
5526 (void *)&cmd_set_bond_mon_period_bonding,
5527 (void *)&cmd_set_bond_mon_period_mon_period,
5528 (void *)&cmd_set_bond_mon_period_portnum,
5529 (void *)&cmd_set_bond_mon_period_period_ms,
5536 struct cmd_set_bonding_agg_mode_policy_result {
5537 cmdline_fixed_string_t set;
5538 cmdline_fixed_string_t bonding;
5539 cmdline_fixed_string_t agg_mode;
5541 cmdline_fixed_string_t policy;
5546 cmd_set_bonding_agg_mode(void *parsed_result,
5547 __attribute__((unused)) struct cmdline *cl,
5548 __attribute__((unused)) void *data)
5550 struct cmd_set_bonding_agg_mode_policy_result *res = parsed_result;
5551 uint8_t policy = AGG_BANDWIDTH;
5553 if (res->port_num >= nb_ports) {
5554 printf("Port id %d must be less than %d\n",
5555 res->port_num, nb_ports);
5559 if (!strcmp(res->policy, "bandwidth"))
5560 policy = AGG_BANDWIDTH;
5561 else if (!strcmp(res->policy, "stable"))
5562 policy = AGG_STABLE;
5563 else if (!strcmp(res->policy, "count"))
5566 rte_eth_bond_8023ad_agg_selection_set(res->port_num, policy);
5570 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_set =
5571 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5573 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_bonding =
5574 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5575 bonding, "bonding");
5577 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_agg_mode =
5578 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5579 agg_mode, "agg_mode");
5581 cmdline_parse_token_num_t cmd_set_bonding_agg_mode_portnum =
5582 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5585 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_policy_string =
5586 TOKEN_STRING_INITIALIZER(
5587 struct cmd_set_bonding_balance_xmit_policy_result,
5588 policy, "stable#bandwidth#count");
5590 cmdline_parse_inst_t cmd_set_bonding_agg_mode_policy = {
5591 .f = cmd_set_bonding_agg_mode,
5593 .help_str = "set bonding mode IEEE802.3AD aggregator policy <port_id> <agg_name>",
5595 (void *)&cmd_set_bonding_agg_mode_set,
5596 (void *)&cmd_set_bonding_agg_mode_bonding,
5597 (void *)&cmd_set_bonding_agg_mode_agg_mode,
5598 (void *)&cmd_set_bonding_agg_mode_portnum,
5599 (void *)&cmd_set_bonding_agg_mode_policy_string,
5605 #endif /* RTE_LIBRTE_PMD_BOND */
5607 /* *** SET FORWARDING MODE *** */
5608 struct cmd_set_fwd_mode_result {
5609 cmdline_fixed_string_t set;
5610 cmdline_fixed_string_t fwd;
5611 cmdline_fixed_string_t mode;
5614 static void cmd_set_fwd_mode_parsed(void *parsed_result,
5615 __attribute__((unused)) struct cmdline *cl,
5616 __attribute__((unused)) void *data)
5618 struct cmd_set_fwd_mode_result *res = parsed_result;
5621 set_pkt_forwarding_mode(res->mode);
5624 cmdline_parse_token_string_t cmd_setfwd_set =
5625 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
5626 cmdline_parse_token_string_t cmd_setfwd_fwd =
5627 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
5628 cmdline_parse_token_string_t cmd_setfwd_mode =
5629 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
5630 "" /* defined at init */);
5632 cmdline_parse_inst_t cmd_set_fwd_mode = {
5633 .f = cmd_set_fwd_mode_parsed,
5635 .help_str = NULL, /* defined at init */
5637 (void *)&cmd_setfwd_set,
5638 (void *)&cmd_setfwd_fwd,
5639 (void *)&cmd_setfwd_mode,
5644 static void cmd_set_fwd_mode_init(void)
5647 static char token[128];
5648 static char help[256];
5649 cmdline_parse_token_string_t *token_struct;
5651 modes = list_pkt_forwarding_modes();
5652 snprintf(help, sizeof(help), "set fwd %s: "
5653 "Set packet forwarding mode", modes);
5654 cmd_set_fwd_mode.help_str = help;
5656 /* string token separator is # */
5657 for (c = token; *modes != '\0'; modes++)
5662 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
5663 token_struct->string_data.str = token;
5666 /* *** SET RETRY FORWARDING MODE *** */
5667 struct cmd_set_fwd_retry_mode_result {
5668 cmdline_fixed_string_t set;
5669 cmdline_fixed_string_t fwd;
5670 cmdline_fixed_string_t mode;
5671 cmdline_fixed_string_t retry;
5674 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
5675 __attribute__((unused)) struct cmdline *cl,
5676 __attribute__((unused)) void *data)
5678 struct cmd_set_fwd_retry_mode_result *res = parsed_result;
5681 set_pkt_forwarding_mode(res->mode);
5684 cmdline_parse_token_string_t cmd_setfwd_retry_set =
5685 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
5687 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
5688 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
5690 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
5691 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
5693 "" /* defined at init */);
5694 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
5695 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
5698 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
5699 .f = cmd_set_fwd_retry_mode_parsed,
5701 .help_str = NULL, /* defined at init */
5703 (void *)&cmd_setfwd_retry_set,
5704 (void *)&cmd_setfwd_retry_fwd,
5705 (void *)&cmd_setfwd_retry_mode,
5706 (void *)&cmd_setfwd_retry_retry,
5711 static void cmd_set_fwd_retry_mode_init(void)
5714 static char token[128];
5715 static char help[256];
5716 cmdline_parse_token_string_t *token_struct;
5718 modes = list_pkt_forwarding_retry_modes();
5719 snprintf(help, sizeof(help), "set fwd %s retry: "
5720 "Set packet forwarding mode with retry", modes);
5721 cmd_set_fwd_retry_mode.help_str = help;
5723 /* string token separator is # */
5724 for (c = token; *modes != '\0'; modes++)
5729 token_struct = (cmdline_parse_token_string_t *)
5730 cmd_set_fwd_retry_mode.tokens[2];
5731 token_struct->string_data.str = token;
5734 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
5735 struct cmd_set_burst_tx_retry_result {
5736 cmdline_fixed_string_t set;
5737 cmdline_fixed_string_t burst;
5738 cmdline_fixed_string_t tx;
5739 cmdline_fixed_string_t delay;
5741 cmdline_fixed_string_t retry;
5745 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
5746 __attribute__((unused)) struct cmdline *cl,
5747 __attribute__((unused)) void *data)
5749 struct cmd_set_burst_tx_retry_result *res = parsed_result;
5751 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
5752 && !strcmp(res->tx, "tx")) {
5753 if (!strcmp(res->delay, "delay"))
5754 burst_tx_delay_time = res->time;
5755 if (!strcmp(res->retry, "retry"))
5756 burst_tx_retry_num = res->retry_num;
5761 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
5762 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
5763 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
5764 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
5766 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
5767 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
5768 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
5769 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
5770 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
5771 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
5772 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
5773 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
5774 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
5775 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
5777 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
5778 .f = cmd_set_burst_tx_retry_parsed,
5779 .help_str = "set burst tx delay <delay_usec> retry <num_retry>",
5781 (void *)&cmd_set_burst_tx_retry_set,
5782 (void *)&cmd_set_burst_tx_retry_burst,
5783 (void *)&cmd_set_burst_tx_retry_tx,
5784 (void *)&cmd_set_burst_tx_retry_delay,
5785 (void *)&cmd_set_burst_tx_retry_time,
5786 (void *)&cmd_set_burst_tx_retry_retry,
5787 (void *)&cmd_set_burst_tx_retry_retry_num,
5792 /* *** SET PROMISC MODE *** */
5793 struct cmd_set_promisc_mode_result {
5794 cmdline_fixed_string_t set;
5795 cmdline_fixed_string_t promisc;
5796 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
5797 uint16_t port_num; /* valid if "allports" argument == 0 */
5798 cmdline_fixed_string_t mode;
5801 static void cmd_set_promisc_mode_parsed(void *parsed_result,
5802 __attribute__((unused)) struct cmdline *cl,
5805 struct cmd_set_promisc_mode_result *res = parsed_result;
5809 if (!strcmp(res->mode, "on"))
5816 RTE_ETH_FOREACH_DEV(i) {
5818 rte_eth_promiscuous_enable(i);
5820 rte_eth_promiscuous_disable(i);
5825 rte_eth_promiscuous_enable(res->port_num);
5827 rte_eth_promiscuous_disable(res->port_num);
5831 cmdline_parse_token_string_t cmd_setpromisc_set =
5832 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
5833 cmdline_parse_token_string_t cmd_setpromisc_promisc =
5834 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
5836 cmdline_parse_token_string_t cmd_setpromisc_portall =
5837 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
5839 cmdline_parse_token_num_t cmd_setpromisc_portnum =
5840 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
5842 cmdline_parse_token_string_t cmd_setpromisc_mode =
5843 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
5846 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
5847 .f = cmd_set_promisc_mode_parsed,
5849 .help_str = "set promisc all on|off: Set promisc mode for all ports",
5851 (void *)&cmd_setpromisc_set,
5852 (void *)&cmd_setpromisc_promisc,
5853 (void *)&cmd_setpromisc_portall,
5854 (void *)&cmd_setpromisc_mode,
5859 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
5860 .f = cmd_set_promisc_mode_parsed,
5862 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
5864 (void *)&cmd_setpromisc_set,
5865 (void *)&cmd_setpromisc_promisc,
5866 (void *)&cmd_setpromisc_portnum,
5867 (void *)&cmd_setpromisc_mode,
5872 /* *** SET ALLMULTI MODE *** */
5873 struct cmd_set_allmulti_mode_result {
5874 cmdline_fixed_string_t set;
5875 cmdline_fixed_string_t allmulti;
5876 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
5877 uint16_t port_num; /* valid if "allports" argument == 0 */
5878 cmdline_fixed_string_t mode;
5881 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
5882 __attribute__((unused)) struct cmdline *cl,
5885 struct cmd_set_allmulti_mode_result *res = parsed_result;
5889 if (!strcmp(res->mode, "on"))
5896 RTE_ETH_FOREACH_DEV(i) {
5898 rte_eth_allmulticast_enable(i);
5900 rte_eth_allmulticast_disable(i);
5905 rte_eth_allmulticast_enable(res->port_num);
5907 rte_eth_allmulticast_disable(res->port_num);
5911 cmdline_parse_token_string_t cmd_setallmulti_set =
5912 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
5913 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
5914 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
5916 cmdline_parse_token_string_t cmd_setallmulti_portall =
5917 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
5919 cmdline_parse_token_num_t cmd_setallmulti_portnum =
5920 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
5922 cmdline_parse_token_string_t cmd_setallmulti_mode =
5923 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
5926 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
5927 .f = cmd_set_allmulti_mode_parsed,
5929 .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
5931 (void *)&cmd_setallmulti_set,
5932 (void *)&cmd_setallmulti_allmulti,
5933 (void *)&cmd_setallmulti_portall,
5934 (void *)&cmd_setallmulti_mode,
5939 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
5940 .f = cmd_set_allmulti_mode_parsed,
5942 .help_str = "set allmulti <port_id> on|off: "
5943 "Set allmulti mode on port_id",
5945 (void *)&cmd_setallmulti_set,
5946 (void *)&cmd_setallmulti_allmulti,
5947 (void *)&cmd_setallmulti_portnum,
5948 (void *)&cmd_setallmulti_mode,
5953 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
5954 struct cmd_link_flow_ctrl_set_result {
5955 cmdline_fixed_string_t set;
5956 cmdline_fixed_string_t flow_ctrl;
5957 cmdline_fixed_string_t rx;
5958 cmdline_fixed_string_t rx_lfc_mode;
5959 cmdline_fixed_string_t tx;
5960 cmdline_fixed_string_t tx_lfc_mode;
5961 cmdline_fixed_string_t mac_ctrl_frame_fwd;
5962 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
5963 cmdline_fixed_string_t autoneg_str;
5964 cmdline_fixed_string_t autoneg;
5965 cmdline_fixed_string_t hw_str;
5966 uint32_t high_water;
5967 cmdline_fixed_string_t lw_str;
5969 cmdline_fixed_string_t pt_str;
5970 uint16_t pause_time;
5971 cmdline_fixed_string_t xon_str;
5976 cmdline_parse_token_string_t cmd_lfc_set_set =
5977 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5979 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
5980 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5981 flow_ctrl, "flow_ctrl");
5982 cmdline_parse_token_string_t cmd_lfc_set_rx =
5983 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5985 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
5986 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5987 rx_lfc_mode, "on#off");
5988 cmdline_parse_token_string_t cmd_lfc_set_tx =
5989 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5991 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
5992 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5993 tx_lfc_mode, "on#off");
5994 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
5995 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5996 hw_str, "high_water");
5997 cmdline_parse_token_num_t cmd_lfc_set_high_water =
5998 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5999 high_water, UINT32);
6000 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
6001 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6002 lw_str, "low_water");
6003 cmdline_parse_token_num_t cmd_lfc_set_low_water =
6004 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6006 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
6007 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6008 pt_str, "pause_time");
6009 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
6010 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6011 pause_time, UINT16);
6012 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
6013 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6014 xon_str, "send_xon");
6015 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
6016 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6018 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
6019 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6020 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
6021 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
6022 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6023 mac_ctrl_frame_fwd_mode, "on#off");
6024 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
6025 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6026 autoneg_str, "autoneg");
6027 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
6028 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6030 cmdline_parse_token_num_t cmd_lfc_set_portid =
6031 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6034 /* forward declaration */
6036 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
6039 cmdline_parse_inst_t cmd_link_flow_control_set = {
6040 .f = cmd_link_flow_ctrl_set_parsed,
6042 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
6043 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
6044 "autoneg on|off <port_id>: Configure the Ethernet flow control",
6046 (void *)&cmd_lfc_set_set,
6047 (void *)&cmd_lfc_set_flow_ctrl,
6048 (void *)&cmd_lfc_set_rx,
6049 (void *)&cmd_lfc_set_rx_mode,
6050 (void *)&cmd_lfc_set_tx,
6051 (void *)&cmd_lfc_set_tx_mode,
6052 (void *)&cmd_lfc_set_high_water,
6053 (void *)&cmd_lfc_set_low_water,
6054 (void *)&cmd_lfc_set_pause_time,
6055 (void *)&cmd_lfc_set_send_xon,
6056 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6057 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6058 (void *)&cmd_lfc_set_autoneg_str,
6059 (void *)&cmd_lfc_set_autoneg,
6060 (void *)&cmd_lfc_set_portid,
6065 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
6066 .f = cmd_link_flow_ctrl_set_parsed,
6067 .data = (void *)&cmd_link_flow_control_set_rx,
6068 .help_str = "set flow_ctrl rx on|off <port_id>: "
6069 "Change rx flow control parameter",
6071 (void *)&cmd_lfc_set_set,
6072 (void *)&cmd_lfc_set_flow_ctrl,
6073 (void *)&cmd_lfc_set_rx,
6074 (void *)&cmd_lfc_set_rx_mode,
6075 (void *)&cmd_lfc_set_portid,
6080 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
6081 .f = cmd_link_flow_ctrl_set_parsed,
6082 .data = (void *)&cmd_link_flow_control_set_tx,
6083 .help_str = "set flow_ctrl tx on|off <port_id>: "
6084 "Change tx flow control parameter",
6086 (void *)&cmd_lfc_set_set,
6087 (void *)&cmd_lfc_set_flow_ctrl,
6088 (void *)&cmd_lfc_set_tx,
6089 (void *)&cmd_lfc_set_tx_mode,
6090 (void *)&cmd_lfc_set_portid,
6095 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
6096 .f = cmd_link_flow_ctrl_set_parsed,
6097 .data = (void *)&cmd_link_flow_control_set_hw,
6098 .help_str = "set flow_ctrl high_water <value> <port_id>: "
6099 "Change high water flow control parameter",
6101 (void *)&cmd_lfc_set_set,
6102 (void *)&cmd_lfc_set_flow_ctrl,
6103 (void *)&cmd_lfc_set_high_water_str,
6104 (void *)&cmd_lfc_set_high_water,
6105 (void *)&cmd_lfc_set_portid,
6110 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
6111 .f = cmd_link_flow_ctrl_set_parsed,
6112 .data = (void *)&cmd_link_flow_control_set_lw,
6113 .help_str = "set flow_ctrl low_water <value> <port_id>: "
6114 "Change low water flow control parameter",
6116 (void *)&cmd_lfc_set_set,
6117 (void *)&cmd_lfc_set_flow_ctrl,
6118 (void *)&cmd_lfc_set_low_water_str,
6119 (void *)&cmd_lfc_set_low_water,
6120 (void *)&cmd_lfc_set_portid,
6125 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
6126 .f = cmd_link_flow_ctrl_set_parsed,
6127 .data = (void *)&cmd_link_flow_control_set_pt,
6128 .help_str = "set flow_ctrl pause_time <value> <port_id>: "
6129 "Change pause time flow control parameter",
6131 (void *)&cmd_lfc_set_set,
6132 (void *)&cmd_lfc_set_flow_ctrl,
6133 (void *)&cmd_lfc_set_pause_time_str,
6134 (void *)&cmd_lfc_set_pause_time,
6135 (void *)&cmd_lfc_set_portid,
6140 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
6141 .f = cmd_link_flow_ctrl_set_parsed,
6142 .data = (void *)&cmd_link_flow_control_set_xon,
6143 .help_str = "set flow_ctrl send_xon <value> <port_id>: "
6144 "Change send_xon flow control parameter",
6146 (void *)&cmd_lfc_set_set,
6147 (void *)&cmd_lfc_set_flow_ctrl,
6148 (void *)&cmd_lfc_set_send_xon_str,
6149 (void *)&cmd_lfc_set_send_xon,
6150 (void *)&cmd_lfc_set_portid,
6155 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
6156 .f = cmd_link_flow_ctrl_set_parsed,
6157 .data = (void *)&cmd_link_flow_control_set_macfwd,
6158 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
6159 "Change mac ctrl fwd flow control parameter",
6161 (void *)&cmd_lfc_set_set,
6162 (void *)&cmd_lfc_set_flow_ctrl,
6163 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6164 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6165 (void *)&cmd_lfc_set_portid,
6170 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
6171 .f = cmd_link_flow_ctrl_set_parsed,
6172 .data = (void *)&cmd_link_flow_control_set_autoneg,
6173 .help_str = "set flow_ctrl autoneg on|off <port_id>: "
6174 "Change autoneg flow control parameter",
6176 (void *)&cmd_lfc_set_set,
6177 (void *)&cmd_lfc_set_flow_ctrl,
6178 (void *)&cmd_lfc_set_autoneg_str,
6179 (void *)&cmd_lfc_set_autoneg,
6180 (void *)&cmd_lfc_set_portid,
6186 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
6187 __attribute__((unused)) struct cmdline *cl,
6190 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
6191 cmdline_parse_inst_t *cmd = data;
6192 struct rte_eth_fc_conf fc_conf;
6198 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
6199 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
6200 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
6201 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
6203 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
6204 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
6207 /* Partial command line, retrieve current configuration */
6209 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
6211 printf("cannot get current flow ctrl parameters, return"
6212 "code = %d\n", ret);
6216 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
6217 (fc_conf.mode == RTE_FC_FULL))
6219 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
6220 (fc_conf.mode == RTE_FC_FULL))
6224 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
6225 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
6227 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
6228 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
6230 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
6232 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
6233 fc_conf.high_water = res->high_water;
6235 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
6236 fc_conf.low_water = res->low_water;
6238 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
6239 fc_conf.pause_time = res->pause_time;
6241 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
6242 fc_conf.send_xon = res->send_xon;
6244 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
6245 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
6246 fc_conf.mac_ctrl_frame_fwd = 1;
6248 fc_conf.mac_ctrl_frame_fwd = 0;
6251 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
6252 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
6254 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
6256 printf("bad flow contrl parameter, return code = %d \n", ret);
6259 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
6260 struct cmd_priority_flow_ctrl_set_result {
6261 cmdline_fixed_string_t set;
6262 cmdline_fixed_string_t pfc_ctrl;
6263 cmdline_fixed_string_t rx;
6264 cmdline_fixed_string_t rx_pfc_mode;
6265 cmdline_fixed_string_t tx;
6266 cmdline_fixed_string_t tx_pfc_mode;
6267 uint32_t high_water;
6269 uint16_t pause_time;
6275 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
6276 __attribute__((unused)) struct cmdline *cl,
6277 __attribute__((unused)) void *data)
6279 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
6280 struct rte_eth_pfc_conf pfc_conf;
6281 int rx_fc_enable, tx_fc_enable;
6285 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
6286 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
6287 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
6288 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
6290 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
6291 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
6294 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
6295 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
6296 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
6297 pfc_conf.fc.high_water = res->high_water;
6298 pfc_conf.fc.low_water = res->low_water;
6299 pfc_conf.fc.pause_time = res->pause_time;
6300 pfc_conf.priority = res->priority;
6302 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
6304 printf("bad priority flow contrl parameter, return code = %d \n", ret);
6307 cmdline_parse_token_string_t cmd_pfc_set_set =
6308 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6310 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
6311 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6312 pfc_ctrl, "pfc_ctrl");
6313 cmdline_parse_token_string_t cmd_pfc_set_rx =
6314 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6316 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
6317 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6318 rx_pfc_mode, "on#off");
6319 cmdline_parse_token_string_t cmd_pfc_set_tx =
6320 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6322 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
6323 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6324 tx_pfc_mode, "on#off");
6325 cmdline_parse_token_num_t cmd_pfc_set_high_water =
6326 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6327 high_water, UINT32);
6328 cmdline_parse_token_num_t cmd_pfc_set_low_water =
6329 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6331 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
6332 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6333 pause_time, UINT16);
6334 cmdline_parse_token_num_t cmd_pfc_set_priority =
6335 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6337 cmdline_parse_token_num_t cmd_pfc_set_portid =
6338 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6341 cmdline_parse_inst_t cmd_priority_flow_control_set = {
6342 .f = cmd_priority_flow_ctrl_set_parsed,
6344 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
6345 "<pause_time> <priority> <port_id>: "
6346 "Configure the Ethernet priority flow control",
6348 (void *)&cmd_pfc_set_set,
6349 (void *)&cmd_pfc_set_flow_ctrl,
6350 (void *)&cmd_pfc_set_rx,
6351 (void *)&cmd_pfc_set_rx_mode,
6352 (void *)&cmd_pfc_set_tx,
6353 (void *)&cmd_pfc_set_tx_mode,
6354 (void *)&cmd_pfc_set_high_water,
6355 (void *)&cmd_pfc_set_low_water,
6356 (void *)&cmd_pfc_set_pause_time,
6357 (void *)&cmd_pfc_set_priority,
6358 (void *)&cmd_pfc_set_portid,
6363 /* *** RESET CONFIGURATION *** */
6364 struct cmd_reset_result {
6365 cmdline_fixed_string_t reset;
6366 cmdline_fixed_string_t def;
6369 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
6371 __attribute__((unused)) void *data)
6373 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
6374 set_def_fwd_config();
6377 cmdline_parse_token_string_t cmd_reset_set =
6378 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
6379 cmdline_parse_token_string_t cmd_reset_def =
6380 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
6383 cmdline_parse_inst_t cmd_reset = {
6384 .f = cmd_reset_parsed,
6386 .help_str = "set default: Reset default forwarding configuration",
6388 (void *)&cmd_reset_set,
6389 (void *)&cmd_reset_def,
6394 /* *** START FORWARDING *** */
6395 struct cmd_start_result {
6396 cmdline_fixed_string_t start;
6399 cmdline_parse_token_string_t cmd_start_start =
6400 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
6402 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
6403 __attribute__((unused)) struct cmdline *cl,
6404 __attribute__((unused)) void *data)
6406 start_packet_forwarding(0);
6409 cmdline_parse_inst_t cmd_start = {
6410 .f = cmd_start_parsed,
6412 .help_str = "start: Start packet forwarding",
6414 (void *)&cmd_start_start,
6419 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
6420 struct cmd_start_tx_first_result {
6421 cmdline_fixed_string_t start;
6422 cmdline_fixed_string_t tx_first;
6426 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
6427 __attribute__((unused)) struct cmdline *cl,
6428 __attribute__((unused)) void *data)
6430 start_packet_forwarding(1);
6433 cmdline_parse_token_string_t cmd_start_tx_first_start =
6434 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
6436 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
6437 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
6438 tx_first, "tx_first");
6440 cmdline_parse_inst_t cmd_start_tx_first = {
6441 .f = cmd_start_tx_first_parsed,
6443 .help_str = "start tx_first: Start packet forwarding, "
6444 "after sending 1 burst of packets",
6446 (void *)&cmd_start_tx_first_start,
6447 (void *)&cmd_start_tx_first_tx_first,
6452 /* *** START FORWARDING WITH N TX BURST FIRST *** */
6453 struct cmd_start_tx_first_n_result {
6454 cmdline_fixed_string_t start;
6455 cmdline_fixed_string_t tx_first;
6460 cmd_start_tx_first_n_parsed(void *parsed_result,
6461 __attribute__((unused)) struct cmdline *cl,
6462 __attribute__((unused)) void *data)
6464 struct cmd_start_tx_first_n_result *res = parsed_result;
6466 start_packet_forwarding(res->tx_num);
6469 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
6470 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
6472 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
6473 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
6474 tx_first, "tx_first");
6475 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
6476 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
6479 cmdline_parse_inst_t cmd_start_tx_first_n = {
6480 .f = cmd_start_tx_first_n_parsed,
6482 .help_str = "start tx_first <num>: "
6483 "packet forwarding, after sending <num> bursts of packets",
6485 (void *)&cmd_start_tx_first_n_start,
6486 (void *)&cmd_start_tx_first_n_tx_first,
6487 (void *)&cmd_start_tx_first_n_tx_num,
6492 /* *** SET LINK UP *** */
6493 struct cmd_set_link_up_result {
6494 cmdline_fixed_string_t set;
6495 cmdline_fixed_string_t link_up;
6496 cmdline_fixed_string_t port;
6500 cmdline_parse_token_string_t cmd_set_link_up_set =
6501 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
6502 cmdline_parse_token_string_t cmd_set_link_up_link_up =
6503 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
6505 cmdline_parse_token_string_t cmd_set_link_up_port =
6506 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
6507 cmdline_parse_token_num_t cmd_set_link_up_port_id =
6508 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT16);
6510 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result,
6511 __attribute__((unused)) struct cmdline *cl,
6512 __attribute__((unused)) void *data)
6514 struct cmd_set_link_up_result *res = parsed_result;
6515 dev_set_link_up(res->port_id);
6518 cmdline_parse_inst_t cmd_set_link_up = {
6519 .f = cmd_set_link_up_parsed,
6521 .help_str = "set link-up port <port id>",
6523 (void *)&cmd_set_link_up_set,
6524 (void *)&cmd_set_link_up_link_up,
6525 (void *)&cmd_set_link_up_port,
6526 (void *)&cmd_set_link_up_port_id,
6531 /* *** SET LINK DOWN *** */
6532 struct cmd_set_link_down_result {
6533 cmdline_fixed_string_t set;
6534 cmdline_fixed_string_t link_down;
6535 cmdline_fixed_string_t port;
6539 cmdline_parse_token_string_t cmd_set_link_down_set =
6540 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
6541 cmdline_parse_token_string_t cmd_set_link_down_link_down =
6542 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
6544 cmdline_parse_token_string_t cmd_set_link_down_port =
6545 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
6546 cmdline_parse_token_num_t cmd_set_link_down_port_id =
6547 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT16);
6549 static void cmd_set_link_down_parsed(
6550 __attribute__((unused)) void *parsed_result,
6551 __attribute__((unused)) struct cmdline *cl,
6552 __attribute__((unused)) void *data)
6554 struct cmd_set_link_down_result *res = parsed_result;
6555 dev_set_link_down(res->port_id);
6558 cmdline_parse_inst_t cmd_set_link_down = {
6559 .f = cmd_set_link_down_parsed,
6561 .help_str = "set link-down port <port id>",
6563 (void *)&cmd_set_link_down_set,
6564 (void *)&cmd_set_link_down_link_down,
6565 (void *)&cmd_set_link_down_port,
6566 (void *)&cmd_set_link_down_port_id,
6571 /* *** SHOW CFG *** */
6572 struct cmd_showcfg_result {
6573 cmdline_fixed_string_t show;
6574 cmdline_fixed_string_t cfg;
6575 cmdline_fixed_string_t what;
6578 static void cmd_showcfg_parsed(void *parsed_result,
6579 __attribute__((unused)) struct cmdline *cl,
6580 __attribute__((unused)) void *data)
6582 struct cmd_showcfg_result *res = parsed_result;
6583 if (!strcmp(res->what, "rxtx"))
6584 rxtx_config_display();
6585 else if (!strcmp(res->what, "cores"))
6586 fwd_lcores_config_display();
6587 else if (!strcmp(res->what, "fwd"))
6588 pkt_fwd_config_display(&cur_fwd_config);
6589 else if (!strcmp(res->what, "txpkts"))
6590 show_tx_pkt_segments();
6593 cmdline_parse_token_string_t cmd_showcfg_show =
6594 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
6595 cmdline_parse_token_string_t cmd_showcfg_port =
6596 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
6597 cmdline_parse_token_string_t cmd_showcfg_what =
6598 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
6599 "rxtx#cores#fwd#txpkts");
6601 cmdline_parse_inst_t cmd_showcfg = {
6602 .f = cmd_showcfg_parsed,
6604 .help_str = "show config rxtx|cores|fwd|txpkts",
6606 (void *)&cmd_showcfg_show,
6607 (void *)&cmd_showcfg_port,
6608 (void *)&cmd_showcfg_what,
6613 /* *** SHOW ALL PORT INFO *** */
6614 struct cmd_showportall_result {
6615 cmdline_fixed_string_t show;
6616 cmdline_fixed_string_t port;
6617 cmdline_fixed_string_t what;
6618 cmdline_fixed_string_t all;
6621 static void cmd_showportall_parsed(void *parsed_result,
6622 __attribute__((unused)) struct cmdline *cl,
6623 __attribute__((unused)) void *data)
6627 struct cmd_showportall_result *res = parsed_result;
6628 if (!strcmp(res->show, "clear")) {
6629 if (!strcmp(res->what, "stats"))
6630 RTE_ETH_FOREACH_DEV(i)
6632 else if (!strcmp(res->what, "xstats"))
6633 RTE_ETH_FOREACH_DEV(i)
6634 nic_xstats_clear(i);
6635 } else if (!strcmp(res->what, "info"))
6636 RTE_ETH_FOREACH_DEV(i)
6637 port_infos_display(i);
6638 else if (!strcmp(res->what, "stats"))
6639 RTE_ETH_FOREACH_DEV(i)
6640 nic_stats_display(i);
6641 else if (!strcmp(res->what, "xstats"))
6642 RTE_ETH_FOREACH_DEV(i)
6643 nic_xstats_display(i);
6644 else if (!strcmp(res->what, "fdir"))
6645 RTE_ETH_FOREACH_DEV(i)
6647 else if (!strcmp(res->what, "stat_qmap"))
6648 RTE_ETH_FOREACH_DEV(i)
6649 nic_stats_mapping_display(i);
6650 else if (!strcmp(res->what, "dcb_tc"))
6651 RTE_ETH_FOREACH_DEV(i)
6652 port_dcb_info_display(i);
6653 else if (!strcmp(res->what, "cap"))
6654 RTE_ETH_FOREACH_DEV(i)
6655 port_offload_cap_display(i);
6658 cmdline_parse_token_string_t cmd_showportall_show =
6659 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
6661 cmdline_parse_token_string_t cmd_showportall_port =
6662 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
6663 cmdline_parse_token_string_t cmd_showportall_what =
6664 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
6665 "info#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
6666 cmdline_parse_token_string_t cmd_showportall_all =
6667 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
6668 cmdline_parse_inst_t cmd_showportall = {
6669 .f = cmd_showportall_parsed,
6671 .help_str = "show|clear port "
6672 "info|stats|xstats|fdir|stat_qmap|dcb_tc|cap all",
6674 (void *)&cmd_showportall_show,
6675 (void *)&cmd_showportall_port,
6676 (void *)&cmd_showportall_what,
6677 (void *)&cmd_showportall_all,
6682 /* *** SHOW PORT INFO *** */
6683 struct cmd_showport_result {
6684 cmdline_fixed_string_t show;
6685 cmdline_fixed_string_t port;
6686 cmdline_fixed_string_t what;
6690 static void cmd_showport_parsed(void *parsed_result,
6691 __attribute__((unused)) struct cmdline *cl,
6692 __attribute__((unused)) void *data)
6694 struct cmd_showport_result *res = parsed_result;
6695 if (!strcmp(res->show, "clear")) {
6696 if (!strcmp(res->what, "stats"))
6697 nic_stats_clear(res->portnum);
6698 else if (!strcmp(res->what, "xstats"))
6699 nic_xstats_clear(res->portnum);
6700 } else if (!strcmp(res->what, "info"))
6701 port_infos_display(res->portnum);
6702 else if (!strcmp(res->what, "stats"))
6703 nic_stats_display(res->portnum);
6704 else if (!strcmp(res->what, "xstats"))
6705 nic_xstats_display(res->portnum);
6706 else if (!strcmp(res->what, "fdir"))
6707 fdir_get_infos(res->portnum);
6708 else if (!strcmp(res->what, "stat_qmap"))
6709 nic_stats_mapping_display(res->portnum);
6710 else if (!strcmp(res->what, "dcb_tc"))
6711 port_dcb_info_display(res->portnum);
6712 else if (!strcmp(res->what, "cap"))
6713 port_offload_cap_display(res->portnum);
6716 cmdline_parse_token_string_t cmd_showport_show =
6717 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
6719 cmdline_parse_token_string_t cmd_showport_port =
6720 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
6721 cmdline_parse_token_string_t cmd_showport_what =
6722 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
6723 "info#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
6724 cmdline_parse_token_num_t cmd_showport_portnum =
6725 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT16);
6727 cmdline_parse_inst_t cmd_showport = {
6728 .f = cmd_showport_parsed,
6730 .help_str = "show|clear port "
6731 "info|stats|xstats|fdir|stat_qmap|dcb_tc|cap "
6734 (void *)&cmd_showport_show,
6735 (void *)&cmd_showport_port,
6736 (void *)&cmd_showport_what,
6737 (void *)&cmd_showport_portnum,
6742 /* *** SHOW QUEUE INFO *** */
6743 struct cmd_showqueue_result {
6744 cmdline_fixed_string_t show;
6745 cmdline_fixed_string_t type;
6746 cmdline_fixed_string_t what;
6752 cmd_showqueue_parsed(void *parsed_result,
6753 __attribute__((unused)) struct cmdline *cl,
6754 __attribute__((unused)) void *data)
6756 struct cmd_showqueue_result *res = parsed_result;
6758 if (!strcmp(res->type, "rxq"))
6759 rx_queue_infos_display(res->portnum, res->queuenum);
6760 else if (!strcmp(res->type, "txq"))
6761 tx_queue_infos_display(res->portnum, res->queuenum);
6764 cmdline_parse_token_string_t cmd_showqueue_show =
6765 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
6766 cmdline_parse_token_string_t cmd_showqueue_type =
6767 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
6768 cmdline_parse_token_string_t cmd_showqueue_what =
6769 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
6770 cmdline_parse_token_num_t cmd_showqueue_portnum =
6771 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, UINT16);
6772 cmdline_parse_token_num_t cmd_showqueue_queuenum =
6773 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, UINT16);
6775 cmdline_parse_inst_t cmd_showqueue = {
6776 .f = cmd_showqueue_parsed,
6778 .help_str = "show rxq|txq info <port_id> <queue_id>",
6780 (void *)&cmd_showqueue_show,
6781 (void *)&cmd_showqueue_type,
6782 (void *)&cmd_showqueue_what,
6783 (void *)&cmd_showqueue_portnum,
6784 (void *)&cmd_showqueue_queuenum,
6789 /* *** READ PORT REGISTER *** */
6790 struct cmd_read_reg_result {
6791 cmdline_fixed_string_t read;
6792 cmdline_fixed_string_t reg;
6798 cmd_read_reg_parsed(void *parsed_result,
6799 __attribute__((unused)) struct cmdline *cl,
6800 __attribute__((unused)) void *data)
6802 struct cmd_read_reg_result *res = parsed_result;
6803 port_reg_display(res->port_id, res->reg_off);
6806 cmdline_parse_token_string_t cmd_read_reg_read =
6807 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
6808 cmdline_parse_token_string_t cmd_read_reg_reg =
6809 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
6810 cmdline_parse_token_num_t cmd_read_reg_port_id =
6811 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT16);
6812 cmdline_parse_token_num_t cmd_read_reg_reg_off =
6813 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
6815 cmdline_parse_inst_t cmd_read_reg = {
6816 .f = cmd_read_reg_parsed,
6818 .help_str = "read reg <port_id> <reg_off>",
6820 (void *)&cmd_read_reg_read,
6821 (void *)&cmd_read_reg_reg,
6822 (void *)&cmd_read_reg_port_id,
6823 (void *)&cmd_read_reg_reg_off,
6828 /* *** READ PORT REGISTER BIT FIELD *** */
6829 struct cmd_read_reg_bit_field_result {
6830 cmdline_fixed_string_t read;
6831 cmdline_fixed_string_t regfield;
6839 cmd_read_reg_bit_field_parsed(void *parsed_result,
6840 __attribute__((unused)) struct cmdline *cl,
6841 __attribute__((unused)) void *data)
6843 struct cmd_read_reg_bit_field_result *res = parsed_result;
6844 port_reg_bit_field_display(res->port_id, res->reg_off,
6845 res->bit1_pos, res->bit2_pos);
6848 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
6849 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
6851 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
6852 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
6853 regfield, "regfield");
6854 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
6855 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
6857 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
6858 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
6860 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
6861 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
6863 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
6864 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
6867 cmdline_parse_inst_t cmd_read_reg_bit_field = {
6868 .f = cmd_read_reg_bit_field_parsed,
6870 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
6871 "Read register bit field between bit_x and bit_y included",
6873 (void *)&cmd_read_reg_bit_field_read,
6874 (void *)&cmd_read_reg_bit_field_regfield,
6875 (void *)&cmd_read_reg_bit_field_port_id,
6876 (void *)&cmd_read_reg_bit_field_reg_off,
6877 (void *)&cmd_read_reg_bit_field_bit1_pos,
6878 (void *)&cmd_read_reg_bit_field_bit2_pos,
6883 /* *** READ PORT REGISTER BIT *** */
6884 struct cmd_read_reg_bit_result {
6885 cmdline_fixed_string_t read;
6886 cmdline_fixed_string_t regbit;
6893 cmd_read_reg_bit_parsed(void *parsed_result,
6894 __attribute__((unused)) struct cmdline *cl,
6895 __attribute__((unused)) void *data)
6897 struct cmd_read_reg_bit_result *res = parsed_result;
6898 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
6901 cmdline_parse_token_string_t cmd_read_reg_bit_read =
6902 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
6903 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
6904 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
6906 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
6907 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT16);
6908 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
6909 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
6910 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
6911 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
6913 cmdline_parse_inst_t cmd_read_reg_bit = {
6914 .f = cmd_read_reg_bit_parsed,
6916 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
6918 (void *)&cmd_read_reg_bit_read,
6919 (void *)&cmd_read_reg_bit_regbit,
6920 (void *)&cmd_read_reg_bit_port_id,
6921 (void *)&cmd_read_reg_bit_reg_off,
6922 (void *)&cmd_read_reg_bit_bit_pos,
6927 /* *** WRITE PORT REGISTER *** */
6928 struct cmd_write_reg_result {
6929 cmdline_fixed_string_t write;
6930 cmdline_fixed_string_t reg;
6937 cmd_write_reg_parsed(void *parsed_result,
6938 __attribute__((unused)) struct cmdline *cl,
6939 __attribute__((unused)) void *data)
6941 struct cmd_write_reg_result *res = parsed_result;
6942 port_reg_set(res->port_id, res->reg_off, res->value);
6945 cmdline_parse_token_string_t cmd_write_reg_write =
6946 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
6947 cmdline_parse_token_string_t cmd_write_reg_reg =
6948 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
6949 cmdline_parse_token_num_t cmd_write_reg_port_id =
6950 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT16);
6951 cmdline_parse_token_num_t cmd_write_reg_reg_off =
6952 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
6953 cmdline_parse_token_num_t cmd_write_reg_value =
6954 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
6956 cmdline_parse_inst_t cmd_write_reg = {
6957 .f = cmd_write_reg_parsed,
6959 .help_str = "write reg <port_id> <reg_off> <reg_value>",
6961 (void *)&cmd_write_reg_write,
6962 (void *)&cmd_write_reg_reg,
6963 (void *)&cmd_write_reg_port_id,
6964 (void *)&cmd_write_reg_reg_off,
6965 (void *)&cmd_write_reg_value,
6970 /* *** WRITE PORT REGISTER BIT FIELD *** */
6971 struct cmd_write_reg_bit_field_result {
6972 cmdline_fixed_string_t write;
6973 cmdline_fixed_string_t regfield;
6982 cmd_write_reg_bit_field_parsed(void *parsed_result,
6983 __attribute__((unused)) struct cmdline *cl,
6984 __attribute__((unused)) void *data)
6986 struct cmd_write_reg_bit_field_result *res = parsed_result;
6987 port_reg_bit_field_set(res->port_id, res->reg_off,
6988 res->bit1_pos, res->bit2_pos, res->value);
6991 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
6992 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
6994 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
6995 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
6996 regfield, "regfield");
6997 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
6998 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
7000 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
7001 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
7003 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
7004 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
7006 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
7007 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
7009 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
7010 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
7013 cmdline_parse_inst_t cmd_write_reg_bit_field = {
7014 .f = cmd_write_reg_bit_field_parsed,
7016 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
7018 "Set register bit field between bit_x and bit_y included",
7020 (void *)&cmd_write_reg_bit_field_write,
7021 (void *)&cmd_write_reg_bit_field_regfield,
7022 (void *)&cmd_write_reg_bit_field_port_id,
7023 (void *)&cmd_write_reg_bit_field_reg_off,
7024 (void *)&cmd_write_reg_bit_field_bit1_pos,
7025 (void *)&cmd_write_reg_bit_field_bit2_pos,
7026 (void *)&cmd_write_reg_bit_field_value,
7031 /* *** WRITE PORT REGISTER BIT *** */
7032 struct cmd_write_reg_bit_result {
7033 cmdline_fixed_string_t write;
7034 cmdline_fixed_string_t regbit;
7042 cmd_write_reg_bit_parsed(void *parsed_result,
7043 __attribute__((unused)) struct cmdline *cl,
7044 __attribute__((unused)) void *data)
7046 struct cmd_write_reg_bit_result *res = parsed_result;
7047 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
7050 cmdline_parse_token_string_t cmd_write_reg_bit_write =
7051 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
7053 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
7054 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
7056 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
7057 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT16);
7058 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
7059 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
7060 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
7061 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
7062 cmdline_parse_token_num_t cmd_write_reg_bit_value =
7063 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
7065 cmdline_parse_inst_t cmd_write_reg_bit = {
7066 .f = cmd_write_reg_bit_parsed,
7068 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
7071 (void *)&cmd_write_reg_bit_write,
7072 (void *)&cmd_write_reg_bit_regbit,
7073 (void *)&cmd_write_reg_bit_port_id,
7074 (void *)&cmd_write_reg_bit_reg_off,
7075 (void *)&cmd_write_reg_bit_bit_pos,
7076 (void *)&cmd_write_reg_bit_value,
7081 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
7082 struct cmd_read_rxd_txd_result {
7083 cmdline_fixed_string_t read;
7084 cmdline_fixed_string_t rxd_txd;
7091 cmd_read_rxd_txd_parsed(void *parsed_result,
7092 __attribute__((unused)) struct cmdline *cl,
7093 __attribute__((unused)) void *data)
7095 struct cmd_read_rxd_txd_result *res = parsed_result;
7097 if (!strcmp(res->rxd_txd, "rxd"))
7098 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
7099 else if (!strcmp(res->rxd_txd, "txd"))
7100 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
7103 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
7104 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
7105 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
7106 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
7108 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
7109 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT16);
7110 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
7111 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
7112 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
7113 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
7115 cmdline_parse_inst_t cmd_read_rxd_txd = {
7116 .f = cmd_read_rxd_txd_parsed,
7118 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
7120 (void *)&cmd_read_rxd_txd_read,
7121 (void *)&cmd_read_rxd_txd_rxd_txd,
7122 (void *)&cmd_read_rxd_txd_port_id,
7123 (void *)&cmd_read_rxd_txd_queue_id,
7124 (void *)&cmd_read_rxd_txd_desc_id,
7130 struct cmd_quit_result {
7131 cmdline_fixed_string_t quit;
7134 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
7136 __attribute__((unused)) void *data)
7142 cmdline_parse_token_string_t cmd_quit_quit =
7143 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
7145 cmdline_parse_inst_t cmd_quit = {
7146 .f = cmd_quit_parsed,
7148 .help_str = "quit: Exit application",
7150 (void *)&cmd_quit_quit,
7155 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
7156 struct cmd_mac_addr_result {
7157 cmdline_fixed_string_t mac_addr_cmd;
7158 cmdline_fixed_string_t what;
7160 struct ether_addr address;
7163 static void cmd_mac_addr_parsed(void *parsed_result,
7164 __attribute__((unused)) struct cmdline *cl,
7165 __attribute__((unused)) void *data)
7167 struct cmd_mac_addr_result *res = parsed_result;
7170 if (strcmp(res->what, "add") == 0)
7171 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
7172 else if (strcmp(res->what, "set") == 0)
7173 ret = rte_eth_dev_default_mac_addr_set(res->port_num,
7176 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
7178 /* check the return value and print it if is < 0 */
7180 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
7184 cmdline_parse_token_string_t cmd_mac_addr_cmd =
7185 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
7187 cmdline_parse_token_string_t cmd_mac_addr_what =
7188 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
7190 cmdline_parse_token_num_t cmd_mac_addr_portnum =
7191 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num,
7193 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
7194 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
7196 cmdline_parse_inst_t cmd_mac_addr = {
7197 .f = cmd_mac_addr_parsed,
7199 .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
7200 "Add/Remove/Set MAC address on port_id",
7202 (void *)&cmd_mac_addr_cmd,
7203 (void *)&cmd_mac_addr_what,
7204 (void *)&cmd_mac_addr_portnum,
7205 (void *)&cmd_mac_addr_addr,
7211 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
7212 struct cmd_set_qmap_result {
7213 cmdline_fixed_string_t set;
7214 cmdline_fixed_string_t qmap;
7215 cmdline_fixed_string_t what;
7222 cmd_set_qmap_parsed(void *parsed_result,
7223 __attribute__((unused)) struct cmdline *cl,
7224 __attribute__((unused)) void *data)
7226 struct cmd_set_qmap_result *res = parsed_result;
7227 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
7229 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
7232 cmdline_parse_token_string_t cmd_setqmap_set =
7233 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7235 cmdline_parse_token_string_t cmd_setqmap_qmap =
7236 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7238 cmdline_parse_token_string_t cmd_setqmap_what =
7239 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7241 cmdline_parse_token_num_t cmd_setqmap_portid =
7242 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7244 cmdline_parse_token_num_t cmd_setqmap_queueid =
7245 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7247 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
7248 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7251 cmdline_parse_inst_t cmd_set_qmap = {
7252 .f = cmd_set_qmap_parsed,
7254 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
7255 "Set statistics mapping value on tx|rx queue_id of port_id",
7257 (void *)&cmd_setqmap_set,
7258 (void *)&cmd_setqmap_qmap,
7259 (void *)&cmd_setqmap_what,
7260 (void *)&cmd_setqmap_portid,
7261 (void *)&cmd_setqmap_queueid,
7262 (void *)&cmd_setqmap_mapvalue,
7267 /* *** SET OPTION TO HIDE ZERO VALUES FOR XSTATS DISPLAY *** */
7268 struct cmd_set_xstats_hide_zero_result {
7269 cmdline_fixed_string_t keyword;
7270 cmdline_fixed_string_t name;
7271 cmdline_fixed_string_t on_off;
7275 cmd_set_xstats_hide_zero_parsed(void *parsed_result,
7276 __attribute__((unused)) struct cmdline *cl,
7277 __attribute__((unused)) void *data)
7279 struct cmd_set_xstats_hide_zero_result *res;
7280 uint16_t on_off = 0;
7282 res = parsed_result;
7283 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
7284 set_xstats_hide_zero(on_off);
7287 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_keyword =
7288 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
7290 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_name =
7291 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
7292 name, "xstats-hide-zero");
7293 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_on_off =
7294 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
7297 cmdline_parse_inst_t cmd_set_xstats_hide_zero = {
7298 .f = cmd_set_xstats_hide_zero_parsed,
7300 .help_str = "set xstats-hide-zero on|off",
7302 (void *)&cmd_set_xstats_hide_zero_keyword,
7303 (void *)&cmd_set_xstats_hide_zero_name,
7304 (void *)&cmd_set_xstats_hide_zero_on_off,
7309 /* *** CONFIGURE UNICAST HASH TABLE *** */
7310 struct cmd_set_uc_hash_table {
7311 cmdline_fixed_string_t set;
7312 cmdline_fixed_string_t port;
7314 cmdline_fixed_string_t what;
7315 struct ether_addr address;
7316 cmdline_fixed_string_t mode;
7320 cmd_set_uc_hash_parsed(void *parsed_result,
7321 __attribute__((unused)) struct cmdline *cl,
7322 __attribute__((unused)) void *data)
7325 struct cmd_set_uc_hash_table *res = parsed_result;
7327 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7329 if (strcmp(res->what, "uta") == 0)
7330 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
7331 &res->address,(uint8_t)is_on);
7333 printf("bad unicast hash table parameter, return code = %d \n", ret);
7337 cmdline_parse_token_string_t cmd_set_uc_hash_set =
7338 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7340 cmdline_parse_token_string_t cmd_set_uc_hash_port =
7341 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7343 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
7344 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
7346 cmdline_parse_token_string_t cmd_set_uc_hash_what =
7347 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7349 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
7350 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
7352 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
7353 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7356 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
7357 .f = cmd_set_uc_hash_parsed,
7359 .help_str = "set port <port_id> uta <mac_addr> on|off)",
7361 (void *)&cmd_set_uc_hash_set,
7362 (void *)&cmd_set_uc_hash_port,
7363 (void *)&cmd_set_uc_hash_portid,
7364 (void *)&cmd_set_uc_hash_what,
7365 (void *)&cmd_set_uc_hash_mac,
7366 (void *)&cmd_set_uc_hash_mode,
7371 struct cmd_set_uc_all_hash_table {
7372 cmdline_fixed_string_t set;
7373 cmdline_fixed_string_t port;
7375 cmdline_fixed_string_t what;
7376 cmdline_fixed_string_t value;
7377 cmdline_fixed_string_t mode;
7381 cmd_set_uc_all_hash_parsed(void *parsed_result,
7382 __attribute__((unused)) struct cmdline *cl,
7383 __attribute__((unused)) void *data)
7386 struct cmd_set_uc_all_hash_table *res = parsed_result;
7388 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7390 if ((strcmp(res->what, "uta") == 0) &&
7391 (strcmp(res->value, "all") == 0))
7392 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
7394 printf("bad unicast hash table parameter,"
7395 "return code = %d \n", ret);
7398 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
7399 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7401 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
7402 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7404 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
7405 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
7407 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
7408 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7410 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
7411 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7413 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
7414 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7417 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
7418 .f = cmd_set_uc_all_hash_parsed,
7420 .help_str = "set port <port_id> uta all on|off",
7422 (void *)&cmd_set_uc_all_hash_set,
7423 (void *)&cmd_set_uc_all_hash_port,
7424 (void *)&cmd_set_uc_all_hash_portid,
7425 (void *)&cmd_set_uc_all_hash_what,
7426 (void *)&cmd_set_uc_all_hash_value,
7427 (void *)&cmd_set_uc_all_hash_mode,
7432 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
7433 struct cmd_set_vf_macvlan_filter {
7434 cmdline_fixed_string_t set;
7435 cmdline_fixed_string_t port;
7437 cmdline_fixed_string_t vf;
7439 struct ether_addr address;
7440 cmdline_fixed_string_t filter_type;
7441 cmdline_fixed_string_t mode;
7445 cmd_set_vf_macvlan_parsed(void *parsed_result,
7446 __attribute__((unused)) struct cmdline *cl,
7447 __attribute__((unused)) void *data)
7450 struct cmd_set_vf_macvlan_filter *res = parsed_result;
7451 struct rte_eth_mac_filter filter;
7453 memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
7455 rte_memcpy(&filter.mac_addr, &res->address, ETHER_ADDR_LEN);
7457 /* set VF MAC filter */
7461 filter.dst_id = res->vf_id;
7463 if (!strcmp(res->filter_type, "exact-mac"))
7464 filter.filter_type = RTE_MAC_PERFECT_MATCH;
7465 else if (!strcmp(res->filter_type, "exact-mac-vlan"))
7466 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
7467 else if (!strcmp(res->filter_type, "hashmac"))
7468 filter.filter_type = RTE_MAC_HASH_MATCH;
7469 else if (!strcmp(res->filter_type, "hashmac-vlan"))
7470 filter.filter_type = RTE_MACVLAN_HASH_MATCH;
7472 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7475 ret = rte_eth_dev_filter_ctrl(res->port_id,
7476 RTE_ETH_FILTER_MACVLAN,
7480 ret = rte_eth_dev_filter_ctrl(res->port_id,
7481 RTE_ETH_FILTER_MACVLAN,
7482 RTE_ETH_FILTER_DELETE,
7486 printf("bad set MAC hash parameter, return code = %d\n", ret);
7490 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
7491 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7493 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
7494 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7496 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
7497 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7499 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
7500 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7502 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
7503 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7505 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
7506 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7508 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
7509 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7510 filter_type, "exact-mac#exact-mac-vlan"
7511 "#hashmac#hashmac-vlan");
7512 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
7513 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7516 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
7517 .f = cmd_set_vf_macvlan_parsed,
7519 .help_str = "set port <port_id> vf <vf_id> <mac_addr> "
7520 "exact-mac|exact-mac-vlan|hashmac|hashmac-vlan on|off: "
7521 "Exact match rule: exact match of MAC or MAC and VLAN; "
7522 "hash match rule: hash match of MAC and exact match of VLAN",
7524 (void *)&cmd_set_vf_macvlan_set,
7525 (void *)&cmd_set_vf_macvlan_port,
7526 (void *)&cmd_set_vf_macvlan_portid,
7527 (void *)&cmd_set_vf_macvlan_vf,
7528 (void *)&cmd_set_vf_macvlan_vf_id,
7529 (void *)&cmd_set_vf_macvlan_mac,
7530 (void *)&cmd_set_vf_macvlan_filter_type,
7531 (void *)&cmd_set_vf_macvlan_mode,
7536 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
7537 struct cmd_set_vf_traffic {
7538 cmdline_fixed_string_t set;
7539 cmdline_fixed_string_t port;
7541 cmdline_fixed_string_t vf;
7543 cmdline_fixed_string_t what;
7544 cmdline_fixed_string_t mode;
7548 cmd_set_vf_traffic_parsed(void *parsed_result,
7549 __attribute__((unused)) struct cmdline *cl,
7550 __attribute__((unused)) void *data)
7552 struct cmd_set_vf_traffic *res = parsed_result;
7553 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
7554 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7556 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
7559 cmdline_parse_token_string_t cmd_setvf_traffic_set =
7560 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7562 cmdline_parse_token_string_t cmd_setvf_traffic_port =
7563 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7565 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
7566 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
7568 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
7569 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7571 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
7572 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
7574 cmdline_parse_token_string_t cmd_setvf_traffic_what =
7575 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7577 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
7578 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7581 cmdline_parse_inst_t cmd_set_vf_traffic = {
7582 .f = cmd_set_vf_traffic_parsed,
7584 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
7586 (void *)&cmd_setvf_traffic_set,
7587 (void *)&cmd_setvf_traffic_port,
7588 (void *)&cmd_setvf_traffic_portid,
7589 (void *)&cmd_setvf_traffic_vf,
7590 (void *)&cmd_setvf_traffic_vfid,
7591 (void *)&cmd_setvf_traffic_what,
7592 (void *)&cmd_setvf_traffic_mode,
7597 /* *** CONFIGURE VF RECEIVE MODE *** */
7598 struct cmd_set_vf_rxmode {
7599 cmdline_fixed_string_t set;
7600 cmdline_fixed_string_t port;
7602 cmdline_fixed_string_t vf;
7604 cmdline_fixed_string_t what;
7605 cmdline_fixed_string_t mode;
7606 cmdline_fixed_string_t on;
7610 cmd_set_vf_rxmode_parsed(void *parsed_result,
7611 __attribute__((unused)) struct cmdline *cl,
7612 __attribute__((unused)) void *data)
7615 uint16_t rx_mode = 0;
7616 struct cmd_set_vf_rxmode *res = parsed_result;
7618 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
7619 if (!strcmp(res->what,"rxmode")) {
7620 if (!strcmp(res->mode, "AUPE"))
7621 rx_mode |= ETH_VMDQ_ACCEPT_UNTAG;
7622 else if (!strcmp(res->mode, "ROPE"))
7623 rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC;
7624 else if (!strcmp(res->mode, "BAM"))
7625 rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST;
7626 else if (!strncmp(res->mode, "MPE",3))
7627 rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST;
7630 RTE_SET_USED(is_on);
7632 #ifdef RTE_LIBRTE_IXGBE_PMD
7633 if (ret == -ENOTSUP)
7634 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id,
7635 rx_mode, (uint8_t)is_on);
7637 #ifdef RTE_LIBRTE_BNXT_PMD
7638 if (ret == -ENOTSUP)
7639 ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id,
7640 rx_mode, (uint8_t)is_on);
7643 printf("bad VF receive mode parameter, return code = %d \n",
7647 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
7648 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7650 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
7651 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7653 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
7654 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
7656 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
7657 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7659 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
7660 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
7662 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
7663 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7665 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
7666 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7667 mode, "AUPE#ROPE#BAM#MPE");
7668 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
7669 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7672 cmdline_parse_inst_t cmd_set_vf_rxmode = {
7673 .f = cmd_set_vf_rxmode_parsed,
7675 .help_str = "set port <port_id> vf <vf_id> rxmode "
7676 "AUPE|ROPE|BAM|MPE on|off",
7678 (void *)&cmd_set_vf_rxmode_set,
7679 (void *)&cmd_set_vf_rxmode_port,
7680 (void *)&cmd_set_vf_rxmode_portid,
7681 (void *)&cmd_set_vf_rxmode_vf,
7682 (void *)&cmd_set_vf_rxmode_vfid,
7683 (void *)&cmd_set_vf_rxmode_what,
7684 (void *)&cmd_set_vf_rxmode_mode,
7685 (void *)&cmd_set_vf_rxmode_on,
7690 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
7691 struct cmd_vf_mac_addr_result {
7692 cmdline_fixed_string_t mac_addr_cmd;
7693 cmdline_fixed_string_t what;
7694 cmdline_fixed_string_t port;
7696 cmdline_fixed_string_t vf;
7698 struct ether_addr address;
7701 static void cmd_vf_mac_addr_parsed(void *parsed_result,
7702 __attribute__((unused)) struct cmdline *cl,
7703 __attribute__((unused)) void *data)
7705 struct cmd_vf_mac_addr_result *res = parsed_result;
7708 if (strcmp(res->what, "add") != 0)
7711 #ifdef RTE_LIBRTE_I40E_PMD
7712 if (ret == -ENOTSUP)
7713 ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num,
7716 #ifdef RTE_LIBRTE_BNXT_PMD
7717 if (ret == -ENOTSUP)
7718 ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address,
7723 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
7727 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
7728 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7729 mac_addr_cmd,"mac_addr");
7730 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
7731 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7733 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
7734 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7736 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
7737 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
7739 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
7740 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7742 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
7743 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
7745 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
7746 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
7749 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
7750 .f = cmd_vf_mac_addr_parsed,
7752 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
7753 "Add MAC address filtering for a VF on port_id",
7755 (void *)&cmd_vf_mac_addr_cmd,
7756 (void *)&cmd_vf_mac_addr_what,
7757 (void *)&cmd_vf_mac_addr_port,
7758 (void *)&cmd_vf_mac_addr_portnum,
7759 (void *)&cmd_vf_mac_addr_vf,
7760 (void *)&cmd_vf_mac_addr_vfnum,
7761 (void *)&cmd_vf_mac_addr_addr,
7766 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
7767 struct cmd_vf_rx_vlan_filter {
7768 cmdline_fixed_string_t rx_vlan;
7769 cmdline_fixed_string_t what;
7771 cmdline_fixed_string_t port;
7773 cmdline_fixed_string_t vf;
7778 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
7779 __attribute__((unused)) struct cmdline *cl,
7780 __attribute__((unused)) void *data)
7782 struct cmd_vf_rx_vlan_filter *res = parsed_result;
7785 __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
7787 #ifdef RTE_LIBRTE_IXGBE_PMD
7788 if (ret == -ENOTSUP)
7789 ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
7790 res->vlan_id, res->vf_mask, is_add);
7792 #ifdef RTE_LIBRTE_I40E_PMD
7793 if (ret == -ENOTSUP)
7794 ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
7795 res->vlan_id, res->vf_mask, is_add);
7797 #ifdef RTE_LIBRTE_BNXT_PMD
7798 if (ret == -ENOTSUP)
7799 ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id,
7800 res->vlan_id, res->vf_mask, is_add);
7807 printf("invalid vlan_id %d or vf_mask %"PRIu64"\n",
7808 res->vlan_id, res->vf_mask);
7811 printf("invalid port_id %d\n", res->port_id);
7814 printf("function not implemented or supported\n");
7817 printf("programming error: (%s)\n", strerror(-ret));
7821 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
7822 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7823 rx_vlan, "rx_vlan");
7824 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
7825 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7827 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
7828 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7830 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
7831 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7833 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
7834 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7836 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
7837 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7839 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
7840 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7843 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
7844 .f = cmd_vf_rx_vlan_filter_parsed,
7846 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
7847 "(vf_mask = hexadecimal VF mask)",
7849 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
7850 (void *)&cmd_vf_rx_vlan_filter_what,
7851 (void *)&cmd_vf_rx_vlan_filter_vlanid,
7852 (void *)&cmd_vf_rx_vlan_filter_port,
7853 (void *)&cmd_vf_rx_vlan_filter_portid,
7854 (void *)&cmd_vf_rx_vlan_filter_vf,
7855 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
7860 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
7861 struct cmd_queue_rate_limit_result {
7862 cmdline_fixed_string_t set;
7863 cmdline_fixed_string_t port;
7865 cmdline_fixed_string_t queue;
7867 cmdline_fixed_string_t rate;
7871 static void cmd_queue_rate_limit_parsed(void *parsed_result,
7872 __attribute__((unused)) struct cmdline *cl,
7873 __attribute__((unused)) void *data)
7875 struct cmd_queue_rate_limit_result *res = parsed_result;
7878 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
7879 && (strcmp(res->queue, "queue") == 0)
7880 && (strcmp(res->rate, "rate") == 0))
7881 ret = set_queue_rate_limit(res->port_num, res->queue_num,
7884 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
7888 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
7889 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7891 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
7892 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7894 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
7895 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
7897 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
7898 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7900 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
7901 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
7903 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
7904 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7906 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
7907 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
7910 cmdline_parse_inst_t cmd_queue_rate_limit = {
7911 .f = cmd_queue_rate_limit_parsed,
7913 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
7914 "Set rate limit for a queue on port_id",
7916 (void *)&cmd_queue_rate_limit_set,
7917 (void *)&cmd_queue_rate_limit_port,
7918 (void *)&cmd_queue_rate_limit_portnum,
7919 (void *)&cmd_queue_rate_limit_queue,
7920 (void *)&cmd_queue_rate_limit_queuenum,
7921 (void *)&cmd_queue_rate_limit_rate,
7922 (void *)&cmd_queue_rate_limit_ratenum,
7927 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
7928 struct cmd_vf_rate_limit_result {
7929 cmdline_fixed_string_t set;
7930 cmdline_fixed_string_t port;
7932 cmdline_fixed_string_t vf;
7934 cmdline_fixed_string_t rate;
7936 cmdline_fixed_string_t q_msk;
7940 static void cmd_vf_rate_limit_parsed(void *parsed_result,
7941 __attribute__((unused)) struct cmdline *cl,
7942 __attribute__((unused)) void *data)
7944 struct cmd_vf_rate_limit_result *res = parsed_result;
7947 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
7948 && (strcmp(res->vf, "vf") == 0)
7949 && (strcmp(res->rate, "rate") == 0)
7950 && (strcmp(res->q_msk, "queue_mask") == 0))
7951 ret = set_vf_rate_limit(res->port_num, res->vf_num,
7952 res->rate_num, res->q_msk_val);
7954 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
7958 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
7959 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7961 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
7962 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7964 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
7965 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7967 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
7968 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7970 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
7971 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7973 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
7974 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7976 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
7977 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7979 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
7980 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7981 q_msk, "queue_mask");
7982 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
7983 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7986 cmdline_parse_inst_t cmd_vf_rate_limit = {
7987 .f = cmd_vf_rate_limit_parsed,
7989 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
7990 "queue_mask <queue_mask_value>: "
7991 "Set rate limit for queues of VF on port_id",
7993 (void *)&cmd_vf_rate_limit_set,
7994 (void *)&cmd_vf_rate_limit_port,
7995 (void *)&cmd_vf_rate_limit_portnum,
7996 (void *)&cmd_vf_rate_limit_vf,
7997 (void *)&cmd_vf_rate_limit_vfnum,
7998 (void *)&cmd_vf_rate_limit_rate,
7999 (void *)&cmd_vf_rate_limit_ratenum,
8000 (void *)&cmd_vf_rate_limit_q_msk,
8001 (void *)&cmd_vf_rate_limit_q_msk_val,
8006 /* *** ADD TUNNEL FILTER OF A PORT *** */
8007 struct cmd_tunnel_filter_result {
8008 cmdline_fixed_string_t cmd;
8009 cmdline_fixed_string_t what;
8011 struct ether_addr outer_mac;
8012 struct ether_addr inner_mac;
8013 cmdline_ipaddr_t ip_value;
8014 uint16_t inner_vlan;
8015 cmdline_fixed_string_t tunnel_type;
8016 cmdline_fixed_string_t filter_type;
8022 cmd_tunnel_filter_parsed(void *parsed_result,
8023 __attribute__((unused)) struct cmdline *cl,
8024 __attribute__((unused)) void *data)
8026 struct cmd_tunnel_filter_result *res = parsed_result;
8027 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
8030 memset(&tunnel_filter_conf, 0, sizeof(tunnel_filter_conf));
8032 ether_addr_copy(&res->outer_mac, &tunnel_filter_conf.outer_mac);
8033 ether_addr_copy(&res->inner_mac, &tunnel_filter_conf.inner_mac);
8034 tunnel_filter_conf.inner_vlan = res->inner_vlan;
8036 if (res->ip_value.family == AF_INET) {
8037 tunnel_filter_conf.ip_addr.ipv4_addr =
8038 res->ip_value.addr.ipv4.s_addr;
8039 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
8041 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
8042 &(res->ip_value.addr.ipv6),
8043 sizeof(struct in6_addr));
8044 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
8047 if (!strcmp(res->filter_type, "imac-ivlan"))
8048 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
8049 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
8050 tunnel_filter_conf.filter_type =
8051 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
8052 else if (!strcmp(res->filter_type, "imac-tenid"))
8053 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
8054 else if (!strcmp(res->filter_type, "imac"))
8055 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
8056 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
8057 tunnel_filter_conf.filter_type =
8058 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
8059 else if (!strcmp(res->filter_type, "oip"))
8060 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_OIP;
8061 else if (!strcmp(res->filter_type, "iip"))
8062 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IIP;
8064 printf("The filter type is not supported");
8068 if (!strcmp(res->tunnel_type, "vxlan"))
8069 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
8070 else if (!strcmp(res->tunnel_type, "nvgre"))
8071 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE;
8072 else if (!strcmp(res->tunnel_type, "ipingre"))
8073 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_IP_IN_GRE;
8075 printf("The tunnel type %s not supported.\n", res->tunnel_type);
8079 tunnel_filter_conf.tenant_id = res->tenant_id;
8080 tunnel_filter_conf.queue_id = res->queue_num;
8081 if (!strcmp(res->what, "add"))
8082 ret = rte_eth_dev_filter_ctrl(res->port_id,
8083 RTE_ETH_FILTER_TUNNEL,
8085 &tunnel_filter_conf);
8087 ret = rte_eth_dev_filter_ctrl(res->port_id,
8088 RTE_ETH_FILTER_TUNNEL,
8089 RTE_ETH_FILTER_DELETE,
8090 &tunnel_filter_conf);
8092 printf("cmd_tunnel_filter_parsed error: (%s)\n",
8096 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
8097 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8098 cmd, "tunnel_filter");
8099 cmdline_parse_token_string_t cmd_tunnel_filter_what =
8100 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8102 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
8103 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8105 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
8106 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8108 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
8109 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8111 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
8112 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8113 inner_vlan, UINT16);
8114 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
8115 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8117 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
8118 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8119 tunnel_type, "vxlan#nvgre#ipingre");
8121 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
8122 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8123 filter_type, "oip#iip#imac-ivlan#imac-ivlan-tenid#imac-tenid#"
8124 "imac#omac-imac-tenid");
8125 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
8126 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8128 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
8129 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8132 cmdline_parse_inst_t cmd_tunnel_filter = {
8133 .f = cmd_tunnel_filter_parsed,
8135 .help_str = "tunnel_filter add|rm <port_id> <outer_mac> <inner_mac> "
8136 "<ip> <inner_vlan> vxlan|nvgre|ipingre oip|iip|imac-ivlan|"
8137 "imac-ivlan-tenid|imac-tenid|imac|omac-imac-tenid <tenant_id> "
8138 "<queue_id>: Add/Rm tunnel filter of a port",
8140 (void *)&cmd_tunnel_filter_cmd,
8141 (void *)&cmd_tunnel_filter_what,
8142 (void *)&cmd_tunnel_filter_port_id,
8143 (void *)&cmd_tunnel_filter_outer_mac,
8144 (void *)&cmd_tunnel_filter_inner_mac,
8145 (void *)&cmd_tunnel_filter_ip_value,
8146 (void *)&cmd_tunnel_filter_innner_vlan,
8147 (void *)&cmd_tunnel_filter_tunnel_type,
8148 (void *)&cmd_tunnel_filter_filter_type,
8149 (void *)&cmd_tunnel_filter_tenant_id,
8150 (void *)&cmd_tunnel_filter_queue_num,
8155 /* *** CONFIGURE TUNNEL UDP PORT *** */
8156 struct cmd_tunnel_udp_config {
8157 cmdline_fixed_string_t cmd;
8158 cmdline_fixed_string_t what;
8164 cmd_tunnel_udp_config_parsed(void *parsed_result,
8165 __attribute__((unused)) struct cmdline *cl,
8166 __attribute__((unused)) void *data)
8168 struct cmd_tunnel_udp_config *res = parsed_result;
8169 struct rte_eth_udp_tunnel tunnel_udp;
8172 tunnel_udp.udp_port = res->udp_port;
8174 if (!strcmp(res->cmd, "rx_vxlan_port"))
8175 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
8177 if (!strcmp(res->what, "add"))
8178 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
8181 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
8185 printf("udp tunneling add error: (%s)\n", strerror(-ret));
8188 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
8189 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
8190 cmd, "rx_vxlan_port");
8191 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
8192 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
8194 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
8195 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
8197 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
8198 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
8201 cmdline_parse_inst_t cmd_tunnel_udp_config = {
8202 .f = cmd_tunnel_udp_config_parsed,
8204 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
8205 "Add/Remove a tunneling UDP port filter",
8207 (void *)&cmd_tunnel_udp_config_cmd,
8208 (void *)&cmd_tunnel_udp_config_what,
8209 (void *)&cmd_tunnel_udp_config_udp_port,
8210 (void *)&cmd_tunnel_udp_config_port_id,
8215 /* *** GLOBAL CONFIG *** */
8216 struct cmd_global_config_result {
8217 cmdline_fixed_string_t cmd;
8219 cmdline_fixed_string_t cfg_type;
8224 cmd_global_config_parsed(void *parsed_result,
8225 __attribute__((unused)) struct cmdline *cl,
8226 __attribute__((unused)) void *data)
8228 struct cmd_global_config_result *res = parsed_result;
8229 struct rte_eth_global_cfg conf;
8232 memset(&conf, 0, sizeof(conf));
8233 conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN;
8234 conf.cfg.gre_key_len = res->len;
8235 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE,
8236 RTE_ETH_FILTER_SET, &conf);
8238 printf("Global config error\n");
8241 cmdline_parse_token_string_t cmd_global_config_cmd =
8242 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd,
8244 cmdline_parse_token_num_t cmd_global_config_port_id =
8245 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id,
8247 cmdline_parse_token_string_t cmd_global_config_type =
8248 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result,
8249 cfg_type, "gre-key-len");
8250 cmdline_parse_token_num_t cmd_global_config_gre_key_len =
8251 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result,
8254 cmdline_parse_inst_t cmd_global_config = {
8255 .f = cmd_global_config_parsed,
8256 .data = (void *)NULL,
8257 .help_str = "global_config <port_id> gre-key-len <key_len>",
8259 (void *)&cmd_global_config_cmd,
8260 (void *)&cmd_global_config_port_id,
8261 (void *)&cmd_global_config_type,
8262 (void *)&cmd_global_config_gre_key_len,
8267 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
8268 struct cmd_set_mirror_mask_result {
8269 cmdline_fixed_string_t set;
8270 cmdline_fixed_string_t port;
8272 cmdline_fixed_string_t mirror;
8274 cmdline_fixed_string_t what;
8275 cmdline_fixed_string_t value;
8276 cmdline_fixed_string_t dstpool;
8278 cmdline_fixed_string_t on;
8281 cmdline_parse_token_string_t cmd_mirror_mask_set =
8282 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8284 cmdline_parse_token_string_t cmd_mirror_mask_port =
8285 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8287 cmdline_parse_token_num_t cmd_mirror_mask_portid =
8288 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
8290 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
8291 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8292 mirror, "mirror-rule");
8293 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
8294 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
8296 cmdline_parse_token_string_t cmd_mirror_mask_what =
8297 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8298 what, "pool-mirror-up#pool-mirror-down"
8300 cmdline_parse_token_string_t cmd_mirror_mask_value =
8301 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8303 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
8304 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8305 dstpool, "dst-pool");
8306 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
8307 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
8309 cmdline_parse_token_string_t cmd_mirror_mask_on =
8310 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8314 cmd_set_mirror_mask_parsed(void *parsed_result,
8315 __attribute__((unused)) struct cmdline *cl,
8316 __attribute__((unused)) void *data)
8319 struct cmd_set_mirror_mask_result *res = parsed_result;
8320 struct rte_eth_mirror_conf mr_conf;
8322 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
8324 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
8326 mr_conf.dst_pool = res->dstpool_id;
8328 if (!strcmp(res->what, "pool-mirror-up")) {
8329 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
8330 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
8331 } else if (!strcmp(res->what, "pool-mirror-down")) {
8332 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
8333 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
8334 } else if (!strcmp(res->what, "vlan-mirror")) {
8335 mr_conf.rule_type = ETH_MIRROR_VLAN;
8336 nb_item = parse_item_list(res->value, "vlan",
8337 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
8341 for (i = 0; i < nb_item; i++) {
8342 if (vlan_list[i] > ETHER_MAX_VLAN_ID) {
8343 printf("Invalid vlan_id: must be < 4096\n");
8347 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
8348 mr_conf.vlan.vlan_mask |= 1ULL << i;
8352 if (!strcmp(res->on, "on"))
8353 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8356 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8359 printf("mirror rule add error: (%s)\n", strerror(-ret));
8362 cmdline_parse_inst_t cmd_set_mirror_mask = {
8363 .f = cmd_set_mirror_mask_parsed,
8365 .help_str = "set port <port_id> mirror-rule <rule_id> "
8366 "pool-mirror-up|pool-mirror-down|vlan-mirror "
8367 "<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off",
8369 (void *)&cmd_mirror_mask_set,
8370 (void *)&cmd_mirror_mask_port,
8371 (void *)&cmd_mirror_mask_portid,
8372 (void *)&cmd_mirror_mask_mirror,
8373 (void *)&cmd_mirror_mask_ruleid,
8374 (void *)&cmd_mirror_mask_what,
8375 (void *)&cmd_mirror_mask_value,
8376 (void *)&cmd_mirror_mask_dstpool,
8377 (void *)&cmd_mirror_mask_poolid,
8378 (void *)&cmd_mirror_mask_on,
8383 /* *** CONFIGURE VM MIRROR UPLINK/DOWNLINK RULE *** */
8384 struct cmd_set_mirror_link_result {
8385 cmdline_fixed_string_t set;
8386 cmdline_fixed_string_t port;
8388 cmdline_fixed_string_t mirror;
8390 cmdline_fixed_string_t what;
8391 cmdline_fixed_string_t dstpool;
8393 cmdline_fixed_string_t on;
8396 cmdline_parse_token_string_t cmd_mirror_link_set =
8397 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8399 cmdline_parse_token_string_t cmd_mirror_link_port =
8400 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8402 cmdline_parse_token_num_t cmd_mirror_link_portid =
8403 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
8405 cmdline_parse_token_string_t cmd_mirror_link_mirror =
8406 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8407 mirror, "mirror-rule");
8408 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
8409 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
8411 cmdline_parse_token_string_t cmd_mirror_link_what =
8412 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8413 what, "uplink-mirror#downlink-mirror");
8414 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
8415 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8416 dstpool, "dst-pool");
8417 cmdline_parse_token_num_t cmd_mirror_link_poolid =
8418 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
8420 cmdline_parse_token_string_t cmd_mirror_link_on =
8421 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8425 cmd_set_mirror_link_parsed(void *parsed_result,
8426 __attribute__((unused)) struct cmdline *cl,
8427 __attribute__((unused)) void *data)
8430 struct cmd_set_mirror_link_result *res = parsed_result;
8431 struct rte_eth_mirror_conf mr_conf;
8433 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
8434 if (!strcmp(res->what, "uplink-mirror"))
8435 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
8437 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
8439 mr_conf.dst_pool = res->dstpool_id;
8441 if (!strcmp(res->on, "on"))
8442 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8445 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8448 /* check the return value and print it if is < 0 */
8450 printf("mirror rule add error: (%s)\n", strerror(-ret));
8454 cmdline_parse_inst_t cmd_set_mirror_link = {
8455 .f = cmd_set_mirror_link_parsed,
8457 .help_str = "set port <port_id> mirror-rule <rule_id> "
8458 "uplink-mirror|downlink-mirror dst-pool <pool_id> on|off",
8460 (void *)&cmd_mirror_link_set,
8461 (void *)&cmd_mirror_link_port,
8462 (void *)&cmd_mirror_link_portid,
8463 (void *)&cmd_mirror_link_mirror,
8464 (void *)&cmd_mirror_link_ruleid,
8465 (void *)&cmd_mirror_link_what,
8466 (void *)&cmd_mirror_link_dstpool,
8467 (void *)&cmd_mirror_link_poolid,
8468 (void *)&cmd_mirror_link_on,
8473 /* *** RESET VM MIRROR RULE *** */
8474 struct cmd_rm_mirror_rule_result {
8475 cmdline_fixed_string_t reset;
8476 cmdline_fixed_string_t port;
8478 cmdline_fixed_string_t mirror;
8482 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
8483 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
8485 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
8486 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
8488 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
8489 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
8491 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
8492 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
8493 mirror, "mirror-rule");
8494 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
8495 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
8499 cmd_reset_mirror_rule_parsed(void *parsed_result,
8500 __attribute__((unused)) struct cmdline *cl,
8501 __attribute__((unused)) void *data)
8504 struct cmd_set_mirror_link_result *res = parsed_result;
8506 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
8508 printf("mirror rule remove error: (%s)\n", strerror(-ret));
8511 cmdline_parse_inst_t cmd_reset_mirror_rule = {
8512 .f = cmd_reset_mirror_rule_parsed,
8514 .help_str = "reset port <port_id> mirror-rule <rule_id>",
8516 (void *)&cmd_rm_mirror_rule_reset,
8517 (void *)&cmd_rm_mirror_rule_port,
8518 (void *)&cmd_rm_mirror_rule_portid,
8519 (void *)&cmd_rm_mirror_rule_mirror,
8520 (void *)&cmd_rm_mirror_rule_ruleid,
8525 /* ******************************************************************************** */
8527 struct cmd_dump_result {
8528 cmdline_fixed_string_t dump;
8532 dump_struct_sizes(void)
8534 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
8535 DUMP_SIZE(struct rte_mbuf);
8536 DUMP_SIZE(struct rte_mempool);
8537 DUMP_SIZE(struct rte_ring);
8541 static void cmd_dump_parsed(void *parsed_result,
8542 __attribute__((unused)) struct cmdline *cl,
8543 __attribute__((unused)) void *data)
8545 struct cmd_dump_result *res = parsed_result;
8547 if (!strcmp(res->dump, "dump_physmem"))
8548 rte_dump_physmem_layout(stdout);
8549 else if (!strcmp(res->dump, "dump_memzone"))
8550 rte_memzone_dump(stdout);
8551 else if (!strcmp(res->dump, "dump_struct_sizes"))
8552 dump_struct_sizes();
8553 else if (!strcmp(res->dump, "dump_ring"))
8554 rte_ring_list_dump(stdout);
8555 else if (!strcmp(res->dump, "dump_mempool"))
8556 rte_mempool_list_dump(stdout);
8557 else if (!strcmp(res->dump, "dump_devargs"))
8558 rte_eal_devargs_dump(stdout);
8559 else if (!strcmp(res->dump, "dump_log_types"))
8560 rte_log_dump(stdout);
8563 cmdline_parse_token_string_t cmd_dump_dump =
8564 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
8567 "dump_struct_sizes#"
8573 cmdline_parse_inst_t cmd_dump = {
8574 .f = cmd_dump_parsed, /* function to call */
8575 .data = NULL, /* 2nd arg of func */
8576 .help_str = "Dump status",
8577 .tokens = { /* token list, NULL terminated */
8578 (void *)&cmd_dump_dump,
8583 /* ******************************************************************************** */
8585 struct cmd_dump_one_result {
8586 cmdline_fixed_string_t dump;
8587 cmdline_fixed_string_t name;
8590 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
8591 __attribute__((unused)) void *data)
8593 struct cmd_dump_one_result *res = parsed_result;
8595 if (!strcmp(res->dump, "dump_ring")) {
8597 r = rte_ring_lookup(res->name);
8599 cmdline_printf(cl, "Cannot find ring\n");
8602 rte_ring_dump(stdout, r);
8603 } else if (!strcmp(res->dump, "dump_mempool")) {
8604 struct rte_mempool *mp;
8605 mp = rte_mempool_lookup(res->name);
8607 cmdline_printf(cl, "Cannot find mempool\n");
8610 rte_mempool_dump(stdout, mp);
8614 cmdline_parse_token_string_t cmd_dump_one_dump =
8615 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
8616 "dump_ring#dump_mempool");
8618 cmdline_parse_token_string_t cmd_dump_one_name =
8619 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
8621 cmdline_parse_inst_t cmd_dump_one = {
8622 .f = cmd_dump_one_parsed, /* function to call */
8623 .data = NULL, /* 2nd arg of func */
8624 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
8625 .tokens = { /* token list, NULL terminated */
8626 (void *)&cmd_dump_one_dump,
8627 (void *)&cmd_dump_one_name,
8632 /* *** Add/Del syn filter *** */
8633 struct cmd_syn_filter_result {
8634 cmdline_fixed_string_t filter;
8636 cmdline_fixed_string_t ops;
8637 cmdline_fixed_string_t priority;
8638 cmdline_fixed_string_t high;
8639 cmdline_fixed_string_t queue;
8644 cmd_syn_filter_parsed(void *parsed_result,
8645 __attribute__((unused)) struct cmdline *cl,
8646 __attribute__((unused)) void *data)
8648 struct cmd_syn_filter_result *res = parsed_result;
8649 struct rte_eth_syn_filter syn_filter;
8652 ret = rte_eth_dev_filter_supported(res->port_id,
8653 RTE_ETH_FILTER_SYN);
8655 printf("syn filter is not supported on port %u.\n",
8660 memset(&syn_filter, 0, sizeof(syn_filter));
8662 if (!strcmp(res->ops, "add")) {
8663 if (!strcmp(res->high, "high"))
8664 syn_filter.hig_pri = 1;
8666 syn_filter.hig_pri = 0;
8668 syn_filter.queue = res->queue_id;
8669 ret = rte_eth_dev_filter_ctrl(res->port_id,
8674 ret = rte_eth_dev_filter_ctrl(res->port_id,
8676 RTE_ETH_FILTER_DELETE,
8680 printf("syn filter programming error: (%s)\n",
8684 cmdline_parse_token_string_t cmd_syn_filter_filter =
8685 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8686 filter, "syn_filter");
8687 cmdline_parse_token_num_t cmd_syn_filter_port_id =
8688 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
8690 cmdline_parse_token_string_t cmd_syn_filter_ops =
8691 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8693 cmdline_parse_token_string_t cmd_syn_filter_priority =
8694 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8695 priority, "priority");
8696 cmdline_parse_token_string_t cmd_syn_filter_high =
8697 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8699 cmdline_parse_token_string_t cmd_syn_filter_queue =
8700 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8702 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
8703 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
8706 cmdline_parse_inst_t cmd_syn_filter = {
8707 .f = cmd_syn_filter_parsed,
8709 .help_str = "syn_filter <port_id> add|del priority high|low queue "
8710 "<queue_id>: Add/Delete syn filter",
8712 (void *)&cmd_syn_filter_filter,
8713 (void *)&cmd_syn_filter_port_id,
8714 (void *)&cmd_syn_filter_ops,
8715 (void *)&cmd_syn_filter_priority,
8716 (void *)&cmd_syn_filter_high,
8717 (void *)&cmd_syn_filter_queue,
8718 (void *)&cmd_syn_filter_queue_id,
8723 /* *** queue region set *** */
8724 struct cmd_queue_region_result {
8725 cmdline_fixed_string_t set;
8726 cmdline_fixed_string_t port;
8728 cmdline_fixed_string_t cmd;
8729 cmdline_fixed_string_t region;
8731 cmdline_fixed_string_t queue_start_index;
8733 cmdline_fixed_string_t queue_num;
8734 uint8_t queue_num_value;
8738 cmd_queue_region_parsed(void *parsed_result,
8739 __attribute__((unused)) struct cmdline *cl,
8740 __attribute__((unused)) void *data)
8742 struct cmd_queue_region_result *res = parsed_result;
8744 #ifdef RTE_LIBRTE_I40E_PMD
8745 struct rte_pmd_i40e_queue_region_conf region_conf;
8746 enum rte_pmd_i40e_queue_region_op op_type;
8749 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
8752 #ifdef RTE_LIBRTE_I40E_PMD
8753 memset(®ion_conf, 0, sizeof(region_conf));
8754 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_SET;
8755 region_conf.region_id = res->region_id;
8756 region_conf.queue_num = res->queue_num_value;
8757 region_conf.queue_start_index = res->queue_id;
8759 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
8760 op_type, ®ion_conf);
8767 printf("function not implemented or supported\n");
8770 printf("queue region config error: (%s)\n", strerror(-ret));
8774 cmdline_parse_token_string_t cmd_queue_region_set =
8775 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
8777 cmdline_parse_token_string_t cmd_queue_region_port =
8778 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, port, "port");
8779 cmdline_parse_token_num_t cmd_queue_region_port_id =
8780 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
8782 cmdline_parse_token_string_t cmd_queue_region_cmd =
8783 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
8784 cmd, "queue-region");
8785 cmdline_parse_token_string_t cmd_queue_region_id =
8786 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
8787 region, "region_id");
8788 cmdline_parse_token_num_t cmd_queue_region_index =
8789 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
8791 cmdline_parse_token_string_t cmd_queue_region_queue_start_index =
8792 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
8793 queue_start_index, "queue_start_index");
8794 cmdline_parse_token_num_t cmd_queue_region_queue_id =
8795 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
8797 cmdline_parse_token_string_t cmd_queue_region_queue_num =
8798 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
8799 queue_num, "queue_num");
8800 cmdline_parse_token_num_t cmd_queue_region_queue_num_value =
8801 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
8802 queue_num_value, UINT8);
8804 cmdline_parse_inst_t cmd_queue_region = {
8805 .f = cmd_queue_region_parsed,
8807 .help_str = "set port <port_id> queue-region region_id <value> "
8808 "queue_start_index <value> queue_num <value>: Set a queue region",
8810 (void *)&cmd_queue_region_set,
8811 (void *)&cmd_queue_region_port,
8812 (void *)&cmd_queue_region_port_id,
8813 (void *)&cmd_queue_region_cmd,
8814 (void *)&cmd_queue_region_id,
8815 (void *)&cmd_queue_region_index,
8816 (void *)&cmd_queue_region_queue_start_index,
8817 (void *)&cmd_queue_region_queue_id,
8818 (void *)&cmd_queue_region_queue_num,
8819 (void *)&cmd_queue_region_queue_num_value,
8824 /* *** queue region and flowtype set *** */
8825 struct cmd_region_flowtype_result {
8826 cmdline_fixed_string_t set;
8827 cmdline_fixed_string_t port;
8829 cmdline_fixed_string_t cmd;
8830 cmdline_fixed_string_t region;
8832 cmdline_fixed_string_t flowtype;
8833 uint8_t flowtype_id;
8837 cmd_region_flowtype_parsed(void *parsed_result,
8838 __attribute__((unused)) struct cmdline *cl,
8839 __attribute__((unused)) void *data)
8841 struct cmd_region_flowtype_result *res = parsed_result;
8843 #ifdef RTE_LIBRTE_I40E_PMD
8844 struct rte_pmd_i40e_queue_region_conf region_conf;
8845 enum rte_pmd_i40e_queue_region_op op_type;
8848 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
8851 #ifdef RTE_LIBRTE_I40E_PMD
8852 memset(®ion_conf, 0, sizeof(region_conf));
8854 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_FLOWTYPE_SET;
8855 region_conf.region_id = res->region_id;
8856 region_conf.hw_flowtype = res->flowtype_id;
8858 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
8859 op_type, ®ion_conf);
8866 printf("function not implemented or supported\n");
8869 printf("region flowtype config error: (%s)\n", strerror(-ret));
8873 cmdline_parse_token_string_t cmd_region_flowtype_set =
8874 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
8876 cmdline_parse_token_string_t cmd_region_flowtype_port =
8877 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
8879 cmdline_parse_token_num_t cmd_region_flowtype_port_index =
8880 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
8882 cmdline_parse_token_string_t cmd_region_flowtype_cmd =
8883 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
8884 cmd, "queue-region");
8885 cmdline_parse_token_string_t cmd_region_flowtype_index =
8886 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
8887 region, "region_id");
8888 cmdline_parse_token_num_t cmd_region_flowtype_id =
8889 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
8891 cmdline_parse_token_string_t cmd_region_flowtype_flow_index =
8892 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
8893 flowtype, "flowtype");
8894 cmdline_parse_token_num_t cmd_region_flowtype_flow_id =
8895 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
8896 flowtype_id, UINT8);
8897 cmdline_parse_inst_t cmd_region_flowtype = {
8898 .f = cmd_region_flowtype_parsed,
8900 .help_str = "set port <port_id> queue-region region_id <value> "
8901 "flowtype <value>: Set a flowtype region index",
8903 (void *)&cmd_region_flowtype_set,
8904 (void *)&cmd_region_flowtype_port,
8905 (void *)&cmd_region_flowtype_port_index,
8906 (void *)&cmd_region_flowtype_cmd,
8907 (void *)&cmd_region_flowtype_index,
8908 (void *)&cmd_region_flowtype_id,
8909 (void *)&cmd_region_flowtype_flow_index,
8910 (void *)&cmd_region_flowtype_flow_id,
8915 /* *** User Priority (UP) to queue region (region_id) set *** */
8916 struct cmd_user_priority_region_result {
8917 cmdline_fixed_string_t set;
8918 cmdline_fixed_string_t port;
8920 cmdline_fixed_string_t cmd;
8921 cmdline_fixed_string_t user_priority;
8922 uint8_t user_priority_id;
8923 cmdline_fixed_string_t region;
8928 cmd_user_priority_region_parsed(void *parsed_result,
8929 __attribute__((unused)) struct cmdline *cl,
8930 __attribute__((unused)) void *data)
8932 struct cmd_user_priority_region_result *res = parsed_result;
8934 #ifdef RTE_LIBRTE_I40E_PMD
8935 struct rte_pmd_i40e_queue_region_conf region_conf;
8936 enum rte_pmd_i40e_queue_region_op op_type;
8939 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
8942 #ifdef RTE_LIBRTE_I40E_PMD
8943 memset(®ion_conf, 0, sizeof(region_conf));
8944 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_USER_PRIORITY_SET;
8945 region_conf.user_priority = res->user_priority_id;
8946 region_conf.region_id = res->region_id;
8948 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
8949 op_type, ®ion_conf);
8956 printf("function not implemented or supported\n");
8959 printf("user_priority region config error: (%s)\n",
8964 cmdline_parse_token_string_t cmd_user_priority_region_set =
8965 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
8967 cmdline_parse_token_string_t cmd_user_priority_region_port =
8968 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
8970 cmdline_parse_token_num_t cmd_user_priority_region_port_index =
8971 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
8973 cmdline_parse_token_string_t cmd_user_priority_region_cmd =
8974 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
8975 cmd, "queue-region");
8976 cmdline_parse_token_string_t cmd_user_priority_region_UP =
8977 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
8978 user_priority, "UP");
8979 cmdline_parse_token_num_t cmd_user_priority_region_UP_id =
8980 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
8981 user_priority_id, UINT8);
8982 cmdline_parse_token_string_t cmd_user_priority_region_region =
8983 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
8984 region, "region_id");
8985 cmdline_parse_token_num_t cmd_user_priority_region_region_id =
8986 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
8989 cmdline_parse_inst_t cmd_user_priority_region = {
8990 .f = cmd_user_priority_region_parsed,
8992 .help_str = "set port <port_id> queue-region UP <value> "
8993 "region_id <value>: Set the mapping of User Priority (UP) "
8994 "to queue region (region_id) ",
8996 (void *)&cmd_user_priority_region_set,
8997 (void *)&cmd_user_priority_region_port,
8998 (void *)&cmd_user_priority_region_port_index,
8999 (void *)&cmd_user_priority_region_cmd,
9000 (void *)&cmd_user_priority_region_UP,
9001 (void *)&cmd_user_priority_region_UP_id,
9002 (void *)&cmd_user_priority_region_region,
9003 (void *)&cmd_user_priority_region_region_id,
9008 /* *** flush all queue region related configuration *** */
9009 struct cmd_flush_queue_region_result {
9010 cmdline_fixed_string_t set;
9011 cmdline_fixed_string_t port;
9013 cmdline_fixed_string_t cmd;
9014 cmdline_fixed_string_t flush;
9015 cmdline_fixed_string_t what;
9019 cmd_flush_queue_region_parsed(void *parsed_result,
9020 __attribute__((unused)) struct cmdline *cl,
9021 __attribute__((unused)) void *data)
9023 struct cmd_flush_queue_region_result *res = parsed_result;
9025 #ifdef RTE_LIBRTE_I40E_PMD
9026 struct rte_pmd_i40e_queue_region_conf region_conf;
9027 enum rte_pmd_i40e_queue_region_op op_type;
9030 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9033 #ifdef RTE_LIBRTE_I40E_PMD
9034 memset(®ion_conf, 0, sizeof(region_conf));
9036 if (strcmp(res->what, "on") == 0)
9037 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_ON;
9039 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_OFF;
9041 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9042 op_type, ®ion_conf);
9049 printf("function not implemented or supported\n");
9052 printf("queue region config flush error: (%s)\n",
9057 cmdline_parse_token_string_t cmd_flush_queue_region_set =
9058 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9060 cmdline_parse_token_string_t cmd_flush_queue_region_port =
9061 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9063 cmdline_parse_token_num_t cmd_flush_queue_region_port_index =
9064 TOKEN_NUM_INITIALIZER(struct cmd_flush_queue_region_result,
9066 cmdline_parse_token_string_t cmd_flush_queue_region_cmd =
9067 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9068 cmd, "queue-region");
9069 cmdline_parse_token_string_t cmd_flush_queue_region_flush =
9070 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9072 cmdline_parse_token_string_t cmd_flush_queue_region_what =
9073 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9076 cmdline_parse_inst_t cmd_flush_queue_region = {
9077 .f = cmd_flush_queue_region_parsed,
9079 .help_str = "set port <port_id> queue-region flush on|off"
9080 ": flush all queue region related configuration",
9082 (void *)&cmd_flush_queue_region_set,
9083 (void *)&cmd_flush_queue_region_port,
9084 (void *)&cmd_flush_queue_region_port_index,
9085 (void *)&cmd_flush_queue_region_cmd,
9086 (void *)&cmd_flush_queue_region_flush,
9087 (void *)&cmd_flush_queue_region_what,
9092 /* *** get all queue region related configuration info *** */
9093 struct cmd_show_queue_region_info {
9094 cmdline_fixed_string_t show;
9095 cmdline_fixed_string_t port;
9097 cmdline_fixed_string_t cmd;
9101 cmd_show_queue_region_info_parsed(void *parsed_result,
9102 __attribute__((unused)) struct cmdline *cl,
9103 __attribute__((unused)) void *data)
9105 struct cmd_show_queue_region_info *res = parsed_result;
9107 #ifdef RTE_LIBRTE_I40E_PMD
9108 struct rte_pmd_i40e_queue_regions rte_pmd_regions;
9109 enum rte_pmd_i40e_queue_region_op op_type;
9112 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9115 #ifdef RTE_LIBRTE_I40E_PMD
9116 memset(&rte_pmd_regions, 0, sizeof(rte_pmd_regions));
9118 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_INFO_GET;
9120 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9121 op_type, &rte_pmd_regions);
9123 port_queue_region_info_display(res->port_id, &rte_pmd_regions);
9130 printf("function not implemented or supported\n");
9133 printf("queue region config info show error: (%s)\n",
9138 cmdline_parse_token_string_t cmd_show_queue_region_info_get =
9139 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
9141 cmdline_parse_token_string_t cmd_show_queue_region_info_port =
9142 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
9144 cmdline_parse_token_num_t cmd_show_queue_region_info_port_index =
9145 TOKEN_NUM_INITIALIZER(struct cmd_show_queue_region_info,
9147 cmdline_parse_token_string_t cmd_show_queue_region_info_cmd =
9148 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
9149 cmd, "queue-region");
9151 cmdline_parse_inst_t cmd_show_queue_region_info_all = {
9152 .f = cmd_show_queue_region_info_parsed,
9154 .help_str = "show port <port_id> queue-region"
9155 ": show all queue region related configuration info",
9157 (void *)&cmd_show_queue_region_info_get,
9158 (void *)&cmd_show_queue_region_info_port,
9159 (void *)&cmd_show_queue_region_info_port_index,
9160 (void *)&cmd_show_queue_region_info_cmd,
9165 /* *** ADD/REMOVE A 2tuple FILTER *** */
9166 struct cmd_2tuple_filter_result {
9167 cmdline_fixed_string_t filter;
9169 cmdline_fixed_string_t ops;
9170 cmdline_fixed_string_t dst_port;
9171 uint16_t dst_port_value;
9172 cmdline_fixed_string_t protocol;
9173 uint8_t protocol_value;
9174 cmdline_fixed_string_t mask;
9176 cmdline_fixed_string_t tcp_flags;
9177 uint8_t tcp_flags_value;
9178 cmdline_fixed_string_t priority;
9179 uint8_t priority_value;
9180 cmdline_fixed_string_t queue;
9185 cmd_2tuple_filter_parsed(void *parsed_result,
9186 __attribute__((unused)) struct cmdline *cl,
9187 __attribute__((unused)) void *data)
9189 struct rte_eth_ntuple_filter filter;
9190 struct cmd_2tuple_filter_result *res = parsed_result;
9193 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
9195 printf("ntuple filter is not supported on port %u.\n",
9200 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
9202 filter.flags = RTE_2TUPLE_FLAGS;
9203 filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
9204 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
9205 filter.proto = res->protocol_value;
9206 filter.priority = res->priority_value;
9207 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
9208 printf("nonzero tcp_flags is only meaningful"
9209 " when protocol is TCP.\n");
9212 if (res->tcp_flags_value > TCP_FLAG_ALL) {
9213 printf("invalid TCP flags.\n");
9217 if (res->tcp_flags_value != 0) {
9218 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
9219 filter.tcp_flags = res->tcp_flags_value;
9222 /* need convert to big endian. */
9223 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
9224 filter.queue = res->queue_id;
9226 if (!strcmp(res->ops, "add"))
9227 ret = rte_eth_dev_filter_ctrl(res->port_id,
9228 RTE_ETH_FILTER_NTUPLE,
9232 ret = rte_eth_dev_filter_ctrl(res->port_id,
9233 RTE_ETH_FILTER_NTUPLE,
9234 RTE_ETH_FILTER_DELETE,
9237 printf("2tuple filter programming error: (%s)\n",
9242 cmdline_parse_token_string_t cmd_2tuple_filter_filter =
9243 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9244 filter, "2tuple_filter");
9245 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
9246 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9248 cmdline_parse_token_string_t cmd_2tuple_filter_ops =
9249 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9251 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
9252 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9253 dst_port, "dst_port");
9254 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
9255 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9256 dst_port_value, UINT16);
9257 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
9258 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9259 protocol, "protocol");
9260 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
9261 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9262 protocol_value, UINT8);
9263 cmdline_parse_token_string_t cmd_2tuple_filter_mask =
9264 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9266 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value =
9267 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9269 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags =
9270 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9271 tcp_flags, "tcp_flags");
9272 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value =
9273 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9274 tcp_flags_value, UINT8);
9275 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
9276 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9277 priority, "priority");
9278 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
9279 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9280 priority_value, UINT8);
9281 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
9282 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9284 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
9285 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9288 cmdline_parse_inst_t cmd_2tuple_filter = {
9289 .f = cmd_2tuple_filter_parsed,
9291 .help_str = "2tuple_filter <port_id> add|del dst_port <value> protocol "
9292 "<value> mask <value> tcp_flags <value> priority <value> queue "
9293 "<queue_id>: Add a 2tuple filter",
9295 (void *)&cmd_2tuple_filter_filter,
9296 (void *)&cmd_2tuple_filter_port_id,
9297 (void *)&cmd_2tuple_filter_ops,
9298 (void *)&cmd_2tuple_filter_dst_port,
9299 (void *)&cmd_2tuple_filter_dst_port_value,
9300 (void *)&cmd_2tuple_filter_protocol,
9301 (void *)&cmd_2tuple_filter_protocol_value,
9302 (void *)&cmd_2tuple_filter_mask,
9303 (void *)&cmd_2tuple_filter_mask_value,
9304 (void *)&cmd_2tuple_filter_tcp_flags,
9305 (void *)&cmd_2tuple_filter_tcp_flags_value,
9306 (void *)&cmd_2tuple_filter_priority,
9307 (void *)&cmd_2tuple_filter_priority_value,
9308 (void *)&cmd_2tuple_filter_queue,
9309 (void *)&cmd_2tuple_filter_queue_id,
9314 /* *** ADD/REMOVE A 5tuple FILTER *** */
9315 struct cmd_5tuple_filter_result {
9316 cmdline_fixed_string_t filter;
9318 cmdline_fixed_string_t ops;
9319 cmdline_fixed_string_t dst_ip;
9320 cmdline_ipaddr_t dst_ip_value;
9321 cmdline_fixed_string_t src_ip;
9322 cmdline_ipaddr_t src_ip_value;
9323 cmdline_fixed_string_t dst_port;
9324 uint16_t dst_port_value;
9325 cmdline_fixed_string_t src_port;
9326 uint16_t src_port_value;
9327 cmdline_fixed_string_t protocol;
9328 uint8_t protocol_value;
9329 cmdline_fixed_string_t mask;
9331 cmdline_fixed_string_t tcp_flags;
9332 uint8_t tcp_flags_value;
9333 cmdline_fixed_string_t priority;
9334 uint8_t priority_value;
9335 cmdline_fixed_string_t queue;
9340 cmd_5tuple_filter_parsed(void *parsed_result,
9341 __attribute__((unused)) struct cmdline *cl,
9342 __attribute__((unused)) void *data)
9344 struct rte_eth_ntuple_filter filter;
9345 struct cmd_5tuple_filter_result *res = parsed_result;
9348 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
9350 printf("ntuple filter is not supported on port %u.\n",
9355 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
9357 filter.flags = RTE_5TUPLE_FLAGS;
9358 filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0;
9359 filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0;
9360 filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0;
9361 filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
9362 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
9363 filter.proto = res->protocol_value;
9364 filter.priority = res->priority_value;
9365 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
9366 printf("nonzero tcp_flags is only meaningful"
9367 " when protocol is TCP.\n");
9370 if (res->tcp_flags_value > TCP_FLAG_ALL) {
9371 printf("invalid TCP flags.\n");
9375 if (res->tcp_flags_value != 0) {
9376 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
9377 filter.tcp_flags = res->tcp_flags_value;
9380 if (res->dst_ip_value.family == AF_INET)
9381 /* no need to convert, already big endian. */
9382 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
9384 if (filter.dst_ip_mask == 0) {
9385 printf("can not support ipv6 involved compare.\n");
9391 if (res->src_ip_value.family == AF_INET)
9392 /* no need to convert, already big endian. */
9393 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
9395 if (filter.src_ip_mask == 0) {
9396 printf("can not support ipv6 involved compare.\n");
9401 /* need convert to big endian. */
9402 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
9403 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
9404 filter.queue = res->queue_id;
9406 if (!strcmp(res->ops, "add"))
9407 ret = rte_eth_dev_filter_ctrl(res->port_id,
9408 RTE_ETH_FILTER_NTUPLE,
9412 ret = rte_eth_dev_filter_ctrl(res->port_id,
9413 RTE_ETH_FILTER_NTUPLE,
9414 RTE_ETH_FILTER_DELETE,
9417 printf("5tuple filter programming error: (%s)\n",
9421 cmdline_parse_token_string_t cmd_5tuple_filter_filter =
9422 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9423 filter, "5tuple_filter");
9424 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
9425 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9427 cmdline_parse_token_string_t cmd_5tuple_filter_ops =
9428 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9430 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
9431 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9433 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
9434 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
9436 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
9437 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9439 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
9440 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
9442 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
9443 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9444 dst_port, "dst_port");
9445 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
9446 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9447 dst_port_value, UINT16);
9448 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
9449 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9450 src_port, "src_port");
9451 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
9452 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9453 src_port_value, UINT16);
9454 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
9455 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9456 protocol, "protocol");
9457 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
9458 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9459 protocol_value, UINT8);
9460 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
9461 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9463 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
9464 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9466 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags =
9467 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9468 tcp_flags, "tcp_flags");
9469 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value =
9470 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9471 tcp_flags_value, UINT8);
9472 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
9473 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9474 priority, "priority");
9475 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
9476 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9477 priority_value, UINT8);
9478 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
9479 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9481 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
9482 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9485 cmdline_parse_inst_t cmd_5tuple_filter = {
9486 .f = cmd_5tuple_filter_parsed,
9488 .help_str = "5tuple_filter <port_id> add|del dst_ip <value> "
9489 "src_ip <value> dst_port <value> src_port <value> "
9490 "protocol <value> mask <value> tcp_flags <value> "
9491 "priority <value> queue <queue_id>: Add/Del a 5tuple filter",
9493 (void *)&cmd_5tuple_filter_filter,
9494 (void *)&cmd_5tuple_filter_port_id,
9495 (void *)&cmd_5tuple_filter_ops,
9496 (void *)&cmd_5tuple_filter_dst_ip,
9497 (void *)&cmd_5tuple_filter_dst_ip_value,
9498 (void *)&cmd_5tuple_filter_src_ip,
9499 (void *)&cmd_5tuple_filter_src_ip_value,
9500 (void *)&cmd_5tuple_filter_dst_port,
9501 (void *)&cmd_5tuple_filter_dst_port_value,
9502 (void *)&cmd_5tuple_filter_src_port,
9503 (void *)&cmd_5tuple_filter_src_port_value,
9504 (void *)&cmd_5tuple_filter_protocol,
9505 (void *)&cmd_5tuple_filter_protocol_value,
9506 (void *)&cmd_5tuple_filter_mask,
9507 (void *)&cmd_5tuple_filter_mask_value,
9508 (void *)&cmd_5tuple_filter_tcp_flags,
9509 (void *)&cmd_5tuple_filter_tcp_flags_value,
9510 (void *)&cmd_5tuple_filter_priority,
9511 (void *)&cmd_5tuple_filter_priority_value,
9512 (void *)&cmd_5tuple_filter_queue,
9513 (void *)&cmd_5tuple_filter_queue_id,
9518 /* *** ADD/REMOVE A flex FILTER *** */
9519 struct cmd_flex_filter_result {
9520 cmdline_fixed_string_t filter;
9521 cmdline_fixed_string_t ops;
9523 cmdline_fixed_string_t len;
9525 cmdline_fixed_string_t bytes;
9526 cmdline_fixed_string_t bytes_value;
9527 cmdline_fixed_string_t mask;
9528 cmdline_fixed_string_t mask_value;
9529 cmdline_fixed_string_t priority;
9530 uint8_t priority_value;
9531 cmdline_fixed_string_t queue;
9535 static int xdigit2val(unsigned char c)
9540 else if (isupper(c))
9548 cmd_flex_filter_parsed(void *parsed_result,
9549 __attribute__((unused)) struct cmdline *cl,
9550 __attribute__((unused)) void *data)
9553 struct rte_eth_flex_filter filter;
9554 struct cmd_flex_filter_result *res = parsed_result;
9555 char *bytes_ptr, *mask_ptr;
9556 uint16_t len, i, j = 0;
9561 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) {
9562 printf("the len exceed the max length 128\n");
9565 memset(&filter, 0, sizeof(struct rte_eth_flex_filter));
9566 filter.len = res->len_value;
9567 filter.priority = res->priority_value;
9568 filter.queue = res->queue_id;
9569 bytes_ptr = res->bytes_value;
9570 mask_ptr = res->mask_value;
9572 /* translate bytes string to array. */
9573 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
9574 (bytes_ptr[1] == 'X')))
9576 len = strnlen(bytes_ptr, res->len_value * 2);
9577 if (len == 0 || (len % 8 != 0)) {
9578 printf("please check len and bytes input\n");
9581 for (i = 0; i < len; i++) {
9583 if (isxdigit(c) == 0) {
9584 /* invalid characters. */
9585 printf("invalid input\n");
9588 val = xdigit2val(c);
9591 filter.bytes[j] = byte;
9592 printf("bytes[%d]:%02x ", j, filter.bytes[j]);
9599 /* translate mask string to uint8_t array. */
9600 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
9601 (mask_ptr[1] == 'X')))
9603 len = strnlen(mask_ptr, (res->len_value + 3) / 4);
9605 printf("invalid input\n");
9610 for (i = 0; i < len; i++) {
9612 if (isxdigit(c) == 0) {
9613 /* invalid characters. */
9614 printf("invalid input\n");
9617 val = xdigit2val(c);
9620 filter.mask[j] = byte;
9621 printf("mask[%d]:%02x ", j, filter.mask[j]);
9629 if (!strcmp(res->ops, "add"))
9630 ret = rte_eth_dev_filter_ctrl(res->port_id,
9631 RTE_ETH_FILTER_FLEXIBLE,
9635 ret = rte_eth_dev_filter_ctrl(res->port_id,
9636 RTE_ETH_FILTER_FLEXIBLE,
9637 RTE_ETH_FILTER_DELETE,
9641 printf("flex filter setting error: (%s)\n", strerror(-ret));
9644 cmdline_parse_token_string_t cmd_flex_filter_filter =
9645 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9646 filter, "flex_filter");
9647 cmdline_parse_token_num_t cmd_flex_filter_port_id =
9648 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
9650 cmdline_parse_token_string_t cmd_flex_filter_ops =
9651 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9653 cmdline_parse_token_string_t cmd_flex_filter_len =
9654 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9656 cmdline_parse_token_num_t cmd_flex_filter_len_value =
9657 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
9659 cmdline_parse_token_string_t cmd_flex_filter_bytes =
9660 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9662 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
9663 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9665 cmdline_parse_token_string_t cmd_flex_filter_mask =
9666 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9668 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
9669 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9671 cmdline_parse_token_string_t cmd_flex_filter_priority =
9672 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9673 priority, "priority");
9674 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
9675 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
9676 priority_value, UINT8);
9677 cmdline_parse_token_string_t cmd_flex_filter_queue =
9678 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9680 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
9681 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
9683 cmdline_parse_inst_t cmd_flex_filter = {
9684 .f = cmd_flex_filter_parsed,
9686 .help_str = "flex_filter <port_id> add|del len <value> bytes "
9687 "<value> mask <value> priority <value> queue <queue_id>: "
9688 "Add/Del a flex filter",
9690 (void *)&cmd_flex_filter_filter,
9691 (void *)&cmd_flex_filter_port_id,
9692 (void *)&cmd_flex_filter_ops,
9693 (void *)&cmd_flex_filter_len,
9694 (void *)&cmd_flex_filter_len_value,
9695 (void *)&cmd_flex_filter_bytes,
9696 (void *)&cmd_flex_filter_bytes_value,
9697 (void *)&cmd_flex_filter_mask,
9698 (void *)&cmd_flex_filter_mask_value,
9699 (void *)&cmd_flex_filter_priority,
9700 (void *)&cmd_flex_filter_priority_value,
9701 (void *)&cmd_flex_filter_queue,
9702 (void *)&cmd_flex_filter_queue_id,
9707 /* *** Filters Control *** */
9709 /* *** deal with ethertype filter *** */
9710 struct cmd_ethertype_filter_result {
9711 cmdline_fixed_string_t filter;
9713 cmdline_fixed_string_t ops;
9714 cmdline_fixed_string_t mac;
9715 struct ether_addr mac_addr;
9716 cmdline_fixed_string_t ethertype;
9717 uint16_t ethertype_value;
9718 cmdline_fixed_string_t drop;
9719 cmdline_fixed_string_t queue;
9723 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
9724 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9725 filter, "ethertype_filter");
9726 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
9727 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
9729 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
9730 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9732 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
9733 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9734 mac, "mac_addr#mac_ignr");
9735 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
9736 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
9738 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
9739 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9740 ethertype, "ethertype");
9741 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
9742 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
9743 ethertype_value, UINT16);
9744 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
9745 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9747 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
9748 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9750 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
9751 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
9755 cmd_ethertype_filter_parsed(void *parsed_result,
9756 __attribute__((unused)) struct cmdline *cl,
9757 __attribute__((unused)) void *data)
9759 struct cmd_ethertype_filter_result *res = parsed_result;
9760 struct rte_eth_ethertype_filter filter;
9763 ret = rte_eth_dev_filter_supported(res->port_id,
9764 RTE_ETH_FILTER_ETHERTYPE);
9766 printf("ethertype filter is not supported on port %u.\n",
9771 memset(&filter, 0, sizeof(filter));
9772 if (!strcmp(res->mac, "mac_addr")) {
9773 filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
9774 rte_memcpy(&filter.mac_addr, &res->mac_addr,
9775 sizeof(struct ether_addr));
9777 if (!strcmp(res->drop, "drop"))
9778 filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
9779 filter.ether_type = res->ethertype_value;
9780 filter.queue = res->queue_id;
9782 if (!strcmp(res->ops, "add"))
9783 ret = rte_eth_dev_filter_ctrl(res->port_id,
9784 RTE_ETH_FILTER_ETHERTYPE,
9788 ret = rte_eth_dev_filter_ctrl(res->port_id,
9789 RTE_ETH_FILTER_ETHERTYPE,
9790 RTE_ETH_FILTER_DELETE,
9793 printf("ethertype filter programming error: (%s)\n",
9797 cmdline_parse_inst_t cmd_ethertype_filter = {
9798 .f = cmd_ethertype_filter_parsed,
9800 .help_str = "ethertype_filter <port_id> add|del mac_addr|mac_ignr "
9801 "<mac_addr> ethertype <value> drop|fw queue <queue_id>: "
9802 "Add or delete an ethertype filter entry",
9804 (void *)&cmd_ethertype_filter_filter,
9805 (void *)&cmd_ethertype_filter_port_id,
9806 (void *)&cmd_ethertype_filter_ops,
9807 (void *)&cmd_ethertype_filter_mac,
9808 (void *)&cmd_ethertype_filter_mac_addr,
9809 (void *)&cmd_ethertype_filter_ethertype,
9810 (void *)&cmd_ethertype_filter_ethertype_value,
9811 (void *)&cmd_ethertype_filter_drop,
9812 (void *)&cmd_ethertype_filter_queue,
9813 (void *)&cmd_ethertype_filter_queue_id,
9818 /* *** deal with flow director filter *** */
9819 struct cmd_flow_director_result {
9820 cmdline_fixed_string_t flow_director_filter;
9822 cmdline_fixed_string_t mode;
9823 cmdline_fixed_string_t mode_value;
9824 cmdline_fixed_string_t ops;
9825 cmdline_fixed_string_t flow;
9826 cmdline_fixed_string_t flow_type;
9827 cmdline_fixed_string_t ether;
9828 uint16_t ether_type;
9829 cmdline_fixed_string_t src;
9830 cmdline_ipaddr_t ip_src;
9832 cmdline_fixed_string_t dst;
9833 cmdline_ipaddr_t ip_dst;
9835 cmdline_fixed_string_t verify_tag;
9836 uint32_t verify_tag_value;
9837 cmdline_ipaddr_t tos;
9839 cmdline_ipaddr_t proto;
9840 uint8_t proto_value;
9841 cmdline_ipaddr_t ttl;
9843 cmdline_fixed_string_t vlan;
9844 uint16_t vlan_value;
9845 cmdline_fixed_string_t flexbytes;
9846 cmdline_fixed_string_t flexbytes_value;
9847 cmdline_fixed_string_t pf_vf;
9848 cmdline_fixed_string_t drop;
9849 cmdline_fixed_string_t queue;
9851 cmdline_fixed_string_t fd_id;
9852 uint32_t fd_id_value;
9853 cmdline_fixed_string_t mac;
9854 struct ether_addr mac_addr;
9855 cmdline_fixed_string_t tunnel;
9856 cmdline_fixed_string_t tunnel_type;
9857 cmdline_fixed_string_t tunnel_id;
9858 uint32_t tunnel_id_value;
9862 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
9865 const char *p, *p0 = q_arg;
9867 unsigned long int_fld;
9868 char *str_fld[max_num];
9873 p = strchr(p0, '(');
9877 p0 = strchr(p, ')');
9882 if (size >= sizeof(s))
9885 snprintf(s, sizeof(s), "%.*s", size, p);
9886 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
9887 if (ret < 0 || ret > max_num)
9889 for (i = 0; i < ret; i++) {
9891 int_fld = strtoul(str_fld[i], &end, 0);
9892 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
9894 flexbytes[i] = (uint8_t)int_fld;
9900 str2flowtype(char *string)
9903 static const struct {
9906 } flowtype_str[] = {
9907 {"raw", RTE_ETH_FLOW_RAW},
9908 {"ipv4", RTE_ETH_FLOW_IPV4},
9909 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
9910 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
9911 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
9912 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
9913 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
9914 {"ipv6", RTE_ETH_FLOW_IPV6},
9915 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
9916 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
9917 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
9918 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
9919 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
9920 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
9923 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
9924 if (!strcmp(flowtype_str[i].str, string))
9925 return flowtype_str[i].type;
9928 if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64)
9929 return (uint16_t)atoi(string);
9931 return RTE_ETH_FLOW_UNKNOWN;
9934 static enum rte_eth_fdir_tunnel_type
9935 str2fdir_tunneltype(char *string)
9939 static const struct {
9941 enum rte_eth_fdir_tunnel_type type;
9942 } tunneltype_str[] = {
9943 {"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE},
9944 {"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN},
9947 for (i = 0; i < RTE_DIM(tunneltype_str); i++) {
9948 if (!strcmp(tunneltype_str[i].str, string))
9949 return tunneltype_str[i].type;
9951 return RTE_FDIR_TUNNEL_TYPE_UNKNOWN;
9954 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
9956 if ((ip_addr).family == AF_INET) \
9957 (ip) = (ip_addr).addr.ipv4.s_addr; \
9959 printf("invalid parameter.\n"); \
9964 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
9966 if ((ip_addr).family == AF_INET6) \
9968 &((ip_addr).addr.ipv6), \
9969 sizeof(struct in6_addr)); \
9971 printf("invalid parameter.\n"); \
9977 cmd_flow_director_filter_parsed(void *parsed_result,
9978 __attribute__((unused)) struct cmdline *cl,
9979 __attribute__((unused)) void *data)
9981 struct cmd_flow_director_result *res = parsed_result;
9982 struct rte_eth_fdir_filter entry;
9983 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
9985 unsigned long vf_id;
9988 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
9990 printf("flow director is not supported on port %u.\n",
9994 memset(flexbytes, 0, sizeof(flexbytes));
9995 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
9997 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
9998 if (strcmp(res->mode_value, "MAC-VLAN")) {
9999 printf("Please set mode to MAC-VLAN.\n");
10002 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
10003 if (strcmp(res->mode_value, "Tunnel")) {
10004 printf("Please set mode to Tunnel.\n");
10008 if (strcmp(res->mode_value, "IP")) {
10009 printf("Please set mode to IP.\n");
10012 entry.input.flow_type = str2flowtype(res->flow_type);
10015 ret = parse_flexbytes(res->flexbytes_value,
10017 RTE_ETH_FDIR_MAX_FLEXLEN);
10019 printf("error: Cannot parse flexbytes input.\n");
10023 switch (entry.input.flow_type) {
10024 case RTE_ETH_FLOW_FRAG_IPV4:
10025 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
10026 entry.input.flow.ip4_flow.proto = res->proto_value;
10028 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
10029 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
10030 IPV4_ADDR_TO_UINT(res->ip_dst,
10031 entry.input.flow.ip4_flow.dst_ip);
10032 IPV4_ADDR_TO_UINT(res->ip_src,
10033 entry.input.flow.ip4_flow.src_ip);
10034 entry.input.flow.ip4_flow.tos = res->tos_value;
10035 entry.input.flow.ip4_flow.ttl = res->ttl_value;
10036 /* need convert to big endian. */
10037 entry.input.flow.udp4_flow.dst_port =
10038 rte_cpu_to_be_16(res->port_dst);
10039 entry.input.flow.udp4_flow.src_port =
10040 rte_cpu_to_be_16(res->port_src);
10042 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
10043 IPV4_ADDR_TO_UINT(res->ip_dst,
10044 entry.input.flow.sctp4_flow.ip.dst_ip);
10045 IPV4_ADDR_TO_UINT(res->ip_src,
10046 entry.input.flow.sctp4_flow.ip.src_ip);
10047 entry.input.flow.ip4_flow.tos = res->tos_value;
10048 entry.input.flow.ip4_flow.ttl = res->ttl_value;
10049 /* need convert to big endian. */
10050 entry.input.flow.sctp4_flow.dst_port =
10051 rte_cpu_to_be_16(res->port_dst);
10052 entry.input.flow.sctp4_flow.src_port =
10053 rte_cpu_to_be_16(res->port_src);
10054 entry.input.flow.sctp4_flow.verify_tag =
10055 rte_cpu_to_be_32(res->verify_tag_value);
10057 case RTE_ETH_FLOW_FRAG_IPV6:
10058 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
10059 entry.input.flow.ipv6_flow.proto = res->proto_value;
10061 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
10062 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
10063 IPV6_ADDR_TO_ARRAY(res->ip_dst,
10064 entry.input.flow.ipv6_flow.dst_ip);
10065 IPV6_ADDR_TO_ARRAY(res->ip_src,
10066 entry.input.flow.ipv6_flow.src_ip);
10067 entry.input.flow.ipv6_flow.tc = res->tos_value;
10068 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
10069 /* need convert to big endian. */
10070 entry.input.flow.udp6_flow.dst_port =
10071 rte_cpu_to_be_16(res->port_dst);
10072 entry.input.flow.udp6_flow.src_port =
10073 rte_cpu_to_be_16(res->port_src);
10075 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
10076 IPV6_ADDR_TO_ARRAY(res->ip_dst,
10077 entry.input.flow.sctp6_flow.ip.dst_ip);
10078 IPV6_ADDR_TO_ARRAY(res->ip_src,
10079 entry.input.flow.sctp6_flow.ip.src_ip);
10080 entry.input.flow.ipv6_flow.tc = res->tos_value;
10081 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
10082 /* need convert to big endian. */
10083 entry.input.flow.sctp6_flow.dst_port =
10084 rte_cpu_to_be_16(res->port_dst);
10085 entry.input.flow.sctp6_flow.src_port =
10086 rte_cpu_to_be_16(res->port_src);
10087 entry.input.flow.sctp6_flow.verify_tag =
10088 rte_cpu_to_be_32(res->verify_tag_value);
10090 case RTE_ETH_FLOW_L2_PAYLOAD:
10091 entry.input.flow.l2_flow.ether_type =
10092 rte_cpu_to_be_16(res->ether_type);
10098 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN)
10099 rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr,
10101 sizeof(struct ether_addr));
10103 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
10104 rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr,
10106 sizeof(struct ether_addr));
10107 entry.input.flow.tunnel_flow.tunnel_type =
10108 str2fdir_tunneltype(res->tunnel_type);
10109 entry.input.flow.tunnel_flow.tunnel_id =
10110 rte_cpu_to_be_32(res->tunnel_id_value);
10113 rte_memcpy(entry.input.flow_ext.flexbytes,
10115 RTE_ETH_FDIR_MAX_FLEXLEN);
10117 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
10119 entry.action.flex_off = 0; /*use 0 by default */
10120 if (!strcmp(res->drop, "drop"))
10121 entry.action.behavior = RTE_ETH_FDIR_REJECT;
10123 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
10125 if (fdir_conf.mode != RTE_FDIR_MODE_PERFECT_MAC_VLAN &&
10126 fdir_conf.mode != RTE_FDIR_MODE_PERFECT_TUNNEL) {
10127 if (!strcmp(res->pf_vf, "pf"))
10128 entry.input.flow_ext.is_vf = 0;
10129 else if (!strncmp(res->pf_vf, "vf", 2)) {
10130 struct rte_eth_dev_info dev_info;
10132 memset(&dev_info, 0, sizeof(dev_info));
10133 rte_eth_dev_info_get(res->port_id, &dev_info);
10135 vf_id = strtoul(res->pf_vf + 2, &end, 10);
10136 if (errno != 0 || *end != '\0' ||
10137 vf_id >= dev_info.max_vfs) {
10138 printf("invalid parameter %s.\n", res->pf_vf);
10141 entry.input.flow_ext.is_vf = 1;
10142 entry.input.flow_ext.dst_id = (uint16_t)vf_id;
10144 printf("invalid parameter %s.\n", res->pf_vf);
10149 /* set to report FD ID by default */
10150 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
10151 entry.action.rx_queue = res->queue_id;
10152 entry.soft_id = res->fd_id_value;
10153 if (!strcmp(res->ops, "add"))
10154 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10155 RTE_ETH_FILTER_ADD, &entry);
10156 else if (!strcmp(res->ops, "del"))
10157 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10158 RTE_ETH_FILTER_DELETE, &entry);
10160 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10161 RTE_ETH_FILTER_UPDATE, &entry);
10163 printf("flow director programming error: (%s)\n",
10167 cmdline_parse_token_string_t cmd_flow_director_filter =
10168 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10169 flow_director_filter, "flow_director_filter");
10170 cmdline_parse_token_num_t cmd_flow_director_port_id =
10171 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10173 cmdline_parse_token_string_t cmd_flow_director_ops =
10174 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10175 ops, "add#del#update");
10176 cmdline_parse_token_string_t cmd_flow_director_flow =
10177 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10179 cmdline_parse_token_string_t cmd_flow_director_flow_type =
10180 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10181 flow_type, "ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
10182 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload");
10183 cmdline_parse_token_string_t cmd_flow_director_ether =
10184 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10186 cmdline_parse_token_num_t cmd_flow_director_ether_type =
10187 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10188 ether_type, UINT16);
10189 cmdline_parse_token_string_t cmd_flow_director_src =
10190 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10192 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
10193 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
10195 cmdline_parse_token_num_t cmd_flow_director_port_src =
10196 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10198 cmdline_parse_token_string_t cmd_flow_director_dst =
10199 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10201 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
10202 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
10204 cmdline_parse_token_num_t cmd_flow_director_port_dst =
10205 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10207 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
10208 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10209 verify_tag, "verify_tag");
10210 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
10211 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10212 verify_tag_value, UINT32);
10213 cmdline_parse_token_string_t cmd_flow_director_tos =
10214 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10216 cmdline_parse_token_num_t cmd_flow_director_tos_value =
10217 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10219 cmdline_parse_token_string_t cmd_flow_director_proto =
10220 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10222 cmdline_parse_token_num_t cmd_flow_director_proto_value =
10223 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10224 proto_value, UINT8);
10225 cmdline_parse_token_string_t cmd_flow_director_ttl =
10226 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10228 cmdline_parse_token_num_t cmd_flow_director_ttl_value =
10229 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10231 cmdline_parse_token_string_t cmd_flow_director_vlan =
10232 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10234 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
10235 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10236 vlan_value, UINT16);
10237 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
10238 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10239 flexbytes, "flexbytes");
10240 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
10241 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10242 flexbytes_value, NULL);
10243 cmdline_parse_token_string_t cmd_flow_director_drop =
10244 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10246 cmdline_parse_token_string_t cmd_flow_director_pf_vf =
10247 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10249 cmdline_parse_token_string_t cmd_flow_director_queue =
10250 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10252 cmdline_parse_token_num_t cmd_flow_director_queue_id =
10253 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10255 cmdline_parse_token_string_t cmd_flow_director_fd_id =
10256 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10258 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
10259 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10260 fd_id_value, UINT32);
10262 cmdline_parse_token_string_t cmd_flow_director_mode =
10263 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10265 cmdline_parse_token_string_t cmd_flow_director_mode_ip =
10266 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10268 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan =
10269 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10270 mode_value, "MAC-VLAN");
10271 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel =
10272 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10273 mode_value, "Tunnel");
10274 cmdline_parse_token_string_t cmd_flow_director_mac =
10275 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10277 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr =
10278 TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result,
10280 cmdline_parse_token_string_t cmd_flow_director_tunnel =
10281 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10283 cmdline_parse_token_string_t cmd_flow_director_tunnel_type =
10284 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10285 tunnel_type, "NVGRE#VxLAN");
10286 cmdline_parse_token_string_t cmd_flow_director_tunnel_id =
10287 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10288 tunnel_id, "tunnel-id");
10289 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value =
10290 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10291 tunnel_id_value, UINT32);
10293 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
10294 .f = cmd_flow_director_filter_parsed,
10296 .help_str = "flow_director_filter <port_id> mode IP add|del|update flow"
10297 " ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
10298 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
10299 "l2_payload src <src_ip> dst <dst_ip> tos <tos_value> "
10300 "proto <proto_value> ttl <ttl_value> vlan <vlan_value> "
10301 "flexbytes <flexbyte_values> drop|fw <pf_vf> queue <queue_id> "
10302 "fd_id <fd_id_value>: "
10303 "Add or delete an ip flow director entry on NIC",
10305 (void *)&cmd_flow_director_filter,
10306 (void *)&cmd_flow_director_port_id,
10307 (void *)&cmd_flow_director_mode,
10308 (void *)&cmd_flow_director_mode_ip,
10309 (void *)&cmd_flow_director_ops,
10310 (void *)&cmd_flow_director_flow,
10311 (void *)&cmd_flow_director_flow_type,
10312 (void *)&cmd_flow_director_src,
10313 (void *)&cmd_flow_director_ip_src,
10314 (void *)&cmd_flow_director_dst,
10315 (void *)&cmd_flow_director_ip_dst,
10316 (void *)&cmd_flow_director_tos,
10317 (void *)&cmd_flow_director_tos_value,
10318 (void *)&cmd_flow_director_proto,
10319 (void *)&cmd_flow_director_proto_value,
10320 (void *)&cmd_flow_director_ttl,
10321 (void *)&cmd_flow_director_ttl_value,
10322 (void *)&cmd_flow_director_vlan,
10323 (void *)&cmd_flow_director_vlan_value,
10324 (void *)&cmd_flow_director_flexbytes,
10325 (void *)&cmd_flow_director_flexbytes_value,
10326 (void *)&cmd_flow_director_drop,
10327 (void *)&cmd_flow_director_pf_vf,
10328 (void *)&cmd_flow_director_queue,
10329 (void *)&cmd_flow_director_queue_id,
10330 (void *)&cmd_flow_director_fd_id,
10331 (void *)&cmd_flow_director_fd_id_value,
10336 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
10337 .f = cmd_flow_director_filter_parsed,
10339 .help_str = "flow_director_filter ... : Add or delete an udp/tcp flow "
10340 "director entry on NIC",
10342 (void *)&cmd_flow_director_filter,
10343 (void *)&cmd_flow_director_port_id,
10344 (void *)&cmd_flow_director_mode,
10345 (void *)&cmd_flow_director_mode_ip,
10346 (void *)&cmd_flow_director_ops,
10347 (void *)&cmd_flow_director_flow,
10348 (void *)&cmd_flow_director_flow_type,
10349 (void *)&cmd_flow_director_src,
10350 (void *)&cmd_flow_director_ip_src,
10351 (void *)&cmd_flow_director_port_src,
10352 (void *)&cmd_flow_director_dst,
10353 (void *)&cmd_flow_director_ip_dst,
10354 (void *)&cmd_flow_director_port_dst,
10355 (void *)&cmd_flow_director_tos,
10356 (void *)&cmd_flow_director_tos_value,
10357 (void *)&cmd_flow_director_ttl,
10358 (void *)&cmd_flow_director_ttl_value,
10359 (void *)&cmd_flow_director_vlan,
10360 (void *)&cmd_flow_director_vlan_value,
10361 (void *)&cmd_flow_director_flexbytes,
10362 (void *)&cmd_flow_director_flexbytes_value,
10363 (void *)&cmd_flow_director_drop,
10364 (void *)&cmd_flow_director_pf_vf,
10365 (void *)&cmd_flow_director_queue,
10366 (void *)&cmd_flow_director_queue_id,
10367 (void *)&cmd_flow_director_fd_id,
10368 (void *)&cmd_flow_director_fd_id_value,
10373 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
10374 .f = cmd_flow_director_filter_parsed,
10376 .help_str = "flow_director_filter ... : Add or delete a sctp flow "
10377 "director entry on NIC",
10379 (void *)&cmd_flow_director_filter,
10380 (void *)&cmd_flow_director_port_id,
10381 (void *)&cmd_flow_director_mode,
10382 (void *)&cmd_flow_director_mode_ip,
10383 (void *)&cmd_flow_director_ops,
10384 (void *)&cmd_flow_director_flow,
10385 (void *)&cmd_flow_director_flow_type,
10386 (void *)&cmd_flow_director_src,
10387 (void *)&cmd_flow_director_ip_src,
10388 (void *)&cmd_flow_director_port_dst,
10389 (void *)&cmd_flow_director_dst,
10390 (void *)&cmd_flow_director_ip_dst,
10391 (void *)&cmd_flow_director_port_dst,
10392 (void *)&cmd_flow_director_verify_tag,
10393 (void *)&cmd_flow_director_verify_tag_value,
10394 (void *)&cmd_flow_director_tos,
10395 (void *)&cmd_flow_director_tos_value,
10396 (void *)&cmd_flow_director_ttl,
10397 (void *)&cmd_flow_director_ttl_value,
10398 (void *)&cmd_flow_director_vlan,
10399 (void *)&cmd_flow_director_vlan_value,
10400 (void *)&cmd_flow_director_flexbytes,
10401 (void *)&cmd_flow_director_flexbytes_value,
10402 (void *)&cmd_flow_director_drop,
10403 (void *)&cmd_flow_director_pf_vf,
10404 (void *)&cmd_flow_director_queue,
10405 (void *)&cmd_flow_director_queue_id,
10406 (void *)&cmd_flow_director_fd_id,
10407 (void *)&cmd_flow_director_fd_id_value,
10412 cmdline_parse_inst_t cmd_add_del_l2_flow_director = {
10413 .f = cmd_flow_director_filter_parsed,
10415 .help_str = "flow_director_filter ... : Add or delete a L2 flow "
10416 "director entry on NIC",
10418 (void *)&cmd_flow_director_filter,
10419 (void *)&cmd_flow_director_port_id,
10420 (void *)&cmd_flow_director_mode,
10421 (void *)&cmd_flow_director_mode_ip,
10422 (void *)&cmd_flow_director_ops,
10423 (void *)&cmd_flow_director_flow,
10424 (void *)&cmd_flow_director_flow_type,
10425 (void *)&cmd_flow_director_ether,
10426 (void *)&cmd_flow_director_ether_type,
10427 (void *)&cmd_flow_director_flexbytes,
10428 (void *)&cmd_flow_director_flexbytes_value,
10429 (void *)&cmd_flow_director_drop,
10430 (void *)&cmd_flow_director_pf_vf,
10431 (void *)&cmd_flow_director_queue,
10432 (void *)&cmd_flow_director_queue_id,
10433 (void *)&cmd_flow_director_fd_id,
10434 (void *)&cmd_flow_director_fd_id_value,
10439 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = {
10440 .f = cmd_flow_director_filter_parsed,
10442 .help_str = "flow_director_filter ... : Add or delete a MAC VLAN flow "
10443 "director entry on NIC",
10445 (void *)&cmd_flow_director_filter,
10446 (void *)&cmd_flow_director_port_id,
10447 (void *)&cmd_flow_director_mode,
10448 (void *)&cmd_flow_director_mode_mac_vlan,
10449 (void *)&cmd_flow_director_ops,
10450 (void *)&cmd_flow_director_mac,
10451 (void *)&cmd_flow_director_mac_addr,
10452 (void *)&cmd_flow_director_vlan,
10453 (void *)&cmd_flow_director_vlan_value,
10454 (void *)&cmd_flow_director_flexbytes,
10455 (void *)&cmd_flow_director_flexbytes_value,
10456 (void *)&cmd_flow_director_drop,
10457 (void *)&cmd_flow_director_queue,
10458 (void *)&cmd_flow_director_queue_id,
10459 (void *)&cmd_flow_director_fd_id,
10460 (void *)&cmd_flow_director_fd_id_value,
10465 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = {
10466 .f = cmd_flow_director_filter_parsed,
10468 .help_str = "flow_director_filter ... : Add or delete a tunnel flow "
10469 "director entry on NIC",
10471 (void *)&cmd_flow_director_filter,
10472 (void *)&cmd_flow_director_port_id,
10473 (void *)&cmd_flow_director_mode,
10474 (void *)&cmd_flow_director_mode_tunnel,
10475 (void *)&cmd_flow_director_ops,
10476 (void *)&cmd_flow_director_mac,
10477 (void *)&cmd_flow_director_mac_addr,
10478 (void *)&cmd_flow_director_vlan,
10479 (void *)&cmd_flow_director_vlan_value,
10480 (void *)&cmd_flow_director_tunnel,
10481 (void *)&cmd_flow_director_tunnel_type,
10482 (void *)&cmd_flow_director_tunnel_id,
10483 (void *)&cmd_flow_director_tunnel_id_value,
10484 (void *)&cmd_flow_director_flexbytes,
10485 (void *)&cmd_flow_director_flexbytes_value,
10486 (void *)&cmd_flow_director_drop,
10487 (void *)&cmd_flow_director_queue,
10488 (void *)&cmd_flow_director_queue_id,
10489 (void *)&cmd_flow_director_fd_id,
10490 (void *)&cmd_flow_director_fd_id_value,
10495 struct cmd_flush_flow_director_result {
10496 cmdline_fixed_string_t flush_flow_director;
10500 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
10501 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
10502 flush_flow_director, "flush_flow_director");
10503 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
10504 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
10508 cmd_flush_flow_director_parsed(void *parsed_result,
10509 __attribute__((unused)) struct cmdline *cl,
10510 __attribute__((unused)) void *data)
10512 struct cmd_flow_director_result *res = parsed_result;
10515 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
10517 printf("flow director is not supported on port %u.\n",
10522 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10523 RTE_ETH_FILTER_FLUSH, NULL);
10525 printf("flow director table flushing error: (%s)\n",
10529 cmdline_parse_inst_t cmd_flush_flow_director = {
10530 .f = cmd_flush_flow_director_parsed,
10532 .help_str = "flush_flow_director <port_id>: "
10533 "Flush all flow director entries of a device on NIC",
10535 (void *)&cmd_flush_flow_director_flush,
10536 (void *)&cmd_flush_flow_director_port_id,
10541 /* *** deal with flow director mask *** */
10542 struct cmd_flow_director_mask_result {
10543 cmdline_fixed_string_t flow_director_mask;
10545 cmdline_fixed_string_t mode;
10546 cmdline_fixed_string_t mode_value;
10547 cmdline_fixed_string_t vlan;
10548 uint16_t vlan_mask;
10549 cmdline_fixed_string_t src_mask;
10550 cmdline_ipaddr_t ipv4_src;
10551 cmdline_ipaddr_t ipv6_src;
10553 cmdline_fixed_string_t dst_mask;
10554 cmdline_ipaddr_t ipv4_dst;
10555 cmdline_ipaddr_t ipv6_dst;
10557 cmdline_fixed_string_t mac;
10558 uint8_t mac_addr_byte_mask;
10559 cmdline_fixed_string_t tunnel_id;
10560 uint32_t tunnel_id_mask;
10561 cmdline_fixed_string_t tunnel_type;
10562 uint8_t tunnel_type_mask;
10566 cmd_flow_director_mask_parsed(void *parsed_result,
10567 __attribute__((unused)) struct cmdline *cl,
10568 __attribute__((unused)) void *data)
10570 struct cmd_flow_director_mask_result *res = parsed_result;
10571 struct rte_eth_fdir_masks *mask;
10572 struct rte_port *port;
10574 if (res->port_id > nb_ports) {
10575 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
10579 port = &ports[res->port_id];
10580 /** Check if the port is not started **/
10581 if (port->port_status != RTE_PORT_STOPPED) {
10582 printf("Please stop port %d first\n", res->port_id);
10586 mask = &port->dev_conf.fdir_conf.mask;
10588 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
10589 if (strcmp(res->mode_value, "MAC-VLAN")) {
10590 printf("Please set mode to MAC-VLAN.\n");
10594 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10595 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
10596 if (strcmp(res->mode_value, "Tunnel")) {
10597 printf("Please set mode to Tunnel.\n");
10601 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10602 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
10603 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
10604 mask->tunnel_type_mask = res->tunnel_type_mask;
10606 if (strcmp(res->mode_value, "IP")) {
10607 printf("Please set mode to IP.\n");
10611 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10612 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
10613 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
10614 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
10615 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
10616 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
10617 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
10620 cmd_reconfig_device_queue(res->port_id, 1, 1);
10623 cmdline_parse_token_string_t cmd_flow_director_mask =
10624 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10625 flow_director_mask, "flow_director_mask");
10626 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
10627 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10629 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
10630 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10632 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
10633 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10634 vlan_mask, UINT16);
10635 cmdline_parse_token_string_t cmd_flow_director_mask_src =
10636 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10637 src_mask, "src_mask");
10638 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
10639 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10641 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
10642 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10644 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
10645 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10647 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
10648 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10649 dst_mask, "dst_mask");
10650 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
10651 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10653 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
10654 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10656 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
10657 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10660 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
10661 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10663 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
10664 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10666 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
10667 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10668 mode_value, "MAC-VLAN");
10669 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
10670 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10671 mode_value, "Tunnel");
10672 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
10673 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10675 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
10676 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10677 mac_addr_byte_mask, UINT8);
10678 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
10679 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10680 tunnel_type, "tunnel-type");
10681 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
10682 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10683 tunnel_type_mask, UINT8);
10684 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
10685 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10686 tunnel_id, "tunnel-id");
10687 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
10688 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10689 tunnel_id_mask, UINT32);
10691 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
10692 .f = cmd_flow_director_mask_parsed,
10694 .help_str = "flow_director_mask ... : "
10695 "Set IP mode flow director's mask on NIC",
10697 (void *)&cmd_flow_director_mask,
10698 (void *)&cmd_flow_director_mask_port_id,
10699 (void *)&cmd_flow_director_mask_mode,
10700 (void *)&cmd_flow_director_mask_mode_ip,
10701 (void *)&cmd_flow_director_mask_vlan,
10702 (void *)&cmd_flow_director_mask_vlan_value,
10703 (void *)&cmd_flow_director_mask_src,
10704 (void *)&cmd_flow_director_mask_ipv4_src,
10705 (void *)&cmd_flow_director_mask_ipv6_src,
10706 (void *)&cmd_flow_director_mask_port_src,
10707 (void *)&cmd_flow_director_mask_dst,
10708 (void *)&cmd_flow_director_mask_ipv4_dst,
10709 (void *)&cmd_flow_director_mask_ipv6_dst,
10710 (void *)&cmd_flow_director_mask_port_dst,
10715 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
10716 .f = cmd_flow_director_mask_parsed,
10718 .help_str = "flow_director_mask ... : Set MAC VLAN mode "
10719 "flow director's mask on NIC",
10721 (void *)&cmd_flow_director_mask,
10722 (void *)&cmd_flow_director_mask_port_id,
10723 (void *)&cmd_flow_director_mask_mode,
10724 (void *)&cmd_flow_director_mask_mode_mac_vlan,
10725 (void *)&cmd_flow_director_mask_vlan,
10726 (void *)&cmd_flow_director_mask_vlan_value,
10731 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
10732 .f = cmd_flow_director_mask_parsed,
10734 .help_str = "flow_director_mask ... : Set tunnel mode "
10735 "flow director's mask on NIC",
10737 (void *)&cmd_flow_director_mask,
10738 (void *)&cmd_flow_director_mask_port_id,
10739 (void *)&cmd_flow_director_mask_mode,
10740 (void *)&cmd_flow_director_mask_mode_tunnel,
10741 (void *)&cmd_flow_director_mask_vlan,
10742 (void *)&cmd_flow_director_mask_vlan_value,
10743 (void *)&cmd_flow_director_mask_mac,
10744 (void *)&cmd_flow_director_mask_mac_value,
10745 (void *)&cmd_flow_director_mask_tunnel_type,
10746 (void *)&cmd_flow_director_mask_tunnel_type_value,
10747 (void *)&cmd_flow_director_mask_tunnel_id,
10748 (void *)&cmd_flow_director_mask_tunnel_id_value,
10753 /* *** deal with flow director mask on flexible payload *** */
10754 struct cmd_flow_director_flex_mask_result {
10755 cmdline_fixed_string_t flow_director_flexmask;
10757 cmdline_fixed_string_t flow;
10758 cmdline_fixed_string_t flow_type;
10759 cmdline_fixed_string_t mask;
10763 cmd_flow_director_flex_mask_parsed(void *parsed_result,
10764 __attribute__((unused)) struct cmdline *cl,
10765 __attribute__((unused)) void *data)
10767 struct cmd_flow_director_flex_mask_result *res = parsed_result;
10768 struct rte_eth_fdir_info fdir_info;
10769 struct rte_eth_fdir_flex_mask flex_mask;
10770 struct rte_port *port;
10771 uint32_t flow_type_mask;
10775 if (res->port_id > nb_ports) {
10776 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
10780 port = &ports[res->port_id];
10781 /** Check if the port is not started **/
10782 if (port->port_status != RTE_PORT_STOPPED) {
10783 printf("Please stop port %d first\n", res->port_id);
10787 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
10788 ret = parse_flexbytes(res->mask,
10790 RTE_ETH_FDIR_MAX_FLEXLEN);
10792 printf("error: Cannot parse mask input.\n");
10796 memset(&fdir_info, 0, sizeof(fdir_info));
10797 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10798 RTE_ETH_FILTER_INFO, &fdir_info);
10800 printf("Cannot get FDir filter info\n");
10804 if (!strcmp(res->flow_type, "none")) {
10805 /* means don't specify the flow type */
10806 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN;
10807 for (i = 0; i < RTE_ETH_FLOW_MAX; i++)
10808 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i],
10809 0, sizeof(struct rte_eth_fdir_flex_mask));
10810 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1;
10811 rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0],
10813 sizeof(struct rte_eth_fdir_flex_mask));
10814 cmd_reconfig_device_queue(res->port_id, 1, 1);
10817 flow_type_mask = fdir_info.flow_types_mask[0];
10818 if (!strcmp(res->flow_type, "all")) {
10819 if (!flow_type_mask) {
10820 printf("No flow type supported\n");
10823 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
10824 if (flow_type_mask & (1 << i)) {
10825 flex_mask.flow_type = i;
10826 fdir_set_flex_mask(res->port_id, &flex_mask);
10829 cmd_reconfig_device_queue(res->port_id, 1, 1);
10832 flex_mask.flow_type = str2flowtype(res->flow_type);
10833 if (!(flow_type_mask & (1 << flex_mask.flow_type))) {
10834 printf("Flow type %s not supported on port %d\n",
10835 res->flow_type, res->port_id);
10838 fdir_set_flex_mask(res->port_id, &flex_mask);
10839 cmd_reconfig_device_queue(res->port_id, 1, 1);
10842 cmdline_parse_token_string_t cmd_flow_director_flexmask =
10843 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
10844 flow_director_flexmask,
10845 "flow_director_flex_mask");
10846 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
10847 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
10849 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
10850 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
10852 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
10853 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
10854 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
10855 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all");
10856 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
10857 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
10860 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
10861 .f = cmd_flow_director_flex_mask_parsed,
10863 .help_str = "flow_director_flex_mask ... : "
10864 "Set flow director's flex mask on NIC",
10866 (void *)&cmd_flow_director_flexmask,
10867 (void *)&cmd_flow_director_flexmask_port_id,
10868 (void *)&cmd_flow_director_flexmask_flow,
10869 (void *)&cmd_flow_director_flexmask_flow_type,
10870 (void *)&cmd_flow_director_flexmask_mask,
10875 /* *** deal with flow director flexible payload configuration *** */
10876 struct cmd_flow_director_flexpayload_result {
10877 cmdline_fixed_string_t flow_director_flexpayload;
10879 cmdline_fixed_string_t payload_layer;
10880 cmdline_fixed_string_t payload_cfg;
10884 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
10887 const char *p, *p0 = q_arg;
10889 unsigned long int_fld;
10890 char *str_fld[max_num];
10895 p = strchr(p0, '(');
10899 p0 = strchr(p, ')');
10904 if (size >= sizeof(s))
10907 snprintf(s, sizeof(s), "%.*s", size, p);
10908 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
10909 if (ret < 0 || ret > max_num)
10911 for (i = 0; i < ret; i++) {
10913 int_fld = strtoul(str_fld[i], &end, 0);
10914 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
10916 offsets[i] = (uint16_t)int_fld;
10922 cmd_flow_director_flxpld_parsed(void *parsed_result,
10923 __attribute__((unused)) struct cmdline *cl,
10924 __attribute__((unused)) void *data)
10926 struct cmd_flow_director_flexpayload_result *res = parsed_result;
10927 struct rte_eth_flex_payload_cfg flex_cfg;
10928 struct rte_port *port;
10931 if (res->port_id > nb_ports) {
10932 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
10936 port = &ports[res->port_id];
10937 /** Check if the port is not started **/
10938 if (port->port_status != RTE_PORT_STOPPED) {
10939 printf("Please stop port %d first\n", res->port_id);
10943 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
10945 if (!strcmp(res->payload_layer, "raw"))
10946 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
10947 else if (!strcmp(res->payload_layer, "l2"))
10948 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
10949 else if (!strcmp(res->payload_layer, "l3"))
10950 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
10951 else if (!strcmp(res->payload_layer, "l4"))
10952 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
10954 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
10955 RTE_ETH_FDIR_MAX_FLEXLEN);
10957 printf("error: Cannot parse flex payload input.\n");
10961 fdir_set_flex_payload(res->port_id, &flex_cfg);
10962 cmd_reconfig_device_queue(res->port_id, 1, 1);
10965 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
10966 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10967 flow_director_flexpayload,
10968 "flow_director_flex_payload");
10969 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
10970 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10972 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
10973 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10974 payload_layer, "raw#l2#l3#l4");
10975 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
10976 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10977 payload_cfg, NULL);
10979 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
10980 .f = cmd_flow_director_flxpld_parsed,
10982 .help_str = "flow_director_flexpayload ... : "
10983 "Set flow director's flex payload on NIC",
10985 (void *)&cmd_flow_director_flexpayload,
10986 (void *)&cmd_flow_director_flexpayload_port_id,
10987 (void *)&cmd_flow_director_flexpayload_payload_layer,
10988 (void *)&cmd_flow_director_flexpayload_payload_cfg,
10993 /* Generic flow interface command. */
10994 extern cmdline_parse_inst_t cmd_flow;
10996 /* *** Classification Filters Control *** */
10997 /* *** Get symmetric hash enable per port *** */
10998 struct cmd_get_sym_hash_ena_per_port_result {
10999 cmdline_fixed_string_t get_sym_hash_ena_per_port;
11004 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
11005 __rte_unused struct cmdline *cl,
11006 __rte_unused void *data)
11008 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
11009 struct rte_eth_hash_filter_info info;
11012 if (rte_eth_dev_filter_supported(res->port_id,
11013 RTE_ETH_FILTER_HASH) < 0) {
11014 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
11019 memset(&info, 0, sizeof(info));
11020 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
11021 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11022 RTE_ETH_FILTER_GET, &info);
11025 printf("Cannot get symmetric hash enable per port "
11026 "on port %u\n", res->port_id);
11030 printf("Symmetric hash is %s on port %u\n", info.info.enable ?
11031 "enabled" : "disabled", res->port_id);
11034 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
11035 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
11036 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
11037 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
11038 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
11041 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
11042 .f = cmd_get_sym_hash_per_port_parsed,
11044 .help_str = "get_sym_hash_ena_per_port <port_id>",
11046 (void *)&cmd_get_sym_hash_ena_per_port_all,
11047 (void *)&cmd_get_sym_hash_ena_per_port_port_id,
11052 /* *** Set symmetric hash enable per port *** */
11053 struct cmd_set_sym_hash_ena_per_port_result {
11054 cmdline_fixed_string_t set_sym_hash_ena_per_port;
11055 cmdline_fixed_string_t enable;
11060 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
11061 __rte_unused struct cmdline *cl,
11062 __rte_unused void *data)
11064 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
11065 struct rte_eth_hash_filter_info info;
11068 if (rte_eth_dev_filter_supported(res->port_id,
11069 RTE_ETH_FILTER_HASH) < 0) {
11070 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
11075 memset(&info, 0, sizeof(info));
11076 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
11077 if (!strcmp(res->enable, "enable"))
11078 info.info.enable = 1;
11079 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11080 RTE_ETH_FILTER_SET, &info);
11082 printf("Cannot set symmetric hash enable per port on "
11083 "port %u\n", res->port_id);
11086 printf("Symmetric hash has been set to %s on port %u\n",
11087 res->enable, res->port_id);
11090 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
11091 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
11092 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
11093 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
11094 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
11096 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
11097 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
11098 enable, "enable#disable");
11100 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
11101 .f = cmd_set_sym_hash_per_port_parsed,
11103 .help_str = "set_sym_hash_ena_per_port <port_id> enable|disable",
11105 (void *)&cmd_set_sym_hash_ena_per_port_all,
11106 (void *)&cmd_set_sym_hash_ena_per_port_port_id,
11107 (void *)&cmd_set_sym_hash_ena_per_port_enable,
11112 /* Get global config of hash function */
11113 struct cmd_get_hash_global_config_result {
11114 cmdline_fixed_string_t get_hash_global_config;
11119 flowtype_to_str(uint16_t ftype)
11125 } ftype_table[] = {
11126 {"ipv4", RTE_ETH_FLOW_IPV4},
11127 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
11128 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
11129 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
11130 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
11131 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
11132 {"ipv6", RTE_ETH_FLOW_IPV6},
11133 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
11134 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
11135 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
11136 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
11137 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
11138 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
11139 {"port", RTE_ETH_FLOW_PORT},
11140 {"vxlan", RTE_ETH_FLOW_VXLAN},
11141 {"geneve", RTE_ETH_FLOW_GENEVE},
11142 {"nvgre", RTE_ETH_FLOW_NVGRE},
11145 for (i = 0; i < RTE_DIM(ftype_table); i++) {
11146 if (ftype_table[i].ftype == ftype)
11147 return ftype_table[i].str;
11154 cmd_get_hash_global_config_parsed(void *parsed_result,
11155 __rte_unused struct cmdline *cl,
11156 __rte_unused void *data)
11158 struct cmd_get_hash_global_config_result *res = parsed_result;
11159 struct rte_eth_hash_filter_info info;
11160 uint32_t idx, offset;
11165 if (rte_eth_dev_filter_supported(res->port_id,
11166 RTE_ETH_FILTER_HASH) < 0) {
11167 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
11172 memset(&info, 0, sizeof(info));
11173 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
11174 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11175 RTE_ETH_FILTER_GET, &info);
11177 printf("Cannot get hash global configurations by port %d\n",
11182 switch (info.info.global_conf.hash_func) {
11183 case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
11184 printf("Hash function is Toeplitz\n");
11186 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
11187 printf("Hash function is Simple XOR\n");
11190 printf("Unknown hash function\n");
11194 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) {
11195 idx = i / UINT32_BIT;
11196 offset = i % UINT32_BIT;
11197 if (!(info.info.global_conf.valid_bit_mask[idx] &
11200 str = flowtype_to_str(i);
11203 printf("Symmetric hash is %s globally for flow type %s "
11205 ((info.info.global_conf.sym_hash_enable_mask[idx] &
11206 (1UL << offset)) ? "enabled" : "disabled"), str,
11211 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
11212 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
11213 get_hash_global_config, "get_hash_global_config");
11214 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
11215 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
11218 cmdline_parse_inst_t cmd_get_hash_global_config = {
11219 .f = cmd_get_hash_global_config_parsed,
11221 .help_str = "get_hash_global_config <port_id>",
11223 (void *)&cmd_get_hash_global_config_all,
11224 (void *)&cmd_get_hash_global_config_port_id,
11229 /* Set global config of hash function */
11230 struct cmd_set_hash_global_config_result {
11231 cmdline_fixed_string_t set_hash_global_config;
11233 cmdline_fixed_string_t hash_func;
11234 cmdline_fixed_string_t flow_type;
11235 cmdline_fixed_string_t enable;
11239 cmd_set_hash_global_config_parsed(void *parsed_result,
11240 __rte_unused struct cmdline *cl,
11241 __rte_unused void *data)
11243 struct cmd_set_hash_global_config_result *res = parsed_result;
11244 struct rte_eth_hash_filter_info info;
11245 uint32_t ftype, idx, offset;
11248 if (rte_eth_dev_filter_supported(res->port_id,
11249 RTE_ETH_FILTER_HASH) < 0) {
11250 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
11254 memset(&info, 0, sizeof(info));
11255 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
11256 if (!strcmp(res->hash_func, "toeplitz"))
11257 info.info.global_conf.hash_func =
11258 RTE_ETH_HASH_FUNCTION_TOEPLITZ;
11259 else if (!strcmp(res->hash_func, "simple_xor"))
11260 info.info.global_conf.hash_func =
11261 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
11262 else if (!strcmp(res->hash_func, "default"))
11263 info.info.global_conf.hash_func =
11264 RTE_ETH_HASH_FUNCTION_DEFAULT;
11266 ftype = str2flowtype(res->flow_type);
11267 idx = ftype / (CHAR_BIT * sizeof(uint32_t));
11268 offset = ftype % (CHAR_BIT * sizeof(uint32_t));
11269 info.info.global_conf.valid_bit_mask[idx] |= (1UL << offset);
11270 if (!strcmp(res->enable, "enable"))
11271 info.info.global_conf.sym_hash_enable_mask[idx] |=
11273 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11274 RTE_ETH_FILTER_SET, &info);
11276 printf("Cannot set global hash configurations by port %d\n",
11279 printf("Global hash configurations have been set "
11280 "succcessfully by port %d\n", res->port_id);
11283 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
11284 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11285 set_hash_global_config, "set_hash_global_config");
11286 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
11287 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
11289 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
11290 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11291 hash_func, "toeplitz#simple_xor#default");
11292 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
11293 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11295 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
11296 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
11297 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
11298 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11299 enable, "enable#disable");
11301 cmdline_parse_inst_t cmd_set_hash_global_config = {
11302 .f = cmd_set_hash_global_config_parsed,
11304 .help_str = "set_hash_global_config <port_id> "
11305 "toeplitz|simple_xor|default "
11306 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
11307 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
11308 "l2_payload enable|disable",
11310 (void *)&cmd_set_hash_global_config_all,
11311 (void *)&cmd_set_hash_global_config_port_id,
11312 (void *)&cmd_set_hash_global_config_hash_func,
11313 (void *)&cmd_set_hash_global_config_flow_type,
11314 (void *)&cmd_set_hash_global_config_enable,
11319 /* Set hash input set */
11320 struct cmd_set_hash_input_set_result {
11321 cmdline_fixed_string_t set_hash_input_set;
11323 cmdline_fixed_string_t flow_type;
11324 cmdline_fixed_string_t inset_field;
11325 cmdline_fixed_string_t select;
11328 static enum rte_eth_input_set_field
11329 str2inset(char *string)
11333 static const struct {
11335 enum rte_eth_input_set_field inset;
11336 } inset_table[] = {
11337 {"ethertype", RTE_ETH_INPUT_SET_L2_ETHERTYPE},
11338 {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN},
11339 {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN},
11340 {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4},
11341 {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4},
11342 {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS},
11343 {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO},
11344 {"ipv4-ttl", RTE_ETH_INPUT_SET_L3_IP4_TTL},
11345 {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6},
11346 {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6},
11347 {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC},
11348 {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER},
11349 {"ipv6-hop-limits", RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS},
11350 {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT},
11351 {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT},
11352 {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT},
11353 {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT},
11354 {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT},
11355 {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT},
11356 {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG},
11357 {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY},
11358 {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY},
11359 {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD},
11360 {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD},
11361 {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD},
11362 {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD},
11363 {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD},
11364 {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD},
11365 {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD},
11366 {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD},
11367 {"none", RTE_ETH_INPUT_SET_NONE},
11370 for (i = 0; i < RTE_DIM(inset_table); i++) {
11371 if (!strcmp(string, inset_table[i].str))
11372 return inset_table[i].inset;
11375 return RTE_ETH_INPUT_SET_UNKNOWN;
11379 cmd_set_hash_input_set_parsed(void *parsed_result,
11380 __rte_unused struct cmdline *cl,
11381 __rte_unused void *data)
11383 struct cmd_set_hash_input_set_result *res = parsed_result;
11384 struct rte_eth_hash_filter_info info;
11386 memset(&info, 0, sizeof(info));
11387 info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT;
11388 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
11389 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
11390 info.info.input_set_conf.inset_size = 1;
11391 if (!strcmp(res->select, "select"))
11392 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
11393 else if (!strcmp(res->select, "add"))
11394 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
11395 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11396 RTE_ETH_FILTER_SET, &info);
11399 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd =
11400 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
11401 set_hash_input_set, "set_hash_input_set");
11402 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id =
11403 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result,
11405 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type =
11406 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
11408 cmdline_parse_token_string_t cmd_set_hash_input_set_field =
11409 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
11411 "ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
11412 "ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#"
11413 "udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#"
11414 "sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#"
11415 "fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#"
11417 cmdline_parse_token_string_t cmd_set_hash_input_set_select =
11418 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
11419 select, "select#add");
11421 cmdline_parse_inst_t cmd_set_hash_input_set = {
11422 .f = cmd_set_hash_input_set_parsed,
11424 .help_str = "set_hash_input_set <port_id> "
11425 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
11426 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload|<flowtype_id> "
11427 "ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|"
11428 "ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|"
11429 "tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|"
11430 "gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
11431 "fld-7th|fld-8th|none select|add",
11433 (void *)&cmd_set_hash_input_set_cmd,
11434 (void *)&cmd_set_hash_input_set_port_id,
11435 (void *)&cmd_set_hash_input_set_flow_type,
11436 (void *)&cmd_set_hash_input_set_field,
11437 (void *)&cmd_set_hash_input_set_select,
11442 /* Set flow director input set */
11443 struct cmd_set_fdir_input_set_result {
11444 cmdline_fixed_string_t set_fdir_input_set;
11446 cmdline_fixed_string_t flow_type;
11447 cmdline_fixed_string_t inset_field;
11448 cmdline_fixed_string_t select;
11452 cmd_set_fdir_input_set_parsed(void *parsed_result,
11453 __rte_unused struct cmdline *cl,
11454 __rte_unused void *data)
11456 struct cmd_set_fdir_input_set_result *res = parsed_result;
11457 struct rte_eth_fdir_filter_info info;
11459 memset(&info, 0, sizeof(info));
11460 info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT;
11461 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
11462 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
11463 info.info.input_set_conf.inset_size = 1;
11464 if (!strcmp(res->select, "select"))
11465 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
11466 else if (!strcmp(res->select, "add"))
11467 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
11468 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11469 RTE_ETH_FILTER_SET, &info);
11472 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd =
11473 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
11474 set_fdir_input_set, "set_fdir_input_set");
11475 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id =
11476 TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result,
11478 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type =
11479 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
11481 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
11482 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
11483 cmdline_parse_token_string_t cmd_set_fdir_input_set_field =
11484 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
11486 "ivlan#ethertype#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
11487 "ipv4-tos#ipv4-proto#ipv4-ttl#ipv6-tc#ipv6-next-header#"
11488 "ipv6-hop-limits#udp-src-port#udp-dst-port#"
11489 "tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#"
11490 "sctp-veri-tag#none");
11491 cmdline_parse_token_string_t cmd_set_fdir_input_set_select =
11492 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
11493 select, "select#add");
11495 cmdline_parse_inst_t cmd_set_fdir_input_set = {
11496 .f = cmd_set_fdir_input_set_parsed,
11498 .help_str = "set_fdir_input_set <port_id> "
11499 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
11500 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
11501 "ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|"
11502 "ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|ipv6-next-header|"
11503 "ipv6-hop-limits|udp-src-port|udp-dst-port|"
11504 "tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|"
11505 "sctp-veri-tag|none select|add",
11507 (void *)&cmd_set_fdir_input_set_cmd,
11508 (void *)&cmd_set_fdir_input_set_port_id,
11509 (void *)&cmd_set_fdir_input_set_flow_type,
11510 (void *)&cmd_set_fdir_input_set_field,
11511 (void *)&cmd_set_fdir_input_set_select,
11516 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
11517 struct cmd_mcast_addr_result {
11518 cmdline_fixed_string_t mcast_addr_cmd;
11519 cmdline_fixed_string_t what;
11521 struct ether_addr mc_addr;
11524 static void cmd_mcast_addr_parsed(void *parsed_result,
11525 __attribute__((unused)) struct cmdline *cl,
11526 __attribute__((unused)) void *data)
11528 struct cmd_mcast_addr_result *res = parsed_result;
11530 if (!is_multicast_ether_addr(&res->mc_addr)) {
11531 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
11532 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
11533 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
11534 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
11537 if (strcmp(res->what, "add") == 0)
11538 mcast_addr_add(res->port_num, &res->mc_addr);
11540 mcast_addr_remove(res->port_num, &res->mc_addr);
11543 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
11544 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
11545 mcast_addr_cmd, "mcast_addr");
11546 cmdline_parse_token_string_t cmd_mcast_addr_what =
11547 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
11549 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
11550 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT16);
11551 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
11552 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
11554 cmdline_parse_inst_t cmd_mcast_addr = {
11555 .f = cmd_mcast_addr_parsed,
11557 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
11558 "Add/Remove multicast MAC address on port_id",
11560 (void *)&cmd_mcast_addr_cmd,
11561 (void *)&cmd_mcast_addr_what,
11562 (void *)&cmd_mcast_addr_portnum,
11563 (void *)&cmd_mcast_addr_addr,
11568 /* l2 tunnel config
11569 * only support E-tag now.
11572 /* Ether type config */
11573 struct cmd_config_l2_tunnel_eth_type_result {
11574 cmdline_fixed_string_t port;
11575 cmdline_fixed_string_t config;
11576 cmdline_fixed_string_t all;
11578 cmdline_fixed_string_t l2_tunnel;
11579 cmdline_fixed_string_t l2_tunnel_type;
11580 cmdline_fixed_string_t eth_type;
11581 uint16_t eth_type_val;
11584 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port =
11585 TOKEN_STRING_INITIALIZER
11586 (struct cmd_config_l2_tunnel_eth_type_result,
11588 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config =
11589 TOKEN_STRING_INITIALIZER
11590 (struct cmd_config_l2_tunnel_eth_type_result,
11592 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str =
11593 TOKEN_STRING_INITIALIZER
11594 (struct cmd_config_l2_tunnel_eth_type_result,
11596 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id =
11597 TOKEN_NUM_INITIALIZER
11598 (struct cmd_config_l2_tunnel_eth_type_result,
11600 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel =
11601 TOKEN_STRING_INITIALIZER
11602 (struct cmd_config_l2_tunnel_eth_type_result,
11603 l2_tunnel, "l2-tunnel");
11604 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type =
11605 TOKEN_STRING_INITIALIZER
11606 (struct cmd_config_l2_tunnel_eth_type_result,
11607 l2_tunnel_type, "E-tag");
11608 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type =
11609 TOKEN_STRING_INITIALIZER
11610 (struct cmd_config_l2_tunnel_eth_type_result,
11611 eth_type, "ether-type");
11612 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val =
11613 TOKEN_NUM_INITIALIZER
11614 (struct cmd_config_l2_tunnel_eth_type_result,
11615 eth_type_val, UINT16);
11617 static enum rte_eth_tunnel_type
11618 str2fdir_l2_tunnel_type(char *string)
11622 static const struct {
11624 enum rte_eth_tunnel_type type;
11625 } l2_tunnel_type_str[] = {
11626 {"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG},
11629 for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) {
11630 if (!strcmp(l2_tunnel_type_str[i].str, string))
11631 return l2_tunnel_type_str[i].type;
11633 return RTE_TUNNEL_TYPE_NONE;
11636 /* ether type config for all ports */
11638 cmd_config_l2_tunnel_eth_type_all_parsed
11639 (void *parsed_result,
11640 __attribute__((unused)) struct cmdline *cl,
11641 __attribute__((unused)) void *data)
11643 struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result;
11644 struct rte_eth_l2_tunnel_conf entry;
11647 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
11648 entry.ether_type = res->eth_type_val;
11650 RTE_ETH_FOREACH_DEV(pid) {
11651 rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry);
11655 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = {
11656 .f = cmd_config_l2_tunnel_eth_type_all_parsed,
11658 .help_str = "port config all l2-tunnel E-tag ether-type <value>",
11660 (void *)&cmd_config_l2_tunnel_eth_type_port,
11661 (void *)&cmd_config_l2_tunnel_eth_type_config,
11662 (void *)&cmd_config_l2_tunnel_eth_type_all_str,
11663 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
11664 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
11665 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
11666 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
11671 /* ether type config for a specific port */
11673 cmd_config_l2_tunnel_eth_type_specific_parsed(
11674 void *parsed_result,
11675 __attribute__((unused)) struct cmdline *cl,
11676 __attribute__((unused)) void *data)
11678 struct cmd_config_l2_tunnel_eth_type_result *res =
11680 struct rte_eth_l2_tunnel_conf entry;
11682 if (port_id_is_invalid(res->id, ENABLED_WARN))
11685 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
11686 entry.ether_type = res->eth_type_val;
11688 rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry);
11691 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = {
11692 .f = cmd_config_l2_tunnel_eth_type_specific_parsed,
11694 .help_str = "port config <port_id> l2-tunnel E-tag ether-type <value>",
11696 (void *)&cmd_config_l2_tunnel_eth_type_port,
11697 (void *)&cmd_config_l2_tunnel_eth_type_config,
11698 (void *)&cmd_config_l2_tunnel_eth_type_id,
11699 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
11700 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
11701 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
11702 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
11707 /* Enable/disable l2 tunnel */
11708 struct cmd_config_l2_tunnel_en_dis_result {
11709 cmdline_fixed_string_t port;
11710 cmdline_fixed_string_t config;
11711 cmdline_fixed_string_t all;
11713 cmdline_fixed_string_t l2_tunnel;
11714 cmdline_fixed_string_t l2_tunnel_type;
11715 cmdline_fixed_string_t en_dis;
11718 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port =
11719 TOKEN_STRING_INITIALIZER
11720 (struct cmd_config_l2_tunnel_en_dis_result,
11722 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config =
11723 TOKEN_STRING_INITIALIZER
11724 (struct cmd_config_l2_tunnel_en_dis_result,
11726 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str =
11727 TOKEN_STRING_INITIALIZER
11728 (struct cmd_config_l2_tunnel_en_dis_result,
11730 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id =
11731 TOKEN_NUM_INITIALIZER
11732 (struct cmd_config_l2_tunnel_en_dis_result,
11734 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel =
11735 TOKEN_STRING_INITIALIZER
11736 (struct cmd_config_l2_tunnel_en_dis_result,
11737 l2_tunnel, "l2-tunnel");
11738 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type =
11739 TOKEN_STRING_INITIALIZER
11740 (struct cmd_config_l2_tunnel_en_dis_result,
11741 l2_tunnel_type, "E-tag");
11742 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis =
11743 TOKEN_STRING_INITIALIZER
11744 (struct cmd_config_l2_tunnel_en_dis_result,
11745 en_dis, "enable#disable");
11747 /* enable/disable l2 tunnel for all ports */
11749 cmd_config_l2_tunnel_en_dis_all_parsed(
11750 void *parsed_result,
11751 __attribute__((unused)) struct cmdline *cl,
11752 __attribute__((unused)) void *data)
11754 struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result;
11755 struct rte_eth_l2_tunnel_conf entry;
11759 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
11761 if (!strcmp("enable", res->en_dis))
11766 RTE_ETH_FOREACH_DEV(pid) {
11767 rte_eth_dev_l2_tunnel_offload_set(pid,
11769 ETH_L2_TUNNEL_ENABLE_MASK,
11774 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = {
11775 .f = cmd_config_l2_tunnel_en_dis_all_parsed,
11777 .help_str = "port config all l2-tunnel E-tag enable|disable",
11779 (void *)&cmd_config_l2_tunnel_en_dis_port,
11780 (void *)&cmd_config_l2_tunnel_en_dis_config,
11781 (void *)&cmd_config_l2_tunnel_en_dis_all_str,
11782 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
11783 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
11784 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
11789 /* enable/disable l2 tunnel for a port */
11791 cmd_config_l2_tunnel_en_dis_specific_parsed(
11792 void *parsed_result,
11793 __attribute__((unused)) struct cmdline *cl,
11794 __attribute__((unused)) void *data)
11796 struct cmd_config_l2_tunnel_en_dis_result *res =
11798 struct rte_eth_l2_tunnel_conf entry;
11800 if (port_id_is_invalid(res->id, ENABLED_WARN))
11803 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
11805 if (!strcmp("enable", res->en_dis))
11806 rte_eth_dev_l2_tunnel_offload_set(res->id,
11808 ETH_L2_TUNNEL_ENABLE_MASK,
11811 rte_eth_dev_l2_tunnel_offload_set(res->id,
11813 ETH_L2_TUNNEL_ENABLE_MASK,
11817 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = {
11818 .f = cmd_config_l2_tunnel_en_dis_specific_parsed,
11820 .help_str = "port config <port_id> l2-tunnel E-tag enable|disable",
11822 (void *)&cmd_config_l2_tunnel_en_dis_port,
11823 (void *)&cmd_config_l2_tunnel_en_dis_config,
11824 (void *)&cmd_config_l2_tunnel_en_dis_id,
11825 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
11826 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
11827 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
11832 /* E-tag configuration */
11834 /* Common result structure for all E-tag configuration */
11835 struct cmd_config_e_tag_result {
11836 cmdline_fixed_string_t e_tag;
11837 cmdline_fixed_string_t set;
11838 cmdline_fixed_string_t insertion;
11839 cmdline_fixed_string_t stripping;
11840 cmdline_fixed_string_t forwarding;
11841 cmdline_fixed_string_t filter;
11842 cmdline_fixed_string_t add;
11843 cmdline_fixed_string_t del;
11844 cmdline_fixed_string_t on;
11845 cmdline_fixed_string_t off;
11846 cmdline_fixed_string_t on_off;
11847 cmdline_fixed_string_t port_tag_id;
11848 uint32_t port_tag_id_val;
11849 cmdline_fixed_string_t e_tag_id;
11850 uint16_t e_tag_id_val;
11851 cmdline_fixed_string_t dst_pool;
11852 uint8_t dst_pool_val;
11853 cmdline_fixed_string_t port;
11855 cmdline_fixed_string_t vf;
11859 /* Common CLI fields for all E-tag configuration */
11860 cmdline_parse_token_string_t cmd_config_e_tag_e_tag =
11861 TOKEN_STRING_INITIALIZER
11862 (struct cmd_config_e_tag_result,
11864 cmdline_parse_token_string_t cmd_config_e_tag_set =
11865 TOKEN_STRING_INITIALIZER
11866 (struct cmd_config_e_tag_result,
11868 cmdline_parse_token_string_t cmd_config_e_tag_insertion =
11869 TOKEN_STRING_INITIALIZER
11870 (struct cmd_config_e_tag_result,
11871 insertion, "insertion");
11872 cmdline_parse_token_string_t cmd_config_e_tag_stripping =
11873 TOKEN_STRING_INITIALIZER
11874 (struct cmd_config_e_tag_result,
11875 stripping, "stripping");
11876 cmdline_parse_token_string_t cmd_config_e_tag_forwarding =
11877 TOKEN_STRING_INITIALIZER
11878 (struct cmd_config_e_tag_result,
11879 forwarding, "forwarding");
11880 cmdline_parse_token_string_t cmd_config_e_tag_filter =
11881 TOKEN_STRING_INITIALIZER
11882 (struct cmd_config_e_tag_result,
11884 cmdline_parse_token_string_t cmd_config_e_tag_add =
11885 TOKEN_STRING_INITIALIZER
11886 (struct cmd_config_e_tag_result,
11888 cmdline_parse_token_string_t cmd_config_e_tag_del =
11889 TOKEN_STRING_INITIALIZER
11890 (struct cmd_config_e_tag_result,
11892 cmdline_parse_token_string_t cmd_config_e_tag_on =
11893 TOKEN_STRING_INITIALIZER
11894 (struct cmd_config_e_tag_result,
11896 cmdline_parse_token_string_t cmd_config_e_tag_off =
11897 TOKEN_STRING_INITIALIZER
11898 (struct cmd_config_e_tag_result,
11900 cmdline_parse_token_string_t cmd_config_e_tag_on_off =
11901 TOKEN_STRING_INITIALIZER
11902 (struct cmd_config_e_tag_result,
11904 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id =
11905 TOKEN_STRING_INITIALIZER
11906 (struct cmd_config_e_tag_result,
11907 port_tag_id, "port-tag-id");
11908 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val =
11909 TOKEN_NUM_INITIALIZER
11910 (struct cmd_config_e_tag_result,
11911 port_tag_id_val, UINT32);
11912 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id =
11913 TOKEN_STRING_INITIALIZER
11914 (struct cmd_config_e_tag_result,
11915 e_tag_id, "e-tag-id");
11916 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val =
11917 TOKEN_NUM_INITIALIZER
11918 (struct cmd_config_e_tag_result,
11919 e_tag_id_val, UINT16);
11920 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool =
11921 TOKEN_STRING_INITIALIZER
11922 (struct cmd_config_e_tag_result,
11923 dst_pool, "dst-pool");
11924 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val =
11925 TOKEN_NUM_INITIALIZER
11926 (struct cmd_config_e_tag_result,
11927 dst_pool_val, UINT8);
11928 cmdline_parse_token_string_t cmd_config_e_tag_port =
11929 TOKEN_STRING_INITIALIZER
11930 (struct cmd_config_e_tag_result,
11932 cmdline_parse_token_num_t cmd_config_e_tag_port_id =
11933 TOKEN_NUM_INITIALIZER
11934 (struct cmd_config_e_tag_result,
11936 cmdline_parse_token_string_t cmd_config_e_tag_vf =
11937 TOKEN_STRING_INITIALIZER
11938 (struct cmd_config_e_tag_result,
11940 cmdline_parse_token_num_t cmd_config_e_tag_vf_id =
11941 TOKEN_NUM_INITIALIZER
11942 (struct cmd_config_e_tag_result,
11945 /* E-tag insertion configuration */
11947 cmd_config_e_tag_insertion_en_parsed(
11948 void *parsed_result,
11949 __attribute__((unused)) struct cmdline *cl,
11950 __attribute__((unused)) void *data)
11952 struct cmd_config_e_tag_result *res =
11954 struct rte_eth_l2_tunnel_conf entry;
11956 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11959 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
11960 entry.tunnel_id = res->port_tag_id_val;
11961 entry.vf_id = res->vf_id;
11962 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
11964 ETH_L2_TUNNEL_INSERTION_MASK,
11969 cmd_config_e_tag_insertion_dis_parsed(
11970 void *parsed_result,
11971 __attribute__((unused)) struct cmdline *cl,
11972 __attribute__((unused)) void *data)
11974 struct cmd_config_e_tag_result *res =
11976 struct rte_eth_l2_tunnel_conf entry;
11978 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11981 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
11982 entry.vf_id = res->vf_id;
11984 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
11986 ETH_L2_TUNNEL_INSERTION_MASK,
11990 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = {
11991 .f = cmd_config_e_tag_insertion_en_parsed,
11993 .help_str = "E-tag ... : E-tag insertion enable",
11995 (void *)&cmd_config_e_tag_e_tag,
11996 (void *)&cmd_config_e_tag_set,
11997 (void *)&cmd_config_e_tag_insertion,
11998 (void *)&cmd_config_e_tag_on,
11999 (void *)&cmd_config_e_tag_port_tag_id,
12000 (void *)&cmd_config_e_tag_port_tag_id_val,
12001 (void *)&cmd_config_e_tag_port,
12002 (void *)&cmd_config_e_tag_port_id,
12003 (void *)&cmd_config_e_tag_vf,
12004 (void *)&cmd_config_e_tag_vf_id,
12009 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = {
12010 .f = cmd_config_e_tag_insertion_dis_parsed,
12012 .help_str = "E-tag ... : E-tag insertion disable",
12014 (void *)&cmd_config_e_tag_e_tag,
12015 (void *)&cmd_config_e_tag_set,
12016 (void *)&cmd_config_e_tag_insertion,
12017 (void *)&cmd_config_e_tag_off,
12018 (void *)&cmd_config_e_tag_port,
12019 (void *)&cmd_config_e_tag_port_id,
12020 (void *)&cmd_config_e_tag_vf,
12021 (void *)&cmd_config_e_tag_vf_id,
12026 /* E-tag stripping configuration */
12028 cmd_config_e_tag_stripping_parsed(
12029 void *parsed_result,
12030 __attribute__((unused)) struct cmdline *cl,
12031 __attribute__((unused)) void *data)
12033 struct cmd_config_e_tag_result *res =
12035 struct rte_eth_l2_tunnel_conf entry;
12037 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12040 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12042 if (!strcmp(res->on_off, "on"))
12043 rte_eth_dev_l2_tunnel_offload_set
12046 ETH_L2_TUNNEL_STRIPPING_MASK,
12049 rte_eth_dev_l2_tunnel_offload_set
12052 ETH_L2_TUNNEL_STRIPPING_MASK,
12056 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = {
12057 .f = cmd_config_e_tag_stripping_parsed,
12059 .help_str = "E-tag ... : E-tag stripping enable/disable",
12061 (void *)&cmd_config_e_tag_e_tag,
12062 (void *)&cmd_config_e_tag_set,
12063 (void *)&cmd_config_e_tag_stripping,
12064 (void *)&cmd_config_e_tag_on_off,
12065 (void *)&cmd_config_e_tag_port,
12066 (void *)&cmd_config_e_tag_port_id,
12071 /* E-tag forwarding configuration */
12073 cmd_config_e_tag_forwarding_parsed(
12074 void *parsed_result,
12075 __attribute__((unused)) struct cmdline *cl,
12076 __attribute__((unused)) void *data)
12078 struct cmd_config_e_tag_result *res = parsed_result;
12079 struct rte_eth_l2_tunnel_conf entry;
12081 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12084 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12086 if (!strcmp(res->on_off, "on"))
12087 rte_eth_dev_l2_tunnel_offload_set
12090 ETH_L2_TUNNEL_FORWARDING_MASK,
12093 rte_eth_dev_l2_tunnel_offload_set
12096 ETH_L2_TUNNEL_FORWARDING_MASK,
12100 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = {
12101 .f = cmd_config_e_tag_forwarding_parsed,
12103 .help_str = "E-tag ... : E-tag forwarding enable/disable",
12105 (void *)&cmd_config_e_tag_e_tag,
12106 (void *)&cmd_config_e_tag_set,
12107 (void *)&cmd_config_e_tag_forwarding,
12108 (void *)&cmd_config_e_tag_on_off,
12109 (void *)&cmd_config_e_tag_port,
12110 (void *)&cmd_config_e_tag_port_id,
12115 /* E-tag filter configuration */
12117 cmd_config_e_tag_filter_add_parsed(
12118 void *parsed_result,
12119 __attribute__((unused)) struct cmdline *cl,
12120 __attribute__((unused)) void *data)
12122 struct cmd_config_e_tag_result *res = parsed_result;
12123 struct rte_eth_l2_tunnel_conf entry;
12126 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12129 if (res->e_tag_id_val > 0x3fff) {
12130 printf("e-tag-id must be equal or less than 0x3fff.\n");
12134 ret = rte_eth_dev_filter_supported(res->port_id,
12135 RTE_ETH_FILTER_L2_TUNNEL);
12137 printf("E-tag filter is not supported on port %u.\n",
12142 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12143 entry.tunnel_id = res->e_tag_id_val;
12144 entry.pool = res->dst_pool_val;
12146 ret = rte_eth_dev_filter_ctrl(res->port_id,
12147 RTE_ETH_FILTER_L2_TUNNEL,
12148 RTE_ETH_FILTER_ADD,
12151 printf("E-tag filter programming error: (%s)\n",
12155 cmdline_parse_inst_t cmd_config_e_tag_filter_add = {
12156 .f = cmd_config_e_tag_filter_add_parsed,
12158 .help_str = "E-tag ... : E-tag filter add",
12160 (void *)&cmd_config_e_tag_e_tag,
12161 (void *)&cmd_config_e_tag_set,
12162 (void *)&cmd_config_e_tag_filter,
12163 (void *)&cmd_config_e_tag_add,
12164 (void *)&cmd_config_e_tag_e_tag_id,
12165 (void *)&cmd_config_e_tag_e_tag_id_val,
12166 (void *)&cmd_config_e_tag_dst_pool,
12167 (void *)&cmd_config_e_tag_dst_pool_val,
12168 (void *)&cmd_config_e_tag_port,
12169 (void *)&cmd_config_e_tag_port_id,
12175 cmd_config_e_tag_filter_del_parsed(
12176 void *parsed_result,
12177 __attribute__((unused)) struct cmdline *cl,
12178 __attribute__((unused)) void *data)
12180 struct cmd_config_e_tag_result *res = parsed_result;
12181 struct rte_eth_l2_tunnel_conf entry;
12184 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12187 if (res->e_tag_id_val > 0x3fff) {
12188 printf("e-tag-id must be less than 0x3fff.\n");
12192 ret = rte_eth_dev_filter_supported(res->port_id,
12193 RTE_ETH_FILTER_L2_TUNNEL);
12195 printf("E-tag filter is not supported on port %u.\n",
12200 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12201 entry.tunnel_id = res->e_tag_id_val;
12203 ret = rte_eth_dev_filter_ctrl(res->port_id,
12204 RTE_ETH_FILTER_L2_TUNNEL,
12205 RTE_ETH_FILTER_DELETE,
12208 printf("E-tag filter programming error: (%s)\n",
12212 cmdline_parse_inst_t cmd_config_e_tag_filter_del = {
12213 .f = cmd_config_e_tag_filter_del_parsed,
12215 .help_str = "E-tag ... : E-tag filter delete",
12217 (void *)&cmd_config_e_tag_e_tag,
12218 (void *)&cmd_config_e_tag_set,
12219 (void *)&cmd_config_e_tag_filter,
12220 (void *)&cmd_config_e_tag_del,
12221 (void *)&cmd_config_e_tag_e_tag_id,
12222 (void *)&cmd_config_e_tag_e_tag_id_val,
12223 (void *)&cmd_config_e_tag_port,
12224 (void *)&cmd_config_e_tag_port_id,
12229 /* vf vlan anti spoof configuration */
12231 /* Common result structure for vf vlan anti spoof */
12232 struct cmd_vf_vlan_anti_spoof_result {
12233 cmdline_fixed_string_t set;
12234 cmdline_fixed_string_t vf;
12235 cmdline_fixed_string_t vlan;
12236 cmdline_fixed_string_t antispoof;
12239 cmdline_fixed_string_t on_off;
12242 /* Common CLI fields for vf vlan anti spoof enable disable */
12243 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
12244 TOKEN_STRING_INITIALIZER
12245 (struct cmd_vf_vlan_anti_spoof_result,
12247 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
12248 TOKEN_STRING_INITIALIZER
12249 (struct cmd_vf_vlan_anti_spoof_result,
12251 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
12252 TOKEN_STRING_INITIALIZER
12253 (struct cmd_vf_vlan_anti_spoof_result,
12255 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
12256 TOKEN_STRING_INITIALIZER
12257 (struct cmd_vf_vlan_anti_spoof_result,
12258 antispoof, "antispoof");
12259 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
12260 TOKEN_NUM_INITIALIZER
12261 (struct cmd_vf_vlan_anti_spoof_result,
12263 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
12264 TOKEN_NUM_INITIALIZER
12265 (struct cmd_vf_vlan_anti_spoof_result,
12267 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
12268 TOKEN_STRING_INITIALIZER
12269 (struct cmd_vf_vlan_anti_spoof_result,
12273 cmd_set_vf_vlan_anti_spoof_parsed(
12274 void *parsed_result,
12275 __attribute__((unused)) struct cmdline *cl,
12276 __attribute__((unused)) void *data)
12278 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
12279 int ret = -ENOTSUP;
12281 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12283 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12286 #ifdef RTE_LIBRTE_IXGBE_PMD
12287 if (ret == -ENOTSUP)
12288 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
12289 res->vf_id, is_on);
12291 #ifdef RTE_LIBRTE_I40E_PMD
12292 if (ret == -ENOTSUP)
12293 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
12294 res->vf_id, is_on);
12296 #ifdef RTE_LIBRTE_BNXT_PMD
12297 if (ret == -ENOTSUP)
12298 ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
12299 res->vf_id, is_on);
12306 printf("invalid vf_id %d\n", res->vf_id);
12309 printf("invalid port_id %d\n", res->port_id);
12312 printf("function not implemented\n");
12315 printf("programming error: (%s)\n", strerror(-ret));
12319 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
12320 .f = cmd_set_vf_vlan_anti_spoof_parsed,
12322 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
12324 (void *)&cmd_vf_vlan_anti_spoof_set,
12325 (void *)&cmd_vf_vlan_anti_spoof_vf,
12326 (void *)&cmd_vf_vlan_anti_spoof_vlan,
12327 (void *)&cmd_vf_vlan_anti_spoof_antispoof,
12328 (void *)&cmd_vf_vlan_anti_spoof_port_id,
12329 (void *)&cmd_vf_vlan_anti_spoof_vf_id,
12330 (void *)&cmd_vf_vlan_anti_spoof_on_off,
12335 /* vf mac anti spoof configuration */
12337 /* Common result structure for vf mac anti spoof */
12338 struct cmd_vf_mac_anti_spoof_result {
12339 cmdline_fixed_string_t set;
12340 cmdline_fixed_string_t vf;
12341 cmdline_fixed_string_t mac;
12342 cmdline_fixed_string_t antispoof;
12345 cmdline_fixed_string_t on_off;
12348 /* Common CLI fields for vf mac anti spoof enable disable */
12349 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
12350 TOKEN_STRING_INITIALIZER
12351 (struct cmd_vf_mac_anti_spoof_result,
12353 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
12354 TOKEN_STRING_INITIALIZER
12355 (struct cmd_vf_mac_anti_spoof_result,
12357 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
12358 TOKEN_STRING_INITIALIZER
12359 (struct cmd_vf_mac_anti_spoof_result,
12361 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
12362 TOKEN_STRING_INITIALIZER
12363 (struct cmd_vf_mac_anti_spoof_result,
12364 antispoof, "antispoof");
12365 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
12366 TOKEN_NUM_INITIALIZER
12367 (struct cmd_vf_mac_anti_spoof_result,
12369 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
12370 TOKEN_NUM_INITIALIZER
12371 (struct cmd_vf_mac_anti_spoof_result,
12373 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
12374 TOKEN_STRING_INITIALIZER
12375 (struct cmd_vf_mac_anti_spoof_result,
12379 cmd_set_vf_mac_anti_spoof_parsed(
12380 void *parsed_result,
12381 __attribute__((unused)) struct cmdline *cl,
12382 __attribute__((unused)) void *data)
12384 struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
12385 int ret = -ENOTSUP;
12387 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12389 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12392 #ifdef RTE_LIBRTE_IXGBE_PMD
12393 if (ret == -ENOTSUP)
12394 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
12395 res->vf_id, is_on);
12397 #ifdef RTE_LIBRTE_I40E_PMD
12398 if (ret == -ENOTSUP)
12399 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
12400 res->vf_id, is_on);
12402 #ifdef RTE_LIBRTE_BNXT_PMD
12403 if (ret == -ENOTSUP)
12404 ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
12405 res->vf_id, is_on);
12412 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12415 printf("invalid port_id %d\n", res->port_id);
12418 printf("function not implemented\n");
12421 printf("programming error: (%s)\n", strerror(-ret));
12425 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
12426 .f = cmd_set_vf_mac_anti_spoof_parsed,
12428 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
12430 (void *)&cmd_vf_mac_anti_spoof_set,
12431 (void *)&cmd_vf_mac_anti_spoof_vf,
12432 (void *)&cmd_vf_mac_anti_spoof_mac,
12433 (void *)&cmd_vf_mac_anti_spoof_antispoof,
12434 (void *)&cmd_vf_mac_anti_spoof_port_id,
12435 (void *)&cmd_vf_mac_anti_spoof_vf_id,
12436 (void *)&cmd_vf_mac_anti_spoof_on_off,
12441 /* vf vlan strip queue configuration */
12443 /* Common result structure for vf mac anti spoof */
12444 struct cmd_vf_vlan_stripq_result {
12445 cmdline_fixed_string_t set;
12446 cmdline_fixed_string_t vf;
12447 cmdline_fixed_string_t vlan;
12448 cmdline_fixed_string_t stripq;
12451 cmdline_fixed_string_t on_off;
12454 /* Common CLI fields for vf vlan strip enable disable */
12455 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
12456 TOKEN_STRING_INITIALIZER
12457 (struct cmd_vf_vlan_stripq_result,
12459 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
12460 TOKEN_STRING_INITIALIZER
12461 (struct cmd_vf_vlan_stripq_result,
12463 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
12464 TOKEN_STRING_INITIALIZER
12465 (struct cmd_vf_vlan_stripq_result,
12467 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
12468 TOKEN_STRING_INITIALIZER
12469 (struct cmd_vf_vlan_stripq_result,
12471 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
12472 TOKEN_NUM_INITIALIZER
12473 (struct cmd_vf_vlan_stripq_result,
12475 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
12476 TOKEN_NUM_INITIALIZER
12477 (struct cmd_vf_vlan_stripq_result,
12479 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
12480 TOKEN_STRING_INITIALIZER
12481 (struct cmd_vf_vlan_stripq_result,
12485 cmd_set_vf_vlan_stripq_parsed(
12486 void *parsed_result,
12487 __attribute__((unused)) struct cmdline *cl,
12488 __attribute__((unused)) void *data)
12490 struct cmd_vf_vlan_stripq_result *res = parsed_result;
12491 int ret = -ENOTSUP;
12493 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12495 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12498 #ifdef RTE_LIBRTE_IXGBE_PMD
12499 if (ret == -ENOTSUP)
12500 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
12501 res->vf_id, is_on);
12503 #ifdef RTE_LIBRTE_I40E_PMD
12504 if (ret == -ENOTSUP)
12505 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
12506 res->vf_id, is_on);
12508 #ifdef RTE_LIBRTE_BNXT_PMD
12509 if (ret == -ENOTSUP)
12510 ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
12511 res->vf_id, is_on);
12518 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12521 printf("invalid port_id %d\n", res->port_id);
12524 printf("function not implemented\n");
12527 printf("programming error: (%s)\n", strerror(-ret));
12531 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
12532 .f = cmd_set_vf_vlan_stripq_parsed,
12534 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
12536 (void *)&cmd_vf_vlan_stripq_set,
12537 (void *)&cmd_vf_vlan_stripq_vf,
12538 (void *)&cmd_vf_vlan_stripq_vlan,
12539 (void *)&cmd_vf_vlan_stripq_stripq,
12540 (void *)&cmd_vf_vlan_stripq_port_id,
12541 (void *)&cmd_vf_vlan_stripq_vf_id,
12542 (void *)&cmd_vf_vlan_stripq_on_off,
12547 /* vf vlan insert configuration */
12549 /* Common result structure for vf vlan insert */
12550 struct cmd_vf_vlan_insert_result {
12551 cmdline_fixed_string_t set;
12552 cmdline_fixed_string_t vf;
12553 cmdline_fixed_string_t vlan;
12554 cmdline_fixed_string_t insert;
12560 /* Common CLI fields for vf vlan insert enable disable */
12561 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
12562 TOKEN_STRING_INITIALIZER
12563 (struct cmd_vf_vlan_insert_result,
12565 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
12566 TOKEN_STRING_INITIALIZER
12567 (struct cmd_vf_vlan_insert_result,
12569 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
12570 TOKEN_STRING_INITIALIZER
12571 (struct cmd_vf_vlan_insert_result,
12573 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
12574 TOKEN_STRING_INITIALIZER
12575 (struct cmd_vf_vlan_insert_result,
12577 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
12578 TOKEN_NUM_INITIALIZER
12579 (struct cmd_vf_vlan_insert_result,
12581 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
12582 TOKEN_NUM_INITIALIZER
12583 (struct cmd_vf_vlan_insert_result,
12585 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
12586 TOKEN_NUM_INITIALIZER
12587 (struct cmd_vf_vlan_insert_result,
12591 cmd_set_vf_vlan_insert_parsed(
12592 void *parsed_result,
12593 __attribute__((unused)) struct cmdline *cl,
12594 __attribute__((unused)) void *data)
12596 struct cmd_vf_vlan_insert_result *res = parsed_result;
12597 int ret = -ENOTSUP;
12599 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12602 #ifdef RTE_LIBRTE_IXGBE_PMD
12603 if (ret == -ENOTSUP)
12604 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
12607 #ifdef RTE_LIBRTE_I40E_PMD
12608 if (ret == -ENOTSUP)
12609 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
12612 #ifdef RTE_LIBRTE_BNXT_PMD
12613 if (ret == -ENOTSUP)
12614 ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
12622 printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id);
12625 printf("invalid port_id %d\n", res->port_id);
12628 printf("function not implemented\n");
12631 printf("programming error: (%s)\n", strerror(-ret));
12635 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
12636 .f = cmd_set_vf_vlan_insert_parsed,
12638 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
12640 (void *)&cmd_vf_vlan_insert_set,
12641 (void *)&cmd_vf_vlan_insert_vf,
12642 (void *)&cmd_vf_vlan_insert_vlan,
12643 (void *)&cmd_vf_vlan_insert_insert,
12644 (void *)&cmd_vf_vlan_insert_port_id,
12645 (void *)&cmd_vf_vlan_insert_vf_id,
12646 (void *)&cmd_vf_vlan_insert_vlan_id,
12651 /* tx loopback configuration */
12653 /* Common result structure for tx loopback */
12654 struct cmd_tx_loopback_result {
12655 cmdline_fixed_string_t set;
12656 cmdline_fixed_string_t tx;
12657 cmdline_fixed_string_t loopback;
12659 cmdline_fixed_string_t on_off;
12662 /* Common CLI fields for tx loopback enable disable */
12663 cmdline_parse_token_string_t cmd_tx_loopback_set =
12664 TOKEN_STRING_INITIALIZER
12665 (struct cmd_tx_loopback_result,
12667 cmdline_parse_token_string_t cmd_tx_loopback_tx =
12668 TOKEN_STRING_INITIALIZER
12669 (struct cmd_tx_loopback_result,
12671 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
12672 TOKEN_STRING_INITIALIZER
12673 (struct cmd_tx_loopback_result,
12674 loopback, "loopback");
12675 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
12676 TOKEN_NUM_INITIALIZER
12677 (struct cmd_tx_loopback_result,
12679 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
12680 TOKEN_STRING_INITIALIZER
12681 (struct cmd_tx_loopback_result,
12685 cmd_set_tx_loopback_parsed(
12686 void *parsed_result,
12687 __attribute__((unused)) struct cmdline *cl,
12688 __attribute__((unused)) void *data)
12690 struct cmd_tx_loopback_result *res = parsed_result;
12691 int ret = -ENOTSUP;
12693 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12695 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12698 #ifdef RTE_LIBRTE_IXGBE_PMD
12699 if (ret == -ENOTSUP)
12700 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
12702 #ifdef RTE_LIBRTE_I40E_PMD
12703 if (ret == -ENOTSUP)
12704 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
12706 #ifdef RTE_LIBRTE_BNXT_PMD
12707 if (ret == -ENOTSUP)
12708 ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
12715 printf("invalid is_on %d\n", is_on);
12718 printf("invalid port_id %d\n", res->port_id);
12721 printf("function not implemented\n");
12724 printf("programming error: (%s)\n", strerror(-ret));
12728 cmdline_parse_inst_t cmd_set_tx_loopback = {
12729 .f = cmd_set_tx_loopback_parsed,
12731 .help_str = "set tx loopback <port_id> on|off",
12733 (void *)&cmd_tx_loopback_set,
12734 (void *)&cmd_tx_loopback_tx,
12735 (void *)&cmd_tx_loopback_loopback,
12736 (void *)&cmd_tx_loopback_port_id,
12737 (void *)&cmd_tx_loopback_on_off,
12742 /* all queues drop enable configuration */
12744 /* Common result structure for all queues drop enable */
12745 struct cmd_all_queues_drop_en_result {
12746 cmdline_fixed_string_t set;
12747 cmdline_fixed_string_t all;
12748 cmdline_fixed_string_t queues;
12749 cmdline_fixed_string_t drop;
12751 cmdline_fixed_string_t on_off;
12754 /* Common CLI fields for tx loopback enable disable */
12755 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
12756 TOKEN_STRING_INITIALIZER
12757 (struct cmd_all_queues_drop_en_result,
12759 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
12760 TOKEN_STRING_INITIALIZER
12761 (struct cmd_all_queues_drop_en_result,
12763 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
12764 TOKEN_STRING_INITIALIZER
12765 (struct cmd_all_queues_drop_en_result,
12767 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
12768 TOKEN_STRING_INITIALIZER
12769 (struct cmd_all_queues_drop_en_result,
12771 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
12772 TOKEN_NUM_INITIALIZER
12773 (struct cmd_all_queues_drop_en_result,
12775 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
12776 TOKEN_STRING_INITIALIZER
12777 (struct cmd_all_queues_drop_en_result,
12781 cmd_set_all_queues_drop_en_parsed(
12782 void *parsed_result,
12783 __attribute__((unused)) struct cmdline *cl,
12784 __attribute__((unused)) void *data)
12786 struct cmd_all_queues_drop_en_result *res = parsed_result;
12787 int ret = -ENOTSUP;
12788 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12790 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12793 #ifdef RTE_LIBRTE_IXGBE_PMD
12794 if (ret == -ENOTSUP)
12795 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
12797 #ifdef RTE_LIBRTE_BNXT_PMD
12798 if (ret == -ENOTSUP)
12799 ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
12805 printf("invalid is_on %d\n", is_on);
12808 printf("invalid port_id %d\n", res->port_id);
12811 printf("function not implemented\n");
12814 printf("programming error: (%s)\n", strerror(-ret));
12818 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
12819 .f = cmd_set_all_queues_drop_en_parsed,
12821 .help_str = "set all queues drop <port_id> on|off",
12823 (void *)&cmd_all_queues_drop_en_set,
12824 (void *)&cmd_all_queues_drop_en_all,
12825 (void *)&cmd_all_queues_drop_en_queues,
12826 (void *)&cmd_all_queues_drop_en_drop,
12827 (void *)&cmd_all_queues_drop_en_port_id,
12828 (void *)&cmd_all_queues_drop_en_on_off,
12833 /* vf split drop enable configuration */
12835 /* Common result structure for vf split drop enable */
12836 struct cmd_vf_split_drop_en_result {
12837 cmdline_fixed_string_t set;
12838 cmdline_fixed_string_t vf;
12839 cmdline_fixed_string_t split;
12840 cmdline_fixed_string_t drop;
12843 cmdline_fixed_string_t on_off;
12846 /* Common CLI fields for vf split drop enable disable */
12847 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
12848 TOKEN_STRING_INITIALIZER
12849 (struct cmd_vf_split_drop_en_result,
12851 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
12852 TOKEN_STRING_INITIALIZER
12853 (struct cmd_vf_split_drop_en_result,
12855 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
12856 TOKEN_STRING_INITIALIZER
12857 (struct cmd_vf_split_drop_en_result,
12859 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
12860 TOKEN_STRING_INITIALIZER
12861 (struct cmd_vf_split_drop_en_result,
12863 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
12864 TOKEN_NUM_INITIALIZER
12865 (struct cmd_vf_split_drop_en_result,
12867 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
12868 TOKEN_NUM_INITIALIZER
12869 (struct cmd_vf_split_drop_en_result,
12871 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
12872 TOKEN_STRING_INITIALIZER
12873 (struct cmd_vf_split_drop_en_result,
12877 cmd_set_vf_split_drop_en_parsed(
12878 void *parsed_result,
12879 __attribute__((unused)) struct cmdline *cl,
12880 __attribute__((unused)) void *data)
12882 struct cmd_vf_split_drop_en_result *res = parsed_result;
12883 int ret = -ENOTSUP;
12884 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12886 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12889 #ifdef RTE_LIBRTE_IXGBE_PMD
12890 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
12897 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12900 printf("invalid port_id %d\n", res->port_id);
12903 printf("not supported on port %d\n", res->port_id);
12906 printf("programming error: (%s)\n", strerror(-ret));
12910 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
12911 .f = cmd_set_vf_split_drop_en_parsed,
12913 .help_str = "set vf split drop <port_id> <vf_id> on|off",
12915 (void *)&cmd_vf_split_drop_en_set,
12916 (void *)&cmd_vf_split_drop_en_vf,
12917 (void *)&cmd_vf_split_drop_en_split,
12918 (void *)&cmd_vf_split_drop_en_drop,
12919 (void *)&cmd_vf_split_drop_en_port_id,
12920 (void *)&cmd_vf_split_drop_en_vf_id,
12921 (void *)&cmd_vf_split_drop_en_on_off,
12926 /* vf mac address configuration */
12928 /* Common result structure for vf mac address */
12929 struct cmd_set_vf_mac_addr_result {
12930 cmdline_fixed_string_t set;
12931 cmdline_fixed_string_t vf;
12932 cmdline_fixed_string_t mac;
12933 cmdline_fixed_string_t addr;
12936 struct ether_addr mac_addr;
12940 /* Common CLI fields for vf split drop enable disable */
12941 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
12942 TOKEN_STRING_INITIALIZER
12943 (struct cmd_set_vf_mac_addr_result,
12945 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
12946 TOKEN_STRING_INITIALIZER
12947 (struct cmd_set_vf_mac_addr_result,
12949 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
12950 TOKEN_STRING_INITIALIZER
12951 (struct cmd_set_vf_mac_addr_result,
12953 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
12954 TOKEN_STRING_INITIALIZER
12955 (struct cmd_set_vf_mac_addr_result,
12957 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
12958 TOKEN_NUM_INITIALIZER
12959 (struct cmd_set_vf_mac_addr_result,
12961 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
12962 TOKEN_NUM_INITIALIZER
12963 (struct cmd_set_vf_mac_addr_result,
12965 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
12966 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
12970 cmd_set_vf_mac_addr_parsed(
12971 void *parsed_result,
12972 __attribute__((unused)) struct cmdline *cl,
12973 __attribute__((unused)) void *data)
12975 struct cmd_set_vf_mac_addr_result *res = parsed_result;
12976 int ret = -ENOTSUP;
12978 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12981 #ifdef RTE_LIBRTE_IXGBE_PMD
12982 if (ret == -ENOTSUP)
12983 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
12986 #ifdef RTE_LIBRTE_I40E_PMD
12987 if (ret == -ENOTSUP)
12988 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
12991 #ifdef RTE_LIBRTE_BNXT_PMD
12992 if (ret == -ENOTSUP)
12993 ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
13001 printf("invalid vf_id %d or mac_addr\n", res->vf_id);
13004 printf("invalid port_id %d\n", res->port_id);
13007 printf("function not implemented\n");
13010 printf("programming error: (%s)\n", strerror(-ret));
13014 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
13015 .f = cmd_set_vf_mac_addr_parsed,
13017 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
13019 (void *)&cmd_set_vf_mac_addr_set,
13020 (void *)&cmd_set_vf_mac_addr_vf,
13021 (void *)&cmd_set_vf_mac_addr_mac,
13022 (void *)&cmd_set_vf_mac_addr_addr,
13023 (void *)&cmd_set_vf_mac_addr_port_id,
13024 (void *)&cmd_set_vf_mac_addr_vf_id,
13025 (void *)&cmd_set_vf_mac_addr_mac_addr,
13030 /* MACsec configuration */
13032 /* Common result structure for MACsec offload enable */
13033 struct cmd_macsec_offload_on_result {
13034 cmdline_fixed_string_t set;
13035 cmdline_fixed_string_t macsec;
13036 cmdline_fixed_string_t offload;
13038 cmdline_fixed_string_t on;
13039 cmdline_fixed_string_t encrypt;
13040 cmdline_fixed_string_t en_on_off;
13041 cmdline_fixed_string_t replay_protect;
13042 cmdline_fixed_string_t rp_on_off;
13045 /* Common CLI fields for MACsec offload disable */
13046 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
13047 TOKEN_STRING_INITIALIZER
13048 (struct cmd_macsec_offload_on_result,
13050 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
13051 TOKEN_STRING_INITIALIZER
13052 (struct cmd_macsec_offload_on_result,
13054 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
13055 TOKEN_STRING_INITIALIZER
13056 (struct cmd_macsec_offload_on_result,
13057 offload, "offload");
13058 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
13059 TOKEN_NUM_INITIALIZER
13060 (struct cmd_macsec_offload_on_result,
13062 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
13063 TOKEN_STRING_INITIALIZER
13064 (struct cmd_macsec_offload_on_result,
13066 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
13067 TOKEN_STRING_INITIALIZER
13068 (struct cmd_macsec_offload_on_result,
13069 encrypt, "encrypt");
13070 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
13071 TOKEN_STRING_INITIALIZER
13072 (struct cmd_macsec_offload_on_result,
13073 en_on_off, "on#off");
13074 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
13075 TOKEN_STRING_INITIALIZER
13076 (struct cmd_macsec_offload_on_result,
13077 replay_protect, "replay-protect");
13078 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
13079 TOKEN_STRING_INITIALIZER
13080 (struct cmd_macsec_offload_on_result,
13081 rp_on_off, "on#off");
13084 cmd_set_macsec_offload_on_parsed(
13085 void *parsed_result,
13086 __attribute__((unused)) struct cmdline *cl,
13087 __attribute__((unused)) void *data)
13089 struct cmd_macsec_offload_on_result *res = parsed_result;
13090 int ret = -ENOTSUP;
13091 portid_t port_id = res->port_id;
13092 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
13093 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
13095 if (port_id_is_invalid(port_id, ENABLED_WARN))
13097 if (!port_is_stopped(port_id)) {
13098 printf("Please stop port %d first\n", port_id);
13102 ports[port_id].tx_ol_flags |= TESTPMD_TX_OFFLOAD_MACSEC;
13103 ports[port_id].dev_conf.txmode.offloads |= DEV_TX_OFFLOAD_MACSEC_INSERT;
13104 #ifdef RTE_LIBRTE_IXGBE_PMD
13105 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
13112 cmd_reconfig_device_queue(port_id, 1, 1);
13115 printf("invalid port_id %d\n", port_id);
13118 printf("not supported on port %d\n", port_id);
13121 printf("programming error: (%s)\n", strerror(-ret));
13125 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
13126 .f = cmd_set_macsec_offload_on_parsed,
13128 .help_str = "set macsec offload <port_id> on "
13129 "encrypt on|off replay-protect on|off",
13131 (void *)&cmd_macsec_offload_on_set,
13132 (void *)&cmd_macsec_offload_on_macsec,
13133 (void *)&cmd_macsec_offload_on_offload,
13134 (void *)&cmd_macsec_offload_on_port_id,
13135 (void *)&cmd_macsec_offload_on_on,
13136 (void *)&cmd_macsec_offload_on_encrypt,
13137 (void *)&cmd_macsec_offload_on_en_on_off,
13138 (void *)&cmd_macsec_offload_on_replay_protect,
13139 (void *)&cmd_macsec_offload_on_rp_on_off,
13144 /* Common result structure for MACsec offload disable */
13145 struct cmd_macsec_offload_off_result {
13146 cmdline_fixed_string_t set;
13147 cmdline_fixed_string_t macsec;
13148 cmdline_fixed_string_t offload;
13150 cmdline_fixed_string_t off;
13153 /* Common CLI fields for MACsec offload disable */
13154 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
13155 TOKEN_STRING_INITIALIZER
13156 (struct cmd_macsec_offload_off_result,
13158 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
13159 TOKEN_STRING_INITIALIZER
13160 (struct cmd_macsec_offload_off_result,
13162 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
13163 TOKEN_STRING_INITIALIZER
13164 (struct cmd_macsec_offload_off_result,
13165 offload, "offload");
13166 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
13167 TOKEN_NUM_INITIALIZER
13168 (struct cmd_macsec_offload_off_result,
13170 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
13171 TOKEN_STRING_INITIALIZER
13172 (struct cmd_macsec_offload_off_result,
13176 cmd_set_macsec_offload_off_parsed(
13177 void *parsed_result,
13178 __attribute__((unused)) struct cmdline *cl,
13179 __attribute__((unused)) void *data)
13181 struct cmd_macsec_offload_off_result *res = parsed_result;
13182 int ret = -ENOTSUP;
13183 portid_t port_id = res->port_id;
13185 if (port_id_is_invalid(port_id, ENABLED_WARN))
13187 if (!port_is_stopped(port_id)) {
13188 printf("Please stop port %d first\n", port_id);
13192 ports[port_id].tx_ol_flags &= ~TESTPMD_TX_OFFLOAD_MACSEC;
13193 ports[port_id].dev_conf.txmode.offloads &=
13194 ~DEV_TX_OFFLOAD_MACSEC_INSERT;
13195 #ifdef RTE_LIBRTE_IXGBE_PMD
13196 ret = rte_pmd_ixgbe_macsec_disable(port_id);
13201 cmd_reconfig_device_queue(port_id, 1, 1);
13204 printf("invalid port_id %d\n", port_id);
13207 printf("not supported on port %d\n", port_id);
13210 printf("programming error: (%s)\n", strerror(-ret));
13214 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
13215 .f = cmd_set_macsec_offload_off_parsed,
13217 .help_str = "set macsec offload <port_id> off",
13219 (void *)&cmd_macsec_offload_off_set,
13220 (void *)&cmd_macsec_offload_off_macsec,
13221 (void *)&cmd_macsec_offload_off_offload,
13222 (void *)&cmd_macsec_offload_off_port_id,
13223 (void *)&cmd_macsec_offload_off_off,
13228 /* Common result structure for MACsec secure connection configure */
13229 struct cmd_macsec_sc_result {
13230 cmdline_fixed_string_t set;
13231 cmdline_fixed_string_t macsec;
13232 cmdline_fixed_string_t sc;
13233 cmdline_fixed_string_t tx_rx;
13235 struct ether_addr mac;
13239 /* Common CLI fields for MACsec secure connection configure */
13240 cmdline_parse_token_string_t cmd_macsec_sc_set =
13241 TOKEN_STRING_INITIALIZER
13242 (struct cmd_macsec_sc_result,
13244 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
13245 TOKEN_STRING_INITIALIZER
13246 (struct cmd_macsec_sc_result,
13248 cmdline_parse_token_string_t cmd_macsec_sc_sc =
13249 TOKEN_STRING_INITIALIZER
13250 (struct cmd_macsec_sc_result,
13252 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
13253 TOKEN_STRING_INITIALIZER
13254 (struct cmd_macsec_sc_result,
13256 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
13257 TOKEN_NUM_INITIALIZER
13258 (struct cmd_macsec_sc_result,
13260 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
13261 TOKEN_ETHERADDR_INITIALIZER
13262 (struct cmd_macsec_sc_result,
13264 cmdline_parse_token_num_t cmd_macsec_sc_pi =
13265 TOKEN_NUM_INITIALIZER
13266 (struct cmd_macsec_sc_result,
13270 cmd_set_macsec_sc_parsed(
13271 void *parsed_result,
13272 __attribute__((unused)) struct cmdline *cl,
13273 __attribute__((unused)) void *data)
13275 struct cmd_macsec_sc_result *res = parsed_result;
13276 int ret = -ENOTSUP;
13277 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
13279 #ifdef RTE_LIBRTE_IXGBE_PMD
13281 rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
13282 res->mac.addr_bytes) :
13283 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
13284 res->mac.addr_bytes, res->pi);
13286 RTE_SET_USED(is_tx);
13292 printf("invalid port_id %d\n", res->port_id);
13295 printf("not supported on port %d\n", res->port_id);
13298 printf("programming error: (%s)\n", strerror(-ret));
13302 cmdline_parse_inst_t cmd_set_macsec_sc = {
13303 .f = cmd_set_macsec_sc_parsed,
13305 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
13307 (void *)&cmd_macsec_sc_set,
13308 (void *)&cmd_macsec_sc_macsec,
13309 (void *)&cmd_macsec_sc_sc,
13310 (void *)&cmd_macsec_sc_tx_rx,
13311 (void *)&cmd_macsec_sc_port_id,
13312 (void *)&cmd_macsec_sc_mac,
13313 (void *)&cmd_macsec_sc_pi,
13318 /* Common result structure for MACsec secure connection configure */
13319 struct cmd_macsec_sa_result {
13320 cmdline_fixed_string_t set;
13321 cmdline_fixed_string_t macsec;
13322 cmdline_fixed_string_t sa;
13323 cmdline_fixed_string_t tx_rx;
13328 cmdline_fixed_string_t key;
13331 /* Common CLI fields for MACsec secure connection configure */
13332 cmdline_parse_token_string_t cmd_macsec_sa_set =
13333 TOKEN_STRING_INITIALIZER
13334 (struct cmd_macsec_sa_result,
13336 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
13337 TOKEN_STRING_INITIALIZER
13338 (struct cmd_macsec_sa_result,
13340 cmdline_parse_token_string_t cmd_macsec_sa_sa =
13341 TOKEN_STRING_INITIALIZER
13342 (struct cmd_macsec_sa_result,
13344 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
13345 TOKEN_STRING_INITIALIZER
13346 (struct cmd_macsec_sa_result,
13348 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
13349 TOKEN_NUM_INITIALIZER
13350 (struct cmd_macsec_sa_result,
13352 cmdline_parse_token_num_t cmd_macsec_sa_idx =
13353 TOKEN_NUM_INITIALIZER
13354 (struct cmd_macsec_sa_result,
13356 cmdline_parse_token_num_t cmd_macsec_sa_an =
13357 TOKEN_NUM_INITIALIZER
13358 (struct cmd_macsec_sa_result,
13360 cmdline_parse_token_num_t cmd_macsec_sa_pn =
13361 TOKEN_NUM_INITIALIZER
13362 (struct cmd_macsec_sa_result,
13364 cmdline_parse_token_string_t cmd_macsec_sa_key =
13365 TOKEN_STRING_INITIALIZER
13366 (struct cmd_macsec_sa_result,
13370 cmd_set_macsec_sa_parsed(
13371 void *parsed_result,
13372 __attribute__((unused)) struct cmdline *cl,
13373 __attribute__((unused)) void *data)
13375 struct cmd_macsec_sa_result *res = parsed_result;
13376 int ret = -ENOTSUP;
13377 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
13378 uint8_t key[16] = { 0 };
13384 key_len = strlen(res->key) / 2;
13388 for (i = 0; i < key_len; i++) {
13389 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
13392 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
13395 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
13398 #ifdef RTE_LIBRTE_IXGBE_PMD
13400 rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
13401 res->idx, res->an, res->pn, key) :
13402 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
13403 res->idx, res->an, res->pn, key);
13405 RTE_SET_USED(is_tx);
13412 printf("invalid idx %d or an %d\n", res->idx, res->an);
13415 printf("invalid port_id %d\n", res->port_id);
13418 printf("not supported on port %d\n", res->port_id);
13421 printf("programming error: (%s)\n", strerror(-ret));
13425 cmdline_parse_inst_t cmd_set_macsec_sa = {
13426 .f = cmd_set_macsec_sa_parsed,
13428 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
13430 (void *)&cmd_macsec_sa_set,
13431 (void *)&cmd_macsec_sa_macsec,
13432 (void *)&cmd_macsec_sa_sa,
13433 (void *)&cmd_macsec_sa_tx_rx,
13434 (void *)&cmd_macsec_sa_port_id,
13435 (void *)&cmd_macsec_sa_idx,
13436 (void *)&cmd_macsec_sa_an,
13437 (void *)&cmd_macsec_sa_pn,
13438 (void *)&cmd_macsec_sa_key,
13443 /* VF unicast promiscuous mode configuration */
13445 /* Common result structure for VF unicast promiscuous mode */
13446 struct cmd_vf_promisc_result {
13447 cmdline_fixed_string_t set;
13448 cmdline_fixed_string_t vf;
13449 cmdline_fixed_string_t promisc;
13452 cmdline_fixed_string_t on_off;
13455 /* Common CLI fields for VF unicast promiscuous mode enable disable */
13456 cmdline_parse_token_string_t cmd_vf_promisc_set =
13457 TOKEN_STRING_INITIALIZER
13458 (struct cmd_vf_promisc_result,
13460 cmdline_parse_token_string_t cmd_vf_promisc_vf =
13461 TOKEN_STRING_INITIALIZER
13462 (struct cmd_vf_promisc_result,
13464 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
13465 TOKEN_STRING_INITIALIZER
13466 (struct cmd_vf_promisc_result,
13467 promisc, "promisc");
13468 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
13469 TOKEN_NUM_INITIALIZER
13470 (struct cmd_vf_promisc_result,
13472 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
13473 TOKEN_NUM_INITIALIZER
13474 (struct cmd_vf_promisc_result,
13476 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
13477 TOKEN_STRING_INITIALIZER
13478 (struct cmd_vf_promisc_result,
13482 cmd_set_vf_promisc_parsed(
13483 void *parsed_result,
13484 __attribute__((unused)) struct cmdline *cl,
13485 __attribute__((unused)) void *data)
13487 struct cmd_vf_promisc_result *res = parsed_result;
13488 int ret = -ENOTSUP;
13490 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13492 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13495 #ifdef RTE_LIBRTE_I40E_PMD
13496 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
13497 res->vf_id, is_on);
13504 printf("invalid vf_id %d\n", res->vf_id);
13507 printf("invalid port_id %d\n", res->port_id);
13510 printf("function not implemented\n");
13513 printf("programming error: (%s)\n", strerror(-ret));
13517 cmdline_parse_inst_t cmd_set_vf_promisc = {
13518 .f = cmd_set_vf_promisc_parsed,
13520 .help_str = "set vf promisc <port_id> <vf_id> on|off: "
13521 "Set unicast promiscuous mode for a VF from the PF",
13523 (void *)&cmd_vf_promisc_set,
13524 (void *)&cmd_vf_promisc_vf,
13525 (void *)&cmd_vf_promisc_promisc,
13526 (void *)&cmd_vf_promisc_port_id,
13527 (void *)&cmd_vf_promisc_vf_id,
13528 (void *)&cmd_vf_promisc_on_off,
13533 /* VF multicast promiscuous mode configuration */
13535 /* Common result structure for VF multicast promiscuous mode */
13536 struct cmd_vf_allmulti_result {
13537 cmdline_fixed_string_t set;
13538 cmdline_fixed_string_t vf;
13539 cmdline_fixed_string_t allmulti;
13542 cmdline_fixed_string_t on_off;
13545 /* Common CLI fields for VF multicast promiscuous mode enable disable */
13546 cmdline_parse_token_string_t cmd_vf_allmulti_set =
13547 TOKEN_STRING_INITIALIZER
13548 (struct cmd_vf_allmulti_result,
13550 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
13551 TOKEN_STRING_INITIALIZER
13552 (struct cmd_vf_allmulti_result,
13554 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
13555 TOKEN_STRING_INITIALIZER
13556 (struct cmd_vf_allmulti_result,
13557 allmulti, "allmulti");
13558 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
13559 TOKEN_NUM_INITIALIZER
13560 (struct cmd_vf_allmulti_result,
13562 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
13563 TOKEN_NUM_INITIALIZER
13564 (struct cmd_vf_allmulti_result,
13566 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
13567 TOKEN_STRING_INITIALIZER
13568 (struct cmd_vf_allmulti_result,
13572 cmd_set_vf_allmulti_parsed(
13573 void *parsed_result,
13574 __attribute__((unused)) struct cmdline *cl,
13575 __attribute__((unused)) void *data)
13577 struct cmd_vf_allmulti_result *res = parsed_result;
13578 int ret = -ENOTSUP;
13580 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13582 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13585 #ifdef RTE_LIBRTE_I40E_PMD
13586 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
13587 res->vf_id, is_on);
13594 printf("invalid vf_id %d\n", res->vf_id);
13597 printf("invalid port_id %d\n", res->port_id);
13600 printf("function not implemented\n");
13603 printf("programming error: (%s)\n", strerror(-ret));
13607 cmdline_parse_inst_t cmd_set_vf_allmulti = {
13608 .f = cmd_set_vf_allmulti_parsed,
13610 .help_str = "set vf allmulti <port_id> <vf_id> on|off: "
13611 "Set multicast promiscuous mode for a VF from the PF",
13613 (void *)&cmd_vf_allmulti_set,
13614 (void *)&cmd_vf_allmulti_vf,
13615 (void *)&cmd_vf_allmulti_allmulti,
13616 (void *)&cmd_vf_allmulti_port_id,
13617 (void *)&cmd_vf_allmulti_vf_id,
13618 (void *)&cmd_vf_allmulti_on_off,
13623 /* vf broadcast mode configuration */
13625 /* Common result structure for vf broadcast */
13626 struct cmd_set_vf_broadcast_result {
13627 cmdline_fixed_string_t set;
13628 cmdline_fixed_string_t vf;
13629 cmdline_fixed_string_t broadcast;
13632 cmdline_fixed_string_t on_off;
13635 /* Common CLI fields for vf broadcast enable disable */
13636 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
13637 TOKEN_STRING_INITIALIZER
13638 (struct cmd_set_vf_broadcast_result,
13640 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
13641 TOKEN_STRING_INITIALIZER
13642 (struct cmd_set_vf_broadcast_result,
13644 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
13645 TOKEN_STRING_INITIALIZER
13646 (struct cmd_set_vf_broadcast_result,
13647 broadcast, "broadcast");
13648 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
13649 TOKEN_NUM_INITIALIZER
13650 (struct cmd_set_vf_broadcast_result,
13652 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
13653 TOKEN_NUM_INITIALIZER
13654 (struct cmd_set_vf_broadcast_result,
13656 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
13657 TOKEN_STRING_INITIALIZER
13658 (struct cmd_set_vf_broadcast_result,
13662 cmd_set_vf_broadcast_parsed(
13663 void *parsed_result,
13664 __attribute__((unused)) struct cmdline *cl,
13665 __attribute__((unused)) void *data)
13667 struct cmd_set_vf_broadcast_result *res = parsed_result;
13668 int ret = -ENOTSUP;
13670 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13672 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13675 #ifdef RTE_LIBRTE_I40E_PMD
13676 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
13677 res->vf_id, is_on);
13684 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13687 printf("invalid port_id %d\n", res->port_id);
13690 printf("function not implemented\n");
13693 printf("programming error: (%s)\n", strerror(-ret));
13697 cmdline_parse_inst_t cmd_set_vf_broadcast = {
13698 .f = cmd_set_vf_broadcast_parsed,
13700 .help_str = "set vf broadcast <port_id> <vf_id> on|off",
13702 (void *)&cmd_set_vf_broadcast_set,
13703 (void *)&cmd_set_vf_broadcast_vf,
13704 (void *)&cmd_set_vf_broadcast_broadcast,
13705 (void *)&cmd_set_vf_broadcast_port_id,
13706 (void *)&cmd_set_vf_broadcast_vf_id,
13707 (void *)&cmd_set_vf_broadcast_on_off,
13712 /* vf vlan tag configuration */
13714 /* Common result structure for vf vlan tag */
13715 struct cmd_set_vf_vlan_tag_result {
13716 cmdline_fixed_string_t set;
13717 cmdline_fixed_string_t vf;
13718 cmdline_fixed_string_t vlan;
13719 cmdline_fixed_string_t tag;
13722 cmdline_fixed_string_t on_off;
13725 /* Common CLI fields for vf vlan tag enable disable */
13726 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
13727 TOKEN_STRING_INITIALIZER
13728 (struct cmd_set_vf_vlan_tag_result,
13730 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
13731 TOKEN_STRING_INITIALIZER
13732 (struct cmd_set_vf_vlan_tag_result,
13734 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
13735 TOKEN_STRING_INITIALIZER
13736 (struct cmd_set_vf_vlan_tag_result,
13738 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
13739 TOKEN_STRING_INITIALIZER
13740 (struct cmd_set_vf_vlan_tag_result,
13742 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
13743 TOKEN_NUM_INITIALIZER
13744 (struct cmd_set_vf_vlan_tag_result,
13746 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
13747 TOKEN_NUM_INITIALIZER
13748 (struct cmd_set_vf_vlan_tag_result,
13750 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
13751 TOKEN_STRING_INITIALIZER
13752 (struct cmd_set_vf_vlan_tag_result,
13756 cmd_set_vf_vlan_tag_parsed(
13757 void *parsed_result,
13758 __attribute__((unused)) struct cmdline *cl,
13759 __attribute__((unused)) void *data)
13761 struct cmd_set_vf_vlan_tag_result *res = parsed_result;
13762 int ret = -ENOTSUP;
13764 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13766 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13769 #ifdef RTE_LIBRTE_I40E_PMD
13770 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
13771 res->vf_id, is_on);
13778 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13781 printf("invalid port_id %d\n", res->port_id);
13784 printf("function not implemented\n");
13787 printf("programming error: (%s)\n", strerror(-ret));
13791 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
13792 .f = cmd_set_vf_vlan_tag_parsed,
13794 .help_str = "set vf vlan tag <port_id> <vf_id> on|off",
13796 (void *)&cmd_set_vf_vlan_tag_set,
13797 (void *)&cmd_set_vf_vlan_tag_vf,
13798 (void *)&cmd_set_vf_vlan_tag_vlan,
13799 (void *)&cmd_set_vf_vlan_tag_tag,
13800 (void *)&cmd_set_vf_vlan_tag_port_id,
13801 (void *)&cmd_set_vf_vlan_tag_vf_id,
13802 (void *)&cmd_set_vf_vlan_tag_on_off,
13807 /* Common definition of VF and TC TX bandwidth configuration */
13808 struct cmd_vf_tc_bw_result {
13809 cmdline_fixed_string_t set;
13810 cmdline_fixed_string_t vf;
13811 cmdline_fixed_string_t tc;
13812 cmdline_fixed_string_t tx;
13813 cmdline_fixed_string_t min_bw;
13814 cmdline_fixed_string_t max_bw;
13815 cmdline_fixed_string_t strict_link_prio;
13820 cmdline_fixed_string_t bw_list;
13824 cmdline_parse_token_string_t cmd_vf_tc_bw_set =
13825 TOKEN_STRING_INITIALIZER
13826 (struct cmd_vf_tc_bw_result,
13828 cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
13829 TOKEN_STRING_INITIALIZER
13830 (struct cmd_vf_tc_bw_result,
13832 cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
13833 TOKEN_STRING_INITIALIZER
13834 (struct cmd_vf_tc_bw_result,
13836 cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
13837 TOKEN_STRING_INITIALIZER
13838 (struct cmd_vf_tc_bw_result,
13840 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio =
13841 TOKEN_STRING_INITIALIZER
13842 (struct cmd_vf_tc_bw_result,
13843 strict_link_prio, "strict-link-priority");
13844 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw =
13845 TOKEN_STRING_INITIALIZER
13846 (struct cmd_vf_tc_bw_result,
13847 min_bw, "min-bandwidth");
13848 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
13849 TOKEN_STRING_INITIALIZER
13850 (struct cmd_vf_tc_bw_result,
13851 max_bw, "max-bandwidth");
13852 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
13853 TOKEN_NUM_INITIALIZER
13854 (struct cmd_vf_tc_bw_result,
13856 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
13857 TOKEN_NUM_INITIALIZER
13858 (struct cmd_vf_tc_bw_result,
13860 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no =
13861 TOKEN_NUM_INITIALIZER
13862 (struct cmd_vf_tc_bw_result,
13864 cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
13865 TOKEN_NUM_INITIALIZER
13866 (struct cmd_vf_tc_bw_result,
13868 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
13869 TOKEN_STRING_INITIALIZER
13870 (struct cmd_vf_tc_bw_result,
13872 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map =
13873 TOKEN_NUM_INITIALIZER
13874 (struct cmd_vf_tc_bw_result,
13877 /* VF max bandwidth setting */
13879 cmd_vf_max_bw_parsed(
13880 void *parsed_result,
13881 __attribute__((unused)) struct cmdline *cl,
13882 __attribute__((unused)) void *data)
13884 struct cmd_vf_tc_bw_result *res = parsed_result;
13885 int ret = -ENOTSUP;
13887 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13890 #ifdef RTE_LIBRTE_I40E_PMD
13891 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id,
13892 res->vf_id, res->bw);
13899 printf("invalid vf_id %d or bandwidth %d\n",
13900 res->vf_id, res->bw);
13903 printf("invalid port_id %d\n", res->port_id);
13906 printf("function not implemented\n");
13909 printf("programming error: (%s)\n", strerror(-ret));
13913 cmdline_parse_inst_t cmd_vf_max_bw = {
13914 .f = cmd_vf_max_bw_parsed,
13916 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
13918 (void *)&cmd_vf_tc_bw_set,
13919 (void *)&cmd_vf_tc_bw_vf,
13920 (void *)&cmd_vf_tc_bw_tx,
13921 (void *)&cmd_vf_tc_bw_max_bw,
13922 (void *)&cmd_vf_tc_bw_port_id,
13923 (void *)&cmd_vf_tc_bw_vf_id,
13924 (void *)&cmd_vf_tc_bw_bw,
13930 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
13935 const char *p, *p0 = str;
13942 p = strchr(p0, '(');
13944 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
13948 p0 = strchr(p, ')');
13950 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
13954 if (size >= sizeof(s)) {
13955 printf("The string size exceeds the internal buffer size\n");
13958 snprintf(s, sizeof(s), "%.*s", size, p);
13959 ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
13961 printf("Failed to get the bandwidth list. ");
13965 for (i = 0; i < ret; i++)
13966 bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
13971 /* TC min bandwidth setting */
13973 cmd_vf_tc_min_bw_parsed(
13974 void *parsed_result,
13975 __attribute__((unused)) struct cmdline *cl,
13976 __attribute__((unused)) void *data)
13978 struct cmd_vf_tc_bw_result *res = parsed_result;
13981 int ret = -ENOTSUP;
13983 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13986 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
13990 #ifdef RTE_LIBRTE_I40E_PMD
13991 ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
13999 printf("invalid vf_id %d or bandwidth\n", res->vf_id);
14002 printf("invalid port_id %d\n", res->port_id);
14005 printf("function not implemented\n");
14008 printf("programming error: (%s)\n", strerror(-ret));
14012 cmdline_parse_inst_t cmd_vf_tc_min_bw = {
14013 .f = cmd_vf_tc_min_bw_parsed,
14015 .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
14016 " <bw1, bw2, ...>",
14018 (void *)&cmd_vf_tc_bw_set,
14019 (void *)&cmd_vf_tc_bw_vf,
14020 (void *)&cmd_vf_tc_bw_tc,
14021 (void *)&cmd_vf_tc_bw_tx,
14022 (void *)&cmd_vf_tc_bw_min_bw,
14023 (void *)&cmd_vf_tc_bw_port_id,
14024 (void *)&cmd_vf_tc_bw_vf_id,
14025 (void *)&cmd_vf_tc_bw_bw_list,
14031 cmd_tc_min_bw_parsed(
14032 void *parsed_result,
14033 __attribute__((unused)) struct cmdline *cl,
14034 __attribute__((unused)) void *data)
14036 struct cmd_vf_tc_bw_result *res = parsed_result;
14037 struct rte_port *port;
14040 int ret = -ENOTSUP;
14042 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14045 port = &ports[res->port_id];
14046 /** Check if the port is not started **/
14047 if (port->port_status != RTE_PORT_STOPPED) {
14048 printf("Please stop port %d first\n", res->port_id);
14052 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
14056 #ifdef RTE_LIBRTE_IXGBE_PMD
14057 ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw);
14064 printf("invalid bandwidth\n");
14067 printf("invalid port_id %d\n", res->port_id);
14070 printf("function not implemented\n");
14073 printf("programming error: (%s)\n", strerror(-ret));
14077 cmdline_parse_inst_t cmd_tc_min_bw = {
14078 .f = cmd_tc_min_bw_parsed,
14080 .help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>",
14082 (void *)&cmd_vf_tc_bw_set,
14083 (void *)&cmd_vf_tc_bw_tc,
14084 (void *)&cmd_vf_tc_bw_tx,
14085 (void *)&cmd_vf_tc_bw_min_bw,
14086 (void *)&cmd_vf_tc_bw_port_id,
14087 (void *)&cmd_vf_tc_bw_bw_list,
14092 /* TC max bandwidth setting */
14094 cmd_vf_tc_max_bw_parsed(
14095 void *parsed_result,
14096 __attribute__((unused)) struct cmdline *cl,
14097 __attribute__((unused)) void *data)
14099 struct cmd_vf_tc_bw_result *res = parsed_result;
14100 int ret = -ENOTSUP;
14102 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14105 #ifdef RTE_LIBRTE_I40E_PMD
14106 ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id,
14107 res->tc_no, res->bw);
14114 printf("invalid vf_id %d, tc_no %d or bandwidth %d\n",
14115 res->vf_id, res->tc_no, res->bw);
14118 printf("invalid port_id %d\n", res->port_id);
14121 printf("function not implemented\n");
14124 printf("programming error: (%s)\n", strerror(-ret));
14128 cmdline_parse_inst_t cmd_vf_tc_max_bw = {
14129 .f = cmd_vf_tc_max_bw_parsed,
14131 .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>"
14134 (void *)&cmd_vf_tc_bw_set,
14135 (void *)&cmd_vf_tc_bw_vf,
14136 (void *)&cmd_vf_tc_bw_tc,
14137 (void *)&cmd_vf_tc_bw_tx,
14138 (void *)&cmd_vf_tc_bw_max_bw,
14139 (void *)&cmd_vf_tc_bw_port_id,
14140 (void *)&cmd_vf_tc_bw_vf_id,
14141 (void *)&cmd_vf_tc_bw_tc_no,
14142 (void *)&cmd_vf_tc_bw_bw,
14148 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
14150 /* *** Set Port default Traffic Management Hierarchy *** */
14151 struct cmd_set_port_tm_hierarchy_default_result {
14152 cmdline_fixed_string_t set;
14153 cmdline_fixed_string_t port;
14154 cmdline_fixed_string_t tm;
14155 cmdline_fixed_string_t hierarchy;
14156 cmdline_fixed_string_t def;
14160 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_set =
14161 TOKEN_STRING_INITIALIZER(
14162 struct cmd_set_port_tm_hierarchy_default_result, set, "set");
14163 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_port =
14164 TOKEN_STRING_INITIALIZER(
14165 struct cmd_set_port_tm_hierarchy_default_result, port, "port");
14166 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_tm =
14167 TOKEN_STRING_INITIALIZER(
14168 struct cmd_set_port_tm_hierarchy_default_result, tm, "tm");
14169 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_hierarchy =
14170 TOKEN_STRING_INITIALIZER(
14171 struct cmd_set_port_tm_hierarchy_default_result,
14172 hierarchy, "hierarchy");
14173 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_default =
14174 TOKEN_STRING_INITIALIZER(
14175 struct cmd_set_port_tm_hierarchy_default_result,
14177 cmdline_parse_token_num_t cmd_set_port_tm_hierarchy_default_port_id =
14178 TOKEN_NUM_INITIALIZER(
14179 struct cmd_set_port_tm_hierarchy_default_result,
14182 static void cmd_set_port_tm_hierarchy_default_parsed(void *parsed_result,
14183 __attribute__((unused)) struct cmdline *cl,
14184 __attribute__((unused)) void *data)
14186 struct cmd_set_port_tm_hierarchy_default_result *res = parsed_result;
14187 struct rte_port *p;
14188 portid_t port_id = res->port_id;
14190 if (port_id_is_invalid(port_id, ENABLED_WARN))
14193 p = &ports[port_id];
14196 if (p->softport.tm_flag == 0) {
14197 printf(" tm not enabled on port %u (error)\n", port_id);
14201 /* Forward mode: tm */
14202 if (strcmp(cur_fwd_config.fwd_eng->fwd_mode_name, "tm")) {
14203 printf(" tm mode not enabled(error)\n");
14207 /* Set the default tm hierarchy */
14208 p->softport.tm.default_hierarchy_enable = 1;
14211 cmdline_parse_inst_t cmd_set_port_tm_hierarchy_default = {
14212 .f = cmd_set_port_tm_hierarchy_default_parsed,
14214 .help_str = "set port tm hierarchy default <port_id>",
14216 (void *)&cmd_set_port_tm_hierarchy_default_set,
14217 (void *)&cmd_set_port_tm_hierarchy_default_port,
14218 (void *)&cmd_set_port_tm_hierarchy_default_tm,
14219 (void *)&cmd_set_port_tm_hierarchy_default_hierarchy,
14220 (void *)&cmd_set_port_tm_hierarchy_default_default,
14221 (void *)&cmd_set_port_tm_hierarchy_default_port_id,
14227 /* Strict link priority scheduling mode setting */
14229 cmd_strict_link_prio_parsed(
14230 void *parsed_result,
14231 __attribute__((unused)) struct cmdline *cl,
14232 __attribute__((unused)) void *data)
14234 struct cmd_vf_tc_bw_result *res = parsed_result;
14235 int ret = -ENOTSUP;
14237 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14240 #ifdef RTE_LIBRTE_I40E_PMD
14241 ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map);
14248 printf("invalid tc_bitmap 0x%x\n", res->tc_map);
14251 printf("invalid port_id %d\n", res->port_id);
14254 printf("function not implemented\n");
14257 printf("programming error: (%s)\n", strerror(-ret));
14261 cmdline_parse_inst_t cmd_strict_link_prio = {
14262 .f = cmd_strict_link_prio_parsed,
14264 .help_str = "set tx strict-link-priority <port_id> <tc_bitmap>",
14266 (void *)&cmd_vf_tc_bw_set,
14267 (void *)&cmd_vf_tc_bw_tx,
14268 (void *)&cmd_vf_tc_bw_strict_link_prio,
14269 (void *)&cmd_vf_tc_bw_port_id,
14270 (void *)&cmd_vf_tc_bw_tc_map,
14275 /* Load dynamic device personalization*/
14276 struct cmd_ddp_add_result {
14277 cmdline_fixed_string_t ddp;
14278 cmdline_fixed_string_t add;
14283 cmdline_parse_token_string_t cmd_ddp_add_ddp =
14284 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp");
14285 cmdline_parse_token_string_t cmd_ddp_add_add =
14286 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add");
14287 cmdline_parse_token_num_t cmd_ddp_add_port_id =
14288 TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id, UINT16);
14289 cmdline_parse_token_string_t cmd_ddp_add_filepath =
14290 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL);
14293 cmd_ddp_add_parsed(
14294 void *parsed_result,
14295 __attribute__((unused)) struct cmdline *cl,
14296 __attribute__((unused)) void *data)
14298 struct cmd_ddp_add_result *res = parsed_result;
14304 int ret = -ENOTSUP;
14306 if (res->port_id > nb_ports) {
14307 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
14311 if (!all_ports_stopped()) {
14312 printf("Please stop all ports first\n");
14316 filepath = strdup(res->filepath);
14317 if (filepath == NULL) {
14318 printf("Failed to allocate memory\n");
14321 file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ',');
14323 buff = open_ddp_package_file(file_fld[0], &size);
14325 free((void *)filepath);
14329 #ifdef RTE_LIBRTE_I40E_PMD
14330 if (ret == -ENOTSUP)
14331 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
14333 RTE_PMD_I40E_PKG_OP_WR_ADD);
14336 if (ret == -EEXIST)
14337 printf("Profile has already existed.\n");
14339 printf("Failed to load profile.\n");
14340 else if (file_num == 2)
14341 save_ddp_package_file(file_fld[1], buff, size);
14343 close_ddp_package_file(buff);
14344 free((void *)filepath);
14347 cmdline_parse_inst_t cmd_ddp_add = {
14348 .f = cmd_ddp_add_parsed,
14350 .help_str = "ddp add <port_id> <profile_path[,output_path]>",
14352 (void *)&cmd_ddp_add_ddp,
14353 (void *)&cmd_ddp_add_add,
14354 (void *)&cmd_ddp_add_port_id,
14355 (void *)&cmd_ddp_add_filepath,
14360 /* Delete dynamic device personalization*/
14361 struct cmd_ddp_del_result {
14362 cmdline_fixed_string_t ddp;
14363 cmdline_fixed_string_t del;
14368 cmdline_parse_token_string_t cmd_ddp_del_ddp =
14369 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp");
14370 cmdline_parse_token_string_t cmd_ddp_del_del =
14371 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del");
14372 cmdline_parse_token_num_t cmd_ddp_del_port_id =
14373 TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, UINT16);
14374 cmdline_parse_token_string_t cmd_ddp_del_filepath =
14375 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL);
14378 cmd_ddp_del_parsed(
14379 void *parsed_result,
14380 __attribute__((unused)) struct cmdline *cl,
14381 __attribute__((unused)) void *data)
14383 struct cmd_ddp_del_result *res = parsed_result;
14386 int ret = -ENOTSUP;
14388 if (res->port_id > nb_ports) {
14389 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
14393 if (!all_ports_stopped()) {
14394 printf("Please stop all ports first\n");
14398 buff = open_ddp_package_file(res->filepath, &size);
14402 #ifdef RTE_LIBRTE_I40E_PMD
14403 if (ret == -ENOTSUP)
14404 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
14406 RTE_PMD_I40E_PKG_OP_WR_DEL);
14409 if (ret == -EACCES)
14410 printf("Profile does not exist.\n");
14412 printf("Failed to delete profile.\n");
14414 close_ddp_package_file(buff);
14417 cmdline_parse_inst_t cmd_ddp_del = {
14418 .f = cmd_ddp_del_parsed,
14420 .help_str = "ddp del <port_id> <profile_path>",
14422 (void *)&cmd_ddp_del_ddp,
14423 (void *)&cmd_ddp_del_del,
14424 (void *)&cmd_ddp_del_port_id,
14425 (void *)&cmd_ddp_del_filepath,
14430 /* Get dynamic device personalization profile info */
14431 struct cmd_ddp_info_result {
14432 cmdline_fixed_string_t ddp;
14433 cmdline_fixed_string_t get;
14434 cmdline_fixed_string_t info;
14438 cmdline_parse_token_string_t cmd_ddp_info_ddp =
14439 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp");
14440 cmdline_parse_token_string_t cmd_ddp_info_get =
14441 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get");
14442 cmdline_parse_token_string_t cmd_ddp_info_info =
14443 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info");
14444 cmdline_parse_token_string_t cmd_ddp_info_filepath =
14445 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL);
14448 cmd_ddp_info_parsed(
14449 void *parsed_result,
14450 __attribute__((unused)) struct cmdline *cl,
14451 __attribute__((unused)) void *data)
14453 struct cmd_ddp_info_result *res = parsed_result;
14456 int ret = -ENOTSUP;
14457 #ifdef RTE_LIBRTE_I40E_PMD
14460 uint32_t buff_size = 0;
14461 struct rte_pmd_i40e_profile_info info;
14462 uint32_t dev_num = 0;
14463 struct rte_pmd_i40e_ddp_device_id *devs;
14464 uint32_t proto_num = 0;
14465 struct rte_pmd_i40e_proto_info *proto = NULL;
14466 uint32_t pctype_num = 0;
14467 struct rte_pmd_i40e_ptype_info *pctype;
14468 uint32_t ptype_num = 0;
14469 struct rte_pmd_i40e_ptype_info *ptype;
14474 pkg = open_ddp_package_file(res->filepath, &pkg_size);
14478 #ifdef RTE_LIBRTE_I40E_PMD
14479 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14480 (uint8_t *)&info, sizeof(info),
14481 RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER);
14483 printf("Global Track id: 0x%x\n", info.track_id);
14484 printf("Global Version: %d.%d.%d.%d\n",
14485 info.version.major,
14486 info.version.minor,
14487 info.version.update,
14488 info.version.draft);
14489 printf("Global Package name: %s\n\n", info.name);
14492 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14493 (uint8_t *)&info, sizeof(info),
14494 RTE_PMD_I40E_PKG_INFO_HEADER);
14496 printf("i40e Profile Track id: 0x%x\n", info.track_id);
14497 printf("i40e Profile Version: %d.%d.%d.%d\n",
14498 info.version.major,
14499 info.version.minor,
14500 info.version.update,
14501 info.version.draft);
14502 printf("i40e Profile name: %s\n\n", info.name);
14505 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14506 (uint8_t *)&buff_size, sizeof(buff_size),
14507 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE);
14508 if (!ret && buff_size) {
14509 buff = (uint8_t *)malloc(buff_size);
14511 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14513 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES);
14515 printf("Package Notes:\n%s\n\n", buff);
14520 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14521 (uint8_t *)&dev_num, sizeof(dev_num),
14522 RTE_PMD_I40E_PKG_INFO_DEVID_NUM);
14523 if (!ret && dev_num) {
14524 buff_size = dev_num * sizeof(struct rte_pmd_i40e_ddp_device_id);
14525 devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(buff_size);
14527 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14528 (uint8_t *)devs, buff_size,
14529 RTE_PMD_I40E_PKG_INFO_DEVID_LIST);
14531 printf("List of supported devices:\n");
14532 for (i = 0; i < dev_num; i++) {
14533 printf(" %04X:%04X %04X:%04X\n",
14534 devs[i].vendor_dev_id >> 16,
14535 devs[i].vendor_dev_id & 0xFFFF,
14536 devs[i].sub_vendor_dev_id >> 16,
14537 devs[i].sub_vendor_dev_id & 0xFFFF);
14545 /* get information about protocols and packet types */
14546 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14547 (uint8_t *)&proto_num, sizeof(proto_num),
14548 RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM);
14549 if (ret || !proto_num)
14550 goto no_print_return;
14552 buff_size = proto_num * sizeof(struct rte_pmd_i40e_proto_info);
14553 proto = (struct rte_pmd_i40e_proto_info *)malloc(buff_size);
14555 goto no_print_return;
14557 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)proto,
14559 RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST);
14561 printf("List of used protocols:\n");
14562 for (i = 0; i < proto_num; i++)
14563 printf(" %2u: %s\n", proto[i].proto_id,
14567 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14568 (uint8_t *)&pctype_num, sizeof(pctype_num),
14569 RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM);
14570 if (ret || !pctype_num)
14571 goto no_print_pctypes;
14573 buff_size = pctype_num * sizeof(struct rte_pmd_i40e_ptype_info);
14574 pctype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
14576 goto no_print_pctypes;
14578 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)pctype,
14580 RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST);
14583 goto no_print_pctypes;
14586 printf("List of defined packet classification types:\n");
14587 for (i = 0; i < pctype_num; i++) {
14588 printf(" %2u:", pctype[i].ptype_id);
14589 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
14590 proto_id = pctype[i].protocols[j];
14591 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
14592 for (n = 0; n < proto_num; n++) {
14593 if (proto[n].proto_id == proto_id) {
14594 printf(" %s", proto[n].name);
14607 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)&ptype_num,
14609 RTE_PMD_I40E_PKG_INFO_PTYPE_NUM);
14610 if (ret || !ptype_num)
14611 goto no_print_return;
14613 buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_info);
14614 ptype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
14616 goto no_print_return;
14618 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)ptype,
14620 RTE_PMD_I40E_PKG_INFO_PTYPE_LIST);
14623 goto no_print_return;
14625 printf("List of defined packet types:\n");
14626 for (i = 0; i < ptype_num; i++) {
14627 printf(" %2u:", ptype[i].ptype_id);
14628 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
14629 proto_id = ptype[i].protocols[j];
14630 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
14631 for (n = 0; n < proto_num; n++) {
14632 if (proto[n].proto_id == proto_id) {
14633 printf(" %s", proto[n].name);
14649 if (ret == -ENOTSUP)
14650 printf("Function not supported in PMD driver\n");
14651 close_ddp_package_file(pkg);
14654 cmdline_parse_inst_t cmd_ddp_get_info = {
14655 .f = cmd_ddp_info_parsed,
14657 .help_str = "ddp get info <profile_path>",
14659 (void *)&cmd_ddp_info_ddp,
14660 (void *)&cmd_ddp_info_get,
14661 (void *)&cmd_ddp_info_info,
14662 (void *)&cmd_ddp_info_filepath,
14667 /* Get dynamic device personalization profile info list*/
14668 #define PROFILE_INFO_SIZE 48
14669 #define MAX_PROFILE_NUM 16
14671 struct cmd_ddp_get_list_result {
14672 cmdline_fixed_string_t ddp;
14673 cmdline_fixed_string_t get;
14674 cmdline_fixed_string_t list;
14678 cmdline_parse_token_string_t cmd_ddp_get_list_ddp =
14679 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp");
14680 cmdline_parse_token_string_t cmd_ddp_get_list_get =
14681 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get");
14682 cmdline_parse_token_string_t cmd_ddp_get_list_list =
14683 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list");
14684 cmdline_parse_token_num_t cmd_ddp_get_list_port_id =
14685 TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id, UINT16);
14688 cmd_ddp_get_list_parsed(
14689 void *parsed_result,
14690 __attribute__((unused)) struct cmdline *cl,
14691 __attribute__((unused)) void *data)
14693 struct cmd_ddp_get_list_result *res = parsed_result;
14694 #ifdef RTE_LIBRTE_I40E_PMD
14695 struct rte_pmd_i40e_profile_list *p_list;
14696 struct rte_pmd_i40e_profile_info *p_info;
14701 int ret = -ENOTSUP;
14703 if (res->port_id > nb_ports) {
14704 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
14708 #ifdef RTE_LIBRTE_I40E_PMD
14709 size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4;
14710 p_list = (struct rte_pmd_i40e_profile_list *)malloc(size);
14712 printf("%s: Failed to malloc buffer\n", __func__);
14714 if (ret == -ENOTSUP)
14715 ret = rte_pmd_i40e_get_ddp_list(res->port_id,
14716 (uint8_t *)p_list, size);
14719 p_num = p_list->p_count;
14720 printf("Profile number is: %d\n\n", p_num);
14722 for (i = 0; i < p_num; i++) {
14723 p_info = &p_list->p_info[i];
14724 printf("Profile %d:\n", i);
14725 printf("Track id: 0x%x\n", p_info->track_id);
14726 printf("Version: %d.%d.%d.%d\n",
14727 p_info->version.major,
14728 p_info->version.minor,
14729 p_info->version.update,
14730 p_info->version.draft);
14731 printf("Profile name: %s\n\n", p_info->name);
14739 printf("Failed to get ddp list\n");
14742 cmdline_parse_inst_t cmd_ddp_get_list = {
14743 .f = cmd_ddp_get_list_parsed,
14745 .help_str = "ddp get list <port_id>",
14747 (void *)&cmd_ddp_get_list_ddp,
14748 (void *)&cmd_ddp_get_list_get,
14749 (void *)&cmd_ddp_get_list_list,
14750 (void *)&cmd_ddp_get_list_port_id,
14755 /* show vf stats */
14757 /* Common result structure for show vf stats */
14758 struct cmd_show_vf_stats_result {
14759 cmdline_fixed_string_t show;
14760 cmdline_fixed_string_t vf;
14761 cmdline_fixed_string_t stats;
14766 /* Common CLI fields show vf stats*/
14767 cmdline_parse_token_string_t cmd_show_vf_stats_show =
14768 TOKEN_STRING_INITIALIZER
14769 (struct cmd_show_vf_stats_result,
14771 cmdline_parse_token_string_t cmd_show_vf_stats_vf =
14772 TOKEN_STRING_INITIALIZER
14773 (struct cmd_show_vf_stats_result,
14775 cmdline_parse_token_string_t cmd_show_vf_stats_stats =
14776 TOKEN_STRING_INITIALIZER
14777 (struct cmd_show_vf_stats_result,
14779 cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
14780 TOKEN_NUM_INITIALIZER
14781 (struct cmd_show_vf_stats_result,
14783 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
14784 TOKEN_NUM_INITIALIZER
14785 (struct cmd_show_vf_stats_result,
14789 cmd_show_vf_stats_parsed(
14790 void *parsed_result,
14791 __attribute__((unused)) struct cmdline *cl,
14792 __attribute__((unused)) void *data)
14794 struct cmd_show_vf_stats_result *res = parsed_result;
14795 struct rte_eth_stats stats;
14796 int ret = -ENOTSUP;
14797 static const char *nic_stats_border = "########################";
14799 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14802 memset(&stats, 0, sizeof(stats));
14804 #ifdef RTE_LIBRTE_I40E_PMD
14805 if (ret == -ENOTSUP)
14806 ret = rte_pmd_i40e_get_vf_stats(res->port_id,
14810 #ifdef RTE_LIBRTE_BNXT_PMD
14811 if (ret == -ENOTSUP)
14812 ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
14821 printf("invalid vf_id %d\n", res->vf_id);
14824 printf("invalid port_id %d\n", res->port_id);
14827 printf("function not implemented\n");
14830 printf("programming error: (%s)\n", strerror(-ret));
14833 printf("\n %s NIC statistics for port %-2d vf %-2d %s\n",
14834 nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
14836 printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: "
14838 stats.ipackets, stats.imissed, stats.ibytes);
14839 printf(" RX-errors: %-"PRIu64"\n", stats.ierrors);
14840 printf(" RX-nombuf: %-10"PRIu64"\n",
14842 printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: "
14844 stats.opackets, stats.oerrors, stats.obytes);
14846 printf(" %s############################%s\n",
14847 nic_stats_border, nic_stats_border);
14850 cmdline_parse_inst_t cmd_show_vf_stats = {
14851 .f = cmd_show_vf_stats_parsed,
14853 .help_str = "show vf stats <port_id> <vf_id>",
14855 (void *)&cmd_show_vf_stats_show,
14856 (void *)&cmd_show_vf_stats_vf,
14857 (void *)&cmd_show_vf_stats_stats,
14858 (void *)&cmd_show_vf_stats_port_id,
14859 (void *)&cmd_show_vf_stats_vf_id,
14864 /* clear vf stats */
14866 /* Common result structure for clear vf stats */
14867 struct cmd_clear_vf_stats_result {
14868 cmdline_fixed_string_t clear;
14869 cmdline_fixed_string_t vf;
14870 cmdline_fixed_string_t stats;
14875 /* Common CLI fields clear vf stats*/
14876 cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
14877 TOKEN_STRING_INITIALIZER
14878 (struct cmd_clear_vf_stats_result,
14880 cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
14881 TOKEN_STRING_INITIALIZER
14882 (struct cmd_clear_vf_stats_result,
14884 cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
14885 TOKEN_STRING_INITIALIZER
14886 (struct cmd_clear_vf_stats_result,
14888 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
14889 TOKEN_NUM_INITIALIZER
14890 (struct cmd_clear_vf_stats_result,
14892 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
14893 TOKEN_NUM_INITIALIZER
14894 (struct cmd_clear_vf_stats_result,
14898 cmd_clear_vf_stats_parsed(
14899 void *parsed_result,
14900 __attribute__((unused)) struct cmdline *cl,
14901 __attribute__((unused)) void *data)
14903 struct cmd_clear_vf_stats_result *res = parsed_result;
14904 int ret = -ENOTSUP;
14906 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14909 #ifdef RTE_LIBRTE_I40E_PMD
14910 if (ret == -ENOTSUP)
14911 ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
14914 #ifdef RTE_LIBRTE_BNXT_PMD
14915 if (ret == -ENOTSUP)
14916 ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
14924 printf("invalid vf_id %d\n", res->vf_id);
14927 printf("invalid port_id %d\n", res->port_id);
14930 printf("function not implemented\n");
14933 printf("programming error: (%s)\n", strerror(-ret));
14937 cmdline_parse_inst_t cmd_clear_vf_stats = {
14938 .f = cmd_clear_vf_stats_parsed,
14940 .help_str = "clear vf stats <port_id> <vf_id>",
14942 (void *)&cmd_clear_vf_stats_clear,
14943 (void *)&cmd_clear_vf_stats_vf,
14944 (void *)&cmd_clear_vf_stats_stats,
14945 (void *)&cmd_clear_vf_stats_port_id,
14946 (void *)&cmd_clear_vf_stats_vf_id,
14951 /* port config pctype mapping reset */
14953 /* Common result structure for port config pctype mapping reset */
14954 struct cmd_pctype_mapping_reset_result {
14955 cmdline_fixed_string_t port;
14956 cmdline_fixed_string_t config;
14958 cmdline_fixed_string_t pctype;
14959 cmdline_fixed_string_t mapping;
14960 cmdline_fixed_string_t reset;
14963 /* Common CLI fields for port config pctype mapping reset*/
14964 cmdline_parse_token_string_t cmd_pctype_mapping_reset_port =
14965 TOKEN_STRING_INITIALIZER
14966 (struct cmd_pctype_mapping_reset_result,
14968 cmdline_parse_token_string_t cmd_pctype_mapping_reset_config =
14969 TOKEN_STRING_INITIALIZER
14970 (struct cmd_pctype_mapping_reset_result,
14972 cmdline_parse_token_num_t cmd_pctype_mapping_reset_port_id =
14973 TOKEN_NUM_INITIALIZER
14974 (struct cmd_pctype_mapping_reset_result,
14976 cmdline_parse_token_string_t cmd_pctype_mapping_reset_pctype =
14977 TOKEN_STRING_INITIALIZER
14978 (struct cmd_pctype_mapping_reset_result,
14980 cmdline_parse_token_string_t cmd_pctype_mapping_reset_mapping =
14981 TOKEN_STRING_INITIALIZER
14982 (struct cmd_pctype_mapping_reset_result,
14983 mapping, "mapping");
14984 cmdline_parse_token_string_t cmd_pctype_mapping_reset_reset =
14985 TOKEN_STRING_INITIALIZER
14986 (struct cmd_pctype_mapping_reset_result,
14990 cmd_pctype_mapping_reset_parsed(
14991 void *parsed_result,
14992 __attribute__((unused)) struct cmdline *cl,
14993 __attribute__((unused)) void *data)
14995 struct cmd_pctype_mapping_reset_result *res = parsed_result;
14996 int ret = -ENOTSUP;
14998 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15001 #ifdef RTE_LIBRTE_I40E_PMD
15002 ret = rte_pmd_i40e_flow_type_mapping_reset(res->port_id);
15009 printf("invalid port_id %d\n", res->port_id);
15012 printf("function not implemented\n");
15015 printf("programming error: (%s)\n", strerror(-ret));
15019 cmdline_parse_inst_t cmd_pctype_mapping_reset = {
15020 .f = cmd_pctype_mapping_reset_parsed,
15022 .help_str = "port config <port_id> pctype mapping reset",
15024 (void *)&cmd_pctype_mapping_reset_port,
15025 (void *)&cmd_pctype_mapping_reset_config,
15026 (void *)&cmd_pctype_mapping_reset_port_id,
15027 (void *)&cmd_pctype_mapping_reset_pctype,
15028 (void *)&cmd_pctype_mapping_reset_mapping,
15029 (void *)&cmd_pctype_mapping_reset_reset,
15034 /* show port pctype mapping */
15036 /* Common result structure for show port pctype mapping */
15037 struct cmd_pctype_mapping_get_result {
15038 cmdline_fixed_string_t show;
15039 cmdline_fixed_string_t port;
15041 cmdline_fixed_string_t pctype;
15042 cmdline_fixed_string_t mapping;
15045 /* Common CLI fields for pctype mapping get */
15046 cmdline_parse_token_string_t cmd_pctype_mapping_get_show =
15047 TOKEN_STRING_INITIALIZER
15048 (struct cmd_pctype_mapping_get_result,
15050 cmdline_parse_token_string_t cmd_pctype_mapping_get_port =
15051 TOKEN_STRING_INITIALIZER
15052 (struct cmd_pctype_mapping_get_result,
15054 cmdline_parse_token_num_t cmd_pctype_mapping_get_port_id =
15055 TOKEN_NUM_INITIALIZER
15056 (struct cmd_pctype_mapping_get_result,
15058 cmdline_parse_token_string_t cmd_pctype_mapping_get_pctype =
15059 TOKEN_STRING_INITIALIZER
15060 (struct cmd_pctype_mapping_get_result,
15062 cmdline_parse_token_string_t cmd_pctype_mapping_get_mapping =
15063 TOKEN_STRING_INITIALIZER
15064 (struct cmd_pctype_mapping_get_result,
15065 mapping, "mapping");
15068 cmd_pctype_mapping_get_parsed(
15069 void *parsed_result,
15070 __attribute__((unused)) struct cmdline *cl,
15071 __attribute__((unused)) void *data)
15073 struct cmd_pctype_mapping_get_result *res = parsed_result;
15074 int ret = -ENOTSUP;
15075 #ifdef RTE_LIBRTE_I40E_PMD
15076 struct rte_pmd_i40e_flow_type_mapping
15077 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
15078 int i, j, first_pctype;
15081 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15084 #ifdef RTE_LIBRTE_I40E_PMD
15085 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, mapping);
15092 printf("invalid port_id %d\n", res->port_id);
15095 printf("function not implemented\n");
15098 printf("programming error: (%s)\n", strerror(-ret));
15102 #ifdef RTE_LIBRTE_I40E_PMD
15103 for (i = 0; i < RTE_PMD_I40E_FLOW_TYPE_MAX; i++) {
15104 if (mapping[i].pctype != 0ULL) {
15107 printf("pctype: ");
15108 for (j = 0; j < RTE_PMD_I40E_PCTYPE_MAX; j++) {
15109 if (mapping[i].pctype & (1ULL << j)) {
15110 printf(first_pctype ?
15111 "%02d" : ",%02d", j);
15115 printf(" -> flowtype: %02d\n", mapping[i].flow_type);
15121 cmdline_parse_inst_t cmd_pctype_mapping_get = {
15122 .f = cmd_pctype_mapping_get_parsed,
15124 .help_str = "show port <port_id> pctype mapping",
15126 (void *)&cmd_pctype_mapping_get_show,
15127 (void *)&cmd_pctype_mapping_get_port,
15128 (void *)&cmd_pctype_mapping_get_port_id,
15129 (void *)&cmd_pctype_mapping_get_pctype,
15130 (void *)&cmd_pctype_mapping_get_mapping,
15135 /* port config pctype mapping update */
15137 /* Common result structure for port config pctype mapping update */
15138 struct cmd_pctype_mapping_update_result {
15139 cmdline_fixed_string_t port;
15140 cmdline_fixed_string_t config;
15142 cmdline_fixed_string_t pctype;
15143 cmdline_fixed_string_t mapping;
15144 cmdline_fixed_string_t update;
15145 cmdline_fixed_string_t pctype_list;
15146 uint16_t flow_type;
15149 /* Common CLI fields for pctype mapping update*/
15150 cmdline_parse_token_string_t cmd_pctype_mapping_update_port =
15151 TOKEN_STRING_INITIALIZER
15152 (struct cmd_pctype_mapping_update_result,
15154 cmdline_parse_token_string_t cmd_pctype_mapping_update_config =
15155 TOKEN_STRING_INITIALIZER
15156 (struct cmd_pctype_mapping_update_result,
15158 cmdline_parse_token_num_t cmd_pctype_mapping_update_port_id =
15159 TOKEN_NUM_INITIALIZER
15160 (struct cmd_pctype_mapping_update_result,
15162 cmdline_parse_token_string_t cmd_pctype_mapping_update_pctype =
15163 TOKEN_STRING_INITIALIZER
15164 (struct cmd_pctype_mapping_update_result,
15166 cmdline_parse_token_string_t cmd_pctype_mapping_update_mapping =
15167 TOKEN_STRING_INITIALIZER
15168 (struct cmd_pctype_mapping_update_result,
15169 mapping, "mapping");
15170 cmdline_parse_token_string_t cmd_pctype_mapping_update_update =
15171 TOKEN_STRING_INITIALIZER
15172 (struct cmd_pctype_mapping_update_result,
15174 cmdline_parse_token_string_t cmd_pctype_mapping_update_pc_type =
15175 TOKEN_STRING_INITIALIZER
15176 (struct cmd_pctype_mapping_update_result,
15177 pctype_list, NULL);
15178 cmdline_parse_token_num_t cmd_pctype_mapping_update_flow_type =
15179 TOKEN_NUM_INITIALIZER
15180 (struct cmd_pctype_mapping_update_result,
15181 flow_type, UINT16);
15184 cmd_pctype_mapping_update_parsed(
15185 void *parsed_result,
15186 __attribute__((unused)) struct cmdline *cl,
15187 __attribute__((unused)) void *data)
15189 struct cmd_pctype_mapping_update_result *res = parsed_result;
15190 int ret = -ENOTSUP;
15191 #ifdef RTE_LIBRTE_I40E_PMD
15192 struct rte_pmd_i40e_flow_type_mapping mapping;
15194 unsigned int nb_item;
15195 unsigned int pctype_list[RTE_PMD_I40E_PCTYPE_MAX];
15198 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15201 #ifdef RTE_LIBRTE_I40E_PMD
15202 nb_item = parse_item_list(res->pctype_list, "pctypes",
15203 RTE_PMD_I40E_PCTYPE_MAX, pctype_list, 1);
15204 mapping.flow_type = res->flow_type;
15205 for (i = 0, mapping.pctype = 0ULL; i < nb_item; i++)
15206 mapping.pctype |= (1ULL << pctype_list[i]);
15207 ret = rte_pmd_i40e_flow_type_mapping_update(res->port_id,
15217 printf("invalid pctype or flow type\n");
15220 printf("invalid port_id %d\n", res->port_id);
15223 printf("function not implemented\n");
15226 printf("programming error: (%s)\n", strerror(-ret));
15230 cmdline_parse_inst_t cmd_pctype_mapping_update = {
15231 .f = cmd_pctype_mapping_update_parsed,
15233 .help_str = "port config <port_id> pctype mapping update"
15234 " <pctype_id_0,[pctype_id_1]*> <flowtype_id>",
15236 (void *)&cmd_pctype_mapping_update_port,
15237 (void *)&cmd_pctype_mapping_update_config,
15238 (void *)&cmd_pctype_mapping_update_port_id,
15239 (void *)&cmd_pctype_mapping_update_pctype,
15240 (void *)&cmd_pctype_mapping_update_mapping,
15241 (void *)&cmd_pctype_mapping_update_update,
15242 (void *)&cmd_pctype_mapping_update_pc_type,
15243 (void *)&cmd_pctype_mapping_update_flow_type,
15248 /* ptype mapping get */
15250 /* Common result structure for ptype mapping get */
15251 struct cmd_ptype_mapping_get_result {
15252 cmdline_fixed_string_t ptype;
15253 cmdline_fixed_string_t mapping;
15254 cmdline_fixed_string_t get;
15256 uint8_t valid_only;
15259 /* Common CLI fields for ptype mapping get */
15260 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype =
15261 TOKEN_STRING_INITIALIZER
15262 (struct cmd_ptype_mapping_get_result,
15264 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping =
15265 TOKEN_STRING_INITIALIZER
15266 (struct cmd_ptype_mapping_get_result,
15267 mapping, "mapping");
15268 cmdline_parse_token_string_t cmd_ptype_mapping_get_get =
15269 TOKEN_STRING_INITIALIZER
15270 (struct cmd_ptype_mapping_get_result,
15272 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id =
15273 TOKEN_NUM_INITIALIZER
15274 (struct cmd_ptype_mapping_get_result,
15276 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only =
15277 TOKEN_NUM_INITIALIZER
15278 (struct cmd_ptype_mapping_get_result,
15279 valid_only, UINT8);
15282 cmd_ptype_mapping_get_parsed(
15283 void *parsed_result,
15284 __attribute__((unused)) struct cmdline *cl,
15285 __attribute__((unused)) void *data)
15287 struct cmd_ptype_mapping_get_result *res = parsed_result;
15288 int ret = -ENOTSUP;
15289 #ifdef RTE_LIBRTE_I40E_PMD
15290 int max_ptype_num = 256;
15291 struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num];
15296 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15299 #ifdef RTE_LIBRTE_I40E_PMD
15300 ret = rte_pmd_i40e_ptype_mapping_get(res->port_id,
15311 printf("invalid port_id %d\n", res->port_id);
15314 printf("function not implemented\n");
15317 printf("programming error: (%s)\n", strerror(-ret));
15320 #ifdef RTE_LIBRTE_I40E_PMD
15322 for (i = 0; i < count; i++)
15323 printf("%3d\t0x%08x\n",
15324 mapping[i].hw_ptype, mapping[i].sw_ptype);
15329 cmdline_parse_inst_t cmd_ptype_mapping_get = {
15330 .f = cmd_ptype_mapping_get_parsed,
15332 .help_str = "ptype mapping get <port_id> <valid_only>",
15334 (void *)&cmd_ptype_mapping_get_ptype,
15335 (void *)&cmd_ptype_mapping_get_mapping,
15336 (void *)&cmd_ptype_mapping_get_get,
15337 (void *)&cmd_ptype_mapping_get_port_id,
15338 (void *)&cmd_ptype_mapping_get_valid_only,
15343 /* ptype mapping replace */
15345 /* Common result structure for ptype mapping replace */
15346 struct cmd_ptype_mapping_replace_result {
15347 cmdline_fixed_string_t ptype;
15348 cmdline_fixed_string_t mapping;
15349 cmdline_fixed_string_t replace;
15356 /* Common CLI fields for ptype mapping replace */
15357 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype =
15358 TOKEN_STRING_INITIALIZER
15359 (struct cmd_ptype_mapping_replace_result,
15361 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping =
15362 TOKEN_STRING_INITIALIZER
15363 (struct cmd_ptype_mapping_replace_result,
15364 mapping, "mapping");
15365 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace =
15366 TOKEN_STRING_INITIALIZER
15367 (struct cmd_ptype_mapping_replace_result,
15368 replace, "replace");
15369 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id =
15370 TOKEN_NUM_INITIALIZER
15371 (struct cmd_ptype_mapping_replace_result,
15373 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target =
15374 TOKEN_NUM_INITIALIZER
15375 (struct cmd_ptype_mapping_replace_result,
15377 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask =
15378 TOKEN_NUM_INITIALIZER
15379 (struct cmd_ptype_mapping_replace_result,
15381 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type =
15382 TOKEN_NUM_INITIALIZER
15383 (struct cmd_ptype_mapping_replace_result,
15387 cmd_ptype_mapping_replace_parsed(
15388 void *parsed_result,
15389 __attribute__((unused)) struct cmdline *cl,
15390 __attribute__((unused)) void *data)
15392 struct cmd_ptype_mapping_replace_result *res = parsed_result;
15393 int ret = -ENOTSUP;
15395 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15398 #ifdef RTE_LIBRTE_I40E_PMD
15399 ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id,
15409 printf("invalid ptype 0x%8x or 0x%8x\n",
15410 res->target, res->pkt_type);
15413 printf("invalid port_id %d\n", res->port_id);
15416 printf("function not implemented\n");
15419 printf("programming error: (%s)\n", strerror(-ret));
15423 cmdline_parse_inst_t cmd_ptype_mapping_replace = {
15424 .f = cmd_ptype_mapping_replace_parsed,
15427 "ptype mapping replace <port_id> <target> <mask> <pkt_type>",
15429 (void *)&cmd_ptype_mapping_replace_ptype,
15430 (void *)&cmd_ptype_mapping_replace_mapping,
15431 (void *)&cmd_ptype_mapping_replace_replace,
15432 (void *)&cmd_ptype_mapping_replace_port_id,
15433 (void *)&cmd_ptype_mapping_replace_target,
15434 (void *)&cmd_ptype_mapping_replace_mask,
15435 (void *)&cmd_ptype_mapping_replace_pkt_type,
15440 /* ptype mapping reset */
15442 /* Common result structure for ptype mapping reset */
15443 struct cmd_ptype_mapping_reset_result {
15444 cmdline_fixed_string_t ptype;
15445 cmdline_fixed_string_t mapping;
15446 cmdline_fixed_string_t reset;
15450 /* Common CLI fields for ptype mapping reset*/
15451 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype =
15452 TOKEN_STRING_INITIALIZER
15453 (struct cmd_ptype_mapping_reset_result,
15455 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping =
15456 TOKEN_STRING_INITIALIZER
15457 (struct cmd_ptype_mapping_reset_result,
15458 mapping, "mapping");
15459 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset =
15460 TOKEN_STRING_INITIALIZER
15461 (struct cmd_ptype_mapping_reset_result,
15463 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id =
15464 TOKEN_NUM_INITIALIZER
15465 (struct cmd_ptype_mapping_reset_result,
15469 cmd_ptype_mapping_reset_parsed(
15470 void *parsed_result,
15471 __attribute__((unused)) struct cmdline *cl,
15472 __attribute__((unused)) void *data)
15474 struct cmd_ptype_mapping_reset_result *res = parsed_result;
15475 int ret = -ENOTSUP;
15477 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15480 #ifdef RTE_LIBRTE_I40E_PMD
15481 ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id);
15488 printf("invalid port_id %d\n", res->port_id);
15491 printf("function not implemented\n");
15494 printf("programming error: (%s)\n", strerror(-ret));
15498 cmdline_parse_inst_t cmd_ptype_mapping_reset = {
15499 .f = cmd_ptype_mapping_reset_parsed,
15501 .help_str = "ptype mapping reset <port_id>",
15503 (void *)&cmd_ptype_mapping_reset_ptype,
15504 (void *)&cmd_ptype_mapping_reset_mapping,
15505 (void *)&cmd_ptype_mapping_reset_reset,
15506 (void *)&cmd_ptype_mapping_reset_port_id,
15511 /* ptype mapping update */
15513 /* Common result structure for ptype mapping update */
15514 struct cmd_ptype_mapping_update_result {
15515 cmdline_fixed_string_t ptype;
15516 cmdline_fixed_string_t mapping;
15517 cmdline_fixed_string_t reset;
15523 /* Common CLI fields for ptype mapping update*/
15524 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype =
15525 TOKEN_STRING_INITIALIZER
15526 (struct cmd_ptype_mapping_update_result,
15528 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping =
15529 TOKEN_STRING_INITIALIZER
15530 (struct cmd_ptype_mapping_update_result,
15531 mapping, "mapping");
15532 cmdline_parse_token_string_t cmd_ptype_mapping_update_update =
15533 TOKEN_STRING_INITIALIZER
15534 (struct cmd_ptype_mapping_update_result,
15536 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id =
15537 TOKEN_NUM_INITIALIZER
15538 (struct cmd_ptype_mapping_update_result,
15540 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype =
15541 TOKEN_NUM_INITIALIZER
15542 (struct cmd_ptype_mapping_update_result,
15544 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype =
15545 TOKEN_NUM_INITIALIZER
15546 (struct cmd_ptype_mapping_update_result,
15550 cmd_ptype_mapping_update_parsed(
15551 void *parsed_result,
15552 __attribute__((unused)) struct cmdline *cl,
15553 __attribute__((unused)) void *data)
15555 struct cmd_ptype_mapping_update_result *res = parsed_result;
15556 int ret = -ENOTSUP;
15557 #ifdef RTE_LIBRTE_I40E_PMD
15558 struct rte_pmd_i40e_ptype_mapping mapping;
15560 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15563 #ifdef RTE_LIBRTE_I40E_PMD
15564 mapping.hw_ptype = res->hw_ptype;
15565 mapping.sw_ptype = res->sw_ptype;
15566 ret = rte_pmd_i40e_ptype_mapping_update(res->port_id,
15576 printf("invalid ptype 0x%8x\n", res->sw_ptype);
15579 printf("invalid port_id %d\n", res->port_id);
15582 printf("function not implemented\n");
15585 printf("programming error: (%s)\n", strerror(-ret));
15589 cmdline_parse_inst_t cmd_ptype_mapping_update = {
15590 .f = cmd_ptype_mapping_update_parsed,
15592 .help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>",
15594 (void *)&cmd_ptype_mapping_update_ptype,
15595 (void *)&cmd_ptype_mapping_update_mapping,
15596 (void *)&cmd_ptype_mapping_update_update,
15597 (void *)&cmd_ptype_mapping_update_port_id,
15598 (void *)&cmd_ptype_mapping_update_hw_ptype,
15599 (void *)&cmd_ptype_mapping_update_sw_ptype,
15604 /* Common result structure for file commands */
15605 struct cmd_cmdfile_result {
15606 cmdline_fixed_string_t load;
15607 cmdline_fixed_string_t filename;
15610 /* Common CLI fields for file commands */
15611 cmdline_parse_token_string_t cmd_load_cmdfile =
15612 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
15613 cmdline_parse_token_string_t cmd_load_cmdfile_filename =
15614 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
15617 cmd_load_from_file_parsed(
15618 void *parsed_result,
15619 __attribute__((unused)) struct cmdline *cl,
15620 __attribute__((unused)) void *data)
15622 struct cmd_cmdfile_result *res = parsed_result;
15624 cmdline_read_from_file(res->filename);
15627 cmdline_parse_inst_t cmd_load_from_file = {
15628 .f = cmd_load_from_file_parsed,
15630 .help_str = "load <filename>",
15632 (void *)&cmd_load_cmdfile,
15633 (void *)&cmd_load_cmdfile_filename,
15638 /* ******************************************************************************** */
15640 /* list of instructions */
15641 cmdline_parse_ctx_t main_ctx[] = {
15642 (cmdline_parse_inst_t *)&cmd_help_brief,
15643 (cmdline_parse_inst_t *)&cmd_help_long,
15644 (cmdline_parse_inst_t *)&cmd_quit,
15645 (cmdline_parse_inst_t *)&cmd_load_from_file,
15646 (cmdline_parse_inst_t *)&cmd_showport,
15647 (cmdline_parse_inst_t *)&cmd_showqueue,
15648 (cmdline_parse_inst_t *)&cmd_showportall,
15649 (cmdline_parse_inst_t *)&cmd_showcfg,
15650 (cmdline_parse_inst_t *)&cmd_start,
15651 (cmdline_parse_inst_t *)&cmd_start_tx_first,
15652 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
15653 (cmdline_parse_inst_t *)&cmd_set_link_up,
15654 (cmdline_parse_inst_t *)&cmd_set_link_down,
15655 (cmdline_parse_inst_t *)&cmd_reset,
15656 (cmdline_parse_inst_t *)&cmd_set_numbers,
15657 (cmdline_parse_inst_t *)&cmd_set_txpkts,
15658 (cmdline_parse_inst_t *)&cmd_set_txsplit,
15659 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
15660 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
15661 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
15662 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
15663 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
15664 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
15665 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
15666 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
15667 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
15668 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
15669 (cmdline_parse_inst_t *)&cmd_set_link_check,
15670 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
15671 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
15672 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
15673 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
15674 #ifdef RTE_LIBRTE_PMD_BOND
15675 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
15676 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
15677 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
15678 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
15679 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
15680 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
15681 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
15682 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
15683 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
15684 (cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues,
15685 (cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy,
15687 (cmdline_parse_inst_t *)&cmd_vlan_offload,
15688 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
15689 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
15690 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
15691 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
15692 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
15693 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
15694 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
15695 (cmdline_parse_inst_t *)&cmd_csum_set,
15696 (cmdline_parse_inst_t *)&cmd_csum_show,
15697 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
15698 (cmdline_parse_inst_t *)&cmd_tso_set,
15699 (cmdline_parse_inst_t *)&cmd_tso_show,
15700 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
15701 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
15702 (cmdline_parse_inst_t *)&cmd_gro_enable,
15703 (cmdline_parse_inst_t *)&cmd_gro_flush,
15704 (cmdline_parse_inst_t *)&cmd_gro_show,
15705 (cmdline_parse_inst_t *)&cmd_gso_enable,
15706 (cmdline_parse_inst_t *)&cmd_gso_size,
15707 (cmdline_parse_inst_t *)&cmd_gso_show,
15708 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
15709 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
15710 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
15711 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
15712 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
15713 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
15714 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
15715 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
15716 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
15717 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
15718 (cmdline_parse_inst_t *)&cmd_config_dcb,
15719 (cmdline_parse_inst_t *)&cmd_read_reg,
15720 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
15721 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
15722 (cmdline_parse_inst_t *)&cmd_write_reg,
15723 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
15724 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
15725 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
15726 (cmdline_parse_inst_t *)&cmd_stop,
15727 (cmdline_parse_inst_t *)&cmd_mac_addr,
15728 (cmdline_parse_inst_t *)&cmd_set_qmap,
15729 (cmdline_parse_inst_t *)&cmd_set_xstats_hide_zero,
15730 (cmdline_parse_inst_t *)&cmd_operate_port,
15731 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
15732 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
15733 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
15734 (cmdline_parse_inst_t *)&cmd_config_speed_all,
15735 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
15736 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
15737 (cmdline_parse_inst_t *)&cmd_config_mtu,
15738 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
15739 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
15740 (cmdline_parse_inst_t *)&cmd_config_rss,
15741 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
15742 (cmdline_parse_inst_t *)&cmd_config_txqflags,
15743 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
15744 (cmdline_parse_inst_t *)&cmd_showport_reta,
15745 (cmdline_parse_inst_t *)&cmd_config_burst,
15746 (cmdline_parse_inst_t *)&cmd_config_thresh,
15747 (cmdline_parse_inst_t *)&cmd_config_threshold,
15748 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
15749 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
15750 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
15751 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
15752 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
15753 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
15754 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
15755 (cmdline_parse_inst_t *)&cmd_global_config,
15756 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
15757 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
15758 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
15759 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
15760 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
15761 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
15762 (cmdline_parse_inst_t *)&cmd_dump,
15763 (cmdline_parse_inst_t *)&cmd_dump_one,
15764 (cmdline_parse_inst_t *)&cmd_ethertype_filter,
15765 (cmdline_parse_inst_t *)&cmd_syn_filter,
15766 (cmdline_parse_inst_t *)&cmd_2tuple_filter,
15767 (cmdline_parse_inst_t *)&cmd_5tuple_filter,
15768 (cmdline_parse_inst_t *)&cmd_flex_filter,
15769 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
15770 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
15771 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
15772 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director,
15773 (cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director,
15774 (cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director,
15775 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
15776 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
15777 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
15778 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
15779 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
15780 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
15781 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
15782 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
15783 (cmdline_parse_inst_t *)&cmd_get_hash_global_config,
15784 (cmdline_parse_inst_t *)&cmd_set_hash_global_config,
15785 (cmdline_parse_inst_t *)&cmd_set_hash_input_set,
15786 (cmdline_parse_inst_t *)&cmd_set_fdir_input_set,
15787 (cmdline_parse_inst_t *)&cmd_flow,
15788 (cmdline_parse_inst_t *)&cmd_show_port_meter_cap,
15789 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm,
15790 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm,
15791 (cmdline_parse_inst_t *)&cmd_del_port_meter_profile,
15792 (cmdline_parse_inst_t *)&cmd_create_port_meter,
15793 (cmdline_parse_inst_t *)&cmd_enable_port_meter,
15794 (cmdline_parse_inst_t *)&cmd_disable_port_meter,
15795 (cmdline_parse_inst_t *)&cmd_del_port_meter,
15796 (cmdline_parse_inst_t *)&cmd_set_port_meter_profile,
15797 (cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table,
15798 (cmdline_parse_inst_t *)&cmd_set_port_meter_policer_action,
15799 (cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask,
15800 (cmdline_parse_inst_t *)&cmd_show_port_meter_stats,
15801 (cmdline_parse_inst_t *)&cmd_mcast_addr,
15802 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all,
15803 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific,
15804 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all,
15805 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific,
15806 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_en,
15807 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_dis,
15808 (cmdline_parse_inst_t *)&cmd_config_e_tag_stripping_en_dis,
15809 (cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis,
15810 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_add,
15811 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_del,
15812 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
15813 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
15814 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
15815 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
15816 (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
15817 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
15818 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
15819 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
15820 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
15821 (cmdline_parse_inst_t *)&cmd_set_macsec_sc,
15822 (cmdline_parse_inst_t *)&cmd_set_macsec_sa,
15823 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
15824 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
15825 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
15826 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
15827 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
15828 (cmdline_parse_inst_t *)&cmd_set_vf_promisc,
15829 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
15830 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
15831 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
15832 (cmdline_parse_inst_t *)&cmd_vf_max_bw,
15833 (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
15834 (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
15835 (cmdline_parse_inst_t *)&cmd_strict_link_prio,
15836 (cmdline_parse_inst_t *)&cmd_tc_min_bw,
15837 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
15838 (cmdline_parse_inst_t *)&cmd_set_port_tm_hierarchy_default,
15840 (cmdline_parse_inst_t *)&cmd_ddp_add,
15841 (cmdline_parse_inst_t *)&cmd_ddp_del,
15842 (cmdline_parse_inst_t *)&cmd_ddp_get_list,
15843 (cmdline_parse_inst_t *)&cmd_ddp_get_info,
15844 (cmdline_parse_inst_t *)&cmd_show_vf_stats,
15845 (cmdline_parse_inst_t *)&cmd_clear_vf_stats,
15846 (cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
15847 (cmdline_parse_inst_t *)&cmd_ptype_mapping_replace,
15848 (cmdline_parse_inst_t *)&cmd_ptype_mapping_reset,
15849 (cmdline_parse_inst_t *)&cmd_ptype_mapping_update,
15851 (cmdline_parse_inst_t *)&cmd_pctype_mapping_get,
15852 (cmdline_parse_inst_t *)&cmd_pctype_mapping_reset,
15853 (cmdline_parse_inst_t *)&cmd_pctype_mapping_update,
15854 (cmdline_parse_inst_t *)&cmd_queue_region,
15855 (cmdline_parse_inst_t *)&cmd_region_flowtype,
15856 (cmdline_parse_inst_t *)&cmd_user_priority_region,
15857 (cmdline_parse_inst_t *)&cmd_flush_queue_region,
15858 (cmdline_parse_inst_t *)&cmd_show_queue_region_info_all,
15859 (cmdline_parse_inst_t *)&cmd_show_port_tm_cap,
15860 (cmdline_parse_inst_t *)&cmd_show_port_tm_level_cap,
15861 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_cap,
15862 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_type,
15863 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_stats,
15864 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shaper_profile,
15865 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shaper_profile,
15866 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shared_shaper,
15867 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shared_shaper,
15868 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_wred_profile,
15869 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_wred_profile,
15870 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_shaper_profile,
15871 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node,
15872 (cmdline_parse_inst_t *)&cmd_add_port_tm_leaf_node,
15873 (cmdline_parse_inst_t *)&cmd_del_port_tm_node,
15874 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_parent,
15875 (cmdline_parse_inst_t *)&cmd_port_tm_hierarchy_commit,
15879 /* read cmdline commands from file */
15881 cmdline_read_from_file(const char *filename)
15883 struct cmdline *cl;
15885 cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
15887 printf("Failed to create file based cmdline context: %s\n",
15892 cmdline_interact(cl);
15897 printf("Read CLI commands from %s\n", filename);
15900 /* prompt function, called from main on MASTER lcore */
15904 /* initialize non-constant commands */
15905 cmd_set_fwd_mode_init();
15906 cmd_set_fwd_retry_mode_init();
15908 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
15909 if (testpmd_cl == NULL)
15911 cmdline_interact(testpmd_cl);
15912 cmdline_stdin_exit(testpmd_cl);
15918 if (testpmd_cl != NULL)
15919 cmdline_quit(testpmd_cl);
15923 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
15925 if (id == (portid_t)RTE_PORT_ALL) {
15928 RTE_ETH_FOREACH_DEV(pid) {
15929 /* check if need_reconfig has been set to 1 */
15930 if (ports[pid].need_reconfig == 0)
15931 ports[pid].need_reconfig = dev;
15932 /* check if need_reconfig_queues has been set to 1 */
15933 if (ports[pid].need_reconfig_queues == 0)
15934 ports[pid].need_reconfig_queues = queue;
15936 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
15937 /* check if need_reconfig has been set to 1 */
15938 if (ports[id].need_reconfig == 0)
15939 ports[id].need_reconfig = dev;
15940 /* check if need_reconfig_queues has been set to 1 */
15941 if (ports[id].need_reconfig_queues == 0)
15942 ports[id].need_reconfig_queues = queue;