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 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
3113 struct cmd_rx_vlan_filter_all_result {
3114 cmdline_fixed_string_t rx_vlan;
3115 cmdline_fixed_string_t what;
3116 cmdline_fixed_string_t all;
3121 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
3122 __attribute__((unused)) struct cmdline *cl,
3123 __attribute__((unused)) void *data)
3125 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
3127 if (!strcmp(res->what, "add"))
3128 rx_vlan_all_filter_set(res->port_id, 1);
3130 rx_vlan_all_filter_set(res->port_id, 0);
3133 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
3134 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3135 rx_vlan, "rx_vlan");
3136 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
3137 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3139 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
3140 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3142 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
3143 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3146 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
3147 .f = cmd_rx_vlan_filter_all_parsed,
3149 .help_str = "rx_vlan add|rm all <port_id>: "
3150 "Add/Remove all identifiers to/from the set of VLAN "
3151 "identifiers filtered by a port",
3153 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
3154 (void *)&cmd_rx_vlan_filter_all_what,
3155 (void *)&cmd_rx_vlan_filter_all_all,
3156 (void *)&cmd_rx_vlan_filter_all_portid,
3161 /* *** VLAN OFFLOAD SET ON A PORT *** */
3162 struct cmd_vlan_offload_result {
3163 cmdline_fixed_string_t vlan;
3164 cmdline_fixed_string_t set;
3165 cmdline_fixed_string_t vlan_type;
3166 cmdline_fixed_string_t what;
3167 cmdline_fixed_string_t on;
3168 cmdline_fixed_string_t port_id;
3172 cmd_vlan_offload_parsed(void *parsed_result,
3173 __attribute__((unused)) struct cmdline *cl,
3174 __attribute__((unused)) void *data)
3177 struct cmd_vlan_offload_result *res = parsed_result;
3180 portid_t port_id = 0;
3184 len = strnlen(str, STR_TOKEN_SIZE);
3186 /* Get port_id first */
3194 tmp = strtoul(str, NULL, 0);
3195 /* If port_id greater that what portid_t can represent, return */
3196 if(tmp >= RTE_MAX_ETHPORTS)
3198 port_id = (portid_t)tmp;
3200 if (!strcmp(res->on, "on"))
3205 if (!strcmp(res->what, "strip"))
3206 rx_vlan_strip_set(port_id, on);
3207 else if(!strcmp(res->what, "stripq")){
3208 uint16_t queue_id = 0;
3210 /* No queue_id, return */
3212 printf("must specify (port,queue_id)\n");
3215 tmp = strtoul(str + i + 1, NULL, 0);
3216 /* If queue_id greater that what 16-bits can represent, return */
3220 queue_id = (uint16_t)tmp;
3221 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
3223 else if (!strcmp(res->what, "filter"))
3224 rx_vlan_filter_set(port_id, on);
3226 vlan_extend_set(port_id, on);
3231 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
3232 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3234 cmdline_parse_token_string_t cmd_vlan_offload_set =
3235 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3237 cmdline_parse_token_string_t cmd_vlan_offload_what =
3238 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3239 what, "strip#filter#qinq#stripq");
3240 cmdline_parse_token_string_t cmd_vlan_offload_on =
3241 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3243 cmdline_parse_token_string_t cmd_vlan_offload_portid =
3244 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3247 cmdline_parse_inst_t cmd_vlan_offload = {
3248 .f = cmd_vlan_offload_parsed,
3250 .help_str = "vlan set strip|filter|qinq|stripq on|off "
3251 "<port_id[,queue_id]>: "
3252 "Filter/Strip for rx side qinq(extended) for both rx/tx sides",
3254 (void *)&cmd_vlan_offload_vlan,
3255 (void *)&cmd_vlan_offload_set,
3256 (void *)&cmd_vlan_offload_what,
3257 (void *)&cmd_vlan_offload_on,
3258 (void *)&cmd_vlan_offload_portid,
3263 /* *** VLAN TPID SET ON A PORT *** */
3264 struct cmd_vlan_tpid_result {
3265 cmdline_fixed_string_t vlan;
3266 cmdline_fixed_string_t set;
3267 cmdline_fixed_string_t vlan_type;
3268 cmdline_fixed_string_t what;
3274 cmd_vlan_tpid_parsed(void *parsed_result,
3275 __attribute__((unused)) struct cmdline *cl,
3276 __attribute__((unused)) void *data)
3278 struct cmd_vlan_tpid_result *res = parsed_result;
3279 enum rte_vlan_type vlan_type;
3281 if (!strcmp(res->vlan_type, "inner"))
3282 vlan_type = ETH_VLAN_TYPE_INNER;
3283 else if (!strcmp(res->vlan_type, "outer"))
3284 vlan_type = ETH_VLAN_TYPE_OUTER;
3286 printf("Unknown vlan type\n");
3289 vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
3292 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
3293 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3295 cmdline_parse_token_string_t cmd_vlan_tpid_set =
3296 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3298 cmdline_parse_token_string_t cmd_vlan_type =
3299 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3300 vlan_type, "inner#outer");
3301 cmdline_parse_token_string_t cmd_vlan_tpid_what =
3302 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3304 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
3305 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3307 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
3308 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3311 cmdline_parse_inst_t cmd_vlan_tpid = {
3312 .f = cmd_vlan_tpid_parsed,
3314 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
3315 "Set the VLAN Ether type",
3317 (void *)&cmd_vlan_tpid_vlan,
3318 (void *)&cmd_vlan_tpid_set,
3319 (void *)&cmd_vlan_type,
3320 (void *)&cmd_vlan_tpid_what,
3321 (void *)&cmd_vlan_tpid_tpid,
3322 (void *)&cmd_vlan_tpid_portid,
3327 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
3328 struct cmd_rx_vlan_filter_result {
3329 cmdline_fixed_string_t rx_vlan;
3330 cmdline_fixed_string_t what;
3336 cmd_rx_vlan_filter_parsed(void *parsed_result,
3337 __attribute__((unused)) struct cmdline *cl,
3338 __attribute__((unused)) void *data)
3340 struct cmd_rx_vlan_filter_result *res = parsed_result;
3342 if (!strcmp(res->what, "add"))
3343 rx_vft_set(res->port_id, res->vlan_id, 1);
3345 rx_vft_set(res->port_id, res->vlan_id, 0);
3348 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
3349 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3350 rx_vlan, "rx_vlan");
3351 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
3352 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3354 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
3355 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3357 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
3358 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3361 cmdline_parse_inst_t cmd_rx_vlan_filter = {
3362 .f = cmd_rx_vlan_filter_parsed,
3364 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
3365 "Add/Remove a VLAN identifier to/from the set of VLAN "
3366 "identifiers filtered by a port",
3368 (void *)&cmd_rx_vlan_filter_rx_vlan,
3369 (void *)&cmd_rx_vlan_filter_what,
3370 (void *)&cmd_rx_vlan_filter_vlanid,
3371 (void *)&cmd_rx_vlan_filter_portid,
3376 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3377 struct cmd_tx_vlan_set_result {
3378 cmdline_fixed_string_t tx_vlan;
3379 cmdline_fixed_string_t set;
3385 cmd_tx_vlan_set_parsed(void *parsed_result,
3386 __attribute__((unused)) struct cmdline *cl,
3387 __attribute__((unused)) void *data)
3389 struct cmd_tx_vlan_set_result *res = parsed_result;
3391 if (!port_is_stopped(res->port_id)) {
3392 printf("Please stop port %d first\n", res->port_id);
3396 tx_vlan_set(res->port_id, res->vlan_id);
3398 cmd_reconfig_device_queue(res->port_id, 1, 1);
3401 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
3402 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3403 tx_vlan, "tx_vlan");
3404 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
3405 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3407 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
3408 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3410 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
3411 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3414 cmdline_parse_inst_t cmd_tx_vlan_set = {
3415 .f = cmd_tx_vlan_set_parsed,
3417 .help_str = "tx_vlan set <port_id> <vlan_id>: "
3418 "Enable hardware insertion of a single VLAN header "
3419 "with a given TAG Identifier in packets sent on a port",
3421 (void *)&cmd_tx_vlan_set_tx_vlan,
3422 (void *)&cmd_tx_vlan_set_set,
3423 (void *)&cmd_tx_vlan_set_portid,
3424 (void *)&cmd_tx_vlan_set_vlanid,
3429 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
3430 struct cmd_tx_vlan_set_qinq_result {
3431 cmdline_fixed_string_t tx_vlan;
3432 cmdline_fixed_string_t set;
3435 uint16_t vlan_id_outer;
3439 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
3440 __attribute__((unused)) struct cmdline *cl,
3441 __attribute__((unused)) void *data)
3443 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
3445 if (!port_is_stopped(res->port_id)) {
3446 printf("Please stop port %d first\n", res->port_id);
3450 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
3452 cmd_reconfig_device_queue(res->port_id, 1, 1);
3455 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
3456 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3457 tx_vlan, "tx_vlan");
3458 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
3459 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3461 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
3462 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3464 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
3465 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3467 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
3468 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3469 vlan_id_outer, UINT16);
3471 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
3472 .f = cmd_tx_vlan_set_qinq_parsed,
3474 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
3475 "Enable hardware insertion of double VLAN header "
3476 "with given TAG Identifiers in packets sent on a port",
3478 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
3479 (void *)&cmd_tx_vlan_set_qinq_set,
3480 (void *)&cmd_tx_vlan_set_qinq_portid,
3481 (void *)&cmd_tx_vlan_set_qinq_vlanid,
3482 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
3487 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
3488 struct cmd_tx_vlan_set_pvid_result {
3489 cmdline_fixed_string_t tx_vlan;
3490 cmdline_fixed_string_t set;
3491 cmdline_fixed_string_t pvid;
3494 cmdline_fixed_string_t mode;
3498 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
3499 __attribute__((unused)) struct cmdline *cl,
3500 __attribute__((unused)) void *data)
3502 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
3504 if (strcmp(res->mode, "on") == 0)
3505 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
3507 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
3510 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
3511 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3512 tx_vlan, "tx_vlan");
3513 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
3514 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3516 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
3517 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3519 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
3520 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3522 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
3523 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3525 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
3526 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3529 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
3530 .f = cmd_tx_vlan_set_pvid_parsed,
3532 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
3534 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
3535 (void *)&cmd_tx_vlan_set_pvid_set,
3536 (void *)&cmd_tx_vlan_set_pvid_pvid,
3537 (void *)&cmd_tx_vlan_set_pvid_port_id,
3538 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
3539 (void *)&cmd_tx_vlan_set_pvid_mode,
3544 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3545 struct cmd_tx_vlan_reset_result {
3546 cmdline_fixed_string_t tx_vlan;
3547 cmdline_fixed_string_t reset;
3552 cmd_tx_vlan_reset_parsed(void *parsed_result,
3553 __attribute__((unused)) struct cmdline *cl,
3554 __attribute__((unused)) void *data)
3556 struct cmd_tx_vlan_reset_result *res = parsed_result;
3558 if (!port_is_stopped(res->port_id)) {
3559 printf("Please stop port %d first\n", res->port_id);
3563 tx_vlan_reset(res->port_id);
3565 cmd_reconfig_device_queue(res->port_id, 1, 1);
3568 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
3569 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
3570 tx_vlan, "tx_vlan");
3571 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
3572 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
3574 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
3575 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
3578 cmdline_parse_inst_t cmd_tx_vlan_reset = {
3579 .f = cmd_tx_vlan_reset_parsed,
3581 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
3582 "VLAN header in packets sent on a port",
3584 (void *)&cmd_tx_vlan_reset_tx_vlan,
3585 (void *)&cmd_tx_vlan_reset_reset,
3586 (void *)&cmd_tx_vlan_reset_portid,
3592 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
3593 struct cmd_csum_result {
3594 cmdline_fixed_string_t csum;
3595 cmdline_fixed_string_t mode;
3596 cmdline_fixed_string_t proto;
3597 cmdline_fixed_string_t hwsw;
3602 csum_show(int port_id)
3604 struct rte_eth_dev_info dev_info;
3605 uint64_t tx_offloads;
3607 tx_offloads = ports[port_id].dev_conf.txmode.offloads;
3608 printf("Parse tunnel is %s\n",
3609 (ports[port_id].parse_tunnel) ? "on" : "off");
3610 printf("IP checksum offload is %s\n",
3611 (tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) ? "hw" : "sw");
3612 printf("UDP checksum offload is %s\n",
3613 (tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
3614 printf("TCP checksum offload is %s\n",
3615 (tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
3616 printf("SCTP checksum offload is %s\n",
3617 (tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
3618 printf("Outer-Ip checksum offload is %s\n",
3619 (tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) ? "hw" : "sw");
3621 /* display warnings if configuration is not supported by the NIC */
3622 rte_eth_dev_info_get(port_id, &dev_info);
3623 if ((tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) &&
3624 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
3625 printf("Warning: hardware IP checksum enabled but not "
3626 "supported by port %d\n", port_id);
3628 if ((tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) &&
3629 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
3630 printf("Warning: hardware UDP checksum enabled but not "
3631 "supported by port %d\n", port_id);
3633 if ((tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) &&
3634 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
3635 printf("Warning: hardware TCP checksum enabled but not "
3636 "supported by port %d\n", port_id);
3638 if ((tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) &&
3639 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
3640 printf("Warning: hardware SCTP checksum enabled but not "
3641 "supported by port %d\n", port_id);
3643 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) &&
3644 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
3645 printf("Warning: hardware outer IP checksum enabled but not "
3646 "supported by port %d\n", port_id);
3651 cmd_csum_parsed(void *parsed_result,
3652 __attribute__((unused)) struct cmdline *cl,
3653 __attribute__((unused)) void *data)
3655 struct cmd_csum_result *res = parsed_result;
3657 uint64_t csum_offloads = 0;
3659 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
3660 printf("invalid port %d\n", res->port_id);
3663 if (!port_is_stopped(res->port_id)) {
3664 printf("Please stop port %d first\n", res->port_id);
3668 if (!strcmp(res->mode, "set")) {
3670 if (!strcmp(res->hwsw, "hw"))
3673 if (!strcmp(res->proto, "ip")) {
3674 csum_offloads |= DEV_TX_OFFLOAD_IPV4_CKSUM;
3675 } else if (!strcmp(res->proto, "udp")) {
3676 csum_offloads |= DEV_TX_OFFLOAD_UDP_CKSUM;
3677 } else if (!strcmp(res->proto, "tcp")) {
3678 csum_offloads |= DEV_TX_OFFLOAD_TCP_CKSUM;
3679 } else if (!strcmp(res->proto, "sctp")) {
3680 csum_offloads |= DEV_TX_OFFLOAD_SCTP_CKSUM;
3681 } else if (!strcmp(res->proto, "outer-ip")) {
3682 csum_offloads |= DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM;
3686 ports[res->port_id].dev_conf.txmode.offloads |=
3689 ports[res->port_id].dev_conf.txmode.offloads &=
3693 csum_show(res->port_id);
3695 cmd_reconfig_device_queue(res->port_id, 1, 1);
3698 cmdline_parse_token_string_t cmd_csum_csum =
3699 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3701 cmdline_parse_token_string_t cmd_csum_mode =
3702 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3704 cmdline_parse_token_string_t cmd_csum_proto =
3705 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3706 proto, "ip#tcp#udp#sctp#outer-ip");
3707 cmdline_parse_token_string_t cmd_csum_hwsw =
3708 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3710 cmdline_parse_token_num_t cmd_csum_portid =
3711 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
3714 cmdline_parse_inst_t cmd_csum_set = {
3715 .f = cmd_csum_parsed,
3717 .help_str = "csum set ip|tcp|udp|sctp|outer-ip hw|sw <port_id>: "
3718 "Enable/Disable hardware calculation of L3/L4 checksum when "
3719 "using csum forward engine",
3721 (void *)&cmd_csum_csum,
3722 (void *)&cmd_csum_mode,
3723 (void *)&cmd_csum_proto,
3724 (void *)&cmd_csum_hwsw,
3725 (void *)&cmd_csum_portid,
3730 cmdline_parse_token_string_t cmd_csum_mode_show =
3731 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3734 cmdline_parse_inst_t cmd_csum_show = {
3735 .f = cmd_csum_parsed,
3737 .help_str = "csum show <port_id>: Show checksum offload configuration",
3739 (void *)&cmd_csum_csum,
3740 (void *)&cmd_csum_mode_show,
3741 (void *)&cmd_csum_portid,
3746 /* Enable/disable tunnel parsing */
3747 struct cmd_csum_tunnel_result {
3748 cmdline_fixed_string_t csum;
3749 cmdline_fixed_string_t parse;
3750 cmdline_fixed_string_t onoff;
3755 cmd_csum_tunnel_parsed(void *parsed_result,
3756 __attribute__((unused)) struct cmdline *cl,
3757 __attribute__((unused)) void *data)
3759 struct cmd_csum_tunnel_result *res = parsed_result;
3761 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3764 if (!strcmp(res->onoff, "on"))
3765 ports[res->port_id].parse_tunnel = 1;
3767 ports[res->port_id].parse_tunnel = 0;
3769 csum_show(res->port_id);
3772 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
3773 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3775 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
3776 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3777 parse, "parse_tunnel");
3778 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
3779 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3781 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
3782 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
3785 cmdline_parse_inst_t cmd_csum_tunnel = {
3786 .f = cmd_csum_tunnel_parsed,
3788 .help_str = "csum parse_tunnel on|off <port_id>: "
3789 "Enable/Disable parsing of tunnels for csum engine",
3791 (void *)&cmd_csum_tunnel_csum,
3792 (void *)&cmd_csum_tunnel_parse,
3793 (void *)&cmd_csum_tunnel_onoff,
3794 (void *)&cmd_csum_tunnel_portid,
3799 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
3800 struct cmd_tso_set_result {
3801 cmdline_fixed_string_t tso;
3802 cmdline_fixed_string_t mode;
3808 cmd_tso_set_parsed(void *parsed_result,
3809 __attribute__((unused)) struct cmdline *cl,
3810 __attribute__((unused)) void *data)
3812 struct cmd_tso_set_result *res = parsed_result;
3813 struct rte_eth_dev_info dev_info;
3815 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3817 if (!port_is_stopped(res->port_id)) {
3818 printf("Please stop port %d first\n", res->port_id);
3822 if (!strcmp(res->mode, "set"))
3823 ports[res->port_id].tso_segsz = res->tso_segsz;
3825 if (ports[res->port_id].tso_segsz == 0) {
3826 ports[res->port_id].dev_conf.txmode.offloads &=
3827 ~DEV_TX_OFFLOAD_TCP_TSO;
3828 printf("TSO for non-tunneled packets is disabled\n");
3830 ports[res->port_id].dev_conf.txmode.offloads |=
3831 DEV_TX_OFFLOAD_TCP_TSO;
3832 printf("TSO segment size for non-tunneled packets is %d\n",
3833 ports[res->port_id].tso_segsz);
3836 /* display warnings if configuration is not supported by the NIC */
3837 rte_eth_dev_info_get(res->port_id, &dev_info);
3838 if ((ports[res->port_id].tso_segsz != 0) &&
3839 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
3840 printf("Warning: TSO enabled but not "
3841 "supported by port %d\n", res->port_id);
3844 cmd_reconfig_device_queue(res->port_id, 1, 1);
3847 cmdline_parse_token_string_t cmd_tso_set_tso =
3848 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3850 cmdline_parse_token_string_t cmd_tso_set_mode =
3851 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3853 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
3854 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3856 cmdline_parse_token_num_t cmd_tso_set_portid =
3857 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3860 cmdline_parse_inst_t cmd_tso_set = {
3861 .f = cmd_tso_set_parsed,
3863 .help_str = "tso set <tso_segsz> <port_id>: "
3864 "Set TSO segment size of non-tunneled packets for csum engine "
3867 (void *)&cmd_tso_set_tso,
3868 (void *)&cmd_tso_set_mode,
3869 (void *)&cmd_tso_set_tso_segsz,
3870 (void *)&cmd_tso_set_portid,
3875 cmdline_parse_token_string_t cmd_tso_show_mode =
3876 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3880 cmdline_parse_inst_t cmd_tso_show = {
3881 .f = cmd_tso_set_parsed,
3883 .help_str = "tso show <port_id>: "
3884 "Show TSO segment size of non-tunneled packets for csum engine",
3886 (void *)&cmd_tso_set_tso,
3887 (void *)&cmd_tso_show_mode,
3888 (void *)&cmd_tso_set_portid,
3893 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
3894 struct cmd_tunnel_tso_set_result {
3895 cmdline_fixed_string_t tso;
3896 cmdline_fixed_string_t mode;
3902 check_tunnel_tso_nic_support(portid_t port_id)
3904 struct rte_eth_dev_info dev_info;
3906 rte_eth_dev_info_get(port_id, &dev_info);
3907 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO))
3908 printf("Warning: TSO enabled but VXLAN TUNNEL TSO not "
3909 "supported by port %d\n", port_id);
3910 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO))
3911 printf("Warning: TSO enabled but GRE TUNNEL TSO not "
3912 "supported by port %d\n", port_id);
3913 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO))
3914 printf("Warning: TSO enabled but IPIP TUNNEL TSO not "
3915 "supported by port %d\n", port_id);
3916 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
3917 printf("Warning: TSO enabled but GENEVE TUNNEL TSO not "
3918 "supported by port %d\n", port_id);
3922 cmd_tunnel_tso_set_parsed(void *parsed_result,
3923 __attribute__((unused)) struct cmdline *cl,
3924 __attribute__((unused)) void *data)
3926 struct cmd_tunnel_tso_set_result *res = parsed_result;
3928 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3930 if (!port_is_stopped(res->port_id)) {
3931 printf("Please stop port %d first\n", res->port_id);
3935 if (!strcmp(res->mode, "set"))
3936 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
3938 if (ports[res->port_id].tunnel_tso_segsz == 0) {
3939 ports[res->port_id].dev_conf.txmode.offloads &=
3940 ~(DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
3941 DEV_TX_OFFLOAD_GRE_TNL_TSO |
3942 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
3943 DEV_TX_OFFLOAD_GENEVE_TNL_TSO);
3944 printf("TSO for tunneled packets is disabled\n");
3946 ports[res->port_id].dev_conf.txmode.offloads |=
3947 (DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
3948 DEV_TX_OFFLOAD_GRE_TNL_TSO |
3949 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
3950 DEV_TX_OFFLOAD_GENEVE_TNL_TSO);
3951 printf("TSO segment size for tunneled packets is %d\n",
3952 ports[res->port_id].tunnel_tso_segsz);
3954 /* Below conditions are needed to make it work:
3955 * (1) tunnel TSO is supported by the NIC;
3956 * (2) "csum parse_tunnel" must be set so that tunneled pkts
3958 * (3) for tunneled pkts with outer L3 of IPv4,
3959 * "csum set outer-ip" must be set to hw, because after tso,
3960 * total_len of outer IP header is changed, and the checksum
3961 * of outer IP header calculated by sw should be wrong; that
3962 * is not necessary for IPv6 tunneled pkts because there's no
3963 * checksum in IP header anymore.
3965 check_tunnel_tso_nic_support(res->port_id);
3967 if (!ports[res->port_id].parse_tunnel)
3968 printf("Warning: csum parse_tunnel must be set "
3969 "so that tunneled packets are recognized\n");
3970 if (!(ports[res->port_id].dev_conf.txmode.offloads &
3971 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM))
3972 printf("Warning: csum set outer-ip must be set to hw "
3973 "if outer L3 is IPv4; not necessary for IPv6\n");
3976 cmd_reconfig_device_queue(res->port_id, 1, 1);
3979 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
3980 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
3982 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
3983 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
3985 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
3986 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
3988 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
3989 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
3992 cmdline_parse_inst_t cmd_tunnel_tso_set = {
3993 .f = cmd_tunnel_tso_set_parsed,
3995 .help_str = "tunnel_tso set <tso_segsz> <port_id>: "
3996 "Set TSO segment size of tunneled packets for csum engine "
3999 (void *)&cmd_tunnel_tso_set_tso,
4000 (void *)&cmd_tunnel_tso_set_mode,
4001 (void *)&cmd_tunnel_tso_set_tso_segsz,
4002 (void *)&cmd_tunnel_tso_set_portid,
4007 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
4008 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4012 cmdline_parse_inst_t cmd_tunnel_tso_show = {
4013 .f = cmd_tunnel_tso_set_parsed,
4015 .help_str = "tunnel_tso show <port_id> "
4016 "Show TSO segment size of tunneled packets for csum engine",
4018 (void *)&cmd_tunnel_tso_set_tso,
4019 (void *)&cmd_tunnel_tso_show_mode,
4020 (void *)&cmd_tunnel_tso_set_portid,
4025 /* *** SET GRO FOR A PORT *** */
4026 struct cmd_gro_enable_result {
4027 cmdline_fixed_string_t cmd_set;
4028 cmdline_fixed_string_t cmd_port;
4029 cmdline_fixed_string_t cmd_keyword;
4030 cmdline_fixed_string_t cmd_onoff;
4035 cmd_gro_enable_parsed(void *parsed_result,
4036 __attribute__((unused)) struct cmdline *cl,
4037 __attribute__((unused)) void *data)
4039 struct cmd_gro_enable_result *res;
4041 res = parsed_result;
4042 if (!strcmp(res->cmd_keyword, "gro"))
4043 setup_gro(res->cmd_onoff, res->cmd_pid);
4046 cmdline_parse_token_string_t cmd_gro_enable_set =
4047 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4049 cmdline_parse_token_string_t cmd_gro_enable_port =
4050 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4051 cmd_keyword, "port");
4052 cmdline_parse_token_num_t cmd_gro_enable_pid =
4053 TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result,
4055 cmdline_parse_token_string_t cmd_gro_enable_keyword =
4056 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4057 cmd_keyword, "gro");
4058 cmdline_parse_token_string_t cmd_gro_enable_onoff =
4059 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4060 cmd_onoff, "on#off");
4062 cmdline_parse_inst_t cmd_gro_enable = {
4063 .f = cmd_gro_enable_parsed,
4065 .help_str = "set port <port_id> gro on|off",
4067 (void *)&cmd_gro_enable_set,
4068 (void *)&cmd_gro_enable_port,
4069 (void *)&cmd_gro_enable_pid,
4070 (void *)&cmd_gro_enable_keyword,
4071 (void *)&cmd_gro_enable_onoff,
4076 /* *** DISPLAY GRO CONFIGURATION *** */
4077 struct cmd_gro_show_result {
4078 cmdline_fixed_string_t cmd_show;
4079 cmdline_fixed_string_t cmd_port;
4080 cmdline_fixed_string_t cmd_keyword;
4085 cmd_gro_show_parsed(void *parsed_result,
4086 __attribute__((unused)) struct cmdline *cl,
4087 __attribute__((unused)) void *data)
4089 struct cmd_gro_show_result *res;
4091 res = parsed_result;
4092 if (!strcmp(res->cmd_keyword, "gro"))
4093 show_gro(res->cmd_pid);
4096 cmdline_parse_token_string_t cmd_gro_show_show =
4097 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4099 cmdline_parse_token_string_t cmd_gro_show_port =
4100 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4102 cmdline_parse_token_num_t cmd_gro_show_pid =
4103 TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result,
4105 cmdline_parse_token_string_t cmd_gro_show_keyword =
4106 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4107 cmd_keyword, "gro");
4109 cmdline_parse_inst_t cmd_gro_show = {
4110 .f = cmd_gro_show_parsed,
4112 .help_str = "show port <port_id> gro",
4114 (void *)&cmd_gro_show_show,
4115 (void *)&cmd_gro_show_port,
4116 (void *)&cmd_gro_show_pid,
4117 (void *)&cmd_gro_show_keyword,
4122 /* *** SET FLUSH CYCLES FOR GRO *** */
4123 struct cmd_gro_flush_result {
4124 cmdline_fixed_string_t cmd_set;
4125 cmdline_fixed_string_t cmd_keyword;
4126 cmdline_fixed_string_t cmd_flush;
4131 cmd_gro_flush_parsed(void *parsed_result,
4132 __attribute__((unused)) struct cmdline *cl,
4133 __attribute__((unused)) void *data)
4135 struct cmd_gro_flush_result *res;
4137 res = parsed_result;
4138 if ((!strcmp(res->cmd_keyword, "gro")) &&
4139 (!strcmp(res->cmd_flush, "flush")))
4140 setup_gro_flush_cycles(res->cmd_cycles);
4143 cmdline_parse_token_string_t cmd_gro_flush_set =
4144 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4146 cmdline_parse_token_string_t cmd_gro_flush_keyword =
4147 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4148 cmd_keyword, "gro");
4149 cmdline_parse_token_string_t cmd_gro_flush_flush =
4150 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4151 cmd_flush, "flush");
4152 cmdline_parse_token_num_t cmd_gro_flush_cycles =
4153 TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result,
4156 cmdline_parse_inst_t cmd_gro_flush = {
4157 .f = cmd_gro_flush_parsed,
4159 .help_str = "set gro flush <cycles>",
4161 (void *)&cmd_gro_flush_set,
4162 (void *)&cmd_gro_flush_keyword,
4163 (void *)&cmd_gro_flush_flush,
4164 (void *)&cmd_gro_flush_cycles,
4169 /* *** ENABLE/DISABLE GSO *** */
4170 struct cmd_gso_enable_result {
4171 cmdline_fixed_string_t cmd_set;
4172 cmdline_fixed_string_t cmd_port;
4173 cmdline_fixed_string_t cmd_keyword;
4174 cmdline_fixed_string_t cmd_mode;
4179 cmd_gso_enable_parsed(void *parsed_result,
4180 __attribute__((unused)) struct cmdline *cl,
4181 __attribute__((unused)) void *data)
4183 struct cmd_gso_enable_result *res;
4185 res = parsed_result;
4186 if (!strcmp(res->cmd_keyword, "gso"))
4187 setup_gso(res->cmd_mode, res->cmd_pid);
4190 cmdline_parse_token_string_t cmd_gso_enable_set =
4191 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4193 cmdline_parse_token_string_t cmd_gso_enable_port =
4194 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4196 cmdline_parse_token_string_t cmd_gso_enable_keyword =
4197 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4198 cmd_keyword, "gso");
4199 cmdline_parse_token_string_t cmd_gso_enable_mode =
4200 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4201 cmd_mode, "on#off");
4202 cmdline_parse_token_num_t cmd_gso_enable_pid =
4203 TOKEN_NUM_INITIALIZER(struct cmd_gso_enable_result,
4206 cmdline_parse_inst_t cmd_gso_enable = {
4207 .f = cmd_gso_enable_parsed,
4209 .help_str = "set port <port_id> gso on|off",
4211 (void *)&cmd_gso_enable_set,
4212 (void *)&cmd_gso_enable_port,
4213 (void *)&cmd_gso_enable_pid,
4214 (void *)&cmd_gso_enable_keyword,
4215 (void *)&cmd_gso_enable_mode,
4220 /* *** SET MAX PACKET LENGTH FOR GSO SEGMENTS *** */
4221 struct cmd_gso_size_result {
4222 cmdline_fixed_string_t cmd_set;
4223 cmdline_fixed_string_t cmd_keyword;
4224 cmdline_fixed_string_t cmd_segsz;
4229 cmd_gso_size_parsed(void *parsed_result,
4230 __attribute__((unused)) struct cmdline *cl,
4231 __attribute__((unused)) void *data)
4233 struct cmd_gso_size_result *res = parsed_result;
4235 if (test_done == 0) {
4236 printf("Before setting GSO segsz, please first"
4237 " stop fowarding\n");
4241 if (!strcmp(res->cmd_keyword, "gso") &&
4242 !strcmp(res->cmd_segsz, "segsz")) {
4243 if (res->cmd_size < RTE_GSO_SEG_SIZE_MIN)
4244 printf("gso_size should be larger than %zu."
4245 " Please input a legal value\n",
4246 RTE_GSO_SEG_SIZE_MIN);
4248 gso_max_segment_size = res->cmd_size;
4252 cmdline_parse_token_string_t cmd_gso_size_set =
4253 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
4255 cmdline_parse_token_string_t cmd_gso_size_keyword =
4256 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
4257 cmd_keyword, "gso");
4258 cmdline_parse_token_string_t cmd_gso_size_segsz =
4259 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
4260 cmd_segsz, "segsz");
4261 cmdline_parse_token_num_t cmd_gso_size_size =
4262 TOKEN_NUM_INITIALIZER(struct cmd_gso_size_result,
4265 cmdline_parse_inst_t cmd_gso_size = {
4266 .f = cmd_gso_size_parsed,
4268 .help_str = "set gso segsz <length>",
4270 (void *)&cmd_gso_size_set,
4271 (void *)&cmd_gso_size_keyword,
4272 (void *)&cmd_gso_size_segsz,
4273 (void *)&cmd_gso_size_size,
4278 /* *** SHOW GSO CONFIGURATION *** */
4279 struct cmd_gso_show_result {
4280 cmdline_fixed_string_t cmd_show;
4281 cmdline_fixed_string_t cmd_port;
4282 cmdline_fixed_string_t cmd_keyword;
4287 cmd_gso_show_parsed(void *parsed_result,
4288 __attribute__((unused)) struct cmdline *cl,
4289 __attribute__((unused)) void *data)
4291 struct cmd_gso_show_result *res = parsed_result;
4293 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
4294 printf("invalid port id %u\n", res->cmd_pid);
4297 if (!strcmp(res->cmd_keyword, "gso")) {
4298 if (gso_ports[res->cmd_pid].enable) {
4299 printf("Max GSO'd packet size: %uB\n"
4300 "Supported GSO types: TCP/IPv4, "
4301 "VxLAN with inner TCP/IPv4 packet, "
4302 "GRE with inner TCP/IPv4 packet\n",
4303 gso_max_segment_size);
4305 printf("GSO is not enabled on Port %u\n", res->cmd_pid);
4309 cmdline_parse_token_string_t cmd_gso_show_show =
4310 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
4312 cmdline_parse_token_string_t cmd_gso_show_port =
4313 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
4315 cmdline_parse_token_string_t cmd_gso_show_keyword =
4316 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
4317 cmd_keyword, "gso");
4318 cmdline_parse_token_num_t cmd_gso_show_pid =
4319 TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result,
4322 cmdline_parse_inst_t cmd_gso_show = {
4323 .f = cmd_gso_show_parsed,
4325 .help_str = "show port <port_id> gso",
4327 (void *)&cmd_gso_show_show,
4328 (void *)&cmd_gso_show_port,
4329 (void *)&cmd_gso_show_pid,
4330 (void *)&cmd_gso_show_keyword,
4335 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
4336 struct cmd_set_flush_rx {
4337 cmdline_fixed_string_t set;
4338 cmdline_fixed_string_t flush_rx;
4339 cmdline_fixed_string_t mode;
4343 cmd_set_flush_rx_parsed(void *parsed_result,
4344 __attribute__((unused)) struct cmdline *cl,
4345 __attribute__((unused)) void *data)
4347 struct cmd_set_flush_rx *res = parsed_result;
4348 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
4351 cmdline_parse_token_string_t cmd_setflushrx_set =
4352 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
4354 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
4355 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
4356 flush_rx, "flush_rx");
4357 cmdline_parse_token_string_t cmd_setflushrx_mode =
4358 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
4362 cmdline_parse_inst_t cmd_set_flush_rx = {
4363 .f = cmd_set_flush_rx_parsed,
4364 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
4367 (void *)&cmd_setflushrx_set,
4368 (void *)&cmd_setflushrx_flush_rx,
4369 (void *)&cmd_setflushrx_mode,
4374 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
4375 struct cmd_set_link_check {
4376 cmdline_fixed_string_t set;
4377 cmdline_fixed_string_t link_check;
4378 cmdline_fixed_string_t mode;
4382 cmd_set_link_check_parsed(void *parsed_result,
4383 __attribute__((unused)) struct cmdline *cl,
4384 __attribute__((unused)) void *data)
4386 struct cmd_set_link_check *res = parsed_result;
4387 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
4390 cmdline_parse_token_string_t cmd_setlinkcheck_set =
4391 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
4393 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
4394 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
4395 link_check, "link_check");
4396 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
4397 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
4401 cmdline_parse_inst_t cmd_set_link_check = {
4402 .f = cmd_set_link_check_parsed,
4403 .help_str = "set link_check on|off: Enable/Disable link status check "
4404 "when starting/stopping a port",
4407 (void *)&cmd_setlinkcheck_set,
4408 (void *)&cmd_setlinkcheck_link_check,
4409 (void *)&cmd_setlinkcheck_mode,
4414 /* *** SET NIC BYPASS MODE *** */
4415 struct cmd_set_bypass_mode_result {
4416 cmdline_fixed_string_t set;
4417 cmdline_fixed_string_t bypass;
4418 cmdline_fixed_string_t mode;
4419 cmdline_fixed_string_t value;
4424 cmd_set_bypass_mode_parsed(void *parsed_result,
4425 __attribute__((unused)) struct cmdline *cl,
4426 __attribute__((unused)) void *data)
4428 struct cmd_set_bypass_mode_result *res = parsed_result;
4429 portid_t port_id = res->port_id;
4430 int32_t rc = -EINVAL;
4432 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4433 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4435 if (!strcmp(res->value, "bypass"))
4436 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
4437 else if (!strcmp(res->value, "isolate"))
4438 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
4440 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4442 /* Set the bypass mode for the relevant port. */
4443 rc = rte_pmd_ixgbe_bypass_state_set(port_id, &bypass_mode);
4446 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
4449 cmdline_parse_token_string_t cmd_setbypass_mode_set =
4450 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4452 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
4453 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4455 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
4456 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4458 cmdline_parse_token_string_t cmd_setbypass_mode_value =
4459 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4460 value, "normal#bypass#isolate");
4461 cmdline_parse_token_num_t cmd_setbypass_mode_port =
4462 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
4465 cmdline_parse_inst_t cmd_set_bypass_mode = {
4466 .f = cmd_set_bypass_mode_parsed,
4467 .help_str = "set bypass mode normal|bypass|isolate <port_id>: "
4468 "Set the NIC bypass mode for port_id",
4471 (void *)&cmd_setbypass_mode_set,
4472 (void *)&cmd_setbypass_mode_bypass,
4473 (void *)&cmd_setbypass_mode_mode,
4474 (void *)&cmd_setbypass_mode_value,
4475 (void *)&cmd_setbypass_mode_port,
4480 /* *** SET NIC BYPASS EVENT *** */
4481 struct cmd_set_bypass_event_result {
4482 cmdline_fixed_string_t set;
4483 cmdline_fixed_string_t bypass;
4484 cmdline_fixed_string_t event;
4485 cmdline_fixed_string_t event_value;
4486 cmdline_fixed_string_t mode;
4487 cmdline_fixed_string_t mode_value;
4492 cmd_set_bypass_event_parsed(void *parsed_result,
4493 __attribute__((unused)) struct cmdline *cl,
4494 __attribute__((unused)) void *data)
4496 int32_t rc = -EINVAL;
4497 struct cmd_set_bypass_event_result *res = parsed_result;
4498 portid_t port_id = res->port_id;
4500 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4501 uint32_t bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
4502 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4504 if (!strcmp(res->event_value, "timeout"))
4505 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT;
4506 else if (!strcmp(res->event_value, "os_on"))
4507 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_ON;
4508 else if (!strcmp(res->event_value, "os_off"))
4509 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_OFF;
4510 else if (!strcmp(res->event_value, "power_on"))
4511 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_ON;
4512 else if (!strcmp(res->event_value, "power_off"))
4513 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_OFF;
4515 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
4517 if (!strcmp(res->mode_value, "bypass"))
4518 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
4519 else if (!strcmp(res->mode_value, "isolate"))
4520 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
4522 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4524 /* Set the watchdog timeout. */
4525 if (bypass_event == RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT) {
4528 if (RTE_PMD_IXGBE_BYPASS_TMT_VALID(bypass_timeout)) {
4529 rc = rte_pmd_ixgbe_bypass_wd_timeout_store(port_id,
4533 printf("Failed to set timeout value %u "
4534 "for port %d, errto code: %d.\n",
4535 bypass_timeout, port_id, rc);
4539 /* Set the bypass event to transition to bypass mode. */
4540 rc = rte_pmd_ixgbe_bypass_event_store(port_id, bypass_event,
4545 printf("\t Failed to set bypass event for port = %d.\n",
4549 cmdline_parse_token_string_t cmd_setbypass_event_set =
4550 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4552 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
4553 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4555 cmdline_parse_token_string_t cmd_setbypass_event_event =
4556 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4558 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
4559 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4560 event_value, "none#timeout#os_off#os_on#power_on#power_off");
4561 cmdline_parse_token_string_t cmd_setbypass_event_mode =
4562 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4564 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
4565 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4566 mode_value, "normal#bypass#isolate");
4567 cmdline_parse_token_num_t cmd_setbypass_event_port =
4568 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
4571 cmdline_parse_inst_t cmd_set_bypass_event = {
4572 .f = cmd_set_bypass_event_parsed,
4573 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
4574 "power_off mode normal|bypass|isolate <port_id>: "
4575 "Set the NIC bypass event mode for port_id",
4578 (void *)&cmd_setbypass_event_set,
4579 (void *)&cmd_setbypass_event_bypass,
4580 (void *)&cmd_setbypass_event_event,
4581 (void *)&cmd_setbypass_event_event_value,
4582 (void *)&cmd_setbypass_event_mode,
4583 (void *)&cmd_setbypass_event_mode_value,
4584 (void *)&cmd_setbypass_event_port,
4590 /* *** SET NIC BYPASS TIMEOUT *** */
4591 struct cmd_set_bypass_timeout_result {
4592 cmdline_fixed_string_t set;
4593 cmdline_fixed_string_t bypass;
4594 cmdline_fixed_string_t timeout;
4595 cmdline_fixed_string_t value;
4599 cmd_set_bypass_timeout_parsed(void *parsed_result,
4600 __attribute__((unused)) struct cmdline *cl,
4601 __attribute__((unused)) void *data)
4603 __rte_unused struct cmd_set_bypass_timeout_result *res = parsed_result;
4605 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4606 if (!strcmp(res->value, "1.5"))
4607 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_1_5_SEC;
4608 else if (!strcmp(res->value, "2"))
4609 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_2_SEC;
4610 else if (!strcmp(res->value, "3"))
4611 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_3_SEC;
4612 else if (!strcmp(res->value, "4"))
4613 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_4_SEC;
4614 else if (!strcmp(res->value, "8"))
4615 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_8_SEC;
4616 else if (!strcmp(res->value, "16"))
4617 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_16_SEC;
4618 else if (!strcmp(res->value, "32"))
4619 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_32_SEC;
4621 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
4625 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
4626 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4628 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
4629 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4631 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
4632 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4633 timeout, "timeout");
4634 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
4635 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4636 value, "0#1.5#2#3#4#8#16#32");
4638 cmdline_parse_inst_t cmd_set_bypass_timeout = {
4639 .f = cmd_set_bypass_timeout_parsed,
4640 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
4641 "Set the NIC bypass watchdog timeout in seconds",
4644 (void *)&cmd_setbypass_timeout_set,
4645 (void *)&cmd_setbypass_timeout_bypass,
4646 (void *)&cmd_setbypass_timeout_timeout,
4647 (void *)&cmd_setbypass_timeout_value,
4652 /* *** SHOW NIC BYPASS MODE *** */
4653 struct cmd_show_bypass_config_result {
4654 cmdline_fixed_string_t show;
4655 cmdline_fixed_string_t bypass;
4656 cmdline_fixed_string_t config;
4661 cmd_show_bypass_config_parsed(void *parsed_result,
4662 __attribute__((unused)) struct cmdline *cl,
4663 __attribute__((unused)) void *data)
4665 struct cmd_show_bypass_config_result *res = parsed_result;
4666 portid_t port_id = res->port_id;
4668 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4669 uint32_t event_mode;
4670 uint32_t bypass_mode;
4671 uint32_t timeout = bypass_timeout;
4674 static const char * const timeouts[RTE_PMD_IXGBE_BYPASS_TMT_NUM] =
4675 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
4676 static const char * const modes[RTE_PMD_IXGBE_BYPASS_MODE_NUM] =
4677 {"UNKNOWN", "normal", "bypass", "isolate"};
4678 static const char * const events[RTE_PMD_IXGBE_BYPASS_EVENT_NUM] = {
4685 int num_events = (sizeof events) / (sizeof events[0]);
4687 /* Display the bypass mode.*/
4688 if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) != 0) {
4689 printf("\tFailed to get bypass mode for port = %d\n", port_id);
4693 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(bypass_mode))
4694 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
4696 printf("\tbypass mode = %s\n", modes[bypass_mode]);
4699 /* Display the bypass timeout.*/
4700 if (!RTE_PMD_IXGBE_BYPASS_TMT_VALID(timeout))
4701 timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
4703 printf("\tbypass timeout = %s\n", timeouts[timeout]);
4705 /* Display the bypass events and associated modes. */
4706 for (i = RTE_PMD_IXGBE_BYPASS_EVENT_START; i < num_events; i++) {
4708 if (rte_pmd_ixgbe_bypass_event_show(port_id, i, &event_mode)) {
4709 printf("\tFailed to get bypass mode for event = %s\n",
4712 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(event_mode))
4713 event_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
4715 printf("\tbypass event: %-16s = %s\n", events[i],
4721 printf("\tFailed to get bypass configuration for port = %d\n",
4725 cmdline_parse_token_string_t cmd_showbypass_config_show =
4726 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4728 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
4729 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4731 cmdline_parse_token_string_t cmd_showbypass_config_config =
4732 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4734 cmdline_parse_token_num_t cmd_showbypass_config_port =
4735 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
4738 cmdline_parse_inst_t cmd_show_bypass_config = {
4739 .f = cmd_show_bypass_config_parsed,
4740 .help_str = "show bypass config <port_id>: "
4741 "Show the NIC bypass config for port_id",
4744 (void *)&cmd_showbypass_config_show,
4745 (void *)&cmd_showbypass_config_bypass,
4746 (void *)&cmd_showbypass_config_config,
4747 (void *)&cmd_showbypass_config_port,
4752 #ifdef RTE_LIBRTE_PMD_BOND
4753 /* *** SET BONDING MODE *** */
4754 struct cmd_set_bonding_mode_result {
4755 cmdline_fixed_string_t set;
4756 cmdline_fixed_string_t bonding;
4757 cmdline_fixed_string_t mode;
4762 static void cmd_set_bonding_mode_parsed(void *parsed_result,
4763 __attribute__((unused)) struct cmdline *cl,
4764 __attribute__((unused)) void *data)
4766 struct cmd_set_bonding_mode_result *res = parsed_result;
4767 portid_t port_id = res->port_id;
4769 /* Set the bonding mode for the relevant port. */
4770 if (0 != rte_eth_bond_mode_set(port_id, res->value))
4771 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
4774 cmdline_parse_token_string_t cmd_setbonding_mode_set =
4775 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4777 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
4778 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4779 bonding, "bonding");
4780 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
4781 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4783 cmdline_parse_token_num_t cmd_setbonding_mode_value =
4784 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
4786 cmdline_parse_token_num_t cmd_setbonding_mode_port =
4787 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
4790 cmdline_parse_inst_t cmd_set_bonding_mode = {
4791 .f = cmd_set_bonding_mode_parsed,
4792 .help_str = "set bonding mode <mode_value> <port_id>: "
4793 "Set the bonding mode for port_id",
4796 (void *) &cmd_setbonding_mode_set,
4797 (void *) &cmd_setbonding_mode_bonding,
4798 (void *) &cmd_setbonding_mode_mode,
4799 (void *) &cmd_setbonding_mode_value,
4800 (void *) &cmd_setbonding_mode_port,
4805 /* *** SET BONDING SLOW_QUEUE SW/HW *** */
4806 struct cmd_set_bonding_lacp_dedicated_queues_result {
4807 cmdline_fixed_string_t set;
4808 cmdline_fixed_string_t bonding;
4809 cmdline_fixed_string_t lacp;
4810 cmdline_fixed_string_t dedicated_queues;
4812 cmdline_fixed_string_t mode;
4815 static void cmd_set_bonding_lacp_dedicated_queues_parsed(void *parsed_result,
4816 __attribute__((unused)) struct cmdline *cl,
4817 __attribute__((unused)) void *data)
4819 struct cmd_set_bonding_lacp_dedicated_queues_result *res = parsed_result;
4820 portid_t port_id = res->port_id;
4821 struct rte_port *port;
4823 port = &ports[port_id];
4825 /** Check if the port is not started **/
4826 if (port->port_status != RTE_PORT_STOPPED) {
4827 printf("Please stop port %d first\n", port_id);
4831 if (!strcmp(res->mode, "enable")) {
4832 if (rte_eth_bond_8023ad_dedicated_queues_enable(port_id) == 0)
4833 printf("Dedicate queues for LACP control packets"
4836 printf("Enabling dedicate queues for LACP control "
4837 "packets on port %d failed\n", port_id);
4838 } else if (!strcmp(res->mode, "disable")) {
4839 if (rte_eth_bond_8023ad_dedicated_queues_disable(port_id) == 0)
4840 printf("Dedicated queues for LACP control packets "
4843 printf("Disabling dedicated queues for LACP control "
4844 "traffic on port %d failed\n", port_id);
4848 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_set =
4849 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4851 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_bonding =
4852 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4853 bonding, "bonding");
4854 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_lacp =
4855 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4857 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_dedicated_queues =
4858 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4859 dedicated_queues, "dedicated_queues");
4860 cmdline_parse_token_num_t cmd_setbonding_lacp_dedicated_queues_port_id =
4861 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4863 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_mode =
4864 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4865 mode, "enable#disable");
4867 cmdline_parse_inst_t cmd_set_lacp_dedicated_queues = {
4868 .f = cmd_set_bonding_lacp_dedicated_queues_parsed,
4869 .help_str = "set bonding lacp dedicated_queues <port_id> "
4871 "Enable/disable dedicated queues for LACP control traffic for port_id",
4874 (void *)&cmd_setbonding_lacp_dedicated_queues_set,
4875 (void *)&cmd_setbonding_lacp_dedicated_queues_bonding,
4876 (void *)&cmd_setbonding_lacp_dedicated_queues_lacp,
4877 (void *)&cmd_setbonding_lacp_dedicated_queues_dedicated_queues,
4878 (void *)&cmd_setbonding_lacp_dedicated_queues_port_id,
4879 (void *)&cmd_setbonding_lacp_dedicated_queues_mode,
4884 /* *** SET BALANCE XMIT POLICY *** */
4885 struct cmd_set_bonding_balance_xmit_policy_result {
4886 cmdline_fixed_string_t set;
4887 cmdline_fixed_string_t bonding;
4888 cmdline_fixed_string_t balance_xmit_policy;
4890 cmdline_fixed_string_t policy;
4893 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
4894 __attribute__((unused)) struct cmdline *cl,
4895 __attribute__((unused)) void *data)
4897 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
4898 portid_t port_id = res->port_id;
4901 if (!strcmp(res->policy, "l2")) {
4902 policy = BALANCE_XMIT_POLICY_LAYER2;
4903 } else if (!strcmp(res->policy, "l23")) {
4904 policy = BALANCE_XMIT_POLICY_LAYER23;
4905 } else if (!strcmp(res->policy, "l34")) {
4906 policy = BALANCE_XMIT_POLICY_LAYER34;
4908 printf("\t Invalid xmit policy selection");
4912 /* Set the bonding mode for the relevant port. */
4913 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
4914 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
4919 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
4920 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4922 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
4923 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4924 bonding, "bonding");
4925 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
4926 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4927 balance_xmit_policy, "balance_xmit_policy");
4928 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
4929 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4931 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
4932 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4933 policy, "l2#l23#l34");
4935 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
4936 .f = cmd_set_bonding_balance_xmit_policy_parsed,
4937 .help_str = "set bonding balance_xmit_policy <port_id> "
4939 "Set the bonding balance_xmit_policy for port_id",
4942 (void *)&cmd_setbonding_balance_xmit_policy_set,
4943 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
4944 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
4945 (void *)&cmd_setbonding_balance_xmit_policy_port,
4946 (void *)&cmd_setbonding_balance_xmit_policy_policy,
4951 /* *** SHOW NIC BONDING CONFIGURATION *** */
4952 struct cmd_show_bonding_config_result {
4953 cmdline_fixed_string_t show;
4954 cmdline_fixed_string_t bonding;
4955 cmdline_fixed_string_t config;
4959 static void cmd_show_bonding_config_parsed(void *parsed_result,
4960 __attribute__((unused)) struct cmdline *cl,
4961 __attribute__((unused)) void *data)
4963 struct cmd_show_bonding_config_result *res = parsed_result;
4964 int bonding_mode, agg_mode;
4965 portid_t slaves[RTE_MAX_ETHPORTS];
4966 int num_slaves, num_active_slaves;
4969 portid_t port_id = res->port_id;
4971 /* Display the bonding mode.*/
4972 bonding_mode = rte_eth_bond_mode_get(port_id);
4973 if (bonding_mode < 0) {
4974 printf("\tFailed to get bonding mode for port = %d\n", port_id);
4977 printf("\tBonding mode: %d\n", bonding_mode);
4979 if (bonding_mode == BONDING_MODE_BALANCE) {
4980 int balance_xmit_policy;
4982 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
4983 if (balance_xmit_policy < 0) {
4984 printf("\tFailed to get balance xmit policy for port = %d\n",
4988 printf("\tBalance Xmit Policy: ");
4990 switch (balance_xmit_policy) {
4991 case BALANCE_XMIT_POLICY_LAYER2:
4992 printf("BALANCE_XMIT_POLICY_LAYER2");
4994 case BALANCE_XMIT_POLICY_LAYER23:
4995 printf("BALANCE_XMIT_POLICY_LAYER23");
4997 case BALANCE_XMIT_POLICY_LAYER34:
4998 printf("BALANCE_XMIT_POLICY_LAYER34");
5005 if (bonding_mode == BONDING_MODE_8023AD) {
5006 agg_mode = rte_eth_bond_8023ad_agg_selection_get(port_id);
5007 printf("\tIEEE802.3AD Aggregator Mode: ");
5010 printf("bandwidth");
5022 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
5024 if (num_slaves < 0) {
5025 printf("\tFailed to get slave list for port = %d\n", port_id);
5028 if (num_slaves > 0) {
5029 printf("\tSlaves (%d): [", num_slaves);
5030 for (i = 0; i < num_slaves - 1; i++)
5031 printf("%d ", slaves[i]);
5033 printf("%d]\n", slaves[num_slaves - 1]);
5035 printf("\tSlaves: []\n");
5039 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
5042 if (num_active_slaves < 0) {
5043 printf("\tFailed to get active slave list for port = %d\n", port_id);
5046 if (num_active_slaves > 0) {
5047 printf("\tActive Slaves (%d): [", num_active_slaves);
5048 for (i = 0; i < num_active_slaves - 1; i++)
5049 printf("%d ", slaves[i]);
5051 printf("%d]\n", slaves[num_active_slaves - 1]);
5054 printf("\tActive Slaves: []\n");
5058 primary_id = rte_eth_bond_primary_get(port_id);
5059 if (primary_id < 0) {
5060 printf("\tFailed to get primary slave for port = %d\n", port_id);
5063 printf("\tPrimary: [%d]\n", primary_id);
5067 cmdline_parse_token_string_t cmd_showbonding_config_show =
5068 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5070 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
5071 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5072 bonding, "bonding");
5073 cmdline_parse_token_string_t cmd_showbonding_config_config =
5074 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5076 cmdline_parse_token_num_t cmd_showbonding_config_port =
5077 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
5080 cmdline_parse_inst_t cmd_show_bonding_config = {
5081 .f = cmd_show_bonding_config_parsed,
5082 .help_str = "show bonding config <port_id>: "
5083 "Show the bonding config for port_id",
5086 (void *)&cmd_showbonding_config_show,
5087 (void *)&cmd_showbonding_config_bonding,
5088 (void *)&cmd_showbonding_config_config,
5089 (void *)&cmd_showbonding_config_port,
5094 /* *** SET BONDING PRIMARY *** */
5095 struct cmd_set_bonding_primary_result {
5096 cmdline_fixed_string_t set;
5097 cmdline_fixed_string_t bonding;
5098 cmdline_fixed_string_t primary;
5103 static void cmd_set_bonding_primary_parsed(void *parsed_result,
5104 __attribute__((unused)) struct cmdline *cl,
5105 __attribute__((unused)) void *data)
5107 struct cmd_set_bonding_primary_result *res = parsed_result;
5108 portid_t master_port_id = res->port_id;
5109 portid_t slave_port_id = res->slave_id;
5111 /* Set the primary slave for a bonded device. */
5112 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
5113 printf("\t Failed to set primary slave for port = %d.\n",
5120 cmdline_parse_token_string_t cmd_setbonding_primary_set =
5121 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5123 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
5124 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5125 bonding, "bonding");
5126 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
5127 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5128 primary, "primary");
5129 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
5130 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
5132 cmdline_parse_token_num_t cmd_setbonding_primary_port =
5133 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
5136 cmdline_parse_inst_t cmd_set_bonding_primary = {
5137 .f = cmd_set_bonding_primary_parsed,
5138 .help_str = "set bonding primary <slave_id> <port_id>: "
5139 "Set the primary slave for port_id",
5142 (void *)&cmd_setbonding_primary_set,
5143 (void *)&cmd_setbonding_primary_bonding,
5144 (void *)&cmd_setbonding_primary_primary,
5145 (void *)&cmd_setbonding_primary_slave,
5146 (void *)&cmd_setbonding_primary_port,
5151 /* *** ADD SLAVE *** */
5152 struct cmd_add_bonding_slave_result {
5153 cmdline_fixed_string_t add;
5154 cmdline_fixed_string_t bonding;
5155 cmdline_fixed_string_t slave;
5160 static void cmd_add_bonding_slave_parsed(void *parsed_result,
5161 __attribute__((unused)) struct cmdline *cl,
5162 __attribute__((unused)) void *data)
5164 struct cmd_add_bonding_slave_result *res = parsed_result;
5165 portid_t master_port_id = res->port_id;
5166 portid_t slave_port_id = res->slave_id;
5168 /* add the slave for a bonded device. */
5169 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
5170 printf("\t Failed to add slave %d to master port = %d.\n",
5171 slave_port_id, master_port_id);
5175 set_port_slave_flag(slave_port_id);
5178 cmdline_parse_token_string_t cmd_addbonding_slave_add =
5179 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5181 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
5182 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5183 bonding, "bonding");
5184 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
5185 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5187 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
5188 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
5190 cmdline_parse_token_num_t cmd_addbonding_slave_port =
5191 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
5194 cmdline_parse_inst_t cmd_add_bonding_slave = {
5195 .f = cmd_add_bonding_slave_parsed,
5196 .help_str = "add bonding slave <slave_id> <port_id>: "
5197 "Add a slave device to a bonded device",
5200 (void *)&cmd_addbonding_slave_add,
5201 (void *)&cmd_addbonding_slave_bonding,
5202 (void *)&cmd_addbonding_slave_slave,
5203 (void *)&cmd_addbonding_slave_slaveid,
5204 (void *)&cmd_addbonding_slave_port,
5209 /* *** REMOVE SLAVE *** */
5210 struct cmd_remove_bonding_slave_result {
5211 cmdline_fixed_string_t remove;
5212 cmdline_fixed_string_t bonding;
5213 cmdline_fixed_string_t slave;
5218 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
5219 __attribute__((unused)) struct cmdline *cl,
5220 __attribute__((unused)) void *data)
5222 struct cmd_remove_bonding_slave_result *res = parsed_result;
5223 portid_t master_port_id = res->port_id;
5224 portid_t slave_port_id = res->slave_id;
5226 /* remove the slave from a bonded device. */
5227 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
5228 printf("\t Failed to remove slave %d from master port = %d.\n",
5229 slave_port_id, master_port_id);
5233 clear_port_slave_flag(slave_port_id);
5236 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
5237 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
5239 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
5240 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
5241 bonding, "bonding");
5242 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
5243 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
5245 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
5246 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
5248 cmdline_parse_token_num_t cmd_removebonding_slave_port =
5249 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
5252 cmdline_parse_inst_t cmd_remove_bonding_slave = {
5253 .f = cmd_remove_bonding_slave_parsed,
5254 .help_str = "remove bonding slave <slave_id> <port_id>: "
5255 "Remove a slave device from a bonded device",
5258 (void *)&cmd_removebonding_slave_remove,
5259 (void *)&cmd_removebonding_slave_bonding,
5260 (void *)&cmd_removebonding_slave_slave,
5261 (void *)&cmd_removebonding_slave_slaveid,
5262 (void *)&cmd_removebonding_slave_port,
5267 /* *** CREATE BONDED DEVICE *** */
5268 struct cmd_create_bonded_device_result {
5269 cmdline_fixed_string_t create;
5270 cmdline_fixed_string_t bonded;
5271 cmdline_fixed_string_t device;
5276 static int bond_dev_num = 0;
5278 static void cmd_create_bonded_device_parsed(void *parsed_result,
5279 __attribute__((unused)) struct cmdline *cl,
5280 __attribute__((unused)) void *data)
5282 struct cmd_create_bonded_device_result *res = parsed_result;
5283 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
5286 if (test_done == 0) {
5287 printf("Please stop forwarding first\n");
5291 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bonding_testpmd_%d",
5294 /* Create a new bonded device. */
5295 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
5297 printf("\t Failed to create bonded device.\n");
5300 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
5303 /* Update number of ports */
5304 nb_ports = rte_eth_dev_count();
5305 reconfig(port_id, res->socket);
5306 rte_eth_promiscuous_enable(port_id);
5311 cmdline_parse_token_string_t cmd_createbonded_device_create =
5312 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
5314 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
5315 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
5317 cmdline_parse_token_string_t cmd_createbonded_device_device =
5318 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
5320 cmdline_parse_token_num_t cmd_createbonded_device_mode =
5321 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
5323 cmdline_parse_token_num_t cmd_createbonded_device_socket =
5324 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
5327 cmdline_parse_inst_t cmd_create_bonded_device = {
5328 .f = cmd_create_bonded_device_parsed,
5329 .help_str = "create bonded device <mode> <socket>: "
5330 "Create a new bonded device with specific bonding mode and socket",
5333 (void *)&cmd_createbonded_device_create,
5334 (void *)&cmd_createbonded_device_bonded,
5335 (void *)&cmd_createbonded_device_device,
5336 (void *)&cmd_createbonded_device_mode,
5337 (void *)&cmd_createbonded_device_socket,
5342 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
5343 struct cmd_set_bond_mac_addr_result {
5344 cmdline_fixed_string_t set;
5345 cmdline_fixed_string_t bonding;
5346 cmdline_fixed_string_t mac_addr;
5348 struct ether_addr address;
5351 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
5352 __attribute__((unused)) struct cmdline *cl,
5353 __attribute__((unused)) void *data)
5355 struct cmd_set_bond_mac_addr_result *res = parsed_result;
5358 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
5361 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
5363 /* check the return value and print it if is < 0 */
5365 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
5368 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
5369 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
5370 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
5371 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
5373 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
5374 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
5376 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
5377 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result,
5379 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
5380 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
5382 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
5383 .f = cmd_set_bond_mac_addr_parsed,
5385 .help_str = "set bonding mac_addr <port_id> <mac_addr>",
5387 (void *)&cmd_set_bond_mac_addr_set,
5388 (void *)&cmd_set_bond_mac_addr_bonding,
5389 (void *)&cmd_set_bond_mac_addr_mac,
5390 (void *)&cmd_set_bond_mac_addr_portnum,
5391 (void *)&cmd_set_bond_mac_addr_addr,
5397 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
5398 struct cmd_set_bond_mon_period_result {
5399 cmdline_fixed_string_t set;
5400 cmdline_fixed_string_t bonding;
5401 cmdline_fixed_string_t mon_period;
5406 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
5407 __attribute__((unused)) struct cmdline *cl,
5408 __attribute__((unused)) void *data)
5410 struct cmd_set_bond_mon_period_result *res = parsed_result;
5413 if (res->port_num >= nb_ports) {
5414 printf("Port id %d must be less than %d\n", res->port_num, nb_ports);
5418 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
5420 /* check the return value and print it if is < 0 */
5422 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
5425 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
5426 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
5428 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
5429 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
5430 bonding, "bonding");
5431 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
5432 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
5433 mon_period, "mon_period");
5434 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
5435 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
5437 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
5438 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
5441 cmdline_parse_inst_t cmd_set_bond_mon_period = {
5442 .f = cmd_set_bond_mon_period_parsed,
5444 .help_str = "set bonding mon_period <port_id> <period_ms>",
5446 (void *)&cmd_set_bond_mon_period_set,
5447 (void *)&cmd_set_bond_mon_period_bonding,
5448 (void *)&cmd_set_bond_mon_period_mon_period,
5449 (void *)&cmd_set_bond_mon_period_portnum,
5450 (void *)&cmd_set_bond_mon_period_period_ms,
5457 struct cmd_set_bonding_agg_mode_policy_result {
5458 cmdline_fixed_string_t set;
5459 cmdline_fixed_string_t bonding;
5460 cmdline_fixed_string_t agg_mode;
5462 cmdline_fixed_string_t policy;
5467 cmd_set_bonding_agg_mode(void *parsed_result,
5468 __attribute__((unused)) struct cmdline *cl,
5469 __attribute__((unused)) void *data)
5471 struct cmd_set_bonding_agg_mode_policy_result *res = parsed_result;
5472 uint8_t policy = AGG_BANDWIDTH;
5474 if (res->port_num >= nb_ports) {
5475 printf("Port id %d must be less than %d\n",
5476 res->port_num, nb_ports);
5480 if (!strcmp(res->policy, "bandwidth"))
5481 policy = AGG_BANDWIDTH;
5482 else if (!strcmp(res->policy, "stable"))
5483 policy = AGG_STABLE;
5484 else if (!strcmp(res->policy, "count"))
5487 rte_eth_bond_8023ad_agg_selection_set(res->port_num, policy);
5491 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_set =
5492 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5494 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_bonding =
5495 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5496 bonding, "bonding");
5498 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_agg_mode =
5499 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5500 agg_mode, "agg_mode");
5502 cmdline_parse_token_num_t cmd_set_bonding_agg_mode_portnum =
5503 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5506 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_policy_string =
5507 TOKEN_STRING_INITIALIZER(
5508 struct cmd_set_bonding_balance_xmit_policy_result,
5509 policy, "stable#bandwidth#count");
5511 cmdline_parse_inst_t cmd_set_bonding_agg_mode_policy = {
5512 .f = cmd_set_bonding_agg_mode,
5514 .help_str = "set bonding mode IEEE802.3AD aggregator policy <port_id> <agg_name>",
5516 (void *)&cmd_set_bonding_agg_mode_set,
5517 (void *)&cmd_set_bonding_agg_mode_bonding,
5518 (void *)&cmd_set_bonding_agg_mode_agg_mode,
5519 (void *)&cmd_set_bonding_agg_mode_portnum,
5520 (void *)&cmd_set_bonding_agg_mode_policy_string,
5526 #endif /* RTE_LIBRTE_PMD_BOND */
5528 /* *** SET FORWARDING MODE *** */
5529 struct cmd_set_fwd_mode_result {
5530 cmdline_fixed_string_t set;
5531 cmdline_fixed_string_t fwd;
5532 cmdline_fixed_string_t mode;
5535 static void cmd_set_fwd_mode_parsed(void *parsed_result,
5536 __attribute__((unused)) struct cmdline *cl,
5537 __attribute__((unused)) void *data)
5539 struct cmd_set_fwd_mode_result *res = parsed_result;
5542 set_pkt_forwarding_mode(res->mode);
5545 cmdline_parse_token_string_t cmd_setfwd_set =
5546 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
5547 cmdline_parse_token_string_t cmd_setfwd_fwd =
5548 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
5549 cmdline_parse_token_string_t cmd_setfwd_mode =
5550 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
5551 "" /* defined at init */);
5553 cmdline_parse_inst_t cmd_set_fwd_mode = {
5554 .f = cmd_set_fwd_mode_parsed,
5556 .help_str = NULL, /* defined at init */
5558 (void *)&cmd_setfwd_set,
5559 (void *)&cmd_setfwd_fwd,
5560 (void *)&cmd_setfwd_mode,
5565 static void cmd_set_fwd_mode_init(void)
5568 static char token[128];
5569 static char help[256];
5570 cmdline_parse_token_string_t *token_struct;
5572 modes = list_pkt_forwarding_modes();
5573 snprintf(help, sizeof(help), "set fwd %s: "
5574 "Set packet forwarding mode", modes);
5575 cmd_set_fwd_mode.help_str = help;
5577 /* string token separator is # */
5578 for (c = token; *modes != '\0'; modes++)
5583 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
5584 token_struct->string_data.str = token;
5587 /* *** SET RETRY FORWARDING MODE *** */
5588 struct cmd_set_fwd_retry_mode_result {
5589 cmdline_fixed_string_t set;
5590 cmdline_fixed_string_t fwd;
5591 cmdline_fixed_string_t mode;
5592 cmdline_fixed_string_t retry;
5595 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
5596 __attribute__((unused)) struct cmdline *cl,
5597 __attribute__((unused)) void *data)
5599 struct cmd_set_fwd_retry_mode_result *res = parsed_result;
5602 set_pkt_forwarding_mode(res->mode);
5605 cmdline_parse_token_string_t cmd_setfwd_retry_set =
5606 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
5608 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
5609 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
5611 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
5612 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
5614 "" /* defined at init */);
5615 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
5616 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
5619 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
5620 .f = cmd_set_fwd_retry_mode_parsed,
5622 .help_str = NULL, /* defined at init */
5624 (void *)&cmd_setfwd_retry_set,
5625 (void *)&cmd_setfwd_retry_fwd,
5626 (void *)&cmd_setfwd_retry_mode,
5627 (void *)&cmd_setfwd_retry_retry,
5632 static void cmd_set_fwd_retry_mode_init(void)
5635 static char token[128];
5636 static char help[256];
5637 cmdline_parse_token_string_t *token_struct;
5639 modes = list_pkt_forwarding_retry_modes();
5640 snprintf(help, sizeof(help), "set fwd %s retry: "
5641 "Set packet forwarding mode with retry", modes);
5642 cmd_set_fwd_retry_mode.help_str = help;
5644 /* string token separator is # */
5645 for (c = token; *modes != '\0'; modes++)
5650 token_struct = (cmdline_parse_token_string_t *)
5651 cmd_set_fwd_retry_mode.tokens[2];
5652 token_struct->string_data.str = token;
5655 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
5656 struct cmd_set_burst_tx_retry_result {
5657 cmdline_fixed_string_t set;
5658 cmdline_fixed_string_t burst;
5659 cmdline_fixed_string_t tx;
5660 cmdline_fixed_string_t delay;
5662 cmdline_fixed_string_t retry;
5666 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
5667 __attribute__((unused)) struct cmdline *cl,
5668 __attribute__((unused)) void *data)
5670 struct cmd_set_burst_tx_retry_result *res = parsed_result;
5672 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
5673 && !strcmp(res->tx, "tx")) {
5674 if (!strcmp(res->delay, "delay"))
5675 burst_tx_delay_time = res->time;
5676 if (!strcmp(res->retry, "retry"))
5677 burst_tx_retry_num = res->retry_num;
5682 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
5683 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
5684 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
5685 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
5687 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
5688 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
5689 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
5690 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
5691 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
5692 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
5693 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
5694 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
5695 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
5696 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
5698 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
5699 .f = cmd_set_burst_tx_retry_parsed,
5700 .help_str = "set burst tx delay <delay_usec> retry <num_retry>",
5702 (void *)&cmd_set_burst_tx_retry_set,
5703 (void *)&cmd_set_burst_tx_retry_burst,
5704 (void *)&cmd_set_burst_tx_retry_tx,
5705 (void *)&cmd_set_burst_tx_retry_delay,
5706 (void *)&cmd_set_burst_tx_retry_time,
5707 (void *)&cmd_set_burst_tx_retry_retry,
5708 (void *)&cmd_set_burst_tx_retry_retry_num,
5713 /* *** SET PROMISC MODE *** */
5714 struct cmd_set_promisc_mode_result {
5715 cmdline_fixed_string_t set;
5716 cmdline_fixed_string_t promisc;
5717 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
5718 uint16_t port_num; /* valid if "allports" argument == 0 */
5719 cmdline_fixed_string_t mode;
5722 static void cmd_set_promisc_mode_parsed(void *parsed_result,
5723 __attribute__((unused)) struct cmdline *cl,
5726 struct cmd_set_promisc_mode_result *res = parsed_result;
5730 if (!strcmp(res->mode, "on"))
5737 RTE_ETH_FOREACH_DEV(i) {
5739 rte_eth_promiscuous_enable(i);
5741 rte_eth_promiscuous_disable(i);
5746 rte_eth_promiscuous_enable(res->port_num);
5748 rte_eth_promiscuous_disable(res->port_num);
5752 cmdline_parse_token_string_t cmd_setpromisc_set =
5753 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
5754 cmdline_parse_token_string_t cmd_setpromisc_promisc =
5755 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
5757 cmdline_parse_token_string_t cmd_setpromisc_portall =
5758 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
5760 cmdline_parse_token_num_t cmd_setpromisc_portnum =
5761 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
5763 cmdline_parse_token_string_t cmd_setpromisc_mode =
5764 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
5767 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
5768 .f = cmd_set_promisc_mode_parsed,
5770 .help_str = "set promisc all on|off: Set promisc mode for all ports",
5772 (void *)&cmd_setpromisc_set,
5773 (void *)&cmd_setpromisc_promisc,
5774 (void *)&cmd_setpromisc_portall,
5775 (void *)&cmd_setpromisc_mode,
5780 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
5781 .f = cmd_set_promisc_mode_parsed,
5783 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
5785 (void *)&cmd_setpromisc_set,
5786 (void *)&cmd_setpromisc_promisc,
5787 (void *)&cmd_setpromisc_portnum,
5788 (void *)&cmd_setpromisc_mode,
5793 /* *** SET ALLMULTI MODE *** */
5794 struct cmd_set_allmulti_mode_result {
5795 cmdline_fixed_string_t set;
5796 cmdline_fixed_string_t allmulti;
5797 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
5798 uint16_t port_num; /* valid if "allports" argument == 0 */
5799 cmdline_fixed_string_t mode;
5802 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
5803 __attribute__((unused)) struct cmdline *cl,
5806 struct cmd_set_allmulti_mode_result *res = parsed_result;
5810 if (!strcmp(res->mode, "on"))
5817 RTE_ETH_FOREACH_DEV(i) {
5819 rte_eth_allmulticast_enable(i);
5821 rte_eth_allmulticast_disable(i);
5826 rte_eth_allmulticast_enable(res->port_num);
5828 rte_eth_allmulticast_disable(res->port_num);
5832 cmdline_parse_token_string_t cmd_setallmulti_set =
5833 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
5834 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
5835 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
5837 cmdline_parse_token_string_t cmd_setallmulti_portall =
5838 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
5840 cmdline_parse_token_num_t cmd_setallmulti_portnum =
5841 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
5843 cmdline_parse_token_string_t cmd_setallmulti_mode =
5844 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
5847 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
5848 .f = cmd_set_allmulti_mode_parsed,
5850 .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
5852 (void *)&cmd_setallmulti_set,
5853 (void *)&cmd_setallmulti_allmulti,
5854 (void *)&cmd_setallmulti_portall,
5855 (void *)&cmd_setallmulti_mode,
5860 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
5861 .f = cmd_set_allmulti_mode_parsed,
5863 .help_str = "set allmulti <port_id> on|off: "
5864 "Set allmulti mode on port_id",
5866 (void *)&cmd_setallmulti_set,
5867 (void *)&cmd_setallmulti_allmulti,
5868 (void *)&cmd_setallmulti_portnum,
5869 (void *)&cmd_setallmulti_mode,
5874 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
5875 struct cmd_link_flow_ctrl_set_result {
5876 cmdline_fixed_string_t set;
5877 cmdline_fixed_string_t flow_ctrl;
5878 cmdline_fixed_string_t rx;
5879 cmdline_fixed_string_t rx_lfc_mode;
5880 cmdline_fixed_string_t tx;
5881 cmdline_fixed_string_t tx_lfc_mode;
5882 cmdline_fixed_string_t mac_ctrl_frame_fwd;
5883 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
5884 cmdline_fixed_string_t autoneg_str;
5885 cmdline_fixed_string_t autoneg;
5886 cmdline_fixed_string_t hw_str;
5887 uint32_t high_water;
5888 cmdline_fixed_string_t lw_str;
5890 cmdline_fixed_string_t pt_str;
5891 uint16_t pause_time;
5892 cmdline_fixed_string_t xon_str;
5897 cmdline_parse_token_string_t cmd_lfc_set_set =
5898 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5900 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
5901 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5902 flow_ctrl, "flow_ctrl");
5903 cmdline_parse_token_string_t cmd_lfc_set_rx =
5904 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5906 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
5907 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5908 rx_lfc_mode, "on#off");
5909 cmdline_parse_token_string_t cmd_lfc_set_tx =
5910 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5912 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
5913 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5914 tx_lfc_mode, "on#off");
5915 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
5916 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5917 hw_str, "high_water");
5918 cmdline_parse_token_num_t cmd_lfc_set_high_water =
5919 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5920 high_water, UINT32);
5921 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
5922 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5923 lw_str, "low_water");
5924 cmdline_parse_token_num_t cmd_lfc_set_low_water =
5925 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5927 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
5928 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5929 pt_str, "pause_time");
5930 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
5931 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5932 pause_time, UINT16);
5933 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
5934 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5935 xon_str, "send_xon");
5936 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
5937 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5939 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
5940 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5941 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
5942 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
5943 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5944 mac_ctrl_frame_fwd_mode, "on#off");
5945 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
5946 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5947 autoneg_str, "autoneg");
5948 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
5949 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5951 cmdline_parse_token_num_t cmd_lfc_set_portid =
5952 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5955 /* forward declaration */
5957 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
5960 cmdline_parse_inst_t cmd_link_flow_control_set = {
5961 .f = cmd_link_flow_ctrl_set_parsed,
5963 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
5964 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
5965 "autoneg on|off <port_id>: Configure the Ethernet flow control",
5967 (void *)&cmd_lfc_set_set,
5968 (void *)&cmd_lfc_set_flow_ctrl,
5969 (void *)&cmd_lfc_set_rx,
5970 (void *)&cmd_lfc_set_rx_mode,
5971 (void *)&cmd_lfc_set_tx,
5972 (void *)&cmd_lfc_set_tx_mode,
5973 (void *)&cmd_lfc_set_high_water,
5974 (void *)&cmd_lfc_set_low_water,
5975 (void *)&cmd_lfc_set_pause_time,
5976 (void *)&cmd_lfc_set_send_xon,
5977 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
5978 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
5979 (void *)&cmd_lfc_set_autoneg_str,
5980 (void *)&cmd_lfc_set_autoneg,
5981 (void *)&cmd_lfc_set_portid,
5986 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
5987 .f = cmd_link_flow_ctrl_set_parsed,
5988 .data = (void *)&cmd_link_flow_control_set_rx,
5989 .help_str = "set flow_ctrl rx on|off <port_id>: "
5990 "Change rx flow control parameter",
5992 (void *)&cmd_lfc_set_set,
5993 (void *)&cmd_lfc_set_flow_ctrl,
5994 (void *)&cmd_lfc_set_rx,
5995 (void *)&cmd_lfc_set_rx_mode,
5996 (void *)&cmd_lfc_set_portid,
6001 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
6002 .f = cmd_link_flow_ctrl_set_parsed,
6003 .data = (void *)&cmd_link_flow_control_set_tx,
6004 .help_str = "set flow_ctrl tx on|off <port_id>: "
6005 "Change tx flow control parameter",
6007 (void *)&cmd_lfc_set_set,
6008 (void *)&cmd_lfc_set_flow_ctrl,
6009 (void *)&cmd_lfc_set_tx,
6010 (void *)&cmd_lfc_set_tx_mode,
6011 (void *)&cmd_lfc_set_portid,
6016 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
6017 .f = cmd_link_flow_ctrl_set_parsed,
6018 .data = (void *)&cmd_link_flow_control_set_hw,
6019 .help_str = "set flow_ctrl high_water <value> <port_id>: "
6020 "Change high water flow control parameter",
6022 (void *)&cmd_lfc_set_set,
6023 (void *)&cmd_lfc_set_flow_ctrl,
6024 (void *)&cmd_lfc_set_high_water_str,
6025 (void *)&cmd_lfc_set_high_water,
6026 (void *)&cmd_lfc_set_portid,
6031 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
6032 .f = cmd_link_flow_ctrl_set_parsed,
6033 .data = (void *)&cmd_link_flow_control_set_lw,
6034 .help_str = "set flow_ctrl low_water <value> <port_id>: "
6035 "Change low water flow control parameter",
6037 (void *)&cmd_lfc_set_set,
6038 (void *)&cmd_lfc_set_flow_ctrl,
6039 (void *)&cmd_lfc_set_low_water_str,
6040 (void *)&cmd_lfc_set_low_water,
6041 (void *)&cmd_lfc_set_portid,
6046 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
6047 .f = cmd_link_flow_ctrl_set_parsed,
6048 .data = (void *)&cmd_link_flow_control_set_pt,
6049 .help_str = "set flow_ctrl pause_time <value> <port_id>: "
6050 "Change pause time flow control parameter",
6052 (void *)&cmd_lfc_set_set,
6053 (void *)&cmd_lfc_set_flow_ctrl,
6054 (void *)&cmd_lfc_set_pause_time_str,
6055 (void *)&cmd_lfc_set_pause_time,
6056 (void *)&cmd_lfc_set_portid,
6061 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
6062 .f = cmd_link_flow_ctrl_set_parsed,
6063 .data = (void *)&cmd_link_flow_control_set_xon,
6064 .help_str = "set flow_ctrl send_xon <value> <port_id>: "
6065 "Change send_xon flow control parameter",
6067 (void *)&cmd_lfc_set_set,
6068 (void *)&cmd_lfc_set_flow_ctrl,
6069 (void *)&cmd_lfc_set_send_xon_str,
6070 (void *)&cmd_lfc_set_send_xon,
6071 (void *)&cmd_lfc_set_portid,
6076 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
6077 .f = cmd_link_flow_ctrl_set_parsed,
6078 .data = (void *)&cmd_link_flow_control_set_macfwd,
6079 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
6080 "Change mac ctrl fwd flow control parameter",
6082 (void *)&cmd_lfc_set_set,
6083 (void *)&cmd_lfc_set_flow_ctrl,
6084 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6085 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6086 (void *)&cmd_lfc_set_portid,
6091 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
6092 .f = cmd_link_flow_ctrl_set_parsed,
6093 .data = (void *)&cmd_link_flow_control_set_autoneg,
6094 .help_str = "set flow_ctrl autoneg on|off <port_id>: "
6095 "Change autoneg flow control parameter",
6097 (void *)&cmd_lfc_set_set,
6098 (void *)&cmd_lfc_set_flow_ctrl,
6099 (void *)&cmd_lfc_set_autoneg_str,
6100 (void *)&cmd_lfc_set_autoneg,
6101 (void *)&cmd_lfc_set_portid,
6107 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
6108 __attribute__((unused)) struct cmdline *cl,
6111 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
6112 cmdline_parse_inst_t *cmd = data;
6113 struct rte_eth_fc_conf fc_conf;
6119 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
6120 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
6121 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
6122 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
6124 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
6125 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
6128 /* Partial command line, retrieve current configuration */
6130 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
6132 printf("cannot get current flow ctrl parameters, return"
6133 "code = %d\n", ret);
6137 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
6138 (fc_conf.mode == RTE_FC_FULL))
6140 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
6141 (fc_conf.mode == RTE_FC_FULL))
6145 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
6146 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
6148 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
6149 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
6151 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
6153 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
6154 fc_conf.high_water = res->high_water;
6156 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
6157 fc_conf.low_water = res->low_water;
6159 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
6160 fc_conf.pause_time = res->pause_time;
6162 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
6163 fc_conf.send_xon = res->send_xon;
6165 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
6166 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
6167 fc_conf.mac_ctrl_frame_fwd = 1;
6169 fc_conf.mac_ctrl_frame_fwd = 0;
6172 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
6173 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
6175 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
6177 printf("bad flow contrl parameter, return code = %d \n", ret);
6180 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
6181 struct cmd_priority_flow_ctrl_set_result {
6182 cmdline_fixed_string_t set;
6183 cmdline_fixed_string_t pfc_ctrl;
6184 cmdline_fixed_string_t rx;
6185 cmdline_fixed_string_t rx_pfc_mode;
6186 cmdline_fixed_string_t tx;
6187 cmdline_fixed_string_t tx_pfc_mode;
6188 uint32_t high_water;
6190 uint16_t pause_time;
6196 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
6197 __attribute__((unused)) struct cmdline *cl,
6198 __attribute__((unused)) void *data)
6200 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
6201 struct rte_eth_pfc_conf pfc_conf;
6202 int rx_fc_enable, tx_fc_enable;
6206 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
6207 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
6208 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
6209 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
6211 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
6212 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
6215 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
6216 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
6217 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
6218 pfc_conf.fc.high_water = res->high_water;
6219 pfc_conf.fc.low_water = res->low_water;
6220 pfc_conf.fc.pause_time = res->pause_time;
6221 pfc_conf.priority = res->priority;
6223 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
6225 printf("bad priority flow contrl parameter, return code = %d \n", ret);
6228 cmdline_parse_token_string_t cmd_pfc_set_set =
6229 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6231 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
6232 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6233 pfc_ctrl, "pfc_ctrl");
6234 cmdline_parse_token_string_t cmd_pfc_set_rx =
6235 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6237 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
6238 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6239 rx_pfc_mode, "on#off");
6240 cmdline_parse_token_string_t cmd_pfc_set_tx =
6241 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6243 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
6244 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6245 tx_pfc_mode, "on#off");
6246 cmdline_parse_token_num_t cmd_pfc_set_high_water =
6247 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6248 high_water, UINT32);
6249 cmdline_parse_token_num_t cmd_pfc_set_low_water =
6250 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6252 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
6253 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6254 pause_time, UINT16);
6255 cmdline_parse_token_num_t cmd_pfc_set_priority =
6256 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6258 cmdline_parse_token_num_t cmd_pfc_set_portid =
6259 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6262 cmdline_parse_inst_t cmd_priority_flow_control_set = {
6263 .f = cmd_priority_flow_ctrl_set_parsed,
6265 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
6266 "<pause_time> <priority> <port_id>: "
6267 "Configure the Ethernet priority flow control",
6269 (void *)&cmd_pfc_set_set,
6270 (void *)&cmd_pfc_set_flow_ctrl,
6271 (void *)&cmd_pfc_set_rx,
6272 (void *)&cmd_pfc_set_rx_mode,
6273 (void *)&cmd_pfc_set_tx,
6274 (void *)&cmd_pfc_set_tx_mode,
6275 (void *)&cmd_pfc_set_high_water,
6276 (void *)&cmd_pfc_set_low_water,
6277 (void *)&cmd_pfc_set_pause_time,
6278 (void *)&cmd_pfc_set_priority,
6279 (void *)&cmd_pfc_set_portid,
6284 /* *** RESET CONFIGURATION *** */
6285 struct cmd_reset_result {
6286 cmdline_fixed_string_t reset;
6287 cmdline_fixed_string_t def;
6290 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
6292 __attribute__((unused)) void *data)
6294 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
6295 set_def_fwd_config();
6298 cmdline_parse_token_string_t cmd_reset_set =
6299 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
6300 cmdline_parse_token_string_t cmd_reset_def =
6301 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
6304 cmdline_parse_inst_t cmd_reset = {
6305 .f = cmd_reset_parsed,
6307 .help_str = "set default: Reset default forwarding configuration",
6309 (void *)&cmd_reset_set,
6310 (void *)&cmd_reset_def,
6315 /* *** START FORWARDING *** */
6316 struct cmd_start_result {
6317 cmdline_fixed_string_t start;
6320 cmdline_parse_token_string_t cmd_start_start =
6321 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
6323 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
6324 __attribute__((unused)) struct cmdline *cl,
6325 __attribute__((unused)) void *data)
6327 start_packet_forwarding(0);
6330 cmdline_parse_inst_t cmd_start = {
6331 .f = cmd_start_parsed,
6333 .help_str = "start: Start packet forwarding",
6335 (void *)&cmd_start_start,
6340 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
6341 struct cmd_start_tx_first_result {
6342 cmdline_fixed_string_t start;
6343 cmdline_fixed_string_t tx_first;
6347 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
6348 __attribute__((unused)) struct cmdline *cl,
6349 __attribute__((unused)) void *data)
6351 start_packet_forwarding(1);
6354 cmdline_parse_token_string_t cmd_start_tx_first_start =
6355 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
6357 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
6358 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
6359 tx_first, "tx_first");
6361 cmdline_parse_inst_t cmd_start_tx_first = {
6362 .f = cmd_start_tx_first_parsed,
6364 .help_str = "start tx_first: Start packet forwarding, "
6365 "after sending 1 burst of packets",
6367 (void *)&cmd_start_tx_first_start,
6368 (void *)&cmd_start_tx_first_tx_first,
6373 /* *** START FORWARDING WITH N TX BURST FIRST *** */
6374 struct cmd_start_tx_first_n_result {
6375 cmdline_fixed_string_t start;
6376 cmdline_fixed_string_t tx_first;
6381 cmd_start_tx_first_n_parsed(void *parsed_result,
6382 __attribute__((unused)) struct cmdline *cl,
6383 __attribute__((unused)) void *data)
6385 struct cmd_start_tx_first_n_result *res = parsed_result;
6387 start_packet_forwarding(res->tx_num);
6390 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
6391 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
6393 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
6394 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
6395 tx_first, "tx_first");
6396 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
6397 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
6400 cmdline_parse_inst_t cmd_start_tx_first_n = {
6401 .f = cmd_start_tx_first_n_parsed,
6403 .help_str = "start tx_first <num>: "
6404 "packet forwarding, after sending <num> bursts of packets",
6406 (void *)&cmd_start_tx_first_n_start,
6407 (void *)&cmd_start_tx_first_n_tx_first,
6408 (void *)&cmd_start_tx_first_n_tx_num,
6413 /* *** SET LINK UP *** */
6414 struct cmd_set_link_up_result {
6415 cmdline_fixed_string_t set;
6416 cmdline_fixed_string_t link_up;
6417 cmdline_fixed_string_t port;
6421 cmdline_parse_token_string_t cmd_set_link_up_set =
6422 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
6423 cmdline_parse_token_string_t cmd_set_link_up_link_up =
6424 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
6426 cmdline_parse_token_string_t cmd_set_link_up_port =
6427 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
6428 cmdline_parse_token_num_t cmd_set_link_up_port_id =
6429 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT16);
6431 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result,
6432 __attribute__((unused)) struct cmdline *cl,
6433 __attribute__((unused)) void *data)
6435 struct cmd_set_link_up_result *res = parsed_result;
6436 dev_set_link_up(res->port_id);
6439 cmdline_parse_inst_t cmd_set_link_up = {
6440 .f = cmd_set_link_up_parsed,
6442 .help_str = "set link-up port <port id>",
6444 (void *)&cmd_set_link_up_set,
6445 (void *)&cmd_set_link_up_link_up,
6446 (void *)&cmd_set_link_up_port,
6447 (void *)&cmd_set_link_up_port_id,
6452 /* *** SET LINK DOWN *** */
6453 struct cmd_set_link_down_result {
6454 cmdline_fixed_string_t set;
6455 cmdline_fixed_string_t link_down;
6456 cmdline_fixed_string_t port;
6460 cmdline_parse_token_string_t cmd_set_link_down_set =
6461 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
6462 cmdline_parse_token_string_t cmd_set_link_down_link_down =
6463 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
6465 cmdline_parse_token_string_t cmd_set_link_down_port =
6466 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
6467 cmdline_parse_token_num_t cmd_set_link_down_port_id =
6468 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT16);
6470 static void cmd_set_link_down_parsed(
6471 __attribute__((unused)) void *parsed_result,
6472 __attribute__((unused)) struct cmdline *cl,
6473 __attribute__((unused)) void *data)
6475 struct cmd_set_link_down_result *res = parsed_result;
6476 dev_set_link_down(res->port_id);
6479 cmdline_parse_inst_t cmd_set_link_down = {
6480 .f = cmd_set_link_down_parsed,
6482 .help_str = "set link-down port <port id>",
6484 (void *)&cmd_set_link_down_set,
6485 (void *)&cmd_set_link_down_link_down,
6486 (void *)&cmd_set_link_down_port,
6487 (void *)&cmd_set_link_down_port_id,
6492 /* *** SHOW CFG *** */
6493 struct cmd_showcfg_result {
6494 cmdline_fixed_string_t show;
6495 cmdline_fixed_string_t cfg;
6496 cmdline_fixed_string_t what;
6499 static void cmd_showcfg_parsed(void *parsed_result,
6500 __attribute__((unused)) struct cmdline *cl,
6501 __attribute__((unused)) void *data)
6503 struct cmd_showcfg_result *res = parsed_result;
6504 if (!strcmp(res->what, "rxtx"))
6505 rxtx_config_display();
6506 else if (!strcmp(res->what, "cores"))
6507 fwd_lcores_config_display();
6508 else if (!strcmp(res->what, "fwd"))
6509 pkt_fwd_config_display(&cur_fwd_config);
6510 else if (!strcmp(res->what, "txpkts"))
6511 show_tx_pkt_segments();
6514 cmdline_parse_token_string_t cmd_showcfg_show =
6515 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
6516 cmdline_parse_token_string_t cmd_showcfg_port =
6517 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
6518 cmdline_parse_token_string_t cmd_showcfg_what =
6519 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
6520 "rxtx#cores#fwd#txpkts");
6522 cmdline_parse_inst_t cmd_showcfg = {
6523 .f = cmd_showcfg_parsed,
6525 .help_str = "show config rxtx|cores|fwd|txpkts",
6527 (void *)&cmd_showcfg_show,
6528 (void *)&cmd_showcfg_port,
6529 (void *)&cmd_showcfg_what,
6534 /* *** SHOW ALL PORT INFO *** */
6535 struct cmd_showportall_result {
6536 cmdline_fixed_string_t show;
6537 cmdline_fixed_string_t port;
6538 cmdline_fixed_string_t what;
6539 cmdline_fixed_string_t all;
6542 static void cmd_showportall_parsed(void *parsed_result,
6543 __attribute__((unused)) struct cmdline *cl,
6544 __attribute__((unused)) void *data)
6548 struct cmd_showportall_result *res = parsed_result;
6549 if (!strcmp(res->show, "clear")) {
6550 if (!strcmp(res->what, "stats"))
6551 RTE_ETH_FOREACH_DEV(i)
6553 else if (!strcmp(res->what, "xstats"))
6554 RTE_ETH_FOREACH_DEV(i)
6555 nic_xstats_clear(i);
6556 } else if (!strcmp(res->what, "info"))
6557 RTE_ETH_FOREACH_DEV(i)
6558 port_infos_display(i);
6559 else if (!strcmp(res->what, "stats"))
6560 RTE_ETH_FOREACH_DEV(i)
6561 nic_stats_display(i);
6562 else if (!strcmp(res->what, "xstats"))
6563 RTE_ETH_FOREACH_DEV(i)
6564 nic_xstats_display(i);
6565 else if (!strcmp(res->what, "fdir"))
6566 RTE_ETH_FOREACH_DEV(i)
6568 else if (!strcmp(res->what, "stat_qmap"))
6569 RTE_ETH_FOREACH_DEV(i)
6570 nic_stats_mapping_display(i);
6571 else if (!strcmp(res->what, "dcb_tc"))
6572 RTE_ETH_FOREACH_DEV(i)
6573 port_dcb_info_display(i);
6574 else if (!strcmp(res->what, "cap"))
6575 RTE_ETH_FOREACH_DEV(i)
6576 port_offload_cap_display(i);
6579 cmdline_parse_token_string_t cmd_showportall_show =
6580 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
6582 cmdline_parse_token_string_t cmd_showportall_port =
6583 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
6584 cmdline_parse_token_string_t cmd_showportall_what =
6585 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
6586 "info#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
6587 cmdline_parse_token_string_t cmd_showportall_all =
6588 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
6589 cmdline_parse_inst_t cmd_showportall = {
6590 .f = cmd_showportall_parsed,
6592 .help_str = "show|clear port "
6593 "info|stats|xstats|fdir|stat_qmap|dcb_tc|cap all",
6595 (void *)&cmd_showportall_show,
6596 (void *)&cmd_showportall_port,
6597 (void *)&cmd_showportall_what,
6598 (void *)&cmd_showportall_all,
6603 /* *** SHOW PORT INFO *** */
6604 struct cmd_showport_result {
6605 cmdline_fixed_string_t show;
6606 cmdline_fixed_string_t port;
6607 cmdline_fixed_string_t what;
6611 static void cmd_showport_parsed(void *parsed_result,
6612 __attribute__((unused)) struct cmdline *cl,
6613 __attribute__((unused)) void *data)
6615 struct cmd_showport_result *res = parsed_result;
6616 if (!strcmp(res->show, "clear")) {
6617 if (!strcmp(res->what, "stats"))
6618 nic_stats_clear(res->portnum);
6619 else if (!strcmp(res->what, "xstats"))
6620 nic_xstats_clear(res->portnum);
6621 } else if (!strcmp(res->what, "info"))
6622 port_infos_display(res->portnum);
6623 else if (!strcmp(res->what, "stats"))
6624 nic_stats_display(res->portnum);
6625 else if (!strcmp(res->what, "xstats"))
6626 nic_xstats_display(res->portnum);
6627 else if (!strcmp(res->what, "fdir"))
6628 fdir_get_infos(res->portnum);
6629 else if (!strcmp(res->what, "stat_qmap"))
6630 nic_stats_mapping_display(res->portnum);
6631 else if (!strcmp(res->what, "dcb_tc"))
6632 port_dcb_info_display(res->portnum);
6633 else if (!strcmp(res->what, "cap"))
6634 port_offload_cap_display(res->portnum);
6637 cmdline_parse_token_string_t cmd_showport_show =
6638 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
6640 cmdline_parse_token_string_t cmd_showport_port =
6641 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
6642 cmdline_parse_token_string_t cmd_showport_what =
6643 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
6644 "info#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
6645 cmdline_parse_token_num_t cmd_showport_portnum =
6646 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT16);
6648 cmdline_parse_inst_t cmd_showport = {
6649 .f = cmd_showport_parsed,
6651 .help_str = "show|clear port "
6652 "info|stats|xstats|fdir|stat_qmap|dcb_tc|cap "
6655 (void *)&cmd_showport_show,
6656 (void *)&cmd_showport_port,
6657 (void *)&cmd_showport_what,
6658 (void *)&cmd_showport_portnum,
6663 /* *** SHOW QUEUE INFO *** */
6664 struct cmd_showqueue_result {
6665 cmdline_fixed_string_t show;
6666 cmdline_fixed_string_t type;
6667 cmdline_fixed_string_t what;
6673 cmd_showqueue_parsed(void *parsed_result,
6674 __attribute__((unused)) struct cmdline *cl,
6675 __attribute__((unused)) void *data)
6677 struct cmd_showqueue_result *res = parsed_result;
6679 if (!strcmp(res->type, "rxq"))
6680 rx_queue_infos_display(res->portnum, res->queuenum);
6681 else if (!strcmp(res->type, "txq"))
6682 tx_queue_infos_display(res->portnum, res->queuenum);
6685 cmdline_parse_token_string_t cmd_showqueue_show =
6686 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
6687 cmdline_parse_token_string_t cmd_showqueue_type =
6688 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
6689 cmdline_parse_token_string_t cmd_showqueue_what =
6690 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
6691 cmdline_parse_token_num_t cmd_showqueue_portnum =
6692 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, UINT16);
6693 cmdline_parse_token_num_t cmd_showqueue_queuenum =
6694 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, UINT16);
6696 cmdline_parse_inst_t cmd_showqueue = {
6697 .f = cmd_showqueue_parsed,
6699 .help_str = "show rxq|txq info <port_id> <queue_id>",
6701 (void *)&cmd_showqueue_show,
6702 (void *)&cmd_showqueue_type,
6703 (void *)&cmd_showqueue_what,
6704 (void *)&cmd_showqueue_portnum,
6705 (void *)&cmd_showqueue_queuenum,
6710 /* *** READ PORT REGISTER *** */
6711 struct cmd_read_reg_result {
6712 cmdline_fixed_string_t read;
6713 cmdline_fixed_string_t reg;
6719 cmd_read_reg_parsed(void *parsed_result,
6720 __attribute__((unused)) struct cmdline *cl,
6721 __attribute__((unused)) void *data)
6723 struct cmd_read_reg_result *res = parsed_result;
6724 port_reg_display(res->port_id, res->reg_off);
6727 cmdline_parse_token_string_t cmd_read_reg_read =
6728 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
6729 cmdline_parse_token_string_t cmd_read_reg_reg =
6730 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
6731 cmdline_parse_token_num_t cmd_read_reg_port_id =
6732 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT16);
6733 cmdline_parse_token_num_t cmd_read_reg_reg_off =
6734 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
6736 cmdline_parse_inst_t cmd_read_reg = {
6737 .f = cmd_read_reg_parsed,
6739 .help_str = "read reg <port_id> <reg_off>",
6741 (void *)&cmd_read_reg_read,
6742 (void *)&cmd_read_reg_reg,
6743 (void *)&cmd_read_reg_port_id,
6744 (void *)&cmd_read_reg_reg_off,
6749 /* *** READ PORT REGISTER BIT FIELD *** */
6750 struct cmd_read_reg_bit_field_result {
6751 cmdline_fixed_string_t read;
6752 cmdline_fixed_string_t regfield;
6760 cmd_read_reg_bit_field_parsed(void *parsed_result,
6761 __attribute__((unused)) struct cmdline *cl,
6762 __attribute__((unused)) void *data)
6764 struct cmd_read_reg_bit_field_result *res = parsed_result;
6765 port_reg_bit_field_display(res->port_id, res->reg_off,
6766 res->bit1_pos, res->bit2_pos);
6769 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
6770 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
6772 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
6773 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
6774 regfield, "regfield");
6775 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
6776 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
6778 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
6779 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
6781 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
6782 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
6784 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
6785 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
6788 cmdline_parse_inst_t cmd_read_reg_bit_field = {
6789 .f = cmd_read_reg_bit_field_parsed,
6791 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
6792 "Read register bit field between bit_x and bit_y included",
6794 (void *)&cmd_read_reg_bit_field_read,
6795 (void *)&cmd_read_reg_bit_field_regfield,
6796 (void *)&cmd_read_reg_bit_field_port_id,
6797 (void *)&cmd_read_reg_bit_field_reg_off,
6798 (void *)&cmd_read_reg_bit_field_bit1_pos,
6799 (void *)&cmd_read_reg_bit_field_bit2_pos,
6804 /* *** READ PORT REGISTER BIT *** */
6805 struct cmd_read_reg_bit_result {
6806 cmdline_fixed_string_t read;
6807 cmdline_fixed_string_t regbit;
6814 cmd_read_reg_bit_parsed(void *parsed_result,
6815 __attribute__((unused)) struct cmdline *cl,
6816 __attribute__((unused)) void *data)
6818 struct cmd_read_reg_bit_result *res = parsed_result;
6819 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
6822 cmdline_parse_token_string_t cmd_read_reg_bit_read =
6823 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
6824 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
6825 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
6827 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
6828 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT16);
6829 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
6830 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
6831 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
6832 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
6834 cmdline_parse_inst_t cmd_read_reg_bit = {
6835 .f = cmd_read_reg_bit_parsed,
6837 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
6839 (void *)&cmd_read_reg_bit_read,
6840 (void *)&cmd_read_reg_bit_regbit,
6841 (void *)&cmd_read_reg_bit_port_id,
6842 (void *)&cmd_read_reg_bit_reg_off,
6843 (void *)&cmd_read_reg_bit_bit_pos,
6848 /* *** WRITE PORT REGISTER *** */
6849 struct cmd_write_reg_result {
6850 cmdline_fixed_string_t write;
6851 cmdline_fixed_string_t reg;
6858 cmd_write_reg_parsed(void *parsed_result,
6859 __attribute__((unused)) struct cmdline *cl,
6860 __attribute__((unused)) void *data)
6862 struct cmd_write_reg_result *res = parsed_result;
6863 port_reg_set(res->port_id, res->reg_off, res->value);
6866 cmdline_parse_token_string_t cmd_write_reg_write =
6867 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
6868 cmdline_parse_token_string_t cmd_write_reg_reg =
6869 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
6870 cmdline_parse_token_num_t cmd_write_reg_port_id =
6871 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT16);
6872 cmdline_parse_token_num_t cmd_write_reg_reg_off =
6873 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
6874 cmdline_parse_token_num_t cmd_write_reg_value =
6875 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
6877 cmdline_parse_inst_t cmd_write_reg = {
6878 .f = cmd_write_reg_parsed,
6880 .help_str = "write reg <port_id> <reg_off> <reg_value>",
6882 (void *)&cmd_write_reg_write,
6883 (void *)&cmd_write_reg_reg,
6884 (void *)&cmd_write_reg_port_id,
6885 (void *)&cmd_write_reg_reg_off,
6886 (void *)&cmd_write_reg_value,
6891 /* *** WRITE PORT REGISTER BIT FIELD *** */
6892 struct cmd_write_reg_bit_field_result {
6893 cmdline_fixed_string_t write;
6894 cmdline_fixed_string_t regfield;
6903 cmd_write_reg_bit_field_parsed(void *parsed_result,
6904 __attribute__((unused)) struct cmdline *cl,
6905 __attribute__((unused)) void *data)
6907 struct cmd_write_reg_bit_field_result *res = parsed_result;
6908 port_reg_bit_field_set(res->port_id, res->reg_off,
6909 res->bit1_pos, res->bit2_pos, res->value);
6912 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
6913 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
6915 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
6916 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
6917 regfield, "regfield");
6918 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
6919 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
6921 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
6922 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
6924 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
6925 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
6927 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
6928 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
6930 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
6931 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
6934 cmdline_parse_inst_t cmd_write_reg_bit_field = {
6935 .f = cmd_write_reg_bit_field_parsed,
6937 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
6939 "Set register bit field between bit_x and bit_y included",
6941 (void *)&cmd_write_reg_bit_field_write,
6942 (void *)&cmd_write_reg_bit_field_regfield,
6943 (void *)&cmd_write_reg_bit_field_port_id,
6944 (void *)&cmd_write_reg_bit_field_reg_off,
6945 (void *)&cmd_write_reg_bit_field_bit1_pos,
6946 (void *)&cmd_write_reg_bit_field_bit2_pos,
6947 (void *)&cmd_write_reg_bit_field_value,
6952 /* *** WRITE PORT REGISTER BIT *** */
6953 struct cmd_write_reg_bit_result {
6954 cmdline_fixed_string_t write;
6955 cmdline_fixed_string_t regbit;
6963 cmd_write_reg_bit_parsed(void *parsed_result,
6964 __attribute__((unused)) struct cmdline *cl,
6965 __attribute__((unused)) void *data)
6967 struct cmd_write_reg_bit_result *res = parsed_result;
6968 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
6971 cmdline_parse_token_string_t cmd_write_reg_bit_write =
6972 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
6974 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
6975 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
6977 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
6978 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT16);
6979 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
6980 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
6981 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
6982 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
6983 cmdline_parse_token_num_t cmd_write_reg_bit_value =
6984 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
6986 cmdline_parse_inst_t cmd_write_reg_bit = {
6987 .f = cmd_write_reg_bit_parsed,
6989 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
6992 (void *)&cmd_write_reg_bit_write,
6993 (void *)&cmd_write_reg_bit_regbit,
6994 (void *)&cmd_write_reg_bit_port_id,
6995 (void *)&cmd_write_reg_bit_reg_off,
6996 (void *)&cmd_write_reg_bit_bit_pos,
6997 (void *)&cmd_write_reg_bit_value,
7002 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
7003 struct cmd_read_rxd_txd_result {
7004 cmdline_fixed_string_t read;
7005 cmdline_fixed_string_t rxd_txd;
7012 cmd_read_rxd_txd_parsed(void *parsed_result,
7013 __attribute__((unused)) struct cmdline *cl,
7014 __attribute__((unused)) void *data)
7016 struct cmd_read_rxd_txd_result *res = parsed_result;
7018 if (!strcmp(res->rxd_txd, "rxd"))
7019 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
7020 else if (!strcmp(res->rxd_txd, "txd"))
7021 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
7024 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
7025 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
7026 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
7027 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
7029 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
7030 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT16);
7031 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
7032 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
7033 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
7034 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
7036 cmdline_parse_inst_t cmd_read_rxd_txd = {
7037 .f = cmd_read_rxd_txd_parsed,
7039 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
7041 (void *)&cmd_read_rxd_txd_read,
7042 (void *)&cmd_read_rxd_txd_rxd_txd,
7043 (void *)&cmd_read_rxd_txd_port_id,
7044 (void *)&cmd_read_rxd_txd_queue_id,
7045 (void *)&cmd_read_rxd_txd_desc_id,
7051 struct cmd_quit_result {
7052 cmdline_fixed_string_t quit;
7055 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
7057 __attribute__((unused)) void *data)
7063 cmdline_parse_token_string_t cmd_quit_quit =
7064 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
7066 cmdline_parse_inst_t cmd_quit = {
7067 .f = cmd_quit_parsed,
7069 .help_str = "quit: Exit application",
7071 (void *)&cmd_quit_quit,
7076 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
7077 struct cmd_mac_addr_result {
7078 cmdline_fixed_string_t mac_addr_cmd;
7079 cmdline_fixed_string_t what;
7081 struct ether_addr address;
7084 static void cmd_mac_addr_parsed(void *parsed_result,
7085 __attribute__((unused)) struct cmdline *cl,
7086 __attribute__((unused)) void *data)
7088 struct cmd_mac_addr_result *res = parsed_result;
7091 if (strcmp(res->what, "add") == 0)
7092 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
7093 else if (strcmp(res->what, "set") == 0)
7094 ret = rte_eth_dev_default_mac_addr_set(res->port_num,
7097 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
7099 /* check the return value and print it if is < 0 */
7101 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
7105 cmdline_parse_token_string_t cmd_mac_addr_cmd =
7106 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
7108 cmdline_parse_token_string_t cmd_mac_addr_what =
7109 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
7111 cmdline_parse_token_num_t cmd_mac_addr_portnum =
7112 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num,
7114 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
7115 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
7117 cmdline_parse_inst_t cmd_mac_addr = {
7118 .f = cmd_mac_addr_parsed,
7120 .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
7121 "Add/Remove/Set MAC address on port_id",
7123 (void *)&cmd_mac_addr_cmd,
7124 (void *)&cmd_mac_addr_what,
7125 (void *)&cmd_mac_addr_portnum,
7126 (void *)&cmd_mac_addr_addr,
7132 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
7133 struct cmd_set_qmap_result {
7134 cmdline_fixed_string_t set;
7135 cmdline_fixed_string_t qmap;
7136 cmdline_fixed_string_t what;
7143 cmd_set_qmap_parsed(void *parsed_result,
7144 __attribute__((unused)) struct cmdline *cl,
7145 __attribute__((unused)) void *data)
7147 struct cmd_set_qmap_result *res = parsed_result;
7148 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
7150 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
7153 cmdline_parse_token_string_t cmd_setqmap_set =
7154 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7156 cmdline_parse_token_string_t cmd_setqmap_qmap =
7157 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7159 cmdline_parse_token_string_t cmd_setqmap_what =
7160 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7162 cmdline_parse_token_num_t cmd_setqmap_portid =
7163 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7165 cmdline_parse_token_num_t cmd_setqmap_queueid =
7166 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7168 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
7169 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7172 cmdline_parse_inst_t cmd_set_qmap = {
7173 .f = cmd_set_qmap_parsed,
7175 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
7176 "Set statistics mapping value on tx|rx queue_id of port_id",
7178 (void *)&cmd_setqmap_set,
7179 (void *)&cmd_setqmap_qmap,
7180 (void *)&cmd_setqmap_what,
7181 (void *)&cmd_setqmap_portid,
7182 (void *)&cmd_setqmap_queueid,
7183 (void *)&cmd_setqmap_mapvalue,
7188 /* *** SET OPTION TO HIDE ZERO VALUES FOR XSTATS DISPLAY *** */
7189 struct cmd_set_xstats_hide_zero_result {
7190 cmdline_fixed_string_t keyword;
7191 cmdline_fixed_string_t name;
7192 cmdline_fixed_string_t on_off;
7196 cmd_set_xstats_hide_zero_parsed(void *parsed_result,
7197 __attribute__((unused)) struct cmdline *cl,
7198 __attribute__((unused)) void *data)
7200 struct cmd_set_xstats_hide_zero_result *res;
7201 uint16_t on_off = 0;
7203 res = parsed_result;
7204 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
7205 set_xstats_hide_zero(on_off);
7208 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_keyword =
7209 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
7211 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_name =
7212 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
7213 name, "xstats-hide-zero");
7214 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_on_off =
7215 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
7218 cmdline_parse_inst_t cmd_set_xstats_hide_zero = {
7219 .f = cmd_set_xstats_hide_zero_parsed,
7221 .help_str = "set xstats-hide-zero on|off",
7223 (void *)&cmd_set_xstats_hide_zero_keyword,
7224 (void *)&cmd_set_xstats_hide_zero_name,
7225 (void *)&cmd_set_xstats_hide_zero_on_off,
7230 /* *** CONFIGURE UNICAST HASH TABLE *** */
7231 struct cmd_set_uc_hash_table {
7232 cmdline_fixed_string_t set;
7233 cmdline_fixed_string_t port;
7235 cmdline_fixed_string_t what;
7236 struct ether_addr address;
7237 cmdline_fixed_string_t mode;
7241 cmd_set_uc_hash_parsed(void *parsed_result,
7242 __attribute__((unused)) struct cmdline *cl,
7243 __attribute__((unused)) void *data)
7246 struct cmd_set_uc_hash_table *res = parsed_result;
7248 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7250 if (strcmp(res->what, "uta") == 0)
7251 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
7252 &res->address,(uint8_t)is_on);
7254 printf("bad unicast hash table parameter, return code = %d \n", ret);
7258 cmdline_parse_token_string_t cmd_set_uc_hash_set =
7259 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7261 cmdline_parse_token_string_t cmd_set_uc_hash_port =
7262 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7264 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
7265 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
7267 cmdline_parse_token_string_t cmd_set_uc_hash_what =
7268 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7270 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
7271 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
7273 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
7274 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7277 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
7278 .f = cmd_set_uc_hash_parsed,
7280 .help_str = "set port <port_id> uta <mac_addr> on|off)",
7282 (void *)&cmd_set_uc_hash_set,
7283 (void *)&cmd_set_uc_hash_port,
7284 (void *)&cmd_set_uc_hash_portid,
7285 (void *)&cmd_set_uc_hash_what,
7286 (void *)&cmd_set_uc_hash_mac,
7287 (void *)&cmd_set_uc_hash_mode,
7292 struct cmd_set_uc_all_hash_table {
7293 cmdline_fixed_string_t set;
7294 cmdline_fixed_string_t port;
7296 cmdline_fixed_string_t what;
7297 cmdline_fixed_string_t value;
7298 cmdline_fixed_string_t mode;
7302 cmd_set_uc_all_hash_parsed(void *parsed_result,
7303 __attribute__((unused)) struct cmdline *cl,
7304 __attribute__((unused)) void *data)
7307 struct cmd_set_uc_all_hash_table *res = parsed_result;
7309 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7311 if ((strcmp(res->what, "uta") == 0) &&
7312 (strcmp(res->value, "all") == 0))
7313 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
7315 printf("bad unicast hash table parameter,"
7316 "return code = %d \n", ret);
7319 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
7320 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7322 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
7323 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7325 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
7326 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
7328 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
7329 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7331 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
7332 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7334 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
7335 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7338 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
7339 .f = cmd_set_uc_all_hash_parsed,
7341 .help_str = "set port <port_id> uta all on|off",
7343 (void *)&cmd_set_uc_all_hash_set,
7344 (void *)&cmd_set_uc_all_hash_port,
7345 (void *)&cmd_set_uc_all_hash_portid,
7346 (void *)&cmd_set_uc_all_hash_what,
7347 (void *)&cmd_set_uc_all_hash_value,
7348 (void *)&cmd_set_uc_all_hash_mode,
7353 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
7354 struct cmd_set_vf_macvlan_filter {
7355 cmdline_fixed_string_t set;
7356 cmdline_fixed_string_t port;
7358 cmdline_fixed_string_t vf;
7360 struct ether_addr address;
7361 cmdline_fixed_string_t filter_type;
7362 cmdline_fixed_string_t mode;
7366 cmd_set_vf_macvlan_parsed(void *parsed_result,
7367 __attribute__((unused)) struct cmdline *cl,
7368 __attribute__((unused)) void *data)
7371 struct cmd_set_vf_macvlan_filter *res = parsed_result;
7372 struct rte_eth_mac_filter filter;
7374 memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
7376 rte_memcpy(&filter.mac_addr, &res->address, ETHER_ADDR_LEN);
7378 /* set VF MAC filter */
7382 filter.dst_id = res->vf_id;
7384 if (!strcmp(res->filter_type, "exact-mac"))
7385 filter.filter_type = RTE_MAC_PERFECT_MATCH;
7386 else if (!strcmp(res->filter_type, "exact-mac-vlan"))
7387 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
7388 else if (!strcmp(res->filter_type, "hashmac"))
7389 filter.filter_type = RTE_MAC_HASH_MATCH;
7390 else if (!strcmp(res->filter_type, "hashmac-vlan"))
7391 filter.filter_type = RTE_MACVLAN_HASH_MATCH;
7393 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7396 ret = rte_eth_dev_filter_ctrl(res->port_id,
7397 RTE_ETH_FILTER_MACVLAN,
7401 ret = rte_eth_dev_filter_ctrl(res->port_id,
7402 RTE_ETH_FILTER_MACVLAN,
7403 RTE_ETH_FILTER_DELETE,
7407 printf("bad set MAC hash parameter, return code = %d\n", ret);
7411 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
7412 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7414 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
7415 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7417 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
7418 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7420 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
7421 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7423 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
7424 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7426 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
7427 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7429 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
7430 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7431 filter_type, "exact-mac#exact-mac-vlan"
7432 "#hashmac#hashmac-vlan");
7433 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
7434 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7437 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
7438 .f = cmd_set_vf_macvlan_parsed,
7440 .help_str = "set port <port_id> vf <vf_id> <mac_addr> "
7441 "exact-mac|exact-mac-vlan|hashmac|hashmac-vlan on|off: "
7442 "Exact match rule: exact match of MAC or MAC and VLAN; "
7443 "hash match rule: hash match of MAC and exact match of VLAN",
7445 (void *)&cmd_set_vf_macvlan_set,
7446 (void *)&cmd_set_vf_macvlan_port,
7447 (void *)&cmd_set_vf_macvlan_portid,
7448 (void *)&cmd_set_vf_macvlan_vf,
7449 (void *)&cmd_set_vf_macvlan_vf_id,
7450 (void *)&cmd_set_vf_macvlan_mac,
7451 (void *)&cmd_set_vf_macvlan_filter_type,
7452 (void *)&cmd_set_vf_macvlan_mode,
7457 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
7458 struct cmd_set_vf_traffic {
7459 cmdline_fixed_string_t set;
7460 cmdline_fixed_string_t port;
7462 cmdline_fixed_string_t vf;
7464 cmdline_fixed_string_t what;
7465 cmdline_fixed_string_t mode;
7469 cmd_set_vf_traffic_parsed(void *parsed_result,
7470 __attribute__((unused)) struct cmdline *cl,
7471 __attribute__((unused)) void *data)
7473 struct cmd_set_vf_traffic *res = parsed_result;
7474 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
7475 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7477 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
7480 cmdline_parse_token_string_t cmd_setvf_traffic_set =
7481 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7483 cmdline_parse_token_string_t cmd_setvf_traffic_port =
7484 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7486 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
7487 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
7489 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
7490 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7492 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
7493 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
7495 cmdline_parse_token_string_t cmd_setvf_traffic_what =
7496 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7498 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
7499 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7502 cmdline_parse_inst_t cmd_set_vf_traffic = {
7503 .f = cmd_set_vf_traffic_parsed,
7505 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
7507 (void *)&cmd_setvf_traffic_set,
7508 (void *)&cmd_setvf_traffic_port,
7509 (void *)&cmd_setvf_traffic_portid,
7510 (void *)&cmd_setvf_traffic_vf,
7511 (void *)&cmd_setvf_traffic_vfid,
7512 (void *)&cmd_setvf_traffic_what,
7513 (void *)&cmd_setvf_traffic_mode,
7518 /* *** CONFIGURE VF RECEIVE MODE *** */
7519 struct cmd_set_vf_rxmode {
7520 cmdline_fixed_string_t set;
7521 cmdline_fixed_string_t port;
7523 cmdline_fixed_string_t vf;
7525 cmdline_fixed_string_t what;
7526 cmdline_fixed_string_t mode;
7527 cmdline_fixed_string_t on;
7531 cmd_set_vf_rxmode_parsed(void *parsed_result,
7532 __attribute__((unused)) struct cmdline *cl,
7533 __attribute__((unused)) void *data)
7536 uint16_t rx_mode = 0;
7537 struct cmd_set_vf_rxmode *res = parsed_result;
7539 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
7540 if (!strcmp(res->what,"rxmode")) {
7541 if (!strcmp(res->mode, "AUPE"))
7542 rx_mode |= ETH_VMDQ_ACCEPT_UNTAG;
7543 else if (!strcmp(res->mode, "ROPE"))
7544 rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC;
7545 else if (!strcmp(res->mode, "BAM"))
7546 rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST;
7547 else if (!strncmp(res->mode, "MPE",3))
7548 rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST;
7551 RTE_SET_USED(is_on);
7553 #ifdef RTE_LIBRTE_IXGBE_PMD
7554 if (ret == -ENOTSUP)
7555 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id,
7556 rx_mode, (uint8_t)is_on);
7558 #ifdef RTE_LIBRTE_BNXT_PMD
7559 if (ret == -ENOTSUP)
7560 ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id,
7561 rx_mode, (uint8_t)is_on);
7564 printf("bad VF receive mode parameter, return code = %d \n",
7568 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
7569 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7571 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
7572 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7574 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
7575 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
7577 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
7578 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7580 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
7581 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
7583 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
7584 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7586 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
7587 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7588 mode, "AUPE#ROPE#BAM#MPE");
7589 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
7590 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7593 cmdline_parse_inst_t cmd_set_vf_rxmode = {
7594 .f = cmd_set_vf_rxmode_parsed,
7596 .help_str = "set port <port_id> vf <vf_id> rxmode "
7597 "AUPE|ROPE|BAM|MPE on|off",
7599 (void *)&cmd_set_vf_rxmode_set,
7600 (void *)&cmd_set_vf_rxmode_port,
7601 (void *)&cmd_set_vf_rxmode_portid,
7602 (void *)&cmd_set_vf_rxmode_vf,
7603 (void *)&cmd_set_vf_rxmode_vfid,
7604 (void *)&cmd_set_vf_rxmode_what,
7605 (void *)&cmd_set_vf_rxmode_mode,
7606 (void *)&cmd_set_vf_rxmode_on,
7611 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
7612 struct cmd_vf_mac_addr_result {
7613 cmdline_fixed_string_t mac_addr_cmd;
7614 cmdline_fixed_string_t what;
7615 cmdline_fixed_string_t port;
7617 cmdline_fixed_string_t vf;
7619 struct ether_addr address;
7622 static void cmd_vf_mac_addr_parsed(void *parsed_result,
7623 __attribute__((unused)) struct cmdline *cl,
7624 __attribute__((unused)) void *data)
7626 struct cmd_vf_mac_addr_result *res = parsed_result;
7629 if (strcmp(res->what, "add") != 0)
7632 #ifdef RTE_LIBRTE_I40E_PMD
7633 if (ret == -ENOTSUP)
7634 ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num,
7637 #ifdef RTE_LIBRTE_BNXT_PMD
7638 if (ret == -ENOTSUP)
7639 ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address,
7644 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
7648 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
7649 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7650 mac_addr_cmd,"mac_addr");
7651 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
7652 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7654 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
7655 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7657 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
7658 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
7660 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
7661 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7663 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
7664 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
7666 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
7667 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
7670 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
7671 .f = cmd_vf_mac_addr_parsed,
7673 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
7674 "Add MAC address filtering for a VF on port_id",
7676 (void *)&cmd_vf_mac_addr_cmd,
7677 (void *)&cmd_vf_mac_addr_what,
7678 (void *)&cmd_vf_mac_addr_port,
7679 (void *)&cmd_vf_mac_addr_portnum,
7680 (void *)&cmd_vf_mac_addr_vf,
7681 (void *)&cmd_vf_mac_addr_vfnum,
7682 (void *)&cmd_vf_mac_addr_addr,
7687 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
7688 struct cmd_vf_rx_vlan_filter {
7689 cmdline_fixed_string_t rx_vlan;
7690 cmdline_fixed_string_t what;
7692 cmdline_fixed_string_t port;
7694 cmdline_fixed_string_t vf;
7699 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
7700 __attribute__((unused)) struct cmdline *cl,
7701 __attribute__((unused)) void *data)
7703 struct cmd_vf_rx_vlan_filter *res = parsed_result;
7706 __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
7708 #ifdef RTE_LIBRTE_IXGBE_PMD
7709 if (ret == -ENOTSUP)
7710 ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
7711 res->vlan_id, res->vf_mask, is_add);
7713 #ifdef RTE_LIBRTE_I40E_PMD
7714 if (ret == -ENOTSUP)
7715 ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
7716 res->vlan_id, res->vf_mask, is_add);
7718 #ifdef RTE_LIBRTE_BNXT_PMD
7719 if (ret == -ENOTSUP)
7720 ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id,
7721 res->vlan_id, res->vf_mask, is_add);
7728 printf("invalid vlan_id %d or vf_mask %"PRIu64"\n",
7729 res->vlan_id, res->vf_mask);
7732 printf("invalid port_id %d\n", res->port_id);
7735 printf("function not implemented or supported\n");
7738 printf("programming error: (%s)\n", strerror(-ret));
7742 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
7743 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7744 rx_vlan, "rx_vlan");
7745 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
7746 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7748 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
7749 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7751 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
7752 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7754 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
7755 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7757 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
7758 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7760 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
7761 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7764 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
7765 .f = cmd_vf_rx_vlan_filter_parsed,
7767 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
7768 "(vf_mask = hexadecimal VF mask)",
7770 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
7771 (void *)&cmd_vf_rx_vlan_filter_what,
7772 (void *)&cmd_vf_rx_vlan_filter_vlanid,
7773 (void *)&cmd_vf_rx_vlan_filter_port,
7774 (void *)&cmd_vf_rx_vlan_filter_portid,
7775 (void *)&cmd_vf_rx_vlan_filter_vf,
7776 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
7781 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
7782 struct cmd_queue_rate_limit_result {
7783 cmdline_fixed_string_t set;
7784 cmdline_fixed_string_t port;
7786 cmdline_fixed_string_t queue;
7788 cmdline_fixed_string_t rate;
7792 static void cmd_queue_rate_limit_parsed(void *parsed_result,
7793 __attribute__((unused)) struct cmdline *cl,
7794 __attribute__((unused)) void *data)
7796 struct cmd_queue_rate_limit_result *res = parsed_result;
7799 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
7800 && (strcmp(res->queue, "queue") == 0)
7801 && (strcmp(res->rate, "rate") == 0))
7802 ret = set_queue_rate_limit(res->port_num, res->queue_num,
7805 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
7809 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
7810 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7812 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
7813 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7815 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
7816 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
7818 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
7819 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7821 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
7822 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
7824 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
7825 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7827 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
7828 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
7831 cmdline_parse_inst_t cmd_queue_rate_limit = {
7832 .f = cmd_queue_rate_limit_parsed,
7834 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
7835 "Set rate limit for a queue on port_id",
7837 (void *)&cmd_queue_rate_limit_set,
7838 (void *)&cmd_queue_rate_limit_port,
7839 (void *)&cmd_queue_rate_limit_portnum,
7840 (void *)&cmd_queue_rate_limit_queue,
7841 (void *)&cmd_queue_rate_limit_queuenum,
7842 (void *)&cmd_queue_rate_limit_rate,
7843 (void *)&cmd_queue_rate_limit_ratenum,
7848 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
7849 struct cmd_vf_rate_limit_result {
7850 cmdline_fixed_string_t set;
7851 cmdline_fixed_string_t port;
7853 cmdline_fixed_string_t vf;
7855 cmdline_fixed_string_t rate;
7857 cmdline_fixed_string_t q_msk;
7861 static void cmd_vf_rate_limit_parsed(void *parsed_result,
7862 __attribute__((unused)) struct cmdline *cl,
7863 __attribute__((unused)) void *data)
7865 struct cmd_vf_rate_limit_result *res = parsed_result;
7868 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
7869 && (strcmp(res->vf, "vf") == 0)
7870 && (strcmp(res->rate, "rate") == 0)
7871 && (strcmp(res->q_msk, "queue_mask") == 0))
7872 ret = set_vf_rate_limit(res->port_num, res->vf_num,
7873 res->rate_num, res->q_msk_val);
7875 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
7879 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
7880 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7882 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
7883 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7885 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
7886 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7888 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
7889 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7891 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
7892 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7894 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
7895 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7897 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
7898 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7900 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
7901 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7902 q_msk, "queue_mask");
7903 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
7904 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7907 cmdline_parse_inst_t cmd_vf_rate_limit = {
7908 .f = cmd_vf_rate_limit_parsed,
7910 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
7911 "queue_mask <queue_mask_value>: "
7912 "Set rate limit for queues of VF on port_id",
7914 (void *)&cmd_vf_rate_limit_set,
7915 (void *)&cmd_vf_rate_limit_port,
7916 (void *)&cmd_vf_rate_limit_portnum,
7917 (void *)&cmd_vf_rate_limit_vf,
7918 (void *)&cmd_vf_rate_limit_vfnum,
7919 (void *)&cmd_vf_rate_limit_rate,
7920 (void *)&cmd_vf_rate_limit_ratenum,
7921 (void *)&cmd_vf_rate_limit_q_msk,
7922 (void *)&cmd_vf_rate_limit_q_msk_val,
7927 /* *** ADD TUNNEL FILTER OF A PORT *** */
7928 struct cmd_tunnel_filter_result {
7929 cmdline_fixed_string_t cmd;
7930 cmdline_fixed_string_t what;
7932 struct ether_addr outer_mac;
7933 struct ether_addr inner_mac;
7934 cmdline_ipaddr_t ip_value;
7935 uint16_t inner_vlan;
7936 cmdline_fixed_string_t tunnel_type;
7937 cmdline_fixed_string_t filter_type;
7943 cmd_tunnel_filter_parsed(void *parsed_result,
7944 __attribute__((unused)) struct cmdline *cl,
7945 __attribute__((unused)) void *data)
7947 struct cmd_tunnel_filter_result *res = parsed_result;
7948 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
7951 memset(&tunnel_filter_conf, 0, sizeof(tunnel_filter_conf));
7953 ether_addr_copy(&res->outer_mac, &tunnel_filter_conf.outer_mac);
7954 ether_addr_copy(&res->inner_mac, &tunnel_filter_conf.inner_mac);
7955 tunnel_filter_conf.inner_vlan = res->inner_vlan;
7957 if (res->ip_value.family == AF_INET) {
7958 tunnel_filter_conf.ip_addr.ipv4_addr =
7959 res->ip_value.addr.ipv4.s_addr;
7960 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
7962 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
7963 &(res->ip_value.addr.ipv6),
7964 sizeof(struct in6_addr));
7965 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
7968 if (!strcmp(res->filter_type, "imac-ivlan"))
7969 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
7970 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
7971 tunnel_filter_conf.filter_type =
7972 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
7973 else if (!strcmp(res->filter_type, "imac-tenid"))
7974 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
7975 else if (!strcmp(res->filter_type, "imac"))
7976 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
7977 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
7978 tunnel_filter_conf.filter_type =
7979 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
7980 else if (!strcmp(res->filter_type, "oip"))
7981 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_OIP;
7982 else if (!strcmp(res->filter_type, "iip"))
7983 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IIP;
7985 printf("The filter type is not supported");
7989 if (!strcmp(res->tunnel_type, "vxlan"))
7990 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
7991 else if (!strcmp(res->tunnel_type, "nvgre"))
7992 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE;
7993 else if (!strcmp(res->tunnel_type, "ipingre"))
7994 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_IP_IN_GRE;
7996 printf("The tunnel type %s not supported.\n", res->tunnel_type);
8000 tunnel_filter_conf.tenant_id = res->tenant_id;
8001 tunnel_filter_conf.queue_id = res->queue_num;
8002 if (!strcmp(res->what, "add"))
8003 ret = rte_eth_dev_filter_ctrl(res->port_id,
8004 RTE_ETH_FILTER_TUNNEL,
8006 &tunnel_filter_conf);
8008 ret = rte_eth_dev_filter_ctrl(res->port_id,
8009 RTE_ETH_FILTER_TUNNEL,
8010 RTE_ETH_FILTER_DELETE,
8011 &tunnel_filter_conf);
8013 printf("cmd_tunnel_filter_parsed error: (%s)\n",
8017 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
8018 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8019 cmd, "tunnel_filter");
8020 cmdline_parse_token_string_t cmd_tunnel_filter_what =
8021 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8023 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
8024 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8026 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
8027 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8029 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
8030 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8032 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
8033 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8034 inner_vlan, UINT16);
8035 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
8036 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8038 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
8039 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8040 tunnel_type, "vxlan#nvgre#ipingre");
8042 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
8043 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8044 filter_type, "oip#iip#imac-ivlan#imac-ivlan-tenid#imac-tenid#"
8045 "imac#omac-imac-tenid");
8046 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
8047 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8049 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
8050 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8053 cmdline_parse_inst_t cmd_tunnel_filter = {
8054 .f = cmd_tunnel_filter_parsed,
8056 .help_str = "tunnel_filter add|rm <port_id> <outer_mac> <inner_mac> "
8057 "<ip> <inner_vlan> vxlan|nvgre|ipingre oip|iip|imac-ivlan|"
8058 "imac-ivlan-tenid|imac-tenid|imac|omac-imac-tenid <tenant_id> "
8059 "<queue_id>: Add/Rm tunnel filter of a port",
8061 (void *)&cmd_tunnel_filter_cmd,
8062 (void *)&cmd_tunnel_filter_what,
8063 (void *)&cmd_tunnel_filter_port_id,
8064 (void *)&cmd_tunnel_filter_outer_mac,
8065 (void *)&cmd_tunnel_filter_inner_mac,
8066 (void *)&cmd_tunnel_filter_ip_value,
8067 (void *)&cmd_tunnel_filter_innner_vlan,
8068 (void *)&cmd_tunnel_filter_tunnel_type,
8069 (void *)&cmd_tunnel_filter_filter_type,
8070 (void *)&cmd_tunnel_filter_tenant_id,
8071 (void *)&cmd_tunnel_filter_queue_num,
8076 /* *** CONFIGURE TUNNEL UDP PORT *** */
8077 struct cmd_tunnel_udp_config {
8078 cmdline_fixed_string_t cmd;
8079 cmdline_fixed_string_t what;
8085 cmd_tunnel_udp_config_parsed(void *parsed_result,
8086 __attribute__((unused)) struct cmdline *cl,
8087 __attribute__((unused)) void *data)
8089 struct cmd_tunnel_udp_config *res = parsed_result;
8090 struct rte_eth_udp_tunnel tunnel_udp;
8093 tunnel_udp.udp_port = res->udp_port;
8095 if (!strcmp(res->cmd, "rx_vxlan_port"))
8096 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
8098 if (!strcmp(res->what, "add"))
8099 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
8102 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
8106 printf("udp tunneling add error: (%s)\n", strerror(-ret));
8109 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
8110 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
8111 cmd, "rx_vxlan_port");
8112 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
8113 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
8115 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
8116 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
8118 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
8119 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
8122 cmdline_parse_inst_t cmd_tunnel_udp_config = {
8123 .f = cmd_tunnel_udp_config_parsed,
8125 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
8126 "Add/Remove a tunneling UDP port filter",
8128 (void *)&cmd_tunnel_udp_config_cmd,
8129 (void *)&cmd_tunnel_udp_config_what,
8130 (void *)&cmd_tunnel_udp_config_udp_port,
8131 (void *)&cmd_tunnel_udp_config_port_id,
8136 /* *** GLOBAL CONFIG *** */
8137 struct cmd_global_config_result {
8138 cmdline_fixed_string_t cmd;
8140 cmdline_fixed_string_t cfg_type;
8145 cmd_global_config_parsed(void *parsed_result,
8146 __attribute__((unused)) struct cmdline *cl,
8147 __attribute__((unused)) void *data)
8149 struct cmd_global_config_result *res = parsed_result;
8150 struct rte_eth_global_cfg conf;
8153 memset(&conf, 0, sizeof(conf));
8154 conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN;
8155 conf.cfg.gre_key_len = res->len;
8156 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE,
8157 RTE_ETH_FILTER_SET, &conf);
8159 printf("Global config error\n");
8162 cmdline_parse_token_string_t cmd_global_config_cmd =
8163 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd,
8165 cmdline_parse_token_num_t cmd_global_config_port_id =
8166 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id,
8168 cmdline_parse_token_string_t cmd_global_config_type =
8169 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result,
8170 cfg_type, "gre-key-len");
8171 cmdline_parse_token_num_t cmd_global_config_gre_key_len =
8172 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result,
8175 cmdline_parse_inst_t cmd_global_config = {
8176 .f = cmd_global_config_parsed,
8177 .data = (void *)NULL,
8178 .help_str = "global_config <port_id> gre-key-len <key_len>",
8180 (void *)&cmd_global_config_cmd,
8181 (void *)&cmd_global_config_port_id,
8182 (void *)&cmd_global_config_type,
8183 (void *)&cmd_global_config_gre_key_len,
8188 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
8189 struct cmd_set_mirror_mask_result {
8190 cmdline_fixed_string_t set;
8191 cmdline_fixed_string_t port;
8193 cmdline_fixed_string_t mirror;
8195 cmdline_fixed_string_t what;
8196 cmdline_fixed_string_t value;
8197 cmdline_fixed_string_t dstpool;
8199 cmdline_fixed_string_t on;
8202 cmdline_parse_token_string_t cmd_mirror_mask_set =
8203 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8205 cmdline_parse_token_string_t cmd_mirror_mask_port =
8206 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8208 cmdline_parse_token_num_t cmd_mirror_mask_portid =
8209 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
8211 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
8212 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8213 mirror, "mirror-rule");
8214 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
8215 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
8217 cmdline_parse_token_string_t cmd_mirror_mask_what =
8218 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8219 what, "pool-mirror-up#pool-mirror-down"
8221 cmdline_parse_token_string_t cmd_mirror_mask_value =
8222 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8224 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
8225 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8226 dstpool, "dst-pool");
8227 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
8228 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
8230 cmdline_parse_token_string_t cmd_mirror_mask_on =
8231 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8235 cmd_set_mirror_mask_parsed(void *parsed_result,
8236 __attribute__((unused)) struct cmdline *cl,
8237 __attribute__((unused)) void *data)
8240 struct cmd_set_mirror_mask_result *res = parsed_result;
8241 struct rte_eth_mirror_conf mr_conf;
8243 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
8245 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
8247 mr_conf.dst_pool = res->dstpool_id;
8249 if (!strcmp(res->what, "pool-mirror-up")) {
8250 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
8251 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
8252 } else if (!strcmp(res->what, "pool-mirror-down")) {
8253 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
8254 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
8255 } else if (!strcmp(res->what, "vlan-mirror")) {
8256 mr_conf.rule_type = ETH_MIRROR_VLAN;
8257 nb_item = parse_item_list(res->value, "vlan",
8258 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
8262 for (i = 0; i < nb_item; i++) {
8263 if (vlan_list[i] > ETHER_MAX_VLAN_ID) {
8264 printf("Invalid vlan_id: must be < 4096\n");
8268 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
8269 mr_conf.vlan.vlan_mask |= 1ULL << i;
8273 if (!strcmp(res->on, "on"))
8274 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8277 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8280 printf("mirror rule add error: (%s)\n", strerror(-ret));
8283 cmdline_parse_inst_t cmd_set_mirror_mask = {
8284 .f = cmd_set_mirror_mask_parsed,
8286 .help_str = "set port <port_id> mirror-rule <rule_id> "
8287 "pool-mirror-up|pool-mirror-down|vlan-mirror "
8288 "<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off",
8290 (void *)&cmd_mirror_mask_set,
8291 (void *)&cmd_mirror_mask_port,
8292 (void *)&cmd_mirror_mask_portid,
8293 (void *)&cmd_mirror_mask_mirror,
8294 (void *)&cmd_mirror_mask_ruleid,
8295 (void *)&cmd_mirror_mask_what,
8296 (void *)&cmd_mirror_mask_value,
8297 (void *)&cmd_mirror_mask_dstpool,
8298 (void *)&cmd_mirror_mask_poolid,
8299 (void *)&cmd_mirror_mask_on,
8304 /* *** CONFIGURE VM MIRROR UPLINK/DOWNLINK RULE *** */
8305 struct cmd_set_mirror_link_result {
8306 cmdline_fixed_string_t set;
8307 cmdline_fixed_string_t port;
8309 cmdline_fixed_string_t mirror;
8311 cmdline_fixed_string_t what;
8312 cmdline_fixed_string_t dstpool;
8314 cmdline_fixed_string_t on;
8317 cmdline_parse_token_string_t cmd_mirror_link_set =
8318 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8320 cmdline_parse_token_string_t cmd_mirror_link_port =
8321 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8323 cmdline_parse_token_num_t cmd_mirror_link_portid =
8324 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
8326 cmdline_parse_token_string_t cmd_mirror_link_mirror =
8327 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8328 mirror, "mirror-rule");
8329 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
8330 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
8332 cmdline_parse_token_string_t cmd_mirror_link_what =
8333 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8334 what, "uplink-mirror#downlink-mirror");
8335 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
8336 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8337 dstpool, "dst-pool");
8338 cmdline_parse_token_num_t cmd_mirror_link_poolid =
8339 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
8341 cmdline_parse_token_string_t cmd_mirror_link_on =
8342 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8346 cmd_set_mirror_link_parsed(void *parsed_result,
8347 __attribute__((unused)) struct cmdline *cl,
8348 __attribute__((unused)) void *data)
8351 struct cmd_set_mirror_link_result *res = parsed_result;
8352 struct rte_eth_mirror_conf mr_conf;
8354 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
8355 if (!strcmp(res->what, "uplink-mirror"))
8356 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
8358 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
8360 mr_conf.dst_pool = res->dstpool_id;
8362 if (!strcmp(res->on, "on"))
8363 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8366 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8369 /* check the return value and print it if is < 0 */
8371 printf("mirror rule add error: (%s)\n", strerror(-ret));
8375 cmdline_parse_inst_t cmd_set_mirror_link = {
8376 .f = cmd_set_mirror_link_parsed,
8378 .help_str = "set port <port_id> mirror-rule <rule_id> "
8379 "uplink-mirror|downlink-mirror dst-pool <pool_id> on|off",
8381 (void *)&cmd_mirror_link_set,
8382 (void *)&cmd_mirror_link_port,
8383 (void *)&cmd_mirror_link_portid,
8384 (void *)&cmd_mirror_link_mirror,
8385 (void *)&cmd_mirror_link_ruleid,
8386 (void *)&cmd_mirror_link_what,
8387 (void *)&cmd_mirror_link_dstpool,
8388 (void *)&cmd_mirror_link_poolid,
8389 (void *)&cmd_mirror_link_on,
8394 /* *** RESET VM MIRROR RULE *** */
8395 struct cmd_rm_mirror_rule_result {
8396 cmdline_fixed_string_t reset;
8397 cmdline_fixed_string_t port;
8399 cmdline_fixed_string_t mirror;
8403 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
8404 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
8406 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
8407 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
8409 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
8410 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
8412 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
8413 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
8414 mirror, "mirror-rule");
8415 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
8416 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
8420 cmd_reset_mirror_rule_parsed(void *parsed_result,
8421 __attribute__((unused)) struct cmdline *cl,
8422 __attribute__((unused)) void *data)
8425 struct cmd_set_mirror_link_result *res = parsed_result;
8427 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
8429 printf("mirror rule remove error: (%s)\n", strerror(-ret));
8432 cmdline_parse_inst_t cmd_reset_mirror_rule = {
8433 .f = cmd_reset_mirror_rule_parsed,
8435 .help_str = "reset port <port_id> mirror-rule <rule_id>",
8437 (void *)&cmd_rm_mirror_rule_reset,
8438 (void *)&cmd_rm_mirror_rule_port,
8439 (void *)&cmd_rm_mirror_rule_portid,
8440 (void *)&cmd_rm_mirror_rule_mirror,
8441 (void *)&cmd_rm_mirror_rule_ruleid,
8446 /* ******************************************************************************** */
8448 struct cmd_dump_result {
8449 cmdline_fixed_string_t dump;
8453 dump_struct_sizes(void)
8455 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
8456 DUMP_SIZE(struct rte_mbuf);
8457 DUMP_SIZE(struct rte_mempool);
8458 DUMP_SIZE(struct rte_ring);
8462 static void cmd_dump_parsed(void *parsed_result,
8463 __attribute__((unused)) struct cmdline *cl,
8464 __attribute__((unused)) void *data)
8466 struct cmd_dump_result *res = parsed_result;
8468 if (!strcmp(res->dump, "dump_physmem"))
8469 rte_dump_physmem_layout(stdout);
8470 else if (!strcmp(res->dump, "dump_memzone"))
8471 rte_memzone_dump(stdout);
8472 else if (!strcmp(res->dump, "dump_struct_sizes"))
8473 dump_struct_sizes();
8474 else if (!strcmp(res->dump, "dump_ring"))
8475 rte_ring_list_dump(stdout);
8476 else if (!strcmp(res->dump, "dump_mempool"))
8477 rte_mempool_list_dump(stdout);
8478 else if (!strcmp(res->dump, "dump_devargs"))
8479 rte_eal_devargs_dump(stdout);
8480 else if (!strcmp(res->dump, "dump_log_types"))
8481 rte_log_dump(stdout);
8484 cmdline_parse_token_string_t cmd_dump_dump =
8485 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
8488 "dump_struct_sizes#"
8494 cmdline_parse_inst_t cmd_dump = {
8495 .f = cmd_dump_parsed, /* function to call */
8496 .data = NULL, /* 2nd arg of func */
8497 .help_str = "Dump status",
8498 .tokens = { /* token list, NULL terminated */
8499 (void *)&cmd_dump_dump,
8504 /* ******************************************************************************** */
8506 struct cmd_dump_one_result {
8507 cmdline_fixed_string_t dump;
8508 cmdline_fixed_string_t name;
8511 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
8512 __attribute__((unused)) void *data)
8514 struct cmd_dump_one_result *res = parsed_result;
8516 if (!strcmp(res->dump, "dump_ring")) {
8518 r = rte_ring_lookup(res->name);
8520 cmdline_printf(cl, "Cannot find ring\n");
8523 rte_ring_dump(stdout, r);
8524 } else if (!strcmp(res->dump, "dump_mempool")) {
8525 struct rte_mempool *mp;
8526 mp = rte_mempool_lookup(res->name);
8528 cmdline_printf(cl, "Cannot find mempool\n");
8531 rte_mempool_dump(stdout, mp);
8535 cmdline_parse_token_string_t cmd_dump_one_dump =
8536 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
8537 "dump_ring#dump_mempool");
8539 cmdline_parse_token_string_t cmd_dump_one_name =
8540 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
8542 cmdline_parse_inst_t cmd_dump_one = {
8543 .f = cmd_dump_one_parsed, /* function to call */
8544 .data = NULL, /* 2nd arg of func */
8545 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
8546 .tokens = { /* token list, NULL terminated */
8547 (void *)&cmd_dump_one_dump,
8548 (void *)&cmd_dump_one_name,
8553 /* *** Add/Del syn filter *** */
8554 struct cmd_syn_filter_result {
8555 cmdline_fixed_string_t filter;
8557 cmdline_fixed_string_t ops;
8558 cmdline_fixed_string_t priority;
8559 cmdline_fixed_string_t high;
8560 cmdline_fixed_string_t queue;
8565 cmd_syn_filter_parsed(void *parsed_result,
8566 __attribute__((unused)) struct cmdline *cl,
8567 __attribute__((unused)) void *data)
8569 struct cmd_syn_filter_result *res = parsed_result;
8570 struct rte_eth_syn_filter syn_filter;
8573 ret = rte_eth_dev_filter_supported(res->port_id,
8574 RTE_ETH_FILTER_SYN);
8576 printf("syn filter is not supported on port %u.\n",
8581 memset(&syn_filter, 0, sizeof(syn_filter));
8583 if (!strcmp(res->ops, "add")) {
8584 if (!strcmp(res->high, "high"))
8585 syn_filter.hig_pri = 1;
8587 syn_filter.hig_pri = 0;
8589 syn_filter.queue = res->queue_id;
8590 ret = rte_eth_dev_filter_ctrl(res->port_id,
8595 ret = rte_eth_dev_filter_ctrl(res->port_id,
8597 RTE_ETH_FILTER_DELETE,
8601 printf("syn filter programming error: (%s)\n",
8605 cmdline_parse_token_string_t cmd_syn_filter_filter =
8606 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8607 filter, "syn_filter");
8608 cmdline_parse_token_num_t cmd_syn_filter_port_id =
8609 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
8611 cmdline_parse_token_string_t cmd_syn_filter_ops =
8612 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8614 cmdline_parse_token_string_t cmd_syn_filter_priority =
8615 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8616 priority, "priority");
8617 cmdline_parse_token_string_t cmd_syn_filter_high =
8618 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8620 cmdline_parse_token_string_t cmd_syn_filter_queue =
8621 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8623 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
8624 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
8627 cmdline_parse_inst_t cmd_syn_filter = {
8628 .f = cmd_syn_filter_parsed,
8630 .help_str = "syn_filter <port_id> add|del priority high|low queue "
8631 "<queue_id>: Add/Delete syn filter",
8633 (void *)&cmd_syn_filter_filter,
8634 (void *)&cmd_syn_filter_port_id,
8635 (void *)&cmd_syn_filter_ops,
8636 (void *)&cmd_syn_filter_priority,
8637 (void *)&cmd_syn_filter_high,
8638 (void *)&cmd_syn_filter_queue,
8639 (void *)&cmd_syn_filter_queue_id,
8644 /* *** queue region set *** */
8645 struct cmd_queue_region_result {
8646 cmdline_fixed_string_t set;
8647 cmdline_fixed_string_t port;
8649 cmdline_fixed_string_t cmd;
8650 cmdline_fixed_string_t region;
8652 cmdline_fixed_string_t queue_start_index;
8654 cmdline_fixed_string_t queue_num;
8655 uint8_t queue_num_value;
8659 cmd_queue_region_parsed(void *parsed_result,
8660 __attribute__((unused)) struct cmdline *cl,
8661 __attribute__((unused)) void *data)
8663 struct cmd_queue_region_result *res = parsed_result;
8665 #ifdef RTE_LIBRTE_I40E_PMD
8666 struct rte_pmd_i40e_queue_region_conf region_conf;
8667 enum rte_pmd_i40e_queue_region_op op_type;
8670 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
8673 #ifdef RTE_LIBRTE_I40E_PMD
8674 memset(®ion_conf, 0, sizeof(region_conf));
8675 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_SET;
8676 region_conf.region_id = res->region_id;
8677 region_conf.queue_num = res->queue_num_value;
8678 region_conf.queue_start_index = res->queue_id;
8680 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
8681 op_type, ®ion_conf);
8688 printf("function not implemented or supported\n");
8691 printf("queue region config error: (%s)\n", strerror(-ret));
8695 cmdline_parse_token_string_t cmd_queue_region_set =
8696 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
8698 cmdline_parse_token_string_t cmd_queue_region_port =
8699 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, port, "port");
8700 cmdline_parse_token_num_t cmd_queue_region_port_id =
8701 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
8703 cmdline_parse_token_string_t cmd_queue_region_cmd =
8704 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
8705 cmd, "queue-region");
8706 cmdline_parse_token_string_t cmd_queue_region_id =
8707 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
8708 region, "region_id");
8709 cmdline_parse_token_num_t cmd_queue_region_index =
8710 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
8712 cmdline_parse_token_string_t cmd_queue_region_queue_start_index =
8713 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
8714 queue_start_index, "queue_start_index");
8715 cmdline_parse_token_num_t cmd_queue_region_queue_id =
8716 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
8718 cmdline_parse_token_string_t cmd_queue_region_queue_num =
8719 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
8720 queue_num, "queue_num");
8721 cmdline_parse_token_num_t cmd_queue_region_queue_num_value =
8722 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
8723 queue_num_value, UINT8);
8725 cmdline_parse_inst_t cmd_queue_region = {
8726 .f = cmd_queue_region_parsed,
8728 .help_str = "set port <port_id> queue-region region_id <value> "
8729 "queue_start_index <value> queue_num <value>: Set a queue region",
8731 (void *)&cmd_queue_region_set,
8732 (void *)&cmd_queue_region_port,
8733 (void *)&cmd_queue_region_port_id,
8734 (void *)&cmd_queue_region_cmd,
8735 (void *)&cmd_queue_region_id,
8736 (void *)&cmd_queue_region_index,
8737 (void *)&cmd_queue_region_queue_start_index,
8738 (void *)&cmd_queue_region_queue_id,
8739 (void *)&cmd_queue_region_queue_num,
8740 (void *)&cmd_queue_region_queue_num_value,
8745 /* *** queue region and flowtype set *** */
8746 struct cmd_region_flowtype_result {
8747 cmdline_fixed_string_t set;
8748 cmdline_fixed_string_t port;
8750 cmdline_fixed_string_t cmd;
8751 cmdline_fixed_string_t region;
8753 cmdline_fixed_string_t flowtype;
8754 uint8_t flowtype_id;
8758 cmd_region_flowtype_parsed(void *parsed_result,
8759 __attribute__((unused)) struct cmdline *cl,
8760 __attribute__((unused)) void *data)
8762 struct cmd_region_flowtype_result *res = parsed_result;
8764 #ifdef RTE_LIBRTE_I40E_PMD
8765 struct rte_pmd_i40e_queue_region_conf region_conf;
8766 enum rte_pmd_i40e_queue_region_op op_type;
8769 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
8772 #ifdef RTE_LIBRTE_I40E_PMD
8773 memset(®ion_conf, 0, sizeof(region_conf));
8775 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_FLOWTYPE_SET;
8776 region_conf.region_id = res->region_id;
8777 region_conf.hw_flowtype = res->flowtype_id;
8779 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
8780 op_type, ®ion_conf);
8787 printf("function not implemented or supported\n");
8790 printf("region flowtype config error: (%s)\n", strerror(-ret));
8794 cmdline_parse_token_string_t cmd_region_flowtype_set =
8795 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
8797 cmdline_parse_token_string_t cmd_region_flowtype_port =
8798 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
8800 cmdline_parse_token_num_t cmd_region_flowtype_port_index =
8801 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
8803 cmdline_parse_token_string_t cmd_region_flowtype_cmd =
8804 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
8805 cmd, "queue-region");
8806 cmdline_parse_token_string_t cmd_region_flowtype_index =
8807 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
8808 region, "region_id");
8809 cmdline_parse_token_num_t cmd_region_flowtype_id =
8810 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
8812 cmdline_parse_token_string_t cmd_region_flowtype_flow_index =
8813 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
8814 flowtype, "flowtype");
8815 cmdline_parse_token_num_t cmd_region_flowtype_flow_id =
8816 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
8817 flowtype_id, UINT8);
8818 cmdline_parse_inst_t cmd_region_flowtype = {
8819 .f = cmd_region_flowtype_parsed,
8821 .help_str = "set port <port_id> queue-region region_id <value> "
8822 "flowtype <value>: Set a flowtype region index",
8824 (void *)&cmd_region_flowtype_set,
8825 (void *)&cmd_region_flowtype_port,
8826 (void *)&cmd_region_flowtype_port_index,
8827 (void *)&cmd_region_flowtype_cmd,
8828 (void *)&cmd_region_flowtype_index,
8829 (void *)&cmd_region_flowtype_id,
8830 (void *)&cmd_region_flowtype_flow_index,
8831 (void *)&cmd_region_flowtype_flow_id,
8836 /* *** User Priority (UP) to queue region (region_id) set *** */
8837 struct cmd_user_priority_region_result {
8838 cmdline_fixed_string_t set;
8839 cmdline_fixed_string_t port;
8841 cmdline_fixed_string_t cmd;
8842 cmdline_fixed_string_t user_priority;
8843 uint8_t user_priority_id;
8844 cmdline_fixed_string_t region;
8849 cmd_user_priority_region_parsed(void *parsed_result,
8850 __attribute__((unused)) struct cmdline *cl,
8851 __attribute__((unused)) void *data)
8853 struct cmd_user_priority_region_result *res = parsed_result;
8855 #ifdef RTE_LIBRTE_I40E_PMD
8856 struct rte_pmd_i40e_queue_region_conf region_conf;
8857 enum rte_pmd_i40e_queue_region_op op_type;
8860 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
8863 #ifdef RTE_LIBRTE_I40E_PMD
8864 memset(®ion_conf, 0, sizeof(region_conf));
8865 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_USER_PRIORITY_SET;
8866 region_conf.user_priority = res->user_priority_id;
8867 region_conf.region_id = res->region_id;
8869 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
8870 op_type, ®ion_conf);
8877 printf("function not implemented or supported\n");
8880 printf("user_priority region config error: (%s)\n",
8885 cmdline_parse_token_string_t cmd_user_priority_region_set =
8886 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
8888 cmdline_parse_token_string_t cmd_user_priority_region_port =
8889 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
8891 cmdline_parse_token_num_t cmd_user_priority_region_port_index =
8892 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
8894 cmdline_parse_token_string_t cmd_user_priority_region_cmd =
8895 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
8896 cmd, "queue-region");
8897 cmdline_parse_token_string_t cmd_user_priority_region_UP =
8898 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
8899 user_priority, "UP");
8900 cmdline_parse_token_num_t cmd_user_priority_region_UP_id =
8901 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
8902 user_priority_id, UINT8);
8903 cmdline_parse_token_string_t cmd_user_priority_region_region =
8904 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
8905 region, "region_id");
8906 cmdline_parse_token_num_t cmd_user_priority_region_region_id =
8907 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
8910 cmdline_parse_inst_t cmd_user_priority_region = {
8911 .f = cmd_user_priority_region_parsed,
8913 .help_str = "set port <port_id> queue-region UP <value> "
8914 "region_id <value>: Set the mapping of User Priority (UP) "
8915 "to queue region (region_id) ",
8917 (void *)&cmd_user_priority_region_set,
8918 (void *)&cmd_user_priority_region_port,
8919 (void *)&cmd_user_priority_region_port_index,
8920 (void *)&cmd_user_priority_region_cmd,
8921 (void *)&cmd_user_priority_region_UP,
8922 (void *)&cmd_user_priority_region_UP_id,
8923 (void *)&cmd_user_priority_region_region,
8924 (void *)&cmd_user_priority_region_region_id,
8929 /* *** flush all queue region related configuration *** */
8930 struct cmd_flush_queue_region_result {
8931 cmdline_fixed_string_t set;
8932 cmdline_fixed_string_t port;
8934 cmdline_fixed_string_t cmd;
8935 cmdline_fixed_string_t flush;
8936 cmdline_fixed_string_t what;
8940 cmd_flush_queue_region_parsed(void *parsed_result,
8941 __attribute__((unused)) struct cmdline *cl,
8942 __attribute__((unused)) void *data)
8944 struct cmd_flush_queue_region_result *res = parsed_result;
8946 #ifdef RTE_LIBRTE_I40E_PMD
8947 struct rte_pmd_i40e_queue_region_conf region_conf;
8948 enum rte_pmd_i40e_queue_region_op op_type;
8951 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
8954 #ifdef RTE_LIBRTE_I40E_PMD
8955 memset(®ion_conf, 0, sizeof(region_conf));
8957 if (strcmp(res->what, "on") == 0)
8958 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_ON;
8960 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_OFF;
8962 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
8963 op_type, ®ion_conf);
8970 printf("function not implemented or supported\n");
8973 printf("queue region config flush error: (%s)\n",
8978 cmdline_parse_token_string_t cmd_flush_queue_region_set =
8979 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
8981 cmdline_parse_token_string_t cmd_flush_queue_region_port =
8982 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
8984 cmdline_parse_token_num_t cmd_flush_queue_region_port_index =
8985 TOKEN_NUM_INITIALIZER(struct cmd_flush_queue_region_result,
8987 cmdline_parse_token_string_t cmd_flush_queue_region_cmd =
8988 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
8989 cmd, "queue-region");
8990 cmdline_parse_token_string_t cmd_flush_queue_region_flush =
8991 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
8993 cmdline_parse_token_string_t cmd_flush_queue_region_what =
8994 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
8997 cmdline_parse_inst_t cmd_flush_queue_region = {
8998 .f = cmd_flush_queue_region_parsed,
9000 .help_str = "set port <port_id> queue-region flush on|off"
9001 ": flush all queue region related configuration",
9003 (void *)&cmd_flush_queue_region_set,
9004 (void *)&cmd_flush_queue_region_port,
9005 (void *)&cmd_flush_queue_region_port_index,
9006 (void *)&cmd_flush_queue_region_cmd,
9007 (void *)&cmd_flush_queue_region_flush,
9008 (void *)&cmd_flush_queue_region_what,
9013 /* *** get all queue region related configuration info *** */
9014 struct cmd_show_queue_region_info {
9015 cmdline_fixed_string_t show;
9016 cmdline_fixed_string_t port;
9018 cmdline_fixed_string_t cmd;
9022 cmd_show_queue_region_info_parsed(void *parsed_result,
9023 __attribute__((unused)) struct cmdline *cl,
9024 __attribute__((unused)) void *data)
9026 struct cmd_show_queue_region_info *res = parsed_result;
9028 #ifdef RTE_LIBRTE_I40E_PMD
9029 struct rte_pmd_i40e_queue_regions rte_pmd_regions;
9030 enum rte_pmd_i40e_queue_region_op op_type;
9033 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9036 #ifdef RTE_LIBRTE_I40E_PMD
9037 memset(&rte_pmd_regions, 0, sizeof(rte_pmd_regions));
9039 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_INFO_GET;
9041 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9042 op_type, &rte_pmd_regions);
9044 port_queue_region_info_display(res->port_id, &rte_pmd_regions);
9051 printf("function not implemented or supported\n");
9054 printf("queue region config info show error: (%s)\n",
9059 cmdline_parse_token_string_t cmd_show_queue_region_info_get =
9060 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
9062 cmdline_parse_token_string_t cmd_show_queue_region_info_port =
9063 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
9065 cmdline_parse_token_num_t cmd_show_queue_region_info_port_index =
9066 TOKEN_NUM_INITIALIZER(struct cmd_show_queue_region_info,
9068 cmdline_parse_token_string_t cmd_show_queue_region_info_cmd =
9069 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
9070 cmd, "queue-region");
9072 cmdline_parse_inst_t cmd_show_queue_region_info_all = {
9073 .f = cmd_show_queue_region_info_parsed,
9075 .help_str = "show port <port_id> queue-region"
9076 ": show all queue region related configuration info",
9078 (void *)&cmd_show_queue_region_info_get,
9079 (void *)&cmd_show_queue_region_info_port,
9080 (void *)&cmd_show_queue_region_info_port_index,
9081 (void *)&cmd_show_queue_region_info_cmd,
9086 /* *** ADD/REMOVE A 2tuple FILTER *** */
9087 struct cmd_2tuple_filter_result {
9088 cmdline_fixed_string_t filter;
9090 cmdline_fixed_string_t ops;
9091 cmdline_fixed_string_t dst_port;
9092 uint16_t dst_port_value;
9093 cmdline_fixed_string_t protocol;
9094 uint8_t protocol_value;
9095 cmdline_fixed_string_t mask;
9097 cmdline_fixed_string_t tcp_flags;
9098 uint8_t tcp_flags_value;
9099 cmdline_fixed_string_t priority;
9100 uint8_t priority_value;
9101 cmdline_fixed_string_t queue;
9106 cmd_2tuple_filter_parsed(void *parsed_result,
9107 __attribute__((unused)) struct cmdline *cl,
9108 __attribute__((unused)) void *data)
9110 struct rte_eth_ntuple_filter filter;
9111 struct cmd_2tuple_filter_result *res = parsed_result;
9114 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
9116 printf("ntuple filter is not supported on port %u.\n",
9121 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
9123 filter.flags = RTE_2TUPLE_FLAGS;
9124 filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
9125 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
9126 filter.proto = res->protocol_value;
9127 filter.priority = res->priority_value;
9128 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
9129 printf("nonzero tcp_flags is only meaningful"
9130 " when protocol is TCP.\n");
9133 if (res->tcp_flags_value > TCP_FLAG_ALL) {
9134 printf("invalid TCP flags.\n");
9138 if (res->tcp_flags_value != 0) {
9139 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
9140 filter.tcp_flags = res->tcp_flags_value;
9143 /* need convert to big endian. */
9144 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
9145 filter.queue = res->queue_id;
9147 if (!strcmp(res->ops, "add"))
9148 ret = rte_eth_dev_filter_ctrl(res->port_id,
9149 RTE_ETH_FILTER_NTUPLE,
9153 ret = rte_eth_dev_filter_ctrl(res->port_id,
9154 RTE_ETH_FILTER_NTUPLE,
9155 RTE_ETH_FILTER_DELETE,
9158 printf("2tuple filter programming error: (%s)\n",
9163 cmdline_parse_token_string_t cmd_2tuple_filter_filter =
9164 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9165 filter, "2tuple_filter");
9166 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
9167 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9169 cmdline_parse_token_string_t cmd_2tuple_filter_ops =
9170 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9172 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
9173 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9174 dst_port, "dst_port");
9175 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
9176 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9177 dst_port_value, UINT16);
9178 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
9179 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9180 protocol, "protocol");
9181 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
9182 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9183 protocol_value, UINT8);
9184 cmdline_parse_token_string_t cmd_2tuple_filter_mask =
9185 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9187 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value =
9188 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9190 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags =
9191 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9192 tcp_flags, "tcp_flags");
9193 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value =
9194 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9195 tcp_flags_value, UINT8);
9196 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
9197 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9198 priority, "priority");
9199 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
9200 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9201 priority_value, UINT8);
9202 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
9203 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9205 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
9206 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9209 cmdline_parse_inst_t cmd_2tuple_filter = {
9210 .f = cmd_2tuple_filter_parsed,
9212 .help_str = "2tuple_filter <port_id> add|del dst_port <value> protocol "
9213 "<value> mask <value> tcp_flags <value> priority <value> queue "
9214 "<queue_id>: Add a 2tuple filter",
9216 (void *)&cmd_2tuple_filter_filter,
9217 (void *)&cmd_2tuple_filter_port_id,
9218 (void *)&cmd_2tuple_filter_ops,
9219 (void *)&cmd_2tuple_filter_dst_port,
9220 (void *)&cmd_2tuple_filter_dst_port_value,
9221 (void *)&cmd_2tuple_filter_protocol,
9222 (void *)&cmd_2tuple_filter_protocol_value,
9223 (void *)&cmd_2tuple_filter_mask,
9224 (void *)&cmd_2tuple_filter_mask_value,
9225 (void *)&cmd_2tuple_filter_tcp_flags,
9226 (void *)&cmd_2tuple_filter_tcp_flags_value,
9227 (void *)&cmd_2tuple_filter_priority,
9228 (void *)&cmd_2tuple_filter_priority_value,
9229 (void *)&cmd_2tuple_filter_queue,
9230 (void *)&cmd_2tuple_filter_queue_id,
9235 /* *** ADD/REMOVE A 5tuple FILTER *** */
9236 struct cmd_5tuple_filter_result {
9237 cmdline_fixed_string_t filter;
9239 cmdline_fixed_string_t ops;
9240 cmdline_fixed_string_t dst_ip;
9241 cmdline_ipaddr_t dst_ip_value;
9242 cmdline_fixed_string_t src_ip;
9243 cmdline_ipaddr_t src_ip_value;
9244 cmdline_fixed_string_t dst_port;
9245 uint16_t dst_port_value;
9246 cmdline_fixed_string_t src_port;
9247 uint16_t src_port_value;
9248 cmdline_fixed_string_t protocol;
9249 uint8_t protocol_value;
9250 cmdline_fixed_string_t mask;
9252 cmdline_fixed_string_t tcp_flags;
9253 uint8_t tcp_flags_value;
9254 cmdline_fixed_string_t priority;
9255 uint8_t priority_value;
9256 cmdline_fixed_string_t queue;
9261 cmd_5tuple_filter_parsed(void *parsed_result,
9262 __attribute__((unused)) struct cmdline *cl,
9263 __attribute__((unused)) void *data)
9265 struct rte_eth_ntuple_filter filter;
9266 struct cmd_5tuple_filter_result *res = parsed_result;
9269 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
9271 printf("ntuple filter is not supported on port %u.\n",
9276 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
9278 filter.flags = RTE_5TUPLE_FLAGS;
9279 filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0;
9280 filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0;
9281 filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0;
9282 filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
9283 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
9284 filter.proto = res->protocol_value;
9285 filter.priority = res->priority_value;
9286 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
9287 printf("nonzero tcp_flags is only meaningful"
9288 " when protocol is TCP.\n");
9291 if (res->tcp_flags_value > TCP_FLAG_ALL) {
9292 printf("invalid TCP flags.\n");
9296 if (res->tcp_flags_value != 0) {
9297 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
9298 filter.tcp_flags = res->tcp_flags_value;
9301 if (res->dst_ip_value.family == AF_INET)
9302 /* no need to convert, already big endian. */
9303 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
9305 if (filter.dst_ip_mask == 0) {
9306 printf("can not support ipv6 involved compare.\n");
9312 if (res->src_ip_value.family == AF_INET)
9313 /* no need to convert, already big endian. */
9314 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
9316 if (filter.src_ip_mask == 0) {
9317 printf("can not support ipv6 involved compare.\n");
9322 /* need convert to big endian. */
9323 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
9324 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
9325 filter.queue = res->queue_id;
9327 if (!strcmp(res->ops, "add"))
9328 ret = rte_eth_dev_filter_ctrl(res->port_id,
9329 RTE_ETH_FILTER_NTUPLE,
9333 ret = rte_eth_dev_filter_ctrl(res->port_id,
9334 RTE_ETH_FILTER_NTUPLE,
9335 RTE_ETH_FILTER_DELETE,
9338 printf("5tuple filter programming error: (%s)\n",
9342 cmdline_parse_token_string_t cmd_5tuple_filter_filter =
9343 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9344 filter, "5tuple_filter");
9345 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
9346 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9348 cmdline_parse_token_string_t cmd_5tuple_filter_ops =
9349 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9351 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
9352 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9354 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
9355 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
9357 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
9358 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9360 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
9361 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
9363 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
9364 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9365 dst_port, "dst_port");
9366 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
9367 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9368 dst_port_value, UINT16);
9369 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
9370 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9371 src_port, "src_port");
9372 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
9373 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9374 src_port_value, UINT16);
9375 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
9376 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9377 protocol, "protocol");
9378 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
9379 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9380 protocol_value, UINT8);
9381 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
9382 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9384 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
9385 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9387 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags =
9388 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9389 tcp_flags, "tcp_flags");
9390 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value =
9391 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9392 tcp_flags_value, UINT8);
9393 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
9394 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9395 priority, "priority");
9396 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
9397 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9398 priority_value, UINT8);
9399 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
9400 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9402 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
9403 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9406 cmdline_parse_inst_t cmd_5tuple_filter = {
9407 .f = cmd_5tuple_filter_parsed,
9409 .help_str = "5tuple_filter <port_id> add|del dst_ip <value> "
9410 "src_ip <value> dst_port <value> src_port <value> "
9411 "protocol <value> mask <value> tcp_flags <value> "
9412 "priority <value> queue <queue_id>: Add/Del a 5tuple filter",
9414 (void *)&cmd_5tuple_filter_filter,
9415 (void *)&cmd_5tuple_filter_port_id,
9416 (void *)&cmd_5tuple_filter_ops,
9417 (void *)&cmd_5tuple_filter_dst_ip,
9418 (void *)&cmd_5tuple_filter_dst_ip_value,
9419 (void *)&cmd_5tuple_filter_src_ip,
9420 (void *)&cmd_5tuple_filter_src_ip_value,
9421 (void *)&cmd_5tuple_filter_dst_port,
9422 (void *)&cmd_5tuple_filter_dst_port_value,
9423 (void *)&cmd_5tuple_filter_src_port,
9424 (void *)&cmd_5tuple_filter_src_port_value,
9425 (void *)&cmd_5tuple_filter_protocol,
9426 (void *)&cmd_5tuple_filter_protocol_value,
9427 (void *)&cmd_5tuple_filter_mask,
9428 (void *)&cmd_5tuple_filter_mask_value,
9429 (void *)&cmd_5tuple_filter_tcp_flags,
9430 (void *)&cmd_5tuple_filter_tcp_flags_value,
9431 (void *)&cmd_5tuple_filter_priority,
9432 (void *)&cmd_5tuple_filter_priority_value,
9433 (void *)&cmd_5tuple_filter_queue,
9434 (void *)&cmd_5tuple_filter_queue_id,
9439 /* *** ADD/REMOVE A flex FILTER *** */
9440 struct cmd_flex_filter_result {
9441 cmdline_fixed_string_t filter;
9442 cmdline_fixed_string_t ops;
9444 cmdline_fixed_string_t len;
9446 cmdline_fixed_string_t bytes;
9447 cmdline_fixed_string_t bytes_value;
9448 cmdline_fixed_string_t mask;
9449 cmdline_fixed_string_t mask_value;
9450 cmdline_fixed_string_t priority;
9451 uint8_t priority_value;
9452 cmdline_fixed_string_t queue;
9456 static int xdigit2val(unsigned char c)
9461 else if (isupper(c))
9469 cmd_flex_filter_parsed(void *parsed_result,
9470 __attribute__((unused)) struct cmdline *cl,
9471 __attribute__((unused)) void *data)
9474 struct rte_eth_flex_filter filter;
9475 struct cmd_flex_filter_result *res = parsed_result;
9476 char *bytes_ptr, *mask_ptr;
9477 uint16_t len, i, j = 0;
9482 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) {
9483 printf("the len exceed the max length 128\n");
9486 memset(&filter, 0, sizeof(struct rte_eth_flex_filter));
9487 filter.len = res->len_value;
9488 filter.priority = res->priority_value;
9489 filter.queue = res->queue_id;
9490 bytes_ptr = res->bytes_value;
9491 mask_ptr = res->mask_value;
9493 /* translate bytes string to array. */
9494 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
9495 (bytes_ptr[1] == 'X')))
9497 len = strnlen(bytes_ptr, res->len_value * 2);
9498 if (len == 0 || (len % 8 != 0)) {
9499 printf("please check len and bytes input\n");
9502 for (i = 0; i < len; i++) {
9504 if (isxdigit(c) == 0) {
9505 /* invalid characters. */
9506 printf("invalid input\n");
9509 val = xdigit2val(c);
9512 filter.bytes[j] = byte;
9513 printf("bytes[%d]:%02x ", j, filter.bytes[j]);
9520 /* translate mask string to uint8_t array. */
9521 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
9522 (mask_ptr[1] == 'X')))
9524 len = strnlen(mask_ptr, (res->len_value + 3) / 4);
9526 printf("invalid input\n");
9531 for (i = 0; i < len; i++) {
9533 if (isxdigit(c) == 0) {
9534 /* invalid characters. */
9535 printf("invalid input\n");
9538 val = xdigit2val(c);
9541 filter.mask[j] = byte;
9542 printf("mask[%d]:%02x ", j, filter.mask[j]);
9550 if (!strcmp(res->ops, "add"))
9551 ret = rte_eth_dev_filter_ctrl(res->port_id,
9552 RTE_ETH_FILTER_FLEXIBLE,
9556 ret = rte_eth_dev_filter_ctrl(res->port_id,
9557 RTE_ETH_FILTER_FLEXIBLE,
9558 RTE_ETH_FILTER_DELETE,
9562 printf("flex filter setting error: (%s)\n", strerror(-ret));
9565 cmdline_parse_token_string_t cmd_flex_filter_filter =
9566 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9567 filter, "flex_filter");
9568 cmdline_parse_token_num_t cmd_flex_filter_port_id =
9569 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
9571 cmdline_parse_token_string_t cmd_flex_filter_ops =
9572 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9574 cmdline_parse_token_string_t cmd_flex_filter_len =
9575 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9577 cmdline_parse_token_num_t cmd_flex_filter_len_value =
9578 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
9580 cmdline_parse_token_string_t cmd_flex_filter_bytes =
9581 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9583 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
9584 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9586 cmdline_parse_token_string_t cmd_flex_filter_mask =
9587 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9589 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
9590 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9592 cmdline_parse_token_string_t cmd_flex_filter_priority =
9593 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9594 priority, "priority");
9595 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
9596 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
9597 priority_value, UINT8);
9598 cmdline_parse_token_string_t cmd_flex_filter_queue =
9599 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9601 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
9602 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
9604 cmdline_parse_inst_t cmd_flex_filter = {
9605 .f = cmd_flex_filter_parsed,
9607 .help_str = "flex_filter <port_id> add|del len <value> bytes "
9608 "<value> mask <value> priority <value> queue <queue_id>: "
9609 "Add/Del a flex filter",
9611 (void *)&cmd_flex_filter_filter,
9612 (void *)&cmd_flex_filter_port_id,
9613 (void *)&cmd_flex_filter_ops,
9614 (void *)&cmd_flex_filter_len,
9615 (void *)&cmd_flex_filter_len_value,
9616 (void *)&cmd_flex_filter_bytes,
9617 (void *)&cmd_flex_filter_bytes_value,
9618 (void *)&cmd_flex_filter_mask,
9619 (void *)&cmd_flex_filter_mask_value,
9620 (void *)&cmd_flex_filter_priority,
9621 (void *)&cmd_flex_filter_priority_value,
9622 (void *)&cmd_flex_filter_queue,
9623 (void *)&cmd_flex_filter_queue_id,
9628 /* *** Filters Control *** */
9630 /* *** deal with ethertype filter *** */
9631 struct cmd_ethertype_filter_result {
9632 cmdline_fixed_string_t filter;
9634 cmdline_fixed_string_t ops;
9635 cmdline_fixed_string_t mac;
9636 struct ether_addr mac_addr;
9637 cmdline_fixed_string_t ethertype;
9638 uint16_t ethertype_value;
9639 cmdline_fixed_string_t drop;
9640 cmdline_fixed_string_t queue;
9644 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
9645 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9646 filter, "ethertype_filter");
9647 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
9648 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
9650 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
9651 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9653 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
9654 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9655 mac, "mac_addr#mac_ignr");
9656 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
9657 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
9659 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
9660 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9661 ethertype, "ethertype");
9662 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
9663 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
9664 ethertype_value, UINT16);
9665 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
9666 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9668 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
9669 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9671 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
9672 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
9676 cmd_ethertype_filter_parsed(void *parsed_result,
9677 __attribute__((unused)) struct cmdline *cl,
9678 __attribute__((unused)) void *data)
9680 struct cmd_ethertype_filter_result *res = parsed_result;
9681 struct rte_eth_ethertype_filter filter;
9684 ret = rte_eth_dev_filter_supported(res->port_id,
9685 RTE_ETH_FILTER_ETHERTYPE);
9687 printf("ethertype filter is not supported on port %u.\n",
9692 memset(&filter, 0, sizeof(filter));
9693 if (!strcmp(res->mac, "mac_addr")) {
9694 filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
9695 rte_memcpy(&filter.mac_addr, &res->mac_addr,
9696 sizeof(struct ether_addr));
9698 if (!strcmp(res->drop, "drop"))
9699 filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
9700 filter.ether_type = res->ethertype_value;
9701 filter.queue = res->queue_id;
9703 if (!strcmp(res->ops, "add"))
9704 ret = rte_eth_dev_filter_ctrl(res->port_id,
9705 RTE_ETH_FILTER_ETHERTYPE,
9709 ret = rte_eth_dev_filter_ctrl(res->port_id,
9710 RTE_ETH_FILTER_ETHERTYPE,
9711 RTE_ETH_FILTER_DELETE,
9714 printf("ethertype filter programming error: (%s)\n",
9718 cmdline_parse_inst_t cmd_ethertype_filter = {
9719 .f = cmd_ethertype_filter_parsed,
9721 .help_str = "ethertype_filter <port_id> add|del mac_addr|mac_ignr "
9722 "<mac_addr> ethertype <value> drop|fw queue <queue_id>: "
9723 "Add or delete an ethertype filter entry",
9725 (void *)&cmd_ethertype_filter_filter,
9726 (void *)&cmd_ethertype_filter_port_id,
9727 (void *)&cmd_ethertype_filter_ops,
9728 (void *)&cmd_ethertype_filter_mac,
9729 (void *)&cmd_ethertype_filter_mac_addr,
9730 (void *)&cmd_ethertype_filter_ethertype,
9731 (void *)&cmd_ethertype_filter_ethertype_value,
9732 (void *)&cmd_ethertype_filter_drop,
9733 (void *)&cmd_ethertype_filter_queue,
9734 (void *)&cmd_ethertype_filter_queue_id,
9739 /* *** deal with flow director filter *** */
9740 struct cmd_flow_director_result {
9741 cmdline_fixed_string_t flow_director_filter;
9743 cmdline_fixed_string_t mode;
9744 cmdline_fixed_string_t mode_value;
9745 cmdline_fixed_string_t ops;
9746 cmdline_fixed_string_t flow;
9747 cmdline_fixed_string_t flow_type;
9748 cmdline_fixed_string_t ether;
9749 uint16_t ether_type;
9750 cmdline_fixed_string_t src;
9751 cmdline_ipaddr_t ip_src;
9753 cmdline_fixed_string_t dst;
9754 cmdline_ipaddr_t ip_dst;
9756 cmdline_fixed_string_t verify_tag;
9757 uint32_t verify_tag_value;
9758 cmdline_ipaddr_t tos;
9760 cmdline_ipaddr_t proto;
9761 uint8_t proto_value;
9762 cmdline_ipaddr_t ttl;
9764 cmdline_fixed_string_t vlan;
9765 uint16_t vlan_value;
9766 cmdline_fixed_string_t flexbytes;
9767 cmdline_fixed_string_t flexbytes_value;
9768 cmdline_fixed_string_t pf_vf;
9769 cmdline_fixed_string_t drop;
9770 cmdline_fixed_string_t queue;
9772 cmdline_fixed_string_t fd_id;
9773 uint32_t fd_id_value;
9774 cmdline_fixed_string_t mac;
9775 struct ether_addr mac_addr;
9776 cmdline_fixed_string_t tunnel;
9777 cmdline_fixed_string_t tunnel_type;
9778 cmdline_fixed_string_t tunnel_id;
9779 uint32_t tunnel_id_value;
9783 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
9786 const char *p, *p0 = q_arg;
9788 unsigned long int_fld;
9789 char *str_fld[max_num];
9794 p = strchr(p0, '(');
9798 p0 = strchr(p, ')');
9803 if (size >= sizeof(s))
9806 snprintf(s, sizeof(s), "%.*s", size, p);
9807 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
9808 if (ret < 0 || ret > max_num)
9810 for (i = 0; i < ret; i++) {
9812 int_fld = strtoul(str_fld[i], &end, 0);
9813 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
9815 flexbytes[i] = (uint8_t)int_fld;
9821 str2flowtype(char *string)
9824 static const struct {
9827 } flowtype_str[] = {
9828 {"raw", RTE_ETH_FLOW_RAW},
9829 {"ipv4", RTE_ETH_FLOW_IPV4},
9830 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
9831 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
9832 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
9833 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
9834 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
9835 {"ipv6", RTE_ETH_FLOW_IPV6},
9836 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
9837 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
9838 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
9839 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
9840 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
9841 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
9844 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
9845 if (!strcmp(flowtype_str[i].str, string))
9846 return flowtype_str[i].type;
9849 if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64)
9850 return (uint16_t)atoi(string);
9852 return RTE_ETH_FLOW_UNKNOWN;
9855 static enum rte_eth_fdir_tunnel_type
9856 str2fdir_tunneltype(char *string)
9860 static const struct {
9862 enum rte_eth_fdir_tunnel_type type;
9863 } tunneltype_str[] = {
9864 {"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE},
9865 {"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN},
9868 for (i = 0; i < RTE_DIM(tunneltype_str); i++) {
9869 if (!strcmp(tunneltype_str[i].str, string))
9870 return tunneltype_str[i].type;
9872 return RTE_FDIR_TUNNEL_TYPE_UNKNOWN;
9875 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
9877 if ((ip_addr).family == AF_INET) \
9878 (ip) = (ip_addr).addr.ipv4.s_addr; \
9880 printf("invalid parameter.\n"); \
9885 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
9887 if ((ip_addr).family == AF_INET6) \
9889 &((ip_addr).addr.ipv6), \
9890 sizeof(struct in6_addr)); \
9892 printf("invalid parameter.\n"); \
9898 cmd_flow_director_filter_parsed(void *parsed_result,
9899 __attribute__((unused)) struct cmdline *cl,
9900 __attribute__((unused)) void *data)
9902 struct cmd_flow_director_result *res = parsed_result;
9903 struct rte_eth_fdir_filter entry;
9904 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
9906 unsigned long vf_id;
9909 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
9911 printf("flow director is not supported on port %u.\n",
9915 memset(flexbytes, 0, sizeof(flexbytes));
9916 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
9918 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
9919 if (strcmp(res->mode_value, "MAC-VLAN")) {
9920 printf("Please set mode to MAC-VLAN.\n");
9923 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
9924 if (strcmp(res->mode_value, "Tunnel")) {
9925 printf("Please set mode to Tunnel.\n");
9929 if (strcmp(res->mode_value, "IP")) {
9930 printf("Please set mode to IP.\n");
9933 entry.input.flow_type = str2flowtype(res->flow_type);
9936 ret = parse_flexbytes(res->flexbytes_value,
9938 RTE_ETH_FDIR_MAX_FLEXLEN);
9940 printf("error: Cannot parse flexbytes input.\n");
9944 switch (entry.input.flow_type) {
9945 case RTE_ETH_FLOW_FRAG_IPV4:
9946 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
9947 entry.input.flow.ip4_flow.proto = res->proto_value;
9949 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
9950 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
9951 IPV4_ADDR_TO_UINT(res->ip_dst,
9952 entry.input.flow.ip4_flow.dst_ip);
9953 IPV4_ADDR_TO_UINT(res->ip_src,
9954 entry.input.flow.ip4_flow.src_ip);
9955 entry.input.flow.ip4_flow.tos = res->tos_value;
9956 entry.input.flow.ip4_flow.ttl = res->ttl_value;
9957 /* need convert to big endian. */
9958 entry.input.flow.udp4_flow.dst_port =
9959 rte_cpu_to_be_16(res->port_dst);
9960 entry.input.flow.udp4_flow.src_port =
9961 rte_cpu_to_be_16(res->port_src);
9963 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
9964 IPV4_ADDR_TO_UINT(res->ip_dst,
9965 entry.input.flow.sctp4_flow.ip.dst_ip);
9966 IPV4_ADDR_TO_UINT(res->ip_src,
9967 entry.input.flow.sctp4_flow.ip.src_ip);
9968 entry.input.flow.ip4_flow.tos = res->tos_value;
9969 entry.input.flow.ip4_flow.ttl = res->ttl_value;
9970 /* need convert to big endian. */
9971 entry.input.flow.sctp4_flow.dst_port =
9972 rte_cpu_to_be_16(res->port_dst);
9973 entry.input.flow.sctp4_flow.src_port =
9974 rte_cpu_to_be_16(res->port_src);
9975 entry.input.flow.sctp4_flow.verify_tag =
9976 rte_cpu_to_be_32(res->verify_tag_value);
9978 case RTE_ETH_FLOW_FRAG_IPV6:
9979 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
9980 entry.input.flow.ipv6_flow.proto = res->proto_value;
9982 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
9983 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
9984 IPV6_ADDR_TO_ARRAY(res->ip_dst,
9985 entry.input.flow.ipv6_flow.dst_ip);
9986 IPV6_ADDR_TO_ARRAY(res->ip_src,
9987 entry.input.flow.ipv6_flow.src_ip);
9988 entry.input.flow.ipv6_flow.tc = res->tos_value;
9989 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
9990 /* need convert to big endian. */
9991 entry.input.flow.udp6_flow.dst_port =
9992 rte_cpu_to_be_16(res->port_dst);
9993 entry.input.flow.udp6_flow.src_port =
9994 rte_cpu_to_be_16(res->port_src);
9996 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
9997 IPV6_ADDR_TO_ARRAY(res->ip_dst,
9998 entry.input.flow.sctp6_flow.ip.dst_ip);
9999 IPV6_ADDR_TO_ARRAY(res->ip_src,
10000 entry.input.flow.sctp6_flow.ip.src_ip);
10001 entry.input.flow.ipv6_flow.tc = res->tos_value;
10002 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
10003 /* need convert to big endian. */
10004 entry.input.flow.sctp6_flow.dst_port =
10005 rte_cpu_to_be_16(res->port_dst);
10006 entry.input.flow.sctp6_flow.src_port =
10007 rte_cpu_to_be_16(res->port_src);
10008 entry.input.flow.sctp6_flow.verify_tag =
10009 rte_cpu_to_be_32(res->verify_tag_value);
10011 case RTE_ETH_FLOW_L2_PAYLOAD:
10012 entry.input.flow.l2_flow.ether_type =
10013 rte_cpu_to_be_16(res->ether_type);
10019 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN)
10020 rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr,
10022 sizeof(struct ether_addr));
10024 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
10025 rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr,
10027 sizeof(struct ether_addr));
10028 entry.input.flow.tunnel_flow.tunnel_type =
10029 str2fdir_tunneltype(res->tunnel_type);
10030 entry.input.flow.tunnel_flow.tunnel_id =
10031 rte_cpu_to_be_32(res->tunnel_id_value);
10034 rte_memcpy(entry.input.flow_ext.flexbytes,
10036 RTE_ETH_FDIR_MAX_FLEXLEN);
10038 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
10040 entry.action.flex_off = 0; /*use 0 by default */
10041 if (!strcmp(res->drop, "drop"))
10042 entry.action.behavior = RTE_ETH_FDIR_REJECT;
10044 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
10046 if (fdir_conf.mode != RTE_FDIR_MODE_PERFECT_MAC_VLAN &&
10047 fdir_conf.mode != RTE_FDIR_MODE_PERFECT_TUNNEL) {
10048 if (!strcmp(res->pf_vf, "pf"))
10049 entry.input.flow_ext.is_vf = 0;
10050 else if (!strncmp(res->pf_vf, "vf", 2)) {
10051 struct rte_eth_dev_info dev_info;
10053 memset(&dev_info, 0, sizeof(dev_info));
10054 rte_eth_dev_info_get(res->port_id, &dev_info);
10056 vf_id = strtoul(res->pf_vf + 2, &end, 10);
10057 if (errno != 0 || *end != '\0' ||
10058 vf_id >= dev_info.max_vfs) {
10059 printf("invalid parameter %s.\n", res->pf_vf);
10062 entry.input.flow_ext.is_vf = 1;
10063 entry.input.flow_ext.dst_id = (uint16_t)vf_id;
10065 printf("invalid parameter %s.\n", res->pf_vf);
10070 /* set to report FD ID by default */
10071 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
10072 entry.action.rx_queue = res->queue_id;
10073 entry.soft_id = res->fd_id_value;
10074 if (!strcmp(res->ops, "add"))
10075 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10076 RTE_ETH_FILTER_ADD, &entry);
10077 else if (!strcmp(res->ops, "del"))
10078 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10079 RTE_ETH_FILTER_DELETE, &entry);
10081 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10082 RTE_ETH_FILTER_UPDATE, &entry);
10084 printf("flow director programming error: (%s)\n",
10088 cmdline_parse_token_string_t cmd_flow_director_filter =
10089 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10090 flow_director_filter, "flow_director_filter");
10091 cmdline_parse_token_num_t cmd_flow_director_port_id =
10092 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10094 cmdline_parse_token_string_t cmd_flow_director_ops =
10095 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10096 ops, "add#del#update");
10097 cmdline_parse_token_string_t cmd_flow_director_flow =
10098 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10100 cmdline_parse_token_string_t cmd_flow_director_flow_type =
10101 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10102 flow_type, "ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
10103 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload");
10104 cmdline_parse_token_string_t cmd_flow_director_ether =
10105 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10107 cmdline_parse_token_num_t cmd_flow_director_ether_type =
10108 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10109 ether_type, UINT16);
10110 cmdline_parse_token_string_t cmd_flow_director_src =
10111 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10113 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
10114 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
10116 cmdline_parse_token_num_t cmd_flow_director_port_src =
10117 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10119 cmdline_parse_token_string_t cmd_flow_director_dst =
10120 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10122 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
10123 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
10125 cmdline_parse_token_num_t cmd_flow_director_port_dst =
10126 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10128 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
10129 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10130 verify_tag, "verify_tag");
10131 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
10132 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10133 verify_tag_value, UINT32);
10134 cmdline_parse_token_string_t cmd_flow_director_tos =
10135 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10137 cmdline_parse_token_num_t cmd_flow_director_tos_value =
10138 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10140 cmdline_parse_token_string_t cmd_flow_director_proto =
10141 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10143 cmdline_parse_token_num_t cmd_flow_director_proto_value =
10144 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10145 proto_value, UINT8);
10146 cmdline_parse_token_string_t cmd_flow_director_ttl =
10147 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10149 cmdline_parse_token_num_t cmd_flow_director_ttl_value =
10150 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10152 cmdline_parse_token_string_t cmd_flow_director_vlan =
10153 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10155 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
10156 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10157 vlan_value, UINT16);
10158 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
10159 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10160 flexbytes, "flexbytes");
10161 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
10162 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10163 flexbytes_value, NULL);
10164 cmdline_parse_token_string_t cmd_flow_director_drop =
10165 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10167 cmdline_parse_token_string_t cmd_flow_director_pf_vf =
10168 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10170 cmdline_parse_token_string_t cmd_flow_director_queue =
10171 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10173 cmdline_parse_token_num_t cmd_flow_director_queue_id =
10174 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10176 cmdline_parse_token_string_t cmd_flow_director_fd_id =
10177 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10179 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
10180 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10181 fd_id_value, UINT32);
10183 cmdline_parse_token_string_t cmd_flow_director_mode =
10184 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10186 cmdline_parse_token_string_t cmd_flow_director_mode_ip =
10187 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10189 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan =
10190 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10191 mode_value, "MAC-VLAN");
10192 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel =
10193 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10194 mode_value, "Tunnel");
10195 cmdline_parse_token_string_t cmd_flow_director_mac =
10196 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10198 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr =
10199 TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result,
10201 cmdline_parse_token_string_t cmd_flow_director_tunnel =
10202 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10204 cmdline_parse_token_string_t cmd_flow_director_tunnel_type =
10205 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10206 tunnel_type, "NVGRE#VxLAN");
10207 cmdline_parse_token_string_t cmd_flow_director_tunnel_id =
10208 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10209 tunnel_id, "tunnel-id");
10210 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value =
10211 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10212 tunnel_id_value, UINT32);
10214 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
10215 .f = cmd_flow_director_filter_parsed,
10217 .help_str = "flow_director_filter <port_id> mode IP add|del|update flow"
10218 " ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
10219 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
10220 "l2_payload src <src_ip> dst <dst_ip> tos <tos_value> "
10221 "proto <proto_value> ttl <ttl_value> vlan <vlan_value> "
10222 "flexbytes <flexbyte_values> drop|fw <pf_vf> queue <queue_id> "
10223 "fd_id <fd_id_value>: "
10224 "Add or delete an ip flow director entry on NIC",
10226 (void *)&cmd_flow_director_filter,
10227 (void *)&cmd_flow_director_port_id,
10228 (void *)&cmd_flow_director_mode,
10229 (void *)&cmd_flow_director_mode_ip,
10230 (void *)&cmd_flow_director_ops,
10231 (void *)&cmd_flow_director_flow,
10232 (void *)&cmd_flow_director_flow_type,
10233 (void *)&cmd_flow_director_src,
10234 (void *)&cmd_flow_director_ip_src,
10235 (void *)&cmd_flow_director_dst,
10236 (void *)&cmd_flow_director_ip_dst,
10237 (void *)&cmd_flow_director_tos,
10238 (void *)&cmd_flow_director_tos_value,
10239 (void *)&cmd_flow_director_proto,
10240 (void *)&cmd_flow_director_proto_value,
10241 (void *)&cmd_flow_director_ttl,
10242 (void *)&cmd_flow_director_ttl_value,
10243 (void *)&cmd_flow_director_vlan,
10244 (void *)&cmd_flow_director_vlan_value,
10245 (void *)&cmd_flow_director_flexbytes,
10246 (void *)&cmd_flow_director_flexbytes_value,
10247 (void *)&cmd_flow_director_drop,
10248 (void *)&cmd_flow_director_pf_vf,
10249 (void *)&cmd_flow_director_queue,
10250 (void *)&cmd_flow_director_queue_id,
10251 (void *)&cmd_flow_director_fd_id,
10252 (void *)&cmd_flow_director_fd_id_value,
10257 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
10258 .f = cmd_flow_director_filter_parsed,
10260 .help_str = "flow_director_filter ... : Add or delete an udp/tcp flow "
10261 "director entry on NIC",
10263 (void *)&cmd_flow_director_filter,
10264 (void *)&cmd_flow_director_port_id,
10265 (void *)&cmd_flow_director_mode,
10266 (void *)&cmd_flow_director_mode_ip,
10267 (void *)&cmd_flow_director_ops,
10268 (void *)&cmd_flow_director_flow,
10269 (void *)&cmd_flow_director_flow_type,
10270 (void *)&cmd_flow_director_src,
10271 (void *)&cmd_flow_director_ip_src,
10272 (void *)&cmd_flow_director_port_src,
10273 (void *)&cmd_flow_director_dst,
10274 (void *)&cmd_flow_director_ip_dst,
10275 (void *)&cmd_flow_director_port_dst,
10276 (void *)&cmd_flow_director_tos,
10277 (void *)&cmd_flow_director_tos_value,
10278 (void *)&cmd_flow_director_ttl,
10279 (void *)&cmd_flow_director_ttl_value,
10280 (void *)&cmd_flow_director_vlan,
10281 (void *)&cmd_flow_director_vlan_value,
10282 (void *)&cmd_flow_director_flexbytes,
10283 (void *)&cmd_flow_director_flexbytes_value,
10284 (void *)&cmd_flow_director_drop,
10285 (void *)&cmd_flow_director_pf_vf,
10286 (void *)&cmd_flow_director_queue,
10287 (void *)&cmd_flow_director_queue_id,
10288 (void *)&cmd_flow_director_fd_id,
10289 (void *)&cmd_flow_director_fd_id_value,
10294 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
10295 .f = cmd_flow_director_filter_parsed,
10297 .help_str = "flow_director_filter ... : Add or delete a sctp flow "
10298 "director entry on NIC",
10300 (void *)&cmd_flow_director_filter,
10301 (void *)&cmd_flow_director_port_id,
10302 (void *)&cmd_flow_director_mode,
10303 (void *)&cmd_flow_director_mode_ip,
10304 (void *)&cmd_flow_director_ops,
10305 (void *)&cmd_flow_director_flow,
10306 (void *)&cmd_flow_director_flow_type,
10307 (void *)&cmd_flow_director_src,
10308 (void *)&cmd_flow_director_ip_src,
10309 (void *)&cmd_flow_director_port_dst,
10310 (void *)&cmd_flow_director_dst,
10311 (void *)&cmd_flow_director_ip_dst,
10312 (void *)&cmd_flow_director_port_dst,
10313 (void *)&cmd_flow_director_verify_tag,
10314 (void *)&cmd_flow_director_verify_tag_value,
10315 (void *)&cmd_flow_director_tos,
10316 (void *)&cmd_flow_director_tos_value,
10317 (void *)&cmd_flow_director_ttl,
10318 (void *)&cmd_flow_director_ttl_value,
10319 (void *)&cmd_flow_director_vlan,
10320 (void *)&cmd_flow_director_vlan_value,
10321 (void *)&cmd_flow_director_flexbytes,
10322 (void *)&cmd_flow_director_flexbytes_value,
10323 (void *)&cmd_flow_director_drop,
10324 (void *)&cmd_flow_director_pf_vf,
10325 (void *)&cmd_flow_director_queue,
10326 (void *)&cmd_flow_director_queue_id,
10327 (void *)&cmd_flow_director_fd_id,
10328 (void *)&cmd_flow_director_fd_id_value,
10333 cmdline_parse_inst_t cmd_add_del_l2_flow_director = {
10334 .f = cmd_flow_director_filter_parsed,
10336 .help_str = "flow_director_filter ... : Add or delete a L2 flow "
10337 "director entry on NIC",
10339 (void *)&cmd_flow_director_filter,
10340 (void *)&cmd_flow_director_port_id,
10341 (void *)&cmd_flow_director_mode,
10342 (void *)&cmd_flow_director_mode_ip,
10343 (void *)&cmd_flow_director_ops,
10344 (void *)&cmd_flow_director_flow,
10345 (void *)&cmd_flow_director_flow_type,
10346 (void *)&cmd_flow_director_ether,
10347 (void *)&cmd_flow_director_ether_type,
10348 (void *)&cmd_flow_director_flexbytes,
10349 (void *)&cmd_flow_director_flexbytes_value,
10350 (void *)&cmd_flow_director_drop,
10351 (void *)&cmd_flow_director_pf_vf,
10352 (void *)&cmd_flow_director_queue,
10353 (void *)&cmd_flow_director_queue_id,
10354 (void *)&cmd_flow_director_fd_id,
10355 (void *)&cmd_flow_director_fd_id_value,
10360 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = {
10361 .f = cmd_flow_director_filter_parsed,
10363 .help_str = "flow_director_filter ... : Add or delete a MAC VLAN flow "
10364 "director entry on NIC",
10366 (void *)&cmd_flow_director_filter,
10367 (void *)&cmd_flow_director_port_id,
10368 (void *)&cmd_flow_director_mode,
10369 (void *)&cmd_flow_director_mode_mac_vlan,
10370 (void *)&cmd_flow_director_ops,
10371 (void *)&cmd_flow_director_mac,
10372 (void *)&cmd_flow_director_mac_addr,
10373 (void *)&cmd_flow_director_vlan,
10374 (void *)&cmd_flow_director_vlan_value,
10375 (void *)&cmd_flow_director_flexbytes,
10376 (void *)&cmd_flow_director_flexbytes_value,
10377 (void *)&cmd_flow_director_drop,
10378 (void *)&cmd_flow_director_queue,
10379 (void *)&cmd_flow_director_queue_id,
10380 (void *)&cmd_flow_director_fd_id,
10381 (void *)&cmd_flow_director_fd_id_value,
10386 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = {
10387 .f = cmd_flow_director_filter_parsed,
10389 .help_str = "flow_director_filter ... : Add or delete a tunnel flow "
10390 "director entry on NIC",
10392 (void *)&cmd_flow_director_filter,
10393 (void *)&cmd_flow_director_port_id,
10394 (void *)&cmd_flow_director_mode,
10395 (void *)&cmd_flow_director_mode_tunnel,
10396 (void *)&cmd_flow_director_ops,
10397 (void *)&cmd_flow_director_mac,
10398 (void *)&cmd_flow_director_mac_addr,
10399 (void *)&cmd_flow_director_vlan,
10400 (void *)&cmd_flow_director_vlan_value,
10401 (void *)&cmd_flow_director_tunnel,
10402 (void *)&cmd_flow_director_tunnel_type,
10403 (void *)&cmd_flow_director_tunnel_id,
10404 (void *)&cmd_flow_director_tunnel_id_value,
10405 (void *)&cmd_flow_director_flexbytes,
10406 (void *)&cmd_flow_director_flexbytes_value,
10407 (void *)&cmd_flow_director_drop,
10408 (void *)&cmd_flow_director_queue,
10409 (void *)&cmd_flow_director_queue_id,
10410 (void *)&cmd_flow_director_fd_id,
10411 (void *)&cmd_flow_director_fd_id_value,
10416 struct cmd_flush_flow_director_result {
10417 cmdline_fixed_string_t flush_flow_director;
10421 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
10422 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
10423 flush_flow_director, "flush_flow_director");
10424 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
10425 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
10429 cmd_flush_flow_director_parsed(void *parsed_result,
10430 __attribute__((unused)) struct cmdline *cl,
10431 __attribute__((unused)) void *data)
10433 struct cmd_flow_director_result *res = parsed_result;
10436 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
10438 printf("flow director is not supported on port %u.\n",
10443 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10444 RTE_ETH_FILTER_FLUSH, NULL);
10446 printf("flow director table flushing error: (%s)\n",
10450 cmdline_parse_inst_t cmd_flush_flow_director = {
10451 .f = cmd_flush_flow_director_parsed,
10453 .help_str = "flush_flow_director <port_id>: "
10454 "Flush all flow director entries of a device on NIC",
10456 (void *)&cmd_flush_flow_director_flush,
10457 (void *)&cmd_flush_flow_director_port_id,
10462 /* *** deal with flow director mask *** */
10463 struct cmd_flow_director_mask_result {
10464 cmdline_fixed_string_t flow_director_mask;
10466 cmdline_fixed_string_t mode;
10467 cmdline_fixed_string_t mode_value;
10468 cmdline_fixed_string_t vlan;
10469 uint16_t vlan_mask;
10470 cmdline_fixed_string_t src_mask;
10471 cmdline_ipaddr_t ipv4_src;
10472 cmdline_ipaddr_t ipv6_src;
10474 cmdline_fixed_string_t dst_mask;
10475 cmdline_ipaddr_t ipv4_dst;
10476 cmdline_ipaddr_t ipv6_dst;
10478 cmdline_fixed_string_t mac;
10479 uint8_t mac_addr_byte_mask;
10480 cmdline_fixed_string_t tunnel_id;
10481 uint32_t tunnel_id_mask;
10482 cmdline_fixed_string_t tunnel_type;
10483 uint8_t tunnel_type_mask;
10487 cmd_flow_director_mask_parsed(void *parsed_result,
10488 __attribute__((unused)) struct cmdline *cl,
10489 __attribute__((unused)) void *data)
10491 struct cmd_flow_director_mask_result *res = parsed_result;
10492 struct rte_eth_fdir_masks *mask;
10493 struct rte_port *port;
10495 if (res->port_id > nb_ports) {
10496 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
10500 port = &ports[res->port_id];
10501 /** Check if the port is not started **/
10502 if (port->port_status != RTE_PORT_STOPPED) {
10503 printf("Please stop port %d first\n", res->port_id);
10507 mask = &port->dev_conf.fdir_conf.mask;
10509 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
10510 if (strcmp(res->mode_value, "MAC-VLAN")) {
10511 printf("Please set mode to MAC-VLAN.\n");
10515 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10516 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
10517 if (strcmp(res->mode_value, "Tunnel")) {
10518 printf("Please set mode to Tunnel.\n");
10522 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10523 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
10524 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
10525 mask->tunnel_type_mask = res->tunnel_type_mask;
10527 if (strcmp(res->mode_value, "IP")) {
10528 printf("Please set mode to IP.\n");
10532 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10533 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
10534 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
10535 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
10536 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
10537 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
10538 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
10541 cmd_reconfig_device_queue(res->port_id, 1, 1);
10544 cmdline_parse_token_string_t cmd_flow_director_mask =
10545 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10546 flow_director_mask, "flow_director_mask");
10547 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
10548 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10550 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
10551 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10553 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
10554 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10555 vlan_mask, UINT16);
10556 cmdline_parse_token_string_t cmd_flow_director_mask_src =
10557 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10558 src_mask, "src_mask");
10559 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
10560 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10562 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
10563 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10565 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
10566 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10568 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
10569 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10570 dst_mask, "dst_mask");
10571 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
10572 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10574 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
10575 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10577 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
10578 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10581 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
10582 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10584 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
10585 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10587 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
10588 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10589 mode_value, "MAC-VLAN");
10590 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
10591 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10592 mode_value, "Tunnel");
10593 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
10594 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10596 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
10597 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10598 mac_addr_byte_mask, UINT8);
10599 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
10600 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10601 tunnel_type, "tunnel-type");
10602 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
10603 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10604 tunnel_type_mask, UINT8);
10605 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
10606 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10607 tunnel_id, "tunnel-id");
10608 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
10609 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10610 tunnel_id_mask, UINT32);
10612 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
10613 .f = cmd_flow_director_mask_parsed,
10615 .help_str = "flow_director_mask ... : "
10616 "Set IP mode flow director's mask on NIC",
10618 (void *)&cmd_flow_director_mask,
10619 (void *)&cmd_flow_director_mask_port_id,
10620 (void *)&cmd_flow_director_mask_mode,
10621 (void *)&cmd_flow_director_mask_mode_ip,
10622 (void *)&cmd_flow_director_mask_vlan,
10623 (void *)&cmd_flow_director_mask_vlan_value,
10624 (void *)&cmd_flow_director_mask_src,
10625 (void *)&cmd_flow_director_mask_ipv4_src,
10626 (void *)&cmd_flow_director_mask_ipv6_src,
10627 (void *)&cmd_flow_director_mask_port_src,
10628 (void *)&cmd_flow_director_mask_dst,
10629 (void *)&cmd_flow_director_mask_ipv4_dst,
10630 (void *)&cmd_flow_director_mask_ipv6_dst,
10631 (void *)&cmd_flow_director_mask_port_dst,
10636 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
10637 .f = cmd_flow_director_mask_parsed,
10639 .help_str = "flow_director_mask ... : Set MAC VLAN mode "
10640 "flow director's mask on NIC",
10642 (void *)&cmd_flow_director_mask,
10643 (void *)&cmd_flow_director_mask_port_id,
10644 (void *)&cmd_flow_director_mask_mode,
10645 (void *)&cmd_flow_director_mask_mode_mac_vlan,
10646 (void *)&cmd_flow_director_mask_vlan,
10647 (void *)&cmd_flow_director_mask_vlan_value,
10652 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
10653 .f = cmd_flow_director_mask_parsed,
10655 .help_str = "flow_director_mask ... : Set tunnel mode "
10656 "flow director's mask on NIC",
10658 (void *)&cmd_flow_director_mask,
10659 (void *)&cmd_flow_director_mask_port_id,
10660 (void *)&cmd_flow_director_mask_mode,
10661 (void *)&cmd_flow_director_mask_mode_tunnel,
10662 (void *)&cmd_flow_director_mask_vlan,
10663 (void *)&cmd_flow_director_mask_vlan_value,
10664 (void *)&cmd_flow_director_mask_mac,
10665 (void *)&cmd_flow_director_mask_mac_value,
10666 (void *)&cmd_flow_director_mask_tunnel_type,
10667 (void *)&cmd_flow_director_mask_tunnel_type_value,
10668 (void *)&cmd_flow_director_mask_tunnel_id,
10669 (void *)&cmd_flow_director_mask_tunnel_id_value,
10674 /* *** deal with flow director mask on flexible payload *** */
10675 struct cmd_flow_director_flex_mask_result {
10676 cmdline_fixed_string_t flow_director_flexmask;
10678 cmdline_fixed_string_t flow;
10679 cmdline_fixed_string_t flow_type;
10680 cmdline_fixed_string_t mask;
10684 cmd_flow_director_flex_mask_parsed(void *parsed_result,
10685 __attribute__((unused)) struct cmdline *cl,
10686 __attribute__((unused)) void *data)
10688 struct cmd_flow_director_flex_mask_result *res = parsed_result;
10689 struct rte_eth_fdir_info fdir_info;
10690 struct rte_eth_fdir_flex_mask flex_mask;
10691 struct rte_port *port;
10692 uint32_t flow_type_mask;
10696 if (res->port_id > nb_ports) {
10697 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
10701 port = &ports[res->port_id];
10702 /** Check if the port is not started **/
10703 if (port->port_status != RTE_PORT_STOPPED) {
10704 printf("Please stop port %d first\n", res->port_id);
10708 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
10709 ret = parse_flexbytes(res->mask,
10711 RTE_ETH_FDIR_MAX_FLEXLEN);
10713 printf("error: Cannot parse mask input.\n");
10717 memset(&fdir_info, 0, sizeof(fdir_info));
10718 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10719 RTE_ETH_FILTER_INFO, &fdir_info);
10721 printf("Cannot get FDir filter info\n");
10725 if (!strcmp(res->flow_type, "none")) {
10726 /* means don't specify the flow type */
10727 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN;
10728 for (i = 0; i < RTE_ETH_FLOW_MAX; i++)
10729 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i],
10730 0, sizeof(struct rte_eth_fdir_flex_mask));
10731 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1;
10732 rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0],
10734 sizeof(struct rte_eth_fdir_flex_mask));
10735 cmd_reconfig_device_queue(res->port_id, 1, 1);
10738 flow_type_mask = fdir_info.flow_types_mask[0];
10739 if (!strcmp(res->flow_type, "all")) {
10740 if (!flow_type_mask) {
10741 printf("No flow type supported\n");
10744 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
10745 if (flow_type_mask & (1 << i)) {
10746 flex_mask.flow_type = i;
10747 fdir_set_flex_mask(res->port_id, &flex_mask);
10750 cmd_reconfig_device_queue(res->port_id, 1, 1);
10753 flex_mask.flow_type = str2flowtype(res->flow_type);
10754 if (!(flow_type_mask & (1 << flex_mask.flow_type))) {
10755 printf("Flow type %s not supported on port %d\n",
10756 res->flow_type, res->port_id);
10759 fdir_set_flex_mask(res->port_id, &flex_mask);
10760 cmd_reconfig_device_queue(res->port_id, 1, 1);
10763 cmdline_parse_token_string_t cmd_flow_director_flexmask =
10764 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
10765 flow_director_flexmask,
10766 "flow_director_flex_mask");
10767 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
10768 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
10770 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
10771 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
10773 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
10774 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
10775 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
10776 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all");
10777 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
10778 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
10781 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
10782 .f = cmd_flow_director_flex_mask_parsed,
10784 .help_str = "flow_director_flex_mask ... : "
10785 "Set flow director's flex mask on NIC",
10787 (void *)&cmd_flow_director_flexmask,
10788 (void *)&cmd_flow_director_flexmask_port_id,
10789 (void *)&cmd_flow_director_flexmask_flow,
10790 (void *)&cmd_flow_director_flexmask_flow_type,
10791 (void *)&cmd_flow_director_flexmask_mask,
10796 /* *** deal with flow director flexible payload configuration *** */
10797 struct cmd_flow_director_flexpayload_result {
10798 cmdline_fixed_string_t flow_director_flexpayload;
10800 cmdline_fixed_string_t payload_layer;
10801 cmdline_fixed_string_t payload_cfg;
10805 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
10808 const char *p, *p0 = q_arg;
10810 unsigned long int_fld;
10811 char *str_fld[max_num];
10816 p = strchr(p0, '(');
10820 p0 = strchr(p, ')');
10825 if (size >= sizeof(s))
10828 snprintf(s, sizeof(s), "%.*s", size, p);
10829 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
10830 if (ret < 0 || ret > max_num)
10832 for (i = 0; i < ret; i++) {
10834 int_fld = strtoul(str_fld[i], &end, 0);
10835 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
10837 offsets[i] = (uint16_t)int_fld;
10843 cmd_flow_director_flxpld_parsed(void *parsed_result,
10844 __attribute__((unused)) struct cmdline *cl,
10845 __attribute__((unused)) void *data)
10847 struct cmd_flow_director_flexpayload_result *res = parsed_result;
10848 struct rte_eth_flex_payload_cfg flex_cfg;
10849 struct rte_port *port;
10852 if (res->port_id > nb_ports) {
10853 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
10857 port = &ports[res->port_id];
10858 /** Check if the port is not started **/
10859 if (port->port_status != RTE_PORT_STOPPED) {
10860 printf("Please stop port %d first\n", res->port_id);
10864 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
10866 if (!strcmp(res->payload_layer, "raw"))
10867 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
10868 else if (!strcmp(res->payload_layer, "l2"))
10869 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
10870 else if (!strcmp(res->payload_layer, "l3"))
10871 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
10872 else if (!strcmp(res->payload_layer, "l4"))
10873 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
10875 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
10876 RTE_ETH_FDIR_MAX_FLEXLEN);
10878 printf("error: Cannot parse flex payload input.\n");
10882 fdir_set_flex_payload(res->port_id, &flex_cfg);
10883 cmd_reconfig_device_queue(res->port_id, 1, 1);
10886 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
10887 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10888 flow_director_flexpayload,
10889 "flow_director_flex_payload");
10890 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
10891 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10893 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
10894 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10895 payload_layer, "raw#l2#l3#l4");
10896 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
10897 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10898 payload_cfg, NULL);
10900 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
10901 .f = cmd_flow_director_flxpld_parsed,
10903 .help_str = "flow_director_flexpayload ... : "
10904 "Set flow director's flex payload on NIC",
10906 (void *)&cmd_flow_director_flexpayload,
10907 (void *)&cmd_flow_director_flexpayload_port_id,
10908 (void *)&cmd_flow_director_flexpayload_payload_layer,
10909 (void *)&cmd_flow_director_flexpayload_payload_cfg,
10914 /* Generic flow interface command. */
10915 extern cmdline_parse_inst_t cmd_flow;
10917 /* *** Classification Filters Control *** */
10918 /* *** Get symmetric hash enable per port *** */
10919 struct cmd_get_sym_hash_ena_per_port_result {
10920 cmdline_fixed_string_t get_sym_hash_ena_per_port;
10925 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
10926 __rte_unused struct cmdline *cl,
10927 __rte_unused void *data)
10929 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
10930 struct rte_eth_hash_filter_info info;
10933 if (rte_eth_dev_filter_supported(res->port_id,
10934 RTE_ETH_FILTER_HASH) < 0) {
10935 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
10940 memset(&info, 0, sizeof(info));
10941 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
10942 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
10943 RTE_ETH_FILTER_GET, &info);
10946 printf("Cannot get symmetric hash enable per port "
10947 "on port %u\n", res->port_id);
10951 printf("Symmetric hash is %s on port %u\n", info.info.enable ?
10952 "enabled" : "disabled", res->port_id);
10955 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
10956 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
10957 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
10958 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
10959 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
10962 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
10963 .f = cmd_get_sym_hash_per_port_parsed,
10965 .help_str = "get_sym_hash_ena_per_port <port_id>",
10967 (void *)&cmd_get_sym_hash_ena_per_port_all,
10968 (void *)&cmd_get_sym_hash_ena_per_port_port_id,
10973 /* *** Set symmetric hash enable per port *** */
10974 struct cmd_set_sym_hash_ena_per_port_result {
10975 cmdline_fixed_string_t set_sym_hash_ena_per_port;
10976 cmdline_fixed_string_t enable;
10981 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
10982 __rte_unused struct cmdline *cl,
10983 __rte_unused void *data)
10985 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
10986 struct rte_eth_hash_filter_info info;
10989 if (rte_eth_dev_filter_supported(res->port_id,
10990 RTE_ETH_FILTER_HASH) < 0) {
10991 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
10996 memset(&info, 0, sizeof(info));
10997 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
10998 if (!strcmp(res->enable, "enable"))
10999 info.info.enable = 1;
11000 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11001 RTE_ETH_FILTER_SET, &info);
11003 printf("Cannot set symmetric hash enable per port on "
11004 "port %u\n", res->port_id);
11007 printf("Symmetric hash has been set to %s on port %u\n",
11008 res->enable, res->port_id);
11011 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
11012 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
11013 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
11014 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
11015 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
11017 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
11018 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
11019 enable, "enable#disable");
11021 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
11022 .f = cmd_set_sym_hash_per_port_parsed,
11024 .help_str = "set_sym_hash_ena_per_port <port_id> enable|disable",
11026 (void *)&cmd_set_sym_hash_ena_per_port_all,
11027 (void *)&cmd_set_sym_hash_ena_per_port_port_id,
11028 (void *)&cmd_set_sym_hash_ena_per_port_enable,
11033 /* Get global config of hash function */
11034 struct cmd_get_hash_global_config_result {
11035 cmdline_fixed_string_t get_hash_global_config;
11040 flowtype_to_str(uint16_t ftype)
11046 } ftype_table[] = {
11047 {"ipv4", RTE_ETH_FLOW_IPV4},
11048 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
11049 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
11050 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
11051 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
11052 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
11053 {"ipv6", RTE_ETH_FLOW_IPV6},
11054 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
11055 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
11056 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
11057 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
11058 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
11059 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
11060 {"port", RTE_ETH_FLOW_PORT},
11061 {"vxlan", RTE_ETH_FLOW_VXLAN},
11062 {"geneve", RTE_ETH_FLOW_GENEVE},
11063 {"nvgre", RTE_ETH_FLOW_NVGRE},
11066 for (i = 0; i < RTE_DIM(ftype_table); i++) {
11067 if (ftype_table[i].ftype == ftype)
11068 return ftype_table[i].str;
11075 cmd_get_hash_global_config_parsed(void *parsed_result,
11076 __rte_unused struct cmdline *cl,
11077 __rte_unused void *data)
11079 struct cmd_get_hash_global_config_result *res = parsed_result;
11080 struct rte_eth_hash_filter_info info;
11081 uint32_t idx, offset;
11086 if (rte_eth_dev_filter_supported(res->port_id,
11087 RTE_ETH_FILTER_HASH) < 0) {
11088 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
11093 memset(&info, 0, sizeof(info));
11094 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
11095 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11096 RTE_ETH_FILTER_GET, &info);
11098 printf("Cannot get hash global configurations by port %d\n",
11103 switch (info.info.global_conf.hash_func) {
11104 case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
11105 printf("Hash function is Toeplitz\n");
11107 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
11108 printf("Hash function is Simple XOR\n");
11111 printf("Unknown hash function\n");
11115 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) {
11116 idx = i / UINT32_BIT;
11117 offset = i % UINT32_BIT;
11118 if (!(info.info.global_conf.valid_bit_mask[idx] &
11121 str = flowtype_to_str(i);
11124 printf("Symmetric hash is %s globally for flow type %s "
11126 ((info.info.global_conf.sym_hash_enable_mask[idx] &
11127 (1UL << offset)) ? "enabled" : "disabled"), str,
11132 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
11133 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
11134 get_hash_global_config, "get_hash_global_config");
11135 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
11136 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
11139 cmdline_parse_inst_t cmd_get_hash_global_config = {
11140 .f = cmd_get_hash_global_config_parsed,
11142 .help_str = "get_hash_global_config <port_id>",
11144 (void *)&cmd_get_hash_global_config_all,
11145 (void *)&cmd_get_hash_global_config_port_id,
11150 /* Set global config of hash function */
11151 struct cmd_set_hash_global_config_result {
11152 cmdline_fixed_string_t set_hash_global_config;
11154 cmdline_fixed_string_t hash_func;
11155 cmdline_fixed_string_t flow_type;
11156 cmdline_fixed_string_t enable;
11160 cmd_set_hash_global_config_parsed(void *parsed_result,
11161 __rte_unused struct cmdline *cl,
11162 __rte_unused void *data)
11164 struct cmd_set_hash_global_config_result *res = parsed_result;
11165 struct rte_eth_hash_filter_info info;
11166 uint32_t ftype, idx, offset;
11169 if (rte_eth_dev_filter_supported(res->port_id,
11170 RTE_ETH_FILTER_HASH) < 0) {
11171 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
11175 memset(&info, 0, sizeof(info));
11176 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
11177 if (!strcmp(res->hash_func, "toeplitz"))
11178 info.info.global_conf.hash_func =
11179 RTE_ETH_HASH_FUNCTION_TOEPLITZ;
11180 else if (!strcmp(res->hash_func, "simple_xor"))
11181 info.info.global_conf.hash_func =
11182 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
11183 else if (!strcmp(res->hash_func, "default"))
11184 info.info.global_conf.hash_func =
11185 RTE_ETH_HASH_FUNCTION_DEFAULT;
11187 ftype = str2flowtype(res->flow_type);
11188 idx = ftype / (CHAR_BIT * sizeof(uint32_t));
11189 offset = ftype % (CHAR_BIT * sizeof(uint32_t));
11190 info.info.global_conf.valid_bit_mask[idx] |= (1UL << offset);
11191 if (!strcmp(res->enable, "enable"))
11192 info.info.global_conf.sym_hash_enable_mask[idx] |=
11194 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11195 RTE_ETH_FILTER_SET, &info);
11197 printf("Cannot set global hash configurations by port %d\n",
11200 printf("Global hash configurations have been set "
11201 "succcessfully by port %d\n", res->port_id);
11204 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
11205 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11206 set_hash_global_config, "set_hash_global_config");
11207 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
11208 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
11210 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
11211 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11212 hash_func, "toeplitz#simple_xor#default");
11213 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
11214 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11216 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
11217 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
11218 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
11219 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11220 enable, "enable#disable");
11222 cmdline_parse_inst_t cmd_set_hash_global_config = {
11223 .f = cmd_set_hash_global_config_parsed,
11225 .help_str = "set_hash_global_config <port_id> "
11226 "toeplitz|simple_xor|default "
11227 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
11228 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
11229 "l2_payload enable|disable",
11231 (void *)&cmd_set_hash_global_config_all,
11232 (void *)&cmd_set_hash_global_config_port_id,
11233 (void *)&cmd_set_hash_global_config_hash_func,
11234 (void *)&cmd_set_hash_global_config_flow_type,
11235 (void *)&cmd_set_hash_global_config_enable,
11240 /* Set hash input set */
11241 struct cmd_set_hash_input_set_result {
11242 cmdline_fixed_string_t set_hash_input_set;
11244 cmdline_fixed_string_t flow_type;
11245 cmdline_fixed_string_t inset_field;
11246 cmdline_fixed_string_t select;
11249 static enum rte_eth_input_set_field
11250 str2inset(char *string)
11254 static const struct {
11256 enum rte_eth_input_set_field inset;
11257 } inset_table[] = {
11258 {"ethertype", RTE_ETH_INPUT_SET_L2_ETHERTYPE},
11259 {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN},
11260 {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN},
11261 {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4},
11262 {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4},
11263 {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS},
11264 {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO},
11265 {"ipv4-ttl", RTE_ETH_INPUT_SET_L3_IP4_TTL},
11266 {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6},
11267 {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6},
11268 {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC},
11269 {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER},
11270 {"ipv6-hop-limits", RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS},
11271 {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT},
11272 {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT},
11273 {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT},
11274 {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT},
11275 {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT},
11276 {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT},
11277 {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG},
11278 {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY},
11279 {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY},
11280 {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD},
11281 {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD},
11282 {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD},
11283 {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD},
11284 {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD},
11285 {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD},
11286 {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD},
11287 {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD},
11288 {"none", RTE_ETH_INPUT_SET_NONE},
11291 for (i = 0; i < RTE_DIM(inset_table); i++) {
11292 if (!strcmp(string, inset_table[i].str))
11293 return inset_table[i].inset;
11296 return RTE_ETH_INPUT_SET_UNKNOWN;
11300 cmd_set_hash_input_set_parsed(void *parsed_result,
11301 __rte_unused struct cmdline *cl,
11302 __rte_unused void *data)
11304 struct cmd_set_hash_input_set_result *res = parsed_result;
11305 struct rte_eth_hash_filter_info info;
11307 memset(&info, 0, sizeof(info));
11308 info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT;
11309 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
11310 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
11311 info.info.input_set_conf.inset_size = 1;
11312 if (!strcmp(res->select, "select"))
11313 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
11314 else if (!strcmp(res->select, "add"))
11315 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
11316 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11317 RTE_ETH_FILTER_SET, &info);
11320 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd =
11321 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
11322 set_hash_input_set, "set_hash_input_set");
11323 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id =
11324 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result,
11326 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type =
11327 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
11329 cmdline_parse_token_string_t cmd_set_hash_input_set_field =
11330 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
11332 "ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
11333 "ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#"
11334 "udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#"
11335 "sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#"
11336 "fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#"
11338 cmdline_parse_token_string_t cmd_set_hash_input_set_select =
11339 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
11340 select, "select#add");
11342 cmdline_parse_inst_t cmd_set_hash_input_set = {
11343 .f = cmd_set_hash_input_set_parsed,
11345 .help_str = "set_hash_input_set <port_id> "
11346 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
11347 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload|<flowtype_id> "
11348 "ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|"
11349 "ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|"
11350 "tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|"
11351 "gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
11352 "fld-7th|fld-8th|none select|add",
11354 (void *)&cmd_set_hash_input_set_cmd,
11355 (void *)&cmd_set_hash_input_set_port_id,
11356 (void *)&cmd_set_hash_input_set_flow_type,
11357 (void *)&cmd_set_hash_input_set_field,
11358 (void *)&cmd_set_hash_input_set_select,
11363 /* Set flow director input set */
11364 struct cmd_set_fdir_input_set_result {
11365 cmdline_fixed_string_t set_fdir_input_set;
11367 cmdline_fixed_string_t flow_type;
11368 cmdline_fixed_string_t inset_field;
11369 cmdline_fixed_string_t select;
11373 cmd_set_fdir_input_set_parsed(void *parsed_result,
11374 __rte_unused struct cmdline *cl,
11375 __rte_unused void *data)
11377 struct cmd_set_fdir_input_set_result *res = parsed_result;
11378 struct rte_eth_fdir_filter_info info;
11380 memset(&info, 0, sizeof(info));
11381 info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT;
11382 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
11383 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
11384 info.info.input_set_conf.inset_size = 1;
11385 if (!strcmp(res->select, "select"))
11386 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
11387 else if (!strcmp(res->select, "add"))
11388 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
11389 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11390 RTE_ETH_FILTER_SET, &info);
11393 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd =
11394 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
11395 set_fdir_input_set, "set_fdir_input_set");
11396 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id =
11397 TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result,
11399 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type =
11400 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
11402 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
11403 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
11404 cmdline_parse_token_string_t cmd_set_fdir_input_set_field =
11405 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
11407 "ivlan#ethertype#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
11408 "ipv4-tos#ipv4-proto#ipv4-ttl#ipv6-tc#ipv6-next-header#"
11409 "ipv6-hop-limits#udp-src-port#udp-dst-port#"
11410 "tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#"
11411 "sctp-veri-tag#none");
11412 cmdline_parse_token_string_t cmd_set_fdir_input_set_select =
11413 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
11414 select, "select#add");
11416 cmdline_parse_inst_t cmd_set_fdir_input_set = {
11417 .f = cmd_set_fdir_input_set_parsed,
11419 .help_str = "set_fdir_input_set <port_id> "
11420 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
11421 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
11422 "ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|"
11423 "ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|ipv6-next-header|"
11424 "ipv6-hop-limits|udp-src-port|udp-dst-port|"
11425 "tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|"
11426 "sctp-veri-tag|none select|add",
11428 (void *)&cmd_set_fdir_input_set_cmd,
11429 (void *)&cmd_set_fdir_input_set_port_id,
11430 (void *)&cmd_set_fdir_input_set_flow_type,
11431 (void *)&cmd_set_fdir_input_set_field,
11432 (void *)&cmd_set_fdir_input_set_select,
11437 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
11438 struct cmd_mcast_addr_result {
11439 cmdline_fixed_string_t mcast_addr_cmd;
11440 cmdline_fixed_string_t what;
11442 struct ether_addr mc_addr;
11445 static void cmd_mcast_addr_parsed(void *parsed_result,
11446 __attribute__((unused)) struct cmdline *cl,
11447 __attribute__((unused)) void *data)
11449 struct cmd_mcast_addr_result *res = parsed_result;
11451 if (!is_multicast_ether_addr(&res->mc_addr)) {
11452 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
11453 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
11454 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
11455 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
11458 if (strcmp(res->what, "add") == 0)
11459 mcast_addr_add(res->port_num, &res->mc_addr);
11461 mcast_addr_remove(res->port_num, &res->mc_addr);
11464 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
11465 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
11466 mcast_addr_cmd, "mcast_addr");
11467 cmdline_parse_token_string_t cmd_mcast_addr_what =
11468 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
11470 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
11471 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT16);
11472 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
11473 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
11475 cmdline_parse_inst_t cmd_mcast_addr = {
11476 .f = cmd_mcast_addr_parsed,
11478 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
11479 "Add/Remove multicast MAC address on port_id",
11481 (void *)&cmd_mcast_addr_cmd,
11482 (void *)&cmd_mcast_addr_what,
11483 (void *)&cmd_mcast_addr_portnum,
11484 (void *)&cmd_mcast_addr_addr,
11489 /* l2 tunnel config
11490 * only support E-tag now.
11493 /* Ether type config */
11494 struct cmd_config_l2_tunnel_eth_type_result {
11495 cmdline_fixed_string_t port;
11496 cmdline_fixed_string_t config;
11497 cmdline_fixed_string_t all;
11499 cmdline_fixed_string_t l2_tunnel;
11500 cmdline_fixed_string_t l2_tunnel_type;
11501 cmdline_fixed_string_t eth_type;
11502 uint16_t eth_type_val;
11505 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port =
11506 TOKEN_STRING_INITIALIZER
11507 (struct cmd_config_l2_tunnel_eth_type_result,
11509 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config =
11510 TOKEN_STRING_INITIALIZER
11511 (struct cmd_config_l2_tunnel_eth_type_result,
11513 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str =
11514 TOKEN_STRING_INITIALIZER
11515 (struct cmd_config_l2_tunnel_eth_type_result,
11517 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id =
11518 TOKEN_NUM_INITIALIZER
11519 (struct cmd_config_l2_tunnel_eth_type_result,
11521 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel =
11522 TOKEN_STRING_INITIALIZER
11523 (struct cmd_config_l2_tunnel_eth_type_result,
11524 l2_tunnel, "l2-tunnel");
11525 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type =
11526 TOKEN_STRING_INITIALIZER
11527 (struct cmd_config_l2_tunnel_eth_type_result,
11528 l2_tunnel_type, "E-tag");
11529 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type =
11530 TOKEN_STRING_INITIALIZER
11531 (struct cmd_config_l2_tunnel_eth_type_result,
11532 eth_type, "ether-type");
11533 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val =
11534 TOKEN_NUM_INITIALIZER
11535 (struct cmd_config_l2_tunnel_eth_type_result,
11536 eth_type_val, UINT16);
11538 static enum rte_eth_tunnel_type
11539 str2fdir_l2_tunnel_type(char *string)
11543 static const struct {
11545 enum rte_eth_tunnel_type type;
11546 } l2_tunnel_type_str[] = {
11547 {"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG},
11550 for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) {
11551 if (!strcmp(l2_tunnel_type_str[i].str, string))
11552 return l2_tunnel_type_str[i].type;
11554 return RTE_TUNNEL_TYPE_NONE;
11557 /* ether type config for all ports */
11559 cmd_config_l2_tunnel_eth_type_all_parsed
11560 (void *parsed_result,
11561 __attribute__((unused)) struct cmdline *cl,
11562 __attribute__((unused)) void *data)
11564 struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result;
11565 struct rte_eth_l2_tunnel_conf entry;
11568 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
11569 entry.ether_type = res->eth_type_val;
11571 RTE_ETH_FOREACH_DEV(pid) {
11572 rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry);
11576 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = {
11577 .f = cmd_config_l2_tunnel_eth_type_all_parsed,
11579 .help_str = "port config all l2-tunnel E-tag ether-type <value>",
11581 (void *)&cmd_config_l2_tunnel_eth_type_port,
11582 (void *)&cmd_config_l2_tunnel_eth_type_config,
11583 (void *)&cmd_config_l2_tunnel_eth_type_all_str,
11584 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
11585 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
11586 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
11587 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
11592 /* ether type config for a specific port */
11594 cmd_config_l2_tunnel_eth_type_specific_parsed(
11595 void *parsed_result,
11596 __attribute__((unused)) struct cmdline *cl,
11597 __attribute__((unused)) void *data)
11599 struct cmd_config_l2_tunnel_eth_type_result *res =
11601 struct rte_eth_l2_tunnel_conf entry;
11603 if (port_id_is_invalid(res->id, ENABLED_WARN))
11606 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
11607 entry.ether_type = res->eth_type_val;
11609 rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry);
11612 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = {
11613 .f = cmd_config_l2_tunnel_eth_type_specific_parsed,
11615 .help_str = "port config <port_id> l2-tunnel E-tag ether-type <value>",
11617 (void *)&cmd_config_l2_tunnel_eth_type_port,
11618 (void *)&cmd_config_l2_tunnel_eth_type_config,
11619 (void *)&cmd_config_l2_tunnel_eth_type_id,
11620 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
11621 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
11622 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
11623 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
11628 /* Enable/disable l2 tunnel */
11629 struct cmd_config_l2_tunnel_en_dis_result {
11630 cmdline_fixed_string_t port;
11631 cmdline_fixed_string_t config;
11632 cmdline_fixed_string_t all;
11634 cmdline_fixed_string_t l2_tunnel;
11635 cmdline_fixed_string_t l2_tunnel_type;
11636 cmdline_fixed_string_t en_dis;
11639 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port =
11640 TOKEN_STRING_INITIALIZER
11641 (struct cmd_config_l2_tunnel_en_dis_result,
11643 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config =
11644 TOKEN_STRING_INITIALIZER
11645 (struct cmd_config_l2_tunnel_en_dis_result,
11647 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str =
11648 TOKEN_STRING_INITIALIZER
11649 (struct cmd_config_l2_tunnel_en_dis_result,
11651 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id =
11652 TOKEN_NUM_INITIALIZER
11653 (struct cmd_config_l2_tunnel_en_dis_result,
11655 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel =
11656 TOKEN_STRING_INITIALIZER
11657 (struct cmd_config_l2_tunnel_en_dis_result,
11658 l2_tunnel, "l2-tunnel");
11659 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type =
11660 TOKEN_STRING_INITIALIZER
11661 (struct cmd_config_l2_tunnel_en_dis_result,
11662 l2_tunnel_type, "E-tag");
11663 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis =
11664 TOKEN_STRING_INITIALIZER
11665 (struct cmd_config_l2_tunnel_en_dis_result,
11666 en_dis, "enable#disable");
11668 /* enable/disable l2 tunnel for all ports */
11670 cmd_config_l2_tunnel_en_dis_all_parsed(
11671 void *parsed_result,
11672 __attribute__((unused)) struct cmdline *cl,
11673 __attribute__((unused)) void *data)
11675 struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result;
11676 struct rte_eth_l2_tunnel_conf entry;
11680 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
11682 if (!strcmp("enable", res->en_dis))
11687 RTE_ETH_FOREACH_DEV(pid) {
11688 rte_eth_dev_l2_tunnel_offload_set(pid,
11690 ETH_L2_TUNNEL_ENABLE_MASK,
11695 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = {
11696 .f = cmd_config_l2_tunnel_en_dis_all_parsed,
11698 .help_str = "port config all l2-tunnel E-tag enable|disable",
11700 (void *)&cmd_config_l2_tunnel_en_dis_port,
11701 (void *)&cmd_config_l2_tunnel_en_dis_config,
11702 (void *)&cmd_config_l2_tunnel_en_dis_all_str,
11703 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
11704 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
11705 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
11710 /* enable/disable l2 tunnel for a port */
11712 cmd_config_l2_tunnel_en_dis_specific_parsed(
11713 void *parsed_result,
11714 __attribute__((unused)) struct cmdline *cl,
11715 __attribute__((unused)) void *data)
11717 struct cmd_config_l2_tunnel_en_dis_result *res =
11719 struct rte_eth_l2_tunnel_conf entry;
11721 if (port_id_is_invalid(res->id, ENABLED_WARN))
11724 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
11726 if (!strcmp("enable", res->en_dis))
11727 rte_eth_dev_l2_tunnel_offload_set(res->id,
11729 ETH_L2_TUNNEL_ENABLE_MASK,
11732 rte_eth_dev_l2_tunnel_offload_set(res->id,
11734 ETH_L2_TUNNEL_ENABLE_MASK,
11738 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = {
11739 .f = cmd_config_l2_tunnel_en_dis_specific_parsed,
11741 .help_str = "port config <port_id> l2-tunnel E-tag enable|disable",
11743 (void *)&cmd_config_l2_tunnel_en_dis_port,
11744 (void *)&cmd_config_l2_tunnel_en_dis_config,
11745 (void *)&cmd_config_l2_tunnel_en_dis_id,
11746 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
11747 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
11748 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
11753 /* E-tag configuration */
11755 /* Common result structure for all E-tag configuration */
11756 struct cmd_config_e_tag_result {
11757 cmdline_fixed_string_t e_tag;
11758 cmdline_fixed_string_t set;
11759 cmdline_fixed_string_t insertion;
11760 cmdline_fixed_string_t stripping;
11761 cmdline_fixed_string_t forwarding;
11762 cmdline_fixed_string_t filter;
11763 cmdline_fixed_string_t add;
11764 cmdline_fixed_string_t del;
11765 cmdline_fixed_string_t on;
11766 cmdline_fixed_string_t off;
11767 cmdline_fixed_string_t on_off;
11768 cmdline_fixed_string_t port_tag_id;
11769 uint32_t port_tag_id_val;
11770 cmdline_fixed_string_t e_tag_id;
11771 uint16_t e_tag_id_val;
11772 cmdline_fixed_string_t dst_pool;
11773 uint8_t dst_pool_val;
11774 cmdline_fixed_string_t port;
11776 cmdline_fixed_string_t vf;
11780 /* Common CLI fields for all E-tag configuration */
11781 cmdline_parse_token_string_t cmd_config_e_tag_e_tag =
11782 TOKEN_STRING_INITIALIZER
11783 (struct cmd_config_e_tag_result,
11785 cmdline_parse_token_string_t cmd_config_e_tag_set =
11786 TOKEN_STRING_INITIALIZER
11787 (struct cmd_config_e_tag_result,
11789 cmdline_parse_token_string_t cmd_config_e_tag_insertion =
11790 TOKEN_STRING_INITIALIZER
11791 (struct cmd_config_e_tag_result,
11792 insertion, "insertion");
11793 cmdline_parse_token_string_t cmd_config_e_tag_stripping =
11794 TOKEN_STRING_INITIALIZER
11795 (struct cmd_config_e_tag_result,
11796 stripping, "stripping");
11797 cmdline_parse_token_string_t cmd_config_e_tag_forwarding =
11798 TOKEN_STRING_INITIALIZER
11799 (struct cmd_config_e_tag_result,
11800 forwarding, "forwarding");
11801 cmdline_parse_token_string_t cmd_config_e_tag_filter =
11802 TOKEN_STRING_INITIALIZER
11803 (struct cmd_config_e_tag_result,
11805 cmdline_parse_token_string_t cmd_config_e_tag_add =
11806 TOKEN_STRING_INITIALIZER
11807 (struct cmd_config_e_tag_result,
11809 cmdline_parse_token_string_t cmd_config_e_tag_del =
11810 TOKEN_STRING_INITIALIZER
11811 (struct cmd_config_e_tag_result,
11813 cmdline_parse_token_string_t cmd_config_e_tag_on =
11814 TOKEN_STRING_INITIALIZER
11815 (struct cmd_config_e_tag_result,
11817 cmdline_parse_token_string_t cmd_config_e_tag_off =
11818 TOKEN_STRING_INITIALIZER
11819 (struct cmd_config_e_tag_result,
11821 cmdline_parse_token_string_t cmd_config_e_tag_on_off =
11822 TOKEN_STRING_INITIALIZER
11823 (struct cmd_config_e_tag_result,
11825 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id =
11826 TOKEN_STRING_INITIALIZER
11827 (struct cmd_config_e_tag_result,
11828 port_tag_id, "port-tag-id");
11829 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val =
11830 TOKEN_NUM_INITIALIZER
11831 (struct cmd_config_e_tag_result,
11832 port_tag_id_val, UINT32);
11833 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id =
11834 TOKEN_STRING_INITIALIZER
11835 (struct cmd_config_e_tag_result,
11836 e_tag_id, "e-tag-id");
11837 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val =
11838 TOKEN_NUM_INITIALIZER
11839 (struct cmd_config_e_tag_result,
11840 e_tag_id_val, UINT16);
11841 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool =
11842 TOKEN_STRING_INITIALIZER
11843 (struct cmd_config_e_tag_result,
11844 dst_pool, "dst-pool");
11845 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val =
11846 TOKEN_NUM_INITIALIZER
11847 (struct cmd_config_e_tag_result,
11848 dst_pool_val, UINT8);
11849 cmdline_parse_token_string_t cmd_config_e_tag_port =
11850 TOKEN_STRING_INITIALIZER
11851 (struct cmd_config_e_tag_result,
11853 cmdline_parse_token_num_t cmd_config_e_tag_port_id =
11854 TOKEN_NUM_INITIALIZER
11855 (struct cmd_config_e_tag_result,
11857 cmdline_parse_token_string_t cmd_config_e_tag_vf =
11858 TOKEN_STRING_INITIALIZER
11859 (struct cmd_config_e_tag_result,
11861 cmdline_parse_token_num_t cmd_config_e_tag_vf_id =
11862 TOKEN_NUM_INITIALIZER
11863 (struct cmd_config_e_tag_result,
11866 /* E-tag insertion configuration */
11868 cmd_config_e_tag_insertion_en_parsed(
11869 void *parsed_result,
11870 __attribute__((unused)) struct cmdline *cl,
11871 __attribute__((unused)) void *data)
11873 struct cmd_config_e_tag_result *res =
11875 struct rte_eth_l2_tunnel_conf entry;
11877 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11880 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
11881 entry.tunnel_id = res->port_tag_id_val;
11882 entry.vf_id = res->vf_id;
11883 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
11885 ETH_L2_TUNNEL_INSERTION_MASK,
11890 cmd_config_e_tag_insertion_dis_parsed(
11891 void *parsed_result,
11892 __attribute__((unused)) struct cmdline *cl,
11893 __attribute__((unused)) void *data)
11895 struct cmd_config_e_tag_result *res =
11897 struct rte_eth_l2_tunnel_conf entry;
11899 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11902 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
11903 entry.vf_id = res->vf_id;
11905 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
11907 ETH_L2_TUNNEL_INSERTION_MASK,
11911 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = {
11912 .f = cmd_config_e_tag_insertion_en_parsed,
11914 .help_str = "E-tag ... : E-tag insertion enable",
11916 (void *)&cmd_config_e_tag_e_tag,
11917 (void *)&cmd_config_e_tag_set,
11918 (void *)&cmd_config_e_tag_insertion,
11919 (void *)&cmd_config_e_tag_on,
11920 (void *)&cmd_config_e_tag_port_tag_id,
11921 (void *)&cmd_config_e_tag_port_tag_id_val,
11922 (void *)&cmd_config_e_tag_port,
11923 (void *)&cmd_config_e_tag_port_id,
11924 (void *)&cmd_config_e_tag_vf,
11925 (void *)&cmd_config_e_tag_vf_id,
11930 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = {
11931 .f = cmd_config_e_tag_insertion_dis_parsed,
11933 .help_str = "E-tag ... : E-tag insertion disable",
11935 (void *)&cmd_config_e_tag_e_tag,
11936 (void *)&cmd_config_e_tag_set,
11937 (void *)&cmd_config_e_tag_insertion,
11938 (void *)&cmd_config_e_tag_off,
11939 (void *)&cmd_config_e_tag_port,
11940 (void *)&cmd_config_e_tag_port_id,
11941 (void *)&cmd_config_e_tag_vf,
11942 (void *)&cmd_config_e_tag_vf_id,
11947 /* E-tag stripping configuration */
11949 cmd_config_e_tag_stripping_parsed(
11950 void *parsed_result,
11951 __attribute__((unused)) struct cmdline *cl,
11952 __attribute__((unused)) void *data)
11954 struct cmd_config_e_tag_result *res =
11956 struct rte_eth_l2_tunnel_conf entry;
11958 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11961 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
11963 if (!strcmp(res->on_off, "on"))
11964 rte_eth_dev_l2_tunnel_offload_set
11967 ETH_L2_TUNNEL_STRIPPING_MASK,
11970 rte_eth_dev_l2_tunnel_offload_set
11973 ETH_L2_TUNNEL_STRIPPING_MASK,
11977 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = {
11978 .f = cmd_config_e_tag_stripping_parsed,
11980 .help_str = "E-tag ... : E-tag stripping enable/disable",
11982 (void *)&cmd_config_e_tag_e_tag,
11983 (void *)&cmd_config_e_tag_set,
11984 (void *)&cmd_config_e_tag_stripping,
11985 (void *)&cmd_config_e_tag_on_off,
11986 (void *)&cmd_config_e_tag_port,
11987 (void *)&cmd_config_e_tag_port_id,
11992 /* E-tag forwarding configuration */
11994 cmd_config_e_tag_forwarding_parsed(
11995 void *parsed_result,
11996 __attribute__((unused)) struct cmdline *cl,
11997 __attribute__((unused)) void *data)
11999 struct cmd_config_e_tag_result *res = parsed_result;
12000 struct rte_eth_l2_tunnel_conf entry;
12002 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12005 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12007 if (!strcmp(res->on_off, "on"))
12008 rte_eth_dev_l2_tunnel_offload_set
12011 ETH_L2_TUNNEL_FORWARDING_MASK,
12014 rte_eth_dev_l2_tunnel_offload_set
12017 ETH_L2_TUNNEL_FORWARDING_MASK,
12021 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = {
12022 .f = cmd_config_e_tag_forwarding_parsed,
12024 .help_str = "E-tag ... : E-tag forwarding enable/disable",
12026 (void *)&cmd_config_e_tag_e_tag,
12027 (void *)&cmd_config_e_tag_set,
12028 (void *)&cmd_config_e_tag_forwarding,
12029 (void *)&cmd_config_e_tag_on_off,
12030 (void *)&cmd_config_e_tag_port,
12031 (void *)&cmd_config_e_tag_port_id,
12036 /* E-tag filter configuration */
12038 cmd_config_e_tag_filter_add_parsed(
12039 void *parsed_result,
12040 __attribute__((unused)) struct cmdline *cl,
12041 __attribute__((unused)) void *data)
12043 struct cmd_config_e_tag_result *res = parsed_result;
12044 struct rte_eth_l2_tunnel_conf entry;
12047 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12050 if (res->e_tag_id_val > 0x3fff) {
12051 printf("e-tag-id must be equal or less than 0x3fff.\n");
12055 ret = rte_eth_dev_filter_supported(res->port_id,
12056 RTE_ETH_FILTER_L2_TUNNEL);
12058 printf("E-tag filter is not supported on port %u.\n",
12063 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12064 entry.tunnel_id = res->e_tag_id_val;
12065 entry.pool = res->dst_pool_val;
12067 ret = rte_eth_dev_filter_ctrl(res->port_id,
12068 RTE_ETH_FILTER_L2_TUNNEL,
12069 RTE_ETH_FILTER_ADD,
12072 printf("E-tag filter programming error: (%s)\n",
12076 cmdline_parse_inst_t cmd_config_e_tag_filter_add = {
12077 .f = cmd_config_e_tag_filter_add_parsed,
12079 .help_str = "E-tag ... : E-tag filter add",
12081 (void *)&cmd_config_e_tag_e_tag,
12082 (void *)&cmd_config_e_tag_set,
12083 (void *)&cmd_config_e_tag_filter,
12084 (void *)&cmd_config_e_tag_add,
12085 (void *)&cmd_config_e_tag_e_tag_id,
12086 (void *)&cmd_config_e_tag_e_tag_id_val,
12087 (void *)&cmd_config_e_tag_dst_pool,
12088 (void *)&cmd_config_e_tag_dst_pool_val,
12089 (void *)&cmd_config_e_tag_port,
12090 (void *)&cmd_config_e_tag_port_id,
12096 cmd_config_e_tag_filter_del_parsed(
12097 void *parsed_result,
12098 __attribute__((unused)) struct cmdline *cl,
12099 __attribute__((unused)) void *data)
12101 struct cmd_config_e_tag_result *res = parsed_result;
12102 struct rte_eth_l2_tunnel_conf entry;
12105 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12108 if (res->e_tag_id_val > 0x3fff) {
12109 printf("e-tag-id must be less than 0x3fff.\n");
12113 ret = rte_eth_dev_filter_supported(res->port_id,
12114 RTE_ETH_FILTER_L2_TUNNEL);
12116 printf("E-tag filter is not supported on port %u.\n",
12121 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12122 entry.tunnel_id = res->e_tag_id_val;
12124 ret = rte_eth_dev_filter_ctrl(res->port_id,
12125 RTE_ETH_FILTER_L2_TUNNEL,
12126 RTE_ETH_FILTER_DELETE,
12129 printf("E-tag filter programming error: (%s)\n",
12133 cmdline_parse_inst_t cmd_config_e_tag_filter_del = {
12134 .f = cmd_config_e_tag_filter_del_parsed,
12136 .help_str = "E-tag ... : E-tag filter delete",
12138 (void *)&cmd_config_e_tag_e_tag,
12139 (void *)&cmd_config_e_tag_set,
12140 (void *)&cmd_config_e_tag_filter,
12141 (void *)&cmd_config_e_tag_del,
12142 (void *)&cmd_config_e_tag_e_tag_id,
12143 (void *)&cmd_config_e_tag_e_tag_id_val,
12144 (void *)&cmd_config_e_tag_port,
12145 (void *)&cmd_config_e_tag_port_id,
12150 /* vf vlan anti spoof configuration */
12152 /* Common result structure for vf vlan anti spoof */
12153 struct cmd_vf_vlan_anti_spoof_result {
12154 cmdline_fixed_string_t set;
12155 cmdline_fixed_string_t vf;
12156 cmdline_fixed_string_t vlan;
12157 cmdline_fixed_string_t antispoof;
12160 cmdline_fixed_string_t on_off;
12163 /* Common CLI fields for vf vlan anti spoof enable disable */
12164 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
12165 TOKEN_STRING_INITIALIZER
12166 (struct cmd_vf_vlan_anti_spoof_result,
12168 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
12169 TOKEN_STRING_INITIALIZER
12170 (struct cmd_vf_vlan_anti_spoof_result,
12172 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
12173 TOKEN_STRING_INITIALIZER
12174 (struct cmd_vf_vlan_anti_spoof_result,
12176 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
12177 TOKEN_STRING_INITIALIZER
12178 (struct cmd_vf_vlan_anti_spoof_result,
12179 antispoof, "antispoof");
12180 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
12181 TOKEN_NUM_INITIALIZER
12182 (struct cmd_vf_vlan_anti_spoof_result,
12184 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
12185 TOKEN_NUM_INITIALIZER
12186 (struct cmd_vf_vlan_anti_spoof_result,
12188 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
12189 TOKEN_STRING_INITIALIZER
12190 (struct cmd_vf_vlan_anti_spoof_result,
12194 cmd_set_vf_vlan_anti_spoof_parsed(
12195 void *parsed_result,
12196 __attribute__((unused)) struct cmdline *cl,
12197 __attribute__((unused)) void *data)
12199 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
12200 int ret = -ENOTSUP;
12202 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12204 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12207 #ifdef RTE_LIBRTE_IXGBE_PMD
12208 if (ret == -ENOTSUP)
12209 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
12210 res->vf_id, is_on);
12212 #ifdef RTE_LIBRTE_I40E_PMD
12213 if (ret == -ENOTSUP)
12214 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
12215 res->vf_id, is_on);
12217 #ifdef RTE_LIBRTE_BNXT_PMD
12218 if (ret == -ENOTSUP)
12219 ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
12220 res->vf_id, is_on);
12227 printf("invalid vf_id %d\n", res->vf_id);
12230 printf("invalid port_id %d\n", res->port_id);
12233 printf("function not implemented\n");
12236 printf("programming error: (%s)\n", strerror(-ret));
12240 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
12241 .f = cmd_set_vf_vlan_anti_spoof_parsed,
12243 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
12245 (void *)&cmd_vf_vlan_anti_spoof_set,
12246 (void *)&cmd_vf_vlan_anti_spoof_vf,
12247 (void *)&cmd_vf_vlan_anti_spoof_vlan,
12248 (void *)&cmd_vf_vlan_anti_spoof_antispoof,
12249 (void *)&cmd_vf_vlan_anti_spoof_port_id,
12250 (void *)&cmd_vf_vlan_anti_spoof_vf_id,
12251 (void *)&cmd_vf_vlan_anti_spoof_on_off,
12256 /* vf mac anti spoof configuration */
12258 /* Common result structure for vf mac anti spoof */
12259 struct cmd_vf_mac_anti_spoof_result {
12260 cmdline_fixed_string_t set;
12261 cmdline_fixed_string_t vf;
12262 cmdline_fixed_string_t mac;
12263 cmdline_fixed_string_t antispoof;
12266 cmdline_fixed_string_t on_off;
12269 /* Common CLI fields for vf mac anti spoof enable disable */
12270 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
12271 TOKEN_STRING_INITIALIZER
12272 (struct cmd_vf_mac_anti_spoof_result,
12274 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
12275 TOKEN_STRING_INITIALIZER
12276 (struct cmd_vf_mac_anti_spoof_result,
12278 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
12279 TOKEN_STRING_INITIALIZER
12280 (struct cmd_vf_mac_anti_spoof_result,
12282 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
12283 TOKEN_STRING_INITIALIZER
12284 (struct cmd_vf_mac_anti_spoof_result,
12285 antispoof, "antispoof");
12286 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
12287 TOKEN_NUM_INITIALIZER
12288 (struct cmd_vf_mac_anti_spoof_result,
12290 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
12291 TOKEN_NUM_INITIALIZER
12292 (struct cmd_vf_mac_anti_spoof_result,
12294 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
12295 TOKEN_STRING_INITIALIZER
12296 (struct cmd_vf_mac_anti_spoof_result,
12300 cmd_set_vf_mac_anti_spoof_parsed(
12301 void *parsed_result,
12302 __attribute__((unused)) struct cmdline *cl,
12303 __attribute__((unused)) void *data)
12305 struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
12306 int ret = -ENOTSUP;
12308 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12310 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12313 #ifdef RTE_LIBRTE_IXGBE_PMD
12314 if (ret == -ENOTSUP)
12315 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
12316 res->vf_id, is_on);
12318 #ifdef RTE_LIBRTE_I40E_PMD
12319 if (ret == -ENOTSUP)
12320 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
12321 res->vf_id, is_on);
12323 #ifdef RTE_LIBRTE_BNXT_PMD
12324 if (ret == -ENOTSUP)
12325 ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
12326 res->vf_id, is_on);
12333 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12336 printf("invalid port_id %d\n", res->port_id);
12339 printf("function not implemented\n");
12342 printf("programming error: (%s)\n", strerror(-ret));
12346 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
12347 .f = cmd_set_vf_mac_anti_spoof_parsed,
12349 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
12351 (void *)&cmd_vf_mac_anti_spoof_set,
12352 (void *)&cmd_vf_mac_anti_spoof_vf,
12353 (void *)&cmd_vf_mac_anti_spoof_mac,
12354 (void *)&cmd_vf_mac_anti_spoof_antispoof,
12355 (void *)&cmd_vf_mac_anti_spoof_port_id,
12356 (void *)&cmd_vf_mac_anti_spoof_vf_id,
12357 (void *)&cmd_vf_mac_anti_spoof_on_off,
12362 /* vf vlan strip queue configuration */
12364 /* Common result structure for vf mac anti spoof */
12365 struct cmd_vf_vlan_stripq_result {
12366 cmdline_fixed_string_t set;
12367 cmdline_fixed_string_t vf;
12368 cmdline_fixed_string_t vlan;
12369 cmdline_fixed_string_t stripq;
12372 cmdline_fixed_string_t on_off;
12375 /* Common CLI fields for vf vlan strip enable disable */
12376 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
12377 TOKEN_STRING_INITIALIZER
12378 (struct cmd_vf_vlan_stripq_result,
12380 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
12381 TOKEN_STRING_INITIALIZER
12382 (struct cmd_vf_vlan_stripq_result,
12384 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
12385 TOKEN_STRING_INITIALIZER
12386 (struct cmd_vf_vlan_stripq_result,
12388 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
12389 TOKEN_STRING_INITIALIZER
12390 (struct cmd_vf_vlan_stripq_result,
12392 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
12393 TOKEN_NUM_INITIALIZER
12394 (struct cmd_vf_vlan_stripq_result,
12396 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
12397 TOKEN_NUM_INITIALIZER
12398 (struct cmd_vf_vlan_stripq_result,
12400 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
12401 TOKEN_STRING_INITIALIZER
12402 (struct cmd_vf_vlan_stripq_result,
12406 cmd_set_vf_vlan_stripq_parsed(
12407 void *parsed_result,
12408 __attribute__((unused)) struct cmdline *cl,
12409 __attribute__((unused)) void *data)
12411 struct cmd_vf_vlan_stripq_result *res = parsed_result;
12412 int ret = -ENOTSUP;
12414 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12416 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12419 #ifdef RTE_LIBRTE_IXGBE_PMD
12420 if (ret == -ENOTSUP)
12421 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
12422 res->vf_id, is_on);
12424 #ifdef RTE_LIBRTE_I40E_PMD
12425 if (ret == -ENOTSUP)
12426 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
12427 res->vf_id, is_on);
12429 #ifdef RTE_LIBRTE_BNXT_PMD
12430 if (ret == -ENOTSUP)
12431 ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
12432 res->vf_id, is_on);
12439 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12442 printf("invalid port_id %d\n", res->port_id);
12445 printf("function not implemented\n");
12448 printf("programming error: (%s)\n", strerror(-ret));
12452 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
12453 .f = cmd_set_vf_vlan_stripq_parsed,
12455 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
12457 (void *)&cmd_vf_vlan_stripq_set,
12458 (void *)&cmd_vf_vlan_stripq_vf,
12459 (void *)&cmd_vf_vlan_stripq_vlan,
12460 (void *)&cmd_vf_vlan_stripq_stripq,
12461 (void *)&cmd_vf_vlan_stripq_port_id,
12462 (void *)&cmd_vf_vlan_stripq_vf_id,
12463 (void *)&cmd_vf_vlan_stripq_on_off,
12468 /* vf vlan insert configuration */
12470 /* Common result structure for vf vlan insert */
12471 struct cmd_vf_vlan_insert_result {
12472 cmdline_fixed_string_t set;
12473 cmdline_fixed_string_t vf;
12474 cmdline_fixed_string_t vlan;
12475 cmdline_fixed_string_t insert;
12481 /* Common CLI fields for vf vlan insert enable disable */
12482 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
12483 TOKEN_STRING_INITIALIZER
12484 (struct cmd_vf_vlan_insert_result,
12486 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
12487 TOKEN_STRING_INITIALIZER
12488 (struct cmd_vf_vlan_insert_result,
12490 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
12491 TOKEN_STRING_INITIALIZER
12492 (struct cmd_vf_vlan_insert_result,
12494 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
12495 TOKEN_STRING_INITIALIZER
12496 (struct cmd_vf_vlan_insert_result,
12498 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
12499 TOKEN_NUM_INITIALIZER
12500 (struct cmd_vf_vlan_insert_result,
12502 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
12503 TOKEN_NUM_INITIALIZER
12504 (struct cmd_vf_vlan_insert_result,
12506 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
12507 TOKEN_NUM_INITIALIZER
12508 (struct cmd_vf_vlan_insert_result,
12512 cmd_set_vf_vlan_insert_parsed(
12513 void *parsed_result,
12514 __attribute__((unused)) struct cmdline *cl,
12515 __attribute__((unused)) void *data)
12517 struct cmd_vf_vlan_insert_result *res = parsed_result;
12518 int ret = -ENOTSUP;
12520 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12523 #ifdef RTE_LIBRTE_IXGBE_PMD
12524 if (ret == -ENOTSUP)
12525 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
12528 #ifdef RTE_LIBRTE_I40E_PMD
12529 if (ret == -ENOTSUP)
12530 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
12533 #ifdef RTE_LIBRTE_BNXT_PMD
12534 if (ret == -ENOTSUP)
12535 ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
12543 printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id);
12546 printf("invalid port_id %d\n", res->port_id);
12549 printf("function not implemented\n");
12552 printf("programming error: (%s)\n", strerror(-ret));
12556 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
12557 .f = cmd_set_vf_vlan_insert_parsed,
12559 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
12561 (void *)&cmd_vf_vlan_insert_set,
12562 (void *)&cmd_vf_vlan_insert_vf,
12563 (void *)&cmd_vf_vlan_insert_vlan,
12564 (void *)&cmd_vf_vlan_insert_insert,
12565 (void *)&cmd_vf_vlan_insert_port_id,
12566 (void *)&cmd_vf_vlan_insert_vf_id,
12567 (void *)&cmd_vf_vlan_insert_vlan_id,
12572 /* tx loopback configuration */
12574 /* Common result structure for tx loopback */
12575 struct cmd_tx_loopback_result {
12576 cmdline_fixed_string_t set;
12577 cmdline_fixed_string_t tx;
12578 cmdline_fixed_string_t loopback;
12580 cmdline_fixed_string_t on_off;
12583 /* Common CLI fields for tx loopback enable disable */
12584 cmdline_parse_token_string_t cmd_tx_loopback_set =
12585 TOKEN_STRING_INITIALIZER
12586 (struct cmd_tx_loopback_result,
12588 cmdline_parse_token_string_t cmd_tx_loopback_tx =
12589 TOKEN_STRING_INITIALIZER
12590 (struct cmd_tx_loopback_result,
12592 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
12593 TOKEN_STRING_INITIALIZER
12594 (struct cmd_tx_loopback_result,
12595 loopback, "loopback");
12596 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
12597 TOKEN_NUM_INITIALIZER
12598 (struct cmd_tx_loopback_result,
12600 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
12601 TOKEN_STRING_INITIALIZER
12602 (struct cmd_tx_loopback_result,
12606 cmd_set_tx_loopback_parsed(
12607 void *parsed_result,
12608 __attribute__((unused)) struct cmdline *cl,
12609 __attribute__((unused)) void *data)
12611 struct cmd_tx_loopback_result *res = parsed_result;
12612 int ret = -ENOTSUP;
12614 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12616 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12619 #ifdef RTE_LIBRTE_IXGBE_PMD
12620 if (ret == -ENOTSUP)
12621 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
12623 #ifdef RTE_LIBRTE_I40E_PMD
12624 if (ret == -ENOTSUP)
12625 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
12627 #ifdef RTE_LIBRTE_BNXT_PMD
12628 if (ret == -ENOTSUP)
12629 ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
12636 printf("invalid is_on %d\n", is_on);
12639 printf("invalid port_id %d\n", res->port_id);
12642 printf("function not implemented\n");
12645 printf("programming error: (%s)\n", strerror(-ret));
12649 cmdline_parse_inst_t cmd_set_tx_loopback = {
12650 .f = cmd_set_tx_loopback_parsed,
12652 .help_str = "set tx loopback <port_id> on|off",
12654 (void *)&cmd_tx_loopback_set,
12655 (void *)&cmd_tx_loopback_tx,
12656 (void *)&cmd_tx_loopback_loopback,
12657 (void *)&cmd_tx_loopback_port_id,
12658 (void *)&cmd_tx_loopback_on_off,
12663 /* all queues drop enable configuration */
12665 /* Common result structure for all queues drop enable */
12666 struct cmd_all_queues_drop_en_result {
12667 cmdline_fixed_string_t set;
12668 cmdline_fixed_string_t all;
12669 cmdline_fixed_string_t queues;
12670 cmdline_fixed_string_t drop;
12672 cmdline_fixed_string_t on_off;
12675 /* Common CLI fields for tx loopback enable disable */
12676 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
12677 TOKEN_STRING_INITIALIZER
12678 (struct cmd_all_queues_drop_en_result,
12680 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
12681 TOKEN_STRING_INITIALIZER
12682 (struct cmd_all_queues_drop_en_result,
12684 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
12685 TOKEN_STRING_INITIALIZER
12686 (struct cmd_all_queues_drop_en_result,
12688 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
12689 TOKEN_STRING_INITIALIZER
12690 (struct cmd_all_queues_drop_en_result,
12692 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
12693 TOKEN_NUM_INITIALIZER
12694 (struct cmd_all_queues_drop_en_result,
12696 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
12697 TOKEN_STRING_INITIALIZER
12698 (struct cmd_all_queues_drop_en_result,
12702 cmd_set_all_queues_drop_en_parsed(
12703 void *parsed_result,
12704 __attribute__((unused)) struct cmdline *cl,
12705 __attribute__((unused)) void *data)
12707 struct cmd_all_queues_drop_en_result *res = parsed_result;
12708 int ret = -ENOTSUP;
12709 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12711 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12714 #ifdef RTE_LIBRTE_IXGBE_PMD
12715 if (ret == -ENOTSUP)
12716 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
12718 #ifdef RTE_LIBRTE_BNXT_PMD
12719 if (ret == -ENOTSUP)
12720 ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
12726 printf("invalid is_on %d\n", is_on);
12729 printf("invalid port_id %d\n", res->port_id);
12732 printf("function not implemented\n");
12735 printf("programming error: (%s)\n", strerror(-ret));
12739 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
12740 .f = cmd_set_all_queues_drop_en_parsed,
12742 .help_str = "set all queues drop <port_id> on|off",
12744 (void *)&cmd_all_queues_drop_en_set,
12745 (void *)&cmd_all_queues_drop_en_all,
12746 (void *)&cmd_all_queues_drop_en_queues,
12747 (void *)&cmd_all_queues_drop_en_drop,
12748 (void *)&cmd_all_queues_drop_en_port_id,
12749 (void *)&cmd_all_queues_drop_en_on_off,
12754 /* vf split drop enable configuration */
12756 /* Common result structure for vf split drop enable */
12757 struct cmd_vf_split_drop_en_result {
12758 cmdline_fixed_string_t set;
12759 cmdline_fixed_string_t vf;
12760 cmdline_fixed_string_t split;
12761 cmdline_fixed_string_t drop;
12764 cmdline_fixed_string_t on_off;
12767 /* Common CLI fields for vf split drop enable disable */
12768 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
12769 TOKEN_STRING_INITIALIZER
12770 (struct cmd_vf_split_drop_en_result,
12772 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
12773 TOKEN_STRING_INITIALIZER
12774 (struct cmd_vf_split_drop_en_result,
12776 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
12777 TOKEN_STRING_INITIALIZER
12778 (struct cmd_vf_split_drop_en_result,
12780 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
12781 TOKEN_STRING_INITIALIZER
12782 (struct cmd_vf_split_drop_en_result,
12784 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
12785 TOKEN_NUM_INITIALIZER
12786 (struct cmd_vf_split_drop_en_result,
12788 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
12789 TOKEN_NUM_INITIALIZER
12790 (struct cmd_vf_split_drop_en_result,
12792 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
12793 TOKEN_STRING_INITIALIZER
12794 (struct cmd_vf_split_drop_en_result,
12798 cmd_set_vf_split_drop_en_parsed(
12799 void *parsed_result,
12800 __attribute__((unused)) struct cmdline *cl,
12801 __attribute__((unused)) void *data)
12803 struct cmd_vf_split_drop_en_result *res = parsed_result;
12804 int ret = -ENOTSUP;
12805 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12807 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12810 #ifdef RTE_LIBRTE_IXGBE_PMD
12811 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
12818 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12821 printf("invalid port_id %d\n", res->port_id);
12824 printf("not supported on port %d\n", res->port_id);
12827 printf("programming error: (%s)\n", strerror(-ret));
12831 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
12832 .f = cmd_set_vf_split_drop_en_parsed,
12834 .help_str = "set vf split drop <port_id> <vf_id> on|off",
12836 (void *)&cmd_vf_split_drop_en_set,
12837 (void *)&cmd_vf_split_drop_en_vf,
12838 (void *)&cmd_vf_split_drop_en_split,
12839 (void *)&cmd_vf_split_drop_en_drop,
12840 (void *)&cmd_vf_split_drop_en_port_id,
12841 (void *)&cmd_vf_split_drop_en_vf_id,
12842 (void *)&cmd_vf_split_drop_en_on_off,
12847 /* vf mac address configuration */
12849 /* Common result structure for vf mac address */
12850 struct cmd_set_vf_mac_addr_result {
12851 cmdline_fixed_string_t set;
12852 cmdline_fixed_string_t vf;
12853 cmdline_fixed_string_t mac;
12854 cmdline_fixed_string_t addr;
12857 struct ether_addr mac_addr;
12861 /* Common CLI fields for vf split drop enable disable */
12862 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
12863 TOKEN_STRING_INITIALIZER
12864 (struct cmd_set_vf_mac_addr_result,
12866 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
12867 TOKEN_STRING_INITIALIZER
12868 (struct cmd_set_vf_mac_addr_result,
12870 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
12871 TOKEN_STRING_INITIALIZER
12872 (struct cmd_set_vf_mac_addr_result,
12874 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
12875 TOKEN_STRING_INITIALIZER
12876 (struct cmd_set_vf_mac_addr_result,
12878 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
12879 TOKEN_NUM_INITIALIZER
12880 (struct cmd_set_vf_mac_addr_result,
12882 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
12883 TOKEN_NUM_INITIALIZER
12884 (struct cmd_set_vf_mac_addr_result,
12886 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
12887 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
12891 cmd_set_vf_mac_addr_parsed(
12892 void *parsed_result,
12893 __attribute__((unused)) struct cmdline *cl,
12894 __attribute__((unused)) void *data)
12896 struct cmd_set_vf_mac_addr_result *res = parsed_result;
12897 int ret = -ENOTSUP;
12899 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12902 #ifdef RTE_LIBRTE_IXGBE_PMD
12903 if (ret == -ENOTSUP)
12904 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
12907 #ifdef RTE_LIBRTE_I40E_PMD
12908 if (ret == -ENOTSUP)
12909 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
12912 #ifdef RTE_LIBRTE_BNXT_PMD
12913 if (ret == -ENOTSUP)
12914 ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
12922 printf("invalid vf_id %d or mac_addr\n", res->vf_id);
12925 printf("invalid port_id %d\n", res->port_id);
12928 printf("function not implemented\n");
12931 printf("programming error: (%s)\n", strerror(-ret));
12935 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
12936 .f = cmd_set_vf_mac_addr_parsed,
12938 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
12940 (void *)&cmd_set_vf_mac_addr_set,
12941 (void *)&cmd_set_vf_mac_addr_vf,
12942 (void *)&cmd_set_vf_mac_addr_mac,
12943 (void *)&cmd_set_vf_mac_addr_addr,
12944 (void *)&cmd_set_vf_mac_addr_port_id,
12945 (void *)&cmd_set_vf_mac_addr_vf_id,
12946 (void *)&cmd_set_vf_mac_addr_mac_addr,
12951 /* MACsec configuration */
12953 /* Common result structure for MACsec offload enable */
12954 struct cmd_macsec_offload_on_result {
12955 cmdline_fixed_string_t set;
12956 cmdline_fixed_string_t macsec;
12957 cmdline_fixed_string_t offload;
12959 cmdline_fixed_string_t on;
12960 cmdline_fixed_string_t encrypt;
12961 cmdline_fixed_string_t en_on_off;
12962 cmdline_fixed_string_t replay_protect;
12963 cmdline_fixed_string_t rp_on_off;
12966 /* Common CLI fields for MACsec offload disable */
12967 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
12968 TOKEN_STRING_INITIALIZER
12969 (struct cmd_macsec_offload_on_result,
12971 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
12972 TOKEN_STRING_INITIALIZER
12973 (struct cmd_macsec_offload_on_result,
12975 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
12976 TOKEN_STRING_INITIALIZER
12977 (struct cmd_macsec_offload_on_result,
12978 offload, "offload");
12979 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
12980 TOKEN_NUM_INITIALIZER
12981 (struct cmd_macsec_offload_on_result,
12983 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
12984 TOKEN_STRING_INITIALIZER
12985 (struct cmd_macsec_offload_on_result,
12987 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
12988 TOKEN_STRING_INITIALIZER
12989 (struct cmd_macsec_offload_on_result,
12990 encrypt, "encrypt");
12991 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
12992 TOKEN_STRING_INITIALIZER
12993 (struct cmd_macsec_offload_on_result,
12994 en_on_off, "on#off");
12995 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
12996 TOKEN_STRING_INITIALIZER
12997 (struct cmd_macsec_offload_on_result,
12998 replay_protect, "replay-protect");
12999 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
13000 TOKEN_STRING_INITIALIZER
13001 (struct cmd_macsec_offload_on_result,
13002 rp_on_off, "on#off");
13005 cmd_set_macsec_offload_on_parsed(
13006 void *parsed_result,
13007 __attribute__((unused)) struct cmdline *cl,
13008 __attribute__((unused)) void *data)
13010 struct cmd_macsec_offload_on_result *res = parsed_result;
13011 int ret = -ENOTSUP;
13012 portid_t port_id = res->port_id;
13013 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
13014 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
13016 if (port_id_is_invalid(port_id, ENABLED_WARN))
13018 if (!port_is_stopped(port_id)) {
13019 printf("Please stop port %d first\n", port_id);
13023 ports[port_id].dev_conf.txmode.offloads |= DEV_TX_OFFLOAD_MACSEC_INSERT;
13024 #ifdef RTE_LIBRTE_IXGBE_PMD
13025 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
13032 cmd_reconfig_device_queue(port_id, 1, 1);
13035 printf("invalid port_id %d\n", port_id);
13038 printf("not supported on port %d\n", port_id);
13041 printf("programming error: (%s)\n", strerror(-ret));
13045 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
13046 .f = cmd_set_macsec_offload_on_parsed,
13048 .help_str = "set macsec offload <port_id> on "
13049 "encrypt on|off replay-protect on|off",
13051 (void *)&cmd_macsec_offload_on_set,
13052 (void *)&cmd_macsec_offload_on_macsec,
13053 (void *)&cmd_macsec_offload_on_offload,
13054 (void *)&cmd_macsec_offload_on_port_id,
13055 (void *)&cmd_macsec_offload_on_on,
13056 (void *)&cmd_macsec_offload_on_encrypt,
13057 (void *)&cmd_macsec_offload_on_en_on_off,
13058 (void *)&cmd_macsec_offload_on_replay_protect,
13059 (void *)&cmd_macsec_offload_on_rp_on_off,
13064 /* Common result structure for MACsec offload disable */
13065 struct cmd_macsec_offload_off_result {
13066 cmdline_fixed_string_t set;
13067 cmdline_fixed_string_t macsec;
13068 cmdline_fixed_string_t offload;
13070 cmdline_fixed_string_t off;
13073 /* Common CLI fields for MACsec offload disable */
13074 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
13075 TOKEN_STRING_INITIALIZER
13076 (struct cmd_macsec_offload_off_result,
13078 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
13079 TOKEN_STRING_INITIALIZER
13080 (struct cmd_macsec_offload_off_result,
13082 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
13083 TOKEN_STRING_INITIALIZER
13084 (struct cmd_macsec_offload_off_result,
13085 offload, "offload");
13086 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
13087 TOKEN_NUM_INITIALIZER
13088 (struct cmd_macsec_offload_off_result,
13090 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
13091 TOKEN_STRING_INITIALIZER
13092 (struct cmd_macsec_offload_off_result,
13096 cmd_set_macsec_offload_off_parsed(
13097 void *parsed_result,
13098 __attribute__((unused)) struct cmdline *cl,
13099 __attribute__((unused)) void *data)
13101 struct cmd_macsec_offload_off_result *res = parsed_result;
13102 int ret = -ENOTSUP;
13103 portid_t port_id = res->port_id;
13105 if (port_id_is_invalid(port_id, ENABLED_WARN))
13107 if (!port_is_stopped(port_id)) {
13108 printf("Please stop port %d first\n", port_id);
13112 ports[port_id].dev_conf.txmode.offloads &=
13113 ~DEV_TX_OFFLOAD_MACSEC_INSERT;
13114 #ifdef RTE_LIBRTE_IXGBE_PMD
13115 ret = rte_pmd_ixgbe_macsec_disable(port_id);
13120 cmd_reconfig_device_queue(port_id, 1, 1);
13123 printf("invalid port_id %d\n", port_id);
13126 printf("not supported on port %d\n", port_id);
13129 printf("programming error: (%s)\n", strerror(-ret));
13133 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
13134 .f = cmd_set_macsec_offload_off_parsed,
13136 .help_str = "set macsec offload <port_id> off",
13138 (void *)&cmd_macsec_offload_off_set,
13139 (void *)&cmd_macsec_offload_off_macsec,
13140 (void *)&cmd_macsec_offload_off_offload,
13141 (void *)&cmd_macsec_offload_off_port_id,
13142 (void *)&cmd_macsec_offload_off_off,
13147 /* Common result structure for MACsec secure connection configure */
13148 struct cmd_macsec_sc_result {
13149 cmdline_fixed_string_t set;
13150 cmdline_fixed_string_t macsec;
13151 cmdline_fixed_string_t sc;
13152 cmdline_fixed_string_t tx_rx;
13154 struct ether_addr mac;
13158 /* Common CLI fields for MACsec secure connection configure */
13159 cmdline_parse_token_string_t cmd_macsec_sc_set =
13160 TOKEN_STRING_INITIALIZER
13161 (struct cmd_macsec_sc_result,
13163 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
13164 TOKEN_STRING_INITIALIZER
13165 (struct cmd_macsec_sc_result,
13167 cmdline_parse_token_string_t cmd_macsec_sc_sc =
13168 TOKEN_STRING_INITIALIZER
13169 (struct cmd_macsec_sc_result,
13171 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
13172 TOKEN_STRING_INITIALIZER
13173 (struct cmd_macsec_sc_result,
13175 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
13176 TOKEN_NUM_INITIALIZER
13177 (struct cmd_macsec_sc_result,
13179 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
13180 TOKEN_ETHERADDR_INITIALIZER
13181 (struct cmd_macsec_sc_result,
13183 cmdline_parse_token_num_t cmd_macsec_sc_pi =
13184 TOKEN_NUM_INITIALIZER
13185 (struct cmd_macsec_sc_result,
13189 cmd_set_macsec_sc_parsed(
13190 void *parsed_result,
13191 __attribute__((unused)) struct cmdline *cl,
13192 __attribute__((unused)) void *data)
13194 struct cmd_macsec_sc_result *res = parsed_result;
13195 int ret = -ENOTSUP;
13196 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
13198 #ifdef RTE_LIBRTE_IXGBE_PMD
13200 rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
13201 res->mac.addr_bytes) :
13202 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
13203 res->mac.addr_bytes, res->pi);
13205 RTE_SET_USED(is_tx);
13211 printf("invalid port_id %d\n", res->port_id);
13214 printf("not supported on port %d\n", res->port_id);
13217 printf("programming error: (%s)\n", strerror(-ret));
13221 cmdline_parse_inst_t cmd_set_macsec_sc = {
13222 .f = cmd_set_macsec_sc_parsed,
13224 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
13226 (void *)&cmd_macsec_sc_set,
13227 (void *)&cmd_macsec_sc_macsec,
13228 (void *)&cmd_macsec_sc_sc,
13229 (void *)&cmd_macsec_sc_tx_rx,
13230 (void *)&cmd_macsec_sc_port_id,
13231 (void *)&cmd_macsec_sc_mac,
13232 (void *)&cmd_macsec_sc_pi,
13237 /* Common result structure for MACsec secure connection configure */
13238 struct cmd_macsec_sa_result {
13239 cmdline_fixed_string_t set;
13240 cmdline_fixed_string_t macsec;
13241 cmdline_fixed_string_t sa;
13242 cmdline_fixed_string_t tx_rx;
13247 cmdline_fixed_string_t key;
13250 /* Common CLI fields for MACsec secure connection configure */
13251 cmdline_parse_token_string_t cmd_macsec_sa_set =
13252 TOKEN_STRING_INITIALIZER
13253 (struct cmd_macsec_sa_result,
13255 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
13256 TOKEN_STRING_INITIALIZER
13257 (struct cmd_macsec_sa_result,
13259 cmdline_parse_token_string_t cmd_macsec_sa_sa =
13260 TOKEN_STRING_INITIALIZER
13261 (struct cmd_macsec_sa_result,
13263 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
13264 TOKEN_STRING_INITIALIZER
13265 (struct cmd_macsec_sa_result,
13267 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
13268 TOKEN_NUM_INITIALIZER
13269 (struct cmd_macsec_sa_result,
13271 cmdline_parse_token_num_t cmd_macsec_sa_idx =
13272 TOKEN_NUM_INITIALIZER
13273 (struct cmd_macsec_sa_result,
13275 cmdline_parse_token_num_t cmd_macsec_sa_an =
13276 TOKEN_NUM_INITIALIZER
13277 (struct cmd_macsec_sa_result,
13279 cmdline_parse_token_num_t cmd_macsec_sa_pn =
13280 TOKEN_NUM_INITIALIZER
13281 (struct cmd_macsec_sa_result,
13283 cmdline_parse_token_string_t cmd_macsec_sa_key =
13284 TOKEN_STRING_INITIALIZER
13285 (struct cmd_macsec_sa_result,
13289 cmd_set_macsec_sa_parsed(
13290 void *parsed_result,
13291 __attribute__((unused)) struct cmdline *cl,
13292 __attribute__((unused)) void *data)
13294 struct cmd_macsec_sa_result *res = parsed_result;
13295 int ret = -ENOTSUP;
13296 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
13297 uint8_t key[16] = { 0 };
13303 key_len = strlen(res->key) / 2;
13307 for (i = 0; i < key_len; i++) {
13308 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
13311 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
13314 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
13317 #ifdef RTE_LIBRTE_IXGBE_PMD
13319 rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
13320 res->idx, res->an, res->pn, key) :
13321 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
13322 res->idx, res->an, res->pn, key);
13324 RTE_SET_USED(is_tx);
13331 printf("invalid idx %d or an %d\n", res->idx, res->an);
13334 printf("invalid port_id %d\n", res->port_id);
13337 printf("not supported on port %d\n", res->port_id);
13340 printf("programming error: (%s)\n", strerror(-ret));
13344 cmdline_parse_inst_t cmd_set_macsec_sa = {
13345 .f = cmd_set_macsec_sa_parsed,
13347 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
13349 (void *)&cmd_macsec_sa_set,
13350 (void *)&cmd_macsec_sa_macsec,
13351 (void *)&cmd_macsec_sa_sa,
13352 (void *)&cmd_macsec_sa_tx_rx,
13353 (void *)&cmd_macsec_sa_port_id,
13354 (void *)&cmd_macsec_sa_idx,
13355 (void *)&cmd_macsec_sa_an,
13356 (void *)&cmd_macsec_sa_pn,
13357 (void *)&cmd_macsec_sa_key,
13362 /* VF unicast promiscuous mode configuration */
13364 /* Common result structure for VF unicast promiscuous mode */
13365 struct cmd_vf_promisc_result {
13366 cmdline_fixed_string_t set;
13367 cmdline_fixed_string_t vf;
13368 cmdline_fixed_string_t promisc;
13371 cmdline_fixed_string_t on_off;
13374 /* Common CLI fields for VF unicast promiscuous mode enable disable */
13375 cmdline_parse_token_string_t cmd_vf_promisc_set =
13376 TOKEN_STRING_INITIALIZER
13377 (struct cmd_vf_promisc_result,
13379 cmdline_parse_token_string_t cmd_vf_promisc_vf =
13380 TOKEN_STRING_INITIALIZER
13381 (struct cmd_vf_promisc_result,
13383 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
13384 TOKEN_STRING_INITIALIZER
13385 (struct cmd_vf_promisc_result,
13386 promisc, "promisc");
13387 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
13388 TOKEN_NUM_INITIALIZER
13389 (struct cmd_vf_promisc_result,
13391 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
13392 TOKEN_NUM_INITIALIZER
13393 (struct cmd_vf_promisc_result,
13395 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
13396 TOKEN_STRING_INITIALIZER
13397 (struct cmd_vf_promisc_result,
13401 cmd_set_vf_promisc_parsed(
13402 void *parsed_result,
13403 __attribute__((unused)) struct cmdline *cl,
13404 __attribute__((unused)) void *data)
13406 struct cmd_vf_promisc_result *res = parsed_result;
13407 int ret = -ENOTSUP;
13409 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13411 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13414 #ifdef RTE_LIBRTE_I40E_PMD
13415 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
13416 res->vf_id, is_on);
13423 printf("invalid vf_id %d\n", res->vf_id);
13426 printf("invalid port_id %d\n", res->port_id);
13429 printf("function not implemented\n");
13432 printf("programming error: (%s)\n", strerror(-ret));
13436 cmdline_parse_inst_t cmd_set_vf_promisc = {
13437 .f = cmd_set_vf_promisc_parsed,
13439 .help_str = "set vf promisc <port_id> <vf_id> on|off: "
13440 "Set unicast promiscuous mode for a VF from the PF",
13442 (void *)&cmd_vf_promisc_set,
13443 (void *)&cmd_vf_promisc_vf,
13444 (void *)&cmd_vf_promisc_promisc,
13445 (void *)&cmd_vf_promisc_port_id,
13446 (void *)&cmd_vf_promisc_vf_id,
13447 (void *)&cmd_vf_promisc_on_off,
13452 /* VF multicast promiscuous mode configuration */
13454 /* Common result structure for VF multicast promiscuous mode */
13455 struct cmd_vf_allmulti_result {
13456 cmdline_fixed_string_t set;
13457 cmdline_fixed_string_t vf;
13458 cmdline_fixed_string_t allmulti;
13461 cmdline_fixed_string_t on_off;
13464 /* Common CLI fields for VF multicast promiscuous mode enable disable */
13465 cmdline_parse_token_string_t cmd_vf_allmulti_set =
13466 TOKEN_STRING_INITIALIZER
13467 (struct cmd_vf_allmulti_result,
13469 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
13470 TOKEN_STRING_INITIALIZER
13471 (struct cmd_vf_allmulti_result,
13473 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
13474 TOKEN_STRING_INITIALIZER
13475 (struct cmd_vf_allmulti_result,
13476 allmulti, "allmulti");
13477 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
13478 TOKEN_NUM_INITIALIZER
13479 (struct cmd_vf_allmulti_result,
13481 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
13482 TOKEN_NUM_INITIALIZER
13483 (struct cmd_vf_allmulti_result,
13485 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
13486 TOKEN_STRING_INITIALIZER
13487 (struct cmd_vf_allmulti_result,
13491 cmd_set_vf_allmulti_parsed(
13492 void *parsed_result,
13493 __attribute__((unused)) struct cmdline *cl,
13494 __attribute__((unused)) void *data)
13496 struct cmd_vf_allmulti_result *res = parsed_result;
13497 int ret = -ENOTSUP;
13499 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13501 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13504 #ifdef RTE_LIBRTE_I40E_PMD
13505 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
13506 res->vf_id, is_on);
13513 printf("invalid vf_id %d\n", res->vf_id);
13516 printf("invalid port_id %d\n", res->port_id);
13519 printf("function not implemented\n");
13522 printf("programming error: (%s)\n", strerror(-ret));
13526 cmdline_parse_inst_t cmd_set_vf_allmulti = {
13527 .f = cmd_set_vf_allmulti_parsed,
13529 .help_str = "set vf allmulti <port_id> <vf_id> on|off: "
13530 "Set multicast promiscuous mode for a VF from the PF",
13532 (void *)&cmd_vf_allmulti_set,
13533 (void *)&cmd_vf_allmulti_vf,
13534 (void *)&cmd_vf_allmulti_allmulti,
13535 (void *)&cmd_vf_allmulti_port_id,
13536 (void *)&cmd_vf_allmulti_vf_id,
13537 (void *)&cmd_vf_allmulti_on_off,
13542 /* vf broadcast mode configuration */
13544 /* Common result structure for vf broadcast */
13545 struct cmd_set_vf_broadcast_result {
13546 cmdline_fixed_string_t set;
13547 cmdline_fixed_string_t vf;
13548 cmdline_fixed_string_t broadcast;
13551 cmdline_fixed_string_t on_off;
13554 /* Common CLI fields for vf broadcast enable disable */
13555 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
13556 TOKEN_STRING_INITIALIZER
13557 (struct cmd_set_vf_broadcast_result,
13559 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
13560 TOKEN_STRING_INITIALIZER
13561 (struct cmd_set_vf_broadcast_result,
13563 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
13564 TOKEN_STRING_INITIALIZER
13565 (struct cmd_set_vf_broadcast_result,
13566 broadcast, "broadcast");
13567 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
13568 TOKEN_NUM_INITIALIZER
13569 (struct cmd_set_vf_broadcast_result,
13571 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
13572 TOKEN_NUM_INITIALIZER
13573 (struct cmd_set_vf_broadcast_result,
13575 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
13576 TOKEN_STRING_INITIALIZER
13577 (struct cmd_set_vf_broadcast_result,
13581 cmd_set_vf_broadcast_parsed(
13582 void *parsed_result,
13583 __attribute__((unused)) struct cmdline *cl,
13584 __attribute__((unused)) void *data)
13586 struct cmd_set_vf_broadcast_result *res = parsed_result;
13587 int ret = -ENOTSUP;
13589 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13591 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13594 #ifdef RTE_LIBRTE_I40E_PMD
13595 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
13596 res->vf_id, is_on);
13603 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13606 printf("invalid port_id %d\n", res->port_id);
13609 printf("function not implemented\n");
13612 printf("programming error: (%s)\n", strerror(-ret));
13616 cmdline_parse_inst_t cmd_set_vf_broadcast = {
13617 .f = cmd_set_vf_broadcast_parsed,
13619 .help_str = "set vf broadcast <port_id> <vf_id> on|off",
13621 (void *)&cmd_set_vf_broadcast_set,
13622 (void *)&cmd_set_vf_broadcast_vf,
13623 (void *)&cmd_set_vf_broadcast_broadcast,
13624 (void *)&cmd_set_vf_broadcast_port_id,
13625 (void *)&cmd_set_vf_broadcast_vf_id,
13626 (void *)&cmd_set_vf_broadcast_on_off,
13631 /* vf vlan tag configuration */
13633 /* Common result structure for vf vlan tag */
13634 struct cmd_set_vf_vlan_tag_result {
13635 cmdline_fixed_string_t set;
13636 cmdline_fixed_string_t vf;
13637 cmdline_fixed_string_t vlan;
13638 cmdline_fixed_string_t tag;
13641 cmdline_fixed_string_t on_off;
13644 /* Common CLI fields for vf vlan tag enable disable */
13645 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
13646 TOKEN_STRING_INITIALIZER
13647 (struct cmd_set_vf_vlan_tag_result,
13649 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
13650 TOKEN_STRING_INITIALIZER
13651 (struct cmd_set_vf_vlan_tag_result,
13653 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
13654 TOKEN_STRING_INITIALIZER
13655 (struct cmd_set_vf_vlan_tag_result,
13657 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
13658 TOKEN_STRING_INITIALIZER
13659 (struct cmd_set_vf_vlan_tag_result,
13661 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
13662 TOKEN_NUM_INITIALIZER
13663 (struct cmd_set_vf_vlan_tag_result,
13665 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
13666 TOKEN_NUM_INITIALIZER
13667 (struct cmd_set_vf_vlan_tag_result,
13669 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
13670 TOKEN_STRING_INITIALIZER
13671 (struct cmd_set_vf_vlan_tag_result,
13675 cmd_set_vf_vlan_tag_parsed(
13676 void *parsed_result,
13677 __attribute__((unused)) struct cmdline *cl,
13678 __attribute__((unused)) void *data)
13680 struct cmd_set_vf_vlan_tag_result *res = parsed_result;
13681 int ret = -ENOTSUP;
13683 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13685 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13688 #ifdef RTE_LIBRTE_I40E_PMD
13689 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
13690 res->vf_id, is_on);
13697 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13700 printf("invalid port_id %d\n", res->port_id);
13703 printf("function not implemented\n");
13706 printf("programming error: (%s)\n", strerror(-ret));
13710 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
13711 .f = cmd_set_vf_vlan_tag_parsed,
13713 .help_str = "set vf vlan tag <port_id> <vf_id> on|off",
13715 (void *)&cmd_set_vf_vlan_tag_set,
13716 (void *)&cmd_set_vf_vlan_tag_vf,
13717 (void *)&cmd_set_vf_vlan_tag_vlan,
13718 (void *)&cmd_set_vf_vlan_tag_tag,
13719 (void *)&cmd_set_vf_vlan_tag_port_id,
13720 (void *)&cmd_set_vf_vlan_tag_vf_id,
13721 (void *)&cmd_set_vf_vlan_tag_on_off,
13726 /* Common definition of VF and TC TX bandwidth configuration */
13727 struct cmd_vf_tc_bw_result {
13728 cmdline_fixed_string_t set;
13729 cmdline_fixed_string_t vf;
13730 cmdline_fixed_string_t tc;
13731 cmdline_fixed_string_t tx;
13732 cmdline_fixed_string_t min_bw;
13733 cmdline_fixed_string_t max_bw;
13734 cmdline_fixed_string_t strict_link_prio;
13739 cmdline_fixed_string_t bw_list;
13743 cmdline_parse_token_string_t cmd_vf_tc_bw_set =
13744 TOKEN_STRING_INITIALIZER
13745 (struct cmd_vf_tc_bw_result,
13747 cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
13748 TOKEN_STRING_INITIALIZER
13749 (struct cmd_vf_tc_bw_result,
13751 cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
13752 TOKEN_STRING_INITIALIZER
13753 (struct cmd_vf_tc_bw_result,
13755 cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
13756 TOKEN_STRING_INITIALIZER
13757 (struct cmd_vf_tc_bw_result,
13759 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio =
13760 TOKEN_STRING_INITIALIZER
13761 (struct cmd_vf_tc_bw_result,
13762 strict_link_prio, "strict-link-priority");
13763 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw =
13764 TOKEN_STRING_INITIALIZER
13765 (struct cmd_vf_tc_bw_result,
13766 min_bw, "min-bandwidth");
13767 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
13768 TOKEN_STRING_INITIALIZER
13769 (struct cmd_vf_tc_bw_result,
13770 max_bw, "max-bandwidth");
13771 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
13772 TOKEN_NUM_INITIALIZER
13773 (struct cmd_vf_tc_bw_result,
13775 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
13776 TOKEN_NUM_INITIALIZER
13777 (struct cmd_vf_tc_bw_result,
13779 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no =
13780 TOKEN_NUM_INITIALIZER
13781 (struct cmd_vf_tc_bw_result,
13783 cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
13784 TOKEN_NUM_INITIALIZER
13785 (struct cmd_vf_tc_bw_result,
13787 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
13788 TOKEN_STRING_INITIALIZER
13789 (struct cmd_vf_tc_bw_result,
13791 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map =
13792 TOKEN_NUM_INITIALIZER
13793 (struct cmd_vf_tc_bw_result,
13796 /* VF max bandwidth setting */
13798 cmd_vf_max_bw_parsed(
13799 void *parsed_result,
13800 __attribute__((unused)) struct cmdline *cl,
13801 __attribute__((unused)) void *data)
13803 struct cmd_vf_tc_bw_result *res = parsed_result;
13804 int ret = -ENOTSUP;
13806 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13809 #ifdef RTE_LIBRTE_I40E_PMD
13810 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id,
13811 res->vf_id, res->bw);
13818 printf("invalid vf_id %d or bandwidth %d\n",
13819 res->vf_id, res->bw);
13822 printf("invalid port_id %d\n", res->port_id);
13825 printf("function not implemented\n");
13828 printf("programming error: (%s)\n", strerror(-ret));
13832 cmdline_parse_inst_t cmd_vf_max_bw = {
13833 .f = cmd_vf_max_bw_parsed,
13835 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
13837 (void *)&cmd_vf_tc_bw_set,
13838 (void *)&cmd_vf_tc_bw_vf,
13839 (void *)&cmd_vf_tc_bw_tx,
13840 (void *)&cmd_vf_tc_bw_max_bw,
13841 (void *)&cmd_vf_tc_bw_port_id,
13842 (void *)&cmd_vf_tc_bw_vf_id,
13843 (void *)&cmd_vf_tc_bw_bw,
13849 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
13854 const char *p, *p0 = str;
13861 p = strchr(p0, '(');
13863 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
13867 p0 = strchr(p, ')');
13869 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
13873 if (size >= sizeof(s)) {
13874 printf("The string size exceeds the internal buffer size\n");
13877 snprintf(s, sizeof(s), "%.*s", size, p);
13878 ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
13880 printf("Failed to get the bandwidth list. ");
13884 for (i = 0; i < ret; i++)
13885 bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
13890 /* TC min bandwidth setting */
13892 cmd_vf_tc_min_bw_parsed(
13893 void *parsed_result,
13894 __attribute__((unused)) struct cmdline *cl,
13895 __attribute__((unused)) void *data)
13897 struct cmd_vf_tc_bw_result *res = parsed_result;
13900 int ret = -ENOTSUP;
13902 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13905 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
13909 #ifdef RTE_LIBRTE_I40E_PMD
13910 ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
13918 printf("invalid vf_id %d or bandwidth\n", res->vf_id);
13921 printf("invalid port_id %d\n", res->port_id);
13924 printf("function not implemented\n");
13927 printf("programming error: (%s)\n", strerror(-ret));
13931 cmdline_parse_inst_t cmd_vf_tc_min_bw = {
13932 .f = cmd_vf_tc_min_bw_parsed,
13934 .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
13935 " <bw1, bw2, ...>",
13937 (void *)&cmd_vf_tc_bw_set,
13938 (void *)&cmd_vf_tc_bw_vf,
13939 (void *)&cmd_vf_tc_bw_tc,
13940 (void *)&cmd_vf_tc_bw_tx,
13941 (void *)&cmd_vf_tc_bw_min_bw,
13942 (void *)&cmd_vf_tc_bw_port_id,
13943 (void *)&cmd_vf_tc_bw_vf_id,
13944 (void *)&cmd_vf_tc_bw_bw_list,
13950 cmd_tc_min_bw_parsed(
13951 void *parsed_result,
13952 __attribute__((unused)) struct cmdline *cl,
13953 __attribute__((unused)) void *data)
13955 struct cmd_vf_tc_bw_result *res = parsed_result;
13956 struct rte_port *port;
13959 int ret = -ENOTSUP;
13961 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13964 port = &ports[res->port_id];
13965 /** Check if the port is not started **/
13966 if (port->port_status != RTE_PORT_STOPPED) {
13967 printf("Please stop port %d first\n", res->port_id);
13971 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
13975 #ifdef RTE_LIBRTE_IXGBE_PMD
13976 ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw);
13983 printf("invalid bandwidth\n");
13986 printf("invalid port_id %d\n", res->port_id);
13989 printf("function not implemented\n");
13992 printf("programming error: (%s)\n", strerror(-ret));
13996 cmdline_parse_inst_t cmd_tc_min_bw = {
13997 .f = cmd_tc_min_bw_parsed,
13999 .help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>",
14001 (void *)&cmd_vf_tc_bw_set,
14002 (void *)&cmd_vf_tc_bw_tc,
14003 (void *)&cmd_vf_tc_bw_tx,
14004 (void *)&cmd_vf_tc_bw_min_bw,
14005 (void *)&cmd_vf_tc_bw_port_id,
14006 (void *)&cmd_vf_tc_bw_bw_list,
14011 /* TC max bandwidth setting */
14013 cmd_vf_tc_max_bw_parsed(
14014 void *parsed_result,
14015 __attribute__((unused)) struct cmdline *cl,
14016 __attribute__((unused)) void *data)
14018 struct cmd_vf_tc_bw_result *res = parsed_result;
14019 int ret = -ENOTSUP;
14021 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14024 #ifdef RTE_LIBRTE_I40E_PMD
14025 ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id,
14026 res->tc_no, res->bw);
14033 printf("invalid vf_id %d, tc_no %d or bandwidth %d\n",
14034 res->vf_id, res->tc_no, res->bw);
14037 printf("invalid port_id %d\n", res->port_id);
14040 printf("function not implemented\n");
14043 printf("programming error: (%s)\n", strerror(-ret));
14047 cmdline_parse_inst_t cmd_vf_tc_max_bw = {
14048 .f = cmd_vf_tc_max_bw_parsed,
14050 .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>"
14053 (void *)&cmd_vf_tc_bw_set,
14054 (void *)&cmd_vf_tc_bw_vf,
14055 (void *)&cmd_vf_tc_bw_tc,
14056 (void *)&cmd_vf_tc_bw_tx,
14057 (void *)&cmd_vf_tc_bw_max_bw,
14058 (void *)&cmd_vf_tc_bw_port_id,
14059 (void *)&cmd_vf_tc_bw_vf_id,
14060 (void *)&cmd_vf_tc_bw_tc_no,
14061 (void *)&cmd_vf_tc_bw_bw,
14067 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
14069 /* *** Set Port default Traffic Management Hierarchy *** */
14070 struct cmd_set_port_tm_hierarchy_default_result {
14071 cmdline_fixed_string_t set;
14072 cmdline_fixed_string_t port;
14073 cmdline_fixed_string_t tm;
14074 cmdline_fixed_string_t hierarchy;
14075 cmdline_fixed_string_t def;
14079 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_set =
14080 TOKEN_STRING_INITIALIZER(
14081 struct cmd_set_port_tm_hierarchy_default_result, set, "set");
14082 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_port =
14083 TOKEN_STRING_INITIALIZER(
14084 struct cmd_set_port_tm_hierarchy_default_result, port, "port");
14085 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_tm =
14086 TOKEN_STRING_INITIALIZER(
14087 struct cmd_set_port_tm_hierarchy_default_result, tm, "tm");
14088 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_hierarchy =
14089 TOKEN_STRING_INITIALIZER(
14090 struct cmd_set_port_tm_hierarchy_default_result,
14091 hierarchy, "hierarchy");
14092 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_default =
14093 TOKEN_STRING_INITIALIZER(
14094 struct cmd_set_port_tm_hierarchy_default_result,
14096 cmdline_parse_token_num_t cmd_set_port_tm_hierarchy_default_port_id =
14097 TOKEN_NUM_INITIALIZER(
14098 struct cmd_set_port_tm_hierarchy_default_result,
14101 static void cmd_set_port_tm_hierarchy_default_parsed(void *parsed_result,
14102 __attribute__((unused)) struct cmdline *cl,
14103 __attribute__((unused)) void *data)
14105 struct cmd_set_port_tm_hierarchy_default_result *res = parsed_result;
14106 struct rte_port *p;
14107 portid_t port_id = res->port_id;
14109 if (port_id_is_invalid(port_id, ENABLED_WARN))
14112 p = &ports[port_id];
14115 if (p->softport.tm_flag == 0) {
14116 printf(" tm not enabled on port %u (error)\n", port_id);
14120 /* Forward mode: tm */
14121 if (strcmp(cur_fwd_config.fwd_eng->fwd_mode_name, "tm")) {
14122 printf(" tm mode not enabled(error)\n");
14126 /* Set the default tm hierarchy */
14127 p->softport.tm.default_hierarchy_enable = 1;
14130 cmdline_parse_inst_t cmd_set_port_tm_hierarchy_default = {
14131 .f = cmd_set_port_tm_hierarchy_default_parsed,
14133 .help_str = "set port tm hierarchy default <port_id>",
14135 (void *)&cmd_set_port_tm_hierarchy_default_set,
14136 (void *)&cmd_set_port_tm_hierarchy_default_port,
14137 (void *)&cmd_set_port_tm_hierarchy_default_tm,
14138 (void *)&cmd_set_port_tm_hierarchy_default_hierarchy,
14139 (void *)&cmd_set_port_tm_hierarchy_default_default,
14140 (void *)&cmd_set_port_tm_hierarchy_default_port_id,
14146 /* Strict link priority scheduling mode setting */
14148 cmd_strict_link_prio_parsed(
14149 void *parsed_result,
14150 __attribute__((unused)) struct cmdline *cl,
14151 __attribute__((unused)) void *data)
14153 struct cmd_vf_tc_bw_result *res = parsed_result;
14154 int ret = -ENOTSUP;
14156 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14159 #ifdef RTE_LIBRTE_I40E_PMD
14160 ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map);
14167 printf("invalid tc_bitmap 0x%x\n", res->tc_map);
14170 printf("invalid port_id %d\n", res->port_id);
14173 printf("function not implemented\n");
14176 printf("programming error: (%s)\n", strerror(-ret));
14180 cmdline_parse_inst_t cmd_strict_link_prio = {
14181 .f = cmd_strict_link_prio_parsed,
14183 .help_str = "set tx strict-link-priority <port_id> <tc_bitmap>",
14185 (void *)&cmd_vf_tc_bw_set,
14186 (void *)&cmd_vf_tc_bw_tx,
14187 (void *)&cmd_vf_tc_bw_strict_link_prio,
14188 (void *)&cmd_vf_tc_bw_port_id,
14189 (void *)&cmd_vf_tc_bw_tc_map,
14194 /* Load dynamic device personalization*/
14195 struct cmd_ddp_add_result {
14196 cmdline_fixed_string_t ddp;
14197 cmdline_fixed_string_t add;
14202 cmdline_parse_token_string_t cmd_ddp_add_ddp =
14203 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp");
14204 cmdline_parse_token_string_t cmd_ddp_add_add =
14205 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add");
14206 cmdline_parse_token_num_t cmd_ddp_add_port_id =
14207 TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id, UINT16);
14208 cmdline_parse_token_string_t cmd_ddp_add_filepath =
14209 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL);
14212 cmd_ddp_add_parsed(
14213 void *parsed_result,
14214 __attribute__((unused)) struct cmdline *cl,
14215 __attribute__((unused)) void *data)
14217 struct cmd_ddp_add_result *res = parsed_result;
14223 int ret = -ENOTSUP;
14225 if (res->port_id > nb_ports) {
14226 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
14230 if (!all_ports_stopped()) {
14231 printf("Please stop all ports first\n");
14235 filepath = strdup(res->filepath);
14236 if (filepath == NULL) {
14237 printf("Failed to allocate memory\n");
14240 file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ',');
14242 buff = open_ddp_package_file(file_fld[0], &size);
14244 free((void *)filepath);
14248 #ifdef RTE_LIBRTE_I40E_PMD
14249 if (ret == -ENOTSUP)
14250 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
14252 RTE_PMD_I40E_PKG_OP_WR_ADD);
14255 if (ret == -EEXIST)
14256 printf("Profile has already existed.\n");
14258 printf("Failed to load profile.\n");
14259 else if (file_num == 2)
14260 save_ddp_package_file(file_fld[1], buff, size);
14262 close_ddp_package_file(buff);
14263 free((void *)filepath);
14266 cmdline_parse_inst_t cmd_ddp_add = {
14267 .f = cmd_ddp_add_parsed,
14269 .help_str = "ddp add <port_id> <profile_path[,output_path]>",
14271 (void *)&cmd_ddp_add_ddp,
14272 (void *)&cmd_ddp_add_add,
14273 (void *)&cmd_ddp_add_port_id,
14274 (void *)&cmd_ddp_add_filepath,
14279 /* Delete dynamic device personalization*/
14280 struct cmd_ddp_del_result {
14281 cmdline_fixed_string_t ddp;
14282 cmdline_fixed_string_t del;
14287 cmdline_parse_token_string_t cmd_ddp_del_ddp =
14288 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp");
14289 cmdline_parse_token_string_t cmd_ddp_del_del =
14290 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del");
14291 cmdline_parse_token_num_t cmd_ddp_del_port_id =
14292 TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, UINT16);
14293 cmdline_parse_token_string_t cmd_ddp_del_filepath =
14294 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL);
14297 cmd_ddp_del_parsed(
14298 void *parsed_result,
14299 __attribute__((unused)) struct cmdline *cl,
14300 __attribute__((unused)) void *data)
14302 struct cmd_ddp_del_result *res = parsed_result;
14305 int ret = -ENOTSUP;
14307 if (res->port_id > nb_ports) {
14308 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
14312 if (!all_ports_stopped()) {
14313 printf("Please stop all ports first\n");
14317 buff = open_ddp_package_file(res->filepath, &size);
14321 #ifdef RTE_LIBRTE_I40E_PMD
14322 if (ret == -ENOTSUP)
14323 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
14325 RTE_PMD_I40E_PKG_OP_WR_DEL);
14328 if (ret == -EACCES)
14329 printf("Profile does not exist.\n");
14331 printf("Failed to delete profile.\n");
14333 close_ddp_package_file(buff);
14336 cmdline_parse_inst_t cmd_ddp_del = {
14337 .f = cmd_ddp_del_parsed,
14339 .help_str = "ddp del <port_id> <profile_path>",
14341 (void *)&cmd_ddp_del_ddp,
14342 (void *)&cmd_ddp_del_del,
14343 (void *)&cmd_ddp_del_port_id,
14344 (void *)&cmd_ddp_del_filepath,
14349 /* Get dynamic device personalization profile info */
14350 struct cmd_ddp_info_result {
14351 cmdline_fixed_string_t ddp;
14352 cmdline_fixed_string_t get;
14353 cmdline_fixed_string_t info;
14357 cmdline_parse_token_string_t cmd_ddp_info_ddp =
14358 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp");
14359 cmdline_parse_token_string_t cmd_ddp_info_get =
14360 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get");
14361 cmdline_parse_token_string_t cmd_ddp_info_info =
14362 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info");
14363 cmdline_parse_token_string_t cmd_ddp_info_filepath =
14364 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL);
14367 cmd_ddp_info_parsed(
14368 void *parsed_result,
14369 __attribute__((unused)) struct cmdline *cl,
14370 __attribute__((unused)) void *data)
14372 struct cmd_ddp_info_result *res = parsed_result;
14375 int ret = -ENOTSUP;
14376 #ifdef RTE_LIBRTE_I40E_PMD
14379 uint32_t buff_size = 0;
14380 struct rte_pmd_i40e_profile_info info;
14381 uint32_t dev_num = 0;
14382 struct rte_pmd_i40e_ddp_device_id *devs;
14383 uint32_t proto_num = 0;
14384 struct rte_pmd_i40e_proto_info *proto = NULL;
14385 uint32_t pctype_num = 0;
14386 struct rte_pmd_i40e_ptype_info *pctype;
14387 uint32_t ptype_num = 0;
14388 struct rte_pmd_i40e_ptype_info *ptype;
14393 pkg = open_ddp_package_file(res->filepath, &pkg_size);
14397 #ifdef RTE_LIBRTE_I40E_PMD
14398 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14399 (uint8_t *)&info, sizeof(info),
14400 RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER);
14402 printf("Global Track id: 0x%x\n", info.track_id);
14403 printf("Global Version: %d.%d.%d.%d\n",
14404 info.version.major,
14405 info.version.minor,
14406 info.version.update,
14407 info.version.draft);
14408 printf("Global Package name: %s\n\n", info.name);
14411 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14412 (uint8_t *)&info, sizeof(info),
14413 RTE_PMD_I40E_PKG_INFO_HEADER);
14415 printf("i40e Profile Track id: 0x%x\n", info.track_id);
14416 printf("i40e Profile Version: %d.%d.%d.%d\n",
14417 info.version.major,
14418 info.version.minor,
14419 info.version.update,
14420 info.version.draft);
14421 printf("i40e Profile name: %s\n\n", info.name);
14424 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14425 (uint8_t *)&buff_size, sizeof(buff_size),
14426 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE);
14427 if (!ret && buff_size) {
14428 buff = (uint8_t *)malloc(buff_size);
14430 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14432 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES);
14434 printf("Package Notes:\n%s\n\n", buff);
14439 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14440 (uint8_t *)&dev_num, sizeof(dev_num),
14441 RTE_PMD_I40E_PKG_INFO_DEVID_NUM);
14442 if (!ret && dev_num) {
14443 buff_size = dev_num * sizeof(struct rte_pmd_i40e_ddp_device_id);
14444 devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(buff_size);
14446 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14447 (uint8_t *)devs, buff_size,
14448 RTE_PMD_I40E_PKG_INFO_DEVID_LIST);
14450 printf("List of supported devices:\n");
14451 for (i = 0; i < dev_num; i++) {
14452 printf(" %04X:%04X %04X:%04X\n",
14453 devs[i].vendor_dev_id >> 16,
14454 devs[i].vendor_dev_id & 0xFFFF,
14455 devs[i].sub_vendor_dev_id >> 16,
14456 devs[i].sub_vendor_dev_id & 0xFFFF);
14464 /* get information about protocols and packet types */
14465 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14466 (uint8_t *)&proto_num, sizeof(proto_num),
14467 RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM);
14468 if (ret || !proto_num)
14469 goto no_print_return;
14471 buff_size = proto_num * sizeof(struct rte_pmd_i40e_proto_info);
14472 proto = (struct rte_pmd_i40e_proto_info *)malloc(buff_size);
14474 goto no_print_return;
14476 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)proto,
14478 RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST);
14480 printf("List of used protocols:\n");
14481 for (i = 0; i < proto_num; i++)
14482 printf(" %2u: %s\n", proto[i].proto_id,
14486 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14487 (uint8_t *)&pctype_num, sizeof(pctype_num),
14488 RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM);
14489 if (ret || !pctype_num)
14490 goto no_print_pctypes;
14492 buff_size = pctype_num * sizeof(struct rte_pmd_i40e_ptype_info);
14493 pctype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
14495 goto no_print_pctypes;
14497 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)pctype,
14499 RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST);
14502 goto no_print_pctypes;
14505 printf("List of defined packet classification types:\n");
14506 for (i = 0; i < pctype_num; i++) {
14507 printf(" %2u:", pctype[i].ptype_id);
14508 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
14509 proto_id = pctype[i].protocols[j];
14510 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
14511 for (n = 0; n < proto_num; n++) {
14512 if (proto[n].proto_id == proto_id) {
14513 printf(" %s", proto[n].name);
14526 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)&ptype_num,
14528 RTE_PMD_I40E_PKG_INFO_PTYPE_NUM);
14529 if (ret || !ptype_num)
14530 goto no_print_return;
14532 buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_info);
14533 ptype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
14535 goto no_print_return;
14537 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)ptype,
14539 RTE_PMD_I40E_PKG_INFO_PTYPE_LIST);
14542 goto no_print_return;
14544 printf("List of defined packet types:\n");
14545 for (i = 0; i < ptype_num; i++) {
14546 printf(" %2u:", ptype[i].ptype_id);
14547 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
14548 proto_id = ptype[i].protocols[j];
14549 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
14550 for (n = 0; n < proto_num; n++) {
14551 if (proto[n].proto_id == proto_id) {
14552 printf(" %s", proto[n].name);
14568 if (ret == -ENOTSUP)
14569 printf("Function not supported in PMD driver\n");
14570 close_ddp_package_file(pkg);
14573 cmdline_parse_inst_t cmd_ddp_get_info = {
14574 .f = cmd_ddp_info_parsed,
14576 .help_str = "ddp get info <profile_path>",
14578 (void *)&cmd_ddp_info_ddp,
14579 (void *)&cmd_ddp_info_get,
14580 (void *)&cmd_ddp_info_info,
14581 (void *)&cmd_ddp_info_filepath,
14586 /* Get dynamic device personalization profile info list*/
14587 #define PROFILE_INFO_SIZE 48
14588 #define MAX_PROFILE_NUM 16
14590 struct cmd_ddp_get_list_result {
14591 cmdline_fixed_string_t ddp;
14592 cmdline_fixed_string_t get;
14593 cmdline_fixed_string_t list;
14597 cmdline_parse_token_string_t cmd_ddp_get_list_ddp =
14598 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp");
14599 cmdline_parse_token_string_t cmd_ddp_get_list_get =
14600 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get");
14601 cmdline_parse_token_string_t cmd_ddp_get_list_list =
14602 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list");
14603 cmdline_parse_token_num_t cmd_ddp_get_list_port_id =
14604 TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id, UINT16);
14607 cmd_ddp_get_list_parsed(
14608 void *parsed_result,
14609 __attribute__((unused)) struct cmdline *cl,
14610 __attribute__((unused)) void *data)
14612 struct cmd_ddp_get_list_result *res = parsed_result;
14613 #ifdef RTE_LIBRTE_I40E_PMD
14614 struct rte_pmd_i40e_profile_list *p_list;
14615 struct rte_pmd_i40e_profile_info *p_info;
14620 int ret = -ENOTSUP;
14622 if (res->port_id > nb_ports) {
14623 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
14627 #ifdef RTE_LIBRTE_I40E_PMD
14628 size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4;
14629 p_list = (struct rte_pmd_i40e_profile_list *)malloc(size);
14631 printf("%s: Failed to malloc buffer\n", __func__);
14633 if (ret == -ENOTSUP)
14634 ret = rte_pmd_i40e_get_ddp_list(res->port_id,
14635 (uint8_t *)p_list, size);
14638 p_num = p_list->p_count;
14639 printf("Profile number is: %d\n\n", p_num);
14641 for (i = 0; i < p_num; i++) {
14642 p_info = &p_list->p_info[i];
14643 printf("Profile %d:\n", i);
14644 printf("Track id: 0x%x\n", p_info->track_id);
14645 printf("Version: %d.%d.%d.%d\n",
14646 p_info->version.major,
14647 p_info->version.minor,
14648 p_info->version.update,
14649 p_info->version.draft);
14650 printf("Profile name: %s\n\n", p_info->name);
14658 printf("Failed to get ddp list\n");
14661 cmdline_parse_inst_t cmd_ddp_get_list = {
14662 .f = cmd_ddp_get_list_parsed,
14664 .help_str = "ddp get list <port_id>",
14666 (void *)&cmd_ddp_get_list_ddp,
14667 (void *)&cmd_ddp_get_list_get,
14668 (void *)&cmd_ddp_get_list_list,
14669 (void *)&cmd_ddp_get_list_port_id,
14674 /* show vf stats */
14676 /* Common result structure for show vf stats */
14677 struct cmd_show_vf_stats_result {
14678 cmdline_fixed_string_t show;
14679 cmdline_fixed_string_t vf;
14680 cmdline_fixed_string_t stats;
14685 /* Common CLI fields show vf stats*/
14686 cmdline_parse_token_string_t cmd_show_vf_stats_show =
14687 TOKEN_STRING_INITIALIZER
14688 (struct cmd_show_vf_stats_result,
14690 cmdline_parse_token_string_t cmd_show_vf_stats_vf =
14691 TOKEN_STRING_INITIALIZER
14692 (struct cmd_show_vf_stats_result,
14694 cmdline_parse_token_string_t cmd_show_vf_stats_stats =
14695 TOKEN_STRING_INITIALIZER
14696 (struct cmd_show_vf_stats_result,
14698 cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
14699 TOKEN_NUM_INITIALIZER
14700 (struct cmd_show_vf_stats_result,
14702 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
14703 TOKEN_NUM_INITIALIZER
14704 (struct cmd_show_vf_stats_result,
14708 cmd_show_vf_stats_parsed(
14709 void *parsed_result,
14710 __attribute__((unused)) struct cmdline *cl,
14711 __attribute__((unused)) void *data)
14713 struct cmd_show_vf_stats_result *res = parsed_result;
14714 struct rte_eth_stats stats;
14715 int ret = -ENOTSUP;
14716 static const char *nic_stats_border = "########################";
14718 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14721 memset(&stats, 0, sizeof(stats));
14723 #ifdef RTE_LIBRTE_I40E_PMD
14724 if (ret == -ENOTSUP)
14725 ret = rte_pmd_i40e_get_vf_stats(res->port_id,
14729 #ifdef RTE_LIBRTE_BNXT_PMD
14730 if (ret == -ENOTSUP)
14731 ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
14740 printf("invalid vf_id %d\n", res->vf_id);
14743 printf("invalid port_id %d\n", res->port_id);
14746 printf("function not implemented\n");
14749 printf("programming error: (%s)\n", strerror(-ret));
14752 printf("\n %s NIC statistics for port %-2d vf %-2d %s\n",
14753 nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
14755 printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: "
14757 stats.ipackets, stats.imissed, stats.ibytes);
14758 printf(" RX-errors: %-"PRIu64"\n", stats.ierrors);
14759 printf(" RX-nombuf: %-10"PRIu64"\n",
14761 printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: "
14763 stats.opackets, stats.oerrors, stats.obytes);
14765 printf(" %s############################%s\n",
14766 nic_stats_border, nic_stats_border);
14769 cmdline_parse_inst_t cmd_show_vf_stats = {
14770 .f = cmd_show_vf_stats_parsed,
14772 .help_str = "show vf stats <port_id> <vf_id>",
14774 (void *)&cmd_show_vf_stats_show,
14775 (void *)&cmd_show_vf_stats_vf,
14776 (void *)&cmd_show_vf_stats_stats,
14777 (void *)&cmd_show_vf_stats_port_id,
14778 (void *)&cmd_show_vf_stats_vf_id,
14783 /* clear vf stats */
14785 /* Common result structure for clear vf stats */
14786 struct cmd_clear_vf_stats_result {
14787 cmdline_fixed_string_t clear;
14788 cmdline_fixed_string_t vf;
14789 cmdline_fixed_string_t stats;
14794 /* Common CLI fields clear vf stats*/
14795 cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
14796 TOKEN_STRING_INITIALIZER
14797 (struct cmd_clear_vf_stats_result,
14799 cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
14800 TOKEN_STRING_INITIALIZER
14801 (struct cmd_clear_vf_stats_result,
14803 cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
14804 TOKEN_STRING_INITIALIZER
14805 (struct cmd_clear_vf_stats_result,
14807 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
14808 TOKEN_NUM_INITIALIZER
14809 (struct cmd_clear_vf_stats_result,
14811 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
14812 TOKEN_NUM_INITIALIZER
14813 (struct cmd_clear_vf_stats_result,
14817 cmd_clear_vf_stats_parsed(
14818 void *parsed_result,
14819 __attribute__((unused)) struct cmdline *cl,
14820 __attribute__((unused)) void *data)
14822 struct cmd_clear_vf_stats_result *res = parsed_result;
14823 int ret = -ENOTSUP;
14825 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14828 #ifdef RTE_LIBRTE_I40E_PMD
14829 if (ret == -ENOTSUP)
14830 ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
14833 #ifdef RTE_LIBRTE_BNXT_PMD
14834 if (ret == -ENOTSUP)
14835 ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
14843 printf("invalid vf_id %d\n", res->vf_id);
14846 printf("invalid port_id %d\n", res->port_id);
14849 printf("function not implemented\n");
14852 printf("programming error: (%s)\n", strerror(-ret));
14856 cmdline_parse_inst_t cmd_clear_vf_stats = {
14857 .f = cmd_clear_vf_stats_parsed,
14859 .help_str = "clear vf stats <port_id> <vf_id>",
14861 (void *)&cmd_clear_vf_stats_clear,
14862 (void *)&cmd_clear_vf_stats_vf,
14863 (void *)&cmd_clear_vf_stats_stats,
14864 (void *)&cmd_clear_vf_stats_port_id,
14865 (void *)&cmd_clear_vf_stats_vf_id,
14870 /* port config pctype mapping reset */
14872 /* Common result structure for port config pctype mapping reset */
14873 struct cmd_pctype_mapping_reset_result {
14874 cmdline_fixed_string_t port;
14875 cmdline_fixed_string_t config;
14877 cmdline_fixed_string_t pctype;
14878 cmdline_fixed_string_t mapping;
14879 cmdline_fixed_string_t reset;
14882 /* Common CLI fields for port config pctype mapping reset*/
14883 cmdline_parse_token_string_t cmd_pctype_mapping_reset_port =
14884 TOKEN_STRING_INITIALIZER
14885 (struct cmd_pctype_mapping_reset_result,
14887 cmdline_parse_token_string_t cmd_pctype_mapping_reset_config =
14888 TOKEN_STRING_INITIALIZER
14889 (struct cmd_pctype_mapping_reset_result,
14891 cmdline_parse_token_num_t cmd_pctype_mapping_reset_port_id =
14892 TOKEN_NUM_INITIALIZER
14893 (struct cmd_pctype_mapping_reset_result,
14895 cmdline_parse_token_string_t cmd_pctype_mapping_reset_pctype =
14896 TOKEN_STRING_INITIALIZER
14897 (struct cmd_pctype_mapping_reset_result,
14899 cmdline_parse_token_string_t cmd_pctype_mapping_reset_mapping =
14900 TOKEN_STRING_INITIALIZER
14901 (struct cmd_pctype_mapping_reset_result,
14902 mapping, "mapping");
14903 cmdline_parse_token_string_t cmd_pctype_mapping_reset_reset =
14904 TOKEN_STRING_INITIALIZER
14905 (struct cmd_pctype_mapping_reset_result,
14909 cmd_pctype_mapping_reset_parsed(
14910 void *parsed_result,
14911 __attribute__((unused)) struct cmdline *cl,
14912 __attribute__((unused)) void *data)
14914 struct cmd_pctype_mapping_reset_result *res = parsed_result;
14915 int ret = -ENOTSUP;
14917 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14920 #ifdef RTE_LIBRTE_I40E_PMD
14921 ret = rte_pmd_i40e_flow_type_mapping_reset(res->port_id);
14928 printf("invalid port_id %d\n", res->port_id);
14931 printf("function not implemented\n");
14934 printf("programming error: (%s)\n", strerror(-ret));
14938 cmdline_parse_inst_t cmd_pctype_mapping_reset = {
14939 .f = cmd_pctype_mapping_reset_parsed,
14941 .help_str = "port config <port_id> pctype mapping reset",
14943 (void *)&cmd_pctype_mapping_reset_port,
14944 (void *)&cmd_pctype_mapping_reset_config,
14945 (void *)&cmd_pctype_mapping_reset_port_id,
14946 (void *)&cmd_pctype_mapping_reset_pctype,
14947 (void *)&cmd_pctype_mapping_reset_mapping,
14948 (void *)&cmd_pctype_mapping_reset_reset,
14953 /* show port pctype mapping */
14955 /* Common result structure for show port pctype mapping */
14956 struct cmd_pctype_mapping_get_result {
14957 cmdline_fixed_string_t show;
14958 cmdline_fixed_string_t port;
14960 cmdline_fixed_string_t pctype;
14961 cmdline_fixed_string_t mapping;
14964 /* Common CLI fields for pctype mapping get */
14965 cmdline_parse_token_string_t cmd_pctype_mapping_get_show =
14966 TOKEN_STRING_INITIALIZER
14967 (struct cmd_pctype_mapping_get_result,
14969 cmdline_parse_token_string_t cmd_pctype_mapping_get_port =
14970 TOKEN_STRING_INITIALIZER
14971 (struct cmd_pctype_mapping_get_result,
14973 cmdline_parse_token_num_t cmd_pctype_mapping_get_port_id =
14974 TOKEN_NUM_INITIALIZER
14975 (struct cmd_pctype_mapping_get_result,
14977 cmdline_parse_token_string_t cmd_pctype_mapping_get_pctype =
14978 TOKEN_STRING_INITIALIZER
14979 (struct cmd_pctype_mapping_get_result,
14981 cmdline_parse_token_string_t cmd_pctype_mapping_get_mapping =
14982 TOKEN_STRING_INITIALIZER
14983 (struct cmd_pctype_mapping_get_result,
14984 mapping, "mapping");
14987 cmd_pctype_mapping_get_parsed(
14988 void *parsed_result,
14989 __attribute__((unused)) struct cmdline *cl,
14990 __attribute__((unused)) void *data)
14992 struct cmd_pctype_mapping_get_result *res = parsed_result;
14993 int ret = -ENOTSUP;
14994 #ifdef RTE_LIBRTE_I40E_PMD
14995 struct rte_pmd_i40e_flow_type_mapping
14996 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
14997 int i, j, first_pctype;
15000 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15003 #ifdef RTE_LIBRTE_I40E_PMD
15004 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, mapping);
15011 printf("invalid port_id %d\n", res->port_id);
15014 printf("function not implemented\n");
15017 printf("programming error: (%s)\n", strerror(-ret));
15021 #ifdef RTE_LIBRTE_I40E_PMD
15022 for (i = 0; i < RTE_PMD_I40E_FLOW_TYPE_MAX; i++) {
15023 if (mapping[i].pctype != 0ULL) {
15026 printf("pctype: ");
15027 for (j = 0; j < RTE_PMD_I40E_PCTYPE_MAX; j++) {
15028 if (mapping[i].pctype & (1ULL << j)) {
15029 printf(first_pctype ?
15030 "%02d" : ",%02d", j);
15034 printf(" -> flowtype: %02d\n", mapping[i].flow_type);
15040 cmdline_parse_inst_t cmd_pctype_mapping_get = {
15041 .f = cmd_pctype_mapping_get_parsed,
15043 .help_str = "show port <port_id> pctype mapping",
15045 (void *)&cmd_pctype_mapping_get_show,
15046 (void *)&cmd_pctype_mapping_get_port,
15047 (void *)&cmd_pctype_mapping_get_port_id,
15048 (void *)&cmd_pctype_mapping_get_pctype,
15049 (void *)&cmd_pctype_mapping_get_mapping,
15054 /* port config pctype mapping update */
15056 /* Common result structure for port config pctype mapping update */
15057 struct cmd_pctype_mapping_update_result {
15058 cmdline_fixed_string_t port;
15059 cmdline_fixed_string_t config;
15061 cmdline_fixed_string_t pctype;
15062 cmdline_fixed_string_t mapping;
15063 cmdline_fixed_string_t update;
15064 cmdline_fixed_string_t pctype_list;
15065 uint16_t flow_type;
15068 /* Common CLI fields for pctype mapping update*/
15069 cmdline_parse_token_string_t cmd_pctype_mapping_update_port =
15070 TOKEN_STRING_INITIALIZER
15071 (struct cmd_pctype_mapping_update_result,
15073 cmdline_parse_token_string_t cmd_pctype_mapping_update_config =
15074 TOKEN_STRING_INITIALIZER
15075 (struct cmd_pctype_mapping_update_result,
15077 cmdline_parse_token_num_t cmd_pctype_mapping_update_port_id =
15078 TOKEN_NUM_INITIALIZER
15079 (struct cmd_pctype_mapping_update_result,
15081 cmdline_parse_token_string_t cmd_pctype_mapping_update_pctype =
15082 TOKEN_STRING_INITIALIZER
15083 (struct cmd_pctype_mapping_update_result,
15085 cmdline_parse_token_string_t cmd_pctype_mapping_update_mapping =
15086 TOKEN_STRING_INITIALIZER
15087 (struct cmd_pctype_mapping_update_result,
15088 mapping, "mapping");
15089 cmdline_parse_token_string_t cmd_pctype_mapping_update_update =
15090 TOKEN_STRING_INITIALIZER
15091 (struct cmd_pctype_mapping_update_result,
15093 cmdline_parse_token_string_t cmd_pctype_mapping_update_pc_type =
15094 TOKEN_STRING_INITIALIZER
15095 (struct cmd_pctype_mapping_update_result,
15096 pctype_list, NULL);
15097 cmdline_parse_token_num_t cmd_pctype_mapping_update_flow_type =
15098 TOKEN_NUM_INITIALIZER
15099 (struct cmd_pctype_mapping_update_result,
15100 flow_type, UINT16);
15103 cmd_pctype_mapping_update_parsed(
15104 void *parsed_result,
15105 __attribute__((unused)) struct cmdline *cl,
15106 __attribute__((unused)) void *data)
15108 struct cmd_pctype_mapping_update_result *res = parsed_result;
15109 int ret = -ENOTSUP;
15110 #ifdef RTE_LIBRTE_I40E_PMD
15111 struct rte_pmd_i40e_flow_type_mapping mapping;
15113 unsigned int nb_item;
15114 unsigned int pctype_list[RTE_PMD_I40E_PCTYPE_MAX];
15117 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15120 #ifdef RTE_LIBRTE_I40E_PMD
15121 nb_item = parse_item_list(res->pctype_list, "pctypes",
15122 RTE_PMD_I40E_PCTYPE_MAX, pctype_list, 1);
15123 mapping.flow_type = res->flow_type;
15124 for (i = 0, mapping.pctype = 0ULL; i < nb_item; i++)
15125 mapping.pctype |= (1ULL << pctype_list[i]);
15126 ret = rte_pmd_i40e_flow_type_mapping_update(res->port_id,
15136 printf("invalid pctype or flow type\n");
15139 printf("invalid port_id %d\n", res->port_id);
15142 printf("function not implemented\n");
15145 printf("programming error: (%s)\n", strerror(-ret));
15149 cmdline_parse_inst_t cmd_pctype_mapping_update = {
15150 .f = cmd_pctype_mapping_update_parsed,
15152 .help_str = "port config <port_id> pctype mapping update"
15153 " <pctype_id_0,[pctype_id_1]*> <flowtype_id>",
15155 (void *)&cmd_pctype_mapping_update_port,
15156 (void *)&cmd_pctype_mapping_update_config,
15157 (void *)&cmd_pctype_mapping_update_port_id,
15158 (void *)&cmd_pctype_mapping_update_pctype,
15159 (void *)&cmd_pctype_mapping_update_mapping,
15160 (void *)&cmd_pctype_mapping_update_update,
15161 (void *)&cmd_pctype_mapping_update_pc_type,
15162 (void *)&cmd_pctype_mapping_update_flow_type,
15167 /* ptype mapping get */
15169 /* Common result structure for ptype mapping get */
15170 struct cmd_ptype_mapping_get_result {
15171 cmdline_fixed_string_t ptype;
15172 cmdline_fixed_string_t mapping;
15173 cmdline_fixed_string_t get;
15175 uint8_t valid_only;
15178 /* Common CLI fields for ptype mapping get */
15179 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype =
15180 TOKEN_STRING_INITIALIZER
15181 (struct cmd_ptype_mapping_get_result,
15183 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping =
15184 TOKEN_STRING_INITIALIZER
15185 (struct cmd_ptype_mapping_get_result,
15186 mapping, "mapping");
15187 cmdline_parse_token_string_t cmd_ptype_mapping_get_get =
15188 TOKEN_STRING_INITIALIZER
15189 (struct cmd_ptype_mapping_get_result,
15191 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id =
15192 TOKEN_NUM_INITIALIZER
15193 (struct cmd_ptype_mapping_get_result,
15195 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only =
15196 TOKEN_NUM_INITIALIZER
15197 (struct cmd_ptype_mapping_get_result,
15198 valid_only, UINT8);
15201 cmd_ptype_mapping_get_parsed(
15202 void *parsed_result,
15203 __attribute__((unused)) struct cmdline *cl,
15204 __attribute__((unused)) void *data)
15206 struct cmd_ptype_mapping_get_result *res = parsed_result;
15207 int ret = -ENOTSUP;
15208 #ifdef RTE_LIBRTE_I40E_PMD
15209 int max_ptype_num = 256;
15210 struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num];
15215 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15218 #ifdef RTE_LIBRTE_I40E_PMD
15219 ret = rte_pmd_i40e_ptype_mapping_get(res->port_id,
15230 printf("invalid port_id %d\n", res->port_id);
15233 printf("function not implemented\n");
15236 printf("programming error: (%s)\n", strerror(-ret));
15239 #ifdef RTE_LIBRTE_I40E_PMD
15241 for (i = 0; i < count; i++)
15242 printf("%3d\t0x%08x\n",
15243 mapping[i].hw_ptype, mapping[i].sw_ptype);
15248 cmdline_parse_inst_t cmd_ptype_mapping_get = {
15249 .f = cmd_ptype_mapping_get_parsed,
15251 .help_str = "ptype mapping get <port_id> <valid_only>",
15253 (void *)&cmd_ptype_mapping_get_ptype,
15254 (void *)&cmd_ptype_mapping_get_mapping,
15255 (void *)&cmd_ptype_mapping_get_get,
15256 (void *)&cmd_ptype_mapping_get_port_id,
15257 (void *)&cmd_ptype_mapping_get_valid_only,
15262 /* ptype mapping replace */
15264 /* Common result structure for ptype mapping replace */
15265 struct cmd_ptype_mapping_replace_result {
15266 cmdline_fixed_string_t ptype;
15267 cmdline_fixed_string_t mapping;
15268 cmdline_fixed_string_t replace;
15275 /* Common CLI fields for ptype mapping replace */
15276 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype =
15277 TOKEN_STRING_INITIALIZER
15278 (struct cmd_ptype_mapping_replace_result,
15280 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping =
15281 TOKEN_STRING_INITIALIZER
15282 (struct cmd_ptype_mapping_replace_result,
15283 mapping, "mapping");
15284 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace =
15285 TOKEN_STRING_INITIALIZER
15286 (struct cmd_ptype_mapping_replace_result,
15287 replace, "replace");
15288 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id =
15289 TOKEN_NUM_INITIALIZER
15290 (struct cmd_ptype_mapping_replace_result,
15292 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target =
15293 TOKEN_NUM_INITIALIZER
15294 (struct cmd_ptype_mapping_replace_result,
15296 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask =
15297 TOKEN_NUM_INITIALIZER
15298 (struct cmd_ptype_mapping_replace_result,
15300 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type =
15301 TOKEN_NUM_INITIALIZER
15302 (struct cmd_ptype_mapping_replace_result,
15306 cmd_ptype_mapping_replace_parsed(
15307 void *parsed_result,
15308 __attribute__((unused)) struct cmdline *cl,
15309 __attribute__((unused)) void *data)
15311 struct cmd_ptype_mapping_replace_result *res = parsed_result;
15312 int ret = -ENOTSUP;
15314 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15317 #ifdef RTE_LIBRTE_I40E_PMD
15318 ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id,
15328 printf("invalid ptype 0x%8x or 0x%8x\n",
15329 res->target, res->pkt_type);
15332 printf("invalid port_id %d\n", res->port_id);
15335 printf("function not implemented\n");
15338 printf("programming error: (%s)\n", strerror(-ret));
15342 cmdline_parse_inst_t cmd_ptype_mapping_replace = {
15343 .f = cmd_ptype_mapping_replace_parsed,
15346 "ptype mapping replace <port_id> <target> <mask> <pkt_type>",
15348 (void *)&cmd_ptype_mapping_replace_ptype,
15349 (void *)&cmd_ptype_mapping_replace_mapping,
15350 (void *)&cmd_ptype_mapping_replace_replace,
15351 (void *)&cmd_ptype_mapping_replace_port_id,
15352 (void *)&cmd_ptype_mapping_replace_target,
15353 (void *)&cmd_ptype_mapping_replace_mask,
15354 (void *)&cmd_ptype_mapping_replace_pkt_type,
15359 /* ptype mapping reset */
15361 /* Common result structure for ptype mapping reset */
15362 struct cmd_ptype_mapping_reset_result {
15363 cmdline_fixed_string_t ptype;
15364 cmdline_fixed_string_t mapping;
15365 cmdline_fixed_string_t reset;
15369 /* Common CLI fields for ptype mapping reset*/
15370 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype =
15371 TOKEN_STRING_INITIALIZER
15372 (struct cmd_ptype_mapping_reset_result,
15374 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping =
15375 TOKEN_STRING_INITIALIZER
15376 (struct cmd_ptype_mapping_reset_result,
15377 mapping, "mapping");
15378 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset =
15379 TOKEN_STRING_INITIALIZER
15380 (struct cmd_ptype_mapping_reset_result,
15382 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id =
15383 TOKEN_NUM_INITIALIZER
15384 (struct cmd_ptype_mapping_reset_result,
15388 cmd_ptype_mapping_reset_parsed(
15389 void *parsed_result,
15390 __attribute__((unused)) struct cmdline *cl,
15391 __attribute__((unused)) void *data)
15393 struct cmd_ptype_mapping_reset_result *res = parsed_result;
15394 int ret = -ENOTSUP;
15396 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15399 #ifdef RTE_LIBRTE_I40E_PMD
15400 ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id);
15407 printf("invalid port_id %d\n", res->port_id);
15410 printf("function not implemented\n");
15413 printf("programming error: (%s)\n", strerror(-ret));
15417 cmdline_parse_inst_t cmd_ptype_mapping_reset = {
15418 .f = cmd_ptype_mapping_reset_parsed,
15420 .help_str = "ptype mapping reset <port_id>",
15422 (void *)&cmd_ptype_mapping_reset_ptype,
15423 (void *)&cmd_ptype_mapping_reset_mapping,
15424 (void *)&cmd_ptype_mapping_reset_reset,
15425 (void *)&cmd_ptype_mapping_reset_port_id,
15430 /* ptype mapping update */
15432 /* Common result structure for ptype mapping update */
15433 struct cmd_ptype_mapping_update_result {
15434 cmdline_fixed_string_t ptype;
15435 cmdline_fixed_string_t mapping;
15436 cmdline_fixed_string_t reset;
15442 /* Common CLI fields for ptype mapping update*/
15443 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype =
15444 TOKEN_STRING_INITIALIZER
15445 (struct cmd_ptype_mapping_update_result,
15447 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping =
15448 TOKEN_STRING_INITIALIZER
15449 (struct cmd_ptype_mapping_update_result,
15450 mapping, "mapping");
15451 cmdline_parse_token_string_t cmd_ptype_mapping_update_update =
15452 TOKEN_STRING_INITIALIZER
15453 (struct cmd_ptype_mapping_update_result,
15455 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id =
15456 TOKEN_NUM_INITIALIZER
15457 (struct cmd_ptype_mapping_update_result,
15459 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype =
15460 TOKEN_NUM_INITIALIZER
15461 (struct cmd_ptype_mapping_update_result,
15463 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype =
15464 TOKEN_NUM_INITIALIZER
15465 (struct cmd_ptype_mapping_update_result,
15469 cmd_ptype_mapping_update_parsed(
15470 void *parsed_result,
15471 __attribute__((unused)) struct cmdline *cl,
15472 __attribute__((unused)) void *data)
15474 struct cmd_ptype_mapping_update_result *res = parsed_result;
15475 int ret = -ENOTSUP;
15476 #ifdef RTE_LIBRTE_I40E_PMD
15477 struct rte_pmd_i40e_ptype_mapping mapping;
15479 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15482 #ifdef RTE_LIBRTE_I40E_PMD
15483 mapping.hw_ptype = res->hw_ptype;
15484 mapping.sw_ptype = res->sw_ptype;
15485 ret = rte_pmd_i40e_ptype_mapping_update(res->port_id,
15495 printf("invalid ptype 0x%8x\n", res->sw_ptype);
15498 printf("invalid port_id %d\n", res->port_id);
15501 printf("function not implemented\n");
15504 printf("programming error: (%s)\n", strerror(-ret));
15508 cmdline_parse_inst_t cmd_ptype_mapping_update = {
15509 .f = cmd_ptype_mapping_update_parsed,
15511 .help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>",
15513 (void *)&cmd_ptype_mapping_update_ptype,
15514 (void *)&cmd_ptype_mapping_update_mapping,
15515 (void *)&cmd_ptype_mapping_update_update,
15516 (void *)&cmd_ptype_mapping_update_port_id,
15517 (void *)&cmd_ptype_mapping_update_hw_ptype,
15518 (void *)&cmd_ptype_mapping_update_sw_ptype,
15523 /* Common result structure for file commands */
15524 struct cmd_cmdfile_result {
15525 cmdline_fixed_string_t load;
15526 cmdline_fixed_string_t filename;
15529 /* Common CLI fields for file commands */
15530 cmdline_parse_token_string_t cmd_load_cmdfile =
15531 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
15532 cmdline_parse_token_string_t cmd_load_cmdfile_filename =
15533 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
15536 cmd_load_from_file_parsed(
15537 void *parsed_result,
15538 __attribute__((unused)) struct cmdline *cl,
15539 __attribute__((unused)) void *data)
15541 struct cmd_cmdfile_result *res = parsed_result;
15543 cmdline_read_from_file(res->filename);
15546 cmdline_parse_inst_t cmd_load_from_file = {
15547 .f = cmd_load_from_file_parsed,
15549 .help_str = "load <filename>",
15551 (void *)&cmd_load_cmdfile,
15552 (void *)&cmd_load_cmdfile_filename,
15557 /* ******************************************************************************** */
15559 /* list of instructions */
15560 cmdline_parse_ctx_t main_ctx[] = {
15561 (cmdline_parse_inst_t *)&cmd_help_brief,
15562 (cmdline_parse_inst_t *)&cmd_help_long,
15563 (cmdline_parse_inst_t *)&cmd_quit,
15564 (cmdline_parse_inst_t *)&cmd_load_from_file,
15565 (cmdline_parse_inst_t *)&cmd_showport,
15566 (cmdline_parse_inst_t *)&cmd_showqueue,
15567 (cmdline_parse_inst_t *)&cmd_showportall,
15568 (cmdline_parse_inst_t *)&cmd_showcfg,
15569 (cmdline_parse_inst_t *)&cmd_start,
15570 (cmdline_parse_inst_t *)&cmd_start_tx_first,
15571 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
15572 (cmdline_parse_inst_t *)&cmd_set_link_up,
15573 (cmdline_parse_inst_t *)&cmd_set_link_down,
15574 (cmdline_parse_inst_t *)&cmd_reset,
15575 (cmdline_parse_inst_t *)&cmd_set_numbers,
15576 (cmdline_parse_inst_t *)&cmd_set_txpkts,
15577 (cmdline_parse_inst_t *)&cmd_set_txsplit,
15578 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
15579 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
15580 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
15581 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
15582 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
15583 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
15584 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
15585 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
15586 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
15587 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
15588 (cmdline_parse_inst_t *)&cmd_set_link_check,
15589 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
15590 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
15591 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
15592 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
15593 #ifdef RTE_LIBRTE_PMD_BOND
15594 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
15595 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
15596 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
15597 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
15598 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
15599 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
15600 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
15601 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
15602 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
15603 (cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues,
15604 (cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy,
15606 (cmdline_parse_inst_t *)&cmd_vlan_offload,
15607 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
15608 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
15609 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
15610 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
15611 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
15612 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
15613 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
15614 (cmdline_parse_inst_t *)&cmd_csum_set,
15615 (cmdline_parse_inst_t *)&cmd_csum_show,
15616 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
15617 (cmdline_parse_inst_t *)&cmd_tso_set,
15618 (cmdline_parse_inst_t *)&cmd_tso_show,
15619 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
15620 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
15621 (cmdline_parse_inst_t *)&cmd_gro_enable,
15622 (cmdline_parse_inst_t *)&cmd_gro_flush,
15623 (cmdline_parse_inst_t *)&cmd_gro_show,
15624 (cmdline_parse_inst_t *)&cmd_gso_enable,
15625 (cmdline_parse_inst_t *)&cmd_gso_size,
15626 (cmdline_parse_inst_t *)&cmd_gso_show,
15627 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
15628 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
15629 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
15630 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
15631 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
15632 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
15633 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
15634 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
15635 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
15636 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
15637 (cmdline_parse_inst_t *)&cmd_config_dcb,
15638 (cmdline_parse_inst_t *)&cmd_read_reg,
15639 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
15640 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
15641 (cmdline_parse_inst_t *)&cmd_write_reg,
15642 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
15643 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
15644 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
15645 (cmdline_parse_inst_t *)&cmd_stop,
15646 (cmdline_parse_inst_t *)&cmd_mac_addr,
15647 (cmdline_parse_inst_t *)&cmd_set_qmap,
15648 (cmdline_parse_inst_t *)&cmd_set_xstats_hide_zero,
15649 (cmdline_parse_inst_t *)&cmd_operate_port,
15650 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
15651 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
15652 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
15653 (cmdline_parse_inst_t *)&cmd_config_speed_all,
15654 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
15655 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
15656 (cmdline_parse_inst_t *)&cmd_config_mtu,
15657 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
15658 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
15659 (cmdline_parse_inst_t *)&cmd_config_rss,
15660 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
15661 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
15662 (cmdline_parse_inst_t *)&cmd_showport_reta,
15663 (cmdline_parse_inst_t *)&cmd_config_burst,
15664 (cmdline_parse_inst_t *)&cmd_config_thresh,
15665 (cmdline_parse_inst_t *)&cmd_config_threshold,
15666 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
15667 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
15668 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
15669 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
15670 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
15671 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
15672 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
15673 (cmdline_parse_inst_t *)&cmd_global_config,
15674 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
15675 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
15676 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
15677 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
15678 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
15679 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
15680 (cmdline_parse_inst_t *)&cmd_dump,
15681 (cmdline_parse_inst_t *)&cmd_dump_one,
15682 (cmdline_parse_inst_t *)&cmd_ethertype_filter,
15683 (cmdline_parse_inst_t *)&cmd_syn_filter,
15684 (cmdline_parse_inst_t *)&cmd_2tuple_filter,
15685 (cmdline_parse_inst_t *)&cmd_5tuple_filter,
15686 (cmdline_parse_inst_t *)&cmd_flex_filter,
15687 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
15688 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
15689 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
15690 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director,
15691 (cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director,
15692 (cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director,
15693 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
15694 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
15695 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
15696 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
15697 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
15698 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
15699 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
15700 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
15701 (cmdline_parse_inst_t *)&cmd_get_hash_global_config,
15702 (cmdline_parse_inst_t *)&cmd_set_hash_global_config,
15703 (cmdline_parse_inst_t *)&cmd_set_hash_input_set,
15704 (cmdline_parse_inst_t *)&cmd_set_fdir_input_set,
15705 (cmdline_parse_inst_t *)&cmd_flow,
15706 (cmdline_parse_inst_t *)&cmd_show_port_meter_cap,
15707 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm,
15708 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm,
15709 (cmdline_parse_inst_t *)&cmd_del_port_meter_profile,
15710 (cmdline_parse_inst_t *)&cmd_create_port_meter,
15711 (cmdline_parse_inst_t *)&cmd_enable_port_meter,
15712 (cmdline_parse_inst_t *)&cmd_disable_port_meter,
15713 (cmdline_parse_inst_t *)&cmd_del_port_meter,
15714 (cmdline_parse_inst_t *)&cmd_set_port_meter_profile,
15715 (cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table,
15716 (cmdline_parse_inst_t *)&cmd_set_port_meter_policer_action,
15717 (cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask,
15718 (cmdline_parse_inst_t *)&cmd_show_port_meter_stats,
15719 (cmdline_parse_inst_t *)&cmd_mcast_addr,
15720 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all,
15721 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific,
15722 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all,
15723 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific,
15724 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_en,
15725 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_dis,
15726 (cmdline_parse_inst_t *)&cmd_config_e_tag_stripping_en_dis,
15727 (cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis,
15728 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_add,
15729 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_del,
15730 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
15731 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
15732 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
15733 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
15734 (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
15735 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
15736 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
15737 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
15738 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
15739 (cmdline_parse_inst_t *)&cmd_set_macsec_sc,
15740 (cmdline_parse_inst_t *)&cmd_set_macsec_sa,
15741 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
15742 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
15743 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
15744 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
15745 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
15746 (cmdline_parse_inst_t *)&cmd_set_vf_promisc,
15747 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
15748 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
15749 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
15750 (cmdline_parse_inst_t *)&cmd_vf_max_bw,
15751 (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
15752 (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
15753 (cmdline_parse_inst_t *)&cmd_strict_link_prio,
15754 (cmdline_parse_inst_t *)&cmd_tc_min_bw,
15755 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
15756 (cmdline_parse_inst_t *)&cmd_set_port_tm_hierarchy_default,
15758 (cmdline_parse_inst_t *)&cmd_ddp_add,
15759 (cmdline_parse_inst_t *)&cmd_ddp_del,
15760 (cmdline_parse_inst_t *)&cmd_ddp_get_list,
15761 (cmdline_parse_inst_t *)&cmd_ddp_get_info,
15762 (cmdline_parse_inst_t *)&cmd_show_vf_stats,
15763 (cmdline_parse_inst_t *)&cmd_clear_vf_stats,
15764 (cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
15765 (cmdline_parse_inst_t *)&cmd_ptype_mapping_replace,
15766 (cmdline_parse_inst_t *)&cmd_ptype_mapping_reset,
15767 (cmdline_parse_inst_t *)&cmd_ptype_mapping_update,
15769 (cmdline_parse_inst_t *)&cmd_pctype_mapping_get,
15770 (cmdline_parse_inst_t *)&cmd_pctype_mapping_reset,
15771 (cmdline_parse_inst_t *)&cmd_pctype_mapping_update,
15772 (cmdline_parse_inst_t *)&cmd_queue_region,
15773 (cmdline_parse_inst_t *)&cmd_region_flowtype,
15774 (cmdline_parse_inst_t *)&cmd_user_priority_region,
15775 (cmdline_parse_inst_t *)&cmd_flush_queue_region,
15776 (cmdline_parse_inst_t *)&cmd_show_queue_region_info_all,
15777 (cmdline_parse_inst_t *)&cmd_show_port_tm_cap,
15778 (cmdline_parse_inst_t *)&cmd_show_port_tm_level_cap,
15779 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_cap,
15780 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_type,
15781 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_stats,
15782 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shaper_profile,
15783 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shaper_profile,
15784 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shared_shaper,
15785 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shared_shaper,
15786 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_wred_profile,
15787 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_wred_profile,
15788 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_shaper_profile,
15789 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node,
15790 (cmdline_parse_inst_t *)&cmd_add_port_tm_leaf_node,
15791 (cmdline_parse_inst_t *)&cmd_del_port_tm_node,
15792 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_parent,
15793 (cmdline_parse_inst_t *)&cmd_port_tm_hierarchy_commit,
15797 /* read cmdline commands from file */
15799 cmdline_read_from_file(const char *filename)
15801 struct cmdline *cl;
15803 cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
15805 printf("Failed to create file based cmdline context: %s\n",
15810 cmdline_interact(cl);
15815 printf("Read CLI commands from %s\n", filename);
15818 /* prompt function, called from main on MASTER lcore */
15822 /* initialize non-constant commands */
15823 cmd_set_fwd_mode_init();
15824 cmd_set_fwd_retry_mode_init();
15826 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
15827 if (testpmd_cl == NULL)
15829 cmdline_interact(testpmd_cl);
15830 cmdline_stdin_exit(testpmd_cl);
15836 if (testpmd_cl != NULL)
15837 cmdline_quit(testpmd_cl);
15841 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
15843 if (id == (portid_t)RTE_PORT_ALL) {
15846 RTE_ETH_FOREACH_DEV(pid) {
15847 /* check if need_reconfig has been set to 1 */
15848 if (ports[pid].need_reconfig == 0)
15849 ports[pid].need_reconfig = dev;
15850 /* check if need_reconfig_queues has been set to 1 */
15851 if (ports[pid].need_reconfig_queues == 0)
15852 ports[pid].need_reconfig_queues = queue;
15854 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
15855 /* check if need_reconfig has been set to 1 */
15856 if (ports[id].need_reconfig == 0)
15857 ports[id].need_reconfig = dev;
15858 /* check if need_reconfig_queues has been set to 1 */
15859 if (ports[id].need_reconfig_queues == 0)
15860 ports[id].need_reconfig_queues = queue;