4 * Copyright(c) 2010-2016 Intel Corporation. All rights reserved.
5 * Copyright(c) 2014 6WIND S.A.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
12 * * Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * * Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in
16 * the documentation and/or other materials provided with the
18 * * Neither the name of Intel Corporation nor the names of its
19 * contributors may be used to endorse or promote products derived
20 * from this software without specific prior written permission.
22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
26 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
28 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
45 #include <net/socket.h>
47 #include <sys/socket.h>
50 #include <netinet/in.h>
52 #include <sys/queue.h>
54 #include <rte_common.h>
55 #include <rte_byteorder.h>
57 #include <rte_debug.h>
58 #include <rte_cycles.h>
59 #include <rte_memory.h>
60 #include <rte_memzone.h>
61 #include <rte_malloc.h>
62 #include <rte_launch.h>
64 #include <rte_per_lcore.h>
65 #include <rte_lcore.h>
66 #include <rte_atomic.h>
67 #include <rte_branch_prediction.h>
69 #include <rte_mempool.h>
70 #include <rte_interrupts.h>
72 #include <rte_ether.h>
73 #include <rte_ethdev.h>
74 #include <rte_string_fns.h>
75 #include <rte_devargs.h>
76 #include <rte_eth_ctrl.h>
80 #include <cmdline_rdline.h>
81 #include <cmdline_parse.h>
82 #include <cmdline_parse_num.h>
83 #include <cmdline_parse_string.h>
84 #include <cmdline_parse_ipaddr.h>
85 #include <cmdline_parse_etheraddr.h>
86 #include <cmdline_socket.h>
88 #ifdef RTE_LIBRTE_PMD_BOND
89 #include <rte_eth_bond.h>
90 #include <rte_eth_bond_8023ad.h>
92 #ifdef RTE_LIBRTE_IXGBE_PMD
93 #include <rte_pmd_ixgbe.h>
95 #ifdef RTE_LIBRTE_I40E_PMD
96 #include <rte_pmd_i40e.h>
98 #ifdef RTE_LIBRTE_BNXT_PMD
99 #include <rte_pmd_bnxt.h>
102 #include "cmdline_mtr.h"
103 #include "cmdline_tm.h"
105 static struct cmdline *testpmd_cl;
107 static void cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue);
109 /* *** Help command with introduction. *** */
110 struct cmd_help_brief_result {
111 cmdline_fixed_string_t help;
114 static void cmd_help_brief_parsed(__attribute__((unused)) void *parsed_result,
116 __attribute__((unused)) void *data)
121 "Help is available for the following sections:\n\n"
122 " help control : Start and stop forwarding.\n"
123 " help display : Displaying port, stats and config "
125 " help config : Configuration information.\n"
126 " help ports : Configuring ports.\n"
127 " help registers : Reading and setting port registers.\n"
128 " help filters : Filters configuration help.\n"
129 " help all : All of the above sections.\n\n"
134 cmdline_parse_token_string_t cmd_help_brief_help =
135 TOKEN_STRING_INITIALIZER(struct cmd_help_brief_result, help, "help");
137 cmdline_parse_inst_t cmd_help_brief = {
138 .f = cmd_help_brief_parsed,
140 .help_str = "help: Show help",
142 (void *)&cmd_help_brief_help,
147 /* *** Help command with help sections. *** */
148 struct cmd_help_long_result {
149 cmdline_fixed_string_t help;
150 cmdline_fixed_string_t section;
153 static void cmd_help_long_parsed(void *parsed_result,
155 __attribute__((unused)) void *data)
158 struct cmd_help_long_result *res = parsed_result;
160 if (!strcmp(res->section, "all"))
163 if (show_all || !strcmp(res->section, "control")) {
168 "Control forwarding:\n"
169 "-------------------\n\n"
172 " Start packet forwarding with current configuration.\n\n"
175 " Start packet forwarding with current config"
176 " after sending one burst of packets.\n\n"
179 " Stop packet forwarding, and display accumulated"
183 " Quit to prompt.\n\n"
187 if (show_all || !strcmp(res->section, "display")) {
195 "show port (info|stats|xstats|fdir|stat_qmap|dcb_tc|cap) (port_id|all)\n"
196 " Display information for port_id, or all.\n\n"
198 "show port X rss reta (size) (mask0,mask1,...)\n"
199 " Display the rss redirection table entry indicated"
200 " by masks on port X. size is used to indicate the"
201 " hardware supported reta size\n\n"
203 "show port rss-hash ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|"
204 "ipv4-sctp|ipv4-other|ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
205 "ipv6-other|l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex [key]\n"
206 " Display the RSS hash functions and RSS hash key"
209 "clear port (info|stats|xstats|fdir|stat_qmap) (port_id|all)\n"
210 " Clear information for port_id, or all.\n\n"
212 "show (rxq|txq) info (port_id) (queue_id)\n"
213 " Display information for configured RX/TX queue.\n\n"
215 "show config (rxtx|cores|fwd|txpkts)\n"
216 " Display the given configuration.\n\n"
218 "read rxd (port_id) (queue_id) (rxd_id)\n"
219 " Display an RX descriptor of a port RX queue.\n\n"
221 "read txd (port_id) (queue_id) (txd_id)\n"
222 " Display a TX descriptor of a port TX queue.\n\n"
224 "ddp get list (port_id)\n"
225 " Get ddp profile info list\n\n"
227 "ddp get info (profile_path)\n"
228 " Get ddp profile information.\n\n"
230 "show vf stats (port_id) (vf_id)\n"
231 " Display a VF's statistics.\n\n"
233 "clear vf stats (port_id) (vf_id)\n"
234 " Reset a VF's statistics.\n\n"
236 "show port (port_id) pctype mapping\n"
237 " Get flow ptype to pctype mapping on a port\n\n"
239 "show port meter stats (port_id) (meter_id) (clear)\n"
240 " Get meter stats on a port\n\n"
241 "show port tm cap (port_id)\n"
242 " Display the port TM capability.\n\n"
244 "show port tm level cap (port_id) (level_id)\n"
245 " Display the port TM hierarchical level capability.\n\n"
247 "show port tm node cap (port_id) (node_id)\n"
248 " Display the port TM node capability.\n\n"
250 "show port tm node type (port_id) (node_id)\n"
251 " Display the port TM node type.\n\n"
253 "show port tm node stats (port_id) (node_id) (clear)\n"
254 " Display the port TM node stats.\n\n"
259 if (show_all || !strcmp(res->section, "config")) {
265 "Configuration changes only become active when"
266 " forwarding is started/restarted.\n\n"
269 " Reset forwarding to the default configuration.\n\n"
271 "set verbose (level)\n"
272 " Set the debug verbosity level X.\n\n"
275 " Set number of ports.\n\n"
278 " Set number of cores.\n\n"
280 "set coremask (mask)\n"
281 " Set the forwarding cores hexadecimal mask.\n\n"
283 "set portmask (mask)\n"
284 " Set the forwarding ports hexadecimal mask.\n\n"
287 " Set number of packets per burst.\n\n"
289 "set burst tx delay (microseconds) retry (num)\n"
290 " Set the transmit delay time and number of retries,"
291 " effective when retry is enabled.\n\n"
293 "set txpkts (x[,y]*)\n"
294 " Set the length of each segment of TXONLY"
295 " and optionally CSUM packets.\n\n"
297 "set txsplit (off|on|rand)\n"
298 " Set the split policy for the TX packets."
299 " Right now only applicable for CSUM and TXONLY"
302 "set corelist (x[,y]*)\n"
303 " Set the list of forwarding cores.\n\n"
305 "set portlist (x[,y]*)\n"
306 " Set the list of forwarding ports.\n\n"
308 "set tx loopback (port_id) (on|off)\n"
309 " Enable or disable tx loopback.\n\n"
311 "set all queues drop (port_id) (on|off)\n"
312 " Set drop enable bit for all queues.\n\n"
314 "set vf split drop (port_id) (vf_id) (on|off)\n"
315 " Set split drop enable bit for a VF from the PF.\n\n"
317 "set vf mac antispoof (port_id) (vf_id) (on|off).\n"
318 " Set MAC antispoof for a VF from the PF.\n\n"
320 "set macsec offload (port_id) on encrypt (on|off) replay-protect (on|off)\n"
321 " Enable MACsec offload.\n\n"
323 "set macsec offload (port_id) off\n"
324 " Disable MACsec offload.\n\n"
326 "set macsec sc (tx|rx) (port_id) (mac) (pi)\n"
327 " Configure MACsec secure connection (SC).\n\n"
329 "set macsec sa (tx|rx) (port_id) (idx) (an) (pn) (key)\n"
330 " Configure MACsec secure association (SA).\n\n"
332 "set vf broadcast (port_id) (vf_id) (on|off)\n"
333 " Set VF broadcast for a VF from the PF.\n\n"
335 "vlan set strip (on|off) (port_id)\n"
336 " Set the VLAN strip on a port.\n\n"
338 "vlan set stripq (on|off) (port_id,queue_id)\n"
339 " Set the VLAN strip for a queue on a port.\n\n"
341 "set vf vlan stripq (port_id) (vf_id) (on|off)\n"
342 " Set the VLAN strip for all queues in a pool for a VF from the PF.\n\n"
344 "set vf vlan insert (port_id) (vf_id) (vlan_id)\n"
345 " Set VLAN insert for a VF from the PF.\n\n"
347 "set vf vlan antispoof (port_id) (vf_id) (on|off)\n"
348 " Set VLAN antispoof for a VF from the PF.\n\n"
350 "set vf vlan tag (port_id) (vf_id) (on|off)\n"
351 " Set VLAN tag for a VF from the PF.\n\n"
353 "set vf tx max-bandwidth (port_id) (vf_id) (bandwidth)\n"
354 " Set a VF's max bandwidth(Mbps).\n\n"
356 "set vf tc tx min-bandwidth (port_id) (vf_id) (bw1, bw2, ...)\n"
357 " Set all TCs' min bandwidth(%%) on a VF.\n\n"
359 "set vf tc tx max-bandwidth (port_id) (vf_id) (tc_no) (bandwidth)\n"
360 " Set a TC's max bandwidth(Mbps) on a VF.\n\n"
362 "set tx strict-link-priority (port_id) (tc_bitmap)\n"
363 " Set some TCs' strict link priority mode on a physical port.\n\n"
365 "set tc tx min-bandwidth (port_id) (bw1, bw2, ...)\n"
366 " Set all TCs' min bandwidth(%%) for all PF and VFs.\n\n"
368 "vlan set filter (on|off) (port_id)\n"
369 " Set the VLAN filter on a port.\n\n"
371 "vlan set qinq (on|off) (port_id)\n"
372 " Set the VLAN QinQ (extended queue in queue)"
375 "vlan set (inner|outer) tpid (value) (port_id)\n"
376 " Set the VLAN TPID for Packet Filtering on"
379 "rx_vlan add (vlan_id|all) (port_id)\n"
380 " Add a vlan_id, or all identifiers, to the set"
381 " of VLAN identifiers filtered by port_id.\n\n"
383 "rx_vlan rm (vlan_id|all) (port_id)\n"
384 " Remove a vlan_id, or all identifiers, from the set"
385 " of VLAN identifiers filtered by port_id.\n\n"
387 "rx_vlan add (vlan_id) port (port_id) vf (vf_mask)\n"
388 " Add a vlan_id, to the set of VLAN identifiers"
389 "filtered for VF(s) from port_id.\n\n"
391 "rx_vlan rm (vlan_id) port (port_id) vf (vf_mask)\n"
392 " Remove a vlan_id, to the set of VLAN identifiers"
393 "filtered for VF(s) from port_id.\n\n"
395 "tunnel_filter add (port_id) (outer_mac) (inner_mac) (ip_addr) "
396 "(inner_vlan) (vxlan|nvgre|ipingre) (imac-ivlan|imac-ivlan-tenid|"
397 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n"
398 " add a tunnel filter of a port.\n\n"
400 "tunnel_filter rm (port_id) (outer_mac) (inner_mac) (ip_addr) "
401 "(inner_vlan) (vxlan|nvgre|ipingre) (imac-ivlan|imac-ivlan-tenid|"
402 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n"
403 " remove a tunnel filter of a port.\n\n"
405 "rx_vxlan_port add (udp_port) (port_id)\n"
406 " Add an UDP port for VXLAN packet filter on a port\n\n"
408 "rx_vxlan_port rm (udp_port) (port_id)\n"
409 " Remove an UDP port for VXLAN packet filter on a port\n\n"
411 "tx_vlan set (port_id) vlan_id[, vlan_id_outer]\n"
412 " Set hardware insertion of VLAN IDs (single or double VLAN "
413 "depends on the number of VLAN IDs) in packets sent on a port.\n\n"
415 "tx_vlan set pvid port_id vlan_id (on|off)\n"
416 " Set port based TX VLAN insertion.\n\n"
418 "tx_vlan reset (port_id)\n"
419 " Disable hardware insertion of a VLAN header in"
420 " packets sent on a port.\n\n"
422 "csum set (ip|udp|tcp|sctp|outer-ip) (hw|sw) (port_id)\n"
423 " Select hardware or software calculation of the"
424 " checksum when transmitting a packet using the"
425 " csum forward engine.\n"
426 " ip|udp|tcp|sctp always concern the inner layer.\n"
427 " outer-ip concerns the outer IP layer in"
428 " case the packet is recognized as a tunnel packet by"
429 " the forward engine (vxlan, gre and ipip are supported)\n"
430 " Please check the NIC datasheet for HW limits.\n\n"
432 "csum parse-tunnel (on|off) (tx_port_id)\n"
433 " If disabled, treat tunnel packets as non-tunneled"
434 " packets (treat inner headers as payload). The port\n"
435 " argument is the port used for TX in csum forward"
438 "csum show (port_id)\n"
439 " Display tx checksum offload configuration\n\n"
441 "tso set (segsize) (portid)\n"
442 " Enable TCP Segmentation Offload in csum forward"
444 " Please check the NIC datasheet for HW limits.\n\n"
447 " Display the status of TCP Segmentation Offload.\n\n"
449 "set port (port_id) gro on|off\n"
450 " Enable or disable Generic Receive Offload in"
451 " csum forwarding engine.\n\n"
453 "show port (port_id) gro\n"
454 " Display GRO configuration.\n\n"
456 "set gro flush (cycles)\n"
457 " Set the cycle to flush GROed packets from"
458 " reassembly tables.\n\n"
460 "set port (port_id) gso (on|off)"
461 " Enable or disable Generic Segmentation Offload in"
462 " csum forwarding engine.\n\n"
464 "set gso segsz (length)\n"
465 " Set max packet length for output GSO segments,"
466 " including packet header and payload.\n\n"
468 "show port (port_id) gso\n"
469 " Show GSO configuration.\n\n"
472 " Set packet forwarding mode.\n\n"
474 "mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n"
475 " Add a MAC address on port_id.\n\n"
477 "mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n"
478 " Remove a MAC address from port_id.\n\n"
480 "mac_addr set (port_id) (XX:XX:XX:XX:XX:XX)\n"
481 " Set the default MAC address for port_id.\n\n"
483 "mac_addr add port (port_id) vf (vf_id) (mac_address)\n"
484 " Add a MAC address for a VF on the port.\n\n"
486 "set vf mac addr (port_id) (vf_id) (XX:XX:XX:XX:XX:XX)\n"
487 " Set the MAC address for a VF from the PF.\n\n"
489 "set port (port_id) uta (mac_address|all) (on|off)\n"
490 " Add/Remove a or all unicast hash filter(s)"
493 "set promisc (port_id|all) (on|off)\n"
494 " Set the promiscuous mode on port_id, or all.\n\n"
496 "set allmulti (port_id|all) (on|off)\n"
497 " Set the allmulti mode on port_id, or all.\n\n"
499 "set vf promisc (port_id) (vf_id) (on|off)\n"
500 " Set unicast promiscuous mode for a VF from the PF.\n\n"
502 "set vf allmulti (port_id) (vf_id) (on|off)\n"
503 " Set multicast promiscuous mode for a VF from the PF.\n\n"
505 "set flow_ctrl rx (on|off) tx (on|off) (high_water)"
506 " (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd"
507 " (on|off) autoneg (on|off) (port_id)\n"
508 "set flow_ctrl rx (on|off) (portid)\n"
509 "set flow_ctrl tx (on|off) (portid)\n"
510 "set flow_ctrl high_water (high_water) (portid)\n"
511 "set flow_ctrl low_water (low_water) (portid)\n"
512 "set flow_ctrl pause_time (pause_time) (portid)\n"
513 "set flow_ctrl send_xon (send_xon) (portid)\n"
514 "set flow_ctrl mac_ctrl_frame_fwd (on|off) (portid)\n"
515 "set flow_ctrl autoneg (on|off) (port_id)\n"
516 " Set the link flow control parameter on a port.\n\n"
518 "set pfc_ctrl rx (on|off) tx (on|off) (high_water)"
519 " (low_water) (pause_time) (priority) (port_id)\n"
520 " Set the priority flow control parameter on a"
523 "set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n"
524 " Set statistics mapping (qmapping 0..15) for RX/TX"
526 " e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2"
527 " on port 0 to mapping 5.\n\n"
529 "set xstats-hide-zero on|off\n"
530 " Set the option to hide the zero values"
531 " for xstats display.\n"
533 "set port (port_id) vf (vf_id) rx|tx on|off\n"
534 " Enable/Disable a VF receive/tranmit from a port\n\n"
536 "set port (port_id) vf (vf_id) (mac_addr)"
537 " (exact-mac#exact-mac-vlan#hashmac|hashmac-vlan) on|off\n"
538 " Add/Remove unicast or multicast MAC addr filter"
541 "set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM"
543 " AUPE:accepts untagged VLAN;"
544 "ROPE:accept unicast hash\n\n"
545 " BAM:accepts broadcast packets;"
546 "MPE:accepts all multicast packets\n\n"
547 " Enable/Disable a VF receive mode of a port\n\n"
549 "set port (port_id) queue (queue_id) rate (rate_num)\n"
550 " Set rate limit for a queue of a port\n\n"
552 "set port (port_id) vf (vf_id) rate (rate_num) "
553 "queue_mask (queue_mask_value)\n"
554 " Set rate limit for queues in VF of a port\n\n"
556 "set port (port_id) mirror-rule (rule_id)"
557 " (pool-mirror-up|pool-mirror-down|vlan-mirror)"
558 " (poolmask|vlanid[,vlanid]*) dst-pool (pool_id) (on|off)\n"
559 " Set pool or vlan type mirror rule on a port.\n"
560 " e.g., 'set port 0 mirror-rule 0 vlan-mirror 0,1"
561 " dst-pool 0 on' enable mirror traffic with vlan 0,1"
564 "set port (port_id) mirror-rule (rule_id)"
565 " (uplink-mirror|downlink-mirror) dst-pool"
566 " (pool_id) (on|off)\n"
567 " Set uplink or downlink type mirror rule on a port.\n"
568 " e.g., 'set port 0 mirror-rule 0 uplink-mirror dst-pool"
569 " 0 on' enable mirror income traffic to pool 0.\n\n"
571 "reset port (port_id) mirror-rule (rule_id)\n"
572 " Reset a mirror rule.\n\n"
574 "set flush_rx (on|off)\n"
575 " Flush (default) or don't flush RX streams before"
576 " forwarding. Mainly used with PCAP drivers.\n\n"
578 "set bypass mode (normal|bypass|isolate) (port_id)\n"
579 " Set the bypass mode for the lowest port on bypass enabled"
582 "set bypass event (timeout|os_on|os_off|power_on|power_off) "
583 "mode (normal|bypass|isolate) (port_id)\n"
584 " Set the event required to initiate specified bypass mode for"
585 " the lowest port on a bypass enabled NIC where:\n"
586 " timeout = enable bypass after watchdog timeout.\n"
587 " os_on = enable bypass when OS/board is powered on.\n"
588 " os_off = enable bypass when OS/board is powered off.\n"
589 " power_on = enable bypass when power supply is turned on.\n"
590 " power_off = enable bypass when power supply is turned off."
593 "set bypass timeout (0|1.5|2|3|4|8|16|32)\n"
594 " Set the bypass watchdog timeout to 'n' seconds"
595 " where 0 = instant.\n\n"
597 "show bypass config (port_id)\n"
598 " Show the bypass configuration for a bypass enabled NIC"
599 " using the lowest port on the NIC.\n\n"
601 #ifdef RTE_LIBRTE_PMD_BOND
602 "create bonded device (mode) (socket)\n"
603 " Create a new bonded device with specific bonding mode and socket.\n\n"
605 "add bonding slave (slave_id) (port_id)\n"
606 " Add a slave device to a bonded device.\n\n"
608 "remove bonding slave (slave_id) (port_id)\n"
609 " Remove a slave device from a bonded device.\n\n"
611 "set bonding mode (value) (port_id)\n"
612 " Set the bonding mode on a bonded device.\n\n"
614 "set bonding primary (slave_id) (port_id)\n"
615 " Set the primary slave for a bonded device.\n\n"
617 "show bonding config (port_id)\n"
618 " Show the bonding config for port_id.\n\n"
620 "set bonding mac_addr (port_id) (address)\n"
621 " Set the MAC address of a bonded device.\n\n"
623 "set bonding mode IEEE802.3AD aggregator policy (port_id) (agg_name)"
624 " Set Aggregation mode for IEEE802.3AD (mode 4)"
626 "set bonding xmit_balance_policy (port_id) (l2|l23|l34)\n"
627 " Set the transmit balance policy for bonded device running in balance mode.\n\n"
629 "set bonding mon_period (port_id) (value)\n"
630 " Set the bonding link status monitoring polling period in ms.\n\n"
632 "set bonding lacp dedicated_queues <port_id> (enable|disable)\n"
633 " Enable/disable dedicated queues for LACP control traffic.\n\n"
636 "set link-up port (port_id)\n"
637 " Set link up for a port.\n\n"
639 "set link-down port (port_id)\n"
640 " Set link down for a port.\n\n"
642 "E-tag set insertion on port-tag-id (value)"
643 " port (port_id) vf (vf_id)\n"
644 " Enable E-tag insertion for a VF on a port\n\n"
646 "E-tag set insertion off port (port_id) vf (vf_id)\n"
647 " Disable E-tag insertion for a VF on a port\n\n"
649 "E-tag set stripping (on|off) port (port_id)\n"
650 " Enable/disable E-tag stripping on a port\n\n"
652 "E-tag set forwarding (on|off) port (port_id)\n"
653 " Enable/disable E-tag based forwarding"
656 "E-tag set filter add e-tag-id (value) dst-pool"
657 " (pool_id) port (port_id)\n"
658 " Add an E-tag forwarding filter on a port\n\n"
660 "E-tag set filter del e-tag-id (value) port (port_id)\n"
661 " Delete an E-tag forwarding filter on a port\n\n"
663 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
664 "set port tm hierarchy default (port_id)\n"
665 " Set default traffic Management hierarchy on a port\n\n"
668 "ddp add (port_id) (profile_path[,output_path])\n"
669 " Load a profile package on a port\n\n"
671 "ddp del (port_id) (profile_path)\n"
672 " Delete a profile package from a port\n\n"
674 "ptype mapping get (port_id) (valid_only)\n"
675 " Get ptype mapping on a port\n\n"
677 "ptype mapping replace (port_id) (target) (mask) (pky_type)\n"
678 " Replace target with the pkt_type in ptype mapping\n\n"
680 "ptype mapping reset (port_id)\n"
681 " Reset ptype mapping on a port\n\n"
683 "ptype mapping update (port_id) (hw_ptype) (sw_ptype)\n"
684 " Update a ptype mapping item on a port\n\n"
686 "set port (port_id) queue-region region_id (value) "
687 "queue_start_index (value) queue_num (value)\n"
688 " Set a queue region on a port\n\n"
690 "set port (port_id) queue-region region_id (value) "
692 " Set a flowtype region index on a port\n\n"
694 "set port (port_id) queue-region UP (value) region_id (value)\n"
695 " Set the mapping of User Priority to "
696 "queue region on a port\n\n"
698 "set port (port_id) queue-region flush (on|off)\n"
699 " flush all queue region related configuration\n\n"
701 "show port meter cap (port_id)\n"
702 " Show port meter capability information\n\n"
704 "add port meter profile srtcm_rfc2697 (port_id) (profile_id) (cir) (cbs) (ebs)\n"
705 " meter profile add - srtcm rfc 2697\n\n"
707 "add port meter profile trtcm_rfc2698 (port_id) (profile_id) (cir) (pir) (cbs) (pbs)\n"
708 " meter profile add - trtcm rfc 2698\n\n"
710 "add port meter profile trtcm_rfc4115 (port_id) (profile_id) (cir) (eir) (cbs) (ebs)\n"
711 " meter profile add - trtcm rfc 4115\n\n"
713 "del port meter profile (port_id) (profile_id)\n"
714 " meter profile delete\n\n"
716 "create port meter (port_id) (mtr_id) (profile_id) (meter_enable)\n"
717 "(g_action) (y_action) (r_action) (stats_mask) (shared)\n"
718 "(use_pre_meter_color) [(dscp_tbl_entry0) (dscp_tbl_entry1)...\n"
719 "(dscp_tbl_entry63)]\n"
722 "enable port meter (port_id) (mtr_id)\n"
725 "disable port meter (port_id) (mtr_id)\n"
728 "del port meter (port_id) (mtr_id)\n"
731 "set port meter profile (port_id) (mtr_id) (profile_id)\n"
732 " meter update meter profile\n\n"
734 "set port meter dscp table (port_id) (mtr_id) [(dscp_tbl_entry0)\n"
735 "(dscp_tbl_entry1)...(dscp_tbl_entry63)]\n"
736 " update meter dscp table entries\n\n"
738 "set port meter policer action (port_id) (mtr_id) (action_mask)\n"
739 "(action0) [(action1) (action2)]\n"
740 " meter update policer action\n\n"
742 "set port meter stats mask (port_id) (mtr_id) (stats_mask)\n"
743 " meter update stats\n\n"
745 "show port (port_id) queue-region\n"
746 " show all queue region related configuration info\n\n"
748 "add port tm node shaper profile (port_id) (shaper_profile_id)"
749 " (tb_rate) (tb_size) (packet_length_adjust)\n"
750 " Add port tm node private shaper profile.\n\n"
752 "del port tm node shaper profile (port_id) (shaper_profile_id)\n"
753 " Delete port tm node private shaper profile.\n\n"
755 "add port tm node shared shaper (port_id) (shared_shaper_id)"
756 " (shaper_profile_id)\n"
757 " Add/update port tm node shared shaper.\n\n"
759 "del port tm node shared shaper (port_id) (shared_shaper_id)\n"
760 " Delete port tm node shared shaper.\n\n"
762 "set port tm node shaper profile (port_id) (node_id)"
763 " (shaper_profile_id)\n"
764 " Set port tm node shaper profile.\n\n"
766 "add port tm node wred profile (port_id) (wred_profile_id)"
767 " (color_g) (min_th_g) (max_th_g) (maxp_inv_g) (wq_log2_g)"
768 " (color_y) (min_th_y) (max_th_y) (maxp_inv_y) (wq_log2_y)"
769 " (color_r) (min_th_r) (max_th_r) (maxp_inv_r) (wq_log2_r)\n"
770 " Add port tm node wred profile.\n\n"
772 "del port tm node wred profile (port_id) (wred_profile_id)\n"
773 " Delete port tm node wred profile.\n\n"
775 "add port tm nonleaf node (port_id) (node_id) (parent_node_id)"
776 " (priority) (weight) (level_id) (shaper_profile_id)"
777 " (n_sp_priorities) (stats_mask) (n_shared_shapers)"
778 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
779 " Add port tm nonleaf node.\n\n"
781 "add port tm leaf node (port_id) (node_id) (parent_node_id)"
782 " (priority) (weight) (level_id) (shaper_profile_id)"
783 " (cman_mode) (wred_profile_id) (stats_mask) (n_shared_shapers)"
784 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
785 " Add port tm leaf node.\n\n"
787 "del port tm node (port_id) (node_id)\n"
788 " Delete port tm node.\n\n"
790 "set port tm node parent (port_id) (node_id) (parent_node_id)"
791 " (priority) (weight)\n"
792 " Set port tm node parent.\n\n"
794 "port tm hierarchy commit (port_id) (clean_on_fail)\n"
795 " Commit tm hierarchy.\n\n"
797 , list_pkt_forwarding_modes()
801 if (show_all || !strcmp(res->section, "ports")) {
807 "----------------\n\n"
809 "port start (port_id|all)\n"
810 " Start all ports or port_id.\n\n"
812 "port stop (port_id|all)\n"
813 " Stop all ports or port_id.\n\n"
815 "port close (port_id|all)\n"
816 " Close all ports or port_id.\n\n"
818 "port attach (ident)\n"
819 " Attach physical or virtual dev by pci address or virtual device name\n\n"
821 "port detach (port_id)\n"
822 " Detach physical or virtual dev by port_id\n\n"
824 "port config (port_id|all)"
825 " speed (10|100|1000|10000|25000|40000|50000|100000|auto)"
826 " duplex (half|full|auto)\n"
827 " Set speed and duplex for all ports or port_id\n\n"
829 "port config all (rxq|txq|rxd|txd) (value)\n"
830 " Set number for rxq/txq/rxd/txd.\n\n"
832 "port config all max-pkt-len (value)\n"
833 " Set the max packet length.\n\n"
835 "port config all (crc-strip|scatter|rx-cksum|rx-timestamp|hw-vlan|hw-vlan-filter|"
836 "hw-vlan-strip|hw-vlan-extend|drop-en)"
838 " Set crc-strip/scatter/rx-checksum/hardware-vlan/drop_en"
841 "port config all rss (all|ip|tcp|udp|sctp|ether|port|vxlan|"
842 "geneve|nvgre|none|<flowtype_id>)\n"
843 " Set the RSS mode.\n\n"
845 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
846 " Set the RSS redirection table.\n\n"
848 "port config (port_id) dcb vt (on|off) (traffic_class)"
850 " Set the DCB mode.\n\n"
852 "port config all burst (value)\n"
853 " Set the number of packets per burst.\n\n"
855 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
857 " Set the ring prefetch/host/writeback threshold"
858 " for tx/rx queue.\n\n"
860 "port config all (txfreet|txrst|rxfreet) (value)\n"
861 " Set free threshold for rx/tx, or set"
862 " tx rs bit threshold.\n\n"
863 "port config mtu X value\n"
864 " Set the MTU of port X to a given value\n\n"
866 "port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
867 " Start/stop a rx/tx queue of port X. Only take effect"
868 " when port X is started\n\n"
870 "port config (port_id|all) l2-tunnel E-tag ether-type"
872 " Set the value of E-tag ether-type.\n\n"
874 "port config (port_id|all) l2-tunnel E-tag"
875 " (enable|disable)\n"
876 " Enable/disable the E-tag support.\n\n"
878 "port config (port_id) pctype mapping reset\n"
879 " Reset flow type to pctype mapping on a port\n\n"
881 "port config (port_id) pctype mapping update"
882 " (pctype_id_0[,pctype_id_1]*) (flow_type_id)\n"
883 " Update a flow type to pctype mapping item on a port\n\n"
887 if (show_all || !strcmp(res->section, "registers")) {
895 "read reg (port_id) (address)\n"
896 " Display value of a port register.\n\n"
898 "read regfield (port_id) (address) (bit_x) (bit_y)\n"
899 " Display a port register bit field.\n\n"
901 "read regbit (port_id) (address) (bit_x)\n"
902 " Display a single port register bit.\n\n"
904 "write reg (port_id) (address) (value)\n"
905 " Set value of a port register.\n\n"
907 "write regfield (port_id) (address) (bit_x) (bit_y)"
909 " Set bit field of a port register.\n\n"
911 "write regbit (port_id) (address) (bit_x) (value)\n"
912 " Set single bit value of a port register.\n\n"
915 if (show_all || !strcmp(res->section, "filters")) {
923 "ethertype_filter (port_id) (add|del)"
924 " (mac_addr|mac_ignr) (mac_address) ethertype"
925 " (ether_type) (drop|fwd) queue (queue_id)\n"
926 " Add/Del an ethertype filter.\n\n"
928 "2tuple_filter (port_id) (add|del)"
929 " dst_port (dst_port_value) protocol (protocol_value)"
930 " mask (mask_value) tcp_flags (tcp_flags_value)"
931 " priority (prio_value) queue (queue_id)\n"
932 " Add/Del a 2tuple filter.\n\n"
934 "5tuple_filter (port_id) (add|del)"
935 " dst_ip (dst_address) src_ip (src_address)"
936 " dst_port (dst_port_value) src_port (src_port_value)"
937 " protocol (protocol_value)"
938 " mask (mask_value) tcp_flags (tcp_flags_value)"
939 " priority (prio_value) queue (queue_id)\n"
940 " Add/Del a 5tuple filter.\n\n"
942 "syn_filter (port_id) (add|del) priority (high|low) queue (queue_id)"
943 " Add/Del syn filter.\n\n"
945 "flex_filter (port_id) (add|del) len (len_value)"
946 " bytes (bytes_value) mask (mask_value)"
947 " priority (prio_value) queue (queue_id)\n"
948 " Add/Del a flex filter.\n\n"
950 "flow_director_filter (port_id) mode IP (add|del|update)"
951 " flow (ipv4-other|ipv4-frag|ipv6-other|ipv6-frag)"
952 " src (src_ip_address) dst (dst_ip_address)"
953 " tos (tos_value) proto (proto_value) ttl (ttl_value)"
954 " vlan (vlan_value) flexbytes (flexbytes_value)"
955 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
956 " fd_id (fd_id_value)\n"
957 " Add/Del an IP type flow director filter.\n\n"
959 "flow_director_filter (port_id) mode IP (add|del|update)"
960 " flow (ipv4-tcp|ipv4-udp|ipv6-tcp|ipv6-udp)"
961 " src (src_ip_address) (src_port)"
962 " dst (dst_ip_address) (dst_port)"
963 " tos (tos_value) ttl (ttl_value)"
964 " vlan (vlan_value) flexbytes (flexbytes_value)"
965 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
966 " fd_id (fd_id_value)\n"
967 " Add/Del an UDP/TCP type flow director filter.\n\n"
969 "flow_director_filter (port_id) mode IP (add|del|update)"
970 " flow (ipv4-sctp|ipv6-sctp)"
971 " src (src_ip_address) (src_port)"
972 " dst (dst_ip_address) (dst_port)"
973 " tag (verification_tag) "
974 " tos (tos_value) ttl (ttl_value)"
976 " flexbytes (flexbytes_value) (drop|fwd)"
977 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
978 " Add/Del a SCTP type flow director filter.\n\n"
980 "flow_director_filter (port_id) mode IP (add|del|update)"
981 " flow l2_payload ether (ethertype)"
982 " flexbytes (flexbytes_value) (drop|fwd)"
983 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
984 " Add/Del a l2 payload type flow director filter.\n\n"
986 "flow_director_filter (port_id) mode MAC-VLAN (add|del|update)"
987 " mac (mac_address) vlan (vlan_value)"
988 " flexbytes (flexbytes_value) (drop|fwd)"
989 " queue (queue_id) fd_id (fd_id_value)\n"
990 " Add/Del a MAC-VLAN flow director filter.\n\n"
992 "flow_director_filter (port_id) mode Tunnel (add|del|update)"
993 " mac (mac_address) vlan (vlan_value)"
994 " tunnel (NVGRE|VxLAN) tunnel-id (tunnel_id_value)"
995 " flexbytes (flexbytes_value) (drop|fwd)"
996 " queue (queue_id) fd_id (fd_id_value)\n"
997 " Add/Del a Tunnel flow director filter.\n\n"
999 "flush_flow_director (port_id)\n"
1000 " Flush all flow director entries of a device.\n\n"
1002 "flow_director_mask (port_id) mode IP vlan (vlan_value)"
1003 " src_mask (ipv4_src) (ipv6_src) (src_port)"
1004 " dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n"
1005 " Set flow director IP mask.\n\n"
1007 "flow_director_mask (port_id) mode MAC-VLAN"
1008 " vlan (vlan_value)\n"
1009 " Set flow director MAC-VLAN mask.\n\n"
1011 "flow_director_mask (port_id) mode Tunnel"
1012 " vlan (vlan_value) mac (mac_value)"
1013 " tunnel-type (tunnel_type_value)"
1014 " tunnel-id (tunnel_id_value)\n"
1015 " Set flow director Tunnel mask.\n\n"
1017 "flow_director_flex_mask (port_id)"
1018 " flow (none|ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
1019 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|l2_payload|all)"
1021 " Configure mask of flex payload.\n\n"
1023 "flow_director_flex_payload (port_id)"
1024 " (raw|l2|l3|l4) (config)\n"
1025 " Configure flex payload selection.\n\n"
1027 "get_sym_hash_ena_per_port (port_id)\n"
1028 " get symmetric hash enable configuration per port.\n\n"
1030 "set_sym_hash_ena_per_port (port_id) (enable|disable)\n"
1031 " set symmetric hash enable configuration per port"
1032 " to enable or disable.\n\n"
1034 "get_hash_global_config (port_id)\n"
1035 " Get the global configurations of hash filters.\n\n"
1037 "set_hash_global_config (port_id) (toeplitz|simple_xor|default)"
1038 " (ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
1039 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload)"
1040 " (enable|disable)\n"
1041 " Set the global configurations of hash filters.\n\n"
1043 "set_hash_input_set (port_id) (ipv4|ipv4-frag|"
1044 "ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
1045 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1046 "l2_payload|<flowtype_id>) (ovlan|ivlan|src-ipv4|dst-ipv4|"
1047 "src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|ipv6-tc|"
1048 "ipv6-next-header|udp-src-port|udp-dst-port|"
1049 "tcp-src-port|tcp-dst-port|sctp-src-port|"
1050 "sctp-dst-port|sctp-veri-tag|udp-key|gre-key|fld-1st|"
1051 "fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|fld-7th|"
1052 "fld-8th|none) (select|add)\n"
1053 " Set the input set for hash.\n\n"
1055 "set_fdir_input_set (port_id) "
1056 "(ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
1057 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1058 "l2_payload) (ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|"
1059 "dst-ipv6|ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|"
1060 "ipv6-next-header|ipv6-hop-limits|udp-src-port|"
1061 "udp-dst-port|tcp-src-port|tcp-dst-port|"
1062 "sctp-src-port|sctp-dst-port|sctp-veri-tag|none)"
1064 " Set the input set for FDir.\n\n"
1066 "flow validate {port_id}"
1067 " [group {group_id}] [priority {level}]"
1068 " [ingress] [egress]"
1069 " pattern {item} [/ {item} [...]] / end"
1070 " actions {action} [/ {action} [...]] / end\n"
1071 " Check whether a flow rule can be created.\n\n"
1073 "flow create {port_id}"
1074 " [group {group_id}] [priority {level}]"
1075 " [ingress] [egress]"
1076 " pattern {item} [/ {item} [...]] / end"
1077 " actions {action} [/ {action} [...]] / end\n"
1078 " Create a flow rule.\n\n"
1080 "flow destroy {port_id} rule {rule_id} [...]\n"
1081 " Destroy specific flow rules.\n\n"
1083 "flow flush {port_id}\n"
1084 " Destroy all flow rules.\n\n"
1086 "flow query {port_id} {rule_id} {action}\n"
1087 " Query an existing flow rule.\n\n"
1089 "flow list {port_id} [group {group_id}] [...]\n"
1090 " List existing flow rules sorted by priority,"
1091 " filtered by group identifiers.\n\n"
1093 "flow isolate {port_id} {boolean}\n"
1094 " Restrict ingress traffic to the defined"
1100 cmdline_parse_token_string_t cmd_help_long_help =
1101 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
1103 cmdline_parse_token_string_t cmd_help_long_section =
1104 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
1105 "all#control#display#config#"
1106 "ports#registers#filters");
1108 cmdline_parse_inst_t cmd_help_long = {
1109 .f = cmd_help_long_parsed,
1111 .help_str = "help all|control|display|config|ports|register|filters: "
1114 (void *)&cmd_help_long_help,
1115 (void *)&cmd_help_long_section,
1121 /* *** start/stop/close all ports *** */
1122 struct cmd_operate_port_result {
1123 cmdline_fixed_string_t keyword;
1124 cmdline_fixed_string_t name;
1125 cmdline_fixed_string_t value;
1128 static void cmd_operate_port_parsed(void *parsed_result,
1129 __attribute__((unused)) struct cmdline *cl,
1130 __attribute__((unused)) void *data)
1132 struct cmd_operate_port_result *res = parsed_result;
1134 if (!strcmp(res->name, "start"))
1135 start_port(RTE_PORT_ALL);
1136 else if (!strcmp(res->name, "stop"))
1137 stop_port(RTE_PORT_ALL);
1138 else if (!strcmp(res->name, "close"))
1139 close_port(RTE_PORT_ALL);
1140 else if (!strcmp(res->name, "reset"))
1141 reset_port(RTE_PORT_ALL);
1143 printf("Unknown parameter\n");
1146 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
1147 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
1149 cmdline_parse_token_string_t cmd_operate_port_all_port =
1150 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
1151 "start#stop#close#reset");
1152 cmdline_parse_token_string_t cmd_operate_port_all_all =
1153 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
1155 cmdline_parse_inst_t cmd_operate_port = {
1156 .f = cmd_operate_port_parsed,
1158 .help_str = "port start|stop|close all: Start/Stop/Close/Reset all ports",
1160 (void *)&cmd_operate_port_all_cmd,
1161 (void *)&cmd_operate_port_all_port,
1162 (void *)&cmd_operate_port_all_all,
1167 /* *** start/stop/close specific port *** */
1168 struct cmd_operate_specific_port_result {
1169 cmdline_fixed_string_t keyword;
1170 cmdline_fixed_string_t name;
1174 static void cmd_operate_specific_port_parsed(void *parsed_result,
1175 __attribute__((unused)) struct cmdline *cl,
1176 __attribute__((unused)) void *data)
1178 struct cmd_operate_specific_port_result *res = parsed_result;
1180 if (!strcmp(res->name, "start"))
1181 start_port(res->value);
1182 else if (!strcmp(res->name, "stop"))
1183 stop_port(res->value);
1184 else if (!strcmp(res->name, "close"))
1185 close_port(res->value);
1186 else if (!strcmp(res->name, "reset"))
1187 reset_port(res->value);
1189 printf("Unknown parameter\n");
1192 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
1193 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1195 cmdline_parse_token_string_t cmd_operate_specific_port_port =
1196 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1197 name, "start#stop#close#reset");
1198 cmdline_parse_token_num_t cmd_operate_specific_port_id =
1199 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
1202 cmdline_parse_inst_t cmd_operate_specific_port = {
1203 .f = cmd_operate_specific_port_parsed,
1205 .help_str = "port start|stop|close <port_id>: Start/Stop/Close/Reset port_id",
1207 (void *)&cmd_operate_specific_port_cmd,
1208 (void *)&cmd_operate_specific_port_port,
1209 (void *)&cmd_operate_specific_port_id,
1214 /* *** attach a specified port *** */
1215 struct cmd_operate_attach_port_result {
1216 cmdline_fixed_string_t port;
1217 cmdline_fixed_string_t keyword;
1218 cmdline_fixed_string_t identifier;
1221 static void cmd_operate_attach_port_parsed(void *parsed_result,
1222 __attribute__((unused)) struct cmdline *cl,
1223 __attribute__((unused)) void *data)
1225 struct cmd_operate_attach_port_result *res = parsed_result;
1227 if (!strcmp(res->keyword, "attach"))
1228 attach_port(res->identifier);
1230 printf("Unknown parameter\n");
1233 cmdline_parse_token_string_t cmd_operate_attach_port_port =
1234 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1236 cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
1237 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1239 cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
1240 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1243 cmdline_parse_inst_t cmd_operate_attach_port = {
1244 .f = cmd_operate_attach_port_parsed,
1246 .help_str = "port attach <identifier>: "
1247 "(identifier: pci address or virtual dev name)",
1249 (void *)&cmd_operate_attach_port_port,
1250 (void *)&cmd_operate_attach_port_keyword,
1251 (void *)&cmd_operate_attach_port_identifier,
1256 /* *** detach a specified port *** */
1257 struct cmd_operate_detach_port_result {
1258 cmdline_fixed_string_t port;
1259 cmdline_fixed_string_t keyword;
1263 static void cmd_operate_detach_port_parsed(void *parsed_result,
1264 __attribute__((unused)) struct cmdline *cl,
1265 __attribute__((unused)) void *data)
1267 struct cmd_operate_detach_port_result *res = parsed_result;
1269 if (!strcmp(res->keyword, "detach"))
1270 detach_port(res->port_id);
1272 printf("Unknown parameter\n");
1275 cmdline_parse_token_string_t cmd_operate_detach_port_port =
1276 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1278 cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
1279 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1281 cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
1282 TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
1285 cmdline_parse_inst_t cmd_operate_detach_port = {
1286 .f = cmd_operate_detach_port_parsed,
1288 .help_str = "port detach <port_id>",
1290 (void *)&cmd_operate_detach_port_port,
1291 (void *)&cmd_operate_detach_port_keyword,
1292 (void *)&cmd_operate_detach_port_port_id,
1297 /* *** configure speed for all ports *** */
1298 struct cmd_config_speed_all {
1299 cmdline_fixed_string_t port;
1300 cmdline_fixed_string_t keyword;
1301 cmdline_fixed_string_t all;
1302 cmdline_fixed_string_t item1;
1303 cmdline_fixed_string_t item2;
1304 cmdline_fixed_string_t value1;
1305 cmdline_fixed_string_t value2;
1309 parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed)
1314 if (!strcmp(duplexstr, "half")) {
1315 duplex = ETH_LINK_HALF_DUPLEX;
1316 } else if (!strcmp(duplexstr, "full")) {
1317 duplex = ETH_LINK_FULL_DUPLEX;
1318 } else if (!strcmp(duplexstr, "auto")) {
1319 duplex = ETH_LINK_FULL_DUPLEX;
1321 printf("Unknown duplex parameter\n");
1325 if (!strcmp(speedstr, "10")) {
1326 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1327 ETH_LINK_SPEED_10M_HD : ETH_LINK_SPEED_10M;
1328 } else if (!strcmp(speedstr, "100")) {
1329 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1330 ETH_LINK_SPEED_100M_HD : ETH_LINK_SPEED_100M;
1332 if (duplex != ETH_LINK_FULL_DUPLEX) {
1333 printf("Invalid speed/duplex parameters\n");
1336 if (!strcmp(speedstr, "1000")) {
1337 *speed = ETH_LINK_SPEED_1G;
1338 } else if (!strcmp(speedstr, "10000")) {
1339 *speed = ETH_LINK_SPEED_10G;
1340 } else if (!strcmp(speedstr, "25000")) {
1341 *speed = ETH_LINK_SPEED_25G;
1342 } else if (!strcmp(speedstr, "40000")) {
1343 *speed = ETH_LINK_SPEED_40G;
1344 } else if (!strcmp(speedstr, "50000")) {
1345 *speed = ETH_LINK_SPEED_50G;
1346 } else if (!strcmp(speedstr, "100000")) {
1347 *speed = ETH_LINK_SPEED_100G;
1348 } else if (!strcmp(speedstr, "auto")) {
1349 *speed = ETH_LINK_SPEED_AUTONEG;
1351 printf("Unknown speed parameter\n");
1360 cmd_config_speed_all_parsed(void *parsed_result,
1361 __attribute__((unused)) struct cmdline *cl,
1362 __attribute__((unused)) void *data)
1364 struct cmd_config_speed_all *res = parsed_result;
1365 uint32_t link_speed;
1368 if (!all_ports_stopped()) {
1369 printf("Please stop all ports first\n");
1373 if (parse_and_check_speed_duplex(res->value1, res->value2,
1377 RTE_ETH_FOREACH_DEV(pid) {
1378 ports[pid].dev_conf.link_speeds = link_speed;
1381 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1384 cmdline_parse_token_string_t cmd_config_speed_all_port =
1385 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1386 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1387 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1389 cmdline_parse_token_string_t cmd_config_speed_all_all =
1390 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1391 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1392 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1393 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1394 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1395 "10#100#1000#10000#25000#40000#50000#100000#auto");
1396 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1397 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1398 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1399 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1402 cmdline_parse_inst_t cmd_config_speed_all = {
1403 .f = cmd_config_speed_all_parsed,
1405 .help_str = "port config all speed "
1406 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1409 (void *)&cmd_config_speed_all_port,
1410 (void *)&cmd_config_speed_all_keyword,
1411 (void *)&cmd_config_speed_all_all,
1412 (void *)&cmd_config_speed_all_item1,
1413 (void *)&cmd_config_speed_all_value1,
1414 (void *)&cmd_config_speed_all_item2,
1415 (void *)&cmd_config_speed_all_value2,
1420 /* *** configure speed for specific port *** */
1421 struct cmd_config_speed_specific {
1422 cmdline_fixed_string_t port;
1423 cmdline_fixed_string_t keyword;
1425 cmdline_fixed_string_t item1;
1426 cmdline_fixed_string_t item2;
1427 cmdline_fixed_string_t value1;
1428 cmdline_fixed_string_t value2;
1432 cmd_config_speed_specific_parsed(void *parsed_result,
1433 __attribute__((unused)) struct cmdline *cl,
1434 __attribute__((unused)) void *data)
1436 struct cmd_config_speed_specific *res = parsed_result;
1437 uint32_t link_speed;
1439 if (!all_ports_stopped()) {
1440 printf("Please stop all ports first\n");
1444 if (port_id_is_invalid(res->id, ENABLED_WARN))
1447 if (parse_and_check_speed_duplex(res->value1, res->value2,
1451 ports[res->id].dev_conf.link_speeds = link_speed;
1453 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1457 cmdline_parse_token_string_t cmd_config_speed_specific_port =
1458 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1460 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1461 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1463 cmdline_parse_token_num_t cmd_config_speed_specific_id =
1464 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT8);
1465 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1466 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1468 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1469 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1470 "10#100#1000#10000#25000#40000#50000#100000#auto");
1471 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1472 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1474 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1475 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1478 cmdline_parse_inst_t cmd_config_speed_specific = {
1479 .f = cmd_config_speed_specific_parsed,
1481 .help_str = "port config <port_id> speed "
1482 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1485 (void *)&cmd_config_speed_specific_port,
1486 (void *)&cmd_config_speed_specific_keyword,
1487 (void *)&cmd_config_speed_specific_id,
1488 (void *)&cmd_config_speed_specific_item1,
1489 (void *)&cmd_config_speed_specific_value1,
1490 (void *)&cmd_config_speed_specific_item2,
1491 (void *)&cmd_config_speed_specific_value2,
1496 /* *** configure txq/rxq, txd/rxd *** */
1497 struct cmd_config_rx_tx {
1498 cmdline_fixed_string_t port;
1499 cmdline_fixed_string_t keyword;
1500 cmdline_fixed_string_t all;
1501 cmdline_fixed_string_t name;
1506 cmd_config_rx_tx_parsed(void *parsed_result,
1507 __attribute__((unused)) struct cmdline *cl,
1508 __attribute__((unused)) void *data)
1510 struct cmd_config_rx_tx *res = parsed_result;
1512 if (!all_ports_stopped()) {
1513 printf("Please stop all ports first\n");
1516 if (!strcmp(res->name, "rxq")) {
1517 if (!res->value && !nb_txq) {
1518 printf("Warning: Either rx or tx queues should be non zero\n");
1521 nb_rxq = res->value;
1523 else if (!strcmp(res->name, "txq")) {
1524 if (!res->value && !nb_rxq) {
1525 printf("Warning: Either rx or tx queues should be non zero\n");
1528 nb_txq = res->value;
1530 else if (!strcmp(res->name, "rxd")) {
1531 if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) {
1532 printf("rxd %d invalid - must be > 0 && <= %d\n",
1533 res->value, RTE_TEST_RX_DESC_MAX);
1536 nb_rxd = res->value;
1537 } else if (!strcmp(res->name, "txd")) {
1538 if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) {
1539 printf("txd %d invalid - must be > 0 && <= %d\n",
1540 res->value, RTE_TEST_TX_DESC_MAX);
1543 nb_txd = res->value;
1545 printf("Unknown parameter\n");
1553 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1556 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1557 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1558 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1559 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1560 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1561 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1562 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1563 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1565 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1566 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
1568 cmdline_parse_inst_t cmd_config_rx_tx = {
1569 .f = cmd_config_rx_tx_parsed,
1571 .help_str = "port config all rxq|txq|rxd|txd <value>",
1573 (void *)&cmd_config_rx_tx_port,
1574 (void *)&cmd_config_rx_tx_keyword,
1575 (void *)&cmd_config_rx_tx_all,
1576 (void *)&cmd_config_rx_tx_name,
1577 (void *)&cmd_config_rx_tx_value,
1582 /* *** config max packet length *** */
1583 struct cmd_config_max_pkt_len_result {
1584 cmdline_fixed_string_t port;
1585 cmdline_fixed_string_t keyword;
1586 cmdline_fixed_string_t all;
1587 cmdline_fixed_string_t name;
1592 cmd_config_max_pkt_len_parsed(void *parsed_result,
1593 __attribute__((unused)) struct cmdline *cl,
1594 __attribute__((unused)) void *data)
1596 struct cmd_config_max_pkt_len_result *res = parsed_result;
1597 uint64_t rx_offloads = rx_mode.offloads;
1599 if (!all_ports_stopped()) {
1600 printf("Please stop all ports first\n");
1604 if (!strcmp(res->name, "max-pkt-len")) {
1605 if (res->value < ETHER_MIN_LEN) {
1606 printf("max-pkt-len can not be less than %d\n",
1610 if (res->value == rx_mode.max_rx_pkt_len)
1613 rx_mode.max_rx_pkt_len = res->value;
1614 if (res->value > ETHER_MAX_LEN)
1615 rx_offloads |= DEV_RX_OFFLOAD_JUMBO_FRAME;
1617 rx_offloads &= ~DEV_RX_OFFLOAD_JUMBO_FRAME;
1619 printf("Unknown parameter\n");
1623 rx_mode.offloads = rx_offloads;
1627 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1630 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
1631 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
1633 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
1634 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
1636 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
1637 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
1639 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
1640 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
1642 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1643 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1646 cmdline_parse_inst_t cmd_config_max_pkt_len = {
1647 .f = cmd_config_max_pkt_len_parsed,
1649 .help_str = "port config all max-pkt-len <value>",
1651 (void *)&cmd_config_max_pkt_len_port,
1652 (void *)&cmd_config_max_pkt_len_keyword,
1653 (void *)&cmd_config_max_pkt_len_all,
1654 (void *)&cmd_config_max_pkt_len_name,
1655 (void *)&cmd_config_max_pkt_len_value,
1660 /* *** configure port MTU *** */
1661 struct cmd_config_mtu_result {
1662 cmdline_fixed_string_t port;
1663 cmdline_fixed_string_t keyword;
1664 cmdline_fixed_string_t mtu;
1670 cmd_config_mtu_parsed(void *parsed_result,
1671 __attribute__((unused)) struct cmdline *cl,
1672 __attribute__((unused)) void *data)
1674 struct cmd_config_mtu_result *res = parsed_result;
1676 if (res->value < ETHER_MIN_LEN) {
1677 printf("mtu cannot be less than %d\n", ETHER_MIN_LEN);
1680 port_mtu_set(res->port_id, res->value);
1683 cmdline_parse_token_string_t cmd_config_mtu_port =
1684 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
1686 cmdline_parse_token_string_t cmd_config_mtu_keyword =
1687 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1689 cmdline_parse_token_string_t cmd_config_mtu_mtu =
1690 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1692 cmdline_parse_token_num_t cmd_config_mtu_port_id =
1693 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT16);
1694 cmdline_parse_token_num_t cmd_config_mtu_value =
1695 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
1697 cmdline_parse_inst_t cmd_config_mtu = {
1698 .f = cmd_config_mtu_parsed,
1700 .help_str = "port config mtu <port_id> <value>",
1702 (void *)&cmd_config_mtu_port,
1703 (void *)&cmd_config_mtu_keyword,
1704 (void *)&cmd_config_mtu_mtu,
1705 (void *)&cmd_config_mtu_port_id,
1706 (void *)&cmd_config_mtu_value,
1711 /* *** configure rx mode *** */
1712 struct cmd_config_rx_mode_flag {
1713 cmdline_fixed_string_t port;
1714 cmdline_fixed_string_t keyword;
1715 cmdline_fixed_string_t all;
1716 cmdline_fixed_string_t name;
1717 cmdline_fixed_string_t value;
1721 cmd_config_rx_mode_flag_parsed(void *parsed_result,
1722 __attribute__((unused)) struct cmdline *cl,
1723 __attribute__((unused)) void *data)
1725 struct cmd_config_rx_mode_flag *res = parsed_result;
1726 uint64_t rx_offloads = rx_mode.offloads;
1728 if (!all_ports_stopped()) {
1729 printf("Please stop all ports first\n");
1733 if (!strcmp(res->name, "crc-strip")) {
1734 if (!strcmp(res->value, "on"))
1735 rx_offloads |= DEV_RX_OFFLOAD_CRC_STRIP;
1736 else if (!strcmp(res->value, "off"))
1737 rx_offloads &= ~DEV_RX_OFFLOAD_CRC_STRIP;
1739 printf("Unknown parameter\n");
1742 } else if (!strcmp(res->name, "scatter")) {
1743 if (!strcmp(res->value, "on")) {
1744 rx_offloads |= DEV_RX_OFFLOAD_SCATTER;
1745 } else if (!strcmp(res->value, "off")) {
1746 rx_offloads &= ~DEV_RX_OFFLOAD_SCATTER;
1748 printf("Unknown parameter\n");
1751 } else if (!strcmp(res->name, "rx-cksum")) {
1752 if (!strcmp(res->value, "on"))
1753 rx_offloads |= DEV_RX_OFFLOAD_CHECKSUM;
1754 else if (!strcmp(res->value, "off"))
1755 rx_offloads &= ~DEV_RX_OFFLOAD_CHECKSUM;
1757 printf("Unknown parameter\n");
1760 } else if (!strcmp(res->name, "rx-timestamp")) {
1761 if (!strcmp(res->value, "on"))
1762 rx_offloads |= DEV_RX_OFFLOAD_TIMESTAMP;
1763 else if (!strcmp(res->value, "off"))
1764 rx_offloads &= ~DEV_RX_OFFLOAD_TIMESTAMP;
1766 printf("Unknown parameter\n");
1769 } else if (!strcmp(res->name, "hw-vlan")) {
1770 if (!strcmp(res->value, "on")) {
1771 rx_offloads |= (DEV_RX_OFFLOAD_VLAN_FILTER |
1772 DEV_RX_OFFLOAD_VLAN_STRIP);
1774 else if (!strcmp(res->value, "off")) {
1775 rx_offloads &= ~(DEV_RX_OFFLOAD_VLAN_FILTER |
1776 DEV_RX_OFFLOAD_VLAN_STRIP);
1779 printf("Unknown parameter\n");
1782 } else if (!strcmp(res->name, "hw-vlan-filter")) {
1783 if (!strcmp(res->value, "on"))
1784 rx_offloads |= DEV_RX_OFFLOAD_VLAN_FILTER;
1785 else if (!strcmp(res->value, "off"))
1786 rx_offloads &= ~DEV_RX_OFFLOAD_VLAN_FILTER;
1788 printf("Unknown parameter\n");
1791 } else if (!strcmp(res->name, "hw-vlan-strip")) {
1792 if (!strcmp(res->value, "on"))
1793 rx_offloads |= DEV_RX_OFFLOAD_VLAN_STRIP;
1794 else if (!strcmp(res->value, "off"))
1795 rx_offloads &= ~DEV_RX_OFFLOAD_VLAN_STRIP;
1797 printf("Unknown parameter\n");
1800 } else if (!strcmp(res->name, "hw-vlan-extend")) {
1801 if (!strcmp(res->value, "on"))
1802 rx_offloads |= DEV_RX_OFFLOAD_VLAN_EXTEND;
1803 else if (!strcmp(res->value, "off"))
1804 rx_offloads &= ~DEV_RX_OFFLOAD_VLAN_EXTEND;
1806 printf("Unknown parameter\n");
1809 } else if (!strcmp(res->name, "drop-en")) {
1810 if (!strcmp(res->value, "on"))
1812 else if (!strcmp(res->value, "off"))
1815 printf("Unknown parameter\n");
1819 printf("Unknown parameter\n");
1822 rx_mode.offloads = rx_offloads;
1826 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1829 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
1830 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
1831 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
1832 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
1834 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
1835 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
1836 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
1837 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
1838 "crc-strip#scatter#rx-cksum#rx-timestamp#hw-vlan#"
1839 "hw-vlan-filter#hw-vlan-strip#hw-vlan-extend");
1840 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
1841 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
1844 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
1845 .f = cmd_config_rx_mode_flag_parsed,
1847 .help_str = "port config all crc-strip|scatter|rx-cksum|rx-timestamp|hw-vlan|"
1848 "hw-vlan-filter|hw-vlan-strip|hw-vlan-extend on|off",
1850 (void *)&cmd_config_rx_mode_flag_port,
1851 (void *)&cmd_config_rx_mode_flag_keyword,
1852 (void *)&cmd_config_rx_mode_flag_all,
1853 (void *)&cmd_config_rx_mode_flag_name,
1854 (void *)&cmd_config_rx_mode_flag_value,
1859 /* *** configure rss *** */
1860 struct cmd_config_rss {
1861 cmdline_fixed_string_t port;
1862 cmdline_fixed_string_t keyword;
1863 cmdline_fixed_string_t all;
1864 cmdline_fixed_string_t name;
1865 cmdline_fixed_string_t value;
1869 cmd_config_rss_parsed(void *parsed_result,
1870 __attribute__((unused)) struct cmdline *cl,
1871 __attribute__((unused)) void *data)
1873 struct cmd_config_rss *res = parsed_result;
1874 struct rte_eth_rss_conf rss_conf = { .rss_key_len = 0, };
1878 if (!strcmp(res->value, "all"))
1879 rss_conf.rss_hf = ETH_RSS_IP | ETH_RSS_TCP |
1880 ETH_RSS_UDP | ETH_RSS_SCTP |
1882 else if (!strcmp(res->value, "ip"))
1883 rss_conf.rss_hf = ETH_RSS_IP;
1884 else if (!strcmp(res->value, "udp"))
1885 rss_conf.rss_hf = ETH_RSS_UDP;
1886 else if (!strcmp(res->value, "tcp"))
1887 rss_conf.rss_hf = ETH_RSS_TCP;
1888 else if (!strcmp(res->value, "sctp"))
1889 rss_conf.rss_hf = ETH_RSS_SCTP;
1890 else if (!strcmp(res->value, "ether"))
1891 rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD;
1892 else if (!strcmp(res->value, "port"))
1893 rss_conf.rss_hf = ETH_RSS_PORT;
1894 else if (!strcmp(res->value, "vxlan"))
1895 rss_conf.rss_hf = ETH_RSS_VXLAN;
1896 else if (!strcmp(res->value, "geneve"))
1897 rss_conf.rss_hf = ETH_RSS_GENEVE;
1898 else if (!strcmp(res->value, "nvgre"))
1899 rss_conf.rss_hf = ETH_RSS_NVGRE;
1900 else if (!strcmp(res->value, "none"))
1901 rss_conf.rss_hf = 0;
1902 else if (isdigit(res->value[0]) && atoi(res->value) > 0 &&
1903 atoi(res->value) < 64)
1904 rss_conf.rss_hf = 1ULL << atoi(res->value);
1906 printf("Unknown parameter\n");
1909 rss_conf.rss_key = NULL;
1910 for (i = 0; i < rte_eth_dev_count(); i++) {
1911 diag = rte_eth_dev_rss_hash_update(i, &rss_conf);
1913 printf("Configuration of RSS hash at ethernet port %d "
1914 "failed with error (%d): %s.\n",
1915 i, -diag, strerror(-diag));
1919 cmdline_parse_token_string_t cmd_config_rss_port =
1920 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
1921 cmdline_parse_token_string_t cmd_config_rss_keyword =
1922 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
1923 cmdline_parse_token_string_t cmd_config_rss_all =
1924 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
1925 cmdline_parse_token_string_t cmd_config_rss_name =
1926 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
1927 cmdline_parse_token_string_t cmd_config_rss_value =
1928 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, NULL);
1930 cmdline_parse_inst_t cmd_config_rss = {
1931 .f = cmd_config_rss_parsed,
1933 .help_str = "port config all rss "
1934 "all|ip|tcp|udp|sctp|ether|port|vxlan|geneve|nvgre|none|<flowtype_id>",
1936 (void *)&cmd_config_rss_port,
1937 (void *)&cmd_config_rss_keyword,
1938 (void *)&cmd_config_rss_all,
1939 (void *)&cmd_config_rss_name,
1940 (void *)&cmd_config_rss_value,
1945 /* *** configure rss hash key *** */
1946 struct cmd_config_rss_hash_key {
1947 cmdline_fixed_string_t port;
1948 cmdline_fixed_string_t config;
1950 cmdline_fixed_string_t rss_hash_key;
1951 cmdline_fixed_string_t rss_type;
1952 cmdline_fixed_string_t key;
1956 hexa_digit_to_value(char hexa_digit)
1958 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
1959 return (uint8_t) (hexa_digit - '0');
1960 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
1961 return (uint8_t) ((hexa_digit - 'a') + 10);
1962 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
1963 return (uint8_t) ((hexa_digit - 'A') + 10);
1964 /* Invalid hexa digit */
1969 parse_and_check_key_hexa_digit(char *key, int idx)
1973 hexa_v = hexa_digit_to_value(key[idx]);
1975 printf("invalid key: character %c at position %d is not a "
1976 "valid hexa digit\n", key[idx], idx);
1981 cmd_config_rss_hash_key_parsed(void *parsed_result,
1982 __attribute__((unused)) struct cmdline *cl,
1983 __attribute__((unused)) void *data)
1985 struct cmd_config_rss_hash_key *res = parsed_result;
1986 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
1990 struct rte_eth_dev_info dev_info;
1991 uint8_t hash_key_size;
1994 memset(&dev_info, 0, sizeof(dev_info));
1995 rte_eth_dev_info_get(res->port_id, &dev_info);
1996 if (dev_info.hash_key_size > 0 &&
1997 dev_info.hash_key_size <= sizeof(hash_key))
1998 hash_key_size = dev_info.hash_key_size;
2000 printf("dev_info did not provide a valid hash key size\n");
2003 /* Check the length of the RSS hash key */
2004 key_len = strlen(res->key);
2005 if (key_len != (hash_key_size * 2)) {
2006 printf("key length: %d invalid - key must be a string of %d"
2007 " hexa-decimal numbers\n",
2008 (int) key_len, hash_key_size * 2);
2011 /* Translate RSS hash key into binary representation */
2012 for (i = 0; i < hash_key_size; i++) {
2013 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
2016 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
2019 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
2021 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
2025 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
2026 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
2027 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
2028 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
2030 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
2031 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT16);
2032 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
2033 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
2034 rss_hash_key, "rss-hash-key");
2035 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
2036 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
2037 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2038 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2039 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2040 "ipv6-tcp-ex#ipv6-udp-ex");
2041 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
2042 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
2044 cmdline_parse_inst_t cmd_config_rss_hash_key = {
2045 .f = cmd_config_rss_hash_key_parsed,
2047 .help_str = "port config <port_id> rss-hash-key "
2048 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2049 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2050 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex "
2051 "<string of hex digits (variable length, NIC dependent)>",
2053 (void *)&cmd_config_rss_hash_key_port,
2054 (void *)&cmd_config_rss_hash_key_config,
2055 (void *)&cmd_config_rss_hash_key_port_id,
2056 (void *)&cmd_config_rss_hash_key_rss_hash_key,
2057 (void *)&cmd_config_rss_hash_key_rss_type,
2058 (void *)&cmd_config_rss_hash_key_value,
2063 /* *** configure port rxq/txq start/stop *** */
2064 struct cmd_config_rxtx_queue {
2065 cmdline_fixed_string_t port;
2067 cmdline_fixed_string_t rxtxq;
2069 cmdline_fixed_string_t opname;
2073 cmd_config_rxtx_queue_parsed(void *parsed_result,
2074 __attribute__((unused)) struct cmdline *cl,
2075 __attribute__((unused)) void *data)
2077 struct cmd_config_rxtx_queue *res = parsed_result;
2082 if (test_done == 0) {
2083 printf("Please stop forwarding first\n");
2087 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2090 if (port_is_started(res->portid) != 1) {
2091 printf("Please start port %u first\n", res->portid);
2095 if (!strcmp(res->rxtxq, "rxq"))
2097 else if (!strcmp(res->rxtxq, "txq"))
2100 printf("Unknown parameter\n");
2104 if (isrx && rx_queue_id_is_invalid(res->qid))
2106 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2109 if (!strcmp(res->opname, "start"))
2111 else if (!strcmp(res->opname, "stop"))
2114 printf("Unknown parameter\n");
2118 if (isstart && isrx)
2119 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
2120 else if (!isstart && isrx)
2121 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
2122 else if (isstart && !isrx)
2123 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
2125 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
2127 if (ret == -ENOTSUP)
2128 printf("Function not supported in PMD driver\n");
2131 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
2132 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
2133 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
2134 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT16);
2135 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
2136 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
2137 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
2138 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
2139 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
2140 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
2143 cmdline_parse_inst_t cmd_config_rxtx_queue = {
2144 .f = cmd_config_rxtx_queue_parsed,
2146 .help_str = "port <port_id> rxq|txq <queue_id> start|stop",
2148 (void *)&cmd_config_speed_all_port,
2149 (void *)&cmd_config_rxtx_queue_portid,
2150 (void *)&cmd_config_rxtx_queue_rxtxq,
2151 (void *)&cmd_config_rxtx_queue_qid,
2152 (void *)&cmd_config_rxtx_queue_opname,
2157 /* *** Configure RSS RETA *** */
2158 struct cmd_config_rss_reta {
2159 cmdline_fixed_string_t port;
2160 cmdline_fixed_string_t keyword;
2162 cmdline_fixed_string_t name;
2163 cmdline_fixed_string_t list_name;
2164 cmdline_fixed_string_t list_of_items;
2168 parse_reta_config(const char *str,
2169 struct rte_eth_rss_reta_entry64 *reta_conf,
2170 uint16_t nb_entries)
2174 uint16_t hash_index, idx, shift;
2177 const char *p, *p0 = str;
2184 unsigned long int_fld[_NUM_FLD];
2185 char *str_fld[_NUM_FLD];
2187 while ((p = strchr(p0,'(')) != NULL) {
2189 if((p0 = strchr(p,')')) == NULL)
2193 if(size >= sizeof(s))
2196 snprintf(s, sizeof(s), "%.*s", size, p);
2197 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
2199 for (i = 0; i < _NUM_FLD; i++) {
2201 int_fld[i] = strtoul(str_fld[i], &end, 0);
2202 if (errno != 0 || end == str_fld[i] ||
2207 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
2208 nb_queue = (uint16_t)int_fld[FLD_QUEUE];
2210 if (hash_index >= nb_entries) {
2211 printf("Invalid RETA hash index=%d\n", hash_index);
2215 idx = hash_index / RTE_RETA_GROUP_SIZE;
2216 shift = hash_index % RTE_RETA_GROUP_SIZE;
2217 reta_conf[idx].mask |= (1ULL << shift);
2218 reta_conf[idx].reta[shift] = nb_queue;
2225 cmd_set_rss_reta_parsed(void *parsed_result,
2226 __attribute__((unused)) struct cmdline *cl,
2227 __attribute__((unused)) void *data)
2230 struct rte_eth_dev_info dev_info;
2231 struct rte_eth_rss_reta_entry64 reta_conf[8];
2232 struct cmd_config_rss_reta *res = parsed_result;
2234 memset(&dev_info, 0, sizeof(dev_info));
2235 rte_eth_dev_info_get(res->port_id, &dev_info);
2236 if (dev_info.reta_size == 0) {
2237 printf("Redirection table size is 0 which is "
2238 "invalid for RSS\n");
2241 printf("The reta size of port %d is %u\n",
2242 res->port_id, dev_info.reta_size);
2243 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
2244 printf("Currently do not support more than %u entries of "
2245 "redirection table\n", ETH_RSS_RETA_SIZE_512);
2249 memset(reta_conf, 0, sizeof(reta_conf));
2250 if (!strcmp(res->list_name, "reta")) {
2251 if (parse_reta_config(res->list_of_items, reta_conf,
2252 dev_info.reta_size)) {
2253 printf("Invalid RSS Redirection Table "
2254 "config entered\n");
2257 ret = rte_eth_dev_rss_reta_update(res->port_id,
2258 reta_conf, dev_info.reta_size);
2260 printf("Bad redirection table parameter, "
2261 "return code = %d \n", ret);
2265 cmdline_parse_token_string_t cmd_config_rss_reta_port =
2266 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
2267 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
2268 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
2269 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
2270 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT16);
2271 cmdline_parse_token_string_t cmd_config_rss_reta_name =
2272 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
2273 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
2274 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
2275 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
2276 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
2278 cmdline_parse_inst_t cmd_config_rss_reta = {
2279 .f = cmd_set_rss_reta_parsed,
2281 .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
2283 (void *)&cmd_config_rss_reta_port,
2284 (void *)&cmd_config_rss_reta_keyword,
2285 (void *)&cmd_config_rss_reta_port_id,
2286 (void *)&cmd_config_rss_reta_name,
2287 (void *)&cmd_config_rss_reta_list_name,
2288 (void *)&cmd_config_rss_reta_list_of_items,
2293 /* *** SHOW PORT RETA INFO *** */
2294 struct cmd_showport_reta {
2295 cmdline_fixed_string_t show;
2296 cmdline_fixed_string_t port;
2298 cmdline_fixed_string_t rss;
2299 cmdline_fixed_string_t reta;
2301 cmdline_fixed_string_t list_of_items;
2305 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
2306 uint16_t nb_entries,
2310 const char *p, *p0 = str;
2315 uint16_t num = (nb_entries + RTE_RETA_GROUP_SIZE - 1) /
2316 RTE_RETA_GROUP_SIZE;
2319 p = strchr(p0, '(');
2323 p0 = strchr(p, ')');
2327 if (size >= sizeof(s)) {
2328 printf("The string size exceeds the internal buffer size\n");
2331 snprintf(s, sizeof(s), "%.*s", size, p);
2332 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
2333 if (ret <= 0 || ret != num) {
2334 printf("The bits of masks do not match the number of "
2335 "reta entries: %u\n", num);
2338 for (i = 0; i < ret; i++)
2339 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
2345 cmd_showport_reta_parsed(void *parsed_result,
2346 __attribute__((unused)) struct cmdline *cl,
2347 __attribute__((unused)) void *data)
2349 struct cmd_showport_reta *res = parsed_result;
2350 struct rte_eth_rss_reta_entry64 reta_conf[8];
2351 struct rte_eth_dev_info dev_info;
2352 uint16_t max_reta_size;
2354 memset(&dev_info, 0, sizeof(dev_info));
2355 rte_eth_dev_info_get(res->port_id, &dev_info);
2356 max_reta_size = RTE_MIN(dev_info.reta_size, ETH_RSS_RETA_SIZE_512);
2357 if (res->size == 0 || res->size > max_reta_size) {
2358 printf("Invalid redirection table size: %u (1-%u)\n",
2359 res->size, max_reta_size);
2363 memset(reta_conf, 0, sizeof(reta_conf));
2364 if (showport_parse_reta_config(reta_conf, res->size,
2365 res->list_of_items) < 0) {
2366 printf("Invalid string: %s for reta masks\n",
2367 res->list_of_items);
2370 port_rss_reta_info(res->port_id, reta_conf, res->size);
2373 cmdline_parse_token_string_t cmd_showport_reta_show =
2374 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
2375 cmdline_parse_token_string_t cmd_showport_reta_port =
2376 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
2377 cmdline_parse_token_num_t cmd_showport_reta_port_id =
2378 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT16);
2379 cmdline_parse_token_string_t cmd_showport_reta_rss =
2380 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
2381 cmdline_parse_token_string_t cmd_showport_reta_reta =
2382 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
2383 cmdline_parse_token_num_t cmd_showport_reta_size =
2384 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16);
2385 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
2386 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
2387 list_of_items, NULL);
2389 cmdline_parse_inst_t cmd_showport_reta = {
2390 .f = cmd_showport_reta_parsed,
2392 .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
2394 (void *)&cmd_showport_reta_show,
2395 (void *)&cmd_showport_reta_port,
2396 (void *)&cmd_showport_reta_port_id,
2397 (void *)&cmd_showport_reta_rss,
2398 (void *)&cmd_showport_reta_reta,
2399 (void *)&cmd_showport_reta_size,
2400 (void *)&cmd_showport_reta_list_of_items,
2405 /* *** Show RSS hash configuration *** */
2406 struct cmd_showport_rss_hash {
2407 cmdline_fixed_string_t show;
2408 cmdline_fixed_string_t port;
2410 cmdline_fixed_string_t rss_hash;
2411 cmdline_fixed_string_t rss_type;
2412 cmdline_fixed_string_t key; /* optional argument */
2415 static void cmd_showport_rss_hash_parsed(void *parsed_result,
2416 __attribute__((unused)) struct cmdline *cl,
2419 struct cmd_showport_rss_hash *res = parsed_result;
2421 port_rss_hash_conf_show(res->port_id, res->rss_type,
2422 show_rss_key != NULL);
2425 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
2426 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
2427 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
2428 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
2429 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
2430 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT16);
2431 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
2432 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
2434 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash_info =
2435 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_type,
2436 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2437 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2438 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2439 "ipv6-tcp-ex#ipv6-udp-ex");
2440 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
2441 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
2443 cmdline_parse_inst_t cmd_showport_rss_hash = {
2444 .f = cmd_showport_rss_hash_parsed,
2446 .help_str = "show port <port_id> rss-hash "
2447 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2448 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2449 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex",
2451 (void *)&cmd_showport_rss_hash_show,
2452 (void *)&cmd_showport_rss_hash_port,
2453 (void *)&cmd_showport_rss_hash_port_id,
2454 (void *)&cmd_showport_rss_hash_rss_hash,
2455 (void *)&cmd_showport_rss_hash_rss_hash_info,
2460 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
2461 .f = cmd_showport_rss_hash_parsed,
2463 .help_str = "show port <port_id> rss-hash "
2464 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2465 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2466 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex key",
2468 (void *)&cmd_showport_rss_hash_show,
2469 (void *)&cmd_showport_rss_hash_port,
2470 (void *)&cmd_showport_rss_hash_port_id,
2471 (void *)&cmd_showport_rss_hash_rss_hash,
2472 (void *)&cmd_showport_rss_hash_rss_hash_info,
2473 (void *)&cmd_showport_rss_hash_rss_key,
2478 /* *** Configure DCB *** */
2479 struct cmd_config_dcb {
2480 cmdline_fixed_string_t port;
2481 cmdline_fixed_string_t config;
2483 cmdline_fixed_string_t dcb;
2484 cmdline_fixed_string_t vt;
2485 cmdline_fixed_string_t vt_en;
2487 cmdline_fixed_string_t pfc;
2488 cmdline_fixed_string_t pfc_en;
2492 cmd_config_dcb_parsed(void *parsed_result,
2493 __attribute__((unused)) struct cmdline *cl,
2494 __attribute__((unused)) void *data)
2496 struct cmd_config_dcb *res = parsed_result;
2497 portid_t port_id = res->port_id;
2498 struct rte_port *port;
2502 port = &ports[port_id];
2503 /** Check if the port is not started **/
2504 if (port->port_status != RTE_PORT_STOPPED) {
2505 printf("Please stop port %d first\n", port_id);
2509 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
2510 printf("The invalid number of traffic class,"
2511 " only 4 or 8 allowed.\n");
2515 if (nb_fwd_lcores < res->num_tcs) {
2516 printf("nb_cores shouldn't be less than number of TCs.\n");
2519 if (!strncmp(res->pfc_en, "on", 2))
2524 /* DCB in VT mode */
2525 if (!strncmp(res->vt_en, "on", 2))
2526 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
2527 (enum rte_eth_nb_tcs)res->num_tcs,
2530 ret = init_port_dcb_config(port_id, DCB_ENABLED,
2531 (enum rte_eth_nb_tcs)res->num_tcs,
2536 printf("Cannot initialize network ports.\n");
2540 cmd_reconfig_device_queue(port_id, 1, 1);
2543 cmdline_parse_token_string_t cmd_config_dcb_port =
2544 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
2545 cmdline_parse_token_string_t cmd_config_dcb_config =
2546 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
2547 cmdline_parse_token_num_t cmd_config_dcb_port_id =
2548 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT16);
2549 cmdline_parse_token_string_t cmd_config_dcb_dcb =
2550 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
2551 cmdline_parse_token_string_t cmd_config_dcb_vt =
2552 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
2553 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
2554 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
2555 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
2556 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
2557 cmdline_parse_token_string_t cmd_config_dcb_pfc=
2558 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
2559 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
2560 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
2562 cmdline_parse_inst_t cmd_config_dcb = {
2563 .f = cmd_config_dcb_parsed,
2565 .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
2567 (void *)&cmd_config_dcb_port,
2568 (void *)&cmd_config_dcb_config,
2569 (void *)&cmd_config_dcb_port_id,
2570 (void *)&cmd_config_dcb_dcb,
2571 (void *)&cmd_config_dcb_vt,
2572 (void *)&cmd_config_dcb_vt_en,
2573 (void *)&cmd_config_dcb_num_tcs,
2574 (void *)&cmd_config_dcb_pfc,
2575 (void *)&cmd_config_dcb_pfc_en,
2580 /* *** configure number of packets per burst *** */
2581 struct cmd_config_burst {
2582 cmdline_fixed_string_t port;
2583 cmdline_fixed_string_t keyword;
2584 cmdline_fixed_string_t all;
2585 cmdline_fixed_string_t name;
2590 cmd_config_burst_parsed(void *parsed_result,
2591 __attribute__((unused)) struct cmdline *cl,
2592 __attribute__((unused)) void *data)
2594 struct cmd_config_burst *res = parsed_result;
2596 if (!all_ports_stopped()) {
2597 printf("Please stop all ports first\n");
2601 if (!strcmp(res->name, "burst")) {
2602 if (res->value < 1 || res->value > MAX_PKT_BURST) {
2603 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
2606 nb_pkt_per_burst = res->value;
2608 printf("Unknown parameter\n");
2614 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2617 cmdline_parse_token_string_t cmd_config_burst_port =
2618 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
2619 cmdline_parse_token_string_t cmd_config_burst_keyword =
2620 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
2621 cmdline_parse_token_string_t cmd_config_burst_all =
2622 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
2623 cmdline_parse_token_string_t cmd_config_burst_name =
2624 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
2625 cmdline_parse_token_num_t cmd_config_burst_value =
2626 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
2628 cmdline_parse_inst_t cmd_config_burst = {
2629 .f = cmd_config_burst_parsed,
2631 .help_str = "port config all burst <value>",
2633 (void *)&cmd_config_burst_port,
2634 (void *)&cmd_config_burst_keyword,
2635 (void *)&cmd_config_burst_all,
2636 (void *)&cmd_config_burst_name,
2637 (void *)&cmd_config_burst_value,
2642 /* *** configure rx/tx queues *** */
2643 struct cmd_config_thresh {
2644 cmdline_fixed_string_t port;
2645 cmdline_fixed_string_t keyword;
2646 cmdline_fixed_string_t all;
2647 cmdline_fixed_string_t name;
2652 cmd_config_thresh_parsed(void *parsed_result,
2653 __attribute__((unused)) struct cmdline *cl,
2654 __attribute__((unused)) void *data)
2656 struct cmd_config_thresh *res = parsed_result;
2658 if (!all_ports_stopped()) {
2659 printf("Please stop all ports first\n");
2663 if (!strcmp(res->name, "txpt"))
2664 tx_pthresh = res->value;
2665 else if(!strcmp(res->name, "txht"))
2666 tx_hthresh = res->value;
2667 else if(!strcmp(res->name, "txwt"))
2668 tx_wthresh = res->value;
2669 else if(!strcmp(res->name, "rxpt"))
2670 rx_pthresh = res->value;
2671 else if(!strcmp(res->name, "rxht"))
2672 rx_hthresh = res->value;
2673 else if(!strcmp(res->name, "rxwt"))
2674 rx_wthresh = res->value;
2676 printf("Unknown parameter\n");
2682 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2685 cmdline_parse_token_string_t cmd_config_thresh_port =
2686 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
2687 cmdline_parse_token_string_t cmd_config_thresh_keyword =
2688 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
2689 cmdline_parse_token_string_t cmd_config_thresh_all =
2690 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
2691 cmdline_parse_token_string_t cmd_config_thresh_name =
2692 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
2693 "txpt#txht#txwt#rxpt#rxht#rxwt");
2694 cmdline_parse_token_num_t cmd_config_thresh_value =
2695 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
2697 cmdline_parse_inst_t cmd_config_thresh = {
2698 .f = cmd_config_thresh_parsed,
2700 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
2702 (void *)&cmd_config_thresh_port,
2703 (void *)&cmd_config_thresh_keyword,
2704 (void *)&cmd_config_thresh_all,
2705 (void *)&cmd_config_thresh_name,
2706 (void *)&cmd_config_thresh_value,
2711 /* *** configure free/rs threshold *** */
2712 struct cmd_config_threshold {
2713 cmdline_fixed_string_t port;
2714 cmdline_fixed_string_t keyword;
2715 cmdline_fixed_string_t all;
2716 cmdline_fixed_string_t name;
2721 cmd_config_threshold_parsed(void *parsed_result,
2722 __attribute__((unused)) struct cmdline *cl,
2723 __attribute__((unused)) void *data)
2725 struct cmd_config_threshold *res = parsed_result;
2727 if (!all_ports_stopped()) {
2728 printf("Please stop all ports first\n");
2732 if (!strcmp(res->name, "txfreet"))
2733 tx_free_thresh = res->value;
2734 else if (!strcmp(res->name, "txrst"))
2735 tx_rs_thresh = res->value;
2736 else if (!strcmp(res->name, "rxfreet"))
2737 rx_free_thresh = res->value;
2739 printf("Unknown parameter\n");
2745 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2748 cmdline_parse_token_string_t cmd_config_threshold_port =
2749 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
2750 cmdline_parse_token_string_t cmd_config_threshold_keyword =
2751 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
2753 cmdline_parse_token_string_t cmd_config_threshold_all =
2754 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
2755 cmdline_parse_token_string_t cmd_config_threshold_name =
2756 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
2757 "txfreet#txrst#rxfreet");
2758 cmdline_parse_token_num_t cmd_config_threshold_value =
2759 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
2761 cmdline_parse_inst_t cmd_config_threshold = {
2762 .f = cmd_config_threshold_parsed,
2764 .help_str = "port config all txfreet|txrst|rxfreet <value>",
2766 (void *)&cmd_config_threshold_port,
2767 (void *)&cmd_config_threshold_keyword,
2768 (void *)&cmd_config_threshold_all,
2769 (void *)&cmd_config_threshold_name,
2770 (void *)&cmd_config_threshold_value,
2776 struct cmd_stop_result {
2777 cmdline_fixed_string_t stop;
2780 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
2781 __attribute__((unused)) struct cmdline *cl,
2782 __attribute__((unused)) void *data)
2784 stop_packet_forwarding();
2787 cmdline_parse_token_string_t cmd_stop_stop =
2788 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
2790 cmdline_parse_inst_t cmd_stop = {
2791 .f = cmd_stop_parsed,
2793 .help_str = "stop: Stop packet forwarding",
2795 (void *)&cmd_stop_stop,
2800 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
2803 parse_item_list(char* str, const char* item_name, unsigned int max_items,
2804 unsigned int *parsed_items, int check_unique_values)
2806 unsigned int nb_item;
2814 * First parse all items in the list and store their value.
2819 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
2821 if ((c >= '0') && (c <= '9')) {
2822 value = (unsigned int) (value * 10 + (c - '0'));
2827 printf("character %c is not a decimal digit\n", c);
2831 printf("No valid value before comma\n");
2834 if (nb_item < max_items) {
2835 parsed_items[nb_item] = value;
2841 if (nb_item >= max_items) {
2842 printf("Number of %s = %u > %u (maximum items)\n",
2843 item_name, nb_item + 1, max_items);
2846 parsed_items[nb_item++] = value;
2847 if (! check_unique_values)
2851 * Then, check that all values in the list are differents.
2852 * No optimization here...
2854 for (i = 0; i < nb_item; i++) {
2855 for (j = i + 1; j < nb_item; j++) {
2856 if (parsed_items[j] == parsed_items[i]) {
2857 printf("duplicated %s %u at index %u and %u\n",
2858 item_name, parsed_items[i], i, j);
2866 struct cmd_set_list_result {
2867 cmdline_fixed_string_t cmd_keyword;
2868 cmdline_fixed_string_t list_name;
2869 cmdline_fixed_string_t list_of_items;
2872 static void cmd_set_list_parsed(void *parsed_result,
2873 __attribute__((unused)) struct cmdline *cl,
2874 __attribute__((unused)) void *data)
2876 struct cmd_set_list_result *res;
2878 unsigned int lcorelist[RTE_MAX_LCORE];
2879 unsigned int portlist[RTE_MAX_ETHPORTS];
2881 unsigned int nb_item;
2883 if (test_done == 0) {
2884 printf("Please stop forwarding first\n");
2888 res = parsed_result;
2889 if (!strcmp(res->list_name, "corelist")) {
2890 nb_item = parse_item_list(res->list_of_items, "core",
2892 parsed_items.lcorelist, 1);
2894 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
2899 if (!strcmp(res->list_name, "portlist")) {
2900 nb_item = parse_item_list(res->list_of_items, "port",
2902 parsed_items.portlist, 1);
2904 set_fwd_ports_list(parsed_items.portlist, nb_item);
2910 cmdline_parse_token_string_t cmd_set_list_keyword =
2911 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
2913 cmdline_parse_token_string_t cmd_set_list_name =
2914 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
2915 "corelist#portlist");
2916 cmdline_parse_token_string_t cmd_set_list_of_items =
2917 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
2920 cmdline_parse_inst_t cmd_set_fwd_list = {
2921 .f = cmd_set_list_parsed,
2923 .help_str = "set corelist|portlist <list0[,list1]*>",
2925 (void *)&cmd_set_list_keyword,
2926 (void *)&cmd_set_list_name,
2927 (void *)&cmd_set_list_of_items,
2932 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
2934 struct cmd_setmask_result {
2935 cmdline_fixed_string_t set;
2936 cmdline_fixed_string_t mask;
2940 static void cmd_set_mask_parsed(void *parsed_result,
2941 __attribute__((unused)) struct cmdline *cl,
2942 __attribute__((unused)) void *data)
2944 struct cmd_setmask_result *res = parsed_result;
2946 if (test_done == 0) {
2947 printf("Please stop forwarding first\n");
2950 if (!strcmp(res->mask, "coremask")) {
2951 set_fwd_lcores_mask(res->hexavalue);
2953 } else if (!strcmp(res->mask, "portmask")) {
2954 set_fwd_ports_mask(res->hexavalue);
2959 cmdline_parse_token_string_t cmd_setmask_set =
2960 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
2961 cmdline_parse_token_string_t cmd_setmask_mask =
2962 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
2963 "coremask#portmask");
2964 cmdline_parse_token_num_t cmd_setmask_value =
2965 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
2967 cmdline_parse_inst_t cmd_set_fwd_mask = {
2968 .f = cmd_set_mask_parsed,
2970 .help_str = "set coremask|portmask <hexadecimal value>",
2972 (void *)&cmd_setmask_set,
2973 (void *)&cmd_setmask_mask,
2974 (void *)&cmd_setmask_value,
2980 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
2982 struct cmd_set_result {
2983 cmdline_fixed_string_t set;
2984 cmdline_fixed_string_t what;
2988 static void cmd_set_parsed(void *parsed_result,
2989 __attribute__((unused)) struct cmdline *cl,
2990 __attribute__((unused)) void *data)
2992 struct cmd_set_result *res = parsed_result;
2993 if (!strcmp(res->what, "nbport")) {
2994 set_fwd_ports_number(res->value);
2996 } else if (!strcmp(res->what, "nbcore")) {
2997 set_fwd_lcores_number(res->value);
2999 } else if (!strcmp(res->what, "burst"))
3000 set_nb_pkt_per_burst(res->value);
3001 else if (!strcmp(res->what, "verbose"))
3002 set_verbose_level(res->value);
3005 cmdline_parse_token_string_t cmd_set_set =
3006 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
3007 cmdline_parse_token_string_t cmd_set_what =
3008 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
3009 "nbport#nbcore#burst#verbose");
3010 cmdline_parse_token_num_t cmd_set_value =
3011 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
3013 cmdline_parse_inst_t cmd_set_numbers = {
3014 .f = cmd_set_parsed,
3016 .help_str = "set nbport|nbcore|burst|verbose <value>",
3018 (void *)&cmd_set_set,
3019 (void *)&cmd_set_what,
3020 (void *)&cmd_set_value,
3025 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
3027 struct cmd_set_txpkts_result {
3028 cmdline_fixed_string_t cmd_keyword;
3029 cmdline_fixed_string_t txpkts;
3030 cmdline_fixed_string_t seg_lengths;
3034 cmd_set_txpkts_parsed(void *parsed_result,
3035 __attribute__((unused)) struct cmdline *cl,
3036 __attribute__((unused)) void *data)
3038 struct cmd_set_txpkts_result *res;
3039 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
3040 unsigned int nb_segs;
3042 res = parsed_result;
3043 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
3044 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
3046 set_tx_pkt_segments(seg_lengths, nb_segs);
3049 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
3050 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3051 cmd_keyword, "set");
3052 cmdline_parse_token_string_t cmd_set_txpkts_name =
3053 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3055 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
3056 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3059 cmdline_parse_inst_t cmd_set_txpkts = {
3060 .f = cmd_set_txpkts_parsed,
3062 .help_str = "set txpkts <len0[,len1]*>",
3064 (void *)&cmd_set_txpkts_keyword,
3065 (void *)&cmd_set_txpkts_name,
3066 (void *)&cmd_set_txpkts_lengths,
3071 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
3073 struct cmd_set_txsplit_result {
3074 cmdline_fixed_string_t cmd_keyword;
3075 cmdline_fixed_string_t txsplit;
3076 cmdline_fixed_string_t mode;
3080 cmd_set_txsplit_parsed(void *parsed_result,
3081 __attribute__((unused)) struct cmdline *cl,
3082 __attribute__((unused)) void *data)
3084 struct cmd_set_txsplit_result *res;
3086 res = parsed_result;
3087 set_tx_pkt_split(res->mode);
3090 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
3091 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3092 cmd_keyword, "set");
3093 cmdline_parse_token_string_t cmd_set_txsplit_name =
3094 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3095 txsplit, "txsplit");
3096 cmdline_parse_token_string_t cmd_set_txsplit_mode =
3097 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3100 cmdline_parse_inst_t cmd_set_txsplit = {
3101 .f = cmd_set_txsplit_parsed,
3103 .help_str = "set txsplit on|off|rand",
3105 (void *)&cmd_set_txsplit_keyword,
3106 (void *)&cmd_set_txsplit_name,
3107 (void *)&cmd_set_txsplit_mode,
3112 /* *** CONFIG TX QUEUE FLAGS *** */
3114 struct cmd_config_txqflags_result {
3115 cmdline_fixed_string_t port;
3116 cmdline_fixed_string_t config;
3117 cmdline_fixed_string_t all;
3118 cmdline_fixed_string_t what;
3122 static void cmd_config_txqflags_parsed(void *parsed_result,
3123 __attribute__((unused)) struct cmdline *cl,
3124 __attribute__((unused)) void *data)
3126 struct cmd_config_txqflags_result *res = parsed_result;
3128 if (!all_ports_stopped()) {
3129 printf("Please stop all ports first\n");
3133 if (strcmp(res->what, "txqflags")) {
3134 printf("Unknown parameter\n");
3138 if (res->hexvalue >= 0) {
3139 txq_flags = res->hexvalue;
3141 printf("txqflags must be >= 0\n");
3147 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3150 cmdline_parse_token_string_t cmd_config_txqflags_port =
3151 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, port,
3153 cmdline_parse_token_string_t cmd_config_txqflags_config =
3154 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, config,
3156 cmdline_parse_token_string_t cmd_config_txqflags_all =
3157 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, all,
3159 cmdline_parse_token_string_t cmd_config_txqflags_what =
3160 TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, what,
3162 cmdline_parse_token_num_t cmd_config_txqflags_value =
3163 TOKEN_NUM_INITIALIZER(struct cmd_config_txqflags_result,
3166 cmdline_parse_inst_t cmd_config_txqflags = {
3167 .f = cmd_config_txqflags_parsed,
3169 .help_str = "port config all txqflags <value>",
3171 (void *)&cmd_config_txqflags_port,
3172 (void *)&cmd_config_txqflags_config,
3173 (void *)&cmd_config_txqflags_all,
3174 (void *)&cmd_config_txqflags_what,
3175 (void *)&cmd_config_txqflags_value,
3180 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
3181 struct cmd_rx_vlan_filter_all_result {
3182 cmdline_fixed_string_t rx_vlan;
3183 cmdline_fixed_string_t what;
3184 cmdline_fixed_string_t all;
3189 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
3190 __attribute__((unused)) struct cmdline *cl,
3191 __attribute__((unused)) void *data)
3193 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
3195 if (!strcmp(res->what, "add"))
3196 rx_vlan_all_filter_set(res->port_id, 1);
3198 rx_vlan_all_filter_set(res->port_id, 0);
3201 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
3202 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3203 rx_vlan, "rx_vlan");
3204 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
3205 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3207 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
3208 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3210 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
3211 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3214 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
3215 .f = cmd_rx_vlan_filter_all_parsed,
3217 .help_str = "rx_vlan add|rm all <port_id>: "
3218 "Add/Remove all identifiers to/from the set of VLAN "
3219 "identifiers filtered by a port",
3221 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
3222 (void *)&cmd_rx_vlan_filter_all_what,
3223 (void *)&cmd_rx_vlan_filter_all_all,
3224 (void *)&cmd_rx_vlan_filter_all_portid,
3229 /* *** VLAN OFFLOAD SET ON A PORT *** */
3230 struct cmd_vlan_offload_result {
3231 cmdline_fixed_string_t vlan;
3232 cmdline_fixed_string_t set;
3233 cmdline_fixed_string_t vlan_type;
3234 cmdline_fixed_string_t what;
3235 cmdline_fixed_string_t on;
3236 cmdline_fixed_string_t port_id;
3240 cmd_vlan_offload_parsed(void *parsed_result,
3241 __attribute__((unused)) struct cmdline *cl,
3242 __attribute__((unused)) void *data)
3245 struct cmd_vlan_offload_result *res = parsed_result;
3248 portid_t port_id = 0;
3252 len = strnlen(str, STR_TOKEN_SIZE);
3254 /* Get port_id first */
3262 tmp = strtoul(str, NULL, 0);
3263 /* If port_id greater that what portid_t can represent, return */
3264 if(tmp >= RTE_MAX_ETHPORTS)
3266 port_id = (portid_t)tmp;
3268 if (!strcmp(res->on, "on"))
3273 if (!strcmp(res->what, "strip"))
3274 rx_vlan_strip_set(port_id, on);
3275 else if(!strcmp(res->what, "stripq")){
3276 uint16_t queue_id = 0;
3278 /* No queue_id, return */
3280 printf("must specify (port,queue_id)\n");
3283 tmp = strtoul(str + i + 1, NULL, 0);
3284 /* If queue_id greater that what 16-bits can represent, return */
3288 queue_id = (uint16_t)tmp;
3289 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
3291 else if (!strcmp(res->what, "filter"))
3292 rx_vlan_filter_set(port_id, on);
3294 vlan_extend_set(port_id, on);
3299 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
3300 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3302 cmdline_parse_token_string_t cmd_vlan_offload_set =
3303 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3305 cmdline_parse_token_string_t cmd_vlan_offload_what =
3306 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3307 what, "strip#filter#qinq#stripq");
3308 cmdline_parse_token_string_t cmd_vlan_offload_on =
3309 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3311 cmdline_parse_token_string_t cmd_vlan_offload_portid =
3312 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3315 cmdline_parse_inst_t cmd_vlan_offload = {
3316 .f = cmd_vlan_offload_parsed,
3318 .help_str = "vlan set strip|filter|qinq|stripq on|off "
3319 "<port_id[,queue_id]>: "
3320 "Filter/Strip for rx side qinq(extended) for both rx/tx sides",
3322 (void *)&cmd_vlan_offload_vlan,
3323 (void *)&cmd_vlan_offload_set,
3324 (void *)&cmd_vlan_offload_what,
3325 (void *)&cmd_vlan_offload_on,
3326 (void *)&cmd_vlan_offload_portid,
3331 /* *** VLAN TPID SET ON A PORT *** */
3332 struct cmd_vlan_tpid_result {
3333 cmdline_fixed_string_t vlan;
3334 cmdline_fixed_string_t set;
3335 cmdline_fixed_string_t vlan_type;
3336 cmdline_fixed_string_t what;
3342 cmd_vlan_tpid_parsed(void *parsed_result,
3343 __attribute__((unused)) struct cmdline *cl,
3344 __attribute__((unused)) void *data)
3346 struct cmd_vlan_tpid_result *res = parsed_result;
3347 enum rte_vlan_type vlan_type;
3349 if (!strcmp(res->vlan_type, "inner"))
3350 vlan_type = ETH_VLAN_TYPE_INNER;
3351 else if (!strcmp(res->vlan_type, "outer"))
3352 vlan_type = ETH_VLAN_TYPE_OUTER;
3354 printf("Unknown vlan type\n");
3357 vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
3360 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
3361 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3363 cmdline_parse_token_string_t cmd_vlan_tpid_set =
3364 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3366 cmdline_parse_token_string_t cmd_vlan_type =
3367 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3368 vlan_type, "inner#outer");
3369 cmdline_parse_token_string_t cmd_vlan_tpid_what =
3370 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3372 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
3373 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3375 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
3376 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3379 cmdline_parse_inst_t cmd_vlan_tpid = {
3380 .f = cmd_vlan_tpid_parsed,
3382 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
3383 "Set the VLAN Ether type",
3385 (void *)&cmd_vlan_tpid_vlan,
3386 (void *)&cmd_vlan_tpid_set,
3387 (void *)&cmd_vlan_type,
3388 (void *)&cmd_vlan_tpid_what,
3389 (void *)&cmd_vlan_tpid_tpid,
3390 (void *)&cmd_vlan_tpid_portid,
3395 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
3396 struct cmd_rx_vlan_filter_result {
3397 cmdline_fixed_string_t rx_vlan;
3398 cmdline_fixed_string_t what;
3404 cmd_rx_vlan_filter_parsed(void *parsed_result,
3405 __attribute__((unused)) struct cmdline *cl,
3406 __attribute__((unused)) void *data)
3408 struct cmd_rx_vlan_filter_result *res = parsed_result;
3410 if (!strcmp(res->what, "add"))
3411 rx_vft_set(res->port_id, res->vlan_id, 1);
3413 rx_vft_set(res->port_id, res->vlan_id, 0);
3416 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
3417 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3418 rx_vlan, "rx_vlan");
3419 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
3420 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3422 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
3423 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3425 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
3426 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3429 cmdline_parse_inst_t cmd_rx_vlan_filter = {
3430 .f = cmd_rx_vlan_filter_parsed,
3432 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
3433 "Add/Remove a VLAN identifier to/from the set of VLAN "
3434 "identifiers filtered by a port",
3436 (void *)&cmd_rx_vlan_filter_rx_vlan,
3437 (void *)&cmd_rx_vlan_filter_what,
3438 (void *)&cmd_rx_vlan_filter_vlanid,
3439 (void *)&cmd_rx_vlan_filter_portid,
3444 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3445 struct cmd_tx_vlan_set_result {
3446 cmdline_fixed_string_t tx_vlan;
3447 cmdline_fixed_string_t set;
3453 cmd_tx_vlan_set_parsed(void *parsed_result,
3454 __attribute__((unused)) struct cmdline *cl,
3455 __attribute__((unused)) void *data)
3457 struct cmd_tx_vlan_set_result *res = parsed_result;
3459 if (!port_is_stopped(res->port_id)) {
3460 printf("Please stop port %d first\n", res->port_id);
3464 tx_vlan_set(res->port_id, res->vlan_id);
3466 cmd_reconfig_device_queue(res->port_id, 1, 1);
3469 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
3470 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3471 tx_vlan, "tx_vlan");
3472 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
3473 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3475 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
3476 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3478 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
3479 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3482 cmdline_parse_inst_t cmd_tx_vlan_set = {
3483 .f = cmd_tx_vlan_set_parsed,
3485 .help_str = "tx_vlan set <port_id> <vlan_id>: "
3486 "Enable hardware insertion of a single VLAN header "
3487 "with a given TAG Identifier in packets sent on a port",
3489 (void *)&cmd_tx_vlan_set_tx_vlan,
3490 (void *)&cmd_tx_vlan_set_set,
3491 (void *)&cmd_tx_vlan_set_portid,
3492 (void *)&cmd_tx_vlan_set_vlanid,
3497 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
3498 struct cmd_tx_vlan_set_qinq_result {
3499 cmdline_fixed_string_t tx_vlan;
3500 cmdline_fixed_string_t set;
3503 uint16_t vlan_id_outer;
3507 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
3508 __attribute__((unused)) struct cmdline *cl,
3509 __attribute__((unused)) void *data)
3511 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
3513 if (!port_is_stopped(res->port_id)) {
3514 printf("Please stop port %d first\n", res->port_id);
3518 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
3520 cmd_reconfig_device_queue(res->port_id, 1, 1);
3523 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
3524 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3525 tx_vlan, "tx_vlan");
3526 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
3527 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3529 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
3530 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3532 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
3533 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3535 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
3536 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3537 vlan_id_outer, UINT16);
3539 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
3540 .f = cmd_tx_vlan_set_qinq_parsed,
3542 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
3543 "Enable hardware insertion of double VLAN header "
3544 "with given TAG Identifiers in packets sent on a port",
3546 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
3547 (void *)&cmd_tx_vlan_set_qinq_set,
3548 (void *)&cmd_tx_vlan_set_qinq_portid,
3549 (void *)&cmd_tx_vlan_set_qinq_vlanid,
3550 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
3555 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
3556 struct cmd_tx_vlan_set_pvid_result {
3557 cmdline_fixed_string_t tx_vlan;
3558 cmdline_fixed_string_t set;
3559 cmdline_fixed_string_t pvid;
3562 cmdline_fixed_string_t mode;
3566 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
3567 __attribute__((unused)) struct cmdline *cl,
3568 __attribute__((unused)) void *data)
3570 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
3572 if (strcmp(res->mode, "on") == 0)
3573 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
3575 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
3578 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
3579 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3580 tx_vlan, "tx_vlan");
3581 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
3582 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3584 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
3585 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3587 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
3588 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3590 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
3591 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3593 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
3594 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3597 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
3598 .f = cmd_tx_vlan_set_pvid_parsed,
3600 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
3602 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
3603 (void *)&cmd_tx_vlan_set_pvid_set,
3604 (void *)&cmd_tx_vlan_set_pvid_pvid,
3605 (void *)&cmd_tx_vlan_set_pvid_port_id,
3606 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
3607 (void *)&cmd_tx_vlan_set_pvid_mode,
3612 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3613 struct cmd_tx_vlan_reset_result {
3614 cmdline_fixed_string_t tx_vlan;
3615 cmdline_fixed_string_t reset;
3620 cmd_tx_vlan_reset_parsed(void *parsed_result,
3621 __attribute__((unused)) struct cmdline *cl,
3622 __attribute__((unused)) void *data)
3624 struct cmd_tx_vlan_reset_result *res = parsed_result;
3626 if (!port_is_stopped(res->port_id)) {
3627 printf("Please stop port %d first\n", res->port_id);
3631 tx_vlan_reset(res->port_id);
3633 cmd_reconfig_device_queue(res->port_id, 1, 1);
3636 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
3637 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
3638 tx_vlan, "tx_vlan");
3639 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
3640 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
3642 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
3643 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
3646 cmdline_parse_inst_t cmd_tx_vlan_reset = {
3647 .f = cmd_tx_vlan_reset_parsed,
3649 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
3650 "VLAN header in packets sent on a port",
3652 (void *)&cmd_tx_vlan_reset_tx_vlan,
3653 (void *)&cmd_tx_vlan_reset_reset,
3654 (void *)&cmd_tx_vlan_reset_portid,
3660 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
3661 struct cmd_csum_result {
3662 cmdline_fixed_string_t csum;
3663 cmdline_fixed_string_t mode;
3664 cmdline_fixed_string_t proto;
3665 cmdline_fixed_string_t hwsw;
3670 csum_show(int port_id)
3672 struct rte_eth_dev_info dev_info;
3673 uint64_t tx_offloads;
3675 tx_offloads = ports[port_id].dev_conf.txmode.offloads;
3676 printf("Parse tunnel is %s\n",
3677 (ports[port_id].parse_tunnel) ? "on" : "off");
3678 printf("IP checksum offload is %s\n",
3679 (tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) ? "hw" : "sw");
3680 printf("UDP checksum offload is %s\n",
3681 (tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
3682 printf("TCP checksum offload is %s\n",
3683 (tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
3684 printf("SCTP checksum offload is %s\n",
3685 (tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
3686 printf("Outer-Ip checksum offload is %s\n",
3687 (tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) ? "hw" : "sw");
3689 /* display warnings if configuration is not supported by the NIC */
3690 rte_eth_dev_info_get(port_id, &dev_info);
3691 if ((tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) &&
3692 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
3693 printf("Warning: hardware IP checksum enabled but not "
3694 "supported by port %d\n", port_id);
3696 if ((tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) &&
3697 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
3698 printf("Warning: hardware UDP checksum enabled but not "
3699 "supported by port %d\n", port_id);
3701 if ((tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) &&
3702 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
3703 printf("Warning: hardware TCP checksum enabled but not "
3704 "supported by port %d\n", port_id);
3706 if ((tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) &&
3707 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
3708 printf("Warning: hardware SCTP checksum enabled but not "
3709 "supported by port %d\n", port_id);
3711 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) &&
3712 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
3713 printf("Warning: hardware outer IP checksum enabled but not "
3714 "supported by port %d\n", port_id);
3719 cmd_csum_parsed(void *parsed_result,
3720 __attribute__((unused)) struct cmdline *cl,
3721 __attribute__((unused)) void *data)
3723 struct cmd_csum_result *res = parsed_result;
3725 uint64_t csum_offloads = 0;
3727 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
3728 printf("invalid port %d\n", res->port_id);
3731 if (!port_is_stopped(res->port_id)) {
3732 printf("Please stop port %d first\n", res->port_id);
3736 if (!strcmp(res->mode, "set")) {
3738 if (!strcmp(res->hwsw, "hw"))
3741 if (!strcmp(res->proto, "ip")) {
3742 csum_offloads |= DEV_TX_OFFLOAD_IPV4_CKSUM;
3743 } else if (!strcmp(res->proto, "udp")) {
3744 csum_offloads |= DEV_TX_OFFLOAD_UDP_CKSUM;
3745 } else if (!strcmp(res->proto, "tcp")) {
3746 csum_offloads |= DEV_TX_OFFLOAD_TCP_CKSUM;
3747 } else if (!strcmp(res->proto, "sctp")) {
3748 csum_offloads |= DEV_TX_OFFLOAD_SCTP_CKSUM;
3749 } else if (!strcmp(res->proto, "outer-ip")) {
3750 csum_offloads |= DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM;
3754 ports[res->port_id].dev_conf.txmode.offloads |=
3757 ports[res->port_id].dev_conf.txmode.offloads &=
3761 csum_show(res->port_id);
3763 cmd_reconfig_device_queue(res->port_id, 1, 1);
3766 cmdline_parse_token_string_t cmd_csum_csum =
3767 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3769 cmdline_parse_token_string_t cmd_csum_mode =
3770 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3772 cmdline_parse_token_string_t cmd_csum_proto =
3773 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3774 proto, "ip#tcp#udp#sctp#outer-ip");
3775 cmdline_parse_token_string_t cmd_csum_hwsw =
3776 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3778 cmdline_parse_token_num_t cmd_csum_portid =
3779 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
3782 cmdline_parse_inst_t cmd_csum_set = {
3783 .f = cmd_csum_parsed,
3785 .help_str = "csum set ip|tcp|udp|sctp|outer-ip hw|sw <port_id>: "
3786 "Enable/Disable hardware calculation of L3/L4 checksum when "
3787 "using csum forward engine",
3789 (void *)&cmd_csum_csum,
3790 (void *)&cmd_csum_mode,
3791 (void *)&cmd_csum_proto,
3792 (void *)&cmd_csum_hwsw,
3793 (void *)&cmd_csum_portid,
3798 cmdline_parse_token_string_t cmd_csum_mode_show =
3799 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3802 cmdline_parse_inst_t cmd_csum_show = {
3803 .f = cmd_csum_parsed,
3805 .help_str = "csum show <port_id>: Show checksum offload configuration",
3807 (void *)&cmd_csum_csum,
3808 (void *)&cmd_csum_mode_show,
3809 (void *)&cmd_csum_portid,
3814 /* Enable/disable tunnel parsing */
3815 struct cmd_csum_tunnel_result {
3816 cmdline_fixed_string_t csum;
3817 cmdline_fixed_string_t parse;
3818 cmdline_fixed_string_t onoff;
3823 cmd_csum_tunnel_parsed(void *parsed_result,
3824 __attribute__((unused)) struct cmdline *cl,
3825 __attribute__((unused)) void *data)
3827 struct cmd_csum_tunnel_result *res = parsed_result;
3829 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3832 if (!strcmp(res->onoff, "on"))
3833 ports[res->port_id].parse_tunnel = 1;
3835 ports[res->port_id].parse_tunnel = 0;
3837 csum_show(res->port_id);
3840 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
3841 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3843 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
3844 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3845 parse, "parse_tunnel");
3846 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
3847 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3849 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
3850 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
3853 cmdline_parse_inst_t cmd_csum_tunnel = {
3854 .f = cmd_csum_tunnel_parsed,
3856 .help_str = "csum parse_tunnel on|off <port_id>: "
3857 "Enable/Disable parsing of tunnels for csum engine",
3859 (void *)&cmd_csum_tunnel_csum,
3860 (void *)&cmd_csum_tunnel_parse,
3861 (void *)&cmd_csum_tunnel_onoff,
3862 (void *)&cmd_csum_tunnel_portid,
3867 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
3868 struct cmd_tso_set_result {
3869 cmdline_fixed_string_t tso;
3870 cmdline_fixed_string_t mode;
3876 cmd_tso_set_parsed(void *parsed_result,
3877 __attribute__((unused)) struct cmdline *cl,
3878 __attribute__((unused)) void *data)
3880 struct cmd_tso_set_result *res = parsed_result;
3881 struct rte_eth_dev_info dev_info;
3883 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3885 if (!port_is_stopped(res->port_id)) {
3886 printf("Please stop port %d first\n", res->port_id);
3890 if (!strcmp(res->mode, "set"))
3891 ports[res->port_id].tso_segsz = res->tso_segsz;
3893 if (ports[res->port_id].tso_segsz == 0) {
3894 ports[res->port_id].dev_conf.txmode.offloads &=
3895 ~DEV_TX_OFFLOAD_TCP_TSO;
3896 printf("TSO for non-tunneled packets is disabled\n");
3898 ports[res->port_id].dev_conf.txmode.offloads |=
3899 DEV_TX_OFFLOAD_TCP_TSO;
3900 printf("TSO segment size for non-tunneled packets is %d\n",
3901 ports[res->port_id].tso_segsz);
3904 /* display warnings if configuration is not supported by the NIC */
3905 rte_eth_dev_info_get(res->port_id, &dev_info);
3906 if ((ports[res->port_id].tso_segsz != 0) &&
3907 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
3908 printf("Warning: TSO enabled but not "
3909 "supported by port %d\n", res->port_id);
3912 cmd_reconfig_device_queue(res->port_id, 1, 1);
3915 cmdline_parse_token_string_t cmd_tso_set_tso =
3916 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3918 cmdline_parse_token_string_t cmd_tso_set_mode =
3919 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3921 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
3922 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3924 cmdline_parse_token_num_t cmd_tso_set_portid =
3925 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3928 cmdline_parse_inst_t cmd_tso_set = {
3929 .f = cmd_tso_set_parsed,
3931 .help_str = "tso set <tso_segsz> <port_id>: "
3932 "Set TSO segment size of non-tunneled packets for csum engine "
3935 (void *)&cmd_tso_set_tso,
3936 (void *)&cmd_tso_set_mode,
3937 (void *)&cmd_tso_set_tso_segsz,
3938 (void *)&cmd_tso_set_portid,
3943 cmdline_parse_token_string_t cmd_tso_show_mode =
3944 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3948 cmdline_parse_inst_t cmd_tso_show = {
3949 .f = cmd_tso_set_parsed,
3951 .help_str = "tso show <port_id>: "
3952 "Show TSO segment size of non-tunneled packets for csum engine",
3954 (void *)&cmd_tso_set_tso,
3955 (void *)&cmd_tso_show_mode,
3956 (void *)&cmd_tso_set_portid,
3961 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
3962 struct cmd_tunnel_tso_set_result {
3963 cmdline_fixed_string_t tso;
3964 cmdline_fixed_string_t mode;
3970 check_tunnel_tso_nic_support(portid_t port_id)
3972 struct rte_eth_dev_info dev_info;
3974 rte_eth_dev_info_get(port_id, &dev_info);
3975 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO))
3976 printf("Warning: TSO enabled but VXLAN TUNNEL TSO not "
3977 "supported by port %d\n", port_id);
3978 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO))
3979 printf("Warning: TSO enabled but GRE TUNNEL TSO not "
3980 "supported by port %d\n", port_id);
3981 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO))
3982 printf("Warning: TSO enabled but IPIP TUNNEL TSO not "
3983 "supported by port %d\n", port_id);
3984 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
3985 printf("Warning: TSO enabled but GENEVE TUNNEL TSO not "
3986 "supported by port %d\n", port_id);
3990 cmd_tunnel_tso_set_parsed(void *parsed_result,
3991 __attribute__((unused)) struct cmdline *cl,
3992 __attribute__((unused)) void *data)
3994 struct cmd_tunnel_tso_set_result *res = parsed_result;
3996 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3998 if (!port_is_stopped(res->port_id)) {
3999 printf("Please stop port %d first\n", res->port_id);
4003 if (!strcmp(res->mode, "set"))
4004 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
4006 if (ports[res->port_id].tunnel_tso_segsz == 0) {
4007 ports[res->port_id].dev_conf.txmode.offloads &=
4008 ~(DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4009 DEV_TX_OFFLOAD_GRE_TNL_TSO |
4010 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4011 DEV_TX_OFFLOAD_GENEVE_TNL_TSO);
4012 printf("TSO for tunneled packets is disabled\n");
4014 ports[res->port_id].dev_conf.txmode.offloads |=
4015 (DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4016 DEV_TX_OFFLOAD_GRE_TNL_TSO |
4017 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4018 DEV_TX_OFFLOAD_GENEVE_TNL_TSO);
4019 printf("TSO segment size for tunneled packets is %d\n",
4020 ports[res->port_id].tunnel_tso_segsz);
4022 /* Below conditions are needed to make it work:
4023 * (1) tunnel TSO is supported by the NIC;
4024 * (2) "csum parse_tunnel" must be set so that tunneled pkts
4026 * (3) for tunneled pkts with outer L3 of IPv4,
4027 * "csum set outer-ip" must be set to hw, because after tso,
4028 * total_len of outer IP header is changed, and the checksum
4029 * of outer IP header calculated by sw should be wrong; that
4030 * is not necessary for IPv6 tunneled pkts because there's no
4031 * checksum in IP header anymore.
4033 check_tunnel_tso_nic_support(res->port_id);
4035 if (!ports[res->port_id].parse_tunnel)
4036 printf("Warning: csum parse_tunnel must be set "
4037 "so that tunneled packets are recognized\n");
4038 if (!(ports[res->port_id].dev_conf.txmode.offloads &
4039 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM))
4040 printf("Warning: csum set outer-ip must be set to hw "
4041 "if outer L3 is IPv4; not necessary for IPv6\n");
4044 cmd_reconfig_device_queue(res->port_id, 1, 1);
4047 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
4048 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4050 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
4051 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4053 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
4054 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4056 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
4057 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4060 cmdline_parse_inst_t cmd_tunnel_tso_set = {
4061 .f = cmd_tunnel_tso_set_parsed,
4063 .help_str = "tunnel_tso set <tso_segsz> <port_id>: "
4064 "Set TSO segment size of tunneled packets for csum engine "
4067 (void *)&cmd_tunnel_tso_set_tso,
4068 (void *)&cmd_tunnel_tso_set_mode,
4069 (void *)&cmd_tunnel_tso_set_tso_segsz,
4070 (void *)&cmd_tunnel_tso_set_portid,
4075 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
4076 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4080 cmdline_parse_inst_t cmd_tunnel_tso_show = {
4081 .f = cmd_tunnel_tso_set_parsed,
4083 .help_str = "tunnel_tso show <port_id> "
4084 "Show TSO segment size of tunneled packets for csum engine",
4086 (void *)&cmd_tunnel_tso_set_tso,
4087 (void *)&cmd_tunnel_tso_show_mode,
4088 (void *)&cmd_tunnel_tso_set_portid,
4093 /* *** SET GRO FOR A PORT *** */
4094 struct cmd_gro_enable_result {
4095 cmdline_fixed_string_t cmd_set;
4096 cmdline_fixed_string_t cmd_port;
4097 cmdline_fixed_string_t cmd_keyword;
4098 cmdline_fixed_string_t cmd_onoff;
4103 cmd_gro_enable_parsed(void *parsed_result,
4104 __attribute__((unused)) struct cmdline *cl,
4105 __attribute__((unused)) void *data)
4107 struct cmd_gro_enable_result *res;
4109 res = parsed_result;
4110 if (!strcmp(res->cmd_keyword, "gro"))
4111 setup_gro(res->cmd_onoff, res->cmd_pid);
4114 cmdline_parse_token_string_t cmd_gro_enable_set =
4115 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4117 cmdline_parse_token_string_t cmd_gro_enable_port =
4118 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4119 cmd_keyword, "port");
4120 cmdline_parse_token_num_t cmd_gro_enable_pid =
4121 TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result,
4123 cmdline_parse_token_string_t cmd_gro_enable_keyword =
4124 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4125 cmd_keyword, "gro");
4126 cmdline_parse_token_string_t cmd_gro_enable_onoff =
4127 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4128 cmd_onoff, "on#off");
4130 cmdline_parse_inst_t cmd_gro_enable = {
4131 .f = cmd_gro_enable_parsed,
4133 .help_str = "set port <port_id> gro on|off",
4135 (void *)&cmd_gro_enable_set,
4136 (void *)&cmd_gro_enable_port,
4137 (void *)&cmd_gro_enable_pid,
4138 (void *)&cmd_gro_enable_keyword,
4139 (void *)&cmd_gro_enable_onoff,
4144 /* *** DISPLAY GRO CONFIGURATION *** */
4145 struct cmd_gro_show_result {
4146 cmdline_fixed_string_t cmd_show;
4147 cmdline_fixed_string_t cmd_port;
4148 cmdline_fixed_string_t cmd_keyword;
4153 cmd_gro_show_parsed(void *parsed_result,
4154 __attribute__((unused)) struct cmdline *cl,
4155 __attribute__((unused)) void *data)
4157 struct cmd_gro_show_result *res;
4159 res = parsed_result;
4160 if (!strcmp(res->cmd_keyword, "gro"))
4161 show_gro(res->cmd_pid);
4164 cmdline_parse_token_string_t cmd_gro_show_show =
4165 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4167 cmdline_parse_token_string_t cmd_gro_show_port =
4168 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4170 cmdline_parse_token_num_t cmd_gro_show_pid =
4171 TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result,
4173 cmdline_parse_token_string_t cmd_gro_show_keyword =
4174 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4175 cmd_keyword, "gro");
4177 cmdline_parse_inst_t cmd_gro_show = {
4178 .f = cmd_gro_show_parsed,
4180 .help_str = "show port <port_id> gro",
4182 (void *)&cmd_gro_show_show,
4183 (void *)&cmd_gro_show_port,
4184 (void *)&cmd_gro_show_pid,
4185 (void *)&cmd_gro_show_keyword,
4190 /* *** SET FLUSH CYCLES FOR GRO *** */
4191 struct cmd_gro_flush_result {
4192 cmdline_fixed_string_t cmd_set;
4193 cmdline_fixed_string_t cmd_keyword;
4194 cmdline_fixed_string_t cmd_flush;
4199 cmd_gro_flush_parsed(void *parsed_result,
4200 __attribute__((unused)) struct cmdline *cl,
4201 __attribute__((unused)) void *data)
4203 struct cmd_gro_flush_result *res;
4205 res = parsed_result;
4206 if ((!strcmp(res->cmd_keyword, "gro")) &&
4207 (!strcmp(res->cmd_flush, "flush")))
4208 setup_gro_flush_cycles(res->cmd_cycles);
4211 cmdline_parse_token_string_t cmd_gro_flush_set =
4212 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4214 cmdline_parse_token_string_t cmd_gro_flush_keyword =
4215 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4216 cmd_keyword, "gro");
4217 cmdline_parse_token_string_t cmd_gro_flush_flush =
4218 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4219 cmd_flush, "flush");
4220 cmdline_parse_token_num_t cmd_gro_flush_cycles =
4221 TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result,
4224 cmdline_parse_inst_t cmd_gro_flush = {
4225 .f = cmd_gro_flush_parsed,
4227 .help_str = "set gro flush <cycles>",
4229 (void *)&cmd_gro_flush_set,
4230 (void *)&cmd_gro_flush_keyword,
4231 (void *)&cmd_gro_flush_flush,
4232 (void *)&cmd_gro_flush_cycles,
4237 /* *** ENABLE/DISABLE GSO *** */
4238 struct cmd_gso_enable_result {
4239 cmdline_fixed_string_t cmd_set;
4240 cmdline_fixed_string_t cmd_port;
4241 cmdline_fixed_string_t cmd_keyword;
4242 cmdline_fixed_string_t cmd_mode;
4247 cmd_gso_enable_parsed(void *parsed_result,
4248 __attribute__((unused)) struct cmdline *cl,
4249 __attribute__((unused)) void *data)
4251 struct cmd_gso_enable_result *res;
4253 res = parsed_result;
4254 if (!strcmp(res->cmd_keyword, "gso"))
4255 setup_gso(res->cmd_mode, res->cmd_pid);
4258 cmdline_parse_token_string_t cmd_gso_enable_set =
4259 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4261 cmdline_parse_token_string_t cmd_gso_enable_port =
4262 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4264 cmdline_parse_token_string_t cmd_gso_enable_keyword =
4265 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4266 cmd_keyword, "gso");
4267 cmdline_parse_token_string_t cmd_gso_enable_mode =
4268 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4269 cmd_mode, "on#off");
4270 cmdline_parse_token_num_t cmd_gso_enable_pid =
4271 TOKEN_NUM_INITIALIZER(struct cmd_gso_enable_result,
4274 cmdline_parse_inst_t cmd_gso_enable = {
4275 .f = cmd_gso_enable_parsed,
4277 .help_str = "set port <port_id> gso on|off",
4279 (void *)&cmd_gso_enable_set,
4280 (void *)&cmd_gso_enable_port,
4281 (void *)&cmd_gso_enable_pid,
4282 (void *)&cmd_gso_enable_keyword,
4283 (void *)&cmd_gso_enable_mode,
4288 /* *** SET MAX PACKET LENGTH FOR GSO SEGMENTS *** */
4289 struct cmd_gso_size_result {
4290 cmdline_fixed_string_t cmd_set;
4291 cmdline_fixed_string_t cmd_keyword;
4292 cmdline_fixed_string_t cmd_segsz;
4297 cmd_gso_size_parsed(void *parsed_result,
4298 __attribute__((unused)) struct cmdline *cl,
4299 __attribute__((unused)) void *data)
4301 struct cmd_gso_size_result *res = parsed_result;
4303 if (test_done == 0) {
4304 printf("Before setting GSO segsz, please first"
4305 " stop fowarding\n");
4309 if (!strcmp(res->cmd_keyword, "gso") &&
4310 !strcmp(res->cmd_segsz, "segsz")) {
4311 if (res->cmd_size < RTE_GSO_SEG_SIZE_MIN)
4312 printf("gso_size should be larger than %zu."
4313 " Please input a legal value\n",
4314 RTE_GSO_SEG_SIZE_MIN);
4316 gso_max_segment_size = res->cmd_size;
4320 cmdline_parse_token_string_t cmd_gso_size_set =
4321 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
4323 cmdline_parse_token_string_t cmd_gso_size_keyword =
4324 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
4325 cmd_keyword, "gso");
4326 cmdline_parse_token_string_t cmd_gso_size_segsz =
4327 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
4328 cmd_segsz, "segsz");
4329 cmdline_parse_token_num_t cmd_gso_size_size =
4330 TOKEN_NUM_INITIALIZER(struct cmd_gso_size_result,
4333 cmdline_parse_inst_t cmd_gso_size = {
4334 .f = cmd_gso_size_parsed,
4336 .help_str = "set gso segsz <length>",
4338 (void *)&cmd_gso_size_set,
4339 (void *)&cmd_gso_size_keyword,
4340 (void *)&cmd_gso_size_segsz,
4341 (void *)&cmd_gso_size_size,
4346 /* *** SHOW GSO CONFIGURATION *** */
4347 struct cmd_gso_show_result {
4348 cmdline_fixed_string_t cmd_show;
4349 cmdline_fixed_string_t cmd_port;
4350 cmdline_fixed_string_t cmd_keyword;
4355 cmd_gso_show_parsed(void *parsed_result,
4356 __attribute__((unused)) struct cmdline *cl,
4357 __attribute__((unused)) void *data)
4359 struct cmd_gso_show_result *res = parsed_result;
4361 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
4362 printf("invalid port id %u\n", res->cmd_pid);
4365 if (!strcmp(res->cmd_keyword, "gso")) {
4366 if (gso_ports[res->cmd_pid].enable) {
4367 printf("Max GSO'd packet size: %uB\n"
4368 "Supported GSO types: TCP/IPv4, "
4369 "VxLAN with inner TCP/IPv4 packet, "
4370 "GRE with inner TCP/IPv4 packet\n",
4371 gso_max_segment_size);
4373 printf("GSO is not enabled on Port %u\n", res->cmd_pid);
4377 cmdline_parse_token_string_t cmd_gso_show_show =
4378 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
4380 cmdline_parse_token_string_t cmd_gso_show_port =
4381 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
4383 cmdline_parse_token_string_t cmd_gso_show_keyword =
4384 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
4385 cmd_keyword, "gso");
4386 cmdline_parse_token_num_t cmd_gso_show_pid =
4387 TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result,
4390 cmdline_parse_inst_t cmd_gso_show = {
4391 .f = cmd_gso_show_parsed,
4393 .help_str = "show port <port_id> gso",
4395 (void *)&cmd_gso_show_show,
4396 (void *)&cmd_gso_show_port,
4397 (void *)&cmd_gso_show_pid,
4398 (void *)&cmd_gso_show_keyword,
4403 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
4404 struct cmd_set_flush_rx {
4405 cmdline_fixed_string_t set;
4406 cmdline_fixed_string_t flush_rx;
4407 cmdline_fixed_string_t mode;
4411 cmd_set_flush_rx_parsed(void *parsed_result,
4412 __attribute__((unused)) struct cmdline *cl,
4413 __attribute__((unused)) void *data)
4415 struct cmd_set_flush_rx *res = parsed_result;
4416 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
4419 cmdline_parse_token_string_t cmd_setflushrx_set =
4420 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
4422 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
4423 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
4424 flush_rx, "flush_rx");
4425 cmdline_parse_token_string_t cmd_setflushrx_mode =
4426 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
4430 cmdline_parse_inst_t cmd_set_flush_rx = {
4431 .f = cmd_set_flush_rx_parsed,
4432 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
4435 (void *)&cmd_setflushrx_set,
4436 (void *)&cmd_setflushrx_flush_rx,
4437 (void *)&cmd_setflushrx_mode,
4442 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
4443 struct cmd_set_link_check {
4444 cmdline_fixed_string_t set;
4445 cmdline_fixed_string_t link_check;
4446 cmdline_fixed_string_t mode;
4450 cmd_set_link_check_parsed(void *parsed_result,
4451 __attribute__((unused)) struct cmdline *cl,
4452 __attribute__((unused)) void *data)
4454 struct cmd_set_link_check *res = parsed_result;
4455 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
4458 cmdline_parse_token_string_t cmd_setlinkcheck_set =
4459 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
4461 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
4462 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
4463 link_check, "link_check");
4464 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
4465 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
4469 cmdline_parse_inst_t cmd_set_link_check = {
4470 .f = cmd_set_link_check_parsed,
4471 .help_str = "set link_check on|off: Enable/Disable link status check "
4472 "when starting/stopping a port",
4475 (void *)&cmd_setlinkcheck_set,
4476 (void *)&cmd_setlinkcheck_link_check,
4477 (void *)&cmd_setlinkcheck_mode,
4482 /* *** SET NIC BYPASS MODE *** */
4483 struct cmd_set_bypass_mode_result {
4484 cmdline_fixed_string_t set;
4485 cmdline_fixed_string_t bypass;
4486 cmdline_fixed_string_t mode;
4487 cmdline_fixed_string_t value;
4492 cmd_set_bypass_mode_parsed(void *parsed_result,
4493 __attribute__((unused)) struct cmdline *cl,
4494 __attribute__((unused)) void *data)
4496 struct cmd_set_bypass_mode_result *res = parsed_result;
4497 portid_t port_id = res->port_id;
4498 int32_t rc = -EINVAL;
4500 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4501 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4503 if (!strcmp(res->value, "bypass"))
4504 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
4505 else if (!strcmp(res->value, "isolate"))
4506 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
4508 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4510 /* Set the bypass mode for the relevant port. */
4511 rc = rte_pmd_ixgbe_bypass_state_set(port_id, &bypass_mode);
4514 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
4517 cmdline_parse_token_string_t cmd_setbypass_mode_set =
4518 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4520 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
4521 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4523 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
4524 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4526 cmdline_parse_token_string_t cmd_setbypass_mode_value =
4527 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4528 value, "normal#bypass#isolate");
4529 cmdline_parse_token_num_t cmd_setbypass_mode_port =
4530 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
4533 cmdline_parse_inst_t cmd_set_bypass_mode = {
4534 .f = cmd_set_bypass_mode_parsed,
4535 .help_str = "set bypass mode normal|bypass|isolate <port_id>: "
4536 "Set the NIC bypass mode for port_id",
4539 (void *)&cmd_setbypass_mode_set,
4540 (void *)&cmd_setbypass_mode_bypass,
4541 (void *)&cmd_setbypass_mode_mode,
4542 (void *)&cmd_setbypass_mode_value,
4543 (void *)&cmd_setbypass_mode_port,
4548 /* *** SET NIC BYPASS EVENT *** */
4549 struct cmd_set_bypass_event_result {
4550 cmdline_fixed_string_t set;
4551 cmdline_fixed_string_t bypass;
4552 cmdline_fixed_string_t event;
4553 cmdline_fixed_string_t event_value;
4554 cmdline_fixed_string_t mode;
4555 cmdline_fixed_string_t mode_value;
4560 cmd_set_bypass_event_parsed(void *parsed_result,
4561 __attribute__((unused)) struct cmdline *cl,
4562 __attribute__((unused)) void *data)
4564 int32_t rc = -EINVAL;
4565 struct cmd_set_bypass_event_result *res = parsed_result;
4566 portid_t port_id = res->port_id;
4568 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4569 uint32_t bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
4570 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4572 if (!strcmp(res->event_value, "timeout"))
4573 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT;
4574 else if (!strcmp(res->event_value, "os_on"))
4575 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_ON;
4576 else if (!strcmp(res->event_value, "os_off"))
4577 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_OFF;
4578 else if (!strcmp(res->event_value, "power_on"))
4579 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_ON;
4580 else if (!strcmp(res->event_value, "power_off"))
4581 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_OFF;
4583 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
4585 if (!strcmp(res->mode_value, "bypass"))
4586 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
4587 else if (!strcmp(res->mode_value, "isolate"))
4588 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
4590 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4592 /* Set the watchdog timeout. */
4593 if (bypass_event == RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT) {
4596 if (RTE_PMD_IXGBE_BYPASS_TMT_VALID(bypass_timeout)) {
4597 rc = rte_pmd_ixgbe_bypass_wd_timeout_store(port_id,
4601 printf("Failed to set timeout value %u "
4602 "for port %d, errto code: %d.\n",
4603 bypass_timeout, port_id, rc);
4607 /* Set the bypass event to transition to bypass mode. */
4608 rc = rte_pmd_ixgbe_bypass_event_store(port_id, bypass_event,
4613 printf("\t Failed to set bypass event for port = %d.\n",
4617 cmdline_parse_token_string_t cmd_setbypass_event_set =
4618 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4620 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
4621 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4623 cmdline_parse_token_string_t cmd_setbypass_event_event =
4624 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4626 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
4627 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4628 event_value, "none#timeout#os_off#os_on#power_on#power_off");
4629 cmdline_parse_token_string_t cmd_setbypass_event_mode =
4630 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4632 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
4633 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4634 mode_value, "normal#bypass#isolate");
4635 cmdline_parse_token_num_t cmd_setbypass_event_port =
4636 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
4639 cmdline_parse_inst_t cmd_set_bypass_event = {
4640 .f = cmd_set_bypass_event_parsed,
4641 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
4642 "power_off mode normal|bypass|isolate <port_id>: "
4643 "Set the NIC bypass event mode for port_id",
4646 (void *)&cmd_setbypass_event_set,
4647 (void *)&cmd_setbypass_event_bypass,
4648 (void *)&cmd_setbypass_event_event,
4649 (void *)&cmd_setbypass_event_event_value,
4650 (void *)&cmd_setbypass_event_mode,
4651 (void *)&cmd_setbypass_event_mode_value,
4652 (void *)&cmd_setbypass_event_port,
4658 /* *** SET NIC BYPASS TIMEOUT *** */
4659 struct cmd_set_bypass_timeout_result {
4660 cmdline_fixed_string_t set;
4661 cmdline_fixed_string_t bypass;
4662 cmdline_fixed_string_t timeout;
4663 cmdline_fixed_string_t value;
4667 cmd_set_bypass_timeout_parsed(void *parsed_result,
4668 __attribute__((unused)) struct cmdline *cl,
4669 __attribute__((unused)) void *data)
4671 __rte_unused struct cmd_set_bypass_timeout_result *res = parsed_result;
4673 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4674 if (!strcmp(res->value, "1.5"))
4675 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_1_5_SEC;
4676 else if (!strcmp(res->value, "2"))
4677 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_2_SEC;
4678 else if (!strcmp(res->value, "3"))
4679 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_3_SEC;
4680 else if (!strcmp(res->value, "4"))
4681 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_4_SEC;
4682 else if (!strcmp(res->value, "8"))
4683 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_8_SEC;
4684 else if (!strcmp(res->value, "16"))
4685 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_16_SEC;
4686 else if (!strcmp(res->value, "32"))
4687 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_32_SEC;
4689 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
4693 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
4694 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4696 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
4697 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4699 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
4700 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4701 timeout, "timeout");
4702 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
4703 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4704 value, "0#1.5#2#3#4#8#16#32");
4706 cmdline_parse_inst_t cmd_set_bypass_timeout = {
4707 .f = cmd_set_bypass_timeout_parsed,
4708 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
4709 "Set the NIC bypass watchdog timeout in seconds",
4712 (void *)&cmd_setbypass_timeout_set,
4713 (void *)&cmd_setbypass_timeout_bypass,
4714 (void *)&cmd_setbypass_timeout_timeout,
4715 (void *)&cmd_setbypass_timeout_value,
4720 /* *** SHOW NIC BYPASS MODE *** */
4721 struct cmd_show_bypass_config_result {
4722 cmdline_fixed_string_t show;
4723 cmdline_fixed_string_t bypass;
4724 cmdline_fixed_string_t config;
4729 cmd_show_bypass_config_parsed(void *parsed_result,
4730 __attribute__((unused)) struct cmdline *cl,
4731 __attribute__((unused)) void *data)
4733 struct cmd_show_bypass_config_result *res = parsed_result;
4734 portid_t port_id = res->port_id;
4736 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4737 uint32_t event_mode;
4738 uint32_t bypass_mode;
4739 uint32_t timeout = bypass_timeout;
4742 static const char * const timeouts[RTE_PMD_IXGBE_BYPASS_TMT_NUM] =
4743 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
4744 static const char * const modes[RTE_PMD_IXGBE_BYPASS_MODE_NUM] =
4745 {"UNKNOWN", "normal", "bypass", "isolate"};
4746 static const char * const events[RTE_PMD_IXGBE_BYPASS_EVENT_NUM] = {
4753 int num_events = (sizeof events) / (sizeof events[0]);
4755 /* Display the bypass mode.*/
4756 if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) != 0) {
4757 printf("\tFailed to get bypass mode for port = %d\n", port_id);
4761 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(bypass_mode))
4762 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
4764 printf("\tbypass mode = %s\n", modes[bypass_mode]);
4767 /* Display the bypass timeout.*/
4768 if (!RTE_PMD_IXGBE_BYPASS_TMT_VALID(timeout))
4769 timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
4771 printf("\tbypass timeout = %s\n", timeouts[timeout]);
4773 /* Display the bypass events and associated modes. */
4774 for (i = RTE_PMD_IXGBE_BYPASS_EVENT_START; i < num_events; i++) {
4776 if (rte_pmd_ixgbe_bypass_event_show(port_id, i, &event_mode)) {
4777 printf("\tFailed to get bypass mode for event = %s\n",
4780 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(event_mode))
4781 event_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
4783 printf("\tbypass event: %-16s = %s\n", events[i],
4789 printf("\tFailed to get bypass configuration for port = %d\n",
4793 cmdline_parse_token_string_t cmd_showbypass_config_show =
4794 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4796 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
4797 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4799 cmdline_parse_token_string_t cmd_showbypass_config_config =
4800 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4802 cmdline_parse_token_num_t cmd_showbypass_config_port =
4803 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
4806 cmdline_parse_inst_t cmd_show_bypass_config = {
4807 .f = cmd_show_bypass_config_parsed,
4808 .help_str = "show bypass config <port_id>: "
4809 "Show the NIC bypass config for port_id",
4812 (void *)&cmd_showbypass_config_show,
4813 (void *)&cmd_showbypass_config_bypass,
4814 (void *)&cmd_showbypass_config_config,
4815 (void *)&cmd_showbypass_config_port,
4820 #ifdef RTE_LIBRTE_PMD_BOND
4821 /* *** SET BONDING MODE *** */
4822 struct cmd_set_bonding_mode_result {
4823 cmdline_fixed_string_t set;
4824 cmdline_fixed_string_t bonding;
4825 cmdline_fixed_string_t mode;
4830 static void cmd_set_bonding_mode_parsed(void *parsed_result,
4831 __attribute__((unused)) struct cmdline *cl,
4832 __attribute__((unused)) void *data)
4834 struct cmd_set_bonding_mode_result *res = parsed_result;
4835 portid_t port_id = res->port_id;
4837 /* Set the bonding mode for the relevant port. */
4838 if (0 != rte_eth_bond_mode_set(port_id, res->value))
4839 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
4842 cmdline_parse_token_string_t cmd_setbonding_mode_set =
4843 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4845 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
4846 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4847 bonding, "bonding");
4848 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
4849 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4851 cmdline_parse_token_num_t cmd_setbonding_mode_value =
4852 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
4854 cmdline_parse_token_num_t cmd_setbonding_mode_port =
4855 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
4858 cmdline_parse_inst_t cmd_set_bonding_mode = {
4859 .f = cmd_set_bonding_mode_parsed,
4860 .help_str = "set bonding mode <mode_value> <port_id>: "
4861 "Set the bonding mode for port_id",
4864 (void *) &cmd_setbonding_mode_set,
4865 (void *) &cmd_setbonding_mode_bonding,
4866 (void *) &cmd_setbonding_mode_mode,
4867 (void *) &cmd_setbonding_mode_value,
4868 (void *) &cmd_setbonding_mode_port,
4873 /* *** SET BONDING SLOW_QUEUE SW/HW *** */
4874 struct cmd_set_bonding_lacp_dedicated_queues_result {
4875 cmdline_fixed_string_t set;
4876 cmdline_fixed_string_t bonding;
4877 cmdline_fixed_string_t lacp;
4878 cmdline_fixed_string_t dedicated_queues;
4880 cmdline_fixed_string_t mode;
4883 static void cmd_set_bonding_lacp_dedicated_queues_parsed(void *parsed_result,
4884 __attribute__((unused)) struct cmdline *cl,
4885 __attribute__((unused)) void *data)
4887 struct cmd_set_bonding_lacp_dedicated_queues_result *res = parsed_result;
4888 portid_t port_id = res->port_id;
4889 struct rte_port *port;
4891 port = &ports[port_id];
4893 /** Check if the port is not started **/
4894 if (port->port_status != RTE_PORT_STOPPED) {
4895 printf("Please stop port %d first\n", port_id);
4899 if (!strcmp(res->mode, "enable")) {
4900 if (rte_eth_bond_8023ad_dedicated_queues_enable(port_id) == 0)
4901 printf("Dedicate queues for LACP control packets"
4904 printf("Enabling dedicate queues for LACP control "
4905 "packets on port %d failed\n", port_id);
4906 } else if (!strcmp(res->mode, "disable")) {
4907 if (rte_eth_bond_8023ad_dedicated_queues_disable(port_id) == 0)
4908 printf("Dedicated queues for LACP control packets "
4911 printf("Disabling dedicated queues for LACP control "
4912 "traffic on port %d failed\n", port_id);
4916 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_set =
4917 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4919 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_bonding =
4920 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4921 bonding, "bonding");
4922 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_lacp =
4923 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4925 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_dedicated_queues =
4926 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4927 dedicated_queues, "dedicated_queues");
4928 cmdline_parse_token_num_t cmd_setbonding_lacp_dedicated_queues_port_id =
4929 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4931 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_mode =
4932 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4933 mode, "enable#disable");
4935 cmdline_parse_inst_t cmd_set_lacp_dedicated_queues = {
4936 .f = cmd_set_bonding_lacp_dedicated_queues_parsed,
4937 .help_str = "set bonding lacp dedicated_queues <port_id> "
4939 "Enable/disable dedicated queues for LACP control traffic for port_id",
4942 (void *)&cmd_setbonding_lacp_dedicated_queues_set,
4943 (void *)&cmd_setbonding_lacp_dedicated_queues_bonding,
4944 (void *)&cmd_setbonding_lacp_dedicated_queues_lacp,
4945 (void *)&cmd_setbonding_lacp_dedicated_queues_dedicated_queues,
4946 (void *)&cmd_setbonding_lacp_dedicated_queues_port_id,
4947 (void *)&cmd_setbonding_lacp_dedicated_queues_mode,
4952 /* *** SET BALANCE XMIT POLICY *** */
4953 struct cmd_set_bonding_balance_xmit_policy_result {
4954 cmdline_fixed_string_t set;
4955 cmdline_fixed_string_t bonding;
4956 cmdline_fixed_string_t balance_xmit_policy;
4958 cmdline_fixed_string_t policy;
4961 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
4962 __attribute__((unused)) struct cmdline *cl,
4963 __attribute__((unused)) void *data)
4965 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
4966 portid_t port_id = res->port_id;
4969 if (!strcmp(res->policy, "l2")) {
4970 policy = BALANCE_XMIT_POLICY_LAYER2;
4971 } else if (!strcmp(res->policy, "l23")) {
4972 policy = BALANCE_XMIT_POLICY_LAYER23;
4973 } else if (!strcmp(res->policy, "l34")) {
4974 policy = BALANCE_XMIT_POLICY_LAYER34;
4976 printf("\t Invalid xmit policy selection");
4980 /* Set the bonding mode for the relevant port. */
4981 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
4982 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
4987 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
4988 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4990 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
4991 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4992 bonding, "bonding");
4993 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
4994 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4995 balance_xmit_policy, "balance_xmit_policy");
4996 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
4997 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4999 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
5000 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5001 policy, "l2#l23#l34");
5003 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
5004 .f = cmd_set_bonding_balance_xmit_policy_parsed,
5005 .help_str = "set bonding balance_xmit_policy <port_id> "
5007 "Set the bonding balance_xmit_policy for port_id",
5010 (void *)&cmd_setbonding_balance_xmit_policy_set,
5011 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
5012 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
5013 (void *)&cmd_setbonding_balance_xmit_policy_port,
5014 (void *)&cmd_setbonding_balance_xmit_policy_policy,
5019 /* *** SHOW NIC BONDING CONFIGURATION *** */
5020 struct cmd_show_bonding_config_result {
5021 cmdline_fixed_string_t show;
5022 cmdline_fixed_string_t bonding;
5023 cmdline_fixed_string_t config;
5027 static void cmd_show_bonding_config_parsed(void *parsed_result,
5028 __attribute__((unused)) struct cmdline *cl,
5029 __attribute__((unused)) void *data)
5031 struct cmd_show_bonding_config_result *res = parsed_result;
5032 int bonding_mode, agg_mode;
5033 portid_t slaves[RTE_MAX_ETHPORTS];
5034 int num_slaves, num_active_slaves;
5037 portid_t port_id = res->port_id;
5039 /* Display the bonding mode.*/
5040 bonding_mode = rte_eth_bond_mode_get(port_id);
5041 if (bonding_mode < 0) {
5042 printf("\tFailed to get bonding mode for port = %d\n", port_id);
5045 printf("\tBonding mode: %d\n", bonding_mode);
5047 if (bonding_mode == BONDING_MODE_BALANCE) {
5048 int balance_xmit_policy;
5050 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
5051 if (balance_xmit_policy < 0) {
5052 printf("\tFailed to get balance xmit policy for port = %d\n",
5056 printf("\tBalance Xmit Policy: ");
5058 switch (balance_xmit_policy) {
5059 case BALANCE_XMIT_POLICY_LAYER2:
5060 printf("BALANCE_XMIT_POLICY_LAYER2");
5062 case BALANCE_XMIT_POLICY_LAYER23:
5063 printf("BALANCE_XMIT_POLICY_LAYER23");
5065 case BALANCE_XMIT_POLICY_LAYER34:
5066 printf("BALANCE_XMIT_POLICY_LAYER34");
5073 if (bonding_mode == BONDING_MODE_8023AD) {
5074 agg_mode = rte_eth_bond_8023ad_agg_selection_get(port_id);
5075 printf("\tIEEE802.3AD Aggregator Mode: ");
5078 printf("bandwidth");
5090 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
5092 if (num_slaves < 0) {
5093 printf("\tFailed to get slave list for port = %d\n", port_id);
5096 if (num_slaves > 0) {
5097 printf("\tSlaves (%d): [", num_slaves);
5098 for (i = 0; i < num_slaves - 1; i++)
5099 printf("%d ", slaves[i]);
5101 printf("%d]\n", slaves[num_slaves - 1]);
5103 printf("\tSlaves: []\n");
5107 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
5110 if (num_active_slaves < 0) {
5111 printf("\tFailed to get active slave list for port = %d\n", port_id);
5114 if (num_active_slaves > 0) {
5115 printf("\tActive Slaves (%d): [", num_active_slaves);
5116 for (i = 0; i < num_active_slaves - 1; i++)
5117 printf("%d ", slaves[i]);
5119 printf("%d]\n", slaves[num_active_slaves - 1]);
5122 printf("\tActive Slaves: []\n");
5126 primary_id = rte_eth_bond_primary_get(port_id);
5127 if (primary_id < 0) {
5128 printf("\tFailed to get primary slave for port = %d\n", port_id);
5131 printf("\tPrimary: [%d]\n", primary_id);
5135 cmdline_parse_token_string_t cmd_showbonding_config_show =
5136 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5138 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
5139 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5140 bonding, "bonding");
5141 cmdline_parse_token_string_t cmd_showbonding_config_config =
5142 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5144 cmdline_parse_token_num_t cmd_showbonding_config_port =
5145 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
5148 cmdline_parse_inst_t cmd_show_bonding_config = {
5149 .f = cmd_show_bonding_config_parsed,
5150 .help_str = "show bonding config <port_id>: "
5151 "Show the bonding config for port_id",
5154 (void *)&cmd_showbonding_config_show,
5155 (void *)&cmd_showbonding_config_bonding,
5156 (void *)&cmd_showbonding_config_config,
5157 (void *)&cmd_showbonding_config_port,
5162 /* *** SET BONDING PRIMARY *** */
5163 struct cmd_set_bonding_primary_result {
5164 cmdline_fixed_string_t set;
5165 cmdline_fixed_string_t bonding;
5166 cmdline_fixed_string_t primary;
5171 static void cmd_set_bonding_primary_parsed(void *parsed_result,
5172 __attribute__((unused)) struct cmdline *cl,
5173 __attribute__((unused)) void *data)
5175 struct cmd_set_bonding_primary_result *res = parsed_result;
5176 portid_t master_port_id = res->port_id;
5177 portid_t slave_port_id = res->slave_id;
5179 /* Set the primary slave for a bonded device. */
5180 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
5181 printf("\t Failed to set primary slave for port = %d.\n",
5188 cmdline_parse_token_string_t cmd_setbonding_primary_set =
5189 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5191 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
5192 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5193 bonding, "bonding");
5194 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
5195 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5196 primary, "primary");
5197 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
5198 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
5200 cmdline_parse_token_num_t cmd_setbonding_primary_port =
5201 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
5204 cmdline_parse_inst_t cmd_set_bonding_primary = {
5205 .f = cmd_set_bonding_primary_parsed,
5206 .help_str = "set bonding primary <slave_id> <port_id>: "
5207 "Set the primary slave for port_id",
5210 (void *)&cmd_setbonding_primary_set,
5211 (void *)&cmd_setbonding_primary_bonding,
5212 (void *)&cmd_setbonding_primary_primary,
5213 (void *)&cmd_setbonding_primary_slave,
5214 (void *)&cmd_setbonding_primary_port,
5219 /* *** ADD SLAVE *** */
5220 struct cmd_add_bonding_slave_result {
5221 cmdline_fixed_string_t add;
5222 cmdline_fixed_string_t bonding;
5223 cmdline_fixed_string_t slave;
5228 static void cmd_add_bonding_slave_parsed(void *parsed_result,
5229 __attribute__((unused)) struct cmdline *cl,
5230 __attribute__((unused)) void *data)
5232 struct cmd_add_bonding_slave_result *res = parsed_result;
5233 portid_t master_port_id = res->port_id;
5234 portid_t slave_port_id = res->slave_id;
5236 /* add the slave for a bonded device. */
5237 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
5238 printf("\t Failed to add slave %d to master port = %d.\n",
5239 slave_port_id, master_port_id);
5243 set_port_slave_flag(slave_port_id);
5246 cmdline_parse_token_string_t cmd_addbonding_slave_add =
5247 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5249 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
5250 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5251 bonding, "bonding");
5252 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
5253 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5255 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
5256 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
5258 cmdline_parse_token_num_t cmd_addbonding_slave_port =
5259 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
5262 cmdline_parse_inst_t cmd_add_bonding_slave = {
5263 .f = cmd_add_bonding_slave_parsed,
5264 .help_str = "add bonding slave <slave_id> <port_id>: "
5265 "Add a slave device to a bonded device",
5268 (void *)&cmd_addbonding_slave_add,
5269 (void *)&cmd_addbonding_slave_bonding,
5270 (void *)&cmd_addbonding_slave_slave,
5271 (void *)&cmd_addbonding_slave_slaveid,
5272 (void *)&cmd_addbonding_slave_port,
5277 /* *** REMOVE SLAVE *** */
5278 struct cmd_remove_bonding_slave_result {
5279 cmdline_fixed_string_t remove;
5280 cmdline_fixed_string_t bonding;
5281 cmdline_fixed_string_t slave;
5286 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
5287 __attribute__((unused)) struct cmdline *cl,
5288 __attribute__((unused)) void *data)
5290 struct cmd_remove_bonding_slave_result *res = parsed_result;
5291 portid_t master_port_id = res->port_id;
5292 portid_t slave_port_id = res->slave_id;
5294 /* remove the slave from a bonded device. */
5295 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
5296 printf("\t Failed to remove slave %d from master port = %d.\n",
5297 slave_port_id, master_port_id);
5301 clear_port_slave_flag(slave_port_id);
5304 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
5305 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
5307 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
5308 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
5309 bonding, "bonding");
5310 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
5311 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
5313 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
5314 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
5316 cmdline_parse_token_num_t cmd_removebonding_slave_port =
5317 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
5320 cmdline_parse_inst_t cmd_remove_bonding_slave = {
5321 .f = cmd_remove_bonding_slave_parsed,
5322 .help_str = "remove bonding slave <slave_id> <port_id>: "
5323 "Remove a slave device from a bonded device",
5326 (void *)&cmd_removebonding_slave_remove,
5327 (void *)&cmd_removebonding_slave_bonding,
5328 (void *)&cmd_removebonding_slave_slave,
5329 (void *)&cmd_removebonding_slave_slaveid,
5330 (void *)&cmd_removebonding_slave_port,
5335 /* *** CREATE BONDED DEVICE *** */
5336 struct cmd_create_bonded_device_result {
5337 cmdline_fixed_string_t create;
5338 cmdline_fixed_string_t bonded;
5339 cmdline_fixed_string_t device;
5344 static int bond_dev_num = 0;
5346 static void cmd_create_bonded_device_parsed(void *parsed_result,
5347 __attribute__((unused)) struct cmdline *cl,
5348 __attribute__((unused)) void *data)
5350 struct cmd_create_bonded_device_result *res = parsed_result;
5351 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
5354 if (test_done == 0) {
5355 printf("Please stop forwarding first\n");
5359 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bonding_testpmd_%d",
5362 /* Create a new bonded device. */
5363 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
5365 printf("\t Failed to create bonded device.\n");
5368 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
5371 /* Update number of ports */
5372 nb_ports = rte_eth_dev_count();
5373 reconfig(port_id, res->socket);
5374 rte_eth_promiscuous_enable(port_id);
5379 cmdline_parse_token_string_t cmd_createbonded_device_create =
5380 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
5382 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
5383 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
5385 cmdline_parse_token_string_t cmd_createbonded_device_device =
5386 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
5388 cmdline_parse_token_num_t cmd_createbonded_device_mode =
5389 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
5391 cmdline_parse_token_num_t cmd_createbonded_device_socket =
5392 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
5395 cmdline_parse_inst_t cmd_create_bonded_device = {
5396 .f = cmd_create_bonded_device_parsed,
5397 .help_str = "create bonded device <mode> <socket>: "
5398 "Create a new bonded device with specific bonding mode and socket",
5401 (void *)&cmd_createbonded_device_create,
5402 (void *)&cmd_createbonded_device_bonded,
5403 (void *)&cmd_createbonded_device_device,
5404 (void *)&cmd_createbonded_device_mode,
5405 (void *)&cmd_createbonded_device_socket,
5410 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
5411 struct cmd_set_bond_mac_addr_result {
5412 cmdline_fixed_string_t set;
5413 cmdline_fixed_string_t bonding;
5414 cmdline_fixed_string_t mac_addr;
5416 struct ether_addr address;
5419 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
5420 __attribute__((unused)) struct cmdline *cl,
5421 __attribute__((unused)) void *data)
5423 struct cmd_set_bond_mac_addr_result *res = parsed_result;
5426 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
5429 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
5431 /* check the return value and print it if is < 0 */
5433 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
5436 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
5437 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
5438 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
5439 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
5441 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
5442 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
5444 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
5445 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result,
5447 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
5448 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
5450 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
5451 .f = cmd_set_bond_mac_addr_parsed,
5453 .help_str = "set bonding mac_addr <port_id> <mac_addr>",
5455 (void *)&cmd_set_bond_mac_addr_set,
5456 (void *)&cmd_set_bond_mac_addr_bonding,
5457 (void *)&cmd_set_bond_mac_addr_mac,
5458 (void *)&cmd_set_bond_mac_addr_portnum,
5459 (void *)&cmd_set_bond_mac_addr_addr,
5465 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
5466 struct cmd_set_bond_mon_period_result {
5467 cmdline_fixed_string_t set;
5468 cmdline_fixed_string_t bonding;
5469 cmdline_fixed_string_t mon_period;
5474 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
5475 __attribute__((unused)) struct cmdline *cl,
5476 __attribute__((unused)) void *data)
5478 struct cmd_set_bond_mon_period_result *res = parsed_result;
5481 if (res->port_num >= nb_ports) {
5482 printf("Port id %d must be less than %d\n", res->port_num, nb_ports);
5486 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
5488 /* check the return value and print it if is < 0 */
5490 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
5493 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
5494 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
5496 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
5497 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
5498 bonding, "bonding");
5499 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
5500 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
5501 mon_period, "mon_period");
5502 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
5503 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
5505 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
5506 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
5509 cmdline_parse_inst_t cmd_set_bond_mon_period = {
5510 .f = cmd_set_bond_mon_period_parsed,
5512 .help_str = "set bonding mon_period <port_id> <period_ms>",
5514 (void *)&cmd_set_bond_mon_period_set,
5515 (void *)&cmd_set_bond_mon_period_bonding,
5516 (void *)&cmd_set_bond_mon_period_mon_period,
5517 (void *)&cmd_set_bond_mon_period_portnum,
5518 (void *)&cmd_set_bond_mon_period_period_ms,
5525 struct cmd_set_bonding_agg_mode_policy_result {
5526 cmdline_fixed_string_t set;
5527 cmdline_fixed_string_t bonding;
5528 cmdline_fixed_string_t agg_mode;
5530 cmdline_fixed_string_t policy;
5535 cmd_set_bonding_agg_mode(void *parsed_result,
5536 __attribute__((unused)) struct cmdline *cl,
5537 __attribute__((unused)) void *data)
5539 struct cmd_set_bonding_agg_mode_policy_result *res = parsed_result;
5540 uint8_t policy = AGG_BANDWIDTH;
5542 if (res->port_num >= nb_ports) {
5543 printf("Port id %d must be less than %d\n",
5544 res->port_num, nb_ports);
5548 if (!strcmp(res->policy, "bandwidth"))
5549 policy = AGG_BANDWIDTH;
5550 else if (!strcmp(res->policy, "stable"))
5551 policy = AGG_STABLE;
5552 else if (!strcmp(res->policy, "count"))
5555 rte_eth_bond_8023ad_agg_selection_set(res->port_num, policy);
5559 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_set =
5560 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5562 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_bonding =
5563 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5564 bonding, "bonding");
5566 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_agg_mode =
5567 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5568 agg_mode, "agg_mode");
5570 cmdline_parse_token_num_t cmd_set_bonding_agg_mode_portnum =
5571 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5574 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_policy_string =
5575 TOKEN_STRING_INITIALIZER(
5576 struct cmd_set_bonding_balance_xmit_policy_result,
5577 policy, "stable#bandwidth#count");
5579 cmdline_parse_inst_t cmd_set_bonding_agg_mode_policy = {
5580 .f = cmd_set_bonding_agg_mode,
5582 .help_str = "set bonding mode IEEE802.3AD aggregator policy <port_id> <agg_name>",
5584 (void *)&cmd_set_bonding_agg_mode_set,
5585 (void *)&cmd_set_bonding_agg_mode_bonding,
5586 (void *)&cmd_set_bonding_agg_mode_agg_mode,
5587 (void *)&cmd_set_bonding_agg_mode_portnum,
5588 (void *)&cmd_set_bonding_agg_mode_policy_string,
5594 #endif /* RTE_LIBRTE_PMD_BOND */
5596 /* *** SET FORWARDING MODE *** */
5597 struct cmd_set_fwd_mode_result {
5598 cmdline_fixed_string_t set;
5599 cmdline_fixed_string_t fwd;
5600 cmdline_fixed_string_t mode;
5603 static void cmd_set_fwd_mode_parsed(void *parsed_result,
5604 __attribute__((unused)) struct cmdline *cl,
5605 __attribute__((unused)) void *data)
5607 struct cmd_set_fwd_mode_result *res = parsed_result;
5610 set_pkt_forwarding_mode(res->mode);
5613 cmdline_parse_token_string_t cmd_setfwd_set =
5614 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
5615 cmdline_parse_token_string_t cmd_setfwd_fwd =
5616 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
5617 cmdline_parse_token_string_t cmd_setfwd_mode =
5618 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
5619 "" /* defined at init */);
5621 cmdline_parse_inst_t cmd_set_fwd_mode = {
5622 .f = cmd_set_fwd_mode_parsed,
5624 .help_str = NULL, /* defined at init */
5626 (void *)&cmd_setfwd_set,
5627 (void *)&cmd_setfwd_fwd,
5628 (void *)&cmd_setfwd_mode,
5633 static void cmd_set_fwd_mode_init(void)
5636 static char token[128];
5637 static char help[256];
5638 cmdline_parse_token_string_t *token_struct;
5640 modes = list_pkt_forwarding_modes();
5641 snprintf(help, sizeof(help), "set fwd %s: "
5642 "Set packet forwarding mode", modes);
5643 cmd_set_fwd_mode.help_str = help;
5645 /* string token separator is # */
5646 for (c = token; *modes != '\0'; modes++)
5651 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
5652 token_struct->string_data.str = token;
5655 /* *** SET RETRY FORWARDING MODE *** */
5656 struct cmd_set_fwd_retry_mode_result {
5657 cmdline_fixed_string_t set;
5658 cmdline_fixed_string_t fwd;
5659 cmdline_fixed_string_t mode;
5660 cmdline_fixed_string_t retry;
5663 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
5664 __attribute__((unused)) struct cmdline *cl,
5665 __attribute__((unused)) void *data)
5667 struct cmd_set_fwd_retry_mode_result *res = parsed_result;
5670 set_pkt_forwarding_mode(res->mode);
5673 cmdline_parse_token_string_t cmd_setfwd_retry_set =
5674 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
5676 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
5677 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
5679 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
5680 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
5682 "" /* defined at init */);
5683 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
5684 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
5687 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
5688 .f = cmd_set_fwd_retry_mode_parsed,
5690 .help_str = NULL, /* defined at init */
5692 (void *)&cmd_setfwd_retry_set,
5693 (void *)&cmd_setfwd_retry_fwd,
5694 (void *)&cmd_setfwd_retry_mode,
5695 (void *)&cmd_setfwd_retry_retry,
5700 static void cmd_set_fwd_retry_mode_init(void)
5703 static char token[128];
5704 static char help[256];
5705 cmdline_parse_token_string_t *token_struct;
5707 modes = list_pkt_forwarding_retry_modes();
5708 snprintf(help, sizeof(help), "set fwd %s retry: "
5709 "Set packet forwarding mode with retry", modes);
5710 cmd_set_fwd_retry_mode.help_str = help;
5712 /* string token separator is # */
5713 for (c = token; *modes != '\0'; modes++)
5718 token_struct = (cmdline_parse_token_string_t *)
5719 cmd_set_fwd_retry_mode.tokens[2];
5720 token_struct->string_data.str = token;
5723 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
5724 struct cmd_set_burst_tx_retry_result {
5725 cmdline_fixed_string_t set;
5726 cmdline_fixed_string_t burst;
5727 cmdline_fixed_string_t tx;
5728 cmdline_fixed_string_t delay;
5730 cmdline_fixed_string_t retry;
5734 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
5735 __attribute__((unused)) struct cmdline *cl,
5736 __attribute__((unused)) void *data)
5738 struct cmd_set_burst_tx_retry_result *res = parsed_result;
5740 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
5741 && !strcmp(res->tx, "tx")) {
5742 if (!strcmp(res->delay, "delay"))
5743 burst_tx_delay_time = res->time;
5744 if (!strcmp(res->retry, "retry"))
5745 burst_tx_retry_num = res->retry_num;
5750 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
5751 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
5752 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
5753 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
5755 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
5756 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
5757 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
5758 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
5759 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
5760 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
5761 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
5762 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
5763 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
5764 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
5766 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
5767 .f = cmd_set_burst_tx_retry_parsed,
5768 .help_str = "set burst tx delay <delay_usec> retry <num_retry>",
5770 (void *)&cmd_set_burst_tx_retry_set,
5771 (void *)&cmd_set_burst_tx_retry_burst,
5772 (void *)&cmd_set_burst_tx_retry_tx,
5773 (void *)&cmd_set_burst_tx_retry_delay,
5774 (void *)&cmd_set_burst_tx_retry_time,
5775 (void *)&cmd_set_burst_tx_retry_retry,
5776 (void *)&cmd_set_burst_tx_retry_retry_num,
5781 /* *** SET PROMISC MODE *** */
5782 struct cmd_set_promisc_mode_result {
5783 cmdline_fixed_string_t set;
5784 cmdline_fixed_string_t promisc;
5785 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
5786 uint16_t port_num; /* valid if "allports" argument == 0 */
5787 cmdline_fixed_string_t mode;
5790 static void cmd_set_promisc_mode_parsed(void *parsed_result,
5791 __attribute__((unused)) struct cmdline *cl,
5794 struct cmd_set_promisc_mode_result *res = parsed_result;
5798 if (!strcmp(res->mode, "on"))
5805 RTE_ETH_FOREACH_DEV(i) {
5807 rte_eth_promiscuous_enable(i);
5809 rte_eth_promiscuous_disable(i);
5814 rte_eth_promiscuous_enable(res->port_num);
5816 rte_eth_promiscuous_disable(res->port_num);
5820 cmdline_parse_token_string_t cmd_setpromisc_set =
5821 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
5822 cmdline_parse_token_string_t cmd_setpromisc_promisc =
5823 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
5825 cmdline_parse_token_string_t cmd_setpromisc_portall =
5826 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
5828 cmdline_parse_token_num_t cmd_setpromisc_portnum =
5829 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
5831 cmdline_parse_token_string_t cmd_setpromisc_mode =
5832 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
5835 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
5836 .f = cmd_set_promisc_mode_parsed,
5838 .help_str = "set promisc all on|off: Set promisc mode for all ports",
5840 (void *)&cmd_setpromisc_set,
5841 (void *)&cmd_setpromisc_promisc,
5842 (void *)&cmd_setpromisc_portall,
5843 (void *)&cmd_setpromisc_mode,
5848 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
5849 .f = cmd_set_promisc_mode_parsed,
5851 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
5853 (void *)&cmd_setpromisc_set,
5854 (void *)&cmd_setpromisc_promisc,
5855 (void *)&cmd_setpromisc_portnum,
5856 (void *)&cmd_setpromisc_mode,
5861 /* *** SET ALLMULTI MODE *** */
5862 struct cmd_set_allmulti_mode_result {
5863 cmdline_fixed_string_t set;
5864 cmdline_fixed_string_t allmulti;
5865 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
5866 uint16_t port_num; /* valid if "allports" argument == 0 */
5867 cmdline_fixed_string_t mode;
5870 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
5871 __attribute__((unused)) struct cmdline *cl,
5874 struct cmd_set_allmulti_mode_result *res = parsed_result;
5878 if (!strcmp(res->mode, "on"))
5885 RTE_ETH_FOREACH_DEV(i) {
5887 rte_eth_allmulticast_enable(i);
5889 rte_eth_allmulticast_disable(i);
5894 rte_eth_allmulticast_enable(res->port_num);
5896 rte_eth_allmulticast_disable(res->port_num);
5900 cmdline_parse_token_string_t cmd_setallmulti_set =
5901 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
5902 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
5903 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
5905 cmdline_parse_token_string_t cmd_setallmulti_portall =
5906 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
5908 cmdline_parse_token_num_t cmd_setallmulti_portnum =
5909 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
5911 cmdline_parse_token_string_t cmd_setallmulti_mode =
5912 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
5915 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
5916 .f = cmd_set_allmulti_mode_parsed,
5918 .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
5920 (void *)&cmd_setallmulti_set,
5921 (void *)&cmd_setallmulti_allmulti,
5922 (void *)&cmd_setallmulti_portall,
5923 (void *)&cmd_setallmulti_mode,
5928 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
5929 .f = cmd_set_allmulti_mode_parsed,
5931 .help_str = "set allmulti <port_id> on|off: "
5932 "Set allmulti mode on port_id",
5934 (void *)&cmd_setallmulti_set,
5935 (void *)&cmd_setallmulti_allmulti,
5936 (void *)&cmd_setallmulti_portnum,
5937 (void *)&cmd_setallmulti_mode,
5942 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
5943 struct cmd_link_flow_ctrl_set_result {
5944 cmdline_fixed_string_t set;
5945 cmdline_fixed_string_t flow_ctrl;
5946 cmdline_fixed_string_t rx;
5947 cmdline_fixed_string_t rx_lfc_mode;
5948 cmdline_fixed_string_t tx;
5949 cmdline_fixed_string_t tx_lfc_mode;
5950 cmdline_fixed_string_t mac_ctrl_frame_fwd;
5951 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
5952 cmdline_fixed_string_t autoneg_str;
5953 cmdline_fixed_string_t autoneg;
5954 cmdline_fixed_string_t hw_str;
5955 uint32_t high_water;
5956 cmdline_fixed_string_t lw_str;
5958 cmdline_fixed_string_t pt_str;
5959 uint16_t pause_time;
5960 cmdline_fixed_string_t xon_str;
5965 cmdline_parse_token_string_t cmd_lfc_set_set =
5966 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5968 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
5969 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5970 flow_ctrl, "flow_ctrl");
5971 cmdline_parse_token_string_t cmd_lfc_set_rx =
5972 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5974 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
5975 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5976 rx_lfc_mode, "on#off");
5977 cmdline_parse_token_string_t cmd_lfc_set_tx =
5978 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5980 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
5981 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5982 tx_lfc_mode, "on#off");
5983 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
5984 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5985 hw_str, "high_water");
5986 cmdline_parse_token_num_t cmd_lfc_set_high_water =
5987 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5988 high_water, UINT32);
5989 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
5990 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5991 lw_str, "low_water");
5992 cmdline_parse_token_num_t cmd_lfc_set_low_water =
5993 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5995 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
5996 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5997 pt_str, "pause_time");
5998 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
5999 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6000 pause_time, UINT16);
6001 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
6002 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6003 xon_str, "send_xon");
6004 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
6005 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6007 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
6008 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6009 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
6010 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
6011 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6012 mac_ctrl_frame_fwd_mode, "on#off");
6013 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
6014 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6015 autoneg_str, "autoneg");
6016 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
6017 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6019 cmdline_parse_token_num_t cmd_lfc_set_portid =
6020 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6023 /* forward declaration */
6025 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
6028 cmdline_parse_inst_t cmd_link_flow_control_set = {
6029 .f = cmd_link_flow_ctrl_set_parsed,
6031 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
6032 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
6033 "autoneg on|off <port_id>: Configure the Ethernet flow control",
6035 (void *)&cmd_lfc_set_set,
6036 (void *)&cmd_lfc_set_flow_ctrl,
6037 (void *)&cmd_lfc_set_rx,
6038 (void *)&cmd_lfc_set_rx_mode,
6039 (void *)&cmd_lfc_set_tx,
6040 (void *)&cmd_lfc_set_tx_mode,
6041 (void *)&cmd_lfc_set_high_water,
6042 (void *)&cmd_lfc_set_low_water,
6043 (void *)&cmd_lfc_set_pause_time,
6044 (void *)&cmd_lfc_set_send_xon,
6045 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6046 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6047 (void *)&cmd_lfc_set_autoneg_str,
6048 (void *)&cmd_lfc_set_autoneg,
6049 (void *)&cmd_lfc_set_portid,
6054 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
6055 .f = cmd_link_flow_ctrl_set_parsed,
6056 .data = (void *)&cmd_link_flow_control_set_rx,
6057 .help_str = "set flow_ctrl rx on|off <port_id>: "
6058 "Change rx flow control parameter",
6060 (void *)&cmd_lfc_set_set,
6061 (void *)&cmd_lfc_set_flow_ctrl,
6062 (void *)&cmd_lfc_set_rx,
6063 (void *)&cmd_lfc_set_rx_mode,
6064 (void *)&cmd_lfc_set_portid,
6069 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
6070 .f = cmd_link_flow_ctrl_set_parsed,
6071 .data = (void *)&cmd_link_flow_control_set_tx,
6072 .help_str = "set flow_ctrl tx on|off <port_id>: "
6073 "Change tx flow control parameter",
6075 (void *)&cmd_lfc_set_set,
6076 (void *)&cmd_lfc_set_flow_ctrl,
6077 (void *)&cmd_lfc_set_tx,
6078 (void *)&cmd_lfc_set_tx_mode,
6079 (void *)&cmd_lfc_set_portid,
6084 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
6085 .f = cmd_link_flow_ctrl_set_parsed,
6086 .data = (void *)&cmd_link_flow_control_set_hw,
6087 .help_str = "set flow_ctrl high_water <value> <port_id>: "
6088 "Change high water flow control parameter",
6090 (void *)&cmd_lfc_set_set,
6091 (void *)&cmd_lfc_set_flow_ctrl,
6092 (void *)&cmd_lfc_set_high_water_str,
6093 (void *)&cmd_lfc_set_high_water,
6094 (void *)&cmd_lfc_set_portid,
6099 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
6100 .f = cmd_link_flow_ctrl_set_parsed,
6101 .data = (void *)&cmd_link_flow_control_set_lw,
6102 .help_str = "set flow_ctrl low_water <value> <port_id>: "
6103 "Change low water flow control parameter",
6105 (void *)&cmd_lfc_set_set,
6106 (void *)&cmd_lfc_set_flow_ctrl,
6107 (void *)&cmd_lfc_set_low_water_str,
6108 (void *)&cmd_lfc_set_low_water,
6109 (void *)&cmd_lfc_set_portid,
6114 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
6115 .f = cmd_link_flow_ctrl_set_parsed,
6116 .data = (void *)&cmd_link_flow_control_set_pt,
6117 .help_str = "set flow_ctrl pause_time <value> <port_id>: "
6118 "Change pause time flow control parameter",
6120 (void *)&cmd_lfc_set_set,
6121 (void *)&cmd_lfc_set_flow_ctrl,
6122 (void *)&cmd_lfc_set_pause_time_str,
6123 (void *)&cmd_lfc_set_pause_time,
6124 (void *)&cmd_lfc_set_portid,
6129 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
6130 .f = cmd_link_flow_ctrl_set_parsed,
6131 .data = (void *)&cmd_link_flow_control_set_xon,
6132 .help_str = "set flow_ctrl send_xon <value> <port_id>: "
6133 "Change send_xon flow control parameter",
6135 (void *)&cmd_lfc_set_set,
6136 (void *)&cmd_lfc_set_flow_ctrl,
6137 (void *)&cmd_lfc_set_send_xon_str,
6138 (void *)&cmd_lfc_set_send_xon,
6139 (void *)&cmd_lfc_set_portid,
6144 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
6145 .f = cmd_link_flow_ctrl_set_parsed,
6146 .data = (void *)&cmd_link_flow_control_set_macfwd,
6147 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
6148 "Change mac ctrl fwd flow control parameter",
6150 (void *)&cmd_lfc_set_set,
6151 (void *)&cmd_lfc_set_flow_ctrl,
6152 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6153 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6154 (void *)&cmd_lfc_set_portid,
6159 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
6160 .f = cmd_link_flow_ctrl_set_parsed,
6161 .data = (void *)&cmd_link_flow_control_set_autoneg,
6162 .help_str = "set flow_ctrl autoneg on|off <port_id>: "
6163 "Change autoneg flow control parameter",
6165 (void *)&cmd_lfc_set_set,
6166 (void *)&cmd_lfc_set_flow_ctrl,
6167 (void *)&cmd_lfc_set_autoneg_str,
6168 (void *)&cmd_lfc_set_autoneg,
6169 (void *)&cmd_lfc_set_portid,
6175 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
6176 __attribute__((unused)) struct cmdline *cl,
6179 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
6180 cmdline_parse_inst_t *cmd = data;
6181 struct rte_eth_fc_conf fc_conf;
6187 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
6188 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
6189 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
6190 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
6192 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
6193 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
6196 /* Partial command line, retrieve current configuration */
6198 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
6200 printf("cannot get current flow ctrl parameters, return"
6201 "code = %d\n", ret);
6205 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
6206 (fc_conf.mode == RTE_FC_FULL))
6208 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
6209 (fc_conf.mode == RTE_FC_FULL))
6213 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
6214 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
6216 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
6217 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
6219 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
6221 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
6222 fc_conf.high_water = res->high_water;
6224 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
6225 fc_conf.low_water = res->low_water;
6227 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
6228 fc_conf.pause_time = res->pause_time;
6230 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
6231 fc_conf.send_xon = res->send_xon;
6233 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
6234 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
6235 fc_conf.mac_ctrl_frame_fwd = 1;
6237 fc_conf.mac_ctrl_frame_fwd = 0;
6240 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
6241 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
6243 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
6245 printf("bad flow contrl parameter, return code = %d \n", ret);
6248 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
6249 struct cmd_priority_flow_ctrl_set_result {
6250 cmdline_fixed_string_t set;
6251 cmdline_fixed_string_t pfc_ctrl;
6252 cmdline_fixed_string_t rx;
6253 cmdline_fixed_string_t rx_pfc_mode;
6254 cmdline_fixed_string_t tx;
6255 cmdline_fixed_string_t tx_pfc_mode;
6256 uint32_t high_water;
6258 uint16_t pause_time;
6264 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
6265 __attribute__((unused)) struct cmdline *cl,
6266 __attribute__((unused)) void *data)
6268 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
6269 struct rte_eth_pfc_conf pfc_conf;
6270 int rx_fc_enable, tx_fc_enable;
6274 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
6275 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
6276 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
6277 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
6279 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
6280 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
6283 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
6284 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
6285 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
6286 pfc_conf.fc.high_water = res->high_water;
6287 pfc_conf.fc.low_water = res->low_water;
6288 pfc_conf.fc.pause_time = res->pause_time;
6289 pfc_conf.priority = res->priority;
6291 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
6293 printf("bad priority flow contrl parameter, return code = %d \n", ret);
6296 cmdline_parse_token_string_t cmd_pfc_set_set =
6297 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6299 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
6300 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6301 pfc_ctrl, "pfc_ctrl");
6302 cmdline_parse_token_string_t cmd_pfc_set_rx =
6303 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6305 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
6306 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6307 rx_pfc_mode, "on#off");
6308 cmdline_parse_token_string_t cmd_pfc_set_tx =
6309 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6311 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
6312 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6313 tx_pfc_mode, "on#off");
6314 cmdline_parse_token_num_t cmd_pfc_set_high_water =
6315 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6316 high_water, UINT32);
6317 cmdline_parse_token_num_t cmd_pfc_set_low_water =
6318 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6320 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
6321 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6322 pause_time, UINT16);
6323 cmdline_parse_token_num_t cmd_pfc_set_priority =
6324 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6326 cmdline_parse_token_num_t cmd_pfc_set_portid =
6327 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6330 cmdline_parse_inst_t cmd_priority_flow_control_set = {
6331 .f = cmd_priority_flow_ctrl_set_parsed,
6333 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
6334 "<pause_time> <priority> <port_id>: "
6335 "Configure the Ethernet priority flow control",
6337 (void *)&cmd_pfc_set_set,
6338 (void *)&cmd_pfc_set_flow_ctrl,
6339 (void *)&cmd_pfc_set_rx,
6340 (void *)&cmd_pfc_set_rx_mode,
6341 (void *)&cmd_pfc_set_tx,
6342 (void *)&cmd_pfc_set_tx_mode,
6343 (void *)&cmd_pfc_set_high_water,
6344 (void *)&cmd_pfc_set_low_water,
6345 (void *)&cmd_pfc_set_pause_time,
6346 (void *)&cmd_pfc_set_priority,
6347 (void *)&cmd_pfc_set_portid,
6352 /* *** RESET CONFIGURATION *** */
6353 struct cmd_reset_result {
6354 cmdline_fixed_string_t reset;
6355 cmdline_fixed_string_t def;
6358 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
6360 __attribute__((unused)) void *data)
6362 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
6363 set_def_fwd_config();
6366 cmdline_parse_token_string_t cmd_reset_set =
6367 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
6368 cmdline_parse_token_string_t cmd_reset_def =
6369 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
6372 cmdline_parse_inst_t cmd_reset = {
6373 .f = cmd_reset_parsed,
6375 .help_str = "set default: Reset default forwarding configuration",
6377 (void *)&cmd_reset_set,
6378 (void *)&cmd_reset_def,
6383 /* *** START FORWARDING *** */
6384 struct cmd_start_result {
6385 cmdline_fixed_string_t start;
6388 cmdline_parse_token_string_t cmd_start_start =
6389 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
6391 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
6392 __attribute__((unused)) struct cmdline *cl,
6393 __attribute__((unused)) void *data)
6395 start_packet_forwarding(0);
6398 cmdline_parse_inst_t cmd_start = {
6399 .f = cmd_start_parsed,
6401 .help_str = "start: Start packet forwarding",
6403 (void *)&cmd_start_start,
6408 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
6409 struct cmd_start_tx_first_result {
6410 cmdline_fixed_string_t start;
6411 cmdline_fixed_string_t tx_first;
6415 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
6416 __attribute__((unused)) struct cmdline *cl,
6417 __attribute__((unused)) void *data)
6419 start_packet_forwarding(1);
6422 cmdline_parse_token_string_t cmd_start_tx_first_start =
6423 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
6425 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
6426 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
6427 tx_first, "tx_first");
6429 cmdline_parse_inst_t cmd_start_tx_first = {
6430 .f = cmd_start_tx_first_parsed,
6432 .help_str = "start tx_first: Start packet forwarding, "
6433 "after sending 1 burst of packets",
6435 (void *)&cmd_start_tx_first_start,
6436 (void *)&cmd_start_tx_first_tx_first,
6441 /* *** START FORWARDING WITH N TX BURST FIRST *** */
6442 struct cmd_start_tx_first_n_result {
6443 cmdline_fixed_string_t start;
6444 cmdline_fixed_string_t tx_first;
6449 cmd_start_tx_first_n_parsed(void *parsed_result,
6450 __attribute__((unused)) struct cmdline *cl,
6451 __attribute__((unused)) void *data)
6453 struct cmd_start_tx_first_n_result *res = parsed_result;
6455 start_packet_forwarding(res->tx_num);
6458 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
6459 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
6461 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
6462 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
6463 tx_first, "tx_first");
6464 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
6465 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
6468 cmdline_parse_inst_t cmd_start_tx_first_n = {
6469 .f = cmd_start_tx_first_n_parsed,
6471 .help_str = "start tx_first <num>: "
6472 "packet forwarding, after sending <num> bursts of packets",
6474 (void *)&cmd_start_tx_first_n_start,
6475 (void *)&cmd_start_tx_first_n_tx_first,
6476 (void *)&cmd_start_tx_first_n_tx_num,
6481 /* *** SET LINK UP *** */
6482 struct cmd_set_link_up_result {
6483 cmdline_fixed_string_t set;
6484 cmdline_fixed_string_t link_up;
6485 cmdline_fixed_string_t port;
6489 cmdline_parse_token_string_t cmd_set_link_up_set =
6490 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
6491 cmdline_parse_token_string_t cmd_set_link_up_link_up =
6492 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
6494 cmdline_parse_token_string_t cmd_set_link_up_port =
6495 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
6496 cmdline_parse_token_num_t cmd_set_link_up_port_id =
6497 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT16);
6499 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result,
6500 __attribute__((unused)) struct cmdline *cl,
6501 __attribute__((unused)) void *data)
6503 struct cmd_set_link_up_result *res = parsed_result;
6504 dev_set_link_up(res->port_id);
6507 cmdline_parse_inst_t cmd_set_link_up = {
6508 .f = cmd_set_link_up_parsed,
6510 .help_str = "set link-up port <port id>",
6512 (void *)&cmd_set_link_up_set,
6513 (void *)&cmd_set_link_up_link_up,
6514 (void *)&cmd_set_link_up_port,
6515 (void *)&cmd_set_link_up_port_id,
6520 /* *** SET LINK DOWN *** */
6521 struct cmd_set_link_down_result {
6522 cmdline_fixed_string_t set;
6523 cmdline_fixed_string_t link_down;
6524 cmdline_fixed_string_t port;
6528 cmdline_parse_token_string_t cmd_set_link_down_set =
6529 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
6530 cmdline_parse_token_string_t cmd_set_link_down_link_down =
6531 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
6533 cmdline_parse_token_string_t cmd_set_link_down_port =
6534 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
6535 cmdline_parse_token_num_t cmd_set_link_down_port_id =
6536 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT16);
6538 static void cmd_set_link_down_parsed(
6539 __attribute__((unused)) void *parsed_result,
6540 __attribute__((unused)) struct cmdline *cl,
6541 __attribute__((unused)) void *data)
6543 struct cmd_set_link_down_result *res = parsed_result;
6544 dev_set_link_down(res->port_id);
6547 cmdline_parse_inst_t cmd_set_link_down = {
6548 .f = cmd_set_link_down_parsed,
6550 .help_str = "set link-down port <port id>",
6552 (void *)&cmd_set_link_down_set,
6553 (void *)&cmd_set_link_down_link_down,
6554 (void *)&cmd_set_link_down_port,
6555 (void *)&cmd_set_link_down_port_id,
6560 /* *** SHOW CFG *** */
6561 struct cmd_showcfg_result {
6562 cmdline_fixed_string_t show;
6563 cmdline_fixed_string_t cfg;
6564 cmdline_fixed_string_t what;
6567 static void cmd_showcfg_parsed(void *parsed_result,
6568 __attribute__((unused)) struct cmdline *cl,
6569 __attribute__((unused)) void *data)
6571 struct cmd_showcfg_result *res = parsed_result;
6572 if (!strcmp(res->what, "rxtx"))
6573 rxtx_config_display();
6574 else if (!strcmp(res->what, "cores"))
6575 fwd_lcores_config_display();
6576 else if (!strcmp(res->what, "fwd"))
6577 pkt_fwd_config_display(&cur_fwd_config);
6578 else if (!strcmp(res->what, "txpkts"))
6579 show_tx_pkt_segments();
6582 cmdline_parse_token_string_t cmd_showcfg_show =
6583 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
6584 cmdline_parse_token_string_t cmd_showcfg_port =
6585 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
6586 cmdline_parse_token_string_t cmd_showcfg_what =
6587 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
6588 "rxtx#cores#fwd#txpkts");
6590 cmdline_parse_inst_t cmd_showcfg = {
6591 .f = cmd_showcfg_parsed,
6593 .help_str = "show config rxtx|cores|fwd|txpkts",
6595 (void *)&cmd_showcfg_show,
6596 (void *)&cmd_showcfg_port,
6597 (void *)&cmd_showcfg_what,
6602 /* *** SHOW ALL PORT INFO *** */
6603 struct cmd_showportall_result {
6604 cmdline_fixed_string_t show;
6605 cmdline_fixed_string_t port;
6606 cmdline_fixed_string_t what;
6607 cmdline_fixed_string_t all;
6610 static void cmd_showportall_parsed(void *parsed_result,
6611 __attribute__((unused)) struct cmdline *cl,
6612 __attribute__((unused)) void *data)
6616 struct cmd_showportall_result *res = parsed_result;
6617 if (!strcmp(res->show, "clear")) {
6618 if (!strcmp(res->what, "stats"))
6619 RTE_ETH_FOREACH_DEV(i)
6621 else if (!strcmp(res->what, "xstats"))
6622 RTE_ETH_FOREACH_DEV(i)
6623 nic_xstats_clear(i);
6624 } else if (!strcmp(res->what, "info"))
6625 RTE_ETH_FOREACH_DEV(i)
6626 port_infos_display(i);
6627 else if (!strcmp(res->what, "stats"))
6628 RTE_ETH_FOREACH_DEV(i)
6629 nic_stats_display(i);
6630 else if (!strcmp(res->what, "xstats"))
6631 RTE_ETH_FOREACH_DEV(i)
6632 nic_xstats_display(i);
6633 else if (!strcmp(res->what, "fdir"))
6634 RTE_ETH_FOREACH_DEV(i)
6636 else if (!strcmp(res->what, "stat_qmap"))
6637 RTE_ETH_FOREACH_DEV(i)
6638 nic_stats_mapping_display(i);
6639 else if (!strcmp(res->what, "dcb_tc"))
6640 RTE_ETH_FOREACH_DEV(i)
6641 port_dcb_info_display(i);
6642 else if (!strcmp(res->what, "cap"))
6643 RTE_ETH_FOREACH_DEV(i)
6644 port_offload_cap_display(i);
6647 cmdline_parse_token_string_t cmd_showportall_show =
6648 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
6650 cmdline_parse_token_string_t cmd_showportall_port =
6651 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
6652 cmdline_parse_token_string_t cmd_showportall_what =
6653 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
6654 "info#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
6655 cmdline_parse_token_string_t cmd_showportall_all =
6656 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
6657 cmdline_parse_inst_t cmd_showportall = {
6658 .f = cmd_showportall_parsed,
6660 .help_str = "show|clear port "
6661 "info|stats|xstats|fdir|stat_qmap|dcb_tc|cap all",
6663 (void *)&cmd_showportall_show,
6664 (void *)&cmd_showportall_port,
6665 (void *)&cmd_showportall_what,
6666 (void *)&cmd_showportall_all,
6671 /* *** SHOW PORT INFO *** */
6672 struct cmd_showport_result {
6673 cmdline_fixed_string_t show;
6674 cmdline_fixed_string_t port;
6675 cmdline_fixed_string_t what;
6679 static void cmd_showport_parsed(void *parsed_result,
6680 __attribute__((unused)) struct cmdline *cl,
6681 __attribute__((unused)) void *data)
6683 struct cmd_showport_result *res = parsed_result;
6684 if (!strcmp(res->show, "clear")) {
6685 if (!strcmp(res->what, "stats"))
6686 nic_stats_clear(res->portnum);
6687 else if (!strcmp(res->what, "xstats"))
6688 nic_xstats_clear(res->portnum);
6689 } else if (!strcmp(res->what, "info"))
6690 port_infos_display(res->portnum);
6691 else if (!strcmp(res->what, "stats"))
6692 nic_stats_display(res->portnum);
6693 else if (!strcmp(res->what, "xstats"))
6694 nic_xstats_display(res->portnum);
6695 else if (!strcmp(res->what, "fdir"))
6696 fdir_get_infos(res->portnum);
6697 else if (!strcmp(res->what, "stat_qmap"))
6698 nic_stats_mapping_display(res->portnum);
6699 else if (!strcmp(res->what, "dcb_tc"))
6700 port_dcb_info_display(res->portnum);
6701 else if (!strcmp(res->what, "cap"))
6702 port_offload_cap_display(res->portnum);
6705 cmdline_parse_token_string_t cmd_showport_show =
6706 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
6708 cmdline_parse_token_string_t cmd_showport_port =
6709 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
6710 cmdline_parse_token_string_t cmd_showport_what =
6711 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
6712 "info#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
6713 cmdline_parse_token_num_t cmd_showport_portnum =
6714 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT16);
6716 cmdline_parse_inst_t cmd_showport = {
6717 .f = cmd_showport_parsed,
6719 .help_str = "show|clear port "
6720 "info|stats|xstats|fdir|stat_qmap|dcb_tc|cap "
6723 (void *)&cmd_showport_show,
6724 (void *)&cmd_showport_port,
6725 (void *)&cmd_showport_what,
6726 (void *)&cmd_showport_portnum,
6731 /* *** SHOW QUEUE INFO *** */
6732 struct cmd_showqueue_result {
6733 cmdline_fixed_string_t show;
6734 cmdline_fixed_string_t type;
6735 cmdline_fixed_string_t what;
6741 cmd_showqueue_parsed(void *parsed_result,
6742 __attribute__((unused)) struct cmdline *cl,
6743 __attribute__((unused)) void *data)
6745 struct cmd_showqueue_result *res = parsed_result;
6747 if (!strcmp(res->type, "rxq"))
6748 rx_queue_infos_display(res->portnum, res->queuenum);
6749 else if (!strcmp(res->type, "txq"))
6750 tx_queue_infos_display(res->portnum, res->queuenum);
6753 cmdline_parse_token_string_t cmd_showqueue_show =
6754 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
6755 cmdline_parse_token_string_t cmd_showqueue_type =
6756 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
6757 cmdline_parse_token_string_t cmd_showqueue_what =
6758 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
6759 cmdline_parse_token_num_t cmd_showqueue_portnum =
6760 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, UINT16);
6761 cmdline_parse_token_num_t cmd_showqueue_queuenum =
6762 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, UINT16);
6764 cmdline_parse_inst_t cmd_showqueue = {
6765 .f = cmd_showqueue_parsed,
6767 .help_str = "show rxq|txq info <port_id> <queue_id>",
6769 (void *)&cmd_showqueue_show,
6770 (void *)&cmd_showqueue_type,
6771 (void *)&cmd_showqueue_what,
6772 (void *)&cmd_showqueue_portnum,
6773 (void *)&cmd_showqueue_queuenum,
6778 /* *** READ PORT REGISTER *** */
6779 struct cmd_read_reg_result {
6780 cmdline_fixed_string_t read;
6781 cmdline_fixed_string_t reg;
6787 cmd_read_reg_parsed(void *parsed_result,
6788 __attribute__((unused)) struct cmdline *cl,
6789 __attribute__((unused)) void *data)
6791 struct cmd_read_reg_result *res = parsed_result;
6792 port_reg_display(res->port_id, res->reg_off);
6795 cmdline_parse_token_string_t cmd_read_reg_read =
6796 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
6797 cmdline_parse_token_string_t cmd_read_reg_reg =
6798 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
6799 cmdline_parse_token_num_t cmd_read_reg_port_id =
6800 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT16);
6801 cmdline_parse_token_num_t cmd_read_reg_reg_off =
6802 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
6804 cmdline_parse_inst_t cmd_read_reg = {
6805 .f = cmd_read_reg_parsed,
6807 .help_str = "read reg <port_id> <reg_off>",
6809 (void *)&cmd_read_reg_read,
6810 (void *)&cmd_read_reg_reg,
6811 (void *)&cmd_read_reg_port_id,
6812 (void *)&cmd_read_reg_reg_off,
6817 /* *** READ PORT REGISTER BIT FIELD *** */
6818 struct cmd_read_reg_bit_field_result {
6819 cmdline_fixed_string_t read;
6820 cmdline_fixed_string_t regfield;
6828 cmd_read_reg_bit_field_parsed(void *parsed_result,
6829 __attribute__((unused)) struct cmdline *cl,
6830 __attribute__((unused)) void *data)
6832 struct cmd_read_reg_bit_field_result *res = parsed_result;
6833 port_reg_bit_field_display(res->port_id, res->reg_off,
6834 res->bit1_pos, res->bit2_pos);
6837 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
6838 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
6840 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
6841 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
6842 regfield, "regfield");
6843 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
6844 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
6846 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
6847 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
6849 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
6850 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
6852 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
6853 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
6856 cmdline_parse_inst_t cmd_read_reg_bit_field = {
6857 .f = cmd_read_reg_bit_field_parsed,
6859 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
6860 "Read register bit field between bit_x and bit_y included",
6862 (void *)&cmd_read_reg_bit_field_read,
6863 (void *)&cmd_read_reg_bit_field_regfield,
6864 (void *)&cmd_read_reg_bit_field_port_id,
6865 (void *)&cmd_read_reg_bit_field_reg_off,
6866 (void *)&cmd_read_reg_bit_field_bit1_pos,
6867 (void *)&cmd_read_reg_bit_field_bit2_pos,
6872 /* *** READ PORT REGISTER BIT *** */
6873 struct cmd_read_reg_bit_result {
6874 cmdline_fixed_string_t read;
6875 cmdline_fixed_string_t regbit;
6882 cmd_read_reg_bit_parsed(void *parsed_result,
6883 __attribute__((unused)) struct cmdline *cl,
6884 __attribute__((unused)) void *data)
6886 struct cmd_read_reg_bit_result *res = parsed_result;
6887 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
6890 cmdline_parse_token_string_t cmd_read_reg_bit_read =
6891 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
6892 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
6893 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
6895 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
6896 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT16);
6897 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
6898 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
6899 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
6900 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
6902 cmdline_parse_inst_t cmd_read_reg_bit = {
6903 .f = cmd_read_reg_bit_parsed,
6905 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
6907 (void *)&cmd_read_reg_bit_read,
6908 (void *)&cmd_read_reg_bit_regbit,
6909 (void *)&cmd_read_reg_bit_port_id,
6910 (void *)&cmd_read_reg_bit_reg_off,
6911 (void *)&cmd_read_reg_bit_bit_pos,
6916 /* *** WRITE PORT REGISTER *** */
6917 struct cmd_write_reg_result {
6918 cmdline_fixed_string_t write;
6919 cmdline_fixed_string_t reg;
6926 cmd_write_reg_parsed(void *parsed_result,
6927 __attribute__((unused)) struct cmdline *cl,
6928 __attribute__((unused)) void *data)
6930 struct cmd_write_reg_result *res = parsed_result;
6931 port_reg_set(res->port_id, res->reg_off, res->value);
6934 cmdline_parse_token_string_t cmd_write_reg_write =
6935 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
6936 cmdline_parse_token_string_t cmd_write_reg_reg =
6937 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
6938 cmdline_parse_token_num_t cmd_write_reg_port_id =
6939 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT16);
6940 cmdline_parse_token_num_t cmd_write_reg_reg_off =
6941 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
6942 cmdline_parse_token_num_t cmd_write_reg_value =
6943 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
6945 cmdline_parse_inst_t cmd_write_reg = {
6946 .f = cmd_write_reg_parsed,
6948 .help_str = "write reg <port_id> <reg_off> <reg_value>",
6950 (void *)&cmd_write_reg_write,
6951 (void *)&cmd_write_reg_reg,
6952 (void *)&cmd_write_reg_port_id,
6953 (void *)&cmd_write_reg_reg_off,
6954 (void *)&cmd_write_reg_value,
6959 /* *** WRITE PORT REGISTER BIT FIELD *** */
6960 struct cmd_write_reg_bit_field_result {
6961 cmdline_fixed_string_t write;
6962 cmdline_fixed_string_t regfield;
6971 cmd_write_reg_bit_field_parsed(void *parsed_result,
6972 __attribute__((unused)) struct cmdline *cl,
6973 __attribute__((unused)) void *data)
6975 struct cmd_write_reg_bit_field_result *res = parsed_result;
6976 port_reg_bit_field_set(res->port_id, res->reg_off,
6977 res->bit1_pos, res->bit2_pos, res->value);
6980 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
6981 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
6983 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
6984 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
6985 regfield, "regfield");
6986 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
6987 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
6989 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
6990 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
6992 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
6993 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
6995 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
6996 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
6998 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
6999 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
7002 cmdline_parse_inst_t cmd_write_reg_bit_field = {
7003 .f = cmd_write_reg_bit_field_parsed,
7005 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
7007 "Set register bit field between bit_x and bit_y included",
7009 (void *)&cmd_write_reg_bit_field_write,
7010 (void *)&cmd_write_reg_bit_field_regfield,
7011 (void *)&cmd_write_reg_bit_field_port_id,
7012 (void *)&cmd_write_reg_bit_field_reg_off,
7013 (void *)&cmd_write_reg_bit_field_bit1_pos,
7014 (void *)&cmd_write_reg_bit_field_bit2_pos,
7015 (void *)&cmd_write_reg_bit_field_value,
7020 /* *** WRITE PORT REGISTER BIT *** */
7021 struct cmd_write_reg_bit_result {
7022 cmdline_fixed_string_t write;
7023 cmdline_fixed_string_t regbit;
7031 cmd_write_reg_bit_parsed(void *parsed_result,
7032 __attribute__((unused)) struct cmdline *cl,
7033 __attribute__((unused)) void *data)
7035 struct cmd_write_reg_bit_result *res = parsed_result;
7036 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
7039 cmdline_parse_token_string_t cmd_write_reg_bit_write =
7040 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
7042 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
7043 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
7045 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
7046 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT16);
7047 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
7048 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
7049 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
7050 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
7051 cmdline_parse_token_num_t cmd_write_reg_bit_value =
7052 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
7054 cmdline_parse_inst_t cmd_write_reg_bit = {
7055 .f = cmd_write_reg_bit_parsed,
7057 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
7060 (void *)&cmd_write_reg_bit_write,
7061 (void *)&cmd_write_reg_bit_regbit,
7062 (void *)&cmd_write_reg_bit_port_id,
7063 (void *)&cmd_write_reg_bit_reg_off,
7064 (void *)&cmd_write_reg_bit_bit_pos,
7065 (void *)&cmd_write_reg_bit_value,
7070 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
7071 struct cmd_read_rxd_txd_result {
7072 cmdline_fixed_string_t read;
7073 cmdline_fixed_string_t rxd_txd;
7080 cmd_read_rxd_txd_parsed(void *parsed_result,
7081 __attribute__((unused)) struct cmdline *cl,
7082 __attribute__((unused)) void *data)
7084 struct cmd_read_rxd_txd_result *res = parsed_result;
7086 if (!strcmp(res->rxd_txd, "rxd"))
7087 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
7088 else if (!strcmp(res->rxd_txd, "txd"))
7089 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
7092 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
7093 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
7094 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
7095 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
7097 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
7098 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT16);
7099 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
7100 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
7101 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
7102 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
7104 cmdline_parse_inst_t cmd_read_rxd_txd = {
7105 .f = cmd_read_rxd_txd_parsed,
7107 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
7109 (void *)&cmd_read_rxd_txd_read,
7110 (void *)&cmd_read_rxd_txd_rxd_txd,
7111 (void *)&cmd_read_rxd_txd_port_id,
7112 (void *)&cmd_read_rxd_txd_queue_id,
7113 (void *)&cmd_read_rxd_txd_desc_id,
7119 struct cmd_quit_result {
7120 cmdline_fixed_string_t quit;
7123 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
7125 __attribute__((unused)) void *data)
7131 cmdline_parse_token_string_t cmd_quit_quit =
7132 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
7134 cmdline_parse_inst_t cmd_quit = {
7135 .f = cmd_quit_parsed,
7137 .help_str = "quit: Exit application",
7139 (void *)&cmd_quit_quit,
7144 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
7145 struct cmd_mac_addr_result {
7146 cmdline_fixed_string_t mac_addr_cmd;
7147 cmdline_fixed_string_t what;
7149 struct ether_addr address;
7152 static void cmd_mac_addr_parsed(void *parsed_result,
7153 __attribute__((unused)) struct cmdline *cl,
7154 __attribute__((unused)) void *data)
7156 struct cmd_mac_addr_result *res = parsed_result;
7159 if (strcmp(res->what, "add") == 0)
7160 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
7161 else if (strcmp(res->what, "set") == 0)
7162 ret = rte_eth_dev_default_mac_addr_set(res->port_num,
7165 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
7167 /* check the return value and print it if is < 0 */
7169 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
7173 cmdline_parse_token_string_t cmd_mac_addr_cmd =
7174 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
7176 cmdline_parse_token_string_t cmd_mac_addr_what =
7177 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
7179 cmdline_parse_token_num_t cmd_mac_addr_portnum =
7180 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num,
7182 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
7183 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
7185 cmdline_parse_inst_t cmd_mac_addr = {
7186 .f = cmd_mac_addr_parsed,
7188 .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
7189 "Add/Remove/Set MAC address on port_id",
7191 (void *)&cmd_mac_addr_cmd,
7192 (void *)&cmd_mac_addr_what,
7193 (void *)&cmd_mac_addr_portnum,
7194 (void *)&cmd_mac_addr_addr,
7200 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
7201 struct cmd_set_qmap_result {
7202 cmdline_fixed_string_t set;
7203 cmdline_fixed_string_t qmap;
7204 cmdline_fixed_string_t what;
7211 cmd_set_qmap_parsed(void *parsed_result,
7212 __attribute__((unused)) struct cmdline *cl,
7213 __attribute__((unused)) void *data)
7215 struct cmd_set_qmap_result *res = parsed_result;
7216 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
7218 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
7221 cmdline_parse_token_string_t cmd_setqmap_set =
7222 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7224 cmdline_parse_token_string_t cmd_setqmap_qmap =
7225 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7227 cmdline_parse_token_string_t cmd_setqmap_what =
7228 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7230 cmdline_parse_token_num_t cmd_setqmap_portid =
7231 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7233 cmdline_parse_token_num_t cmd_setqmap_queueid =
7234 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7236 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
7237 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7240 cmdline_parse_inst_t cmd_set_qmap = {
7241 .f = cmd_set_qmap_parsed,
7243 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
7244 "Set statistics mapping value on tx|rx queue_id of port_id",
7246 (void *)&cmd_setqmap_set,
7247 (void *)&cmd_setqmap_qmap,
7248 (void *)&cmd_setqmap_what,
7249 (void *)&cmd_setqmap_portid,
7250 (void *)&cmd_setqmap_queueid,
7251 (void *)&cmd_setqmap_mapvalue,
7256 /* *** SET OPTION TO HIDE ZERO VALUES FOR XSTATS DISPLAY *** */
7257 struct cmd_set_xstats_hide_zero_result {
7258 cmdline_fixed_string_t keyword;
7259 cmdline_fixed_string_t name;
7260 cmdline_fixed_string_t on_off;
7264 cmd_set_xstats_hide_zero_parsed(void *parsed_result,
7265 __attribute__((unused)) struct cmdline *cl,
7266 __attribute__((unused)) void *data)
7268 struct cmd_set_xstats_hide_zero_result *res;
7269 uint16_t on_off = 0;
7271 res = parsed_result;
7272 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
7273 set_xstats_hide_zero(on_off);
7276 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_keyword =
7277 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
7279 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_name =
7280 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
7281 name, "xstats-hide-zero");
7282 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_on_off =
7283 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
7286 cmdline_parse_inst_t cmd_set_xstats_hide_zero = {
7287 .f = cmd_set_xstats_hide_zero_parsed,
7289 .help_str = "set xstats-hide-zero on|off",
7291 (void *)&cmd_set_xstats_hide_zero_keyword,
7292 (void *)&cmd_set_xstats_hide_zero_name,
7293 (void *)&cmd_set_xstats_hide_zero_on_off,
7298 /* *** CONFIGURE UNICAST HASH TABLE *** */
7299 struct cmd_set_uc_hash_table {
7300 cmdline_fixed_string_t set;
7301 cmdline_fixed_string_t port;
7303 cmdline_fixed_string_t what;
7304 struct ether_addr address;
7305 cmdline_fixed_string_t mode;
7309 cmd_set_uc_hash_parsed(void *parsed_result,
7310 __attribute__((unused)) struct cmdline *cl,
7311 __attribute__((unused)) void *data)
7314 struct cmd_set_uc_hash_table *res = parsed_result;
7316 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7318 if (strcmp(res->what, "uta") == 0)
7319 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
7320 &res->address,(uint8_t)is_on);
7322 printf("bad unicast hash table parameter, return code = %d \n", ret);
7326 cmdline_parse_token_string_t cmd_set_uc_hash_set =
7327 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7329 cmdline_parse_token_string_t cmd_set_uc_hash_port =
7330 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7332 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
7333 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
7335 cmdline_parse_token_string_t cmd_set_uc_hash_what =
7336 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7338 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
7339 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
7341 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
7342 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7345 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
7346 .f = cmd_set_uc_hash_parsed,
7348 .help_str = "set port <port_id> uta <mac_addr> on|off)",
7350 (void *)&cmd_set_uc_hash_set,
7351 (void *)&cmd_set_uc_hash_port,
7352 (void *)&cmd_set_uc_hash_portid,
7353 (void *)&cmd_set_uc_hash_what,
7354 (void *)&cmd_set_uc_hash_mac,
7355 (void *)&cmd_set_uc_hash_mode,
7360 struct cmd_set_uc_all_hash_table {
7361 cmdline_fixed_string_t set;
7362 cmdline_fixed_string_t port;
7364 cmdline_fixed_string_t what;
7365 cmdline_fixed_string_t value;
7366 cmdline_fixed_string_t mode;
7370 cmd_set_uc_all_hash_parsed(void *parsed_result,
7371 __attribute__((unused)) struct cmdline *cl,
7372 __attribute__((unused)) void *data)
7375 struct cmd_set_uc_all_hash_table *res = parsed_result;
7377 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7379 if ((strcmp(res->what, "uta") == 0) &&
7380 (strcmp(res->value, "all") == 0))
7381 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
7383 printf("bad unicast hash table parameter,"
7384 "return code = %d \n", ret);
7387 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
7388 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7390 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
7391 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7393 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
7394 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
7396 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
7397 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7399 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
7400 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7402 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
7403 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7406 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
7407 .f = cmd_set_uc_all_hash_parsed,
7409 .help_str = "set port <port_id> uta all on|off",
7411 (void *)&cmd_set_uc_all_hash_set,
7412 (void *)&cmd_set_uc_all_hash_port,
7413 (void *)&cmd_set_uc_all_hash_portid,
7414 (void *)&cmd_set_uc_all_hash_what,
7415 (void *)&cmd_set_uc_all_hash_value,
7416 (void *)&cmd_set_uc_all_hash_mode,
7421 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
7422 struct cmd_set_vf_macvlan_filter {
7423 cmdline_fixed_string_t set;
7424 cmdline_fixed_string_t port;
7426 cmdline_fixed_string_t vf;
7428 struct ether_addr address;
7429 cmdline_fixed_string_t filter_type;
7430 cmdline_fixed_string_t mode;
7434 cmd_set_vf_macvlan_parsed(void *parsed_result,
7435 __attribute__((unused)) struct cmdline *cl,
7436 __attribute__((unused)) void *data)
7439 struct cmd_set_vf_macvlan_filter *res = parsed_result;
7440 struct rte_eth_mac_filter filter;
7442 memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
7444 rte_memcpy(&filter.mac_addr, &res->address, ETHER_ADDR_LEN);
7446 /* set VF MAC filter */
7450 filter.dst_id = res->vf_id;
7452 if (!strcmp(res->filter_type, "exact-mac"))
7453 filter.filter_type = RTE_MAC_PERFECT_MATCH;
7454 else if (!strcmp(res->filter_type, "exact-mac-vlan"))
7455 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
7456 else if (!strcmp(res->filter_type, "hashmac"))
7457 filter.filter_type = RTE_MAC_HASH_MATCH;
7458 else if (!strcmp(res->filter_type, "hashmac-vlan"))
7459 filter.filter_type = RTE_MACVLAN_HASH_MATCH;
7461 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7464 ret = rte_eth_dev_filter_ctrl(res->port_id,
7465 RTE_ETH_FILTER_MACVLAN,
7469 ret = rte_eth_dev_filter_ctrl(res->port_id,
7470 RTE_ETH_FILTER_MACVLAN,
7471 RTE_ETH_FILTER_DELETE,
7475 printf("bad set MAC hash parameter, return code = %d\n", ret);
7479 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
7480 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7482 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
7483 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7485 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
7486 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7488 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
7489 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7491 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
7492 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7494 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
7495 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7497 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
7498 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7499 filter_type, "exact-mac#exact-mac-vlan"
7500 "#hashmac#hashmac-vlan");
7501 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
7502 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7505 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
7506 .f = cmd_set_vf_macvlan_parsed,
7508 .help_str = "set port <port_id> vf <vf_id> <mac_addr> "
7509 "exact-mac|exact-mac-vlan|hashmac|hashmac-vlan on|off: "
7510 "Exact match rule: exact match of MAC or MAC and VLAN; "
7511 "hash match rule: hash match of MAC and exact match of VLAN",
7513 (void *)&cmd_set_vf_macvlan_set,
7514 (void *)&cmd_set_vf_macvlan_port,
7515 (void *)&cmd_set_vf_macvlan_portid,
7516 (void *)&cmd_set_vf_macvlan_vf,
7517 (void *)&cmd_set_vf_macvlan_vf_id,
7518 (void *)&cmd_set_vf_macvlan_mac,
7519 (void *)&cmd_set_vf_macvlan_filter_type,
7520 (void *)&cmd_set_vf_macvlan_mode,
7525 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
7526 struct cmd_set_vf_traffic {
7527 cmdline_fixed_string_t set;
7528 cmdline_fixed_string_t port;
7530 cmdline_fixed_string_t vf;
7532 cmdline_fixed_string_t what;
7533 cmdline_fixed_string_t mode;
7537 cmd_set_vf_traffic_parsed(void *parsed_result,
7538 __attribute__((unused)) struct cmdline *cl,
7539 __attribute__((unused)) void *data)
7541 struct cmd_set_vf_traffic *res = parsed_result;
7542 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
7543 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7545 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
7548 cmdline_parse_token_string_t cmd_setvf_traffic_set =
7549 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7551 cmdline_parse_token_string_t cmd_setvf_traffic_port =
7552 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7554 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
7555 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
7557 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
7558 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7560 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
7561 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
7563 cmdline_parse_token_string_t cmd_setvf_traffic_what =
7564 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7566 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
7567 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7570 cmdline_parse_inst_t cmd_set_vf_traffic = {
7571 .f = cmd_set_vf_traffic_parsed,
7573 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
7575 (void *)&cmd_setvf_traffic_set,
7576 (void *)&cmd_setvf_traffic_port,
7577 (void *)&cmd_setvf_traffic_portid,
7578 (void *)&cmd_setvf_traffic_vf,
7579 (void *)&cmd_setvf_traffic_vfid,
7580 (void *)&cmd_setvf_traffic_what,
7581 (void *)&cmd_setvf_traffic_mode,
7586 /* *** CONFIGURE VF RECEIVE MODE *** */
7587 struct cmd_set_vf_rxmode {
7588 cmdline_fixed_string_t set;
7589 cmdline_fixed_string_t port;
7591 cmdline_fixed_string_t vf;
7593 cmdline_fixed_string_t what;
7594 cmdline_fixed_string_t mode;
7595 cmdline_fixed_string_t on;
7599 cmd_set_vf_rxmode_parsed(void *parsed_result,
7600 __attribute__((unused)) struct cmdline *cl,
7601 __attribute__((unused)) void *data)
7604 uint16_t rx_mode = 0;
7605 struct cmd_set_vf_rxmode *res = parsed_result;
7607 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
7608 if (!strcmp(res->what,"rxmode")) {
7609 if (!strcmp(res->mode, "AUPE"))
7610 rx_mode |= ETH_VMDQ_ACCEPT_UNTAG;
7611 else if (!strcmp(res->mode, "ROPE"))
7612 rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC;
7613 else if (!strcmp(res->mode, "BAM"))
7614 rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST;
7615 else if (!strncmp(res->mode, "MPE",3))
7616 rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST;
7619 RTE_SET_USED(is_on);
7621 #ifdef RTE_LIBRTE_IXGBE_PMD
7622 if (ret == -ENOTSUP)
7623 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id,
7624 rx_mode, (uint8_t)is_on);
7626 #ifdef RTE_LIBRTE_BNXT_PMD
7627 if (ret == -ENOTSUP)
7628 ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id,
7629 rx_mode, (uint8_t)is_on);
7632 printf("bad VF receive mode parameter, return code = %d \n",
7636 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
7637 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7639 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
7640 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7642 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
7643 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
7645 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
7646 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7648 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
7649 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
7651 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
7652 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7654 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
7655 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7656 mode, "AUPE#ROPE#BAM#MPE");
7657 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
7658 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7661 cmdline_parse_inst_t cmd_set_vf_rxmode = {
7662 .f = cmd_set_vf_rxmode_parsed,
7664 .help_str = "set port <port_id> vf <vf_id> rxmode "
7665 "AUPE|ROPE|BAM|MPE on|off",
7667 (void *)&cmd_set_vf_rxmode_set,
7668 (void *)&cmd_set_vf_rxmode_port,
7669 (void *)&cmd_set_vf_rxmode_portid,
7670 (void *)&cmd_set_vf_rxmode_vf,
7671 (void *)&cmd_set_vf_rxmode_vfid,
7672 (void *)&cmd_set_vf_rxmode_what,
7673 (void *)&cmd_set_vf_rxmode_mode,
7674 (void *)&cmd_set_vf_rxmode_on,
7679 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
7680 struct cmd_vf_mac_addr_result {
7681 cmdline_fixed_string_t mac_addr_cmd;
7682 cmdline_fixed_string_t what;
7683 cmdline_fixed_string_t port;
7685 cmdline_fixed_string_t vf;
7687 struct ether_addr address;
7690 static void cmd_vf_mac_addr_parsed(void *parsed_result,
7691 __attribute__((unused)) struct cmdline *cl,
7692 __attribute__((unused)) void *data)
7694 struct cmd_vf_mac_addr_result *res = parsed_result;
7697 if (strcmp(res->what, "add") != 0)
7700 #ifdef RTE_LIBRTE_I40E_PMD
7701 if (ret == -ENOTSUP)
7702 ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num,
7705 #ifdef RTE_LIBRTE_BNXT_PMD
7706 if (ret == -ENOTSUP)
7707 ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address,
7712 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
7716 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
7717 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7718 mac_addr_cmd,"mac_addr");
7719 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
7720 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7722 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
7723 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7725 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
7726 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
7728 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
7729 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7731 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
7732 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
7734 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
7735 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
7738 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
7739 .f = cmd_vf_mac_addr_parsed,
7741 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
7742 "Add MAC address filtering for a VF on port_id",
7744 (void *)&cmd_vf_mac_addr_cmd,
7745 (void *)&cmd_vf_mac_addr_what,
7746 (void *)&cmd_vf_mac_addr_port,
7747 (void *)&cmd_vf_mac_addr_portnum,
7748 (void *)&cmd_vf_mac_addr_vf,
7749 (void *)&cmd_vf_mac_addr_vfnum,
7750 (void *)&cmd_vf_mac_addr_addr,
7755 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
7756 struct cmd_vf_rx_vlan_filter {
7757 cmdline_fixed_string_t rx_vlan;
7758 cmdline_fixed_string_t what;
7760 cmdline_fixed_string_t port;
7762 cmdline_fixed_string_t vf;
7767 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
7768 __attribute__((unused)) struct cmdline *cl,
7769 __attribute__((unused)) void *data)
7771 struct cmd_vf_rx_vlan_filter *res = parsed_result;
7774 __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
7776 #ifdef RTE_LIBRTE_IXGBE_PMD
7777 if (ret == -ENOTSUP)
7778 ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
7779 res->vlan_id, res->vf_mask, is_add);
7781 #ifdef RTE_LIBRTE_I40E_PMD
7782 if (ret == -ENOTSUP)
7783 ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
7784 res->vlan_id, res->vf_mask, is_add);
7786 #ifdef RTE_LIBRTE_BNXT_PMD
7787 if (ret == -ENOTSUP)
7788 ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id,
7789 res->vlan_id, res->vf_mask, is_add);
7796 printf("invalid vlan_id %d or vf_mask %"PRIu64"\n",
7797 res->vlan_id, res->vf_mask);
7800 printf("invalid port_id %d\n", res->port_id);
7803 printf("function not implemented or supported\n");
7806 printf("programming error: (%s)\n", strerror(-ret));
7810 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
7811 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7812 rx_vlan, "rx_vlan");
7813 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
7814 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7816 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
7817 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7819 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
7820 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7822 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
7823 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7825 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
7826 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7828 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
7829 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7832 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
7833 .f = cmd_vf_rx_vlan_filter_parsed,
7835 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
7836 "(vf_mask = hexadecimal VF mask)",
7838 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
7839 (void *)&cmd_vf_rx_vlan_filter_what,
7840 (void *)&cmd_vf_rx_vlan_filter_vlanid,
7841 (void *)&cmd_vf_rx_vlan_filter_port,
7842 (void *)&cmd_vf_rx_vlan_filter_portid,
7843 (void *)&cmd_vf_rx_vlan_filter_vf,
7844 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
7849 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
7850 struct cmd_queue_rate_limit_result {
7851 cmdline_fixed_string_t set;
7852 cmdline_fixed_string_t port;
7854 cmdline_fixed_string_t queue;
7856 cmdline_fixed_string_t rate;
7860 static void cmd_queue_rate_limit_parsed(void *parsed_result,
7861 __attribute__((unused)) struct cmdline *cl,
7862 __attribute__((unused)) void *data)
7864 struct cmd_queue_rate_limit_result *res = parsed_result;
7867 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
7868 && (strcmp(res->queue, "queue") == 0)
7869 && (strcmp(res->rate, "rate") == 0))
7870 ret = set_queue_rate_limit(res->port_num, res->queue_num,
7873 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
7877 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
7878 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7880 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
7881 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7883 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
7884 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
7886 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
7887 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7889 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
7890 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
7892 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
7893 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7895 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
7896 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
7899 cmdline_parse_inst_t cmd_queue_rate_limit = {
7900 .f = cmd_queue_rate_limit_parsed,
7902 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
7903 "Set rate limit for a queue on port_id",
7905 (void *)&cmd_queue_rate_limit_set,
7906 (void *)&cmd_queue_rate_limit_port,
7907 (void *)&cmd_queue_rate_limit_portnum,
7908 (void *)&cmd_queue_rate_limit_queue,
7909 (void *)&cmd_queue_rate_limit_queuenum,
7910 (void *)&cmd_queue_rate_limit_rate,
7911 (void *)&cmd_queue_rate_limit_ratenum,
7916 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
7917 struct cmd_vf_rate_limit_result {
7918 cmdline_fixed_string_t set;
7919 cmdline_fixed_string_t port;
7921 cmdline_fixed_string_t vf;
7923 cmdline_fixed_string_t rate;
7925 cmdline_fixed_string_t q_msk;
7929 static void cmd_vf_rate_limit_parsed(void *parsed_result,
7930 __attribute__((unused)) struct cmdline *cl,
7931 __attribute__((unused)) void *data)
7933 struct cmd_vf_rate_limit_result *res = parsed_result;
7936 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
7937 && (strcmp(res->vf, "vf") == 0)
7938 && (strcmp(res->rate, "rate") == 0)
7939 && (strcmp(res->q_msk, "queue_mask") == 0))
7940 ret = set_vf_rate_limit(res->port_num, res->vf_num,
7941 res->rate_num, res->q_msk_val);
7943 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
7947 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
7948 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7950 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
7951 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7953 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
7954 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7956 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
7957 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7959 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
7960 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7962 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
7963 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7965 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
7966 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7968 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
7969 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7970 q_msk, "queue_mask");
7971 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
7972 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7975 cmdline_parse_inst_t cmd_vf_rate_limit = {
7976 .f = cmd_vf_rate_limit_parsed,
7978 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
7979 "queue_mask <queue_mask_value>: "
7980 "Set rate limit for queues of VF on port_id",
7982 (void *)&cmd_vf_rate_limit_set,
7983 (void *)&cmd_vf_rate_limit_port,
7984 (void *)&cmd_vf_rate_limit_portnum,
7985 (void *)&cmd_vf_rate_limit_vf,
7986 (void *)&cmd_vf_rate_limit_vfnum,
7987 (void *)&cmd_vf_rate_limit_rate,
7988 (void *)&cmd_vf_rate_limit_ratenum,
7989 (void *)&cmd_vf_rate_limit_q_msk,
7990 (void *)&cmd_vf_rate_limit_q_msk_val,
7995 /* *** ADD TUNNEL FILTER OF A PORT *** */
7996 struct cmd_tunnel_filter_result {
7997 cmdline_fixed_string_t cmd;
7998 cmdline_fixed_string_t what;
8000 struct ether_addr outer_mac;
8001 struct ether_addr inner_mac;
8002 cmdline_ipaddr_t ip_value;
8003 uint16_t inner_vlan;
8004 cmdline_fixed_string_t tunnel_type;
8005 cmdline_fixed_string_t filter_type;
8011 cmd_tunnel_filter_parsed(void *parsed_result,
8012 __attribute__((unused)) struct cmdline *cl,
8013 __attribute__((unused)) void *data)
8015 struct cmd_tunnel_filter_result *res = parsed_result;
8016 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
8019 memset(&tunnel_filter_conf, 0, sizeof(tunnel_filter_conf));
8021 ether_addr_copy(&res->outer_mac, &tunnel_filter_conf.outer_mac);
8022 ether_addr_copy(&res->inner_mac, &tunnel_filter_conf.inner_mac);
8023 tunnel_filter_conf.inner_vlan = res->inner_vlan;
8025 if (res->ip_value.family == AF_INET) {
8026 tunnel_filter_conf.ip_addr.ipv4_addr =
8027 res->ip_value.addr.ipv4.s_addr;
8028 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
8030 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
8031 &(res->ip_value.addr.ipv6),
8032 sizeof(struct in6_addr));
8033 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
8036 if (!strcmp(res->filter_type, "imac-ivlan"))
8037 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
8038 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
8039 tunnel_filter_conf.filter_type =
8040 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
8041 else if (!strcmp(res->filter_type, "imac-tenid"))
8042 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
8043 else if (!strcmp(res->filter_type, "imac"))
8044 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
8045 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
8046 tunnel_filter_conf.filter_type =
8047 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
8048 else if (!strcmp(res->filter_type, "oip"))
8049 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_OIP;
8050 else if (!strcmp(res->filter_type, "iip"))
8051 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IIP;
8053 printf("The filter type is not supported");
8057 if (!strcmp(res->tunnel_type, "vxlan"))
8058 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
8059 else if (!strcmp(res->tunnel_type, "nvgre"))
8060 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE;
8061 else if (!strcmp(res->tunnel_type, "ipingre"))
8062 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_IP_IN_GRE;
8064 printf("The tunnel type %s not supported.\n", res->tunnel_type);
8068 tunnel_filter_conf.tenant_id = res->tenant_id;
8069 tunnel_filter_conf.queue_id = res->queue_num;
8070 if (!strcmp(res->what, "add"))
8071 ret = rte_eth_dev_filter_ctrl(res->port_id,
8072 RTE_ETH_FILTER_TUNNEL,
8074 &tunnel_filter_conf);
8076 ret = rte_eth_dev_filter_ctrl(res->port_id,
8077 RTE_ETH_FILTER_TUNNEL,
8078 RTE_ETH_FILTER_DELETE,
8079 &tunnel_filter_conf);
8081 printf("cmd_tunnel_filter_parsed error: (%s)\n",
8085 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
8086 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8087 cmd, "tunnel_filter");
8088 cmdline_parse_token_string_t cmd_tunnel_filter_what =
8089 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8091 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
8092 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8094 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
8095 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8097 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
8098 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8100 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
8101 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8102 inner_vlan, UINT16);
8103 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
8104 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8106 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
8107 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8108 tunnel_type, "vxlan#nvgre#ipingre");
8110 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
8111 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8112 filter_type, "oip#iip#imac-ivlan#imac-ivlan-tenid#imac-tenid#"
8113 "imac#omac-imac-tenid");
8114 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
8115 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8117 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
8118 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8121 cmdline_parse_inst_t cmd_tunnel_filter = {
8122 .f = cmd_tunnel_filter_parsed,
8124 .help_str = "tunnel_filter add|rm <port_id> <outer_mac> <inner_mac> "
8125 "<ip> <inner_vlan> vxlan|nvgre|ipingre oip|iip|imac-ivlan|"
8126 "imac-ivlan-tenid|imac-tenid|imac|omac-imac-tenid <tenant_id> "
8127 "<queue_id>: Add/Rm tunnel filter of a port",
8129 (void *)&cmd_tunnel_filter_cmd,
8130 (void *)&cmd_tunnel_filter_what,
8131 (void *)&cmd_tunnel_filter_port_id,
8132 (void *)&cmd_tunnel_filter_outer_mac,
8133 (void *)&cmd_tunnel_filter_inner_mac,
8134 (void *)&cmd_tunnel_filter_ip_value,
8135 (void *)&cmd_tunnel_filter_innner_vlan,
8136 (void *)&cmd_tunnel_filter_tunnel_type,
8137 (void *)&cmd_tunnel_filter_filter_type,
8138 (void *)&cmd_tunnel_filter_tenant_id,
8139 (void *)&cmd_tunnel_filter_queue_num,
8144 /* *** CONFIGURE TUNNEL UDP PORT *** */
8145 struct cmd_tunnel_udp_config {
8146 cmdline_fixed_string_t cmd;
8147 cmdline_fixed_string_t what;
8153 cmd_tunnel_udp_config_parsed(void *parsed_result,
8154 __attribute__((unused)) struct cmdline *cl,
8155 __attribute__((unused)) void *data)
8157 struct cmd_tunnel_udp_config *res = parsed_result;
8158 struct rte_eth_udp_tunnel tunnel_udp;
8161 tunnel_udp.udp_port = res->udp_port;
8163 if (!strcmp(res->cmd, "rx_vxlan_port"))
8164 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
8166 if (!strcmp(res->what, "add"))
8167 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
8170 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
8174 printf("udp tunneling add error: (%s)\n", strerror(-ret));
8177 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
8178 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
8179 cmd, "rx_vxlan_port");
8180 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
8181 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
8183 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
8184 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
8186 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
8187 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
8190 cmdline_parse_inst_t cmd_tunnel_udp_config = {
8191 .f = cmd_tunnel_udp_config_parsed,
8193 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
8194 "Add/Remove a tunneling UDP port filter",
8196 (void *)&cmd_tunnel_udp_config_cmd,
8197 (void *)&cmd_tunnel_udp_config_what,
8198 (void *)&cmd_tunnel_udp_config_udp_port,
8199 (void *)&cmd_tunnel_udp_config_port_id,
8204 /* *** GLOBAL CONFIG *** */
8205 struct cmd_global_config_result {
8206 cmdline_fixed_string_t cmd;
8208 cmdline_fixed_string_t cfg_type;
8213 cmd_global_config_parsed(void *parsed_result,
8214 __attribute__((unused)) struct cmdline *cl,
8215 __attribute__((unused)) void *data)
8217 struct cmd_global_config_result *res = parsed_result;
8218 struct rte_eth_global_cfg conf;
8221 memset(&conf, 0, sizeof(conf));
8222 conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN;
8223 conf.cfg.gre_key_len = res->len;
8224 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE,
8225 RTE_ETH_FILTER_SET, &conf);
8227 printf("Global config error\n");
8230 cmdline_parse_token_string_t cmd_global_config_cmd =
8231 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd,
8233 cmdline_parse_token_num_t cmd_global_config_port_id =
8234 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id,
8236 cmdline_parse_token_string_t cmd_global_config_type =
8237 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result,
8238 cfg_type, "gre-key-len");
8239 cmdline_parse_token_num_t cmd_global_config_gre_key_len =
8240 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result,
8243 cmdline_parse_inst_t cmd_global_config = {
8244 .f = cmd_global_config_parsed,
8245 .data = (void *)NULL,
8246 .help_str = "global_config <port_id> gre-key-len <key_len>",
8248 (void *)&cmd_global_config_cmd,
8249 (void *)&cmd_global_config_port_id,
8250 (void *)&cmd_global_config_type,
8251 (void *)&cmd_global_config_gre_key_len,
8256 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
8257 struct cmd_set_mirror_mask_result {
8258 cmdline_fixed_string_t set;
8259 cmdline_fixed_string_t port;
8261 cmdline_fixed_string_t mirror;
8263 cmdline_fixed_string_t what;
8264 cmdline_fixed_string_t value;
8265 cmdline_fixed_string_t dstpool;
8267 cmdline_fixed_string_t on;
8270 cmdline_parse_token_string_t cmd_mirror_mask_set =
8271 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8273 cmdline_parse_token_string_t cmd_mirror_mask_port =
8274 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8276 cmdline_parse_token_num_t cmd_mirror_mask_portid =
8277 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
8279 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
8280 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8281 mirror, "mirror-rule");
8282 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
8283 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
8285 cmdline_parse_token_string_t cmd_mirror_mask_what =
8286 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8287 what, "pool-mirror-up#pool-mirror-down"
8289 cmdline_parse_token_string_t cmd_mirror_mask_value =
8290 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8292 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
8293 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8294 dstpool, "dst-pool");
8295 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
8296 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
8298 cmdline_parse_token_string_t cmd_mirror_mask_on =
8299 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8303 cmd_set_mirror_mask_parsed(void *parsed_result,
8304 __attribute__((unused)) struct cmdline *cl,
8305 __attribute__((unused)) void *data)
8308 struct cmd_set_mirror_mask_result *res = parsed_result;
8309 struct rte_eth_mirror_conf mr_conf;
8311 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
8313 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
8315 mr_conf.dst_pool = res->dstpool_id;
8317 if (!strcmp(res->what, "pool-mirror-up")) {
8318 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
8319 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
8320 } else if (!strcmp(res->what, "pool-mirror-down")) {
8321 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
8322 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
8323 } else if (!strcmp(res->what, "vlan-mirror")) {
8324 mr_conf.rule_type = ETH_MIRROR_VLAN;
8325 nb_item = parse_item_list(res->value, "vlan",
8326 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
8330 for (i = 0; i < nb_item; i++) {
8331 if (vlan_list[i] > ETHER_MAX_VLAN_ID) {
8332 printf("Invalid vlan_id: must be < 4096\n");
8336 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
8337 mr_conf.vlan.vlan_mask |= 1ULL << i;
8341 if (!strcmp(res->on, "on"))
8342 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8345 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8348 printf("mirror rule add error: (%s)\n", strerror(-ret));
8351 cmdline_parse_inst_t cmd_set_mirror_mask = {
8352 .f = cmd_set_mirror_mask_parsed,
8354 .help_str = "set port <port_id> mirror-rule <rule_id> "
8355 "pool-mirror-up|pool-mirror-down|vlan-mirror "
8356 "<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off",
8358 (void *)&cmd_mirror_mask_set,
8359 (void *)&cmd_mirror_mask_port,
8360 (void *)&cmd_mirror_mask_portid,
8361 (void *)&cmd_mirror_mask_mirror,
8362 (void *)&cmd_mirror_mask_ruleid,
8363 (void *)&cmd_mirror_mask_what,
8364 (void *)&cmd_mirror_mask_value,
8365 (void *)&cmd_mirror_mask_dstpool,
8366 (void *)&cmd_mirror_mask_poolid,
8367 (void *)&cmd_mirror_mask_on,
8372 /* *** CONFIGURE VM MIRROR UPLINK/DOWNLINK RULE *** */
8373 struct cmd_set_mirror_link_result {
8374 cmdline_fixed_string_t set;
8375 cmdline_fixed_string_t port;
8377 cmdline_fixed_string_t mirror;
8379 cmdline_fixed_string_t what;
8380 cmdline_fixed_string_t dstpool;
8382 cmdline_fixed_string_t on;
8385 cmdline_parse_token_string_t cmd_mirror_link_set =
8386 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8388 cmdline_parse_token_string_t cmd_mirror_link_port =
8389 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8391 cmdline_parse_token_num_t cmd_mirror_link_portid =
8392 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
8394 cmdline_parse_token_string_t cmd_mirror_link_mirror =
8395 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8396 mirror, "mirror-rule");
8397 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
8398 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
8400 cmdline_parse_token_string_t cmd_mirror_link_what =
8401 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8402 what, "uplink-mirror#downlink-mirror");
8403 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
8404 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8405 dstpool, "dst-pool");
8406 cmdline_parse_token_num_t cmd_mirror_link_poolid =
8407 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
8409 cmdline_parse_token_string_t cmd_mirror_link_on =
8410 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8414 cmd_set_mirror_link_parsed(void *parsed_result,
8415 __attribute__((unused)) struct cmdline *cl,
8416 __attribute__((unused)) void *data)
8419 struct cmd_set_mirror_link_result *res = parsed_result;
8420 struct rte_eth_mirror_conf mr_conf;
8422 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
8423 if (!strcmp(res->what, "uplink-mirror"))
8424 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
8426 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
8428 mr_conf.dst_pool = res->dstpool_id;
8430 if (!strcmp(res->on, "on"))
8431 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8434 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8437 /* check the return value and print it if is < 0 */
8439 printf("mirror rule add error: (%s)\n", strerror(-ret));
8443 cmdline_parse_inst_t cmd_set_mirror_link = {
8444 .f = cmd_set_mirror_link_parsed,
8446 .help_str = "set port <port_id> mirror-rule <rule_id> "
8447 "uplink-mirror|downlink-mirror dst-pool <pool_id> on|off",
8449 (void *)&cmd_mirror_link_set,
8450 (void *)&cmd_mirror_link_port,
8451 (void *)&cmd_mirror_link_portid,
8452 (void *)&cmd_mirror_link_mirror,
8453 (void *)&cmd_mirror_link_ruleid,
8454 (void *)&cmd_mirror_link_what,
8455 (void *)&cmd_mirror_link_dstpool,
8456 (void *)&cmd_mirror_link_poolid,
8457 (void *)&cmd_mirror_link_on,
8462 /* *** RESET VM MIRROR RULE *** */
8463 struct cmd_rm_mirror_rule_result {
8464 cmdline_fixed_string_t reset;
8465 cmdline_fixed_string_t port;
8467 cmdline_fixed_string_t mirror;
8471 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
8472 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
8474 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
8475 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
8477 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
8478 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
8480 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
8481 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
8482 mirror, "mirror-rule");
8483 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
8484 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
8488 cmd_reset_mirror_rule_parsed(void *parsed_result,
8489 __attribute__((unused)) struct cmdline *cl,
8490 __attribute__((unused)) void *data)
8493 struct cmd_set_mirror_link_result *res = parsed_result;
8495 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
8497 printf("mirror rule remove error: (%s)\n", strerror(-ret));
8500 cmdline_parse_inst_t cmd_reset_mirror_rule = {
8501 .f = cmd_reset_mirror_rule_parsed,
8503 .help_str = "reset port <port_id> mirror-rule <rule_id>",
8505 (void *)&cmd_rm_mirror_rule_reset,
8506 (void *)&cmd_rm_mirror_rule_port,
8507 (void *)&cmd_rm_mirror_rule_portid,
8508 (void *)&cmd_rm_mirror_rule_mirror,
8509 (void *)&cmd_rm_mirror_rule_ruleid,
8514 /* ******************************************************************************** */
8516 struct cmd_dump_result {
8517 cmdline_fixed_string_t dump;
8521 dump_struct_sizes(void)
8523 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
8524 DUMP_SIZE(struct rte_mbuf);
8525 DUMP_SIZE(struct rte_mempool);
8526 DUMP_SIZE(struct rte_ring);
8530 static void cmd_dump_parsed(void *parsed_result,
8531 __attribute__((unused)) struct cmdline *cl,
8532 __attribute__((unused)) void *data)
8534 struct cmd_dump_result *res = parsed_result;
8536 if (!strcmp(res->dump, "dump_physmem"))
8537 rte_dump_physmem_layout(stdout);
8538 else if (!strcmp(res->dump, "dump_memzone"))
8539 rte_memzone_dump(stdout);
8540 else if (!strcmp(res->dump, "dump_struct_sizes"))
8541 dump_struct_sizes();
8542 else if (!strcmp(res->dump, "dump_ring"))
8543 rte_ring_list_dump(stdout);
8544 else if (!strcmp(res->dump, "dump_mempool"))
8545 rte_mempool_list_dump(stdout);
8546 else if (!strcmp(res->dump, "dump_devargs"))
8547 rte_eal_devargs_dump(stdout);
8548 else if (!strcmp(res->dump, "dump_log_types"))
8549 rte_log_dump(stdout);
8552 cmdline_parse_token_string_t cmd_dump_dump =
8553 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
8556 "dump_struct_sizes#"
8562 cmdline_parse_inst_t cmd_dump = {
8563 .f = cmd_dump_parsed, /* function to call */
8564 .data = NULL, /* 2nd arg of func */
8565 .help_str = "Dump status",
8566 .tokens = { /* token list, NULL terminated */
8567 (void *)&cmd_dump_dump,
8572 /* ******************************************************************************** */
8574 struct cmd_dump_one_result {
8575 cmdline_fixed_string_t dump;
8576 cmdline_fixed_string_t name;
8579 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
8580 __attribute__((unused)) void *data)
8582 struct cmd_dump_one_result *res = parsed_result;
8584 if (!strcmp(res->dump, "dump_ring")) {
8586 r = rte_ring_lookup(res->name);
8588 cmdline_printf(cl, "Cannot find ring\n");
8591 rte_ring_dump(stdout, r);
8592 } else if (!strcmp(res->dump, "dump_mempool")) {
8593 struct rte_mempool *mp;
8594 mp = rte_mempool_lookup(res->name);
8596 cmdline_printf(cl, "Cannot find mempool\n");
8599 rte_mempool_dump(stdout, mp);
8603 cmdline_parse_token_string_t cmd_dump_one_dump =
8604 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
8605 "dump_ring#dump_mempool");
8607 cmdline_parse_token_string_t cmd_dump_one_name =
8608 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
8610 cmdline_parse_inst_t cmd_dump_one = {
8611 .f = cmd_dump_one_parsed, /* function to call */
8612 .data = NULL, /* 2nd arg of func */
8613 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
8614 .tokens = { /* token list, NULL terminated */
8615 (void *)&cmd_dump_one_dump,
8616 (void *)&cmd_dump_one_name,
8621 /* *** Add/Del syn filter *** */
8622 struct cmd_syn_filter_result {
8623 cmdline_fixed_string_t filter;
8625 cmdline_fixed_string_t ops;
8626 cmdline_fixed_string_t priority;
8627 cmdline_fixed_string_t high;
8628 cmdline_fixed_string_t queue;
8633 cmd_syn_filter_parsed(void *parsed_result,
8634 __attribute__((unused)) struct cmdline *cl,
8635 __attribute__((unused)) void *data)
8637 struct cmd_syn_filter_result *res = parsed_result;
8638 struct rte_eth_syn_filter syn_filter;
8641 ret = rte_eth_dev_filter_supported(res->port_id,
8642 RTE_ETH_FILTER_SYN);
8644 printf("syn filter is not supported on port %u.\n",
8649 memset(&syn_filter, 0, sizeof(syn_filter));
8651 if (!strcmp(res->ops, "add")) {
8652 if (!strcmp(res->high, "high"))
8653 syn_filter.hig_pri = 1;
8655 syn_filter.hig_pri = 0;
8657 syn_filter.queue = res->queue_id;
8658 ret = rte_eth_dev_filter_ctrl(res->port_id,
8663 ret = rte_eth_dev_filter_ctrl(res->port_id,
8665 RTE_ETH_FILTER_DELETE,
8669 printf("syn filter programming error: (%s)\n",
8673 cmdline_parse_token_string_t cmd_syn_filter_filter =
8674 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8675 filter, "syn_filter");
8676 cmdline_parse_token_num_t cmd_syn_filter_port_id =
8677 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
8679 cmdline_parse_token_string_t cmd_syn_filter_ops =
8680 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8682 cmdline_parse_token_string_t cmd_syn_filter_priority =
8683 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8684 priority, "priority");
8685 cmdline_parse_token_string_t cmd_syn_filter_high =
8686 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8688 cmdline_parse_token_string_t cmd_syn_filter_queue =
8689 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8691 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
8692 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
8695 cmdline_parse_inst_t cmd_syn_filter = {
8696 .f = cmd_syn_filter_parsed,
8698 .help_str = "syn_filter <port_id> add|del priority high|low queue "
8699 "<queue_id>: Add/Delete syn filter",
8701 (void *)&cmd_syn_filter_filter,
8702 (void *)&cmd_syn_filter_port_id,
8703 (void *)&cmd_syn_filter_ops,
8704 (void *)&cmd_syn_filter_priority,
8705 (void *)&cmd_syn_filter_high,
8706 (void *)&cmd_syn_filter_queue,
8707 (void *)&cmd_syn_filter_queue_id,
8712 /* *** queue region set *** */
8713 struct cmd_queue_region_result {
8714 cmdline_fixed_string_t set;
8715 cmdline_fixed_string_t port;
8717 cmdline_fixed_string_t cmd;
8718 cmdline_fixed_string_t region;
8720 cmdline_fixed_string_t queue_start_index;
8722 cmdline_fixed_string_t queue_num;
8723 uint8_t queue_num_value;
8727 cmd_queue_region_parsed(void *parsed_result,
8728 __attribute__((unused)) struct cmdline *cl,
8729 __attribute__((unused)) void *data)
8731 struct cmd_queue_region_result *res = parsed_result;
8733 #ifdef RTE_LIBRTE_I40E_PMD
8734 struct rte_pmd_i40e_queue_region_conf region_conf;
8735 enum rte_pmd_i40e_queue_region_op op_type;
8738 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
8741 #ifdef RTE_LIBRTE_I40E_PMD
8742 memset(®ion_conf, 0, sizeof(region_conf));
8743 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_SET;
8744 region_conf.region_id = res->region_id;
8745 region_conf.queue_num = res->queue_num_value;
8746 region_conf.queue_start_index = res->queue_id;
8748 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
8749 op_type, ®ion_conf);
8756 printf("function not implemented or supported\n");
8759 printf("queue region config error: (%s)\n", strerror(-ret));
8763 cmdline_parse_token_string_t cmd_queue_region_set =
8764 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
8766 cmdline_parse_token_string_t cmd_queue_region_port =
8767 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, port, "port");
8768 cmdline_parse_token_num_t cmd_queue_region_port_id =
8769 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
8771 cmdline_parse_token_string_t cmd_queue_region_cmd =
8772 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
8773 cmd, "queue-region");
8774 cmdline_parse_token_string_t cmd_queue_region_id =
8775 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
8776 region, "region_id");
8777 cmdline_parse_token_num_t cmd_queue_region_index =
8778 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
8780 cmdline_parse_token_string_t cmd_queue_region_queue_start_index =
8781 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
8782 queue_start_index, "queue_start_index");
8783 cmdline_parse_token_num_t cmd_queue_region_queue_id =
8784 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
8786 cmdline_parse_token_string_t cmd_queue_region_queue_num =
8787 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
8788 queue_num, "queue_num");
8789 cmdline_parse_token_num_t cmd_queue_region_queue_num_value =
8790 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
8791 queue_num_value, UINT8);
8793 cmdline_parse_inst_t cmd_queue_region = {
8794 .f = cmd_queue_region_parsed,
8796 .help_str = "set port <port_id> queue-region region_id <value> "
8797 "queue_start_index <value> queue_num <value>: Set a queue region",
8799 (void *)&cmd_queue_region_set,
8800 (void *)&cmd_queue_region_port,
8801 (void *)&cmd_queue_region_port_id,
8802 (void *)&cmd_queue_region_cmd,
8803 (void *)&cmd_queue_region_id,
8804 (void *)&cmd_queue_region_index,
8805 (void *)&cmd_queue_region_queue_start_index,
8806 (void *)&cmd_queue_region_queue_id,
8807 (void *)&cmd_queue_region_queue_num,
8808 (void *)&cmd_queue_region_queue_num_value,
8813 /* *** queue region and flowtype set *** */
8814 struct cmd_region_flowtype_result {
8815 cmdline_fixed_string_t set;
8816 cmdline_fixed_string_t port;
8818 cmdline_fixed_string_t cmd;
8819 cmdline_fixed_string_t region;
8821 cmdline_fixed_string_t flowtype;
8822 uint8_t flowtype_id;
8826 cmd_region_flowtype_parsed(void *parsed_result,
8827 __attribute__((unused)) struct cmdline *cl,
8828 __attribute__((unused)) void *data)
8830 struct cmd_region_flowtype_result *res = parsed_result;
8832 #ifdef RTE_LIBRTE_I40E_PMD
8833 struct rte_pmd_i40e_queue_region_conf region_conf;
8834 enum rte_pmd_i40e_queue_region_op op_type;
8837 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
8840 #ifdef RTE_LIBRTE_I40E_PMD
8841 memset(®ion_conf, 0, sizeof(region_conf));
8843 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_FLOWTYPE_SET;
8844 region_conf.region_id = res->region_id;
8845 region_conf.hw_flowtype = res->flowtype_id;
8847 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
8848 op_type, ®ion_conf);
8855 printf("function not implemented or supported\n");
8858 printf("region flowtype config error: (%s)\n", strerror(-ret));
8862 cmdline_parse_token_string_t cmd_region_flowtype_set =
8863 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
8865 cmdline_parse_token_string_t cmd_region_flowtype_port =
8866 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
8868 cmdline_parse_token_num_t cmd_region_flowtype_port_index =
8869 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
8871 cmdline_parse_token_string_t cmd_region_flowtype_cmd =
8872 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
8873 cmd, "queue-region");
8874 cmdline_parse_token_string_t cmd_region_flowtype_index =
8875 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
8876 region, "region_id");
8877 cmdline_parse_token_num_t cmd_region_flowtype_id =
8878 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
8880 cmdline_parse_token_string_t cmd_region_flowtype_flow_index =
8881 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
8882 flowtype, "flowtype");
8883 cmdline_parse_token_num_t cmd_region_flowtype_flow_id =
8884 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
8885 flowtype_id, UINT8);
8886 cmdline_parse_inst_t cmd_region_flowtype = {
8887 .f = cmd_region_flowtype_parsed,
8889 .help_str = "set port <port_id> queue-region region_id <value> "
8890 "flowtype <value>: Set a flowtype region index",
8892 (void *)&cmd_region_flowtype_set,
8893 (void *)&cmd_region_flowtype_port,
8894 (void *)&cmd_region_flowtype_port_index,
8895 (void *)&cmd_region_flowtype_cmd,
8896 (void *)&cmd_region_flowtype_index,
8897 (void *)&cmd_region_flowtype_id,
8898 (void *)&cmd_region_flowtype_flow_index,
8899 (void *)&cmd_region_flowtype_flow_id,
8904 /* *** User Priority (UP) to queue region (region_id) set *** */
8905 struct cmd_user_priority_region_result {
8906 cmdline_fixed_string_t set;
8907 cmdline_fixed_string_t port;
8909 cmdline_fixed_string_t cmd;
8910 cmdline_fixed_string_t user_priority;
8911 uint8_t user_priority_id;
8912 cmdline_fixed_string_t region;
8917 cmd_user_priority_region_parsed(void *parsed_result,
8918 __attribute__((unused)) struct cmdline *cl,
8919 __attribute__((unused)) void *data)
8921 struct cmd_user_priority_region_result *res = parsed_result;
8923 #ifdef RTE_LIBRTE_I40E_PMD
8924 struct rte_pmd_i40e_queue_region_conf region_conf;
8925 enum rte_pmd_i40e_queue_region_op op_type;
8928 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
8931 #ifdef RTE_LIBRTE_I40E_PMD
8932 memset(®ion_conf, 0, sizeof(region_conf));
8933 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_USER_PRIORITY_SET;
8934 region_conf.user_priority = res->user_priority_id;
8935 region_conf.region_id = res->region_id;
8937 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
8938 op_type, ®ion_conf);
8945 printf("function not implemented or supported\n");
8948 printf("user_priority region config error: (%s)\n",
8953 cmdline_parse_token_string_t cmd_user_priority_region_set =
8954 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
8956 cmdline_parse_token_string_t cmd_user_priority_region_port =
8957 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
8959 cmdline_parse_token_num_t cmd_user_priority_region_port_index =
8960 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
8962 cmdline_parse_token_string_t cmd_user_priority_region_cmd =
8963 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
8964 cmd, "queue-region");
8965 cmdline_parse_token_string_t cmd_user_priority_region_UP =
8966 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
8967 user_priority, "UP");
8968 cmdline_parse_token_num_t cmd_user_priority_region_UP_id =
8969 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
8970 user_priority_id, UINT8);
8971 cmdline_parse_token_string_t cmd_user_priority_region_region =
8972 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
8973 region, "region_id");
8974 cmdline_parse_token_num_t cmd_user_priority_region_region_id =
8975 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
8978 cmdline_parse_inst_t cmd_user_priority_region = {
8979 .f = cmd_user_priority_region_parsed,
8981 .help_str = "set port <port_id> queue-region UP <value> "
8982 "region_id <value>: Set the mapping of User Priority (UP) "
8983 "to queue region (region_id) ",
8985 (void *)&cmd_user_priority_region_set,
8986 (void *)&cmd_user_priority_region_port,
8987 (void *)&cmd_user_priority_region_port_index,
8988 (void *)&cmd_user_priority_region_cmd,
8989 (void *)&cmd_user_priority_region_UP,
8990 (void *)&cmd_user_priority_region_UP_id,
8991 (void *)&cmd_user_priority_region_region,
8992 (void *)&cmd_user_priority_region_region_id,
8997 /* *** flush all queue region related configuration *** */
8998 struct cmd_flush_queue_region_result {
8999 cmdline_fixed_string_t set;
9000 cmdline_fixed_string_t port;
9002 cmdline_fixed_string_t cmd;
9003 cmdline_fixed_string_t flush;
9004 cmdline_fixed_string_t what;
9008 cmd_flush_queue_region_parsed(void *parsed_result,
9009 __attribute__((unused)) struct cmdline *cl,
9010 __attribute__((unused)) void *data)
9012 struct cmd_flush_queue_region_result *res = parsed_result;
9014 #ifdef RTE_LIBRTE_I40E_PMD
9015 struct rte_pmd_i40e_queue_region_conf region_conf;
9016 enum rte_pmd_i40e_queue_region_op op_type;
9019 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9022 #ifdef RTE_LIBRTE_I40E_PMD
9023 memset(®ion_conf, 0, sizeof(region_conf));
9025 if (strcmp(res->what, "on") == 0)
9026 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_ON;
9028 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_OFF;
9030 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9031 op_type, ®ion_conf);
9038 printf("function not implemented or supported\n");
9041 printf("queue region config flush error: (%s)\n",
9046 cmdline_parse_token_string_t cmd_flush_queue_region_set =
9047 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9049 cmdline_parse_token_string_t cmd_flush_queue_region_port =
9050 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9052 cmdline_parse_token_num_t cmd_flush_queue_region_port_index =
9053 TOKEN_NUM_INITIALIZER(struct cmd_flush_queue_region_result,
9055 cmdline_parse_token_string_t cmd_flush_queue_region_cmd =
9056 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9057 cmd, "queue-region");
9058 cmdline_parse_token_string_t cmd_flush_queue_region_flush =
9059 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9061 cmdline_parse_token_string_t cmd_flush_queue_region_what =
9062 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9065 cmdline_parse_inst_t cmd_flush_queue_region = {
9066 .f = cmd_flush_queue_region_parsed,
9068 .help_str = "set port <port_id> queue-region flush on|off"
9069 ": flush all queue region related configuration",
9071 (void *)&cmd_flush_queue_region_set,
9072 (void *)&cmd_flush_queue_region_port,
9073 (void *)&cmd_flush_queue_region_port_index,
9074 (void *)&cmd_flush_queue_region_cmd,
9075 (void *)&cmd_flush_queue_region_flush,
9076 (void *)&cmd_flush_queue_region_what,
9081 /* *** get all queue region related configuration info *** */
9082 struct cmd_show_queue_region_info {
9083 cmdline_fixed_string_t show;
9084 cmdline_fixed_string_t port;
9086 cmdline_fixed_string_t cmd;
9090 cmd_show_queue_region_info_parsed(void *parsed_result,
9091 __attribute__((unused)) struct cmdline *cl,
9092 __attribute__((unused)) void *data)
9094 struct cmd_show_queue_region_info *res = parsed_result;
9096 #ifdef RTE_LIBRTE_I40E_PMD
9097 struct rte_pmd_i40e_queue_regions rte_pmd_regions;
9098 enum rte_pmd_i40e_queue_region_op op_type;
9101 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9104 #ifdef RTE_LIBRTE_I40E_PMD
9105 memset(&rte_pmd_regions, 0, sizeof(rte_pmd_regions));
9107 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_INFO_GET;
9109 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9110 op_type, &rte_pmd_regions);
9112 port_queue_region_info_display(res->port_id, &rte_pmd_regions);
9119 printf("function not implemented or supported\n");
9122 printf("queue region config info show error: (%s)\n",
9127 cmdline_parse_token_string_t cmd_show_queue_region_info_get =
9128 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
9130 cmdline_parse_token_string_t cmd_show_queue_region_info_port =
9131 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
9133 cmdline_parse_token_num_t cmd_show_queue_region_info_port_index =
9134 TOKEN_NUM_INITIALIZER(struct cmd_show_queue_region_info,
9136 cmdline_parse_token_string_t cmd_show_queue_region_info_cmd =
9137 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
9138 cmd, "queue-region");
9140 cmdline_parse_inst_t cmd_show_queue_region_info_all = {
9141 .f = cmd_show_queue_region_info_parsed,
9143 .help_str = "show port <port_id> queue-region"
9144 ": show all queue region related configuration info",
9146 (void *)&cmd_show_queue_region_info_get,
9147 (void *)&cmd_show_queue_region_info_port,
9148 (void *)&cmd_show_queue_region_info_port_index,
9149 (void *)&cmd_show_queue_region_info_cmd,
9154 /* *** ADD/REMOVE A 2tuple FILTER *** */
9155 struct cmd_2tuple_filter_result {
9156 cmdline_fixed_string_t filter;
9158 cmdline_fixed_string_t ops;
9159 cmdline_fixed_string_t dst_port;
9160 uint16_t dst_port_value;
9161 cmdline_fixed_string_t protocol;
9162 uint8_t protocol_value;
9163 cmdline_fixed_string_t mask;
9165 cmdline_fixed_string_t tcp_flags;
9166 uint8_t tcp_flags_value;
9167 cmdline_fixed_string_t priority;
9168 uint8_t priority_value;
9169 cmdline_fixed_string_t queue;
9174 cmd_2tuple_filter_parsed(void *parsed_result,
9175 __attribute__((unused)) struct cmdline *cl,
9176 __attribute__((unused)) void *data)
9178 struct rte_eth_ntuple_filter filter;
9179 struct cmd_2tuple_filter_result *res = parsed_result;
9182 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
9184 printf("ntuple filter is not supported on port %u.\n",
9189 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
9191 filter.flags = RTE_2TUPLE_FLAGS;
9192 filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
9193 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
9194 filter.proto = res->protocol_value;
9195 filter.priority = res->priority_value;
9196 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
9197 printf("nonzero tcp_flags is only meaningful"
9198 " when protocol is TCP.\n");
9201 if (res->tcp_flags_value > TCP_FLAG_ALL) {
9202 printf("invalid TCP flags.\n");
9206 if (res->tcp_flags_value != 0) {
9207 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
9208 filter.tcp_flags = res->tcp_flags_value;
9211 /* need convert to big endian. */
9212 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
9213 filter.queue = res->queue_id;
9215 if (!strcmp(res->ops, "add"))
9216 ret = rte_eth_dev_filter_ctrl(res->port_id,
9217 RTE_ETH_FILTER_NTUPLE,
9221 ret = rte_eth_dev_filter_ctrl(res->port_id,
9222 RTE_ETH_FILTER_NTUPLE,
9223 RTE_ETH_FILTER_DELETE,
9226 printf("2tuple filter programming error: (%s)\n",
9231 cmdline_parse_token_string_t cmd_2tuple_filter_filter =
9232 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9233 filter, "2tuple_filter");
9234 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
9235 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9237 cmdline_parse_token_string_t cmd_2tuple_filter_ops =
9238 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9240 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
9241 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9242 dst_port, "dst_port");
9243 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
9244 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9245 dst_port_value, UINT16);
9246 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
9247 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9248 protocol, "protocol");
9249 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
9250 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9251 protocol_value, UINT8);
9252 cmdline_parse_token_string_t cmd_2tuple_filter_mask =
9253 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9255 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value =
9256 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9258 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags =
9259 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9260 tcp_flags, "tcp_flags");
9261 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value =
9262 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9263 tcp_flags_value, UINT8);
9264 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
9265 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9266 priority, "priority");
9267 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
9268 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9269 priority_value, UINT8);
9270 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
9271 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9273 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
9274 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9277 cmdline_parse_inst_t cmd_2tuple_filter = {
9278 .f = cmd_2tuple_filter_parsed,
9280 .help_str = "2tuple_filter <port_id> add|del dst_port <value> protocol "
9281 "<value> mask <value> tcp_flags <value> priority <value> queue "
9282 "<queue_id>: Add a 2tuple filter",
9284 (void *)&cmd_2tuple_filter_filter,
9285 (void *)&cmd_2tuple_filter_port_id,
9286 (void *)&cmd_2tuple_filter_ops,
9287 (void *)&cmd_2tuple_filter_dst_port,
9288 (void *)&cmd_2tuple_filter_dst_port_value,
9289 (void *)&cmd_2tuple_filter_protocol,
9290 (void *)&cmd_2tuple_filter_protocol_value,
9291 (void *)&cmd_2tuple_filter_mask,
9292 (void *)&cmd_2tuple_filter_mask_value,
9293 (void *)&cmd_2tuple_filter_tcp_flags,
9294 (void *)&cmd_2tuple_filter_tcp_flags_value,
9295 (void *)&cmd_2tuple_filter_priority,
9296 (void *)&cmd_2tuple_filter_priority_value,
9297 (void *)&cmd_2tuple_filter_queue,
9298 (void *)&cmd_2tuple_filter_queue_id,
9303 /* *** ADD/REMOVE A 5tuple FILTER *** */
9304 struct cmd_5tuple_filter_result {
9305 cmdline_fixed_string_t filter;
9307 cmdline_fixed_string_t ops;
9308 cmdline_fixed_string_t dst_ip;
9309 cmdline_ipaddr_t dst_ip_value;
9310 cmdline_fixed_string_t src_ip;
9311 cmdline_ipaddr_t src_ip_value;
9312 cmdline_fixed_string_t dst_port;
9313 uint16_t dst_port_value;
9314 cmdline_fixed_string_t src_port;
9315 uint16_t src_port_value;
9316 cmdline_fixed_string_t protocol;
9317 uint8_t protocol_value;
9318 cmdline_fixed_string_t mask;
9320 cmdline_fixed_string_t tcp_flags;
9321 uint8_t tcp_flags_value;
9322 cmdline_fixed_string_t priority;
9323 uint8_t priority_value;
9324 cmdline_fixed_string_t queue;
9329 cmd_5tuple_filter_parsed(void *parsed_result,
9330 __attribute__((unused)) struct cmdline *cl,
9331 __attribute__((unused)) void *data)
9333 struct rte_eth_ntuple_filter filter;
9334 struct cmd_5tuple_filter_result *res = parsed_result;
9337 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
9339 printf("ntuple filter is not supported on port %u.\n",
9344 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
9346 filter.flags = RTE_5TUPLE_FLAGS;
9347 filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0;
9348 filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0;
9349 filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0;
9350 filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
9351 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
9352 filter.proto = res->protocol_value;
9353 filter.priority = res->priority_value;
9354 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
9355 printf("nonzero tcp_flags is only meaningful"
9356 " when protocol is TCP.\n");
9359 if (res->tcp_flags_value > TCP_FLAG_ALL) {
9360 printf("invalid TCP flags.\n");
9364 if (res->tcp_flags_value != 0) {
9365 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
9366 filter.tcp_flags = res->tcp_flags_value;
9369 if (res->dst_ip_value.family == AF_INET)
9370 /* no need to convert, already big endian. */
9371 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
9373 if (filter.dst_ip_mask == 0) {
9374 printf("can not support ipv6 involved compare.\n");
9380 if (res->src_ip_value.family == AF_INET)
9381 /* no need to convert, already big endian. */
9382 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
9384 if (filter.src_ip_mask == 0) {
9385 printf("can not support ipv6 involved compare.\n");
9390 /* need convert to big endian. */
9391 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
9392 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
9393 filter.queue = res->queue_id;
9395 if (!strcmp(res->ops, "add"))
9396 ret = rte_eth_dev_filter_ctrl(res->port_id,
9397 RTE_ETH_FILTER_NTUPLE,
9401 ret = rte_eth_dev_filter_ctrl(res->port_id,
9402 RTE_ETH_FILTER_NTUPLE,
9403 RTE_ETH_FILTER_DELETE,
9406 printf("5tuple filter programming error: (%s)\n",
9410 cmdline_parse_token_string_t cmd_5tuple_filter_filter =
9411 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9412 filter, "5tuple_filter");
9413 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
9414 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9416 cmdline_parse_token_string_t cmd_5tuple_filter_ops =
9417 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9419 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
9420 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9422 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
9423 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
9425 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
9426 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9428 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
9429 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
9431 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
9432 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9433 dst_port, "dst_port");
9434 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
9435 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9436 dst_port_value, UINT16);
9437 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
9438 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9439 src_port, "src_port");
9440 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
9441 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9442 src_port_value, UINT16);
9443 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
9444 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9445 protocol, "protocol");
9446 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
9447 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9448 protocol_value, UINT8);
9449 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
9450 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9452 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
9453 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9455 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags =
9456 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9457 tcp_flags, "tcp_flags");
9458 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value =
9459 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9460 tcp_flags_value, UINT8);
9461 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
9462 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9463 priority, "priority");
9464 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
9465 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9466 priority_value, UINT8);
9467 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
9468 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9470 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
9471 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9474 cmdline_parse_inst_t cmd_5tuple_filter = {
9475 .f = cmd_5tuple_filter_parsed,
9477 .help_str = "5tuple_filter <port_id> add|del dst_ip <value> "
9478 "src_ip <value> dst_port <value> src_port <value> "
9479 "protocol <value> mask <value> tcp_flags <value> "
9480 "priority <value> queue <queue_id>: Add/Del a 5tuple filter",
9482 (void *)&cmd_5tuple_filter_filter,
9483 (void *)&cmd_5tuple_filter_port_id,
9484 (void *)&cmd_5tuple_filter_ops,
9485 (void *)&cmd_5tuple_filter_dst_ip,
9486 (void *)&cmd_5tuple_filter_dst_ip_value,
9487 (void *)&cmd_5tuple_filter_src_ip,
9488 (void *)&cmd_5tuple_filter_src_ip_value,
9489 (void *)&cmd_5tuple_filter_dst_port,
9490 (void *)&cmd_5tuple_filter_dst_port_value,
9491 (void *)&cmd_5tuple_filter_src_port,
9492 (void *)&cmd_5tuple_filter_src_port_value,
9493 (void *)&cmd_5tuple_filter_protocol,
9494 (void *)&cmd_5tuple_filter_protocol_value,
9495 (void *)&cmd_5tuple_filter_mask,
9496 (void *)&cmd_5tuple_filter_mask_value,
9497 (void *)&cmd_5tuple_filter_tcp_flags,
9498 (void *)&cmd_5tuple_filter_tcp_flags_value,
9499 (void *)&cmd_5tuple_filter_priority,
9500 (void *)&cmd_5tuple_filter_priority_value,
9501 (void *)&cmd_5tuple_filter_queue,
9502 (void *)&cmd_5tuple_filter_queue_id,
9507 /* *** ADD/REMOVE A flex FILTER *** */
9508 struct cmd_flex_filter_result {
9509 cmdline_fixed_string_t filter;
9510 cmdline_fixed_string_t ops;
9512 cmdline_fixed_string_t len;
9514 cmdline_fixed_string_t bytes;
9515 cmdline_fixed_string_t bytes_value;
9516 cmdline_fixed_string_t mask;
9517 cmdline_fixed_string_t mask_value;
9518 cmdline_fixed_string_t priority;
9519 uint8_t priority_value;
9520 cmdline_fixed_string_t queue;
9524 static int xdigit2val(unsigned char c)
9529 else if (isupper(c))
9537 cmd_flex_filter_parsed(void *parsed_result,
9538 __attribute__((unused)) struct cmdline *cl,
9539 __attribute__((unused)) void *data)
9542 struct rte_eth_flex_filter filter;
9543 struct cmd_flex_filter_result *res = parsed_result;
9544 char *bytes_ptr, *mask_ptr;
9545 uint16_t len, i, j = 0;
9550 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) {
9551 printf("the len exceed the max length 128\n");
9554 memset(&filter, 0, sizeof(struct rte_eth_flex_filter));
9555 filter.len = res->len_value;
9556 filter.priority = res->priority_value;
9557 filter.queue = res->queue_id;
9558 bytes_ptr = res->bytes_value;
9559 mask_ptr = res->mask_value;
9561 /* translate bytes string to array. */
9562 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
9563 (bytes_ptr[1] == 'X')))
9565 len = strnlen(bytes_ptr, res->len_value * 2);
9566 if (len == 0 || (len % 8 != 0)) {
9567 printf("please check len and bytes input\n");
9570 for (i = 0; i < len; i++) {
9572 if (isxdigit(c) == 0) {
9573 /* invalid characters. */
9574 printf("invalid input\n");
9577 val = xdigit2val(c);
9580 filter.bytes[j] = byte;
9581 printf("bytes[%d]:%02x ", j, filter.bytes[j]);
9588 /* translate mask string to uint8_t array. */
9589 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
9590 (mask_ptr[1] == 'X')))
9592 len = strnlen(mask_ptr, (res->len_value + 3) / 4);
9594 printf("invalid input\n");
9599 for (i = 0; i < len; i++) {
9601 if (isxdigit(c) == 0) {
9602 /* invalid characters. */
9603 printf("invalid input\n");
9606 val = xdigit2val(c);
9609 filter.mask[j] = byte;
9610 printf("mask[%d]:%02x ", j, filter.mask[j]);
9618 if (!strcmp(res->ops, "add"))
9619 ret = rte_eth_dev_filter_ctrl(res->port_id,
9620 RTE_ETH_FILTER_FLEXIBLE,
9624 ret = rte_eth_dev_filter_ctrl(res->port_id,
9625 RTE_ETH_FILTER_FLEXIBLE,
9626 RTE_ETH_FILTER_DELETE,
9630 printf("flex filter setting error: (%s)\n", strerror(-ret));
9633 cmdline_parse_token_string_t cmd_flex_filter_filter =
9634 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9635 filter, "flex_filter");
9636 cmdline_parse_token_num_t cmd_flex_filter_port_id =
9637 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
9639 cmdline_parse_token_string_t cmd_flex_filter_ops =
9640 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9642 cmdline_parse_token_string_t cmd_flex_filter_len =
9643 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9645 cmdline_parse_token_num_t cmd_flex_filter_len_value =
9646 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
9648 cmdline_parse_token_string_t cmd_flex_filter_bytes =
9649 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9651 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
9652 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9654 cmdline_parse_token_string_t cmd_flex_filter_mask =
9655 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9657 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
9658 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9660 cmdline_parse_token_string_t cmd_flex_filter_priority =
9661 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9662 priority, "priority");
9663 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
9664 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
9665 priority_value, UINT8);
9666 cmdline_parse_token_string_t cmd_flex_filter_queue =
9667 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9669 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
9670 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
9672 cmdline_parse_inst_t cmd_flex_filter = {
9673 .f = cmd_flex_filter_parsed,
9675 .help_str = "flex_filter <port_id> add|del len <value> bytes "
9676 "<value> mask <value> priority <value> queue <queue_id>: "
9677 "Add/Del a flex filter",
9679 (void *)&cmd_flex_filter_filter,
9680 (void *)&cmd_flex_filter_port_id,
9681 (void *)&cmd_flex_filter_ops,
9682 (void *)&cmd_flex_filter_len,
9683 (void *)&cmd_flex_filter_len_value,
9684 (void *)&cmd_flex_filter_bytes,
9685 (void *)&cmd_flex_filter_bytes_value,
9686 (void *)&cmd_flex_filter_mask,
9687 (void *)&cmd_flex_filter_mask_value,
9688 (void *)&cmd_flex_filter_priority,
9689 (void *)&cmd_flex_filter_priority_value,
9690 (void *)&cmd_flex_filter_queue,
9691 (void *)&cmd_flex_filter_queue_id,
9696 /* *** Filters Control *** */
9698 /* *** deal with ethertype filter *** */
9699 struct cmd_ethertype_filter_result {
9700 cmdline_fixed_string_t filter;
9702 cmdline_fixed_string_t ops;
9703 cmdline_fixed_string_t mac;
9704 struct ether_addr mac_addr;
9705 cmdline_fixed_string_t ethertype;
9706 uint16_t ethertype_value;
9707 cmdline_fixed_string_t drop;
9708 cmdline_fixed_string_t queue;
9712 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
9713 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9714 filter, "ethertype_filter");
9715 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
9716 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
9718 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
9719 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9721 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
9722 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9723 mac, "mac_addr#mac_ignr");
9724 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
9725 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
9727 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
9728 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9729 ethertype, "ethertype");
9730 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
9731 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
9732 ethertype_value, UINT16);
9733 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
9734 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9736 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
9737 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9739 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
9740 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
9744 cmd_ethertype_filter_parsed(void *parsed_result,
9745 __attribute__((unused)) struct cmdline *cl,
9746 __attribute__((unused)) void *data)
9748 struct cmd_ethertype_filter_result *res = parsed_result;
9749 struct rte_eth_ethertype_filter filter;
9752 ret = rte_eth_dev_filter_supported(res->port_id,
9753 RTE_ETH_FILTER_ETHERTYPE);
9755 printf("ethertype filter is not supported on port %u.\n",
9760 memset(&filter, 0, sizeof(filter));
9761 if (!strcmp(res->mac, "mac_addr")) {
9762 filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
9763 rte_memcpy(&filter.mac_addr, &res->mac_addr,
9764 sizeof(struct ether_addr));
9766 if (!strcmp(res->drop, "drop"))
9767 filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
9768 filter.ether_type = res->ethertype_value;
9769 filter.queue = res->queue_id;
9771 if (!strcmp(res->ops, "add"))
9772 ret = rte_eth_dev_filter_ctrl(res->port_id,
9773 RTE_ETH_FILTER_ETHERTYPE,
9777 ret = rte_eth_dev_filter_ctrl(res->port_id,
9778 RTE_ETH_FILTER_ETHERTYPE,
9779 RTE_ETH_FILTER_DELETE,
9782 printf("ethertype filter programming error: (%s)\n",
9786 cmdline_parse_inst_t cmd_ethertype_filter = {
9787 .f = cmd_ethertype_filter_parsed,
9789 .help_str = "ethertype_filter <port_id> add|del mac_addr|mac_ignr "
9790 "<mac_addr> ethertype <value> drop|fw queue <queue_id>: "
9791 "Add or delete an ethertype filter entry",
9793 (void *)&cmd_ethertype_filter_filter,
9794 (void *)&cmd_ethertype_filter_port_id,
9795 (void *)&cmd_ethertype_filter_ops,
9796 (void *)&cmd_ethertype_filter_mac,
9797 (void *)&cmd_ethertype_filter_mac_addr,
9798 (void *)&cmd_ethertype_filter_ethertype,
9799 (void *)&cmd_ethertype_filter_ethertype_value,
9800 (void *)&cmd_ethertype_filter_drop,
9801 (void *)&cmd_ethertype_filter_queue,
9802 (void *)&cmd_ethertype_filter_queue_id,
9807 /* *** deal with flow director filter *** */
9808 struct cmd_flow_director_result {
9809 cmdline_fixed_string_t flow_director_filter;
9811 cmdline_fixed_string_t mode;
9812 cmdline_fixed_string_t mode_value;
9813 cmdline_fixed_string_t ops;
9814 cmdline_fixed_string_t flow;
9815 cmdline_fixed_string_t flow_type;
9816 cmdline_fixed_string_t ether;
9817 uint16_t ether_type;
9818 cmdline_fixed_string_t src;
9819 cmdline_ipaddr_t ip_src;
9821 cmdline_fixed_string_t dst;
9822 cmdline_ipaddr_t ip_dst;
9824 cmdline_fixed_string_t verify_tag;
9825 uint32_t verify_tag_value;
9826 cmdline_ipaddr_t tos;
9828 cmdline_ipaddr_t proto;
9829 uint8_t proto_value;
9830 cmdline_ipaddr_t ttl;
9832 cmdline_fixed_string_t vlan;
9833 uint16_t vlan_value;
9834 cmdline_fixed_string_t flexbytes;
9835 cmdline_fixed_string_t flexbytes_value;
9836 cmdline_fixed_string_t pf_vf;
9837 cmdline_fixed_string_t drop;
9838 cmdline_fixed_string_t queue;
9840 cmdline_fixed_string_t fd_id;
9841 uint32_t fd_id_value;
9842 cmdline_fixed_string_t mac;
9843 struct ether_addr mac_addr;
9844 cmdline_fixed_string_t tunnel;
9845 cmdline_fixed_string_t tunnel_type;
9846 cmdline_fixed_string_t tunnel_id;
9847 uint32_t tunnel_id_value;
9851 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
9854 const char *p, *p0 = q_arg;
9856 unsigned long int_fld;
9857 char *str_fld[max_num];
9862 p = strchr(p0, '(');
9866 p0 = strchr(p, ')');
9871 if (size >= sizeof(s))
9874 snprintf(s, sizeof(s), "%.*s", size, p);
9875 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
9876 if (ret < 0 || ret > max_num)
9878 for (i = 0; i < ret; i++) {
9880 int_fld = strtoul(str_fld[i], &end, 0);
9881 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
9883 flexbytes[i] = (uint8_t)int_fld;
9889 str2flowtype(char *string)
9892 static const struct {
9895 } flowtype_str[] = {
9896 {"raw", RTE_ETH_FLOW_RAW},
9897 {"ipv4", RTE_ETH_FLOW_IPV4},
9898 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
9899 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
9900 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
9901 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
9902 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
9903 {"ipv6", RTE_ETH_FLOW_IPV6},
9904 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
9905 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
9906 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
9907 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
9908 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
9909 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
9912 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
9913 if (!strcmp(flowtype_str[i].str, string))
9914 return flowtype_str[i].type;
9917 if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64)
9918 return (uint16_t)atoi(string);
9920 return RTE_ETH_FLOW_UNKNOWN;
9923 static enum rte_eth_fdir_tunnel_type
9924 str2fdir_tunneltype(char *string)
9928 static const struct {
9930 enum rte_eth_fdir_tunnel_type type;
9931 } tunneltype_str[] = {
9932 {"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE},
9933 {"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN},
9936 for (i = 0; i < RTE_DIM(tunneltype_str); i++) {
9937 if (!strcmp(tunneltype_str[i].str, string))
9938 return tunneltype_str[i].type;
9940 return RTE_FDIR_TUNNEL_TYPE_UNKNOWN;
9943 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
9945 if ((ip_addr).family == AF_INET) \
9946 (ip) = (ip_addr).addr.ipv4.s_addr; \
9948 printf("invalid parameter.\n"); \
9953 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
9955 if ((ip_addr).family == AF_INET6) \
9957 &((ip_addr).addr.ipv6), \
9958 sizeof(struct in6_addr)); \
9960 printf("invalid parameter.\n"); \
9966 cmd_flow_director_filter_parsed(void *parsed_result,
9967 __attribute__((unused)) struct cmdline *cl,
9968 __attribute__((unused)) void *data)
9970 struct cmd_flow_director_result *res = parsed_result;
9971 struct rte_eth_fdir_filter entry;
9972 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
9974 unsigned long vf_id;
9977 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
9979 printf("flow director is not supported on port %u.\n",
9983 memset(flexbytes, 0, sizeof(flexbytes));
9984 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
9986 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
9987 if (strcmp(res->mode_value, "MAC-VLAN")) {
9988 printf("Please set mode to MAC-VLAN.\n");
9991 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
9992 if (strcmp(res->mode_value, "Tunnel")) {
9993 printf("Please set mode to Tunnel.\n");
9997 if (strcmp(res->mode_value, "IP")) {
9998 printf("Please set mode to IP.\n");
10001 entry.input.flow_type = str2flowtype(res->flow_type);
10004 ret = parse_flexbytes(res->flexbytes_value,
10006 RTE_ETH_FDIR_MAX_FLEXLEN);
10008 printf("error: Cannot parse flexbytes input.\n");
10012 switch (entry.input.flow_type) {
10013 case RTE_ETH_FLOW_FRAG_IPV4:
10014 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
10015 entry.input.flow.ip4_flow.proto = res->proto_value;
10017 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
10018 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
10019 IPV4_ADDR_TO_UINT(res->ip_dst,
10020 entry.input.flow.ip4_flow.dst_ip);
10021 IPV4_ADDR_TO_UINT(res->ip_src,
10022 entry.input.flow.ip4_flow.src_ip);
10023 entry.input.flow.ip4_flow.tos = res->tos_value;
10024 entry.input.flow.ip4_flow.ttl = res->ttl_value;
10025 /* need convert to big endian. */
10026 entry.input.flow.udp4_flow.dst_port =
10027 rte_cpu_to_be_16(res->port_dst);
10028 entry.input.flow.udp4_flow.src_port =
10029 rte_cpu_to_be_16(res->port_src);
10031 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
10032 IPV4_ADDR_TO_UINT(res->ip_dst,
10033 entry.input.flow.sctp4_flow.ip.dst_ip);
10034 IPV4_ADDR_TO_UINT(res->ip_src,
10035 entry.input.flow.sctp4_flow.ip.src_ip);
10036 entry.input.flow.ip4_flow.tos = res->tos_value;
10037 entry.input.flow.ip4_flow.ttl = res->ttl_value;
10038 /* need convert to big endian. */
10039 entry.input.flow.sctp4_flow.dst_port =
10040 rte_cpu_to_be_16(res->port_dst);
10041 entry.input.flow.sctp4_flow.src_port =
10042 rte_cpu_to_be_16(res->port_src);
10043 entry.input.flow.sctp4_flow.verify_tag =
10044 rte_cpu_to_be_32(res->verify_tag_value);
10046 case RTE_ETH_FLOW_FRAG_IPV6:
10047 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
10048 entry.input.flow.ipv6_flow.proto = res->proto_value;
10050 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
10051 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
10052 IPV6_ADDR_TO_ARRAY(res->ip_dst,
10053 entry.input.flow.ipv6_flow.dst_ip);
10054 IPV6_ADDR_TO_ARRAY(res->ip_src,
10055 entry.input.flow.ipv6_flow.src_ip);
10056 entry.input.flow.ipv6_flow.tc = res->tos_value;
10057 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
10058 /* need convert to big endian. */
10059 entry.input.flow.udp6_flow.dst_port =
10060 rte_cpu_to_be_16(res->port_dst);
10061 entry.input.flow.udp6_flow.src_port =
10062 rte_cpu_to_be_16(res->port_src);
10064 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
10065 IPV6_ADDR_TO_ARRAY(res->ip_dst,
10066 entry.input.flow.sctp6_flow.ip.dst_ip);
10067 IPV6_ADDR_TO_ARRAY(res->ip_src,
10068 entry.input.flow.sctp6_flow.ip.src_ip);
10069 entry.input.flow.ipv6_flow.tc = res->tos_value;
10070 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
10071 /* need convert to big endian. */
10072 entry.input.flow.sctp6_flow.dst_port =
10073 rte_cpu_to_be_16(res->port_dst);
10074 entry.input.flow.sctp6_flow.src_port =
10075 rte_cpu_to_be_16(res->port_src);
10076 entry.input.flow.sctp6_flow.verify_tag =
10077 rte_cpu_to_be_32(res->verify_tag_value);
10079 case RTE_ETH_FLOW_L2_PAYLOAD:
10080 entry.input.flow.l2_flow.ether_type =
10081 rte_cpu_to_be_16(res->ether_type);
10087 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN)
10088 rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr,
10090 sizeof(struct ether_addr));
10092 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
10093 rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr,
10095 sizeof(struct ether_addr));
10096 entry.input.flow.tunnel_flow.tunnel_type =
10097 str2fdir_tunneltype(res->tunnel_type);
10098 entry.input.flow.tunnel_flow.tunnel_id =
10099 rte_cpu_to_be_32(res->tunnel_id_value);
10102 rte_memcpy(entry.input.flow_ext.flexbytes,
10104 RTE_ETH_FDIR_MAX_FLEXLEN);
10106 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
10108 entry.action.flex_off = 0; /*use 0 by default */
10109 if (!strcmp(res->drop, "drop"))
10110 entry.action.behavior = RTE_ETH_FDIR_REJECT;
10112 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
10114 if (fdir_conf.mode != RTE_FDIR_MODE_PERFECT_MAC_VLAN &&
10115 fdir_conf.mode != RTE_FDIR_MODE_PERFECT_TUNNEL) {
10116 if (!strcmp(res->pf_vf, "pf"))
10117 entry.input.flow_ext.is_vf = 0;
10118 else if (!strncmp(res->pf_vf, "vf", 2)) {
10119 struct rte_eth_dev_info dev_info;
10121 memset(&dev_info, 0, sizeof(dev_info));
10122 rte_eth_dev_info_get(res->port_id, &dev_info);
10124 vf_id = strtoul(res->pf_vf + 2, &end, 10);
10125 if (errno != 0 || *end != '\0' ||
10126 vf_id >= dev_info.max_vfs) {
10127 printf("invalid parameter %s.\n", res->pf_vf);
10130 entry.input.flow_ext.is_vf = 1;
10131 entry.input.flow_ext.dst_id = (uint16_t)vf_id;
10133 printf("invalid parameter %s.\n", res->pf_vf);
10138 /* set to report FD ID by default */
10139 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
10140 entry.action.rx_queue = res->queue_id;
10141 entry.soft_id = res->fd_id_value;
10142 if (!strcmp(res->ops, "add"))
10143 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10144 RTE_ETH_FILTER_ADD, &entry);
10145 else if (!strcmp(res->ops, "del"))
10146 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10147 RTE_ETH_FILTER_DELETE, &entry);
10149 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10150 RTE_ETH_FILTER_UPDATE, &entry);
10152 printf("flow director programming error: (%s)\n",
10156 cmdline_parse_token_string_t cmd_flow_director_filter =
10157 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10158 flow_director_filter, "flow_director_filter");
10159 cmdline_parse_token_num_t cmd_flow_director_port_id =
10160 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10162 cmdline_parse_token_string_t cmd_flow_director_ops =
10163 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10164 ops, "add#del#update");
10165 cmdline_parse_token_string_t cmd_flow_director_flow =
10166 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10168 cmdline_parse_token_string_t cmd_flow_director_flow_type =
10169 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10170 flow_type, "ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
10171 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload");
10172 cmdline_parse_token_string_t cmd_flow_director_ether =
10173 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10175 cmdline_parse_token_num_t cmd_flow_director_ether_type =
10176 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10177 ether_type, UINT16);
10178 cmdline_parse_token_string_t cmd_flow_director_src =
10179 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10181 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
10182 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
10184 cmdline_parse_token_num_t cmd_flow_director_port_src =
10185 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10187 cmdline_parse_token_string_t cmd_flow_director_dst =
10188 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10190 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
10191 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
10193 cmdline_parse_token_num_t cmd_flow_director_port_dst =
10194 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10196 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
10197 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10198 verify_tag, "verify_tag");
10199 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
10200 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10201 verify_tag_value, UINT32);
10202 cmdline_parse_token_string_t cmd_flow_director_tos =
10203 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10205 cmdline_parse_token_num_t cmd_flow_director_tos_value =
10206 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10208 cmdline_parse_token_string_t cmd_flow_director_proto =
10209 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10211 cmdline_parse_token_num_t cmd_flow_director_proto_value =
10212 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10213 proto_value, UINT8);
10214 cmdline_parse_token_string_t cmd_flow_director_ttl =
10215 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10217 cmdline_parse_token_num_t cmd_flow_director_ttl_value =
10218 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10220 cmdline_parse_token_string_t cmd_flow_director_vlan =
10221 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10223 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
10224 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10225 vlan_value, UINT16);
10226 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
10227 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10228 flexbytes, "flexbytes");
10229 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
10230 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10231 flexbytes_value, NULL);
10232 cmdline_parse_token_string_t cmd_flow_director_drop =
10233 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10235 cmdline_parse_token_string_t cmd_flow_director_pf_vf =
10236 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10238 cmdline_parse_token_string_t cmd_flow_director_queue =
10239 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10241 cmdline_parse_token_num_t cmd_flow_director_queue_id =
10242 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10244 cmdline_parse_token_string_t cmd_flow_director_fd_id =
10245 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10247 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
10248 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10249 fd_id_value, UINT32);
10251 cmdline_parse_token_string_t cmd_flow_director_mode =
10252 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10254 cmdline_parse_token_string_t cmd_flow_director_mode_ip =
10255 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10257 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan =
10258 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10259 mode_value, "MAC-VLAN");
10260 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel =
10261 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10262 mode_value, "Tunnel");
10263 cmdline_parse_token_string_t cmd_flow_director_mac =
10264 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10266 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr =
10267 TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result,
10269 cmdline_parse_token_string_t cmd_flow_director_tunnel =
10270 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10272 cmdline_parse_token_string_t cmd_flow_director_tunnel_type =
10273 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10274 tunnel_type, "NVGRE#VxLAN");
10275 cmdline_parse_token_string_t cmd_flow_director_tunnel_id =
10276 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10277 tunnel_id, "tunnel-id");
10278 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value =
10279 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10280 tunnel_id_value, UINT32);
10282 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
10283 .f = cmd_flow_director_filter_parsed,
10285 .help_str = "flow_director_filter <port_id> mode IP add|del|update flow"
10286 " ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
10287 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
10288 "l2_payload src <src_ip> dst <dst_ip> tos <tos_value> "
10289 "proto <proto_value> ttl <ttl_value> vlan <vlan_value> "
10290 "flexbytes <flexbyte_values> drop|fw <pf_vf> queue <queue_id> "
10291 "fd_id <fd_id_value>: "
10292 "Add or delete an ip flow director entry on NIC",
10294 (void *)&cmd_flow_director_filter,
10295 (void *)&cmd_flow_director_port_id,
10296 (void *)&cmd_flow_director_mode,
10297 (void *)&cmd_flow_director_mode_ip,
10298 (void *)&cmd_flow_director_ops,
10299 (void *)&cmd_flow_director_flow,
10300 (void *)&cmd_flow_director_flow_type,
10301 (void *)&cmd_flow_director_src,
10302 (void *)&cmd_flow_director_ip_src,
10303 (void *)&cmd_flow_director_dst,
10304 (void *)&cmd_flow_director_ip_dst,
10305 (void *)&cmd_flow_director_tos,
10306 (void *)&cmd_flow_director_tos_value,
10307 (void *)&cmd_flow_director_proto,
10308 (void *)&cmd_flow_director_proto_value,
10309 (void *)&cmd_flow_director_ttl,
10310 (void *)&cmd_flow_director_ttl_value,
10311 (void *)&cmd_flow_director_vlan,
10312 (void *)&cmd_flow_director_vlan_value,
10313 (void *)&cmd_flow_director_flexbytes,
10314 (void *)&cmd_flow_director_flexbytes_value,
10315 (void *)&cmd_flow_director_drop,
10316 (void *)&cmd_flow_director_pf_vf,
10317 (void *)&cmd_flow_director_queue,
10318 (void *)&cmd_flow_director_queue_id,
10319 (void *)&cmd_flow_director_fd_id,
10320 (void *)&cmd_flow_director_fd_id_value,
10325 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
10326 .f = cmd_flow_director_filter_parsed,
10328 .help_str = "flow_director_filter ... : Add or delete an udp/tcp flow "
10329 "director entry on NIC",
10331 (void *)&cmd_flow_director_filter,
10332 (void *)&cmd_flow_director_port_id,
10333 (void *)&cmd_flow_director_mode,
10334 (void *)&cmd_flow_director_mode_ip,
10335 (void *)&cmd_flow_director_ops,
10336 (void *)&cmd_flow_director_flow,
10337 (void *)&cmd_flow_director_flow_type,
10338 (void *)&cmd_flow_director_src,
10339 (void *)&cmd_flow_director_ip_src,
10340 (void *)&cmd_flow_director_port_src,
10341 (void *)&cmd_flow_director_dst,
10342 (void *)&cmd_flow_director_ip_dst,
10343 (void *)&cmd_flow_director_port_dst,
10344 (void *)&cmd_flow_director_tos,
10345 (void *)&cmd_flow_director_tos_value,
10346 (void *)&cmd_flow_director_ttl,
10347 (void *)&cmd_flow_director_ttl_value,
10348 (void *)&cmd_flow_director_vlan,
10349 (void *)&cmd_flow_director_vlan_value,
10350 (void *)&cmd_flow_director_flexbytes,
10351 (void *)&cmd_flow_director_flexbytes_value,
10352 (void *)&cmd_flow_director_drop,
10353 (void *)&cmd_flow_director_pf_vf,
10354 (void *)&cmd_flow_director_queue,
10355 (void *)&cmd_flow_director_queue_id,
10356 (void *)&cmd_flow_director_fd_id,
10357 (void *)&cmd_flow_director_fd_id_value,
10362 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
10363 .f = cmd_flow_director_filter_parsed,
10365 .help_str = "flow_director_filter ... : Add or delete a sctp flow "
10366 "director entry on NIC",
10368 (void *)&cmd_flow_director_filter,
10369 (void *)&cmd_flow_director_port_id,
10370 (void *)&cmd_flow_director_mode,
10371 (void *)&cmd_flow_director_mode_ip,
10372 (void *)&cmd_flow_director_ops,
10373 (void *)&cmd_flow_director_flow,
10374 (void *)&cmd_flow_director_flow_type,
10375 (void *)&cmd_flow_director_src,
10376 (void *)&cmd_flow_director_ip_src,
10377 (void *)&cmd_flow_director_port_dst,
10378 (void *)&cmd_flow_director_dst,
10379 (void *)&cmd_flow_director_ip_dst,
10380 (void *)&cmd_flow_director_port_dst,
10381 (void *)&cmd_flow_director_verify_tag,
10382 (void *)&cmd_flow_director_verify_tag_value,
10383 (void *)&cmd_flow_director_tos,
10384 (void *)&cmd_flow_director_tos_value,
10385 (void *)&cmd_flow_director_ttl,
10386 (void *)&cmd_flow_director_ttl_value,
10387 (void *)&cmd_flow_director_vlan,
10388 (void *)&cmd_flow_director_vlan_value,
10389 (void *)&cmd_flow_director_flexbytes,
10390 (void *)&cmd_flow_director_flexbytes_value,
10391 (void *)&cmd_flow_director_drop,
10392 (void *)&cmd_flow_director_pf_vf,
10393 (void *)&cmd_flow_director_queue,
10394 (void *)&cmd_flow_director_queue_id,
10395 (void *)&cmd_flow_director_fd_id,
10396 (void *)&cmd_flow_director_fd_id_value,
10401 cmdline_parse_inst_t cmd_add_del_l2_flow_director = {
10402 .f = cmd_flow_director_filter_parsed,
10404 .help_str = "flow_director_filter ... : Add or delete a L2 flow "
10405 "director entry on NIC",
10407 (void *)&cmd_flow_director_filter,
10408 (void *)&cmd_flow_director_port_id,
10409 (void *)&cmd_flow_director_mode,
10410 (void *)&cmd_flow_director_mode_ip,
10411 (void *)&cmd_flow_director_ops,
10412 (void *)&cmd_flow_director_flow,
10413 (void *)&cmd_flow_director_flow_type,
10414 (void *)&cmd_flow_director_ether,
10415 (void *)&cmd_flow_director_ether_type,
10416 (void *)&cmd_flow_director_flexbytes,
10417 (void *)&cmd_flow_director_flexbytes_value,
10418 (void *)&cmd_flow_director_drop,
10419 (void *)&cmd_flow_director_pf_vf,
10420 (void *)&cmd_flow_director_queue,
10421 (void *)&cmd_flow_director_queue_id,
10422 (void *)&cmd_flow_director_fd_id,
10423 (void *)&cmd_flow_director_fd_id_value,
10428 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = {
10429 .f = cmd_flow_director_filter_parsed,
10431 .help_str = "flow_director_filter ... : Add or delete a MAC VLAN flow "
10432 "director entry on NIC",
10434 (void *)&cmd_flow_director_filter,
10435 (void *)&cmd_flow_director_port_id,
10436 (void *)&cmd_flow_director_mode,
10437 (void *)&cmd_flow_director_mode_mac_vlan,
10438 (void *)&cmd_flow_director_ops,
10439 (void *)&cmd_flow_director_mac,
10440 (void *)&cmd_flow_director_mac_addr,
10441 (void *)&cmd_flow_director_vlan,
10442 (void *)&cmd_flow_director_vlan_value,
10443 (void *)&cmd_flow_director_flexbytes,
10444 (void *)&cmd_flow_director_flexbytes_value,
10445 (void *)&cmd_flow_director_drop,
10446 (void *)&cmd_flow_director_queue,
10447 (void *)&cmd_flow_director_queue_id,
10448 (void *)&cmd_flow_director_fd_id,
10449 (void *)&cmd_flow_director_fd_id_value,
10454 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = {
10455 .f = cmd_flow_director_filter_parsed,
10457 .help_str = "flow_director_filter ... : Add or delete a tunnel flow "
10458 "director entry on NIC",
10460 (void *)&cmd_flow_director_filter,
10461 (void *)&cmd_flow_director_port_id,
10462 (void *)&cmd_flow_director_mode,
10463 (void *)&cmd_flow_director_mode_tunnel,
10464 (void *)&cmd_flow_director_ops,
10465 (void *)&cmd_flow_director_mac,
10466 (void *)&cmd_flow_director_mac_addr,
10467 (void *)&cmd_flow_director_vlan,
10468 (void *)&cmd_flow_director_vlan_value,
10469 (void *)&cmd_flow_director_tunnel,
10470 (void *)&cmd_flow_director_tunnel_type,
10471 (void *)&cmd_flow_director_tunnel_id,
10472 (void *)&cmd_flow_director_tunnel_id_value,
10473 (void *)&cmd_flow_director_flexbytes,
10474 (void *)&cmd_flow_director_flexbytes_value,
10475 (void *)&cmd_flow_director_drop,
10476 (void *)&cmd_flow_director_queue,
10477 (void *)&cmd_flow_director_queue_id,
10478 (void *)&cmd_flow_director_fd_id,
10479 (void *)&cmd_flow_director_fd_id_value,
10484 struct cmd_flush_flow_director_result {
10485 cmdline_fixed_string_t flush_flow_director;
10489 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
10490 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
10491 flush_flow_director, "flush_flow_director");
10492 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
10493 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
10497 cmd_flush_flow_director_parsed(void *parsed_result,
10498 __attribute__((unused)) struct cmdline *cl,
10499 __attribute__((unused)) void *data)
10501 struct cmd_flow_director_result *res = parsed_result;
10504 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
10506 printf("flow director is not supported on port %u.\n",
10511 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10512 RTE_ETH_FILTER_FLUSH, NULL);
10514 printf("flow director table flushing error: (%s)\n",
10518 cmdline_parse_inst_t cmd_flush_flow_director = {
10519 .f = cmd_flush_flow_director_parsed,
10521 .help_str = "flush_flow_director <port_id>: "
10522 "Flush all flow director entries of a device on NIC",
10524 (void *)&cmd_flush_flow_director_flush,
10525 (void *)&cmd_flush_flow_director_port_id,
10530 /* *** deal with flow director mask *** */
10531 struct cmd_flow_director_mask_result {
10532 cmdline_fixed_string_t flow_director_mask;
10534 cmdline_fixed_string_t mode;
10535 cmdline_fixed_string_t mode_value;
10536 cmdline_fixed_string_t vlan;
10537 uint16_t vlan_mask;
10538 cmdline_fixed_string_t src_mask;
10539 cmdline_ipaddr_t ipv4_src;
10540 cmdline_ipaddr_t ipv6_src;
10542 cmdline_fixed_string_t dst_mask;
10543 cmdline_ipaddr_t ipv4_dst;
10544 cmdline_ipaddr_t ipv6_dst;
10546 cmdline_fixed_string_t mac;
10547 uint8_t mac_addr_byte_mask;
10548 cmdline_fixed_string_t tunnel_id;
10549 uint32_t tunnel_id_mask;
10550 cmdline_fixed_string_t tunnel_type;
10551 uint8_t tunnel_type_mask;
10555 cmd_flow_director_mask_parsed(void *parsed_result,
10556 __attribute__((unused)) struct cmdline *cl,
10557 __attribute__((unused)) void *data)
10559 struct cmd_flow_director_mask_result *res = parsed_result;
10560 struct rte_eth_fdir_masks *mask;
10561 struct rte_port *port;
10563 if (res->port_id > nb_ports) {
10564 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
10568 port = &ports[res->port_id];
10569 /** Check if the port is not started **/
10570 if (port->port_status != RTE_PORT_STOPPED) {
10571 printf("Please stop port %d first\n", res->port_id);
10575 mask = &port->dev_conf.fdir_conf.mask;
10577 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
10578 if (strcmp(res->mode_value, "MAC-VLAN")) {
10579 printf("Please set mode to MAC-VLAN.\n");
10583 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10584 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
10585 if (strcmp(res->mode_value, "Tunnel")) {
10586 printf("Please set mode to Tunnel.\n");
10590 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10591 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
10592 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
10593 mask->tunnel_type_mask = res->tunnel_type_mask;
10595 if (strcmp(res->mode_value, "IP")) {
10596 printf("Please set mode to IP.\n");
10600 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10601 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
10602 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
10603 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
10604 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
10605 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
10606 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
10609 cmd_reconfig_device_queue(res->port_id, 1, 1);
10612 cmdline_parse_token_string_t cmd_flow_director_mask =
10613 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10614 flow_director_mask, "flow_director_mask");
10615 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
10616 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10618 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
10619 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10621 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
10622 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10623 vlan_mask, UINT16);
10624 cmdline_parse_token_string_t cmd_flow_director_mask_src =
10625 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10626 src_mask, "src_mask");
10627 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
10628 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10630 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
10631 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10633 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
10634 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10636 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
10637 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10638 dst_mask, "dst_mask");
10639 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
10640 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10642 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
10643 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10645 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
10646 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10649 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
10650 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10652 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
10653 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10655 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
10656 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10657 mode_value, "MAC-VLAN");
10658 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
10659 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10660 mode_value, "Tunnel");
10661 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
10662 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10664 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
10665 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10666 mac_addr_byte_mask, UINT8);
10667 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
10668 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10669 tunnel_type, "tunnel-type");
10670 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
10671 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10672 tunnel_type_mask, UINT8);
10673 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
10674 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10675 tunnel_id, "tunnel-id");
10676 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
10677 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10678 tunnel_id_mask, UINT32);
10680 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
10681 .f = cmd_flow_director_mask_parsed,
10683 .help_str = "flow_director_mask ... : "
10684 "Set IP mode flow director's mask on NIC",
10686 (void *)&cmd_flow_director_mask,
10687 (void *)&cmd_flow_director_mask_port_id,
10688 (void *)&cmd_flow_director_mask_mode,
10689 (void *)&cmd_flow_director_mask_mode_ip,
10690 (void *)&cmd_flow_director_mask_vlan,
10691 (void *)&cmd_flow_director_mask_vlan_value,
10692 (void *)&cmd_flow_director_mask_src,
10693 (void *)&cmd_flow_director_mask_ipv4_src,
10694 (void *)&cmd_flow_director_mask_ipv6_src,
10695 (void *)&cmd_flow_director_mask_port_src,
10696 (void *)&cmd_flow_director_mask_dst,
10697 (void *)&cmd_flow_director_mask_ipv4_dst,
10698 (void *)&cmd_flow_director_mask_ipv6_dst,
10699 (void *)&cmd_flow_director_mask_port_dst,
10704 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
10705 .f = cmd_flow_director_mask_parsed,
10707 .help_str = "flow_director_mask ... : Set MAC VLAN mode "
10708 "flow director's mask on NIC",
10710 (void *)&cmd_flow_director_mask,
10711 (void *)&cmd_flow_director_mask_port_id,
10712 (void *)&cmd_flow_director_mask_mode,
10713 (void *)&cmd_flow_director_mask_mode_mac_vlan,
10714 (void *)&cmd_flow_director_mask_vlan,
10715 (void *)&cmd_flow_director_mask_vlan_value,
10720 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
10721 .f = cmd_flow_director_mask_parsed,
10723 .help_str = "flow_director_mask ... : Set tunnel mode "
10724 "flow director's mask on NIC",
10726 (void *)&cmd_flow_director_mask,
10727 (void *)&cmd_flow_director_mask_port_id,
10728 (void *)&cmd_flow_director_mask_mode,
10729 (void *)&cmd_flow_director_mask_mode_tunnel,
10730 (void *)&cmd_flow_director_mask_vlan,
10731 (void *)&cmd_flow_director_mask_vlan_value,
10732 (void *)&cmd_flow_director_mask_mac,
10733 (void *)&cmd_flow_director_mask_mac_value,
10734 (void *)&cmd_flow_director_mask_tunnel_type,
10735 (void *)&cmd_flow_director_mask_tunnel_type_value,
10736 (void *)&cmd_flow_director_mask_tunnel_id,
10737 (void *)&cmd_flow_director_mask_tunnel_id_value,
10742 /* *** deal with flow director mask on flexible payload *** */
10743 struct cmd_flow_director_flex_mask_result {
10744 cmdline_fixed_string_t flow_director_flexmask;
10746 cmdline_fixed_string_t flow;
10747 cmdline_fixed_string_t flow_type;
10748 cmdline_fixed_string_t mask;
10752 cmd_flow_director_flex_mask_parsed(void *parsed_result,
10753 __attribute__((unused)) struct cmdline *cl,
10754 __attribute__((unused)) void *data)
10756 struct cmd_flow_director_flex_mask_result *res = parsed_result;
10757 struct rte_eth_fdir_info fdir_info;
10758 struct rte_eth_fdir_flex_mask flex_mask;
10759 struct rte_port *port;
10760 uint32_t flow_type_mask;
10764 if (res->port_id > nb_ports) {
10765 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
10769 port = &ports[res->port_id];
10770 /** Check if the port is not started **/
10771 if (port->port_status != RTE_PORT_STOPPED) {
10772 printf("Please stop port %d first\n", res->port_id);
10776 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
10777 ret = parse_flexbytes(res->mask,
10779 RTE_ETH_FDIR_MAX_FLEXLEN);
10781 printf("error: Cannot parse mask input.\n");
10785 memset(&fdir_info, 0, sizeof(fdir_info));
10786 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10787 RTE_ETH_FILTER_INFO, &fdir_info);
10789 printf("Cannot get FDir filter info\n");
10793 if (!strcmp(res->flow_type, "none")) {
10794 /* means don't specify the flow type */
10795 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN;
10796 for (i = 0; i < RTE_ETH_FLOW_MAX; i++)
10797 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i],
10798 0, sizeof(struct rte_eth_fdir_flex_mask));
10799 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1;
10800 rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0],
10802 sizeof(struct rte_eth_fdir_flex_mask));
10803 cmd_reconfig_device_queue(res->port_id, 1, 1);
10806 flow_type_mask = fdir_info.flow_types_mask[0];
10807 if (!strcmp(res->flow_type, "all")) {
10808 if (!flow_type_mask) {
10809 printf("No flow type supported\n");
10812 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
10813 if (flow_type_mask & (1 << i)) {
10814 flex_mask.flow_type = i;
10815 fdir_set_flex_mask(res->port_id, &flex_mask);
10818 cmd_reconfig_device_queue(res->port_id, 1, 1);
10821 flex_mask.flow_type = str2flowtype(res->flow_type);
10822 if (!(flow_type_mask & (1 << flex_mask.flow_type))) {
10823 printf("Flow type %s not supported on port %d\n",
10824 res->flow_type, res->port_id);
10827 fdir_set_flex_mask(res->port_id, &flex_mask);
10828 cmd_reconfig_device_queue(res->port_id, 1, 1);
10831 cmdline_parse_token_string_t cmd_flow_director_flexmask =
10832 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
10833 flow_director_flexmask,
10834 "flow_director_flex_mask");
10835 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
10836 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
10838 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
10839 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
10841 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
10842 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
10843 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
10844 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all");
10845 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
10846 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
10849 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
10850 .f = cmd_flow_director_flex_mask_parsed,
10852 .help_str = "flow_director_flex_mask ... : "
10853 "Set flow director's flex mask on NIC",
10855 (void *)&cmd_flow_director_flexmask,
10856 (void *)&cmd_flow_director_flexmask_port_id,
10857 (void *)&cmd_flow_director_flexmask_flow,
10858 (void *)&cmd_flow_director_flexmask_flow_type,
10859 (void *)&cmd_flow_director_flexmask_mask,
10864 /* *** deal with flow director flexible payload configuration *** */
10865 struct cmd_flow_director_flexpayload_result {
10866 cmdline_fixed_string_t flow_director_flexpayload;
10868 cmdline_fixed_string_t payload_layer;
10869 cmdline_fixed_string_t payload_cfg;
10873 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
10876 const char *p, *p0 = q_arg;
10878 unsigned long int_fld;
10879 char *str_fld[max_num];
10884 p = strchr(p0, '(');
10888 p0 = strchr(p, ')');
10893 if (size >= sizeof(s))
10896 snprintf(s, sizeof(s), "%.*s", size, p);
10897 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
10898 if (ret < 0 || ret > max_num)
10900 for (i = 0; i < ret; i++) {
10902 int_fld = strtoul(str_fld[i], &end, 0);
10903 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
10905 offsets[i] = (uint16_t)int_fld;
10911 cmd_flow_director_flxpld_parsed(void *parsed_result,
10912 __attribute__((unused)) struct cmdline *cl,
10913 __attribute__((unused)) void *data)
10915 struct cmd_flow_director_flexpayload_result *res = parsed_result;
10916 struct rte_eth_flex_payload_cfg flex_cfg;
10917 struct rte_port *port;
10920 if (res->port_id > nb_ports) {
10921 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
10925 port = &ports[res->port_id];
10926 /** Check if the port is not started **/
10927 if (port->port_status != RTE_PORT_STOPPED) {
10928 printf("Please stop port %d first\n", res->port_id);
10932 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
10934 if (!strcmp(res->payload_layer, "raw"))
10935 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
10936 else if (!strcmp(res->payload_layer, "l2"))
10937 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
10938 else if (!strcmp(res->payload_layer, "l3"))
10939 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
10940 else if (!strcmp(res->payload_layer, "l4"))
10941 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
10943 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
10944 RTE_ETH_FDIR_MAX_FLEXLEN);
10946 printf("error: Cannot parse flex payload input.\n");
10950 fdir_set_flex_payload(res->port_id, &flex_cfg);
10951 cmd_reconfig_device_queue(res->port_id, 1, 1);
10954 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
10955 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10956 flow_director_flexpayload,
10957 "flow_director_flex_payload");
10958 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
10959 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10961 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
10962 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10963 payload_layer, "raw#l2#l3#l4");
10964 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
10965 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10966 payload_cfg, NULL);
10968 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
10969 .f = cmd_flow_director_flxpld_parsed,
10971 .help_str = "flow_director_flexpayload ... : "
10972 "Set flow director's flex payload on NIC",
10974 (void *)&cmd_flow_director_flexpayload,
10975 (void *)&cmd_flow_director_flexpayload_port_id,
10976 (void *)&cmd_flow_director_flexpayload_payload_layer,
10977 (void *)&cmd_flow_director_flexpayload_payload_cfg,
10982 /* Generic flow interface command. */
10983 extern cmdline_parse_inst_t cmd_flow;
10985 /* *** Classification Filters Control *** */
10986 /* *** Get symmetric hash enable per port *** */
10987 struct cmd_get_sym_hash_ena_per_port_result {
10988 cmdline_fixed_string_t get_sym_hash_ena_per_port;
10993 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
10994 __rte_unused struct cmdline *cl,
10995 __rte_unused void *data)
10997 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
10998 struct rte_eth_hash_filter_info info;
11001 if (rte_eth_dev_filter_supported(res->port_id,
11002 RTE_ETH_FILTER_HASH) < 0) {
11003 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
11008 memset(&info, 0, sizeof(info));
11009 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
11010 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11011 RTE_ETH_FILTER_GET, &info);
11014 printf("Cannot get symmetric hash enable per port "
11015 "on port %u\n", res->port_id);
11019 printf("Symmetric hash is %s on port %u\n", info.info.enable ?
11020 "enabled" : "disabled", res->port_id);
11023 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
11024 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
11025 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
11026 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
11027 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
11030 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
11031 .f = cmd_get_sym_hash_per_port_parsed,
11033 .help_str = "get_sym_hash_ena_per_port <port_id>",
11035 (void *)&cmd_get_sym_hash_ena_per_port_all,
11036 (void *)&cmd_get_sym_hash_ena_per_port_port_id,
11041 /* *** Set symmetric hash enable per port *** */
11042 struct cmd_set_sym_hash_ena_per_port_result {
11043 cmdline_fixed_string_t set_sym_hash_ena_per_port;
11044 cmdline_fixed_string_t enable;
11049 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
11050 __rte_unused struct cmdline *cl,
11051 __rte_unused void *data)
11053 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
11054 struct rte_eth_hash_filter_info info;
11057 if (rte_eth_dev_filter_supported(res->port_id,
11058 RTE_ETH_FILTER_HASH) < 0) {
11059 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
11064 memset(&info, 0, sizeof(info));
11065 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
11066 if (!strcmp(res->enable, "enable"))
11067 info.info.enable = 1;
11068 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11069 RTE_ETH_FILTER_SET, &info);
11071 printf("Cannot set symmetric hash enable per port on "
11072 "port %u\n", res->port_id);
11075 printf("Symmetric hash has been set to %s on port %u\n",
11076 res->enable, res->port_id);
11079 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
11080 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
11081 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
11082 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
11083 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
11085 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
11086 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
11087 enable, "enable#disable");
11089 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
11090 .f = cmd_set_sym_hash_per_port_parsed,
11092 .help_str = "set_sym_hash_ena_per_port <port_id> enable|disable",
11094 (void *)&cmd_set_sym_hash_ena_per_port_all,
11095 (void *)&cmd_set_sym_hash_ena_per_port_port_id,
11096 (void *)&cmd_set_sym_hash_ena_per_port_enable,
11101 /* Get global config of hash function */
11102 struct cmd_get_hash_global_config_result {
11103 cmdline_fixed_string_t get_hash_global_config;
11108 flowtype_to_str(uint16_t ftype)
11114 } ftype_table[] = {
11115 {"ipv4", RTE_ETH_FLOW_IPV4},
11116 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
11117 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
11118 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
11119 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
11120 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
11121 {"ipv6", RTE_ETH_FLOW_IPV6},
11122 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
11123 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
11124 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
11125 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
11126 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
11127 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
11128 {"port", RTE_ETH_FLOW_PORT},
11129 {"vxlan", RTE_ETH_FLOW_VXLAN},
11130 {"geneve", RTE_ETH_FLOW_GENEVE},
11131 {"nvgre", RTE_ETH_FLOW_NVGRE},
11134 for (i = 0; i < RTE_DIM(ftype_table); i++) {
11135 if (ftype_table[i].ftype == ftype)
11136 return ftype_table[i].str;
11143 cmd_get_hash_global_config_parsed(void *parsed_result,
11144 __rte_unused struct cmdline *cl,
11145 __rte_unused void *data)
11147 struct cmd_get_hash_global_config_result *res = parsed_result;
11148 struct rte_eth_hash_filter_info info;
11149 uint32_t idx, offset;
11154 if (rte_eth_dev_filter_supported(res->port_id,
11155 RTE_ETH_FILTER_HASH) < 0) {
11156 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
11161 memset(&info, 0, sizeof(info));
11162 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
11163 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11164 RTE_ETH_FILTER_GET, &info);
11166 printf("Cannot get hash global configurations by port %d\n",
11171 switch (info.info.global_conf.hash_func) {
11172 case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
11173 printf("Hash function is Toeplitz\n");
11175 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
11176 printf("Hash function is Simple XOR\n");
11179 printf("Unknown hash function\n");
11183 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) {
11184 idx = i / UINT32_BIT;
11185 offset = i % UINT32_BIT;
11186 if (!(info.info.global_conf.valid_bit_mask[idx] &
11189 str = flowtype_to_str(i);
11192 printf("Symmetric hash is %s globally for flow type %s "
11194 ((info.info.global_conf.sym_hash_enable_mask[idx] &
11195 (1UL << offset)) ? "enabled" : "disabled"), str,
11200 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
11201 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
11202 get_hash_global_config, "get_hash_global_config");
11203 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
11204 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
11207 cmdline_parse_inst_t cmd_get_hash_global_config = {
11208 .f = cmd_get_hash_global_config_parsed,
11210 .help_str = "get_hash_global_config <port_id>",
11212 (void *)&cmd_get_hash_global_config_all,
11213 (void *)&cmd_get_hash_global_config_port_id,
11218 /* Set global config of hash function */
11219 struct cmd_set_hash_global_config_result {
11220 cmdline_fixed_string_t set_hash_global_config;
11222 cmdline_fixed_string_t hash_func;
11223 cmdline_fixed_string_t flow_type;
11224 cmdline_fixed_string_t enable;
11228 cmd_set_hash_global_config_parsed(void *parsed_result,
11229 __rte_unused struct cmdline *cl,
11230 __rte_unused void *data)
11232 struct cmd_set_hash_global_config_result *res = parsed_result;
11233 struct rte_eth_hash_filter_info info;
11234 uint32_t ftype, idx, offset;
11237 if (rte_eth_dev_filter_supported(res->port_id,
11238 RTE_ETH_FILTER_HASH) < 0) {
11239 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
11243 memset(&info, 0, sizeof(info));
11244 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
11245 if (!strcmp(res->hash_func, "toeplitz"))
11246 info.info.global_conf.hash_func =
11247 RTE_ETH_HASH_FUNCTION_TOEPLITZ;
11248 else if (!strcmp(res->hash_func, "simple_xor"))
11249 info.info.global_conf.hash_func =
11250 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
11251 else if (!strcmp(res->hash_func, "default"))
11252 info.info.global_conf.hash_func =
11253 RTE_ETH_HASH_FUNCTION_DEFAULT;
11255 ftype = str2flowtype(res->flow_type);
11256 idx = ftype / (CHAR_BIT * sizeof(uint32_t));
11257 offset = ftype % (CHAR_BIT * sizeof(uint32_t));
11258 info.info.global_conf.valid_bit_mask[idx] |= (1UL << offset);
11259 if (!strcmp(res->enable, "enable"))
11260 info.info.global_conf.sym_hash_enable_mask[idx] |=
11262 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11263 RTE_ETH_FILTER_SET, &info);
11265 printf("Cannot set global hash configurations by port %d\n",
11268 printf("Global hash configurations have been set "
11269 "succcessfully by port %d\n", res->port_id);
11272 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
11273 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11274 set_hash_global_config, "set_hash_global_config");
11275 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
11276 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
11278 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
11279 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11280 hash_func, "toeplitz#simple_xor#default");
11281 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
11282 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11284 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
11285 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
11286 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
11287 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11288 enable, "enable#disable");
11290 cmdline_parse_inst_t cmd_set_hash_global_config = {
11291 .f = cmd_set_hash_global_config_parsed,
11293 .help_str = "set_hash_global_config <port_id> "
11294 "toeplitz|simple_xor|default "
11295 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
11296 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
11297 "l2_payload enable|disable",
11299 (void *)&cmd_set_hash_global_config_all,
11300 (void *)&cmd_set_hash_global_config_port_id,
11301 (void *)&cmd_set_hash_global_config_hash_func,
11302 (void *)&cmd_set_hash_global_config_flow_type,
11303 (void *)&cmd_set_hash_global_config_enable,
11308 /* Set hash input set */
11309 struct cmd_set_hash_input_set_result {
11310 cmdline_fixed_string_t set_hash_input_set;
11312 cmdline_fixed_string_t flow_type;
11313 cmdline_fixed_string_t inset_field;
11314 cmdline_fixed_string_t select;
11317 static enum rte_eth_input_set_field
11318 str2inset(char *string)
11322 static const struct {
11324 enum rte_eth_input_set_field inset;
11325 } inset_table[] = {
11326 {"ethertype", RTE_ETH_INPUT_SET_L2_ETHERTYPE},
11327 {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN},
11328 {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN},
11329 {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4},
11330 {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4},
11331 {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS},
11332 {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO},
11333 {"ipv4-ttl", RTE_ETH_INPUT_SET_L3_IP4_TTL},
11334 {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6},
11335 {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6},
11336 {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC},
11337 {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER},
11338 {"ipv6-hop-limits", RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS},
11339 {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT},
11340 {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT},
11341 {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT},
11342 {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT},
11343 {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT},
11344 {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT},
11345 {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG},
11346 {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY},
11347 {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY},
11348 {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD},
11349 {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD},
11350 {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD},
11351 {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD},
11352 {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD},
11353 {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD},
11354 {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD},
11355 {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD},
11356 {"none", RTE_ETH_INPUT_SET_NONE},
11359 for (i = 0; i < RTE_DIM(inset_table); i++) {
11360 if (!strcmp(string, inset_table[i].str))
11361 return inset_table[i].inset;
11364 return RTE_ETH_INPUT_SET_UNKNOWN;
11368 cmd_set_hash_input_set_parsed(void *parsed_result,
11369 __rte_unused struct cmdline *cl,
11370 __rte_unused void *data)
11372 struct cmd_set_hash_input_set_result *res = parsed_result;
11373 struct rte_eth_hash_filter_info info;
11375 memset(&info, 0, sizeof(info));
11376 info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT;
11377 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
11378 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
11379 info.info.input_set_conf.inset_size = 1;
11380 if (!strcmp(res->select, "select"))
11381 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
11382 else if (!strcmp(res->select, "add"))
11383 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
11384 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11385 RTE_ETH_FILTER_SET, &info);
11388 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd =
11389 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
11390 set_hash_input_set, "set_hash_input_set");
11391 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id =
11392 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result,
11394 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type =
11395 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
11397 cmdline_parse_token_string_t cmd_set_hash_input_set_field =
11398 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
11400 "ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
11401 "ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#"
11402 "udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#"
11403 "sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#"
11404 "fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#"
11406 cmdline_parse_token_string_t cmd_set_hash_input_set_select =
11407 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
11408 select, "select#add");
11410 cmdline_parse_inst_t cmd_set_hash_input_set = {
11411 .f = cmd_set_hash_input_set_parsed,
11413 .help_str = "set_hash_input_set <port_id> "
11414 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
11415 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload|<flowtype_id> "
11416 "ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|"
11417 "ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|"
11418 "tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|"
11419 "gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
11420 "fld-7th|fld-8th|none select|add",
11422 (void *)&cmd_set_hash_input_set_cmd,
11423 (void *)&cmd_set_hash_input_set_port_id,
11424 (void *)&cmd_set_hash_input_set_flow_type,
11425 (void *)&cmd_set_hash_input_set_field,
11426 (void *)&cmd_set_hash_input_set_select,
11431 /* Set flow director input set */
11432 struct cmd_set_fdir_input_set_result {
11433 cmdline_fixed_string_t set_fdir_input_set;
11435 cmdline_fixed_string_t flow_type;
11436 cmdline_fixed_string_t inset_field;
11437 cmdline_fixed_string_t select;
11441 cmd_set_fdir_input_set_parsed(void *parsed_result,
11442 __rte_unused struct cmdline *cl,
11443 __rte_unused void *data)
11445 struct cmd_set_fdir_input_set_result *res = parsed_result;
11446 struct rte_eth_fdir_filter_info info;
11448 memset(&info, 0, sizeof(info));
11449 info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT;
11450 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
11451 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
11452 info.info.input_set_conf.inset_size = 1;
11453 if (!strcmp(res->select, "select"))
11454 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
11455 else if (!strcmp(res->select, "add"))
11456 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
11457 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11458 RTE_ETH_FILTER_SET, &info);
11461 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd =
11462 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
11463 set_fdir_input_set, "set_fdir_input_set");
11464 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id =
11465 TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result,
11467 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type =
11468 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
11470 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
11471 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
11472 cmdline_parse_token_string_t cmd_set_fdir_input_set_field =
11473 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
11475 "ivlan#ethertype#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
11476 "ipv4-tos#ipv4-proto#ipv4-ttl#ipv6-tc#ipv6-next-header#"
11477 "ipv6-hop-limits#udp-src-port#udp-dst-port#"
11478 "tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#"
11479 "sctp-veri-tag#none");
11480 cmdline_parse_token_string_t cmd_set_fdir_input_set_select =
11481 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
11482 select, "select#add");
11484 cmdline_parse_inst_t cmd_set_fdir_input_set = {
11485 .f = cmd_set_fdir_input_set_parsed,
11487 .help_str = "set_fdir_input_set <port_id> "
11488 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
11489 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
11490 "ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|"
11491 "ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|ipv6-next-header|"
11492 "ipv6-hop-limits|udp-src-port|udp-dst-port|"
11493 "tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|"
11494 "sctp-veri-tag|none select|add",
11496 (void *)&cmd_set_fdir_input_set_cmd,
11497 (void *)&cmd_set_fdir_input_set_port_id,
11498 (void *)&cmd_set_fdir_input_set_flow_type,
11499 (void *)&cmd_set_fdir_input_set_field,
11500 (void *)&cmd_set_fdir_input_set_select,
11505 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
11506 struct cmd_mcast_addr_result {
11507 cmdline_fixed_string_t mcast_addr_cmd;
11508 cmdline_fixed_string_t what;
11510 struct ether_addr mc_addr;
11513 static void cmd_mcast_addr_parsed(void *parsed_result,
11514 __attribute__((unused)) struct cmdline *cl,
11515 __attribute__((unused)) void *data)
11517 struct cmd_mcast_addr_result *res = parsed_result;
11519 if (!is_multicast_ether_addr(&res->mc_addr)) {
11520 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
11521 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
11522 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
11523 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
11526 if (strcmp(res->what, "add") == 0)
11527 mcast_addr_add(res->port_num, &res->mc_addr);
11529 mcast_addr_remove(res->port_num, &res->mc_addr);
11532 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
11533 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
11534 mcast_addr_cmd, "mcast_addr");
11535 cmdline_parse_token_string_t cmd_mcast_addr_what =
11536 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
11538 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
11539 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT16);
11540 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
11541 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
11543 cmdline_parse_inst_t cmd_mcast_addr = {
11544 .f = cmd_mcast_addr_parsed,
11546 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
11547 "Add/Remove multicast MAC address on port_id",
11549 (void *)&cmd_mcast_addr_cmd,
11550 (void *)&cmd_mcast_addr_what,
11551 (void *)&cmd_mcast_addr_portnum,
11552 (void *)&cmd_mcast_addr_addr,
11557 /* l2 tunnel config
11558 * only support E-tag now.
11561 /* Ether type config */
11562 struct cmd_config_l2_tunnel_eth_type_result {
11563 cmdline_fixed_string_t port;
11564 cmdline_fixed_string_t config;
11565 cmdline_fixed_string_t all;
11567 cmdline_fixed_string_t l2_tunnel;
11568 cmdline_fixed_string_t l2_tunnel_type;
11569 cmdline_fixed_string_t eth_type;
11570 uint16_t eth_type_val;
11573 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port =
11574 TOKEN_STRING_INITIALIZER
11575 (struct cmd_config_l2_tunnel_eth_type_result,
11577 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config =
11578 TOKEN_STRING_INITIALIZER
11579 (struct cmd_config_l2_tunnel_eth_type_result,
11581 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str =
11582 TOKEN_STRING_INITIALIZER
11583 (struct cmd_config_l2_tunnel_eth_type_result,
11585 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id =
11586 TOKEN_NUM_INITIALIZER
11587 (struct cmd_config_l2_tunnel_eth_type_result,
11589 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel =
11590 TOKEN_STRING_INITIALIZER
11591 (struct cmd_config_l2_tunnel_eth_type_result,
11592 l2_tunnel, "l2-tunnel");
11593 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type =
11594 TOKEN_STRING_INITIALIZER
11595 (struct cmd_config_l2_tunnel_eth_type_result,
11596 l2_tunnel_type, "E-tag");
11597 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type =
11598 TOKEN_STRING_INITIALIZER
11599 (struct cmd_config_l2_tunnel_eth_type_result,
11600 eth_type, "ether-type");
11601 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val =
11602 TOKEN_NUM_INITIALIZER
11603 (struct cmd_config_l2_tunnel_eth_type_result,
11604 eth_type_val, UINT16);
11606 static enum rte_eth_tunnel_type
11607 str2fdir_l2_tunnel_type(char *string)
11611 static const struct {
11613 enum rte_eth_tunnel_type type;
11614 } l2_tunnel_type_str[] = {
11615 {"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG},
11618 for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) {
11619 if (!strcmp(l2_tunnel_type_str[i].str, string))
11620 return l2_tunnel_type_str[i].type;
11622 return RTE_TUNNEL_TYPE_NONE;
11625 /* ether type config for all ports */
11627 cmd_config_l2_tunnel_eth_type_all_parsed
11628 (void *parsed_result,
11629 __attribute__((unused)) struct cmdline *cl,
11630 __attribute__((unused)) void *data)
11632 struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result;
11633 struct rte_eth_l2_tunnel_conf entry;
11636 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
11637 entry.ether_type = res->eth_type_val;
11639 RTE_ETH_FOREACH_DEV(pid) {
11640 rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry);
11644 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = {
11645 .f = cmd_config_l2_tunnel_eth_type_all_parsed,
11647 .help_str = "port config all l2-tunnel E-tag ether-type <value>",
11649 (void *)&cmd_config_l2_tunnel_eth_type_port,
11650 (void *)&cmd_config_l2_tunnel_eth_type_config,
11651 (void *)&cmd_config_l2_tunnel_eth_type_all_str,
11652 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
11653 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
11654 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
11655 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
11660 /* ether type config for a specific port */
11662 cmd_config_l2_tunnel_eth_type_specific_parsed(
11663 void *parsed_result,
11664 __attribute__((unused)) struct cmdline *cl,
11665 __attribute__((unused)) void *data)
11667 struct cmd_config_l2_tunnel_eth_type_result *res =
11669 struct rte_eth_l2_tunnel_conf entry;
11671 if (port_id_is_invalid(res->id, ENABLED_WARN))
11674 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
11675 entry.ether_type = res->eth_type_val;
11677 rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry);
11680 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = {
11681 .f = cmd_config_l2_tunnel_eth_type_specific_parsed,
11683 .help_str = "port config <port_id> l2-tunnel E-tag ether-type <value>",
11685 (void *)&cmd_config_l2_tunnel_eth_type_port,
11686 (void *)&cmd_config_l2_tunnel_eth_type_config,
11687 (void *)&cmd_config_l2_tunnel_eth_type_id,
11688 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
11689 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
11690 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
11691 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
11696 /* Enable/disable l2 tunnel */
11697 struct cmd_config_l2_tunnel_en_dis_result {
11698 cmdline_fixed_string_t port;
11699 cmdline_fixed_string_t config;
11700 cmdline_fixed_string_t all;
11702 cmdline_fixed_string_t l2_tunnel;
11703 cmdline_fixed_string_t l2_tunnel_type;
11704 cmdline_fixed_string_t en_dis;
11707 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port =
11708 TOKEN_STRING_INITIALIZER
11709 (struct cmd_config_l2_tunnel_en_dis_result,
11711 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config =
11712 TOKEN_STRING_INITIALIZER
11713 (struct cmd_config_l2_tunnel_en_dis_result,
11715 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str =
11716 TOKEN_STRING_INITIALIZER
11717 (struct cmd_config_l2_tunnel_en_dis_result,
11719 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id =
11720 TOKEN_NUM_INITIALIZER
11721 (struct cmd_config_l2_tunnel_en_dis_result,
11723 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel =
11724 TOKEN_STRING_INITIALIZER
11725 (struct cmd_config_l2_tunnel_en_dis_result,
11726 l2_tunnel, "l2-tunnel");
11727 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type =
11728 TOKEN_STRING_INITIALIZER
11729 (struct cmd_config_l2_tunnel_en_dis_result,
11730 l2_tunnel_type, "E-tag");
11731 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis =
11732 TOKEN_STRING_INITIALIZER
11733 (struct cmd_config_l2_tunnel_en_dis_result,
11734 en_dis, "enable#disable");
11736 /* enable/disable l2 tunnel for all ports */
11738 cmd_config_l2_tunnel_en_dis_all_parsed(
11739 void *parsed_result,
11740 __attribute__((unused)) struct cmdline *cl,
11741 __attribute__((unused)) void *data)
11743 struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result;
11744 struct rte_eth_l2_tunnel_conf entry;
11748 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
11750 if (!strcmp("enable", res->en_dis))
11755 RTE_ETH_FOREACH_DEV(pid) {
11756 rte_eth_dev_l2_tunnel_offload_set(pid,
11758 ETH_L2_TUNNEL_ENABLE_MASK,
11763 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = {
11764 .f = cmd_config_l2_tunnel_en_dis_all_parsed,
11766 .help_str = "port config all l2-tunnel E-tag enable|disable",
11768 (void *)&cmd_config_l2_tunnel_en_dis_port,
11769 (void *)&cmd_config_l2_tunnel_en_dis_config,
11770 (void *)&cmd_config_l2_tunnel_en_dis_all_str,
11771 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
11772 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
11773 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
11778 /* enable/disable l2 tunnel for a port */
11780 cmd_config_l2_tunnel_en_dis_specific_parsed(
11781 void *parsed_result,
11782 __attribute__((unused)) struct cmdline *cl,
11783 __attribute__((unused)) void *data)
11785 struct cmd_config_l2_tunnel_en_dis_result *res =
11787 struct rte_eth_l2_tunnel_conf entry;
11789 if (port_id_is_invalid(res->id, ENABLED_WARN))
11792 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
11794 if (!strcmp("enable", res->en_dis))
11795 rte_eth_dev_l2_tunnel_offload_set(res->id,
11797 ETH_L2_TUNNEL_ENABLE_MASK,
11800 rte_eth_dev_l2_tunnel_offload_set(res->id,
11802 ETH_L2_TUNNEL_ENABLE_MASK,
11806 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = {
11807 .f = cmd_config_l2_tunnel_en_dis_specific_parsed,
11809 .help_str = "port config <port_id> l2-tunnel E-tag enable|disable",
11811 (void *)&cmd_config_l2_tunnel_en_dis_port,
11812 (void *)&cmd_config_l2_tunnel_en_dis_config,
11813 (void *)&cmd_config_l2_tunnel_en_dis_id,
11814 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
11815 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
11816 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
11821 /* E-tag configuration */
11823 /* Common result structure for all E-tag configuration */
11824 struct cmd_config_e_tag_result {
11825 cmdline_fixed_string_t e_tag;
11826 cmdline_fixed_string_t set;
11827 cmdline_fixed_string_t insertion;
11828 cmdline_fixed_string_t stripping;
11829 cmdline_fixed_string_t forwarding;
11830 cmdline_fixed_string_t filter;
11831 cmdline_fixed_string_t add;
11832 cmdline_fixed_string_t del;
11833 cmdline_fixed_string_t on;
11834 cmdline_fixed_string_t off;
11835 cmdline_fixed_string_t on_off;
11836 cmdline_fixed_string_t port_tag_id;
11837 uint32_t port_tag_id_val;
11838 cmdline_fixed_string_t e_tag_id;
11839 uint16_t e_tag_id_val;
11840 cmdline_fixed_string_t dst_pool;
11841 uint8_t dst_pool_val;
11842 cmdline_fixed_string_t port;
11844 cmdline_fixed_string_t vf;
11848 /* Common CLI fields for all E-tag configuration */
11849 cmdline_parse_token_string_t cmd_config_e_tag_e_tag =
11850 TOKEN_STRING_INITIALIZER
11851 (struct cmd_config_e_tag_result,
11853 cmdline_parse_token_string_t cmd_config_e_tag_set =
11854 TOKEN_STRING_INITIALIZER
11855 (struct cmd_config_e_tag_result,
11857 cmdline_parse_token_string_t cmd_config_e_tag_insertion =
11858 TOKEN_STRING_INITIALIZER
11859 (struct cmd_config_e_tag_result,
11860 insertion, "insertion");
11861 cmdline_parse_token_string_t cmd_config_e_tag_stripping =
11862 TOKEN_STRING_INITIALIZER
11863 (struct cmd_config_e_tag_result,
11864 stripping, "stripping");
11865 cmdline_parse_token_string_t cmd_config_e_tag_forwarding =
11866 TOKEN_STRING_INITIALIZER
11867 (struct cmd_config_e_tag_result,
11868 forwarding, "forwarding");
11869 cmdline_parse_token_string_t cmd_config_e_tag_filter =
11870 TOKEN_STRING_INITIALIZER
11871 (struct cmd_config_e_tag_result,
11873 cmdline_parse_token_string_t cmd_config_e_tag_add =
11874 TOKEN_STRING_INITIALIZER
11875 (struct cmd_config_e_tag_result,
11877 cmdline_parse_token_string_t cmd_config_e_tag_del =
11878 TOKEN_STRING_INITIALIZER
11879 (struct cmd_config_e_tag_result,
11881 cmdline_parse_token_string_t cmd_config_e_tag_on =
11882 TOKEN_STRING_INITIALIZER
11883 (struct cmd_config_e_tag_result,
11885 cmdline_parse_token_string_t cmd_config_e_tag_off =
11886 TOKEN_STRING_INITIALIZER
11887 (struct cmd_config_e_tag_result,
11889 cmdline_parse_token_string_t cmd_config_e_tag_on_off =
11890 TOKEN_STRING_INITIALIZER
11891 (struct cmd_config_e_tag_result,
11893 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id =
11894 TOKEN_STRING_INITIALIZER
11895 (struct cmd_config_e_tag_result,
11896 port_tag_id, "port-tag-id");
11897 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val =
11898 TOKEN_NUM_INITIALIZER
11899 (struct cmd_config_e_tag_result,
11900 port_tag_id_val, UINT32);
11901 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id =
11902 TOKEN_STRING_INITIALIZER
11903 (struct cmd_config_e_tag_result,
11904 e_tag_id, "e-tag-id");
11905 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val =
11906 TOKEN_NUM_INITIALIZER
11907 (struct cmd_config_e_tag_result,
11908 e_tag_id_val, UINT16);
11909 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool =
11910 TOKEN_STRING_INITIALIZER
11911 (struct cmd_config_e_tag_result,
11912 dst_pool, "dst-pool");
11913 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val =
11914 TOKEN_NUM_INITIALIZER
11915 (struct cmd_config_e_tag_result,
11916 dst_pool_val, UINT8);
11917 cmdline_parse_token_string_t cmd_config_e_tag_port =
11918 TOKEN_STRING_INITIALIZER
11919 (struct cmd_config_e_tag_result,
11921 cmdline_parse_token_num_t cmd_config_e_tag_port_id =
11922 TOKEN_NUM_INITIALIZER
11923 (struct cmd_config_e_tag_result,
11925 cmdline_parse_token_string_t cmd_config_e_tag_vf =
11926 TOKEN_STRING_INITIALIZER
11927 (struct cmd_config_e_tag_result,
11929 cmdline_parse_token_num_t cmd_config_e_tag_vf_id =
11930 TOKEN_NUM_INITIALIZER
11931 (struct cmd_config_e_tag_result,
11934 /* E-tag insertion configuration */
11936 cmd_config_e_tag_insertion_en_parsed(
11937 void *parsed_result,
11938 __attribute__((unused)) struct cmdline *cl,
11939 __attribute__((unused)) void *data)
11941 struct cmd_config_e_tag_result *res =
11943 struct rte_eth_l2_tunnel_conf entry;
11945 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11948 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
11949 entry.tunnel_id = res->port_tag_id_val;
11950 entry.vf_id = res->vf_id;
11951 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
11953 ETH_L2_TUNNEL_INSERTION_MASK,
11958 cmd_config_e_tag_insertion_dis_parsed(
11959 void *parsed_result,
11960 __attribute__((unused)) struct cmdline *cl,
11961 __attribute__((unused)) void *data)
11963 struct cmd_config_e_tag_result *res =
11965 struct rte_eth_l2_tunnel_conf entry;
11967 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11970 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
11971 entry.vf_id = res->vf_id;
11973 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
11975 ETH_L2_TUNNEL_INSERTION_MASK,
11979 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = {
11980 .f = cmd_config_e_tag_insertion_en_parsed,
11982 .help_str = "E-tag ... : E-tag insertion enable",
11984 (void *)&cmd_config_e_tag_e_tag,
11985 (void *)&cmd_config_e_tag_set,
11986 (void *)&cmd_config_e_tag_insertion,
11987 (void *)&cmd_config_e_tag_on,
11988 (void *)&cmd_config_e_tag_port_tag_id,
11989 (void *)&cmd_config_e_tag_port_tag_id_val,
11990 (void *)&cmd_config_e_tag_port,
11991 (void *)&cmd_config_e_tag_port_id,
11992 (void *)&cmd_config_e_tag_vf,
11993 (void *)&cmd_config_e_tag_vf_id,
11998 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = {
11999 .f = cmd_config_e_tag_insertion_dis_parsed,
12001 .help_str = "E-tag ... : E-tag insertion disable",
12003 (void *)&cmd_config_e_tag_e_tag,
12004 (void *)&cmd_config_e_tag_set,
12005 (void *)&cmd_config_e_tag_insertion,
12006 (void *)&cmd_config_e_tag_off,
12007 (void *)&cmd_config_e_tag_port,
12008 (void *)&cmd_config_e_tag_port_id,
12009 (void *)&cmd_config_e_tag_vf,
12010 (void *)&cmd_config_e_tag_vf_id,
12015 /* E-tag stripping configuration */
12017 cmd_config_e_tag_stripping_parsed(
12018 void *parsed_result,
12019 __attribute__((unused)) struct cmdline *cl,
12020 __attribute__((unused)) void *data)
12022 struct cmd_config_e_tag_result *res =
12024 struct rte_eth_l2_tunnel_conf entry;
12026 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12029 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12031 if (!strcmp(res->on_off, "on"))
12032 rte_eth_dev_l2_tunnel_offload_set
12035 ETH_L2_TUNNEL_STRIPPING_MASK,
12038 rte_eth_dev_l2_tunnel_offload_set
12041 ETH_L2_TUNNEL_STRIPPING_MASK,
12045 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = {
12046 .f = cmd_config_e_tag_stripping_parsed,
12048 .help_str = "E-tag ... : E-tag stripping enable/disable",
12050 (void *)&cmd_config_e_tag_e_tag,
12051 (void *)&cmd_config_e_tag_set,
12052 (void *)&cmd_config_e_tag_stripping,
12053 (void *)&cmd_config_e_tag_on_off,
12054 (void *)&cmd_config_e_tag_port,
12055 (void *)&cmd_config_e_tag_port_id,
12060 /* E-tag forwarding configuration */
12062 cmd_config_e_tag_forwarding_parsed(
12063 void *parsed_result,
12064 __attribute__((unused)) struct cmdline *cl,
12065 __attribute__((unused)) void *data)
12067 struct cmd_config_e_tag_result *res = parsed_result;
12068 struct rte_eth_l2_tunnel_conf entry;
12070 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12073 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12075 if (!strcmp(res->on_off, "on"))
12076 rte_eth_dev_l2_tunnel_offload_set
12079 ETH_L2_TUNNEL_FORWARDING_MASK,
12082 rte_eth_dev_l2_tunnel_offload_set
12085 ETH_L2_TUNNEL_FORWARDING_MASK,
12089 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = {
12090 .f = cmd_config_e_tag_forwarding_parsed,
12092 .help_str = "E-tag ... : E-tag forwarding enable/disable",
12094 (void *)&cmd_config_e_tag_e_tag,
12095 (void *)&cmd_config_e_tag_set,
12096 (void *)&cmd_config_e_tag_forwarding,
12097 (void *)&cmd_config_e_tag_on_off,
12098 (void *)&cmd_config_e_tag_port,
12099 (void *)&cmd_config_e_tag_port_id,
12104 /* E-tag filter configuration */
12106 cmd_config_e_tag_filter_add_parsed(
12107 void *parsed_result,
12108 __attribute__((unused)) struct cmdline *cl,
12109 __attribute__((unused)) void *data)
12111 struct cmd_config_e_tag_result *res = parsed_result;
12112 struct rte_eth_l2_tunnel_conf entry;
12115 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12118 if (res->e_tag_id_val > 0x3fff) {
12119 printf("e-tag-id must be equal or less than 0x3fff.\n");
12123 ret = rte_eth_dev_filter_supported(res->port_id,
12124 RTE_ETH_FILTER_L2_TUNNEL);
12126 printf("E-tag filter is not supported on port %u.\n",
12131 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12132 entry.tunnel_id = res->e_tag_id_val;
12133 entry.pool = res->dst_pool_val;
12135 ret = rte_eth_dev_filter_ctrl(res->port_id,
12136 RTE_ETH_FILTER_L2_TUNNEL,
12137 RTE_ETH_FILTER_ADD,
12140 printf("E-tag filter programming error: (%s)\n",
12144 cmdline_parse_inst_t cmd_config_e_tag_filter_add = {
12145 .f = cmd_config_e_tag_filter_add_parsed,
12147 .help_str = "E-tag ... : E-tag filter add",
12149 (void *)&cmd_config_e_tag_e_tag,
12150 (void *)&cmd_config_e_tag_set,
12151 (void *)&cmd_config_e_tag_filter,
12152 (void *)&cmd_config_e_tag_add,
12153 (void *)&cmd_config_e_tag_e_tag_id,
12154 (void *)&cmd_config_e_tag_e_tag_id_val,
12155 (void *)&cmd_config_e_tag_dst_pool,
12156 (void *)&cmd_config_e_tag_dst_pool_val,
12157 (void *)&cmd_config_e_tag_port,
12158 (void *)&cmd_config_e_tag_port_id,
12164 cmd_config_e_tag_filter_del_parsed(
12165 void *parsed_result,
12166 __attribute__((unused)) struct cmdline *cl,
12167 __attribute__((unused)) void *data)
12169 struct cmd_config_e_tag_result *res = parsed_result;
12170 struct rte_eth_l2_tunnel_conf entry;
12173 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12176 if (res->e_tag_id_val > 0x3fff) {
12177 printf("e-tag-id must be less than 0x3fff.\n");
12181 ret = rte_eth_dev_filter_supported(res->port_id,
12182 RTE_ETH_FILTER_L2_TUNNEL);
12184 printf("E-tag filter is not supported on port %u.\n",
12189 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12190 entry.tunnel_id = res->e_tag_id_val;
12192 ret = rte_eth_dev_filter_ctrl(res->port_id,
12193 RTE_ETH_FILTER_L2_TUNNEL,
12194 RTE_ETH_FILTER_DELETE,
12197 printf("E-tag filter programming error: (%s)\n",
12201 cmdline_parse_inst_t cmd_config_e_tag_filter_del = {
12202 .f = cmd_config_e_tag_filter_del_parsed,
12204 .help_str = "E-tag ... : E-tag filter delete",
12206 (void *)&cmd_config_e_tag_e_tag,
12207 (void *)&cmd_config_e_tag_set,
12208 (void *)&cmd_config_e_tag_filter,
12209 (void *)&cmd_config_e_tag_del,
12210 (void *)&cmd_config_e_tag_e_tag_id,
12211 (void *)&cmd_config_e_tag_e_tag_id_val,
12212 (void *)&cmd_config_e_tag_port,
12213 (void *)&cmd_config_e_tag_port_id,
12218 /* vf vlan anti spoof configuration */
12220 /* Common result structure for vf vlan anti spoof */
12221 struct cmd_vf_vlan_anti_spoof_result {
12222 cmdline_fixed_string_t set;
12223 cmdline_fixed_string_t vf;
12224 cmdline_fixed_string_t vlan;
12225 cmdline_fixed_string_t antispoof;
12228 cmdline_fixed_string_t on_off;
12231 /* Common CLI fields for vf vlan anti spoof enable disable */
12232 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
12233 TOKEN_STRING_INITIALIZER
12234 (struct cmd_vf_vlan_anti_spoof_result,
12236 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
12237 TOKEN_STRING_INITIALIZER
12238 (struct cmd_vf_vlan_anti_spoof_result,
12240 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
12241 TOKEN_STRING_INITIALIZER
12242 (struct cmd_vf_vlan_anti_spoof_result,
12244 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
12245 TOKEN_STRING_INITIALIZER
12246 (struct cmd_vf_vlan_anti_spoof_result,
12247 antispoof, "antispoof");
12248 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
12249 TOKEN_NUM_INITIALIZER
12250 (struct cmd_vf_vlan_anti_spoof_result,
12252 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
12253 TOKEN_NUM_INITIALIZER
12254 (struct cmd_vf_vlan_anti_spoof_result,
12256 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
12257 TOKEN_STRING_INITIALIZER
12258 (struct cmd_vf_vlan_anti_spoof_result,
12262 cmd_set_vf_vlan_anti_spoof_parsed(
12263 void *parsed_result,
12264 __attribute__((unused)) struct cmdline *cl,
12265 __attribute__((unused)) void *data)
12267 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
12268 int ret = -ENOTSUP;
12270 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12272 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12275 #ifdef RTE_LIBRTE_IXGBE_PMD
12276 if (ret == -ENOTSUP)
12277 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
12278 res->vf_id, is_on);
12280 #ifdef RTE_LIBRTE_I40E_PMD
12281 if (ret == -ENOTSUP)
12282 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
12283 res->vf_id, is_on);
12285 #ifdef RTE_LIBRTE_BNXT_PMD
12286 if (ret == -ENOTSUP)
12287 ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
12288 res->vf_id, is_on);
12295 printf("invalid vf_id %d\n", res->vf_id);
12298 printf("invalid port_id %d\n", res->port_id);
12301 printf("function not implemented\n");
12304 printf("programming error: (%s)\n", strerror(-ret));
12308 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
12309 .f = cmd_set_vf_vlan_anti_spoof_parsed,
12311 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
12313 (void *)&cmd_vf_vlan_anti_spoof_set,
12314 (void *)&cmd_vf_vlan_anti_spoof_vf,
12315 (void *)&cmd_vf_vlan_anti_spoof_vlan,
12316 (void *)&cmd_vf_vlan_anti_spoof_antispoof,
12317 (void *)&cmd_vf_vlan_anti_spoof_port_id,
12318 (void *)&cmd_vf_vlan_anti_spoof_vf_id,
12319 (void *)&cmd_vf_vlan_anti_spoof_on_off,
12324 /* vf mac anti spoof configuration */
12326 /* Common result structure for vf mac anti spoof */
12327 struct cmd_vf_mac_anti_spoof_result {
12328 cmdline_fixed_string_t set;
12329 cmdline_fixed_string_t vf;
12330 cmdline_fixed_string_t mac;
12331 cmdline_fixed_string_t antispoof;
12334 cmdline_fixed_string_t on_off;
12337 /* Common CLI fields for vf mac anti spoof enable disable */
12338 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
12339 TOKEN_STRING_INITIALIZER
12340 (struct cmd_vf_mac_anti_spoof_result,
12342 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
12343 TOKEN_STRING_INITIALIZER
12344 (struct cmd_vf_mac_anti_spoof_result,
12346 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
12347 TOKEN_STRING_INITIALIZER
12348 (struct cmd_vf_mac_anti_spoof_result,
12350 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
12351 TOKEN_STRING_INITIALIZER
12352 (struct cmd_vf_mac_anti_spoof_result,
12353 antispoof, "antispoof");
12354 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
12355 TOKEN_NUM_INITIALIZER
12356 (struct cmd_vf_mac_anti_spoof_result,
12358 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
12359 TOKEN_NUM_INITIALIZER
12360 (struct cmd_vf_mac_anti_spoof_result,
12362 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
12363 TOKEN_STRING_INITIALIZER
12364 (struct cmd_vf_mac_anti_spoof_result,
12368 cmd_set_vf_mac_anti_spoof_parsed(
12369 void *parsed_result,
12370 __attribute__((unused)) struct cmdline *cl,
12371 __attribute__((unused)) void *data)
12373 struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
12374 int ret = -ENOTSUP;
12376 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12378 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12381 #ifdef RTE_LIBRTE_IXGBE_PMD
12382 if (ret == -ENOTSUP)
12383 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
12384 res->vf_id, is_on);
12386 #ifdef RTE_LIBRTE_I40E_PMD
12387 if (ret == -ENOTSUP)
12388 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
12389 res->vf_id, is_on);
12391 #ifdef RTE_LIBRTE_BNXT_PMD
12392 if (ret == -ENOTSUP)
12393 ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
12394 res->vf_id, is_on);
12401 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12404 printf("invalid port_id %d\n", res->port_id);
12407 printf("function not implemented\n");
12410 printf("programming error: (%s)\n", strerror(-ret));
12414 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
12415 .f = cmd_set_vf_mac_anti_spoof_parsed,
12417 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
12419 (void *)&cmd_vf_mac_anti_spoof_set,
12420 (void *)&cmd_vf_mac_anti_spoof_vf,
12421 (void *)&cmd_vf_mac_anti_spoof_mac,
12422 (void *)&cmd_vf_mac_anti_spoof_antispoof,
12423 (void *)&cmd_vf_mac_anti_spoof_port_id,
12424 (void *)&cmd_vf_mac_anti_spoof_vf_id,
12425 (void *)&cmd_vf_mac_anti_spoof_on_off,
12430 /* vf vlan strip queue configuration */
12432 /* Common result structure for vf mac anti spoof */
12433 struct cmd_vf_vlan_stripq_result {
12434 cmdline_fixed_string_t set;
12435 cmdline_fixed_string_t vf;
12436 cmdline_fixed_string_t vlan;
12437 cmdline_fixed_string_t stripq;
12440 cmdline_fixed_string_t on_off;
12443 /* Common CLI fields for vf vlan strip enable disable */
12444 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
12445 TOKEN_STRING_INITIALIZER
12446 (struct cmd_vf_vlan_stripq_result,
12448 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
12449 TOKEN_STRING_INITIALIZER
12450 (struct cmd_vf_vlan_stripq_result,
12452 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
12453 TOKEN_STRING_INITIALIZER
12454 (struct cmd_vf_vlan_stripq_result,
12456 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
12457 TOKEN_STRING_INITIALIZER
12458 (struct cmd_vf_vlan_stripq_result,
12460 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
12461 TOKEN_NUM_INITIALIZER
12462 (struct cmd_vf_vlan_stripq_result,
12464 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
12465 TOKEN_NUM_INITIALIZER
12466 (struct cmd_vf_vlan_stripq_result,
12468 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
12469 TOKEN_STRING_INITIALIZER
12470 (struct cmd_vf_vlan_stripq_result,
12474 cmd_set_vf_vlan_stripq_parsed(
12475 void *parsed_result,
12476 __attribute__((unused)) struct cmdline *cl,
12477 __attribute__((unused)) void *data)
12479 struct cmd_vf_vlan_stripq_result *res = parsed_result;
12480 int ret = -ENOTSUP;
12482 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12484 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12487 #ifdef RTE_LIBRTE_IXGBE_PMD
12488 if (ret == -ENOTSUP)
12489 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
12490 res->vf_id, is_on);
12492 #ifdef RTE_LIBRTE_I40E_PMD
12493 if (ret == -ENOTSUP)
12494 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
12495 res->vf_id, is_on);
12497 #ifdef RTE_LIBRTE_BNXT_PMD
12498 if (ret == -ENOTSUP)
12499 ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
12500 res->vf_id, is_on);
12507 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12510 printf("invalid port_id %d\n", res->port_id);
12513 printf("function not implemented\n");
12516 printf("programming error: (%s)\n", strerror(-ret));
12520 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
12521 .f = cmd_set_vf_vlan_stripq_parsed,
12523 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
12525 (void *)&cmd_vf_vlan_stripq_set,
12526 (void *)&cmd_vf_vlan_stripq_vf,
12527 (void *)&cmd_vf_vlan_stripq_vlan,
12528 (void *)&cmd_vf_vlan_stripq_stripq,
12529 (void *)&cmd_vf_vlan_stripq_port_id,
12530 (void *)&cmd_vf_vlan_stripq_vf_id,
12531 (void *)&cmd_vf_vlan_stripq_on_off,
12536 /* vf vlan insert configuration */
12538 /* Common result structure for vf vlan insert */
12539 struct cmd_vf_vlan_insert_result {
12540 cmdline_fixed_string_t set;
12541 cmdline_fixed_string_t vf;
12542 cmdline_fixed_string_t vlan;
12543 cmdline_fixed_string_t insert;
12549 /* Common CLI fields for vf vlan insert enable disable */
12550 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
12551 TOKEN_STRING_INITIALIZER
12552 (struct cmd_vf_vlan_insert_result,
12554 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
12555 TOKEN_STRING_INITIALIZER
12556 (struct cmd_vf_vlan_insert_result,
12558 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
12559 TOKEN_STRING_INITIALIZER
12560 (struct cmd_vf_vlan_insert_result,
12562 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
12563 TOKEN_STRING_INITIALIZER
12564 (struct cmd_vf_vlan_insert_result,
12566 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
12567 TOKEN_NUM_INITIALIZER
12568 (struct cmd_vf_vlan_insert_result,
12570 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
12571 TOKEN_NUM_INITIALIZER
12572 (struct cmd_vf_vlan_insert_result,
12574 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
12575 TOKEN_NUM_INITIALIZER
12576 (struct cmd_vf_vlan_insert_result,
12580 cmd_set_vf_vlan_insert_parsed(
12581 void *parsed_result,
12582 __attribute__((unused)) struct cmdline *cl,
12583 __attribute__((unused)) void *data)
12585 struct cmd_vf_vlan_insert_result *res = parsed_result;
12586 int ret = -ENOTSUP;
12588 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12591 #ifdef RTE_LIBRTE_IXGBE_PMD
12592 if (ret == -ENOTSUP)
12593 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
12596 #ifdef RTE_LIBRTE_I40E_PMD
12597 if (ret == -ENOTSUP)
12598 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
12601 #ifdef RTE_LIBRTE_BNXT_PMD
12602 if (ret == -ENOTSUP)
12603 ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
12611 printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id);
12614 printf("invalid port_id %d\n", res->port_id);
12617 printf("function not implemented\n");
12620 printf("programming error: (%s)\n", strerror(-ret));
12624 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
12625 .f = cmd_set_vf_vlan_insert_parsed,
12627 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
12629 (void *)&cmd_vf_vlan_insert_set,
12630 (void *)&cmd_vf_vlan_insert_vf,
12631 (void *)&cmd_vf_vlan_insert_vlan,
12632 (void *)&cmd_vf_vlan_insert_insert,
12633 (void *)&cmd_vf_vlan_insert_port_id,
12634 (void *)&cmd_vf_vlan_insert_vf_id,
12635 (void *)&cmd_vf_vlan_insert_vlan_id,
12640 /* tx loopback configuration */
12642 /* Common result structure for tx loopback */
12643 struct cmd_tx_loopback_result {
12644 cmdline_fixed_string_t set;
12645 cmdline_fixed_string_t tx;
12646 cmdline_fixed_string_t loopback;
12648 cmdline_fixed_string_t on_off;
12651 /* Common CLI fields for tx loopback enable disable */
12652 cmdline_parse_token_string_t cmd_tx_loopback_set =
12653 TOKEN_STRING_INITIALIZER
12654 (struct cmd_tx_loopback_result,
12656 cmdline_parse_token_string_t cmd_tx_loopback_tx =
12657 TOKEN_STRING_INITIALIZER
12658 (struct cmd_tx_loopback_result,
12660 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
12661 TOKEN_STRING_INITIALIZER
12662 (struct cmd_tx_loopback_result,
12663 loopback, "loopback");
12664 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
12665 TOKEN_NUM_INITIALIZER
12666 (struct cmd_tx_loopback_result,
12668 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
12669 TOKEN_STRING_INITIALIZER
12670 (struct cmd_tx_loopback_result,
12674 cmd_set_tx_loopback_parsed(
12675 void *parsed_result,
12676 __attribute__((unused)) struct cmdline *cl,
12677 __attribute__((unused)) void *data)
12679 struct cmd_tx_loopback_result *res = parsed_result;
12680 int ret = -ENOTSUP;
12682 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12684 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12687 #ifdef RTE_LIBRTE_IXGBE_PMD
12688 if (ret == -ENOTSUP)
12689 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
12691 #ifdef RTE_LIBRTE_I40E_PMD
12692 if (ret == -ENOTSUP)
12693 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
12695 #ifdef RTE_LIBRTE_BNXT_PMD
12696 if (ret == -ENOTSUP)
12697 ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
12704 printf("invalid is_on %d\n", is_on);
12707 printf("invalid port_id %d\n", res->port_id);
12710 printf("function not implemented\n");
12713 printf("programming error: (%s)\n", strerror(-ret));
12717 cmdline_parse_inst_t cmd_set_tx_loopback = {
12718 .f = cmd_set_tx_loopback_parsed,
12720 .help_str = "set tx loopback <port_id> on|off",
12722 (void *)&cmd_tx_loopback_set,
12723 (void *)&cmd_tx_loopback_tx,
12724 (void *)&cmd_tx_loopback_loopback,
12725 (void *)&cmd_tx_loopback_port_id,
12726 (void *)&cmd_tx_loopback_on_off,
12731 /* all queues drop enable configuration */
12733 /* Common result structure for all queues drop enable */
12734 struct cmd_all_queues_drop_en_result {
12735 cmdline_fixed_string_t set;
12736 cmdline_fixed_string_t all;
12737 cmdline_fixed_string_t queues;
12738 cmdline_fixed_string_t drop;
12740 cmdline_fixed_string_t on_off;
12743 /* Common CLI fields for tx loopback enable disable */
12744 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
12745 TOKEN_STRING_INITIALIZER
12746 (struct cmd_all_queues_drop_en_result,
12748 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
12749 TOKEN_STRING_INITIALIZER
12750 (struct cmd_all_queues_drop_en_result,
12752 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
12753 TOKEN_STRING_INITIALIZER
12754 (struct cmd_all_queues_drop_en_result,
12756 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
12757 TOKEN_STRING_INITIALIZER
12758 (struct cmd_all_queues_drop_en_result,
12760 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
12761 TOKEN_NUM_INITIALIZER
12762 (struct cmd_all_queues_drop_en_result,
12764 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
12765 TOKEN_STRING_INITIALIZER
12766 (struct cmd_all_queues_drop_en_result,
12770 cmd_set_all_queues_drop_en_parsed(
12771 void *parsed_result,
12772 __attribute__((unused)) struct cmdline *cl,
12773 __attribute__((unused)) void *data)
12775 struct cmd_all_queues_drop_en_result *res = parsed_result;
12776 int ret = -ENOTSUP;
12777 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12779 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12782 #ifdef RTE_LIBRTE_IXGBE_PMD
12783 if (ret == -ENOTSUP)
12784 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
12786 #ifdef RTE_LIBRTE_BNXT_PMD
12787 if (ret == -ENOTSUP)
12788 ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
12794 printf("invalid is_on %d\n", is_on);
12797 printf("invalid port_id %d\n", res->port_id);
12800 printf("function not implemented\n");
12803 printf("programming error: (%s)\n", strerror(-ret));
12807 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
12808 .f = cmd_set_all_queues_drop_en_parsed,
12810 .help_str = "set all queues drop <port_id> on|off",
12812 (void *)&cmd_all_queues_drop_en_set,
12813 (void *)&cmd_all_queues_drop_en_all,
12814 (void *)&cmd_all_queues_drop_en_queues,
12815 (void *)&cmd_all_queues_drop_en_drop,
12816 (void *)&cmd_all_queues_drop_en_port_id,
12817 (void *)&cmd_all_queues_drop_en_on_off,
12822 /* vf split drop enable configuration */
12824 /* Common result structure for vf split drop enable */
12825 struct cmd_vf_split_drop_en_result {
12826 cmdline_fixed_string_t set;
12827 cmdline_fixed_string_t vf;
12828 cmdline_fixed_string_t split;
12829 cmdline_fixed_string_t drop;
12832 cmdline_fixed_string_t on_off;
12835 /* Common CLI fields for vf split drop enable disable */
12836 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
12837 TOKEN_STRING_INITIALIZER
12838 (struct cmd_vf_split_drop_en_result,
12840 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
12841 TOKEN_STRING_INITIALIZER
12842 (struct cmd_vf_split_drop_en_result,
12844 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
12845 TOKEN_STRING_INITIALIZER
12846 (struct cmd_vf_split_drop_en_result,
12848 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
12849 TOKEN_STRING_INITIALIZER
12850 (struct cmd_vf_split_drop_en_result,
12852 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
12853 TOKEN_NUM_INITIALIZER
12854 (struct cmd_vf_split_drop_en_result,
12856 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
12857 TOKEN_NUM_INITIALIZER
12858 (struct cmd_vf_split_drop_en_result,
12860 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
12861 TOKEN_STRING_INITIALIZER
12862 (struct cmd_vf_split_drop_en_result,
12866 cmd_set_vf_split_drop_en_parsed(
12867 void *parsed_result,
12868 __attribute__((unused)) struct cmdline *cl,
12869 __attribute__((unused)) void *data)
12871 struct cmd_vf_split_drop_en_result *res = parsed_result;
12872 int ret = -ENOTSUP;
12873 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12875 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12878 #ifdef RTE_LIBRTE_IXGBE_PMD
12879 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
12886 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12889 printf("invalid port_id %d\n", res->port_id);
12892 printf("not supported on port %d\n", res->port_id);
12895 printf("programming error: (%s)\n", strerror(-ret));
12899 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
12900 .f = cmd_set_vf_split_drop_en_parsed,
12902 .help_str = "set vf split drop <port_id> <vf_id> on|off",
12904 (void *)&cmd_vf_split_drop_en_set,
12905 (void *)&cmd_vf_split_drop_en_vf,
12906 (void *)&cmd_vf_split_drop_en_split,
12907 (void *)&cmd_vf_split_drop_en_drop,
12908 (void *)&cmd_vf_split_drop_en_port_id,
12909 (void *)&cmd_vf_split_drop_en_vf_id,
12910 (void *)&cmd_vf_split_drop_en_on_off,
12915 /* vf mac address configuration */
12917 /* Common result structure for vf mac address */
12918 struct cmd_set_vf_mac_addr_result {
12919 cmdline_fixed_string_t set;
12920 cmdline_fixed_string_t vf;
12921 cmdline_fixed_string_t mac;
12922 cmdline_fixed_string_t addr;
12925 struct ether_addr mac_addr;
12929 /* Common CLI fields for vf split drop enable disable */
12930 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
12931 TOKEN_STRING_INITIALIZER
12932 (struct cmd_set_vf_mac_addr_result,
12934 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
12935 TOKEN_STRING_INITIALIZER
12936 (struct cmd_set_vf_mac_addr_result,
12938 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
12939 TOKEN_STRING_INITIALIZER
12940 (struct cmd_set_vf_mac_addr_result,
12942 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
12943 TOKEN_STRING_INITIALIZER
12944 (struct cmd_set_vf_mac_addr_result,
12946 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
12947 TOKEN_NUM_INITIALIZER
12948 (struct cmd_set_vf_mac_addr_result,
12950 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
12951 TOKEN_NUM_INITIALIZER
12952 (struct cmd_set_vf_mac_addr_result,
12954 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
12955 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
12959 cmd_set_vf_mac_addr_parsed(
12960 void *parsed_result,
12961 __attribute__((unused)) struct cmdline *cl,
12962 __attribute__((unused)) void *data)
12964 struct cmd_set_vf_mac_addr_result *res = parsed_result;
12965 int ret = -ENOTSUP;
12967 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12970 #ifdef RTE_LIBRTE_IXGBE_PMD
12971 if (ret == -ENOTSUP)
12972 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
12975 #ifdef RTE_LIBRTE_I40E_PMD
12976 if (ret == -ENOTSUP)
12977 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
12980 #ifdef RTE_LIBRTE_BNXT_PMD
12981 if (ret == -ENOTSUP)
12982 ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
12990 printf("invalid vf_id %d or mac_addr\n", res->vf_id);
12993 printf("invalid port_id %d\n", res->port_id);
12996 printf("function not implemented\n");
12999 printf("programming error: (%s)\n", strerror(-ret));
13003 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
13004 .f = cmd_set_vf_mac_addr_parsed,
13006 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
13008 (void *)&cmd_set_vf_mac_addr_set,
13009 (void *)&cmd_set_vf_mac_addr_vf,
13010 (void *)&cmd_set_vf_mac_addr_mac,
13011 (void *)&cmd_set_vf_mac_addr_addr,
13012 (void *)&cmd_set_vf_mac_addr_port_id,
13013 (void *)&cmd_set_vf_mac_addr_vf_id,
13014 (void *)&cmd_set_vf_mac_addr_mac_addr,
13019 /* MACsec configuration */
13021 /* Common result structure for MACsec offload enable */
13022 struct cmd_macsec_offload_on_result {
13023 cmdline_fixed_string_t set;
13024 cmdline_fixed_string_t macsec;
13025 cmdline_fixed_string_t offload;
13027 cmdline_fixed_string_t on;
13028 cmdline_fixed_string_t encrypt;
13029 cmdline_fixed_string_t en_on_off;
13030 cmdline_fixed_string_t replay_protect;
13031 cmdline_fixed_string_t rp_on_off;
13034 /* Common CLI fields for MACsec offload disable */
13035 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
13036 TOKEN_STRING_INITIALIZER
13037 (struct cmd_macsec_offload_on_result,
13039 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
13040 TOKEN_STRING_INITIALIZER
13041 (struct cmd_macsec_offload_on_result,
13043 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
13044 TOKEN_STRING_INITIALIZER
13045 (struct cmd_macsec_offload_on_result,
13046 offload, "offload");
13047 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
13048 TOKEN_NUM_INITIALIZER
13049 (struct cmd_macsec_offload_on_result,
13051 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
13052 TOKEN_STRING_INITIALIZER
13053 (struct cmd_macsec_offload_on_result,
13055 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
13056 TOKEN_STRING_INITIALIZER
13057 (struct cmd_macsec_offload_on_result,
13058 encrypt, "encrypt");
13059 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
13060 TOKEN_STRING_INITIALIZER
13061 (struct cmd_macsec_offload_on_result,
13062 en_on_off, "on#off");
13063 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
13064 TOKEN_STRING_INITIALIZER
13065 (struct cmd_macsec_offload_on_result,
13066 replay_protect, "replay-protect");
13067 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
13068 TOKEN_STRING_INITIALIZER
13069 (struct cmd_macsec_offload_on_result,
13070 rp_on_off, "on#off");
13073 cmd_set_macsec_offload_on_parsed(
13074 void *parsed_result,
13075 __attribute__((unused)) struct cmdline *cl,
13076 __attribute__((unused)) void *data)
13078 struct cmd_macsec_offload_on_result *res = parsed_result;
13079 int ret = -ENOTSUP;
13080 portid_t port_id = res->port_id;
13081 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
13082 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
13084 if (port_id_is_invalid(port_id, ENABLED_WARN))
13086 if (!port_is_stopped(port_id)) {
13087 printf("Please stop port %d first\n", port_id);
13091 ports[port_id].dev_conf.txmode.offloads |= DEV_TX_OFFLOAD_MACSEC_INSERT;
13092 #ifdef RTE_LIBRTE_IXGBE_PMD
13093 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
13100 cmd_reconfig_device_queue(port_id, 1, 1);
13103 printf("invalid port_id %d\n", port_id);
13106 printf("not supported on port %d\n", port_id);
13109 printf("programming error: (%s)\n", strerror(-ret));
13113 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
13114 .f = cmd_set_macsec_offload_on_parsed,
13116 .help_str = "set macsec offload <port_id> on "
13117 "encrypt on|off replay-protect on|off",
13119 (void *)&cmd_macsec_offload_on_set,
13120 (void *)&cmd_macsec_offload_on_macsec,
13121 (void *)&cmd_macsec_offload_on_offload,
13122 (void *)&cmd_macsec_offload_on_port_id,
13123 (void *)&cmd_macsec_offload_on_on,
13124 (void *)&cmd_macsec_offload_on_encrypt,
13125 (void *)&cmd_macsec_offload_on_en_on_off,
13126 (void *)&cmd_macsec_offload_on_replay_protect,
13127 (void *)&cmd_macsec_offload_on_rp_on_off,
13132 /* Common result structure for MACsec offload disable */
13133 struct cmd_macsec_offload_off_result {
13134 cmdline_fixed_string_t set;
13135 cmdline_fixed_string_t macsec;
13136 cmdline_fixed_string_t offload;
13138 cmdline_fixed_string_t off;
13141 /* Common CLI fields for MACsec offload disable */
13142 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
13143 TOKEN_STRING_INITIALIZER
13144 (struct cmd_macsec_offload_off_result,
13146 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
13147 TOKEN_STRING_INITIALIZER
13148 (struct cmd_macsec_offload_off_result,
13150 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
13151 TOKEN_STRING_INITIALIZER
13152 (struct cmd_macsec_offload_off_result,
13153 offload, "offload");
13154 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
13155 TOKEN_NUM_INITIALIZER
13156 (struct cmd_macsec_offload_off_result,
13158 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
13159 TOKEN_STRING_INITIALIZER
13160 (struct cmd_macsec_offload_off_result,
13164 cmd_set_macsec_offload_off_parsed(
13165 void *parsed_result,
13166 __attribute__((unused)) struct cmdline *cl,
13167 __attribute__((unused)) void *data)
13169 struct cmd_macsec_offload_off_result *res = parsed_result;
13170 int ret = -ENOTSUP;
13171 portid_t port_id = res->port_id;
13173 if (port_id_is_invalid(port_id, ENABLED_WARN))
13175 if (!port_is_stopped(port_id)) {
13176 printf("Please stop port %d first\n", port_id);
13180 ports[port_id].dev_conf.txmode.offloads &=
13181 ~DEV_TX_OFFLOAD_MACSEC_INSERT;
13182 #ifdef RTE_LIBRTE_IXGBE_PMD
13183 ret = rte_pmd_ixgbe_macsec_disable(port_id);
13188 cmd_reconfig_device_queue(port_id, 1, 1);
13191 printf("invalid port_id %d\n", port_id);
13194 printf("not supported on port %d\n", port_id);
13197 printf("programming error: (%s)\n", strerror(-ret));
13201 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
13202 .f = cmd_set_macsec_offload_off_parsed,
13204 .help_str = "set macsec offload <port_id> off",
13206 (void *)&cmd_macsec_offload_off_set,
13207 (void *)&cmd_macsec_offload_off_macsec,
13208 (void *)&cmd_macsec_offload_off_offload,
13209 (void *)&cmd_macsec_offload_off_port_id,
13210 (void *)&cmd_macsec_offload_off_off,
13215 /* Common result structure for MACsec secure connection configure */
13216 struct cmd_macsec_sc_result {
13217 cmdline_fixed_string_t set;
13218 cmdline_fixed_string_t macsec;
13219 cmdline_fixed_string_t sc;
13220 cmdline_fixed_string_t tx_rx;
13222 struct ether_addr mac;
13226 /* Common CLI fields for MACsec secure connection configure */
13227 cmdline_parse_token_string_t cmd_macsec_sc_set =
13228 TOKEN_STRING_INITIALIZER
13229 (struct cmd_macsec_sc_result,
13231 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
13232 TOKEN_STRING_INITIALIZER
13233 (struct cmd_macsec_sc_result,
13235 cmdline_parse_token_string_t cmd_macsec_sc_sc =
13236 TOKEN_STRING_INITIALIZER
13237 (struct cmd_macsec_sc_result,
13239 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
13240 TOKEN_STRING_INITIALIZER
13241 (struct cmd_macsec_sc_result,
13243 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
13244 TOKEN_NUM_INITIALIZER
13245 (struct cmd_macsec_sc_result,
13247 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
13248 TOKEN_ETHERADDR_INITIALIZER
13249 (struct cmd_macsec_sc_result,
13251 cmdline_parse_token_num_t cmd_macsec_sc_pi =
13252 TOKEN_NUM_INITIALIZER
13253 (struct cmd_macsec_sc_result,
13257 cmd_set_macsec_sc_parsed(
13258 void *parsed_result,
13259 __attribute__((unused)) struct cmdline *cl,
13260 __attribute__((unused)) void *data)
13262 struct cmd_macsec_sc_result *res = parsed_result;
13263 int ret = -ENOTSUP;
13264 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
13266 #ifdef RTE_LIBRTE_IXGBE_PMD
13268 rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
13269 res->mac.addr_bytes) :
13270 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
13271 res->mac.addr_bytes, res->pi);
13273 RTE_SET_USED(is_tx);
13279 printf("invalid port_id %d\n", res->port_id);
13282 printf("not supported on port %d\n", res->port_id);
13285 printf("programming error: (%s)\n", strerror(-ret));
13289 cmdline_parse_inst_t cmd_set_macsec_sc = {
13290 .f = cmd_set_macsec_sc_parsed,
13292 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
13294 (void *)&cmd_macsec_sc_set,
13295 (void *)&cmd_macsec_sc_macsec,
13296 (void *)&cmd_macsec_sc_sc,
13297 (void *)&cmd_macsec_sc_tx_rx,
13298 (void *)&cmd_macsec_sc_port_id,
13299 (void *)&cmd_macsec_sc_mac,
13300 (void *)&cmd_macsec_sc_pi,
13305 /* Common result structure for MACsec secure connection configure */
13306 struct cmd_macsec_sa_result {
13307 cmdline_fixed_string_t set;
13308 cmdline_fixed_string_t macsec;
13309 cmdline_fixed_string_t sa;
13310 cmdline_fixed_string_t tx_rx;
13315 cmdline_fixed_string_t key;
13318 /* Common CLI fields for MACsec secure connection configure */
13319 cmdline_parse_token_string_t cmd_macsec_sa_set =
13320 TOKEN_STRING_INITIALIZER
13321 (struct cmd_macsec_sa_result,
13323 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
13324 TOKEN_STRING_INITIALIZER
13325 (struct cmd_macsec_sa_result,
13327 cmdline_parse_token_string_t cmd_macsec_sa_sa =
13328 TOKEN_STRING_INITIALIZER
13329 (struct cmd_macsec_sa_result,
13331 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
13332 TOKEN_STRING_INITIALIZER
13333 (struct cmd_macsec_sa_result,
13335 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
13336 TOKEN_NUM_INITIALIZER
13337 (struct cmd_macsec_sa_result,
13339 cmdline_parse_token_num_t cmd_macsec_sa_idx =
13340 TOKEN_NUM_INITIALIZER
13341 (struct cmd_macsec_sa_result,
13343 cmdline_parse_token_num_t cmd_macsec_sa_an =
13344 TOKEN_NUM_INITIALIZER
13345 (struct cmd_macsec_sa_result,
13347 cmdline_parse_token_num_t cmd_macsec_sa_pn =
13348 TOKEN_NUM_INITIALIZER
13349 (struct cmd_macsec_sa_result,
13351 cmdline_parse_token_string_t cmd_macsec_sa_key =
13352 TOKEN_STRING_INITIALIZER
13353 (struct cmd_macsec_sa_result,
13357 cmd_set_macsec_sa_parsed(
13358 void *parsed_result,
13359 __attribute__((unused)) struct cmdline *cl,
13360 __attribute__((unused)) void *data)
13362 struct cmd_macsec_sa_result *res = parsed_result;
13363 int ret = -ENOTSUP;
13364 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
13365 uint8_t key[16] = { 0 };
13371 key_len = strlen(res->key) / 2;
13375 for (i = 0; i < key_len; i++) {
13376 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
13379 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
13382 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
13385 #ifdef RTE_LIBRTE_IXGBE_PMD
13387 rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
13388 res->idx, res->an, res->pn, key) :
13389 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
13390 res->idx, res->an, res->pn, key);
13392 RTE_SET_USED(is_tx);
13399 printf("invalid idx %d or an %d\n", res->idx, res->an);
13402 printf("invalid port_id %d\n", res->port_id);
13405 printf("not supported on port %d\n", res->port_id);
13408 printf("programming error: (%s)\n", strerror(-ret));
13412 cmdline_parse_inst_t cmd_set_macsec_sa = {
13413 .f = cmd_set_macsec_sa_parsed,
13415 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
13417 (void *)&cmd_macsec_sa_set,
13418 (void *)&cmd_macsec_sa_macsec,
13419 (void *)&cmd_macsec_sa_sa,
13420 (void *)&cmd_macsec_sa_tx_rx,
13421 (void *)&cmd_macsec_sa_port_id,
13422 (void *)&cmd_macsec_sa_idx,
13423 (void *)&cmd_macsec_sa_an,
13424 (void *)&cmd_macsec_sa_pn,
13425 (void *)&cmd_macsec_sa_key,
13430 /* VF unicast promiscuous mode configuration */
13432 /* Common result structure for VF unicast promiscuous mode */
13433 struct cmd_vf_promisc_result {
13434 cmdline_fixed_string_t set;
13435 cmdline_fixed_string_t vf;
13436 cmdline_fixed_string_t promisc;
13439 cmdline_fixed_string_t on_off;
13442 /* Common CLI fields for VF unicast promiscuous mode enable disable */
13443 cmdline_parse_token_string_t cmd_vf_promisc_set =
13444 TOKEN_STRING_INITIALIZER
13445 (struct cmd_vf_promisc_result,
13447 cmdline_parse_token_string_t cmd_vf_promisc_vf =
13448 TOKEN_STRING_INITIALIZER
13449 (struct cmd_vf_promisc_result,
13451 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
13452 TOKEN_STRING_INITIALIZER
13453 (struct cmd_vf_promisc_result,
13454 promisc, "promisc");
13455 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
13456 TOKEN_NUM_INITIALIZER
13457 (struct cmd_vf_promisc_result,
13459 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
13460 TOKEN_NUM_INITIALIZER
13461 (struct cmd_vf_promisc_result,
13463 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
13464 TOKEN_STRING_INITIALIZER
13465 (struct cmd_vf_promisc_result,
13469 cmd_set_vf_promisc_parsed(
13470 void *parsed_result,
13471 __attribute__((unused)) struct cmdline *cl,
13472 __attribute__((unused)) void *data)
13474 struct cmd_vf_promisc_result *res = parsed_result;
13475 int ret = -ENOTSUP;
13477 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13479 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13482 #ifdef RTE_LIBRTE_I40E_PMD
13483 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
13484 res->vf_id, is_on);
13491 printf("invalid vf_id %d\n", res->vf_id);
13494 printf("invalid port_id %d\n", res->port_id);
13497 printf("function not implemented\n");
13500 printf("programming error: (%s)\n", strerror(-ret));
13504 cmdline_parse_inst_t cmd_set_vf_promisc = {
13505 .f = cmd_set_vf_promisc_parsed,
13507 .help_str = "set vf promisc <port_id> <vf_id> on|off: "
13508 "Set unicast promiscuous mode for a VF from the PF",
13510 (void *)&cmd_vf_promisc_set,
13511 (void *)&cmd_vf_promisc_vf,
13512 (void *)&cmd_vf_promisc_promisc,
13513 (void *)&cmd_vf_promisc_port_id,
13514 (void *)&cmd_vf_promisc_vf_id,
13515 (void *)&cmd_vf_promisc_on_off,
13520 /* VF multicast promiscuous mode configuration */
13522 /* Common result structure for VF multicast promiscuous mode */
13523 struct cmd_vf_allmulti_result {
13524 cmdline_fixed_string_t set;
13525 cmdline_fixed_string_t vf;
13526 cmdline_fixed_string_t allmulti;
13529 cmdline_fixed_string_t on_off;
13532 /* Common CLI fields for VF multicast promiscuous mode enable disable */
13533 cmdline_parse_token_string_t cmd_vf_allmulti_set =
13534 TOKEN_STRING_INITIALIZER
13535 (struct cmd_vf_allmulti_result,
13537 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
13538 TOKEN_STRING_INITIALIZER
13539 (struct cmd_vf_allmulti_result,
13541 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
13542 TOKEN_STRING_INITIALIZER
13543 (struct cmd_vf_allmulti_result,
13544 allmulti, "allmulti");
13545 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
13546 TOKEN_NUM_INITIALIZER
13547 (struct cmd_vf_allmulti_result,
13549 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
13550 TOKEN_NUM_INITIALIZER
13551 (struct cmd_vf_allmulti_result,
13553 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
13554 TOKEN_STRING_INITIALIZER
13555 (struct cmd_vf_allmulti_result,
13559 cmd_set_vf_allmulti_parsed(
13560 void *parsed_result,
13561 __attribute__((unused)) struct cmdline *cl,
13562 __attribute__((unused)) void *data)
13564 struct cmd_vf_allmulti_result *res = parsed_result;
13565 int ret = -ENOTSUP;
13567 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13569 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13572 #ifdef RTE_LIBRTE_I40E_PMD
13573 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
13574 res->vf_id, is_on);
13581 printf("invalid vf_id %d\n", res->vf_id);
13584 printf("invalid port_id %d\n", res->port_id);
13587 printf("function not implemented\n");
13590 printf("programming error: (%s)\n", strerror(-ret));
13594 cmdline_parse_inst_t cmd_set_vf_allmulti = {
13595 .f = cmd_set_vf_allmulti_parsed,
13597 .help_str = "set vf allmulti <port_id> <vf_id> on|off: "
13598 "Set multicast promiscuous mode for a VF from the PF",
13600 (void *)&cmd_vf_allmulti_set,
13601 (void *)&cmd_vf_allmulti_vf,
13602 (void *)&cmd_vf_allmulti_allmulti,
13603 (void *)&cmd_vf_allmulti_port_id,
13604 (void *)&cmd_vf_allmulti_vf_id,
13605 (void *)&cmd_vf_allmulti_on_off,
13610 /* vf broadcast mode configuration */
13612 /* Common result structure for vf broadcast */
13613 struct cmd_set_vf_broadcast_result {
13614 cmdline_fixed_string_t set;
13615 cmdline_fixed_string_t vf;
13616 cmdline_fixed_string_t broadcast;
13619 cmdline_fixed_string_t on_off;
13622 /* Common CLI fields for vf broadcast enable disable */
13623 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
13624 TOKEN_STRING_INITIALIZER
13625 (struct cmd_set_vf_broadcast_result,
13627 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
13628 TOKEN_STRING_INITIALIZER
13629 (struct cmd_set_vf_broadcast_result,
13631 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
13632 TOKEN_STRING_INITIALIZER
13633 (struct cmd_set_vf_broadcast_result,
13634 broadcast, "broadcast");
13635 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
13636 TOKEN_NUM_INITIALIZER
13637 (struct cmd_set_vf_broadcast_result,
13639 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
13640 TOKEN_NUM_INITIALIZER
13641 (struct cmd_set_vf_broadcast_result,
13643 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
13644 TOKEN_STRING_INITIALIZER
13645 (struct cmd_set_vf_broadcast_result,
13649 cmd_set_vf_broadcast_parsed(
13650 void *parsed_result,
13651 __attribute__((unused)) struct cmdline *cl,
13652 __attribute__((unused)) void *data)
13654 struct cmd_set_vf_broadcast_result *res = parsed_result;
13655 int ret = -ENOTSUP;
13657 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13659 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13662 #ifdef RTE_LIBRTE_I40E_PMD
13663 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
13664 res->vf_id, is_on);
13671 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13674 printf("invalid port_id %d\n", res->port_id);
13677 printf("function not implemented\n");
13680 printf("programming error: (%s)\n", strerror(-ret));
13684 cmdline_parse_inst_t cmd_set_vf_broadcast = {
13685 .f = cmd_set_vf_broadcast_parsed,
13687 .help_str = "set vf broadcast <port_id> <vf_id> on|off",
13689 (void *)&cmd_set_vf_broadcast_set,
13690 (void *)&cmd_set_vf_broadcast_vf,
13691 (void *)&cmd_set_vf_broadcast_broadcast,
13692 (void *)&cmd_set_vf_broadcast_port_id,
13693 (void *)&cmd_set_vf_broadcast_vf_id,
13694 (void *)&cmd_set_vf_broadcast_on_off,
13699 /* vf vlan tag configuration */
13701 /* Common result structure for vf vlan tag */
13702 struct cmd_set_vf_vlan_tag_result {
13703 cmdline_fixed_string_t set;
13704 cmdline_fixed_string_t vf;
13705 cmdline_fixed_string_t vlan;
13706 cmdline_fixed_string_t tag;
13709 cmdline_fixed_string_t on_off;
13712 /* Common CLI fields for vf vlan tag enable disable */
13713 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
13714 TOKEN_STRING_INITIALIZER
13715 (struct cmd_set_vf_vlan_tag_result,
13717 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
13718 TOKEN_STRING_INITIALIZER
13719 (struct cmd_set_vf_vlan_tag_result,
13721 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
13722 TOKEN_STRING_INITIALIZER
13723 (struct cmd_set_vf_vlan_tag_result,
13725 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
13726 TOKEN_STRING_INITIALIZER
13727 (struct cmd_set_vf_vlan_tag_result,
13729 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
13730 TOKEN_NUM_INITIALIZER
13731 (struct cmd_set_vf_vlan_tag_result,
13733 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
13734 TOKEN_NUM_INITIALIZER
13735 (struct cmd_set_vf_vlan_tag_result,
13737 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
13738 TOKEN_STRING_INITIALIZER
13739 (struct cmd_set_vf_vlan_tag_result,
13743 cmd_set_vf_vlan_tag_parsed(
13744 void *parsed_result,
13745 __attribute__((unused)) struct cmdline *cl,
13746 __attribute__((unused)) void *data)
13748 struct cmd_set_vf_vlan_tag_result *res = parsed_result;
13749 int ret = -ENOTSUP;
13751 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13753 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13756 #ifdef RTE_LIBRTE_I40E_PMD
13757 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
13758 res->vf_id, is_on);
13765 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13768 printf("invalid port_id %d\n", res->port_id);
13771 printf("function not implemented\n");
13774 printf("programming error: (%s)\n", strerror(-ret));
13778 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
13779 .f = cmd_set_vf_vlan_tag_parsed,
13781 .help_str = "set vf vlan tag <port_id> <vf_id> on|off",
13783 (void *)&cmd_set_vf_vlan_tag_set,
13784 (void *)&cmd_set_vf_vlan_tag_vf,
13785 (void *)&cmd_set_vf_vlan_tag_vlan,
13786 (void *)&cmd_set_vf_vlan_tag_tag,
13787 (void *)&cmd_set_vf_vlan_tag_port_id,
13788 (void *)&cmd_set_vf_vlan_tag_vf_id,
13789 (void *)&cmd_set_vf_vlan_tag_on_off,
13794 /* Common definition of VF and TC TX bandwidth configuration */
13795 struct cmd_vf_tc_bw_result {
13796 cmdline_fixed_string_t set;
13797 cmdline_fixed_string_t vf;
13798 cmdline_fixed_string_t tc;
13799 cmdline_fixed_string_t tx;
13800 cmdline_fixed_string_t min_bw;
13801 cmdline_fixed_string_t max_bw;
13802 cmdline_fixed_string_t strict_link_prio;
13807 cmdline_fixed_string_t bw_list;
13811 cmdline_parse_token_string_t cmd_vf_tc_bw_set =
13812 TOKEN_STRING_INITIALIZER
13813 (struct cmd_vf_tc_bw_result,
13815 cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
13816 TOKEN_STRING_INITIALIZER
13817 (struct cmd_vf_tc_bw_result,
13819 cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
13820 TOKEN_STRING_INITIALIZER
13821 (struct cmd_vf_tc_bw_result,
13823 cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
13824 TOKEN_STRING_INITIALIZER
13825 (struct cmd_vf_tc_bw_result,
13827 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio =
13828 TOKEN_STRING_INITIALIZER
13829 (struct cmd_vf_tc_bw_result,
13830 strict_link_prio, "strict-link-priority");
13831 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw =
13832 TOKEN_STRING_INITIALIZER
13833 (struct cmd_vf_tc_bw_result,
13834 min_bw, "min-bandwidth");
13835 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
13836 TOKEN_STRING_INITIALIZER
13837 (struct cmd_vf_tc_bw_result,
13838 max_bw, "max-bandwidth");
13839 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
13840 TOKEN_NUM_INITIALIZER
13841 (struct cmd_vf_tc_bw_result,
13843 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
13844 TOKEN_NUM_INITIALIZER
13845 (struct cmd_vf_tc_bw_result,
13847 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no =
13848 TOKEN_NUM_INITIALIZER
13849 (struct cmd_vf_tc_bw_result,
13851 cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
13852 TOKEN_NUM_INITIALIZER
13853 (struct cmd_vf_tc_bw_result,
13855 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
13856 TOKEN_STRING_INITIALIZER
13857 (struct cmd_vf_tc_bw_result,
13859 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map =
13860 TOKEN_NUM_INITIALIZER
13861 (struct cmd_vf_tc_bw_result,
13864 /* VF max bandwidth setting */
13866 cmd_vf_max_bw_parsed(
13867 void *parsed_result,
13868 __attribute__((unused)) struct cmdline *cl,
13869 __attribute__((unused)) void *data)
13871 struct cmd_vf_tc_bw_result *res = parsed_result;
13872 int ret = -ENOTSUP;
13874 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13877 #ifdef RTE_LIBRTE_I40E_PMD
13878 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id,
13879 res->vf_id, res->bw);
13886 printf("invalid vf_id %d or bandwidth %d\n",
13887 res->vf_id, res->bw);
13890 printf("invalid port_id %d\n", res->port_id);
13893 printf("function not implemented\n");
13896 printf("programming error: (%s)\n", strerror(-ret));
13900 cmdline_parse_inst_t cmd_vf_max_bw = {
13901 .f = cmd_vf_max_bw_parsed,
13903 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
13905 (void *)&cmd_vf_tc_bw_set,
13906 (void *)&cmd_vf_tc_bw_vf,
13907 (void *)&cmd_vf_tc_bw_tx,
13908 (void *)&cmd_vf_tc_bw_max_bw,
13909 (void *)&cmd_vf_tc_bw_port_id,
13910 (void *)&cmd_vf_tc_bw_vf_id,
13911 (void *)&cmd_vf_tc_bw_bw,
13917 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
13922 const char *p, *p0 = str;
13929 p = strchr(p0, '(');
13931 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
13935 p0 = strchr(p, ')');
13937 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
13941 if (size >= sizeof(s)) {
13942 printf("The string size exceeds the internal buffer size\n");
13945 snprintf(s, sizeof(s), "%.*s", size, p);
13946 ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
13948 printf("Failed to get the bandwidth list. ");
13952 for (i = 0; i < ret; i++)
13953 bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
13958 /* TC min bandwidth setting */
13960 cmd_vf_tc_min_bw_parsed(
13961 void *parsed_result,
13962 __attribute__((unused)) struct cmdline *cl,
13963 __attribute__((unused)) void *data)
13965 struct cmd_vf_tc_bw_result *res = parsed_result;
13968 int ret = -ENOTSUP;
13970 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13973 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
13977 #ifdef RTE_LIBRTE_I40E_PMD
13978 ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
13986 printf("invalid vf_id %d or bandwidth\n", res->vf_id);
13989 printf("invalid port_id %d\n", res->port_id);
13992 printf("function not implemented\n");
13995 printf("programming error: (%s)\n", strerror(-ret));
13999 cmdline_parse_inst_t cmd_vf_tc_min_bw = {
14000 .f = cmd_vf_tc_min_bw_parsed,
14002 .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
14003 " <bw1, bw2, ...>",
14005 (void *)&cmd_vf_tc_bw_set,
14006 (void *)&cmd_vf_tc_bw_vf,
14007 (void *)&cmd_vf_tc_bw_tc,
14008 (void *)&cmd_vf_tc_bw_tx,
14009 (void *)&cmd_vf_tc_bw_min_bw,
14010 (void *)&cmd_vf_tc_bw_port_id,
14011 (void *)&cmd_vf_tc_bw_vf_id,
14012 (void *)&cmd_vf_tc_bw_bw_list,
14018 cmd_tc_min_bw_parsed(
14019 void *parsed_result,
14020 __attribute__((unused)) struct cmdline *cl,
14021 __attribute__((unused)) void *data)
14023 struct cmd_vf_tc_bw_result *res = parsed_result;
14024 struct rte_port *port;
14027 int ret = -ENOTSUP;
14029 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14032 port = &ports[res->port_id];
14033 /** Check if the port is not started **/
14034 if (port->port_status != RTE_PORT_STOPPED) {
14035 printf("Please stop port %d first\n", res->port_id);
14039 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
14043 #ifdef RTE_LIBRTE_IXGBE_PMD
14044 ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw);
14051 printf("invalid bandwidth\n");
14054 printf("invalid port_id %d\n", res->port_id);
14057 printf("function not implemented\n");
14060 printf("programming error: (%s)\n", strerror(-ret));
14064 cmdline_parse_inst_t cmd_tc_min_bw = {
14065 .f = cmd_tc_min_bw_parsed,
14067 .help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>",
14069 (void *)&cmd_vf_tc_bw_set,
14070 (void *)&cmd_vf_tc_bw_tc,
14071 (void *)&cmd_vf_tc_bw_tx,
14072 (void *)&cmd_vf_tc_bw_min_bw,
14073 (void *)&cmd_vf_tc_bw_port_id,
14074 (void *)&cmd_vf_tc_bw_bw_list,
14079 /* TC max bandwidth setting */
14081 cmd_vf_tc_max_bw_parsed(
14082 void *parsed_result,
14083 __attribute__((unused)) struct cmdline *cl,
14084 __attribute__((unused)) void *data)
14086 struct cmd_vf_tc_bw_result *res = parsed_result;
14087 int ret = -ENOTSUP;
14089 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14092 #ifdef RTE_LIBRTE_I40E_PMD
14093 ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id,
14094 res->tc_no, res->bw);
14101 printf("invalid vf_id %d, tc_no %d or bandwidth %d\n",
14102 res->vf_id, res->tc_no, res->bw);
14105 printf("invalid port_id %d\n", res->port_id);
14108 printf("function not implemented\n");
14111 printf("programming error: (%s)\n", strerror(-ret));
14115 cmdline_parse_inst_t cmd_vf_tc_max_bw = {
14116 .f = cmd_vf_tc_max_bw_parsed,
14118 .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>"
14121 (void *)&cmd_vf_tc_bw_set,
14122 (void *)&cmd_vf_tc_bw_vf,
14123 (void *)&cmd_vf_tc_bw_tc,
14124 (void *)&cmd_vf_tc_bw_tx,
14125 (void *)&cmd_vf_tc_bw_max_bw,
14126 (void *)&cmd_vf_tc_bw_port_id,
14127 (void *)&cmd_vf_tc_bw_vf_id,
14128 (void *)&cmd_vf_tc_bw_tc_no,
14129 (void *)&cmd_vf_tc_bw_bw,
14135 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
14137 /* *** Set Port default Traffic Management Hierarchy *** */
14138 struct cmd_set_port_tm_hierarchy_default_result {
14139 cmdline_fixed_string_t set;
14140 cmdline_fixed_string_t port;
14141 cmdline_fixed_string_t tm;
14142 cmdline_fixed_string_t hierarchy;
14143 cmdline_fixed_string_t def;
14147 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_set =
14148 TOKEN_STRING_INITIALIZER(
14149 struct cmd_set_port_tm_hierarchy_default_result, set, "set");
14150 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_port =
14151 TOKEN_STRING_INITIALIZER(
14152 struct cmd_set_port_tm_hierarchy_default_result, port, "port");
14153 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_tm =
14154 TOKEN_STRING_INITIALIZER(
14155 struct cmd_set_port_tm_hierarchy_default_result, tm, "tm");
14156 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_hierarchy =
14157 TOKEN_STRING_INITIALIZER(
14158 struct cmd_set_port_tm_hierarchy_default_result,
14159 hierarchy, "hierarchy");
14160 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_default =
14161 TOKEN_STRING_INITIALIZER(
14162 struct cmd_set_port_tm_hierarchy_default_result,
14164 cmdline_parse_token_num_t cmd_set_port_tm_hierarchy_default_port_id =
14165 TOKEN_NUM_INITIALIZER(
14166 struct cmd_set_port_tm_hierarchy_default_result,
14169 static void cmd_set_port_tm_hierarchy_default_parsed(void *parsed_result,
14170 __attribute__((unused)) struct cmdline *cl,
14171 __attribute__((unused)) void *data)
14173 struct cmd_set_port_tm_hierarchy_default_result *res = parsed_result;
14174 struct rte_port *p;
14175 portid_t port_id = res->port_id;
14177 if (port_id_is_invalid(port_id, ENABLED_WARN))
14180 p = &ports[port_id];
14183 if (p->softport.tm_flag == 0) {
14184 printf(" tm not enabled on port %u (error)\n", port_id);
14188 /* Forward mode: tm */
14189 if (strcmp(cur_fwd_config.fwd_eng->fwd_mode_name, "tm")) {
14190 printf(" tm mode not enabled(error)\n");
14194 /* Set the default tm hierarchy */
14195 p->softport.tm.default_hierarchy_enable = 1;
14198 cmdline_parse_inst_t cmd_set_port_tm_hierarchy_default = {
14199 .f = cmd_set_port_tm_hierarchy_default_parsed,
14201 .help_str = "set port tm hierarchy default <port_id>",
14203 (void *)&cmd_set_port_tm_hierarchy_default_set,
14204 (void *)&cmd_set_port_tm_hierarchy_default_port,
14205 (void *)&cmd_set_port_tm_hierarchy_default_tm,
14206 (void *)&cmd_set_port_tm_hierarchy_default_hierarchy,
14207 (void *)&cmd_set_port_tm_hierarchy_default_default,
14208 (void *)&cmd_set_port_tm_hierarchy_default_port_id,
14214 /* Strict link priority scheduling mode setting */
14216 cmd_strict_link_prio_parsed(
14217 void *parsed_result,
14218 __attribute__((unused)) struct cmdline *cl,
14219 __attribute__((unused)) void *data)
14221 struct cmd_vf_tc_bw_result *res = parsed_result;
14222 int ret = -ENOTSUP;
14224 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14227 #ifdef RTE_LIBRTE_I40E_PMD
14228 ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map);
14235 printf("invalid tc_bitmap 0x%x\n", res->tc_map);
14238 printf("invalid port_id %d\n", res->port_id);
14241 printf("function not implemented\n");
14244 printf("programming error: (%s)\n", strerror(-ret));
14248 cmdline_parse_inst_t cmd_strict_link_prio = {
14249 .f = cmd_strict_link_prio_parsed,
14251 .help_str = "set tx strict-link-priority <port_id> <tc_bitmap>",
14253 (void *)&cmd_vf_tc_bw_set,
14254 (void *)&cmd_vf_tc_bw_tx,
14255 (void *)&cmd_vf_tc_bw_strict_link_prio,
14256 (void *)&cmd_vf_tc_bw_port_id,
14257 (void *)&cmd_vf_tc_bw_tc_map,
14262 /* Load dynamic device personalization*/
14263 struct cmd_ddp_add_result {
14264 cmdline_fixed_string_t ddp;
14265 cmdline_fixed_string_t add;
14270 cmdline_parse_token_string_t cmd_ddp_add_ddp =
14271 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp");
14272 cmdline_parse_token_string_t cmd_ddp_add_add =
14273 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add");
14274 cmdline_parse_token_num_t cmd_ddp_add_port_id =
14275 TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id, UINT16);
14276 cmdline_parse_token_string_t cmd_ddp_add_filepath =
14277 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL);
14280 cmd_ddp_add_parsed(
14281 void *parsed_result,
14282 __attribute__((unused)) struct cmdline *cl,
14283 __attribute__((unused)) void *data)
14285 struct cmd_ddp_add_result *res = parsed_result;
14291 int ret = -ENOTSUP;
14293 if (res->port_id > nb_ports) {
14294 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
14298 if (!all_ports_stopped()) {
14299 printf("Please stop all ports first\n");
14303 filepath = strdup(res->filepath);
14304 if (filepath == NULL) {
14305 printf("Failed to allocate memory\n");
14308 file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ',');
14310 buff = open_ddp_package_file(file_fld[0], &size);
14312 free((void *)filepath);
14316 #ifdef RTE_LIBRTE_I40E_PMD
14317 if (ret == -ENOTSUP)
14318 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
14320 RTE_PMD_I40E_PKG_OP_WR_ADD);
14323 if (ret == -EEXIST)
14324 printf("Profile has already existed.\n");
14326 printf("Failed to load profile.\n");
14327 else if (file_num == 2)
14328 save_ddp_package_file(file_fld[1], buff, size);
14330 close_ddp_package_file(buff);
14331 free((void *)filepath);
14334 cmdline_parse_inst_t cmd_ddp_add = {
14335 .f = cmd_ddp_add_parsed,
14337 .help_str = "ddp add <port_id> <profile_path[,output_path]>",
14339 (void *)&cmd_ddp_add_ddp,
14340 (void *)&cmd_ddp_add_add,
14341 (void *)&cmd_ddp_add_port_id,
14342 (void *)&cmd_ddp_add_filepath,
14347 /* Delete dynamic device personalization*/
14348 struct cmd_ddp_del_result {
14349 cmdline_fixed_string_t ddp;
14350 cmdline_fixed_string_t del;
14355 cmdline_parse_token_string_t cmd_ddp_del_ddp =
14356 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp");
14357 cmdline_parse_token_string_t cmd_ddp_del_del =
14358 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del");
14359 cmdline_parse_token_num_t cmd_ddp_del_port_id =
14360 TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, UINT16);
14361 cmdline_parse_token_string_t cmd_ddp_del_filepath =
14362 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL);
14365 cmd_ddp_del_parsed(
14366 void *parsed_result,
14367 __attribute__((unused)) struct cmdline *cl,
14368 __attribute__((unused)) void *data)
14370 struct cmd_ddp_del_result *res = parsed_result;
14373 int ret = -ENOTSUP;
14375 if (res->port_id > nb_ports) {
14376 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
14380 if (!all_ports_stopped()) {
14381 printf("Please stop all ports first\n");
14385 buff = open_ddp_package_file(res->filepath, &size);
14389 #ifdef RTE_LIBRTE_I40E_PMD
14390 if (ret == -ENOTSUP)
14391 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
14393 RTE_PMD_I40E_PKG_OP_WR_DEL);
14396 if (ret == -EACCES)
14397 printf("Profile does not exist.\n");
14399 printf("Failed to delete profile.\n");
14401 close_ddp_package_file(buff);
14404 cmdline_parse_inst_t cmd_ddp_del = {
14405 .f = cmd_ddp_del_parsed,
14407 .help_str = "ddp del <port_id> <profile_path>",
14409 (void *)&cmd_ddp_del_ddp,
14410 (void *)&cmd_ddp_del_del,
14411 (void *)&cmd_ddp_del_port_id,
14412 (void *)&cmd_ddp_del_filepath,
14417 /* Get dynamic device personalization profile info */
14418 struct cmd_ddp_info_result {
14419 cmdline_fixed_string_t ddp;
14420 cmdline_fixed_string_t get;
14421 cmdline_fixed_string_t info;
14425 cmdline_parse_token_string_t cmd_ddp_info_ddp =
14426 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp");
14427 cmdline_parse_token_string_t cmd_ddp_info_get =
14428 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get");
14429 cmdline_parse_token_string_t cmd_ddp_info_info =
14430 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info");
14431 cmdline_parse_token_string_t cmd_ddp_info_filepath =
14432 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL);
14435 cmd_ddp_info_parsed(
14436 void *parsed_result,
14437 __attribute__((unused)) struct cmdline *cl,
14438 __attribute__((unused)) void *data)
14440 struct cmd_ddp_info_result *res = parsed_result;
14443 int ret = -ENOTSUP;
14444 #ifdef RTE_LIBRTE_I40E_PMD
14447 uint32_t buff_size = 0;
14448 struct rte_pmd_i40e_profile_info info;
14449 uint32_t dev_num = 0;
14450 struct rte_pmd_i40e_ddp_device_id *devs;
14451 uint32_t proto_num = 0;
14452 struct rte_pmd_i40e_proto_info *proto = NULL;
14453 uint32_t pctype_num = 0;
14454 struct rte_pmd_i40e_ptype_info *pctype;
14455 uint32_t ptype_num = 0;
14456 struct rte_pmd_i40e_ptype_info *ptype;
14461 pkg = open_ddp_package_file(res->filepath, &pkg_size);
14465 #ifdef RTE_LIBRTE_I40E_PMD
14466 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14467 (uint8_t *)&info, sizeof(info),
14468 RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER);
14470 printf("Global Track id: 0x%x\n", info.track_id);
14471 printf("Global Version: %d.%d.%d.%d\n",
14472 info.version.major,
14473 info.version.minor,
14474 info.version.update,
14475 info.version.draft);
14476 printf("Global Package name: %s\n\n", info.name);
14479 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14480 (uint8_t *)&info, sizeof(info),
14481 RTE_PMD_I40E_PKG_INFO_HEADER);
14483 printf("i40e Profile Track id: 0x%x\n", info.track_id);
14484 printf("i40e Profile Version: %d.%d.%d.%d\n",
14485 info.version.major,
14486 info.version.minor,
14487 info.version.update,
14488 info.version.draft);
14489 printf("i40e Profile name: %s\n\n", info.name);
14492 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14493 (uint8_t *)&buff_size, sizeof(buff_size),
14494 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE);
14495 if (!ret && buff_size) {
14496 buff = (uint8_t *)malloc(buff_size);
14498 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14500 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES);
14502 printf("Package Notes:\n%s\n\n", buff);
14507 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14508 (uint8_t *)&dev_num, sizeof(dev_num),
14509 RTE_PMD_I40E_PKG_INFO_DEVID_NUM);
14510 if (!ret && dev_num) {
14511 buff_size = dev_num * sizeof(struct rte_pmd_i40e_ddp_device_id);
14512 devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(buff_size);
14514 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14515 (uint8_t *)devs, buff_size,
14516 RTE_PMD_I40E_PKG_INFO_DEVID_LIST);
14518 printf("List of supported devices:\n");
14519 for (i = 0; i < dev_num; i++) {
14520 printf(" %04X:%04X %04X:%04X\n",
14521 devs[i].vendor_dev_id >> 16,
14522 devs[i].vendor_dev_id & 0xFFFF,
14523 devs[i].sub_vendor_dev_id >> 16,
14524 devs[i].sub_vendor_dev_id & 0xFFFF);
14532 /* get information about protocols and packet types */
14533 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14534 (uint8_t *)&proto_num, sizeof(proto_num),
14535 RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM);
14536 if (ret || !proto_num)
14537 goto no_print_return;
14539 buff_size = proto_num * sizeof(struct rte_pmd_i40e_proto_info);
14540 proto = (struct rte_pmd_i40e_proto_info *)malloc(buff_size);
14542 goto no_print_return;
14544 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)proto,
14546 RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST);
14548 printf("List of used protocols:\n");
14549 for (i = 0; i < proto_num; i++)
14550 printf(" %2u: %s\n", proto[i].proto_id,
14554 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14555 (uint8_t *)&pctype_num, sizeof(pctype_num),
14556 RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM);
14557 if (ret || !pctype_num)
14558 goto no_print_pctypes;
14560 buff_size = pctype_num * sizeof(struct rte_pmd_i40e_ptype_info);
14561 pctype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
14563 goto no_print_pctypes;
14565 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)pctype,
14567 RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST);
14570 goto no_print_pctypes;
14573 printf("List of defined packet classification types:\n");
14574 for (i = 0; i < pctype_num; i++) {
14575 printf(" %2u:", pctype[i].ptype_id);
14576 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
14577 proto_id = pctype[i].protocols[j];
14578 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
14579 for (n = 0; n < proto_num; n++) {
14580 if (proto[n].proto_id == proto_id) {
14581 printf(" %s", proto[n].name);
14594 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)&ptype_num,
14596 RTE_PMD_I40E_PKG_INFO_PTYPE_NUM);
14597 if (ret || !ptype_num)
14598 goto no_print_return;
14600 buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_info);
14601 ptype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
14603 goto no_print_return;
14605 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)ptype,
14607 RTE_PMD_I40E_PKG_INFO_PTYPE_LIST);
14610 goto no_print_return;
14612 printf("List of defined packet types:\n");
14613 for (i = 0; i < ptype_num; i++) {
14614 printf(" %2u:", ptype[i].ptype_id);
14615 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
14616 proto_id = ptype[i].protocols[j];
14617 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
14618 for (n = 0; n < proto_num; n++) {
14619 if (proto[n].proto_id == proto_id) {
14620 printf(" %s", proto[n].name);
14636 if (ret == -ENOTSUP)
14637 printf("Function not supported in PMD driver\n");
14638 close_ddp_package_file(pkg);
14641 cmdline_parse_inst_t cmd_ddp_get_info = {
14642 .f = cmd_ddp_info_parsed,
14644 .help_str = "ddp get info <profile_path>",
14646 (void *)&cmd_ddp_info_ddp,
14647 (void *)&cmd_ddp_info_get,
14648 (void *)&cmd_ddp_info_info,
14649 (void *)&cmd_ddp_info_filepath,
14654 /* Get dynamic device personalization profile info list*/
14655 #define PROFILE_INFO_SIZE 48
14656 #define MAX_PROFILE_NUM 16
14658 struct cmd_ddp_get_list_result {
14659 cmdline_fixed_string_t ddp;
14660 cmdline_fixed_string_t get;
14661 cmdline_fixed_string_t list;
14665 cmdline_parse_token_string_t cmd_ddp_get_list_ddp =
14666 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp");
14667 cmdline_parse_token_string_t cmd_ddp_get_list_get =
14668 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get");
14669 cmdline_parse_token_string_t cmd_ddp_get_list_list =
14670 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list");
14671 cmdline_parse_token_num_t cmd_ddp_get_list_port_id =
14672 TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id, UINT16);
14675 cmd_ddp_get_list_parsed(
14676 void *parsed_result,
14677 __attribute__((unused)) struct cmdline *cl,
14678 __attribute__((unused)) void *data)
14680 struct cmd_ddp_get_list_result *res = parsed_result;
14681 #ifdef RTE_LIBRTE_I40E_PMD
14682 struct rte_pmd_i40e_profile_list *p_list;
14683 struct rte_pmd_i40e_profile_info *p_info;
14688 int ret = -ENOTSUP;
14690 if (res->port_id > nb_ports) {
14691 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
14695 #ifdef RTE_LIBRTE_I40E_PMD
14696 size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4;
14697 p_list = (struct rte_pmd_i40e_profile_list *)malloc(size);
14699 printf("%s: Failed to malloc buffer\n", __func__);
14701 if (ret == -ENOTSUP)
14702 ret = rte_pmd_i40e_get_ddp_list(res->port_id,
14703 (uint8_t *)p_list, size);
14706 p_num = p_list->p_count;
14707 printf("Profile number is: %d\n\n", p_num);
14709 for (i = 0; i < p_num; i++) {
14710 p_info = &p_list->p_info[i];
14711 printf("Profile %d:\n", i);
14712 printf("Track id: 0x%x\n", p_info->track_id);
14713 printf("Version: %d.%d.%d.%d\n",
14714 p_info->version.major,
14715 p_info->version.minor,
14716 p_info->version.update,
14717 p_info->version.draft);
14718 printf("Profile name: %s\n\n", p_info->name);
14726 printf("Failed to get ddp list\n");
14729 cmdline_parse_inst_t cmd_ddp_get_list = {
14730 .f = cmd_ddp_get_list_parsed,
14732 .help_str = "ddp get list <port_id>",
14734 (void *)&cmd_ddp_get_list_ddp,
14735 (void *)&cmd_ddp_get_list_get,
14736 (void *)&cmd_ddp_get_list_list,
14737 (void *)&cmd_ddp_get_list_port_id,
14742 /* show vf stats */
14744 /* Common result structure for show vf stats */
14745 struct cmd_show_vf_stats_result {
14746 cmdline_fixed_string_t show;
14747 cmdline_fixed_string_t vf;
14748 cmdline_fixed_string_t stats;
14753 /* Common CLI fields show vf stats*/
14754 cmdline_parse_token_string_t cmd_show_vf_stats_show =
14755 TOKEN_STRING_INITIALIZER
14756 (struct cmd_show_vf_stats_result,
14758 cmdline_parse_token_string_t cmd_show_vf_stats_vf =
14759 TOKEN_STRING_INITIALIZER
14760 (struct cmd_show_vf_stats_result,
14762 cmdline_parse_token_string_t cmd_show_vf_stats_stats =
14763 TOKEN_STRING_INITIALIZER
14764 (struct cmd_show_vf_stats_result,
14766 cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
14767 TOKEN_NUM_INITIALIZER
14768 (struct cmd_show_vf_stats_result,
14770 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
14771 TOKEN_NUM_INITIALIZER
14772 (struct cmd_show_vf_stats_result,
14776 cmd_show_vf_stats_parsed(
14777 void *parsed_result,
14778 __attribute__((unused)) struct cmdline *cl,
14779 __attribute__((unused)) void *data)
14781 struct cmd_show_vf_stats_result *res = parsed_result;
14782 struct rte_eth_stats stats;
14783 int ret = -ENOTSUP;
14784 static const char *nic_stats_border = "########################";
14786 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14789 memset(&stats, 0, sizeof(stats));
14791 #ifdef RTE_LIBRTE_I40E_PMD
14792 if (ret == -ENOTSUP)
14793 ret = rte_pmd_i40e_get_vf_stats(res->port_id,
14797 #ifdef RTE_LIBRTE_BNXT_PMD
14798 if (ret == -ENOTSUP)
14799 ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
14808 printf("invalid vf_id %d\n", res->vf_id);
14811 printf("invalid port_id %d\n", res->port_id);
14814 printf("function not implemented\n");
14817 printf("programming error: (%s)\n", strerror(-ret));
14820 printf("\n %s NIC statistics for port %-2d vf %-2d %s\n",
14821 nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
14823 printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: "
14825 stats.ipackets, stats.imissed, stats.ibytes);
14826 printf(" RX-errors: %-"PRIu64"\n", stats.ierrors);
14827 printf(" RX-nombuf: %-10"PRIu64"\n",
14829 printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: "
14831 stats.opackets, stats.oerrors, stats.obytes);
14833 printf(" %s############################%s\n",
14834 nic_stats_border, nic_stats_border);
14837 cmdline_parse_inst_t cmd_show_vf_stats = {
14838 .f = cmd_show_vf_stats_parsed,
14840 .help_str = "show vf stats <port_id> <vf_id>",
14842 (void *)&cmd_show_vf_stats_show,
14843 (void *)&cmd_show_vf_stats_vf,
14844 (void *)&cmd_show_vf_stats_stats,
14845 (void *)&cmd_show_vf_stats_port_id,
14846 (void *)&cmd_show_vf_stats_vf_id,
14851 /* clear vf stats */
14853 /* Common result structure for clear vf stats */
14854 struct cmd_clear_vf_stats_result {
14855 cmdline_fixed_string_t clear;
14856 cmdline_fixed_string_t vf;
14857 cmdline_fixed_string_t stats;
14862 /* Common CLI fields clear vf stats*/
14863 cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
14864 TOKEN_STRING_INITIALIZER
14865 (struct cmd_clear_vf_stats_result,
14867 cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
14868 TOKEN_STRING_INITIALIZER
14869 (struct cmd_clear_vf_stats_result,
14871 cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
14872 TOKEN_STRING_INITIALIZER
14873 (struct cmd_clear_vf_stats_result,
14875 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
14876 TOKEN_NUM_INITIALIZER
14877 (struct cmd_clear_vf_stats_result,
14879 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
14880 TOKEN_NUM_INITIALIZER
14881 (struct cmd_clear_vf_stats_result,
14885 cmd_clear_vf_stats_parsed(
14886 void *parsed_result,
14887 __attribute__((unused)) struct cmdline *cl,
14888 __attribute__((unused)) void *data)
14890 struct cmd_clear_vf_stats_result *res = parsed_result;
14891 int ret = -ENOTSUP;
14893 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14896 #ifdef RTE_LIBRTE_I40E_PMD
14897 if (ret == -ENOTSUP)
14898 ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
14901 #ifdef RTE_LIBRTE_BNXT_PMD
14902 if (ret == -ENOTSUP)
14903 ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
14911 printf("invalid vf_id %d\n", res->vf_id);
14914 printf("invalid port_id %d\n", res->port_id);
14917 printf("function not implemented\n");
14920 printf("programming error: (%s)\n", strerror(-ret));
14924 cmdline_parse_inst_t cmd_clear_vf_stats = {
14925 .f = cmd_clear_vf_stats_parsed,
14927 .help_str = "clear vf stats <port_id> <vf_id>",
14929 (void *)&cmd_clear_vf_stats_clear,
14930 (void *)&cmd_clear_vf_stats_vf,
14931 (void *)&cmd_clear_vf_stats_stats,
14932 (void *)&cmd_clear_vf_stats_port_id,
14933 (void *)&cmd_clear_vf_stats_vf_id,
14938 /* port config pctype mapping reset */
14940 /* Common result structure for port config pctype mapping reset */
14941 struct cmd_pctype_mapping_reset_result {
14942 cmdline_fixed_string_t port;
14943 cmdline_fixed_string_t config;
14945 cmdline_fixed_string_t pctype;
14946 cmdline_fixed_string_t mapping;
14947 cmdline_fixed_string_t reset;
14950 /* Common CLI fields for port config pctype mapping reset*/
14951 cmdline_parse_token_string_t cmd_pctype_mapping_reset_port =
14952 TOKEN_STRING_INITIALIZER
14953 (struct cmd_pctype_mapping_reset_result,
14955 cmdline_parse_token_string_t cmd_pctype_mapping_reset_config =
14956 TOKEN_STRING_INITIALIZER
14957 (struct cmd_pctype_mapping_reset_result,
14959 cmdline_parse_token_num_t cmd_pctype_mapping_reset_port_id =
14960 TOKEN_NUM_INITIALIZER
14961 (struct cmd_pctype_mapping_reset_result,
14963 cmdline_parse_token_string_t cmd_pctype_mapping_reset_pctype =
14964 TOKEN_STRING_INITIALIZER
14965 (struct cmd_pctype_mapping_reset_result,
14967 cmdline_parse_token_string_t cmd_pctype_mapping_reset_mapping =
14968 TOKEN_STRING_INITIALIZER
14969 (struct cmd_pctype_mapping_reset_result,
14970 mapping, "mapping");
14971 cmdline_parse_token_string_t cmd_pctype_mapping_reset_reset =
14972 TOKEN_STRING_INITIALIZER
14973 (struct cmd_pctype_mapping_reset_result,
14977 cmd_pctype_mapping_reset_parsed(
14978 void *parsed_result,
14979 __attribute__((unused)) struct cmdline *cl,
14980 __attribute__((unused)) void *data)
14982 struct cmd_pctype_mapping_reset_result *res = parsed_result;
14983 int ret = -ENOTSUP;
14985 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14988 #ifdef RTE_LIBRTE_I40E_PMD
14989 ret = rte_pmd_i40e_flow_type_mapping_reset(res->port_id);
14996 printf("invalid port_id %d\n", res->port_id);
14999 printf("function not implemented\n");
15002 printf("programming error: (%s)\n", strerror(-ret));
15006 cmdline_parse_inst_t cmd_pctype_mapping_reset = {
15007 .f = cmd_pctype_mapping_reset_parsed,
15009 .help_str = "port config <port_id> pctype mapping reset",
15011 (void *)&cmd_pctype_mapping_reset_port,
15012 (void *)&cmd_pctype_mapping_reset_config,
15013 (void *)&cmd_pctype_mapping_reset_port_id,
15014 (void *)&cmd_pctype_mapping_reset_pctype,
15015 (void *)&cmd_pctype_mapping_reset_mapping,
15016 (void *)&cmd_pctype_mapping_reset_reset,
15021 /* show port pctype mapping */
15023 /* Common result structure for show port pctype mapping */
15024 struct cmd_pctype_mapping_get_result {
15025 cmdline_fixed_string_t show;
15026 cmdline_fixed_string_t port;
15028 cmdline_fixed_string_t pctype;
15029 cmdline_fixed_string_t mapping;
15032 /* Common CLI fields for pctype mapping get */
15033 cmdline_parse_token_string_t cmd_pctype_mapping_get_show =
15034 TOKEN_STRING_INITIALIZER
15035 (struct cmd_pctype_mapping_get_result,
15037 cmdline_parse_token_string_t cmd_pctype_mapping_get_port =
15038 TOKEN_STRING_INITIALIZER
15039 (struct cmd_pctype_mapping_get_result,
15041 cmdline_parse_token_num_t cmd_pctype_mapping_get_port_id =
15042 TOKEN_NUM_INITIALIZER
15043 (struct cmd_pctype_mapping_get_result,
15045 cmdline_parse_token_string_t cmd_pctype_mapping_get_pctype =
15046 TOKEN_STRING_INITIALIZER
15047 (struct cmd_pctype_mapping_get_result,
15049 cmdline_parse_token_string_t cmd_pctype_mapping_get_mapping =
15050 TOKEN_STRING_INITIALIZER
15051 (struct cmd_pctype_mapping_get_result,
15052 mapping, "mapping");
15055 cmd_pctype_mapping_get_parsed(
15056 void *parsed_result,
15057 __attribute__((unused)) struct cmdline *cl,
15058 __attribute__((unused)) void *data)
15060 struct cmd_pctype_mapping_get_result *res = parsed_result;
15061 int ret = -ENOTSUP;
15062 #ifdef RTE_LIBRTE_I40E_PMD
15063 struct rte_pmd_i40e_flow_type_mapping
15064 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
15065 int i, j, first_pctype;
15068 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15071 #ifdef RTE_LIBRTE_I40E_PMD
15072 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, mapping);
15079 printf("invalid port_id %d\n", res->port_id);
15082 printf("function not implemented\n");
15085 printf("programming error: (%s)\n", strerror(-ret));
15089 #ifdef RTE_LIBRTE_I40E_PMD
15090 for (i = 0; i < RTE_PMD_I40E_FLOW_TYPE_MAX; i++) {
15091 if (mapping[i].pctype != 0ULL) {
15094 printf("pctype: ");
15095 for (j = 0; j < RTE_PMD_I40E_PCTYPE_MAX; j++) {
15096 if (mapping[i].pctype & (1ULL << j)) {
15097 printf(first_pctype ?
15098 "%02d" : ",%02d", j);
15102 printf(" -> flowtype: %02d\n", mapping[i].flow_type);
15108 cmdline_parse_inst_t cmd_pctype_mapping_get = {
15109 .f = cmd_pctype_mapping_get_parsed,
15111 .help_str = "show port <port_id> pctype mapping",
15113 (void *)&cmd_pctype_mapping_get_show,
15114 (void *)&cmd_pctype_mapping_get_port,
15115 (void *)&cmd_pctype_mapping_get_port_id,
15116 (void *)&cmd_pctype_mapping_get_pctype,
15117 (void *)&cmd_pctype_mapping_get_mapping,
15122 /* port config pctype mapping update */
15124 /* Common result structure for port config pctype mapping update */
15125 struct cmd_pctype_mapping_update_result {
15126 cmdline_fixed_string_t port;
15127 cmdline_fixed_string_t config;
15129 cmdline_fixed_string_t pctype;
15130 cmdline_fixed_string_t mapping;
15131 cmdline_fixed_string_t update;
15132 cmdline_fixed_string_t pctype_list;
15133 uint16_t flow_type;
15136 /* Common CLI fields for pctype mapping update*/
15137 cmdline_parse_token_string_t cmd_pctype_mapping_update_port =
15138 TOKEN_STRING_INITIALIZER
15139 (struct cmd_pctype_mapping_update_result,
15141 cmdline_parse_token_string_t cmd_pctype_mapping_update_config =
15142 TOKEN_STRING_INITIALIZER
15143 (struct cmd_pctype_mapping_update_result,
15145 cmdline_parse_token_num_t cmd_pctype_mapping_update_port_id =
15146 TOKEN_NUM_INITIALIZER
15147 (struct cmd_pctype_mapping_update_result,
15149 cmdline_parse_token_string_t cmd_pctype_mapping_update_pctype =
15150 TOKEN_STRING_INITIALIZER
15151 (struct cmd_pctype_mapping_update_result,
15153 cmdline_parse_token_string_t cmd_pctype_mapping_update_mapping =
15154 TOKEN_STRING_INITIALIZER
15155 (struct cmd_pctype_mapping_update_result,
15156 mapping, "mapping");
15157 cmdline_parse_token_string_t cmd_pctype_mapping_update_update =
15158 TOKEN_STRING_INITIALIZER
15159 (struct cmd_pctype_mapping_update_result,
15161 cmdline_parse_token_string_t cmd_pctype_mapping_update_pc_type =
15162 TOKEN_STRING_INITIALIZER
15163 (struct cmd_pctype_mapping_update_result,
15164 pctype_list, NULL);
15165 cmdline_parse_token_num_t cmd_pctype_mapping_update_flow_type =
15166 TOKEN_NUM_INITIALIZER
15167 (struct cmd_pctype_mapping_update_result,
15168 flow_type, UINT16);
15171 cmd_pctype_mapping_update_parsed(
15172 void *parsed_result,
15173 __attribute__((unused)) struct cmdline *cl,
15174 __attribute__((unused)) void *data)
15176 struct cmd_pctype_mapping_update_result *res = parsed_result;
15177 int ret = -ENOTSUP;
15178 #ifdef RTE_LIBRTE_I40E_PMD
15179 struct rte_pmd_i40e_flow_type_mapping mapping;
15181 unsigned int nb_item;
15182 unsigned int pctype_list[RTE_PMD_I40E_PCTYPE_MAX];
15185 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15188 #ifdef RTE_LIBRTE_I40E_PMD
15189 nb_item = parse_item_list(res->pctype_list, "pctypes",
15190 RTE_PMD_I40E_PCTYPE_MAX, pctype_list, 1);
15191 mapping.flow_type = res->flow_type;
15192 for (i = 0, mapping.pctype = 0ULL; i < nb_item; i++)
15193 mapping.pctype |= (1ULL << pctype_list[i]);
15194 ret = rte_pmd_i40e_flow_type_mapping_update(res->port_id,
15204 printf("invalid pctype or flow type\n");
15207 printf("invalid port_id %d\n", res->port_id);
15210 printf("function not implemented\n");
15213 printf("programming error: (%s)\n", strerror(-ret));
15217 cmdline_parse_inst_t cmd_pctype_mapping_update = {
15218 .f = cmd_pctype_mapping_update_parsed,
15220 .help_str = "port config <port_id> pctype mapping update"
15221 " <pctype_id_0,[pctype_id_1]*> <flowtype_id>",
15223 (void *)&cmd_pctype_mapping_update_port,
15224 (void *)&cmd_pctype_mapping_update_config,
15225 (void *)&cmd_pctype_mapping_update_port_id,
15226 (void *)&cmd_pctype_mapping_update_pctype,
15227 (void *)&cmd_pctype_mapping_update_mapping,
15228 (void *)&cmd_pctype_mapping_update_update,
15229 (void *)&cmd_pctype_mapping_update_pc_type,
15230 (void *)&cmd_pctype_mapping_update_flow_type,
15235 /* ptype mapping get */
15237 /* Common result structure for ptype mapping get */
15238 struct cmd_ptype_mapping_get_result {
15239 cmdline_fixed_string_t ptype;
15240 cmdline_fixed_string_t mapping;
15241 cmdline_fixed_string_t get;
15243 uint8_t valid_only;
15246 /* Common CLI fields for ptype mapping get */
15247 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype =
15248 TOKEN_STRING_INITIALIZER
15249 (struct cmd_ptype_mapping_get_result,
15251 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping =
15252 TOKEN_STRING_INITIALIZER
15253 (struct cmd_ptype_mapping_get_result,
15254 mapping, "mapping");
15255 cmdline_parse_token_string_t cmd_ptype_mapping_get_get =
15256 TOKEN_STRING_INITIALIZER
15257 (struct cmd_ptype_mapping_get_result,
15259 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id =
15260 TOKEN_NUM_INITIALIZER
15261 (struct cmd_ptype_mapping_get_result,
15263 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only =
15264 TOKEN_NUM_INITIALIZER
15265 (struct cmd_ptype_mapping_get_result,
15266 valid_only, UINT8);
15269 cmd_ptype_mapping_get_parsed(
15270 void *parsed_result,
15271 __attribute__((unused)) struct cmdline *cl,
15272 __attribute__((unused)) void *data)
15274 struct cmd_ptype_mapping_get_result *res = parsed_result;
15275 int ret = -ENOTSUP;
15276 #ifdef RTE_LIBRTE_I40E_PMD
15277 int max_ptype_num = 256;
15278 struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num];
15283 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15286 #ifdef RTE_LIBRTE_I40E_PMD
15287 ret = rte_pmd_i40e_ptype_mapping_get(res->port_id,
15298 printf("invalid port_id %d\n", res->port_id);
15301 printf("function not implemented\n");
15304 printf("programming error: (%s)\n", strerror(-ret));
15307 #ifdef RTE_LIBRTE_I40E_PMD
15309 for (i = 0; i < count; i++)
15310 printf("%3d\t0x%08x\n",
15311 mapping[i].hw_ptype, mapping[i].sw_ptype);
15316 cmdline_parse_inst_t cmd_ptype_mapping_get = {
15317 .f = cmd_ptype_mapping_get_parsed,
15319 .help_str = "ptype mapping get <port_id> <valid_only>",
15321 (void *)&cmd_ptype_mapping_get_ptype,
15322 (void *)&cmd_ptype_mapping_get_mapping,
15323 (void *)&cmd_ptype_mapping_get_get,
15324 (void *)&cmd_ptype_mapping_get_port_id,
15325 (void *)&cmd_ptype_mapping_get_valid_only,
15330 /* ptype mapping replace */
15332 /* Common result structure for ptype mapping replace */
15333 struct cmd_ptype_mapping_replace_result {
15334 cmdline_fixed_string_t ptype;
15335 cmdline_fixed_string_t mapping;
15336 cmdline_fixed_string_t replace;
15343 /* Common CLI fields for ptype mapping replace */
15344 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype =
15345 TOKEN_STRING_INITIALIZER
15346 (struct cmd_ptype_mapping_replace_result,
15348 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping =
15349 TOKEN_STRING_INITIALIZER
15350 (struct cmd_ptype_mapping_replace_result,
15351 mapping, "mapping");
15352 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace =
15353 TOKEN_STRING_INITIALIZER
15354 (struct cmd_ptype_mapping_replace_result,
15355 replace, "replace");
15356 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id =
15357 TOKEN_NUM_INITIALIZER
15358 (struct cmd_ptype_mapping_replace_result,
15360 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target =
15361 TOKEN_NUM_INITIALIZER
15362 (struct cmd_ptype_mapping_replace_result,
15364 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask =
15365 TOKEN_NUM_INITIALIZER
15366 (struct cmd_ptype_mapping_replace_result,
15368 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type =
15369 TOKEN_NUM_INITIALIZER
15370 (struct cmd_ptype_mapping_replace_result,
15374 cmd_ptype_mapping_replace_parsed(
15375 void *parsed_result,
15376 __attribute__((unused)) struct cmdline *cl,
15377 __attribute__((unused)) void *data)
15379 struct cmd_ptype_mapping_replace_result *res = parsed_result;
15380 int ret = -ENOTSUP;
15382 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15385 #ifdef RTE_LIBRTE_I40E_PMD
15386 ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id,
15396 printf("invalid ptype 0x%8x or 0x%8x\n",
15397 res->target, res->pkt_type);
15400 printf("invalid port_id %d\n", res->port_id);
15403 printf("function not implemented\n");
15406 printf("programming error: (%s)\n", strerror(-ret));
15410 cmdline_parse_inst_t cmd_ptype_mapping_replace = {
15411 .f = cmd_ptype_mapping_replace_parsed,
15414 "ptype mapping replace <port_id> <target> <mask> <pkt_type>",
15416 (void *)&cmd_ptype_mapping_replace_ptype,
15417 (void *)&cmd_ptype_mapping_replace_mapping,
15418 (void *)&cmd_ptype_mapping_replace_replace,
15419 (void *)&cmd_ptype_mapping_replace_port_id,
15420 (void *)&cmd_ptype_mapping_replace_target,
15421 (void *)&cmd_ptype_mapping_replace_mask,
15422 (void *)&cmd_ptype_mapping_replace_pkt_type,
15427 /* ptype mapping reset */
15429 /* Common result structure for ptype mapping reset */
15430 struct cmd_ptype_mapping_reset_result {
15431 cmdline_fixed_string_t ptype;
15432 cmdline_fixed_string_t mapping;
15433 cmdline_fixed_string_t reset;
15437 /* Common CLI fields for ptype mapping reset*/
15438 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype =
15439 TOKEN_STRING_INITIALIZER
15440 (struct cmd_ptype_mapping_reset_result,
15442 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping =
15443 TOKEN_STRING_INITIALIZER
15444 (struct cmd_ptype_mapping_reset_result,
15445 mapping, "mapping");
15446 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset =
15447 TOKEN_STRING_INITIALIZER
15448 (struct cmd_ptype_mapping_reset_result,
15450 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id =
15451 TOKEN_NUM_INITIALIZER
15452 (struct cmd_ptype_mapping_reset_result,
15456 cmd_ptype_mapping_reset_parsed(
15457 void *parsed_result,
15458 __attribute__((unused)) struct cmdline *cl,
15459 __attribute__((unused)) void *data)
15461 struct cmd_ptype_mapping_reset_result *res = parsed_result;
15462 int ret = -ENOTSUP;
15464 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15467 #ifdef RTE_LIBRTE_I40E_PMD
15468 ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id);
15475 printf("invalid port_id %d\n", res->port_id);
15478 printf("function not implemented\n");
15481 printf("programming error: (%s)\n", strerror(-ret));
15485 cmdline_parse_inst_t cmd_ptype_mapping_reset = {
15486 .f = cmd_ptype_mapping_reset_parsed,
15488 .help_str = "ptype mapping reset <port_id>",
15490 (void *)&cmd_ptype_mapping_reset_ptype,
15491 (void *)&cmd_ptype_mapping_reset_mapping,
15492 (void *)&cmd_ptype_mapping_reset_reset,
15493 (void *)&cmd_ptype_mapping_reset_port_id,
15498 /* ptype mapping update */
15500 /* Common result structure for ptype mapping update */
15501 struct cmd_ptype_mapping_update_result {
15502 cmdline_fixed_string_t ptype;
15503 cmdline_fixed_string_t mapping;
15504 cmdline_fixed_string_t reset;
15510 /* Common CLI fields for ptype mapping update*/
15511 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype =
15512 TOKEN_STRING_INITIALIZER
15513 (struct cmd_ptype_mapping_update_result,
15515 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping =
15516 TOKEN_STRING_INITIALIZER
15517 (struct cmd_ptype_mapping_update_result,
15518 mapping, "mapping");
15519 cmdline_parse_token_string_t cmd_ptype_mapping_update_update =
15520 TOKEN_STRING_INITIALIZER
15521 (struct cmd_ptype_mapping_update_result,
15523 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id =
15524 TOKEN_NUM_INITIALIZER
15525 (struct cmd_ptype_mapping_update_result,
15527 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype =
15528 TOKEN_NUM_INITIALIZER
15529 (struct cmd_ptype_mapping_update_result,
15531 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype =
15532 TOKEN_NUM_INITIALIZER
15533 (struct cmd_ptype_mapping_update_result,
15537 cmd_ptype_mapping_update_parsed(
15538 void *parsed_result,
15539 __attribute__((unused)) struct cmdline *cl,
15540 __attribute__((unused)) void *data)
15542 struct cmd_ptype_mapping_update_result *res = parsed_result;
15543 int ret = -ENOTSUP;
15544 #ifdef RTE_LIBRTE_I40E_PMD
15545 struct rte_pmd_i40e_ptype_mapping mapping;
15547 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15550 #ifdef RTE_LIBRTE_I40E_PMD
15551 mapping.hw_ptype = res->hw_ptype;
15552 mapping.sw_ptype = res->sw_ptype;
15553 ret = rte_pmd_i40e_ptype_mapping_update(res->port_id,
15563 printf("invalid ptype 0x%8x\n", res->sw_ptype);
15566 printf("invalid port_id %d\n", res->port_id);
15569 printf("function not implemented\n");
15572 printf("programming error: (%s)\n", strerror(-ret));
15576 cmdline_parse_inst_t cmd_ptype_mapping_update = {
15577 .f = cmd_ptype_mapping_update_parsed,
15579 .help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>",
15581 (void *)&cmd_ptype_mapping_update_ptype,
15582 (void *)&cmd_ptype_mapping_update_mapping,
15583 (void *)&cmd_ptype_mapping_update_update,
15584 (void *)&cmd_ptype_mapping_update_port_id,
15585 (void *)&cmd_ptype_mapping_update_hw_ptype,
15586 (void *)&cmd_ptype_mapping_update_sw_ptype,
15591 /* Common result structure for file commands */
15592 struct cmd_cmdfile_result {
15593 cmdline_fixed_string_t load;
15594 cmdline_fixed_string_t filename;
15597 /* Common CLI fields for file commands */
15598 cmdline_parse_token_string_t cmd_load_cmdfile =
15599 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
15600 cmdline_parse_token_string_t cmd_load_cmdfile_filename =
15601 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
15604 cmd_load_from_file_parsed(
15605 void *parsed_result,
15606 __attribute__((unused)) struct cmdline *cl,
15607 __attribute__((unused)) void *data)
15609 struct cmd_cmdfile_result *res = parsed_result;
15611 cmdline_read_from_file(res->filename);
15614 cmdline_parse_inst_t cmd_load_from_file = {
15615 .f = cmd_load_from_file_parsed,
15617 .help_str = "load <filename>",
15619 (void *)&cmd_load_cmdfile,
15620 (void *)&cmd_load_cmdfile_filename,
15625 /* ******************************************************************************** */
15627 /* list of instructions */
15628 cmdline_parse_ctx_t main_ctx[] = {
15629 (cmdline_parse_inst_t *)&cmd_help_brief,
15630 (cmdline_parse_inst_t *)&cmd_help_long,
15631 (cmdline_parse_inst_t *)&cmd_quit,
15632 (cmdline_parse_inst_t *)&cmd_load_from_file,
15633 (cmdline_parse_inst_t *)&cmd_showport,
15634 (cmdline_parse_inst_t *)&cmd_showqueue,
15635 (cmdline_parse_inst_t *)&cmd_showportall,
15636 (cmdline_parse_inst_t *)&cmd_showcfg,
15637 (cmdline_parse_inst_t *)&cmd_start,
15638 (cmdline_parse_inst_t *)&cmd_start_tx_first,
15639 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
15640 (cmdline_parse_inst_t *)&cmd_set_link_up,
15641 (cmdline_parse_inst_t *)&cmd_set_link_down,
15642 (cmdline_parse_inst_t *)&cmd_reset,
15643 (cmdline_parse_inst_t *)&cmd_set_numbers,
15644 (cmdline_parse_inst_t *)&cmd_set_txpkts,
15645 (cmdline_parse_inst_t *)&cmd_set_txsplit,
15646 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
15647 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
15648 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
15649 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
15650 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
15651 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
15652 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
15653 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
15654 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
15655 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
15656 (cmdline_parse_inst_t *)&cmd_set_link_check,
15657 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
15658 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
15659 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
15660 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
15661 #ifdef RTE_LIBRTE_PMD_BOND
15662 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
15663 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
15664 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
15665 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
15666 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
15667 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
15668 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
15669 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
15670 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
15671 (cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues,
15672 (cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy,
15674 (cmdline_parse_inst_t *)&cmd_vlan_offload,
15675 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
15676 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
15677 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
15678 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
15679 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
15680 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
15681 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
15682 (cmdline_parse_inst_t *)&cmd_csum_set,
15683 (cmdline_parse_inst_t *)&cmd_csum_show,
15684 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
15685 (cmdline_parse_inst_t *)&cmd_tso_set,
15686 (cmdline_parse_inst_t *)&cmd_tso_show,
15687 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
15688 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
15689 (cmdline_parse_inst_t *)&cmd_gro_enable,
15690 (cmdline_parse_inst_t *)&cmd_gro_flush,
15691 (cmdline_parse_inst_t *)&cmd_gro_show,
15692 (cmdline_parse_inst_t *)&cmd_gso_enable,
15693 (cmdline_parse_inst_t *)&cmd_gso_size,
15694 (cmdline_parse_inst_t *)&cmd_gso_show,
15695 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
15696 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
15697 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
15698 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
15699 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
15700 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
15701 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
15702 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
15703 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
15704 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
15705 (cmdline_parse_inst_t *)&cmd_config_dcb,
15706 (cmdline_parse_inst_t *)&cmd_read_reg,
15707 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
15708 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
15709 (cmdline_parse_inst_t *)&cmd_write_reg,
15710 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
15711 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
15712 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
15713 (cmdline_parse_inst_t *)&cmd_stop,
15714 (cmdline_parse_inst_t *)&cmd_mac_addr,
15715 (cmdline_parse_inst_t *)&cmd_set_qmap,
15716 (cmdline_parse_inst_t *)&cmd_set_xstats_hide_zero,
15717 (cmdline_parse_inst_t *)&cmd_operate_port,
15718 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
15719 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
15720 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
15721 (cmdline_parse_inst_t *)&cmd_config_speed_all,
15722 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
15723 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
15724 (cmdline_parse_inst_t *)&cmd_config_mtu,
15725 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
15726 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
15727 (cmdline_parse_inst_t *)&cmd_config_rss,
15728 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
15729 (cmdline_parse_inst_t *)&cmd_config_txqflags,
15730 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
15731 (cmdline_parse_inst_t *)&cmd_showport_reta,
15732 (cmdline_parse_inst_t *)&cmd_config_burst,
15733 (cmdline_parse_inst_t *)&cmd_config_thresh,
15734 (cmdline_parse_inst_t *)&cmd_config_threshold,
15735 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
15736 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
15737 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
15738 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
15739 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
15740 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
15741 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
15742 (cmdline_parse_inst_t *)&cmd_global_config,
15743 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
15744 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
15745 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
15746 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
15747 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
15748 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
15749 (cmdline_parse_inst_t *)&cmd_dump,
15750 (cmdline_parse_inst_t *)&cmd_dump_one,
15751 (cmdline_parse_inst_t *)&cmd_ethertype_filter,
15752 (cmdline_parse_inst_t *)&cmd_syn_filter,
15753 (cmdline_parse_inst_t *)&cmd_2tuple_filter,
15754 (cmdline_parse_inst_t *)&cmd_5tuple_filter,
15755 (cmdline_parse_inst_t *)&cmd_flex_filter,
15756 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
15757 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
15758 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
15759 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director,
15760 (cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director,
15761 (cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director,
15762 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
15763 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
15764 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
15765 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
15766 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
15767 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
15768 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
15769 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
15770 (cmdline_parse_inst_t *)&cmd_get_hash_global_config,
15771 (cmdline_parse_inst_t *)&cmd_set_hash_global_config,
15772 (cmdline_parse_inst_t *)&cmd_set_hash_input_set,
15773 (cmdline_parse_inst_t *)&cmd_set_fdir_input_set,
15774 (cmdline_parse_inst_t *)&cmd_flow,
15775 (cmdline_parse_inst_t *)&cmd_show_port_meter_cap,
15776 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm,
15777 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm,
15778 (cmdline_parse_inst_t *)&cmd_del_port_meter_profile,
15779 (cmdline_parse_inst_t *)&cmd_create_port_meter,
15780 (cmdline_parse_inst_t *)&cmd_enable_port_meter,
15781 (cmdline_parse_inst_t *)&cmd_disable_port_meter,
15782 (cmdline_parse_inst_t *)&cmd_del_port_meter,
15783 (cmdline_parse_inst_t *)&cmd_set_port_meter_profile,
15784 (cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table,
15785 (cmdline_parse_inst_t *)&cmd_set_port_meter_policer_action,
15786 (cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask,
15787 (cmdline_parse_inst_t *)&cmd_show_port_meter_stats,
15788 (cmdline_parse_inst_t *)&cmd_mcast_addr,
15789 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all,
15790 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific,
15791 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all,
15792 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific,
15793 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_en,
15794 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_dis,
15795 (cmdline_parse_inst_t *)&cmd_config_e_tag_stripping_en_dis,
15796 (cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis,
15797 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_add,
15798 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_del,
15799 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
15800 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
15801 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
15802 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
15803 (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
15804 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
15805 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
15806 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
15807 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
15808 (cmdline_parse_inst_t *)&cmd_set_macsec_sc,
15809 (cmdline_parse_inst_t *)&cmd_set_macsec_sa,
15810 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
15811 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
15812 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
15813 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
15814 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
15815 (cmdline_parse_inst_t *)&cmd_set_vf_promisc,
15816 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
15817 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
15818 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
15819 (cmdline_parse_inst_t *)&cmd_vf_max_bw,
15820 (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
15821 (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
15822 (cmdline_parse_inst_t *)&cmd_strict_link_prio,
15823 (cmdline_parse_inst_t *)&cmd_tc_min_bw,
15824 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
15825 (cmdline_parse_inst_t *)&cmd_set_port_tm_hierarchy_default,
15827 (cmdline_parse_inst_t *)&cmd_ddp_add,
15828 (cmdline_parse_inst_t *)&cmd_ddp_del,
15829 (cmdline_parse_inst_t *)&cmd_ddp_get_list,
15830 (cmdline_parse_inst_t *)&cmd_ddp_get_info,
15831 (cmdline_parse_inst_t *)&cmd_show_vf_stats,
15832 (cmdline_parse_inst_t *)&cmd_clear_vf_stats,
15833 (cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
15834 (cmdline_parse_inst_t *)&cmd_ptype_mapping_replace,
15835 (cmdline_parse_inst_t *)&cmd_ptype_mapping_reset,
15836 (cmdline_parse_inst_t *)&cmd_ptype_mapping_update,
15838 (cmdline_parse_inst_t *)&cmd_pctype_mapping_get,
15839 (cmdline_parse_inst_t *)&cmd_pctype_mapping_reset,
15840 (cmdline_parse_inst_t *)&cmd_pctype_mapping_update,
15841 (cmdline_parse_inst_t *)&cmd_queue_region,
15842 (cmdline_parse_inst_t *)&cmd_region_flowtype,
15843 (cmdline_parse_inst_t *)&cmd_user_priority_region,
15844 (cmdline_parse_inst_t *)&cmd_flush_queue_region,
15845 (cmdline_parse_inst_t *)&cmd_show_queue_region_info_all,
15846 (cmdline_parse_inst_t *)&cmd_show_port_tm_cap,
15847 (cmdline_parse_inst_t *)&cmd_show_port_tm_level_cap,
15848 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_cap,
15849 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_type,
15850 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_stats,
15851 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shaper_profile,
15852 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shaper_profile,
15853 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shared_shaper,
15854 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shared_shaper,
15855 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_wred_profile,
15856 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_wred_profile,
15857 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_shaper_profile,
15858 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node,
15859 (cmdline_parse_inst_t *)&cmd_add_port_tm_leaf_node,
15860 (cmdline_parse_inst_t *)&cmd_del_port_tm_node,
15861 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_parent,
15862 (cmdline_parse_inst_t *)&cmd_port_tm_hierarchy_commit,
15866 /* read cmdline commands from file */
15868 cmdline_read_from_file(const char *filename)
15870 struct cmdline *cl;
15872 cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
15874 printf("Failed to create file based cmdline context: %s\n",
15879 cmdline_interact(cl);
15884 printf("Read CLI commands from %s\n", filename);
15887 /* prompt function, called from main on MASTER lcore */
15891 /* initialize non-constant commands */
15892 cmd_set_fwd_mode_init();
15893 cmd_set_fwd_retry_mode_init();
15895 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
15896 if (testpmd_cl == NULL)
15898 cmdline_interact(testpmd_cl);
15899 cmdline_stdin_exit(testpmd_cl);
15905 if (testpmd_cl != NULL)
15906 cmdline_quit(testpmd_cl);
15910 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
15912 if (id == (portid_t)RTE_PORT_ALL) {
15915 RTE_ETH_FOREACH_DEV(pid) {
15916 /* check if need_reconfig has been set to 1 */
15917 if (ports[pid].need_reconfig == 0)
15918 ports[pid].need_reconfig = dev;
15919 /* check if need_reconfig_queues has been set to 1 */
15920 if (ports[pid].need_reconfig_queues == 0)
15921 ports[pid].need_reconfig_queues = queue;
15923 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
15924 /* check if need_reconfig has been set to 1 */
15925 if (ports[id].need_reconfig == 0)
15926 ports[id].need_reconfig = dev;
15927 /* check if need_reconfig_queues has been set to 1 */
15928 if (ports[id].need_reconfig_queues == 0)
15929 ports[id].need_reconfig_queues = queue;