4 * Copyright(c) 2010-2016 Intel Corporation. All rights reserved.
5 * Copyright(c) 2014 6WIND S.A.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
12 * * Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * * Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in
16 * the documentation and/or other materials provided with the
18 * * Neither the name of Intel Corporation nor the names of its
19 * contributors may be used to endorse or promote products derived
20 * from this software without specific prior written permission.
22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
26 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
28 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
45 #include <net/socket.h>
47 #include <sys/socket.h>
50 #include <netinet/in.h>
52 #include <sys/queue.h>
54 #include <rte_common.h>
55 #include <rte_byteorder.h>
57 #include <rte_debug.h>
58 #include <rte_cycles.h>
59 #include <rte_memory.h>
60 #include <rte_memzone.h>
61 #include <rte_malloc.h>
62 #include <rte_launch.h>
64 #include <rte_per_lcore.h>
65 #include <rte_lcore.h>
66 #include <rte_atomic.h>
67 #include <rte_branch_prediction.h>
69 #include <rte_mempool.h>
70 #include <rte_interrupts.h>
72 #include <rte_ether.h>
73 #include <rte_ethdev.h>
74 #include <rte_string_fns.h>
75 #include <rte_devargs.h>
76 #include <rte_eth_ctrl.h>
80 #include <cmdline_rdline.h>
81 #include <cmdline_parse.h>
82 #include <cmdline_parse_num.h>
83 #include <cmdline_parse_string.h>
84 #include <cmdline_parse_ipaddr.h>
85 #include <cmdline_parse_etheraddr.h>
86 #include <cmdline_socket.h>
88 #ifdef RTE_LIBRTE_PMD_BOND
89 #include <rte_eth_bond.h>
90 #include <rte_eth_bond_8023ad.h>
92 #ifdef RTE_LIBRTE_IXGBE_PMD
93 #include <rte_pmd_ixgbe.h>
95 #ifdef RTE_LIBRTE_I40E_PMD
96 #include <rte_pmd_i40e.h>
98 #ifdef RTE_LIBRTE_BNXT_PMD
99 #include <rte_pmd_bnxt.h>
102 #include "cmdline_mtr.h"
103 #include "cmdline_tm.h"
105 static struct cmdline *testpmd_cl;
107 static void cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue);
109 /* *** Help command with introduction. *** */
110 struct cmd_help_brief_result {
111 cmdline_fixed_string_t help;
114 static void cmd_help_brief_parsed(__attribute__((unused)) void *parsed_result,
116 __attribute__((unused)) void *data)
121 "Help is available for the following sections:\n\n"
122 " help control : Start and stop forwarding.\n"
123 " help display : Displaying port, stats and config "
125 " help config : Configuration information.\n"
126 " help ports : Configuring ports.\n"
127 " help registers : Reading and setting port registers.\n"
128 " help filters : Filters configuration help.\n"
129 " help all : All of the above sections.\n\n"
134 cmdline_parse_token_string_t cmd_help_brief_help =
135 TOKEN_STRING_INITIALIZER(struct cmd_help_brief_result, help, "help");
137 cmdline_parse_inst_t cmd_help_brief = {
138 .f = cmd_help_brief_parsed,
140 .help_str = "help: Show help",
142 (void *)&cmd_help_brief_help,
147 /* *** Help command with help sections. *** */
148 struct cmd_help_long_result {
149 cmdline_fixed_string_t help;
150 cmdline_fixed_string_t section;
153 static void cmd_help_long_parsed(void *parsed_result,
155 __attribute__((unused)) void *data)
158 struct cmd_help_long_result *res = parsed_result;
160 if (!strcmp(res->section, "all"))
163 if (show_all || !strcmp(res->section, "control")) {
168 "Control forwarding:\n"
169 "-------------------\n\n"
172 " Start packet forwarding with current configuration.\n\n"
175 " Start packet forwarding with current config"
176 " after sending one burst of packets.\n\n"
179 " Stop packet forwarding, and display accumulated"
183 " Quit to prompt.\n\n"
187 if (show_all || !strcmp(res->section, "display")) {
195 "show port (info|stats|xstats|fdir|stat_qmap|dcb_tc|cap) (port_id|all)\n"
196 " Display information for port_id, or all.\n\n"
198 "show port X rss reta (size) (mask0,mask1,...)\n"
199 " Display the rss redirection table entry indicated"
200 " by masks on port X. size is used to indicate the"
201 " hardware supported reta size\n\n"
203 "show port rss-hash ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|"
204 "ipv4-sctp|ipv4-other|ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
205 "ipv6-other|l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex [key]\n"
206 " Display the RSS hash functions and RSS hash key"
209 "clear port (info|stats|xstats|fdir|stat_qmap) (port_id|all)\n"
210 " Clear information for port_id, or all.\n\n"
212 "show (rxq|txq) info (port_id) (queue_id)\n"
213 " Display information for configured RX/TX queue.\n\n"
215 "show config (rxtx|cores|fwd|txpkts)\n"
216 " Display the given configuration.\n\n"
218 "read rxd (port_id) (queue_id) (rxd_id)\n"
219 " Display an RX descriptor of a port RX queue.\n\n"
221 "read txd (port_id) (queue_id) (txd_id)\n"
222 " Display a TX descriptor of a port TX queue.\n\n"
224 "ddp get list (port_id)\n"
225 " Get ddp profile info list\n\n"
227 "ddp get info (profile_path)\n"
228 " Get ddp profile information.\n\n"
230 "show vf stats (port_id) (vf_id)\n"
231 " Display a VF's statistics.\n\n"
233 "clear vf stats (port_id) (vf_id)\n"
234 " Reset a VF's statistics.\n\n"
236 "show port (port_id) pctype mapping\n"
237 " Get flow ptype to pctype mapping on a port\n\n"
239 "show port meter stats (port_id) (meter_id) (clear)\n"
240 " Get meter stats on a port\n\n"
241 "show port tm cap (port_id)\n"
242 " Display the port TM capability.\n\n"
244 "show port tm level cap (port_id) (level_id)\n"
245 " Display the port TM hierarchical level capability.\n\n"
247 "show port tm node cap (port_id) (node_id)\n"
248 " Display the port TM node capability.\n\n"
250 "show port tm node type (port_id) (node_id)\n"
251 " Display the port TM node type.\n\n"
253 "show port tm node stats (port_id) (node_id) (clear)\n"
254 " Display the port TM node stats.\n\n"
259 if (show_all || !strcmp(res->section, "config")) {
265 "Configuration changes only become active when"
266 " forwarding is started/restarted.\n\n"
269 " Reset forwarding to the default configuration.\n\n"
271 "set verbose (level)\n"
272 " Set the debug verbosity level X.\n\n"
275 " Set number of ports.\n\n"
278 " Set number of cores.\n\n"
280 "set coremask (mask)\n"
281 " Set the forwarding cores hexadecimal mask.\n\n"
283 "set portmask (mask)\n"
284 " Set the forwarding ports hexadecimal mask.\n\n"
287 " Set number of packets per burst.\n\n"
289 "set burst tx delay (microseconds) retry (num)\n"
290 " Set the transmit delay time and number of retries,"
291 " effective when retry is enabled.\n\n"
293 "set txpkts (x[,y]*)\n"
294 " Set the length of each segment of TXONLY"
295 " and optionally CSUM packets.\n\n"
297 "set txsplit (off|on|rand)\n"
298 " Set the split policy for the TX packets."
299 " Right now only applicable for CSUM and TXONLY"
302 "set corelist (x[,y]*)\n"
303 " Set the list of forwarding cores.\n\n"
305 "set portlist (x[,y]*)\n"
306 " Set the list of forwarding ports.\n\n"
308 "set tx loopback (port_id) (on|off)\n"
309 " Enable or disable tx loopback.\n\n"
311 "set all queues drop (port_id) (on|off)\n"
312 " Set drop enable bit for all queues.\n\n"
314 "set vf split drop (port_id) (vf_id) (on|off)\n"
315 " Set split drop enable bit for a VF from the PF.\n\n"
317 "set vf mac antispoof (port_id) (vf_id) (on|off).\n"
318 " Set MAC antispoof for a VF from the PF.\n\n"
320 "set macsec offload (port_id) on encrypt (on|off) replay-protect (on|off)\n"
321 " Enable MACsec offload.\n\n"
323 "set macsec offload (port_id) off\n"
324 " Disable MACsec offload.\n\n"
326 "set macsec sc (tx|rx) (port_id) (mac) (pi)\n"
327 " Configure MACsec secure connection (SC).\n\n"
329 "set macsec sa (tx|rx) (port_id) (idx) (an) (pn) (key)\n"
330 " Configure MACsec secure association (SA).\n\n"
332 "set vf broadcast (port_id) (vf_id) (on|off)\n"
333 " Set VF broadcast for a VF from the PF.\n\n"
335 "vlan set strip (on|off) (port_id)\n"
336 " Set the VLAN strip on a port.\n\n"
338 "vlan set stripq (on|off) (port_id,queue_id)\n"
339 " Set the VLAN strip for a queue on a port.\n\n"
341 "set vf vlan stripq (port_id) (vf_id) (on|off)\n"
342 " Set the VLAN strip for all queues in a pool for a VF from the PF.\n\n"
344 "set vf vlan insert (port_id) (vf_id) (vlan_id)\n"
345 " Set VLAN insert for a VF from the PF.\n\n"
347 "set vf vlan antispoof (port_id) (vf_id) (on|off)\n"
348 " Set VLAN antispoof for a VF from the PF.\n\n"
350 "set vf vlan tag (port_id) (vf_id) (on|off)\n"
351 " Set VLAN tag for a VF from the PF.\n\n"
353 "set vf tx max-bandwidth (port_id) (vf_id) (bandwidth)\n"
354 " Set a VF's max bandwidth(Mbps).\n\n"
356 "set vf tc tx min-bandwidth (port_id) (vf_id) (bw1, bw2, ...)\n"
357 " Set all TCs' min bandwidth(%%) on a VF.\n\n"
359 "set vf tc tx max-bandwidth (port_id) (vf_id) (tc_no) (bandwidth)\n"
360 " Set a TC's max bandwidth(Mbps) on a VF.\n\n"
362 "set tx strict-link-priority (port_id) (tc_bitmap)\n"
363 " Set some TCs' strict link priority mode on a physical port.\n\n"
365 "set tc tx min-bandwidth (port_id) (bw1, bw2, ...)\n"
366 " Set all TCs' min bandwidth(%%) for all PF and VFs.\n\n"
368 "vlan set filter (on|off) (port_id)\n"
369 " Set the VLAN filter on a port.\n\n"
371 "vlan set qinq (on|off) (port_id)\n"
372 " Set the VLAN QinQ (extended queue in queue)"
375 "vlan set (inner|outer) tpid (value) (port_id)\n"
376 " Set the VLAN TPID for Packet Filtering on"
379 "rx_vlan add (vlan_id|all) (port_id)\n"
380 " Add a vlan_id, or all identifiers, to the set"
381 " of VLAN identifiers filtered by port_id.\n\n"
383 "rx_vlan rm (vlan_id|all) (port_id)\n"
384 " Remove a vlan_id, or all identifiers, from the set"
385 " of VLAN identifiers filtered by port_id.\n\n"
387 "rx_vlan add (vlan_id) port (port_id) vf (vf_mask)\n"
388 " Add a vlan_id, to the set of VLAN identifiers"
389 "filtered for VF(s) from port_id.\n\n"
391 "rx_vlan rm (vlan_id) port (port_id) vf (vf_mask)\n"
392 " Remove a vlan_id, to the set of VLAN identifiers"
393 "filtered for VF(s) from port_id.\n\n"
395 "tunnel_filter add (port_id) (outer_mac) (inner_mac) (ip_addr) "
396 "(inner_vlan) (vxlan|nvgre|ipingre) (imac-ivlan|imac-ivlan-tenid|"
397 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n"
398 " add a tunnel filter of a port.\n\n"
400 "tunnel_filter rm (port_id) (outer_mac) (inner_mac) (ip_addr) "
401 "(inner_vlan) (vxlan|nvgre|ipingre) (imac-ivlan|imac-ivlan-tenid|"
402 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n"
403 " remove a tunnel filter of a port.\n\n"
405 "rx_vxlan_port add (udp_port) (port_id)\n"
406 " Add an UDP port for VXLAN packet filter on a port\n\n"
408 "rx_vxlan_port rm (udp_port) (port_id)\n"
409 " Remove an UDP port for VXLAN packet filter on a port\n\n"
411 "tx_vlan set (port_id) vlan_id[, vlan_id_outer]\n"
412 " Set hardware insertion of VLAN IDs (single or double VLAN "
413 "depends on the number of VLAN IDs) in packets sent on a port.\n\n"
415 "tx_vlan set pvid port_id vlan_id (on|off)\n"
416 " Set port based TX VLAN insertion.\n\n"
418 "tx_vlan reset (port_id)\n"
419 " Disable hardware insertion of a VLAN header in"
420 " packets sent on a port.\n\n"
422 "csum set (ip|udp|tcp|sctp|outer-ip) (hw|sw) (port_id)\n"
423 " Select hardware or software calculation of the"
424 " checksum when transmitting a packet using the"
425 " csum forward engine.\n"
426 " ip|udp|tcp|sctp always concern the inner layer.\n"
427 " outer-ip concerns the outer IP layer in"
428 " case the packet is recognized as a tunnel packet by"
429 " the forward engine (vxlan, gre and ipip are supported)\n"
430 " Please check the NIC datasheet for HW limits.\n\n"
432 "csum parse-tunnel (on|off) (tx_port_id)\n"
433 " If disabled, treat tunnel packets as non-tunneled"
434 " packets (treat inner headers as payload). The port\n"
435 " argument is the port used for TX in csum forward"
438 "csum show (port_id)\n"
439 " Display tx checksum offload configuration\n\n"
441 "tso set (segsize) (portid)\n"
442 " Enable TCP Segmentation Offload in csum forward"
444 " Please check the NIC datasheet for HW limits.\n\n"
447 " Display the status of TCP Segmentation Offload.\n\n"
449 "set port (port_id) gro on|off\n"
450 " Enable or disable Generic Receive Offload in"
451 " csum forwarding engine.\n\n"
453 "show port (port_id) gro\n"
454 " Display GRO configuration.\n\n"
456 "set gro flush (cycles)\n"
457 " Set the cycle to flush GROed packets from"
458 " reassembly tables.\n\n"
460 "set port (port_id) gso (on|off)"
461 " Enable or disable Generic Segmentation Offload in"
462 " csum forwarding engine.\n\n"
464 "set gso segsz (length)\n"
465 " Set max packet length for output GSO segments,"
466 " including packet header and payload.\n\n"
468 "show port (port_id) gso\n"
469 " Show GSO configuration.\n\n"
472 " Set packet forwarding mode.\n\n"
474 "mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n"
475 " Add a MAC address on port_id.\n\n"
477 "mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n"
478 " Remove a MAC address from port_id.\n\n"
480 "mac_addr set (port_id) (XX:XX:XX:XX:XX:XX)\n"
481 " Set the default MAC address for port_id.\n\n"
483 "mac_addr add port (port_id) vf (vf_id) (mac_address)\n"
484 " Add a MAC address for a VF on the port.\n\n"
486 "set vf mac addr (port_id) (vf_id) (XX:XX:XX:XX:XX:XX)\n"
487 " Set the MAC address for a VF from the PF.\n\n"
489 "set port (port_id) uta (mac_address|all) (on|off)\n"
490 " Add/Remove a or all unicast hash filter(s)"
493 "set promisc (port_id|all) (on|off)\n"
494 " Set the promiscuous mode on port_id, or all.\n\n"
496 "set allmulti (port_id|all) (on|off)\n"
497 " Set the allmulti mode on port_id, or all.\n\n"
499 "set vf promisc (port_id) (vf_id) (on|off)\n"
500 " Set unicast promiscuous mode for a VF from the PF.\n\n"
502 "set vf allmulti (port_id) (vf_id) (on|off)\n"
503 " Set multicast promiscuous mode for a VF from the PF.\n\n"
505 "set flow_ctrl rx (on|off) tx (on|off) (high_water)"
506 " (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd"
507 " (on|off) autoneg (on|off) (port_id)\n"
508 "set flow_ctrl rx (on|off) (portid)\n"
509 "set flow_ctrl tx (on|off) (portid)\n"
510 "set flow_ctrl high_water (high_water) (portid)\n"
511 "set flow_ctrl low_water (low_water) (portid)\n"
512 "set flow_ctrl pause_time (pause_time) (portid)\n"
513 "set flow_ctrl send_xon (send_xon) (portid)\n"
514 "set flow_ctrl mac_ctrl_frame_fwd (on|off) (portid)\n"
515 "set flow_ctrl autoneg (on|off) (port_id)\n"
516 " Set the link flow control parameter on a port.\n\n"
518 "set pfc_ctrl rx (on|off) tx (on|off) (high_water)"
519 " (low_water) (pause_time) (priority) (port_id)\n"
520 " Set the priority flow control parameter on a"
523 "set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n"
524 " Set statistics mapping (qmapping 0..15) for RX/TX"
526 " e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2"
527 " on port 0 to mapping 5.\n\n"
529 "set xstats-hide-zero on|off\n"
530 " Set the option to hide the zero values"
531 " for xstats display.\n"
533 "set port (port_id) vf (vf_id) rx|tx on|off\n"
534 " Enable/Disable a VF receive/tranmit from a port\n\n"
536 "set port (port_id) vf (vf_id) (mac_addr)"
537 " (exact-mac#exact-mac-vlan#hashmac|hashmac-vlan) on|off\n"
538 " Add/Remove unicast or multicast MAC addr filter"
541 "set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM"
543 " AUPE:accepts untagged VLAN;"
544 "ROPE:accept unicast hash\n\n"
545 " BAM:accepts broadcast packets;"
546 "MPE:accepts all multicast packets\n\n"
547 " Enable/Disable a VF receive mode of a port\n\n"
549 "set port (port_id) queue (queue_id) rate (rate_num)\n"
550 " Set rate limit for a queue of a port\n\n"
552 "set port (port_id) vf (vf_id) rate (rate_num) "
553 "queue_mask (queue_mask_value)\n"
554 " Set rate limit for queues in VF of a port\n\n"
556 "set port (port_id) mirror-rule (rule_id)"
557 " (pool-mirror-up|pool-mirror-down|vlan-mirror)"
558 " (poolmask|vlanid[,vlanid]*) dst-pool (pool_id) (on|off)\n"
559 " Set pool or vlan type mirror rule on a port.\n"
560 " e.g., 'set port 0 mirror-rule 0 vlan-mirror 0,1"
561 " dst-pool 0 on' enable mirror traffic with vlan 0,1"
564 "set port (port_id) mirror-rule (rule_id)"
565 " (uplink-mirror|downlink-mirror) dst-pool"
566 " (pool_id) (on|off)\n"
567 " Set uplink or downlink type mirror rule on a port.\n"
568 " e.g., 'set port 0 mirror-rule 0 uplink-mirror dst-pool"
569 " 0 on' enable mirror income traffic to pool 0.\n\n"
571 "reset port (port_id) mirror-rule (rule_id)\n"
572 " Reset a mirror rule.\n\n"
574 "set flush_rx (on|off)\n"
575 " Flush (default) or don't flush RX streams before"
576 " forwarding. Mainly used with PCAP drivers.\n\n"
578 "set bypass mode (normal|bypass|isolate) (port_id)\n"
579 " Set the bypass mode for the lowest port on bypass enabled"
582 "set bypass event (timeout|os_on|os_off|power_on|power_off) "
583 "mode (normal|bypass|isolate) (port_id)\n"
584 " Set the event required to initiate specified bypass mode for"
585 " the lowest port on a bypass enabled NIC where:\n"
586 " timeout = enable bypass after watchdog timeout.\n"
587 " os_on = enable bypass when OS/board is powered on.\n"
588 " os_off = enable bypass when OS/board is powered off.\n"
589 " power_on = enable bypass when power supply is turned on.\n"
590 " power_off = enable bypass when power supply is turned off."
593 "set bypass timeout (0|1.5|2|3|4|8|16|32)\n"
594 " Set the bypass watchdog timeout to 'n' seconds"
595 " where 0 = instant.\n\n"
597 "show bypass config (port_id)\n"
598 " Show the bypass configuration for a bypass enabled NIC"
599 " using the lowest port on the NIC.\n\n"
601 #ifdef RTE_LIBRTE_PMD_BOND
602 "create bonded device (mode) (socket)\n"
603 " Create a new bonded device with specific bonding mode and socket.\n\n"
605 "add bonding slave (slave_id) (port_id)\n"
606 " Add a slave device to a bonded device.\n\n"
608 "remove bonding slave (slave_id) (port_id)\n"
609 " Remove a slave device from a bonded device.\n\n"
611 "set bonding mode (value) (port_id)\n"
612 " Set the bonding mode on a bonded device.\n\n"
614 "set bonding primary (slave_id) (port_id)\n"
615 " Set the primary slave for a bonded device.\n\n"
617 "show bonding config (port_id)\n"
618 " Show the bonding config for port_id.\n\n"
620 "set bonding mac_addr (port_id) (address)\n"
621 " Set the MAC address of a bonded device.\n\n"
623 "set bonding mode IEEE802.3AD aggregator policy (port_id) (agg_name)"
624 " Set Aggregation mode for IEEE802.3AD (mode 4)"
626 "set bonding xmit_balance_policy (port_id) (l2|l23|l34)\n"
627 " Set the transmit balance policy for bonded device running in balance mode.\n\n"
629 "set bonding mon_period (port_id) (value)\n"
630 " Set the bonding link status monitoring polling period in ms.\n\n"
632 "set bonding lacp dedicated_queues <port_id> (enable|disable)\n"
633 " Enable/disable dedicated queues for LACP control traffic.\n\n"
636 "set link-up port (port_id)\n"
637 " Set link up for a port.\n\n"
639 "set link-down port (port_id)\n"
640 " Set link down for a port.\n\n"
642 "E-tag set insertion on port-tag-id (value)"
643 " port (port_id) vf (vf_id)\n"
644 " Enable E-tag insertion for a VF on a port\n\n"
646 "E-tag set insertion off port (port_id) vf (vf_id)\n"
647 " Disable E-tag insertion for a VF on a port\n\n"
649 "E-tag set stripping (on|off) port (port_id)\n"
650 " Enable/disable E-tag stripping on a port\n\n"
652 "E-tag set forwarding (on|off) port (port_id)\n"
653 " Enable/disable E-tag based forwarding"
656 "E-tag set filter add e-tag-id (value) dst-pool"
657 " (pool_id) port (port_id)\n"
658 " Add an E-tag forwarding filter on a port\n\n"
660 "E-tag set filter del e-tag-id (value) port (port_id)\n"
661 " Delete an E-tag forwarding filter on a port\n\n"
663 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
664 "set port tm hierarchy default (port_id)\n"
665 " Set default traffic Management hierarchy on a port\n\n"
668 "ddp add (port_id) (profile_path[,output_path])\n"
669 " Load a profile package on a port\n\n"
671 "ddp del (port_id) (profile_path)\n"
672 " Delete a profile package from a port\n\n"
674 "ptype mapping get (port_id) (valid_only)\n"
675 " Get ptype mapping on a port\n\n"
677 "ptype mapping replace (port_id) (target) (mask) (pky_type)\n"
678 " Replace target with the pkt_type in ptype mapping\n\n"
680 "ptype mapping reset (port_id)\n"
681 " Reset ptype mapping on a port\n\n"
683 "ptype mapping update (port_id) (hw_ptype) (sw_ptype)\n"
684 " Update a ptype mapping item on a port\n\n"
686 "set port (port_id) queue-region region_id (value) "
687 "queue_start_index (value) queue_num (value)\n"
688 " Set a queue region on a port\n\n"
690 "set port (port_id) queue-region region_id (value) "
692 " Set a flowtype region index on a port\n\n"
694 "set port (port_id) queue-region UP (value) region_id (value)\n"
695 " Set the mapping of User Priority to "
696 "queue region on a port\n\n"
698 "set port (port_id) queue-region flush (on|off)\n"
699 " flush all queue region related configuration\n\n"
701 "show port meter cap (port_id)\n"
702 " Show port meter capability information\n\n"
704 "add port meter profile srtcm_rfc2697 (port_id) (profile_id) (cir) (cbs) (ebs)\n"
705 " meter profile add - srtcm rfc 2697\n\n"
707 "add port meter profile trtcm_rfc2698 (port_id) (profile_id) (cir) (pir) (cbs) (pbs)\n"
708 " meter profile add - trtcm rfc 2698\n\n"
710 "add port meter profile trtcm_rfc4115 (port_id) (profile_id) (cir) (eir) (cbs) (ebs)\n"
711 " meter profile add - trtcm rfc 4115\n\n"
713 "del port meter profile (port_id) (profile_id)\n"
714 " meter profile delete\n\n"
716 "create port meter (port_id) (mtr_id) (profile_id) (meter_enable)\n"
717 "(g_action) (y_action) (r_action) (stats_mask) (shared)\n"
718 "(use_pre_meter_color) [(dscp_tbl_entry0) (dscp_tbl_entry1)...\n"
719 "(dscp_tbl_entry63)]\n"
722 "enable port meter (port_id) (mtr_id)\n"
725 "disable port meter (port_id) (mtr_id)\n"
728 "del port meter (port_id) (mtr_id)\n"
731 "set port meter profile (port_id) (mtr_id) (profile_id)\n"
732 " meter update meter profile\n\n"
734 "set port meter dscp table (port_id) (mtr_id) [(dscp_tbl_entry0)\n"
735 "(dscp_tbl_entry1)...(dscp_tbl_entry63)]\n"
736 " update meter dscp table entries\n\n"
738 "set port meter policer action (port_id) (mtr_id) (action_mask)\n"
739 "(action0) [(action1) (action2)]\n"
740 " meter update policer action\n\n"
742 "set port meter stats mask (port_id) (mtr_id) (stats_mask)\n"
743 " meter update stats\n\n"
745 "show port (port_id) queue-region\n"
746 " show all queue region related configuration info\n\n"
748 "add port tm node shaper profile (port_id) (shaper_profile_id)"
749 " (tb_rate) (tb_size) (packet_length_adjust)\n"
750 " Add port tm node private shaper profile.\n\n"
752 "del port tm node shaper profile (port_id) (shaper_profile_id)\n"
753 " Delete port tm node private shaper profile.\n\n"
755 "add port tm node shared shaper (port_id) (shared_shaper_id)"
756 " (shaper_profile_id)\n"
757 " Add/update port tm node shared shaper.\n\n"
759 "del port tm node shared shaper (port_id) (shared_shaper_id)\n"
760 " Delete port tm node shared shaper.\n\n"
762 "set port tm node shaper profile (port_id) (node_id)"
763 " (shaper_profile_id)\n"
764 " Set port tm node shaper profile.\n\n"
766 "add port tm node wred profile (port_id) (wred_profile_id)"
767 " (color_g) (min_th_g) (max_th_g) (maxp_inv_g) (wq_log2_g)"
768 " (color_y) (min_th_y) (max_th_y) (maxp_inv_y) (wq_log2_y)"
769 " (color_r) (min_th_r) (max_th_r) (maxp_inv_r) (wq_log2_r)\n"
770 " Add port tm node wred profile.\n\n"
772 "del port tm node wred profile (port_id) (wred_profile_id)\n"
773 " Delete port tm node wred profile.\n\n"
775 "add port tm nonleaf node (port_id) (node_id) (parent_node_id)"
776 " (priority) (weight) (level_id) (shaper_profile_id)"
777 " (n_sp_priorities) (stats_mask) (n_shared_shapers)"
778 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
779 " Add port tm nonleaf node.\n\n"
781 "add port tm leaf node (port_id) (node_id) (parent_node_id)"
782 " (priority) (weight) (level_id) (shaper_profile_id)"
783 " (cman_mode) (wred_profile_id) (stats_mask) (n_shared_shapers)"
784 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
785 " Add port tm leaf node.\n\n"
787 "del port tm node (port_id) (node_id)\n"
788 " Delete port tm node.\n\n"
790 "set port tm node parent (port_id) (node_id) (parent_node_id)"
791 " (priority) (weight)\n"
792 " Set port tm node parent.\n\n"
794 "port tm hierarchy commit (port_id) (clean_on_fail)\n"
795 " Commit tm hierarchy.\n\n"
797 , list_pkt_forwarding_modes()
801 if (show_all || !strcmp(res->section, "ports")) {
807 "----------------\n\n"
809 "port start (port_id|all)\n"
810 " Start all ports or port_id.\n\n"
812 "port stop (port_id|all)\n"
813 " Stop all ports or port_id.\n\n"
815 "port close (port_id|all)\n"
816 " Close all ports or port_id.\n\n"
818 "port attach (ident)\n"
819 " Attach physical or virtual dev by pci address or virtual device name\n\n"
821 "port detach (port_id)\n"
822 " Detach physical or virtual dev by port_id\n\n"
824 "port config (port_id|all)"
825 " speed (10|100|1000|10000|25000|40000|50000|100000|auto)"
826 " duplex (half|full|auto)\n"
827 " Set speed and duplex for all ports or port_id\n\n"
829 "port config all (rxq|txq|rxd|txd) (value)\n"
830 " Set number for rxq/txq/rxd/txd.\n\n"
832 "port config all max-pkt-len (value)\n"
833 " Set the max packet length.\n\n"
835 "port config all (crc-strip|scatter|rx-cksum|rx-timestamp|hw-vlan|hw-vlan-filter|"
836 "hw-vlan-strip|hw-vlan-extend|drop-en)"
838 " Set crc-strip/scatter/rx-checksum/hardware-vlan/drop_en"
841 "port config all rss (all|ip|tcp|udp|sctp|ether|port|vxlan|"
842 "geneve|nvgre|none|<flowtype_id>)\n"
843 " Set the RSS mode.\n\n"
845 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
846 " Set the RSS redirection table.\n\n"
848 "port config (port_id) dcb vt (on|off) (traffic_class)"
850 " Set the DCB mode.\n\n"
852 "port config all burst (value)\n"
853 " Set the number of packets per burst.\n\n"
855 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
857 " Set the ring prefetch/host/writeback threshold"
858 " for tx/rx queue.\n\n"
860 "port config all (txfreet|txrst|rxfreet) (value)\n"
861 " Set free threshold for rx/tx, or set"
862 " tx rs bit threshold.\n\n"
863 "port config mtu X value\n"
864 " Set the MTU of port X to a given value\n\n"
866 "port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
867 " Start/stop a rx/tx queue of port X. Only take effect"
868 " when port X is started\n\n"
870 "port config (port_id|all) l2-tunnel E-tag ether-type"
872 " Set the value of E-tag ether-type.\n\n"
874 "port config (port_id|all) l2-tunnel E-tag"
875 " (enable|disable)\n"
876 " Enable/disable the E-tag support.\n\n"
878 "port config (port_id) pctype mapping reset\n"
879 " Reset flow type to pctype mapping on a port\n\n"
881 "port config (port_id) pctype mapping update"
882 " (pctype_id_0[,pctype_id_1]*) (flow_type_id)\n"
883 " Update a flow type to pctype mapping item on a port\n\n"
887 if (show_all || !strcmp(res->section, "registers")) {
895 "read reg (port_id) (address)\n"
896 " Display value of a port register.\n\n"
898 "read regfield (port_id) (address) (bit_x) (bit_y)\n"
899 " Display a port register bit field.\n\n"
901 "read regbit (port_id) (address) (bit_x)\n"
902 " Display a single port register bit.\n\n"
904 "write reg (port_id) (address) (value)\n"
905 " Set value of a port register.\n\n"
907 "write regfield (port_id) (address) (bit_x) (bit_y)"
909 " Set bit field of a port register.\n\n"
911 "write regbit (port_id) (address) (bit_x) (value)\n"
912 " Set single bit value of a port register.\n\n"
915 if (show_all || !strcmp(res->section, "filters")) {
923 "ethertype_filter (port_id) (add|del)"
924 " (mac_addr|mac_ignr) (mac_address) ethertype"
925 " (ether_type) (drop|fwd) queue (queue_id)\n"
926 " Add/Del an ethertype filter.\n\n"
928 "2tuple_filter (port_id) (add|del)"
929 " dst_port (dst_port_value) protocol (protocol_value)"
930 " mask (mask_value) tcp_flags (tcp_flags_value)"
931 " priority (prio_value) queue (queue_id)\n"
932 " Add/Del a 2tuple filter.\n\n"
934 "5tuple_filter (port_id) (add|del)"
935 " dst_ip (dst_address) src_ip (src_address)"
936 " dst_port (dst_port_value) src_port (src_port_value)"
937 " protocol (protocol_value)"
938 " mask (mask_value) tcp_flags (tcp_flags_value)"
939 " priority (prio_value) queue (queue_id)\n"
940 " Add/Del a 5tuple filter.\n\n"
942 "syn_filter (port_id) (add|del) priority (high|low) queue (queue_id)"
943 " Add/Del syn filter.\n\n"
945 "flex_filter (port_id) (add|del) len (len_value)"
946 " bytes (bytes_value) mask (mask_value)"
947 " priority (prio_value) queue (queue_id)\n"
948 " Add/Del a flex filter.\n\n"
950 "flow_director_filter (port_id) mode IP (add|del|update)"
951 " flow (ipv4-other|ipv4-frag|ipv6-other|ipv6-frag)"
952 " src (src_ip_address) dst (dst_ip_address)"
953 " tos (tos_value) proto (proto_value) ttl (ttl_value)"
954 " vlan (vlan_value) flexbytes (flexbytes_value)"
955 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
956 " fd_id (fd_id_value)\n"
957 " Add/Del an IP type flow director filter.\n\n"
959 "flow_director_filter (port_id) mode IP (add|del|update)"
960 " flow (ipv4-tcp|ipv4-udp|ipv6-tcp|ipv6-udp)"
961 " src (src_ip_address) (src_port)"
962 " dst (dst_ip_address) (dst_port)"
963 " tos (tos_value) ttl (ttl_value)"
964 " vlan (vlan_value) flexbytes (flexbytes_value)"
965 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
966 " fd_id (fd_id_value)\n"
967 " Add/Del an UDP/TCP type flow director filter.\n\n"
969 "flow_director_filter (port_id) mode IP (add|del|update)"
970 " flow (ipv4-sctp|ipv6-sctp)"
971 " src (src_ip_address) (src_port)"
972 " dst (dst_ip_address) (dst_port)"
973 " tag (verification_tag) "
974 " tos (tos_value) ttl (ttl_value)"
976 " flexbytes (flexbytes_value) (drop|fwd)"
977 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
978 " Add/Del a SCTP type flow director filter.\n\n"
980 "flow_director_filter (port_id) mode IP (add|del|update)"
981 " flow l2_payload ether (ethertype)"
982 " flexbytes (flexbytes_value) (drop|fwd)"
983 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
984 " Add/Del a l2 payload type flow director filter.\n\n"
986 "flow_director_filter (port_id) mode MAC-VLAN (add|del|update)"
987 " mac (mac_address) vlan (vlan_value)"
988 " flexbytes (flexbytes_value) (drop|fwd)"
989 " queue (queue_id) fd_id (fd_id_value)\n"
990 " Add/Del a MAC-VLAN flow director filter.\n\n"
992 "flow_director_filter (port_id) mode Tunnel (add|del|update)"
993 " mac (mac_address) vlan (vlan_value)"
994 " tunnel (NVGRE|VxLAN) tunnel-id (tunnel_id_value)"
995 " flexbytes (flexbytes_value) (drop|fwd)"
996 " queue (queue_id) fd_id (fd_id_value)\n"
997 " Add/Del a Tunnel flow director filter.\n\n"
999 "flush_flow_director (port_id)\n"
1000 " Flush all flow director entries of a device.\n\n"
1002 "flow_director_mask (port_id) mode IP vlan (vlan_value)"
1003 " src_mask (ipv4_src) (ipv6_src) (src_port)"
1004 " dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n"
1005 " Set flow director IP mask.\n\n"
1007 "flow_director_mask (port_id) mode MAC-VLAN"
1008 " vlan (vlan_value)\n"
1009 " Set flow director MAC-VLAN mask.\n\n"
1011 "flow_director_mask (port_id) mode Tunnel"
1012 " vlan (vlan_value) mac (mac_value)"
1013 " tunnel-type (tunnel_type_value)"
1014 " tunnel-id (tunnel_id_value)\n"
1015 " Set flow director Tunnel mask.\n\n"
1017 "flow_director_flex_mask (port_id)"
1018 " flow (none|ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
1019 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|l2_payload|all)"
1021 " Configure mask of flex payload.\n\n"
1023 "flow_director_flex_payload (port_id)"
1024 " (raw|l2|l3|l4) (config)\n"
1025 " Configure flex payload selection.\n\n"
1027 "get_sym_hash_ena_per_port (port_id)\n"
1028 " get symmetric hash enable configuration per port.\n\n"
1030 "set_sym_hash_ena_per_port (port_id) (enable|disable)\n"
1031 " set symmetric hash enable configuration per port"
1032 " to enable or disable.\n\n"
1034 "get_hash_global_config (port_id)\n"
1035 " Get the global configurations of hash filters.\n\n"
1037 "set_hash_global_config (port_id) (toeplitz|simple_xor|default)"
1038 " (ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
1039 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload)"
1040 " (enable|disable)\n"
1041 " Set the global configurations of hash filters.\n\n"
1043 "set_hash_input_set (port_id) (ipv4|ipv4-frag|"
1044 "ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
1045 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1046 "l2_payload|<flowtype_id>) (ovlan|ivlan|src-ipv4|dst-ipv4|"
1047 "src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|ipv6-tc|"
1048 "ipv6-next-header|udp-src-port|udp-dst-port|"
1049 "tcp-src-port|tcp-dst-port|sctp-src-port|"
1050 "sctp-dst-port|sctp-veri-tag|udp-key|gre-key|fld-1st|"
1051 "fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|fld-7th|"
1052 "fld-8th|none) (select|add)\n"
1053 " Set the input set for hash.\n\n"
1055 "set_fdir_input_set (port_id) "
1056 "(ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
1057 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1058 "l2_payload) (ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|"
1059 "dst-ipv6|ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|"
1060 "ipv6-next-header|ipv6-hop-limits|udp-src-port|"
1061 "udp-dst-port|tcp-src-port|tcp-dst-port|"
1062 "sctp-src-port|sctp-dst-port|sctp-veri-tag|none)"
1064 " Set the input set for FDir.\n\n"
1066 "flow validate {port_id}"
1067 " [group {group_id}] [priority {level}]"
1068 " [ingress] [egress]"
1069 " pattern {item} [/ {item} [...]] / end"
1070 " actions {action} [/ {action} [...]] / end\n"
1071 " Check whether a flow rule can be created.\n\n"
1073 "flow create {port_id}"
1074 " [group {group_id}] [priority {level}]"
1075 " [ingress] [egress]"
1076 " pattern {item} [/ {item} [...]] / end"
1077 " actions {action} [/ {action} [...]] / end\n"
1078 " Create a flow rule.\n\n"
1080 "flow destroy {port_id} rule {rule_id} [...]\n"
1081 " Destroy specific flow rules.\n\n"
1083 "flow flush {port_id}\n"
1084 " Destroy all flow rules.\n\n"
1086 "flow query {port_id} {rule_id} {action}\n"
1087 " Query an existing flow rule.\n\n"
1089 "flow list {port_id} [group {group_id}] [...]\n"
1090 " List existing flow rules sorted by priority,"
1091 " filtered by group identifiers.\n\n"
1093 "flow isolate {port_id} {boolean}\n"
1094 " Restrict ingress traffic to the defined"
1100 cmdline_parse_token_string_t cmd_help_long_help =
1101 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
1103 cmdline_parse_token_string_t cmd_help_long_section =
1104 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
1105 "all#control#display#config#"
1106 "ports#registers#filters");
1108 cmdline_parse_inst_t cmd_help_long = {
1109 .f = cmd_help_long_parsed,
1111 .help_str = "help all|control|display|config|ports|register|filters: "
1114 (void *)&cmd_help_long_help,
1115 (void *)&cmd_help_long_section,
1121 /* *** start/stop/close all ports *** */
1122 struct cmd_operate_port_result {
1123 cmdline_fixed_string_t keyword;
1124 cmdline_fixed_string_t name;
1125 cmdline_fixed_string_t value;
1128 static void cmd_operate_port_parsed(void *parsed_result,
1129 __attribute__((unused)) struct cmdline *cl,
1130 __attribute__((unused)) void *data)
1132 struct cmd_operate_port_result *res = parsed_result;
1134 if (!strcmp(res->name, "start"))
1135 start_port(RTE_PORT_ALL);
1136 else if (!strcmp(res->name, "stop"))
1137 stop_port(RTE_PORT_ALL);
1138 else if (!strcmp(res->name, "close"))
1139 close_port(RTE_PORT_ALL);
1140 else if (!strcmp(res->name, "reset"))
1141 reset_port(RTE_PORT_ALL);
1143 printf("Unknown parameter\n");
1146 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
1147 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
1149 cmdline_parse_token_string_t cmd_operate_port_all_port =
1150 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
1151 "start#stop#close#reset");
1152 cmdline_parse_token_string_t cmd_operate_port_all_all =
1153 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
1155 cmdline_parse_inst_t cmd_operate_port = {
1156 .f = cmd_operate_port_parsed,
1158 .help_str = "port start|stop|close all: Start/Stop/Close/Reset all ports",
1160 (void *)&cmd_operate_port_all_cmd,
1161 (void *)&cmd_operate_port_all_port,
1162 (void *)&cmd_operate_port_all_all,
1167 /* *** start/stop/close specific port *** */
1168 struct cmd_operate_specific_port_result {
1169 cmdline_fixed_string_t keyword;
1170 cmdline_fixed_string_t name;
1174 static void cmd_operate_specific_port_parsed(void *parsed_result,
1175 __attribute__((unused)) struct cmdline *cl,
1176 __attribute__((unused)) void *data)
1178 struct cmd_operate_specific_port_result *res = parsed_result;
1180 if (!strcmp(res->name, "start"))
1181 start_port(res->value);
1182 else if (!strcmp(res->name, "stop"))
1183 stop_port(res->value);
1184 else if (!strcmp(res->name, "close"))
1185 close_port(res->value);
1186 else if (!strcmp(res->name, "reset"))
1187 reset_port(res->value);
1189 printf("Unknown parameter\n");
1192 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
1193 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1195 cmdline_parse_token_string_t cmd_operate_specific_port_port =
1196 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1197 name, "start#stop#close#reset");
1198 cmdline_parse_token_num_t cmd_operate_specific_port_id =
1199 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
1202 cmdline_parse_inst_t cmd_operate_specific_port = {
1203 .f = cmd_operate_specific_port_parsed,
1205 .help_str = "port start|stop|close <port_id>: Start/Stop/Close/Reset port_id",
1207 (void *)&cmd_operate_specific_port_cmd,
1208 (void *)&cmd_operate_specific_port_port,
1209 (void *)&cmd_operate_specific_port_id,
1214 /* *** attach a specified port *** */
1215 struct cmd_operate_attach_port_result {
1216 cmdline_fixed_string_t port;
1217 cmdline_fixed_string_t keyword;
1218 cmdline_fixed_string_t identifier;
1221 static void cmd_operate_attach_port_parsed(void *parsed_result,
1222 __attribute__((unused)) struct cmdline *cl,
1223 __attribute__((unused)) void *data)
1225 struct cmd_operate_attach_port_result *res = parsed_result;
1227 if (!strcmp(res->keyword, "attach"))
1228 attach_port(res->identifier);
1230 printf("Unknown parameter\n");
1233 cmdline_parse_token_string_t cmd_operate_attach_port_port =
1234 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1236 cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
1237 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1239 cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
1240 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1243 cmdline_parse_inst_t cmd_operate_attach_port = {
1244 .f = cmd_operate_attach_port_parsed,
1246 .help_str = "port attach <identifier>: "
1247 "(identifier: pci address or virtual dev name)",
1249 (void *)&cmd_operate_attach_port_port,
1250 (void *)&cmd_operate_attach_port_keyword,
1251 (void *)&cmd_operate_attach_port_identifier,
1256 /* *** detach a specified port *** */
1257 struct cmd_operate_detach_port_result {
1258 cmdline_fixed_string_t port;
1259 cmdline_fixed_string_t keyword;
1263 static void cmd_operate_detach_port_parsed(void *parsed_result,
1264 __attribute__((unused)) struct cmdline *cl,
1265 __attribute__((unused)) void *data)
1267 struct cmd_operate_detach_port_result *res = parsed_result;
1269 if (!strcmp(res->keyword, "detach"))
1270 detach_port(res->port_id);
1272 printf("Unknown parameter\n");
1275 cmdline_parse_token_string_t cmd_operate_detach_port_port =
1276 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1278 cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
1279 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1281 cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
1282 TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
1285 cmdline_parse_inst_t cmd_operate_detach_port = {
1286 .f = cmd_operate_detach_port_parsed,
1288 .help_str = "port detach <port_id>",
1290 (void *)&cmd_operate_detach_port_port,
1291 (void *)&cmd_operate_detach_port_keyword,
1292 (void *)&cmd_operate_detach_port_port_id,
1297 /* *** configure speed for all ports *** */
1298 struct cmd_config_speed_all {
1299 cmdline_fixed_string_t port;
1300 cmdline_fixed_string_t keyword;
1301 cmdline_fixed_string_t all;
1302 cmdline_fixed_string_t item1;
1303 cmdline_fixed_string_t item2;
1304 cmdline_fixed_string_t value1;
1305 cmdline_fixed_string_t value2;
1309 parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed)
1314 if (!strcmp(duplexstr, "half")) {
1315 duplex = ETH_LINK_HALF_DUPLEX;
1316 } else if (!strcmp(duplexstr, "full")) {
1317 duplex = ETH_LINK_FULL_DUPLEX;
1318 } else if (!strcmp(duplexstr, "auto")) {
1319 duplex = ETH_LINK_FULL_DUPLEX;
1321 printf("Unknown duplex parameter\n");
1325 if (!strcmp(speedstr, "10")) {
1326 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1327 ETH_LINK_SPEED_10M_HD : ETH_LINK_SPEED_10M;
1328 } else if (!strcmp(speedstr, "100")) {
1329 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1330 ETH_LINK_SPEED_100M_HD : ETH_LINK_SPEED_100M;
1332 if (duplex != ETH_LINK_FULL_DUPLEX) {
1333 printf("Invalid speed/duplex parameters\n");
1336 if (!strcmp(speedstr, "1000")) {
1337 *speed = ETH_LINK_SPEED_1G;
1338 } else if (!strcmp(speedstr, "10000")) {
1339 *speed = ETH_LINK_SPEED_10G;
1340 } else if (!strcmp(speedstr, "25000")) {
1341 *speed = ETH_LINK_SPEED_25G;
1342 } else if (!strcmp(speedstr, "40000")) {
1343 *speed = ETH_LINK_SPEED_40G;
1344 } else if (!strcmp(speedstr, "50000")) {
1345 *speed = ETH_LINK_SPEED_50G;
1346 } else if (!strcmp(speedstr, "100000")) {
1347 *speed = ETH_LINK_SPEED_100G;
1348 } else if (!strcmp(speedstr, "auto")) {
1349 *speed = ETH_LINK_SPEED_AUTONEG;
1351 printf("Unknown speed parameter\n");
1360 cmd_config_speed_all_parsed(void *parsed_result,
1361 __attribute__((unused)) struct cmdline *cl,
1362 __attribute__((unused)) void *data)
1364 struct cmd_config_speed_all *res = parsed_result;
1365 uint32_t link_speed;
1368 if (!all_ports_stopped()) {
1369 printf("Please stop all ports first\n");
1373 if (parse_and_check_speed_duplex(res->value1, res->value2,
1377 RTE_ETH_FOREACH_DEV(pid) {
1378 ports[pid].dev_conf.link_speeds = link_speed;
1381 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1384 cmdline_parse_token_string_t cmd_config_speed_all_port =
1385 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1386 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1387 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1389 cmdline_parse_token_string_t cmd_config_speed_all_all =
1390 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1391 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1392 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1393 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1394 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1395 "10#100#1000#10000#25000#40000#50000#100000#auto");
1396 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1397 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1398 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1399 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1402 cmdline_parse_inst_t cmd_config_speed_all = {
1403 .f = cmd_config_speed_all_parsed,
1405 .help_str = "port config all speed "
1406 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1409 (void *)&cmd_config_speed_all_port,
1410 (void *)&cmd_config_speed_all_keyword,
1411 (void *)&cmd_config_speed_all_all,
1412 (void *)&cmd_config_speed_all_item1,
1413 (void *)&cmd_config_speed_all_value1,
1414 (void *)&cmd_config_speed_all_item2,
1415 (void *)&cmd_config_speed_all_value2,
1420 /* *** configure speed for specific port *** */
1421 struct cmd_config_speed_specific {
1422 cmdline_fixed_string_t port;
1423 cmdline_fixed_string_t keyword;
1425 cmdline_fixed_string_t item1;
1426 cmdline_fixed_string_t item2;
1427 cmdline_fixed_string_t value1;
1428 cmdline_fixed_string_t value2;
1432 cmd_config_speed_specific_parsed(void *parsed_result,
1433 __attribute__((unused)) struct cmdline *cl,
1434 __attribute__((unused)) void *data)
1436 struct cmd_config_speed_specific *res = parsed_result;
1437 uint32_t link_speed;
1439 if (!all_ports_stopped()) {
1440 printf("Please stop all ports first\n");
1444 if (port_id_is_invalid(res->id, ENABLED_WARN))
1447 if (parse_and_check_speed_duplex(res->value1, res->value2,
1451 ports[res->id].dev_conf.link_speeds = link_speed;
1453 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1457 cmdline_parse_token_string_t cmd_config_speed_specific_port =
1458 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1460 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1461 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1463 cmdline_parse_token_num_t cmd_config_speed_specific_id =
1464 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT8);
1465 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1466 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1468 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1469 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1470 "10#100#1000#10000#25000#40000#50000#100000#auto");
1471 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1472 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1474 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1475 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1478 cmdline_parse_inst_t cmd_config_speed_specific = {
1479 .f = cmd_config_speed_specific_parsed,
1481 .help_str = "port config <port_id> speed "
1482 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1485 (void *)&cmd_config_speed_specific_port,
1486 (void *)&cmd_config_speed_specific_keyword,
1487 (void *)&cmd_config_speed_specific_id,
1488 (void *)&cmd_config_speed_specific_item1,
1489 (void *)&cmd_config_speed_specific_value1,
1490 (void *)&cmd_config_speed_specific_item2,
1491 (void *)&cmd_config_speed_specific_value2,
1496 /* *** configure txq/rxq, txd/rxd *** */
1497 struct cmd_config_rx_tx {
1498 cmdline_fixed_string_t port;
1499 cmdline_fixed_string_t keyword;
1500 cmdline_fixed_string_t all;
1501 cmdline_fixed_string_t name;
1506 cmd_config_rx_tx_parsed(void *parsed_result,
1507 __attribute__((unused)) struct cmdline *cl,
1508 __attribute__((unused)) void *data)
1510 struct cmd_config_rx_tx *res = parsed_result;
1512 if (!all_ports_stopped()) {
1513 printf("Please stop all ports first\n");
1516 if (!strcmp(res->name, "rxq")) {
1517 if (!res->value && !nb_txq) {
1518 printf("Warning: Either rx or tx queues should be non zero\n");
1521 nb_rxq = res->value;
1523 else if (!strcmp(res->name, "txq")) {
1524 if (!res->value && !nb_rxq) {
1525 printf("Warning: Either rx or tx queues should be non zero\n");
1528 nb_txq = res->value;
1530 else if (!strcmp(res->name, "rxd")) {
1531 if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) {
1532 printf("rxd %d invalid - must be > 0 && <= %d\n",
1533 res->value, RTE_TEST_RX_DESC_MAX);
1536 nb_rxd = res->value;
1537 } else if (!strcmp(res->name, "txd")) {
1538 if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) {
1539 printf("txd %d invalid - must be > 0 && <= %d\n",
1540 res->value, RTE_TEST_TX_DESC_MAX);
1543 nb_txd = res->value;
1545 printf("Unknown parameter\n");
1553 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1556 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1557 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1558 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1559 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1560 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1561 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1562 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1563 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1565 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1566 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
1568 cmdline_parse_inst_t cmd_config_rx_tx = {
1569 .f = cmd_config_rx_tx_parsed,
1571 .help_str = "port config all rxq|txq|rxd|txd <value>",
1573 (void *)&cmd_config_rx_tx_port,
1574 (void *)&cmd_config_rx_tx_keyword,
1575 (void *)&cmd_config_rx_tx_all,
1576 (void *)&cmd_config_rx_tx_name,
1577 (void *)&cmd_config_rx_tx_value,
1582 /* *** config max packet length *** */
1583 struct cmd_config_max_pkt_len_result {
1584 cmdline_fixed_string_t port;
1585 cmdline_fixed_string_t keyword;
1586 cmdline_fixed_string_t all;
1587 cmdline_fixed_string_t name;
1592 cmd_config_max_pkt_len_parsed(void *parsed_result,
1593 __attribute__((unused)) struct cmdline *cl,
1594 __attribute__((unused)) void *data)
1596 struct cmd_config_max_pkt_len_result *res = parsed_result;
1597 uint64_t rx_offloads = rx_mode.offloads;
1599 if (!all_ports_stopped()) {
1600 printf("Please stop all ports first\n");
1604 if (!strcmp(res->name, "max-pkt-len")) {
1605 if (res->value < ETHER_MIN_LEN) {
1606 printf("max-pkt-len can not be less than %d\n",
1610 if (res->value == rx_mode.max_rx_pkt_len)
1613 rx_mode.max_rx_pkt_len = res->value;
1614 if (res->value > ETHER_MAX_LEN)
1615 rx_offloads |= DEV_RX_OFFLOAD_JUMBO_FRAME;
1617 rx_offloads &= ~DEV_RX_OFFLOAD_JUMBO_FRAME;
1619 printf("Unknown parameter\n");
1623 rx_mode.offloads = rx_offloads;
1627 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1630 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
1631 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
1633 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
1634 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
1636 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
1637 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
1639 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
1640 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
1642 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1643 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1646 cmdline_parse_inst_t cmd_config_max_pkt_len = {
1647 .f = cmd_config_max_pkt_len_parsed,
1649 .help_str = "port config all max-pkt-len <value>",
1651 (void *)&cmd_config_max_pkt_len_port,
1652 (void *)&cmd_config_max_pkt_len_keyword,
1653 (void *)&cmd_config_max_pkt_len_all,
1654 (void *)&cmd_config_max_pkt_len_name,
1655 (void *)&cmd_config_max_pkt_len_value,
1660 /* *** configure port MTU *** */
1661 struct cmd_config_mtu_result {
1662 cmdline_fixed_string_t port;
1663 cmdline_fixed_string_t keyword;
1664 cmdline_fixed_string_t mtu;
1670 cmd_config_mtu_parsed(void *parsed_result,
1671 __attribute__((unused)) struct cmdline *cl,
1672 __attribute__((unused)) void *data)
1674 struct cmd_config_mtu_result *res = parsed_result;
1676 if (res->value < ETHER_MIN_LEN) {
1677 printf("mtu cannot be less than %d\n", ETHER_MIN_LEN);
1680 port_mtu_set(res->port_id, res->value);
1683 cmdline_parse_token_string_t cmd_config_mtu_port =
1684 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
1686 cmdline_parse_token_string_t cmd_config_mtu_keyword =
1687 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1689 cmdline_parse_token_string_t cmd_config_mtu_mtu =
1690 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1692 cmdline_parse_token_num_t cmd_config_mtu_port_id =
1693 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT16);
1694 cmdline_parse_token_num_t cmd_config_mtu_value =
1695 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
1697 cmdline_parse_inst_t cmd_config_mtu = {
1698 .f = cmd_config_mtu_parsed,
1700 .help_str = "port config mtu <port_id> <value>",
1702 (void *)&cmd_config_mtu_port,
1703 (void *)&cmd_config_mtu_keyword,
1704 (void *)&cmd_config_mtu_mtu,
1705 (void *)&cmd_config_mtu_port_id,
1706 (void *)&cmd_config_mtu_value,
1711 /* *** configure rx mode *** */
1712 struct cmd_config_rx_mode_flag {
1713 cmdline_fixed_string_t port;
1714 cmdline_fixed_string_t keyword;
1715 cmdline_fixed_string_t all;
1716 cmdline_fixed_string_t name;
1717 cmdline_fixed_string_t value;
1721 cmd_config_rx_mode_flag_parsed(void *parsed_result,
1722 __attribute__((unused)) struct cmdline *cl,
1723 __attribute__((unused)) void *data)
1725 struct cmd_config_rx_mode_flag *res = parsed_result;
1726 uint64_t rx_offloads = rx_mode.offloads;
1728 if (!all_ports_stopped()) {
1729 printf("Please stop all ports first\n");
1733 if (!strcmp(res->name, "crc-strip")) {
1734 if (!strcmp(res->value, "on"))
1735 rx_offloads |= DEV_RX_OFFLOAD_CRC_STRIP;
1736 else if (!strcmp(res->value, "off"))
1737 rx_offloads &= ~DEV_RX_OFFLOAD_CRC_STRIP;
1739 printf("Unknown parameter\n");
1742 } else if (!strcmp(res->name, "scatter")) {
1743 if (!strcmp(res->value, "on")) {
1744 rx_offloads |= DEV_RX_OFFLOAD_SCATTER;
1745 } else if (!strcmp(res->value, "off")) {
1746 rx_offloads &= ~DEV_RX_OFFLOAD_SCATTER;
1748 printf("Unknown parameter\n");
1751 } else if (!strcmp(res->name, "rx-cksum")) {
1752 if (!strcmp(res->value, "on"))
1753 rx_offloads |= DEV_RX_OFFLOAD_CHECKSUM;
1754 else if (!strcmp(res->value, "off"))
1755 rx_offloads &= ~DEV_RX_OFFLOAD_CHECKSUM;
1757 printf("Unknown parameter\n");
1760 } else if (!strcmp(res->name, "rx-timestamp")) {
1761 if (!strcmp(res->value, "on"))
1762 rx_offloads |= DEV_RX_OFFLOAD_TIMESTAMP;
1763 else if (!strcmp(res->value, "off"))
1764 rx_offloads &= ~DEV_RX_OFFLOAD_TIMESTAMP;
1766 printf("Unknown parameter\n");
1769 } else if (!strcmp(res->name, "hw-vlan")) {
1770 if (!strcmp(res->value, "on")) {
1771 rx_offloads |= (DEV_RX_OFFLOAD_VLAN_FILTER |
1772 DEV_RX_OFFLOAD_VLAN_STRIP);
1774 else if (!strcmp(res->value, "off")) {
1775 rx_offloads &= ~(DEV_RX_OFFLOAD_VLAN_FILTER |
1776 DEV_RX_OFFLOAD_VLAN_STRIP);
1779 printf("Unknown parameter\n");
1782 } else if (!strcmp(res->name, "hw-vlan-filter")) {
1783 if (!strcmp(res->value, "on"))
1784 rx_offloads |= DEV_RX_OFFLOAD_VLAN_FILTER;
1785 else if (!strcmp(res->value, "off"))
1786 rx_offloads &= ~DEV_RX_OFFLOAD_VLAN_FILTER;
1788 printf("Unknown parameter\n");
1791 } else if (!strcmp(res->name, "hw-vlan-strip")) {
1792 if (!strcmp(res->value, "on"))
1793 rx_offloads |= DEV_RX_OFFLOAD_VLAN_STRIP;
1794 else if (!strcmp(res->value, "off"))
1795 rx_offloads &= ~DEV_RX_OFFLOAD_VLAN_STRIP;
1797 printf("Unknown parameter\n");
1800 } else if (!strcmp(res->name, "hw-vlan-extend")) {
1801 if (!strcmp(res->value, "on"))
1802 rx_offloads |= DEV_RX_OFFLOAD_VLAN_EXTEND;
1803 else if (!strcmp(res->value, "off"))
1804 rx_offloads &= ~DEV_RX_OFFLOAD_VLAN_EXTEND;
1806 printf("Unknown parameter\n");
1809 } else if (!strcmp(res->name, "drop-en")) {
1810 if (!strcmp(res->value, "on"))
1812 else if (!strcmp(res->value, "off"))
1815 printf("Unknown parameter\n");
1819 printf("Unknown parameter\n");
1822 rx_mode.offloads = rx_offloads;
1826 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1829 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
1830 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
1831 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
1832 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
1834 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
1835 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
1836 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
1837 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
1838 "crc-strip#scatter#rx-cksum#rx-timestamp#hw-vlan#"
1839 "hw-vlan-filter#hw-vlan-strip#hw-vlan-extend");
1840 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
1841 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
1844 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
1845 .f = cmd_config_rx_mode_flag_parsed,
1847 .help_str = "port config all crc-strip|scatter|rx-cksum|rx-timestamp|hw-vlan|"
1848 "hw-vlan-filter|hw-vlan-strip|hw-vlan-extend on|off",
1850 (void *)&cmd_config_rx_mode_flag_port,
1851 (void *)&cmd_config_rx_mode_flag_keyword,
1852 (void *)&cmd_config_rx_mode_flag_all,
1853 (void *)&cmd_config_rx_mode_flag_name,
1854 (void *)&cmd_config_rx_mode_flag_value,
1859 /* *** configure rss *** */
1860 struct cmd_config_rss {
1861 cmdline_fixed_string_t port;
1862 cmdline_fixed_string_t keyword;
1863 cmdline_fixed_string_t all;
1864 cmdline_fixed_string_t name;
1865 cmdline_fixed_string_t value;
1869 cmd_config_rss_parsed(void *parsed_result,
1870 __attribute__((unused)) struct cmdline *cl,
1871 __attribute__((unused)) void *data)
1873 struct cmd_config_rss *res = parsed_result;
1874 struct rte_eth_rss_conf rss_conf = { .rss_key_len = 0, };
1878 if (!strcmp(res->value, "all"))
1879 rss_conf.rss_hf = ETH_RSS_IP | ETH_RSS_TCP |
1880 ETH_RSS_UDP | ETH_RSS_SCTP |
1882 else if (!strcmp(res->value, "ip"))
1883 rss_conf.rss_hf = ETH_RSS_IP;
1884 else if (!strcmp(res->value, "udp"))
1885 rss_conf.rss_hf = ETH_RSS_UDP;
1886 else if (!strcmp(res->value, "tcp"))
1887 rss_conf.rss_hf = ETH_RSS_TCP;
1888 else if (!strcmp(res->value, "sctp"))
1889 rss_conf.rss_hf = ETH_RSS_SCTP;
1890 else if (!strcmp(res->value, "ether"))
1891 rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD;
1892 else if (!strcmp(res->value, "port"))
1893 rss_conf.rss_hf = ETH_RSS_PORT;
1894 else if (!strcmp(res->value, "vxlan"))
1895 rss_conf.rss_hf = ETH_RSS_VXLAN;
1896 else if (!strcmp(res->value, "geneve"))
1897 rss_conf.rss_hf = ETH_RSS_GENEVE;
1898 else if (!strcmp(res->value, "nvgre"))
1899 rss_conf.rss_hf = ETH_RSS_NVGRE;
1900 else if (!strcmp(res->value, "none"))
1901 rss_conf.rss_hf = 0;
1902 else if (isdigit(res->value[0]) && atoi(res->value) > 0 &&
1903 atoi(res->value) < 64)
1904 rss_conf.rss_hf = 1ULL << atoi(res->value);
1906 printf("Unknown parameter\n");
1909 rss_conf.rss_key = NULL;
1910 for (i = 0; i < rte_eth_dev_count(); i++) {
1911 diag = rte_eth_dev_rss_hash_update(i, &rss_conf);
1913 printf("Configuration of RSS hash at ethernet port %d "
1914 "failed with error (%d): %s.\n",
1915 i, -diag, strerror(-diag));
1919 cmdline_parse_token_string_t cmd_config_rss_port =
1920 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
1921 cmdline_parse_token_string_t cmd_config_rss_keyword =
1922 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
1923 cmdline_parse_token_string_t cmd_config_rss_all =
1924 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
1925 cmdline_parse_token_string_t cmd_config_rss_name =
1926 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
1927 cmdline_parse_token_string_t cmd_config_rss_value =
1928 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, NULL);
1930 cmdline_parse_inst_t cmd_config_rss = {
1931 .f = cmd_config_rss_parsed,
1933 .help_str = "port config all rss "
1934 "all|ip|tcp|udp|sctp|ether|port|vxlan|geneve|nvgre|none|<flowtype_id>",
1936 (void *)&cmd_config_rss_port,
1937 (void *)&cmd_config_rss_keyword,
1938 (void *)&cmd_config_rss_all,
1939 (void *)&cmd_config_rss_name,
1940 (void *)&cmd_config_rss_value,
1945 /* *** configure rss hash key *** */
1946 struct cmd_config_rss_hash_key {
1947 cmdline_fixed_string_t port;
1948 cmdline_fixed_string_t config;
1950 cmdline_fixed_string_t rss_hash_key;
1951 cmdline_fixed_string_t rss_type;
1952 cmdline_fixed_string_t key;
1956 hexa_digit_to_value(char hexa_digit)
1958 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
1959 return (uint8_t) (hexa_digit - '0');
1960 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
1961 return (uint8_t) ((hexa_digit - 'a') + 10);
1962 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
1963 return (uint8_t) ((hexa_digit - 'A') + 10);
1964 /* Invalid hexa digit */
1969 parse_and_check_key_hexa_digit(char *key, int idx)
1973 hexa_v = hexa_digit_to_value(key[idx]);
1975 printf("invalid key: character %c at position %d is not a "
1976 "valid hexa digit\n", key[idx], idx);
1981 cmd_config_rss_hash_key_parsed(void *parsed_result,
1982 __attribute__((unused)) struct cmdline *cl,
1983 __attribute__((unused)) void *data)
1985 struct cmd_config_rss_hash_key *res = parsed_result;
1986 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
1990 struct rte_eth_dev_info dev_info;
1991 uint8_t hash_key_size;
1994 memset(&dev_info, 0, sizeof(dev_info));
1995 rte_eth_dev_info_get(res->port_id, &dev_info);
1996 if (dev_info.hash_key_size > 0 &&
1997 dev_info.hash_key_size <= sizeof(hash_key))
1998 hash_key_size = dev_info.hash_key_size;
2000 printf("dev_info did not provide a valid hash key size\n");
2003 /* Check the length of the RSS hash key */
2004 key_len = strlen(res->key);
2005 if (key_len != (hash_key_size * 2)) {
2006 printf("key length: %d invalid - key must be a string of %d"
2007 " hexa-decimal numbers\n",
2008 (int) key_len, hash_key_size * 2);
2011 /* Translate RSS hash key into binary representation */
2012 for (i = 0; i < hash_key_size; i++) {
2013 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
2016 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
2019 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
2021 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
2025 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
2026 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
2027 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
2028 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
2030 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
2031 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT16);
2032 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
2033 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
2034 rss_hash_key, "rss-hash-key");
2035 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
2036 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
2037 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2038 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2039 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2040 "ipv6-tcp-ex#ipv6-udp-ex");
2041 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
2042 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
2044 cmdline_parse_inst_t cmd_config_rss_hash_key = {
2045 .f = cmd_config_rss_hash_key_parsed,
2047 .help_str = "port config <port_id> rss-hash-key "
2048 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2049 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2050 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex "
2051 "<string of hex digits (variable length, NIC dependent)>",
2053 (void *)&cmd_config_rss_hash_key_port,
2054 (void *)&cmd_config_rss_hash_key_config,
2055 (void *)&cmd_config_rss_hash_key_port_id,
2056 (void *)&cmd_config_rss_hash_key_rss_hash_key,
2057 (void *)&cmd_config_rss_hash_key_rss_type,
2058 (void *)&cmd_config_rss_hash_key_value,
2063 /* *** configure port rxq/txq start/stop *** */
2064 struct cmd_config_rxtx_queue {
2065 cmdline_fixed_string_t port;
2067 cmdline_fixed_string_t rxtxq;
2069 cmdline_fixed_string_t opname;
2073 cmd_config_rxtx_queue_parsed(void *parsed_result,
2074 __attribute__((unused)) struct cmdline *cl,
2075 __attribute__((unused)) void *data)
2077 struct cmd_config_rxtx_queue *res = parsed_result;
2082 if (test_done == 0) {
2083 printf("Please stop forwarding first\n");
2087 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2090 if (port_is_started(res->portid) != 1) {
2091 printf("Please start port %u first\n", res->portid);
2095 if (!strcmp(res->rxtxq, "rxq"))
2097 else if (!strcmp(res->rxtxq, "txq"))
2100 printf("Unknown parameter\n");
2104 if (isrx && rx_queue_id_is_invalid(res->qid))
2106 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2109 if (!strcmp(res->opname, "start"))
2111 else if (!strcmp(res->opname, "stop"))
2114 printf("Unknown parameter\n");
2118 if (isstart && isrx)
2119 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
2120 else if (!isstart && isrx)
2121 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
2122 else if (isstart && !isrx)
2123 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
2125 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
2127 if (ret == -ENOTSUP)
2128 printf("Function not supported in PMD driver\n");
2131 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
2132 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
2133 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
2134 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT16);
2135 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
2136 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
2137 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
2138 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
2139 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
2140 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
2143 cmdline_parse_inst_t cmd_config_rxtx_queue = {
2144 .f = cmd_config_rxtx_queue_parsed,
2146 .help_str = "port <port_id> rxq|txq <queue_id> start|stop",
2148 (void *)&cmd_config_speed_all_port,
2149 (void *)&cmd_config_rxtx_queue_portid,
2150 (void *)&cmd_config_rxtx_queue_rxtxq,
2151 (void *)&cmd_config_rxtx_queue_qid,
2152 (void *)&cmd_config_rxtx_queue_opname,
2157 /* *** Configure RSS RETA *** */
2158 struct cmd_config_rss_reta {
2159 cmdline_fixed_string_t port;
2160 cmdline_fixed_string_t keyword;
2162 cmdline_fixed_string_t name;
2163 cmdline_fixed_string_t list_name;
2164 cmdline_fixed_string_t list_of_items;
2168 parse_reta_config(const char *str,
2169 struct rte_eth_rss_reta_entry64 *reta_conf,
2170 uint16_t nb_entries)
2174 uint16_t hash_index, idx, shift;
2177 const char *p, *p0 = str;
2184 unsigned long int_fld[_NUM_FLD];
2185 char *str_fld[_NUM_FLD];
2187 while ((p = strchr(p0,'(')) != NULL) {
2189 if((p0 = strchr(p,')')) == NULL)
2193 if(size >= sizeof(s))
2196 snprintf(s, sizeof(s), "%.*s", size, p);
2197 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
2199 for (i = 0; i < _NUM_FLD; i++) {
2201 int_fld[i] = strtoul(str_fld[i], &end, 0);
2202 if (errno != 0 || end == str_fld[i] ||
2207 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
2208 nb_queue = (uint16_t)int_fld[FLD_QUEUE];
2210 if (hash_index >= nb_entries) {
2211 printf("Invalid RETA hash index=%d\n", hash_index);
2215 idx = hash_index / RTE_RETA_GROUP_SIZE;
2216 shift = hash_index % RTE_RETA_GROUP_SIZE;
2217 reta_conf[idx].mask |= (1ULL << shift);
2218 reta_conf[idx].reta[shift] = nb_queue;
2225 cmd_set_rss_reta_parsed(void *parsed_result,
2226 __attribute__((unused)) struct cmdline *cl,
2227 __attribute__((unused)) void *data)
2230 struct rte_eth_dev_info dev_info;
2231 struct rte_eth_rss_reta_entry64 reta_conf[8];
2232 struct cmd_config_rss_reta *res = parsed_result;
2234 memset(&dev_info, 0, sizeof(dev_info));
2235 rte_eth_dev_info_get(res->port_id, &dev_info);
2236 if (dev_info.reta_size == 0) {
2237 printf("Redirection table size is 0 which is "
2238 "invalid for RSS\n");
2241 printf("The reta size of port %d is %u\n",
2242 res->port_id, dev_info.reta_size);
2243 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
2244 printf("Currently do not support more than %u entries of "
2245 "redirection table\n", ETH_RSS_RETA_SIZE_512);
2249 memset(reta_conf, 0, sizeof(reta_conf));
2250 if (!strcmp(res->list_name, "reta")) {
2251 if (parse_reta_config(res->list_of_items, reta_conf,
2252 dev_info.reta_size)) {
2253 printf("Invalid RSS Redirection Table "
2254 "config entered\n");
2257 ret = rte_eth_dev_rss_reta_update(res->port_id,
2258 reta_conf, dev_info.reta_size);
2260 printf("Bad redirection table parameter, "
2261 "return code = %d \n", ret);
2265 cmdline_parse_token_string_t cmd_config_rss_reta_port =
2266 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
2267 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
2268 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
2269 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
2270 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT16);
2271 cmdline_parse_token_string_t cmd_config_rss_reta_name =
2272 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
2273 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
2274 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
2275 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
2276 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
2278 cmdline_parse_inst_t cmd_config_rss_reta = {
2279 .f = cmd_set_rss_reta_parsed,
2281 .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
2283 (void *)&cmd_config_rss_reta_port,
2284 (void *)&cmd_config_rss_reta_keyword,
2285 (void *)&cmd_config_rss_reta_port_id,
2286 (void *)&cmd_config_rss_reta_name,
2287 (void *)&cmd_config_rss_reta_list_name,
2288 (void *)&cmd_config_rss_reta_list_of_items,
2293 /* *** SHOW PORT RETA INFO *** */
2294 struct cmd_showport_reta {
2295 cmdline_fixed_string_t show;
2296 cmdline_fixed_string_t port;
2298 cmdline_fixed_string_t rss;
2299 cmdline_fixed_string_t reta;
2301 cmdline_fixed_string_t list_of_items;
2305 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
2306 uint16_t nb_entries,
2310 const char *p, *p0 = str;
2315 uint16_t num = (nb_entries + RTE_RETA_GROUP_SIZE - 1) /
2316 RTE_RETA_GROUP_SIZE;
2319 p = strchr(p0, '(');
2323 p0 = strchr(p, ')');
2327 if (size >= sizeof(s)) {
2328 printf("The string size exceeds the internal buffer size\n");
2331 snprintf(s, sizeof(s), "%.*s", size, p);
2332 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
2333 if (ret <= 0 || ret != num) {
2334 printf("The bits of masks do not match the number of "
2335 "reta entries: %u\n", num);
2338 for (i = 0; i < ret; i++)
2339 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
2345 cmd_showport_reta_parsed(void *parsed_result,
2346 __attribute__((unused)) struct cmdline *cl,
2347 __attribute__((unused)) void *data)
2349 struct cmd_showport_reta *res = parsed_result;
2350 struct rte_eth_rss_reta_entry64 reta_conf[8];
2351 struct rte_eth_dev_info dev_info;
2352 uint16_t max_reta_size;
2354 memset(&dev_info, 0, sizeof(dev_info));
2355 rte_eth_dev_info_get(res->port_id, &dev_info);
2356 max_reta_size = RTE_MIN(dev_info.reta_size, ETH_RSS_RETA_SIZE_512);
2357 if (res->size == 0 || res->size > max_reta_size) {
2358 printf("Invalid redirection table size: %u (1-%u)\n",
2359 res->size, max_reta_size);
2363 memset(reta_conf, 0, sizeof(reta_conf));
2364 if (showport_parse_reta_config(reta_conf, res->size,
2365 res->list_of_items) < 0) {
2366 printf("Invalid string: %s for reta masks\n",
2367 res->list_of_items);
2370 port_rss_reta_info(res->port_id, reta_conf, res->size);
2373 cmdline_parse_token_string_t cmd_showport_reta_show =
2374 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
2375 cmdline_parse_token_string_t cmd_showport_reta_port =
2376 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
2377 cmdline_parse_token_num_t cmd_showport_reta_port_id =
2378 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT16);
2379 cmdline_parse_token_string_t cmd_showport_reta_rss =
2380 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
2381 cmdline_parse_token_string_t cmd_showport_reta_reta =
2382 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
2383 cmdline_parse_token_num_t cmd_showport_reta_size =
2384 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16);
2385 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
2386 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
2387 list_of_items, NULL);
2389 cmdline_parse_inst_t cmd_showport_reta = {
2390 .f = cmd_showport_reta_parsed,
2392 .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
2394 (void *)&cmd_showport_reta_show,
2395 (void *)&cmd_showport_reta_port,
2396 (void *)&cmd_showport_reta_port_id,
2397 (void *)&cmd_showport_reta_rss,
2398 (void *)&cmd_showport_reta_reta,
2399 (void *)&cmd_showport_reta_size,
2400 (void *)&cmd_showport_reta_list_of_items,
2405 /* *** Show RSS hash configuration *** */
2406 struct cmd_showport_rss_hash {
2407 cmdline_fixed_string_t show;
2408 cmdline_fixed_string_t port;
2410 cmdline_fixed_string_t rss_hash;
2411 cmdline_fixed_string_t rss_type;
2412 cmdline_fixed_string_t key; /* optional argument */
2415 static void cmd_showport_rss_hash_parsed(void *parsed_result,
2416 __attribute__((unused)) struct cmdline *cl,
2419 struct cmd_showport_rss_hash *res = parsed_result;
2421 port_rss_hash_conf_show(res->port_id, res->rss_type,
2422 show_rss_key != NULL);
2425 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
2426 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
2427 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
2428 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
2429 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
2430 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT16);
2431 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
2432 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
2434 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash_info =
2435 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_type,
2436 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2437 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2438 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2439 "ipv6-tcp-ex#ipv6-udp-ex");
2440 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
2441 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
2443 cmdline_parse_inst_t cmd_showport_rss_hash = {
2444 .f = cmd_showport_rss_hash_parsed,
2446 .help_str = "show port <port_id> rss-hash "
2447 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2448 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2449 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex",
2451 (void *)&cmd_showport_rss_hash_show,
2452 (void *)&cmd_showport_rss_hash_port,
2453 (void *)&cmd_showport_rss_hash_port_id,
2454 (void *)&cmd_showport_rss_hash_rss_hash,
2455 (void *)&cmd_showport_rss_hash_rss_hash_info,
2460 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
2461 .f = cmd_showport_rss_hash_parsed,
2463 .help_str = "show port <port_id> rss-hash "
2464 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2465 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2466 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex key",
2468 (void *)&cmd_showport_rss_hash_show,
2469 (void *)&cmd_showport_rss_hash_port,
2470 (void *)&cmd_showport_rss_hash_port_id,
2471 (void *)&cmd_showport_rss_hash_rss_hash,
2472 (void *)&cmd_showport_rss_hash_rss_hash_info,
2473 (void *)&cmd_showport_rss_hash_rss_key,
2478 /* *** Configure DCB *** */
2479 struct cmd_config_dcb {
2480 cmdline_fixed_string_t port;
2481 cmdline_fixed_string_t config;
2483 cmdline_fixed_string_t dcb;
2484 cmdline_fixed_string_t vt;
2485 cmdline_fixed_string_t vt_en;
2487 cmdline_fixed_string_t pfc;
2488 cmdline_fixed_string_t pfc_en;
2492 cmd_config_dcb_parsed(void *parsed_result,
2493 __attribute__((unused)) struct cmdline *cl,
2494 __attribute__((unused)) void *data)
2496 struct cmd_config_dcb *res = parsed_result;
2497 portid_t port_id = res->port_id;
2498 struct rte_port *port;
2502 port = &ports[port_id];
2503 /** Check if the port is not started **/
2504 if (port->port_status != RTE_PORT_STOPPED) {
2505 printf("Please stop port %d first\n", port_id);
2509 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
2510 printf("The invalid number of traffic class,"
2511 " only 4 or 8 allowed.\n");
2515 if (nb_fwd_lcores < res->num_tcs) {
2516 printf("nb_cores shouldn't be less than number of TCs.\n");
2519 if (!strncmp(res->pfc_en, "on", 2))
2524 /* DCB in VT mode */
2525 if (!strncmp(res->vt_en, "on", 2))
2526 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
2527 (enum rte_eth_nb_tcs)res->num_tcs,
2530 ret = init_port_dcb_config(port_id, DCB_ENABLED,
2531 (enum rte_eth_nb_tcs)res->num_tcs,
2536 printf("Cannot initialize network ports.\n");
2540 cmd_reconfig_device_queue(port_id, 1, 1);
2543 cmdline_parse_token_string_t cmd_config_dcb_port =
2544 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
2545 cmdline_parse_token_string_t cmd_config_dcb_config =
2546 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
2547 cmdline_parse_token_num_t cmd_config_dcb_port_id =
2548 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT16);
2549 cmdline_parse_token_string_t cmd_config_dcb_dcb =
2550 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
2551 cmdline_parse_token_string_t cmd_config_dcb_vt =
2552 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
2553 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
2554 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
2555 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
2556 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
2557 cmdline_parse_token_string_t cmd_config_dcb_pfc=
2558 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
2559 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
2560 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
2562 cmdline_parse_inst_t cmd_config_dcb = {
2563 .f = cmd_config_dcb_parsed,
2565 .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
2567 (void *)&cmd_config_dcb_port,
2568 (void *)&cmd_config_dcb_config,
2569 (void *)&cmd_config_dcb_port_id,
2570 (void *)&cmd_config_dcb_dcb,
2571 (void *)&cmd_config_dcb_vt,
2572 (void *)&cmd_config_dcb_vt_en,
2573 (void *)&cmd_config_dcb_num_tcs,
2574 (void *)&cmd_config_dcb_pfc,
2575 (void *)&cmd_config_dcb_pfc_en,
2580 /* *** configure number of packets per burst *** */
2581 struct cmd_config_burst {
2582 cmdline_fixed_string_t port;
2583 cmdline_fixed_string_t keyword;
2584 cmdline_fixed_string_t all;
2585 cmdline_fixed_string_t name;
2590 cmd_config_burst_parsed(void *parsed_result,
2591 __attribute__((unused)) struct cmdline *cl,
2592 __attribute__((unused)) void *data)
2594 struct cmd_config_burst *res = parsed_result;
2596 if (!all_ports_stopped()) {
2597 printf("Please stop all ports first\n");
2601 if (!strcmp(res->name, "burst")) {
2602 if (res->value < 1 || res->value > MAX_PKT_BURST) {
2603 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
2606 nb_pkt_per_burst = res->value;
2608 printf("Unknown parameter\n");
2614 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2617 cmdline_parse_token_string_t cmd_config_burst_port =
2618 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
2619 cmdline_parse_token_string_t cmd_config_burst_keyword =
2620 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
2621 cmdline_parse_token_string_t cmd_config_burst_all =
2622 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
2623 cmdline_parse_token_string_t cmd_config_burst_name =
2624 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
2625 cmdline_parse_token_num_t cmd_config_burst_value =
2626 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
2628 cmdline_parse_inst_t cmd_config_burst = {
2629 .f = cmd_config_burst_parsed,
2631 .help_str = "port config all burst <value>",
2633 (void *)&cmd_config_burst_port,
2634 (void *)&cmd_config_burst_keyword,
2635 (void *)&cmd_config_burst_all,
2636 (void *)&cmd_config_burst_name,
2637 (void *)&cmd_config_burst_value,
2642 /* *** configure rx/tx queues *** */
2643 struct cmd_config_thresh {
2644 cmdline_fixed_string_t port;
2645 cmdline_fixed_string_t keyword;
2646 cmdline_fixed_string_t all;
2647 cmdline_fixed_string_t name;
2652 cmd_config_thresh_parsed(void *parsed_result,
2653 __attribute__((unused)) struct cmdline *cl,
2654 __attribute__((unused)) void *data)
2656 struct cmd_config_thresh *res = parsed_result;
2658 if (!all_ports_stopped()) {
2659 printf("Please stop all ports first\n");
2663 if (!strcmp(res->name, "txpt"))
2664 tx_pthresh = res->value;
2665 else if(!strcmp(res->name, "txht"))
2666 tx_hthresh = res->value;
2667 else if(!strcmp(res->name, "txwt"))
2668 tx_wthresh = res->value;
2669 else if(!strcmp(res->name, "rxpt"))
2670 rx_pthresh = res->value;
2671 else if(!strcmp(res->name, "rxht"))
2672 rx_hthresh = res->value;
2673 else if(!strcmp(res->name, "rxwt"))
2674 rx_wthresh = res->value;
2676 printf("Unknown parameter\n");
2682 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2685 cmdline_parse_token_string_t cmd_config_thresh_port =
2686 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
2687 cmdline_parse_token_string_t cmd_config_thresh_keyword =
2688 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
2689 cmdline_parse_token_string_t cmd_config_thresh_all =
2690 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
2691 cmdline_parse_token_string_t cmd_config_thresh_name =
2692 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
2693 "txpt#txht#txwt#rxpt#rxht#rxwt");
2694 cmdline_parse_token_num_t cmd_config_thresh_value =
2695 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
2697 cmdline_parse_inst_t cmd_config_thresh = {
2698 .f = cmd_config_thresh_parsed,
2700 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
2702 (void *)&cmd_config_thresh_port,
2703 (void *)&cmd_config_thresh_keyword,
2704 (void *)&cmd_config_thresh_all,
2705 (void *)&cmd_config_thresh_name,
2706 (void *)&cmd_config_thresh_value,
2711 /* *** configure free/rs threshold *** */
2712 struct cmd_config_threshold {
2713 cmdline_fixed_string_t port;
2714 cmdline_fixed_string_t keyword;
2715 cmdline_fixed_string_t all;
2716 cmdline_fixed_string_t name;
2721 cmd_config_threshold_parsed(void *parsed_result,
2722 __attribute__((unused)) struct cmdline *cl,
2723 __attribute__((unused)) void *data)
2725 struct cmd_config_threshold *res = parsed_result;
2727 if (!all_ports_stopped()) {
2728 printf("Please stop all ports first\n");
2732 if (!strcmp(res->name, "txfreet"))
2733 tx_free_thresh = res->value;
2734 else if (!strcmp(res->name, "txrst"))
2735 tx_rs_thresh = res->value;
2736 else if (!strcmp(res->name, "rxfreet"))
2737 rx_free_thresh = res->value;
2739 printf("Unknown parameter\n");
2745 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2748 cmdline_parse_token_string_t cmd_config_threshold_port =
2749 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
2750 cmdline_parse_token_string_t cmd_config_threshold_keyword =
2751 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
2753 cmdline_parse_token_string_t cmd_config_threshold_all =
2754 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
2755 cmdline_parse_token_string_t cmd_config_threshold_name =
2756 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
2757 "txfreet#txrst#rxfreet");
2758 cmdline_parse_token_num_t cmd_config_threshold_value =
2759 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
2761 cmdline_parse_inst_t cmd_config_threshold = {
2762 .f = cmd_config_threshold_parsed,
2764 .help_str = "port config all txfreet|txrst|rxfreet <value>",
2766 (void *)&cmd_config_threshold_port,
2767 (void *)&cmd_config_threshold_keyword,
2768 (void *)&cmd_config_threshold_all,
2769 (void *)&cmd_config_threshold_name,
2770 (void *)&cmd_config_threshold_value,
2776 struct cmd_stop_result {
2777 cmdline_fixed_string_t stop;
2780 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
2781 __attribute__((unused)) struct cmdline *cl,
2782 __attribute__((unused)) void *data)
2784 stop_packet_forwarding();
2787 cmdline_parse_token_string_t cmd_stop_stop =
2788 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
2790 cmdline_parse_inst_t cmd_stop = {
2791 .f = cmd_stop_parsed,
2793 .help_str = "stop: Stop packet forwarding",
2795 (void *)&cmd_stop_stop,
2800 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
2803 parse_item_list(char* str, const char* item_name, unsigned int max_items,
2804 unsigned int *parsed_items, int check_unique_values)
2806 unsigned int nb_item;
2814 * First parse all items in the list and store their value.
2819 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
2821 if ((c >= '0') && (c <= '9')) {
2822 value = (unsigned int) (value * 10 + (c - '0'));
2827 printf("character %c is not a decimal digit\n", c);
2831 printf("No valid value before comma\n");
2834 if (nb_item < max_items) {
2835 parsed_items[nb_item] = value;
2841 if (nb_item >= max_items) {
2842 printf("Number of %s = %u > %u (maximum items)\n",
2843 item_name, nb_item + 1, max_items);
2846 parsed_items[nb_item++] = value;
2847 if (! check_unique_values)
2851 * Then, check that all values in the list are differents.
2852 * No optimization here...
2854 for (i = 0; i < nb_item; i++) {
2855 for (j = i + 1; j < nb_item; j++) {
2856 if (parsed_items[j] == parsed_items[i]) {
2857 printf("duplicated %s %u at index %u and %u\n",
2858 item_name, parsed_items[i], i, j);
2866 struct cmd_set_list_result {
2867 cmdline_fixed_string_t cmd_keyword;
2868 cmdline_fixed_string_t list_name;
2869 cmdline_fixed_string_t list_of_items;
2872 static void cmd_set_list_parsed(void *parsed_result,
2873 __attribute__((unused)) struct cmdline *cl,
2874 __attribute__((unused)) void *data)
2876 struct cmd_set_list_result *res;
2878 unsigned int lcorelist[RTE_MAX_LCORE];
2879 unsigned int portlist[RTE_MAX_ETHPORTS];
2881 unsigned int nb_item;
2883 if (test_done == 0) {
2884 printf("Please stop forwarding first\n");
2888 res = parsed_result;
2889 if (!strcmp(res->list_name, "corelist")) {
2890 nb_item = parse_item_list(res->list_of_items, "core",
2892 parsed_items.lcorelist, 1);
2894 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
2899 if (!strcmp(res->list_name, "portlist")) {
2900 nb_item = parse_item_list(res->list_of_items, "port",
2902 parsed_items.portlist, 1);
2904 set_fwd_ports_list(parsed_items.portlist, nb_item);
2910 cmdline_parse_token_string_t cmd_set_list_keyword =
2911 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
2913 cmdline_parse_token_string_t cmd_set_list_name =
2914 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
2915 "corelist#portlist");
2916 cmdline_parse_token_string_t cmd_set_list_of_items =
2917 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
2920 cmdline_parse_inst_t cmd_set_fwd_list = {
2921 .f = cmd_set_list_parsed,
2923 .help_str = "set corelist|portlist <list0[,list1]*>",
2925 (void *)&cmd_set_list_keyword,
2926 (void *)&cmd_set_list_name,
2927 (void *)&cmd_set_list_of_items,
2932 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
2934 struct cmd_setmask_result {
2935 cmdline_fixed_string_t set;
2936 cmdline_fixed_string_t mask;
2940 static void cmd_set_mask_parsed(void *parsed_result,
2941 __attribute__((unused)) struct cmdline *cl,
2942 __attribute__((unused)) void *data)
2944 struct cmd_setmask_result *res = parsed_result;
2946 if (test_done == 0) {
2947 printf("Please stop forwarding first\n");
2950 if (!strcmp(res->mask, "coremask")) {
2951 set_fwd_lcores_mask(res->hexavalue);
2953 } else if (!strcmp(res->mask, "portmask")) {
2954 set_fwd_ports_mask(res->hexavalue);
2959 cmdline_parse_token_string_t cmd_setmask_set =
2960 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
2961 cmdline_parse_token_string_t cmd_setmask_mask =
2962 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
2963 "coremask#portmask");
2964 cmdline_parse_token_num_t cmd_setmask_value =
2965 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
2967 cmdline_parse_inst_t cmd_set_fwd_mask = {
2968 .f = cmd_set_mask_parsed,
2970 .help_str = "set coremask|portmask <hexadecimal value>",
2972 (void *)&cmd_setmask_set,
2973 (void *)&cmd_setmask_mask,
2974 (void *)&cmd_setmask_value,
2980 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
2982 struct cmd_set_result {
2983 cmdline_fixed_string_t set;
2984 cmdline_fixed_string_t what;
2988 static void cmd_set_parsed(void *parsed_result,
2989 __attribute__((unused)) struct cmdline *cl,
2990 __attribute__((unused)) void *data)
2992 struct cmd_set_result *res = parsed_result;
2993 if (!strcmp(res->what, "nbport")) {
2994 set_fwd_ports_number(res->value);
2996 } else if (!strcmp(res->what, "nbcore")) {
2997 set_fwd_lcores_number(res->value);
2999 } else if (!strcmp(res->what, "burst"))
3000 set_nb_pkt_per_burst(res->value);
3001 else if (!strcmp(res->what, "verbose"))
3002 set_verbose_level(res->value);
3005 cmdline_parse_token_string_t cmd_set_set =
3006 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
3007 cmdline_parse_token_string_t cmd_set_what =
3008 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
3009 "nbport#nbcore#burst#verbose");
3010 cmdline_parse_token_num_t cmd_set_value =
3011 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
3013 cmdline_parse_inst_t cmd_set_numbers = {
3014 .f = cmd_set_parsed,
3016 .help_str = "set nbport|nbcore|burst|verbose <value>",
3018 (void *)&cmd_set_set,
3019 (void *)&cmd_set_what,
3020 (void *)&cmd_set_value,
3025 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
3027 struct cmd_set_txpkts_result {
3028 cmdline_fixed_string_t cmd_keyword;
3029 cmdline_fixed_string_t txpkts;
3030 cmdline_fixed_string_t seg_lengths;
3034 cmd_set_txpkts_parsed(void *parsed_result,
3035 __attribute__((unused)) struct cmdline *cl,
3036 __attribute__((unused)) void *data)
3038 struct cmd_set_txpkts_result *res;
3039 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
3040 unsigned int nb_segs;
3042 res = parsed_result;
3043 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
3044 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
3046 set_tx_pkt_segments(seg_lengths, nb_segs);
3049 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
3050 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3051 cmd_keyword, "set");
3052 cmdline_parse_token_string_t cmd_set_txpkts_name =
3053 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3055 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
3056 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3059 cmdline_parse_inst_t cmd_set_txpkts = {
3060 .f = cmd_set_txpkts_parsed,
3062 .help_str = "set txpkts <len0[,len1]*>",
3064 (void *)&cmd_set_txpkts_keyword,
3065 (void *)&cmd_set_txpkts_name,
3066 (void *)&cmd_set_txpkts_lengths,
3071 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
3073 struct cmd_set_txsplit_result {
3074 cmdline_fixed_string_t cmd_keyword;
3075 cmdline_fixed_string_t txsplit;
3076 cmdline_fixed_string_t mode;
3080 cmd_set_txsplit_parsed(void *parsed_result,
3081 __attribute__((unused)) struct cmdline *cl,
3082 __attribute__((unused)) void *data)
3084 struct cmd_set_txsplit_result *res;
3086 res = parsed_result;
3087 set_tx_pkt_split(res->mode);
3090 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
3091 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3092 cmd_keyword, "set");
3093 cmdline_parse_token_string_t cmd_set_txsplit_name =
3094 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3095 txsplit, "txsplit");
3096 cmdline_parse_token_string_t cmd_set_txsplit_mode =
3097 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3100 cmdline_parse_inst_t cmd_set_txsplit = {
3101 .f = cmd_set_txsplit_parsed,
3103 .help_str = "set txsplit on|off|rand",
3105 (void *)&cmd_set_txsplit_keyword,
3106 (void *)&cmd_set_txsplit_name,
3107 (void *)&cmd_set_txsplit_mode,
3112 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
3113 struct cmd_rx_vlan_filter_all_result {
3114 cmdline_fixed_string_t rx_vlan;
3115 cmdline_fixed_string_t what;
3116 cmdline_fixed_string_t all;
3121 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
3122 __attribute__((unused)) struct cmdline *cl,
3123 __attribute__((unused)) void *data)
3125 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
3127 if (!strcmp(res->what, "add"))
3128 rx_vlan_all_filter_set(res->port_id, 1);
3130 rx_vlan_all_filter_set(res->port_id, 0);
3133 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
3134 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3135 rx_vlan, "rx_vlan");
3136 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
3137 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3139 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
3140 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3142 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
3143 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3146 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
3147 .f = cmd_rx_vlan_filter_all_parsed,
3149 .help_str = "rx_vlan add|rm all <port_id>: "
3150 "Add/Remove all identifiers to/from the set of VLAN "
3151 "identifiers filtered by a port",
3153 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
3154 (void *)&cmd_rx_vlan_filter_all_what,
3155 (void *)&cmd_rx_vlan_filter_all_all,
3156 (void *)&cmd_rx_vlan_filter_all_portid,
3161 /* *** VLAN OFFLOAD SET ON A PORT *** */
3162 struct cmd_vlan_offload_result {
3163 cmdline_fixed_string_t vlan;
3164 cmdline_fixed_string_t set;
3165 cmdline_fixed_string_t vlan_type;
3166 cmdline_fixed_string_t what;
3167 cmdline_fixed_string_t on;
3168 cmdline_fixed_string_t port_id;
3172 cmd_vlan_offload_parsed(void *parsed_result,
3173 __attribute__((unused)) struct cmdline *cl,
3174 __attribute__((unused)) void *data)
3177 struct cmd_vlan_offload_result *res = parsed_result;
3180 portid_t port_id = 0;
3184 len = strnlen(str, STR_TOKEN_SIZE);
3186 /* Get port_id first */
3194 tmp = strtoul(str, NULL, 0);
3195 /* If port_id greater that what portid_t can represent, return */
3196 if(tmp >= RTE_MAX_ETHPORTS)
3198 port_id = (portid_t)tmp;
3200 if (!strcmp(res->on, "on"))
3205 if (!strcmp(res->what, "strip"))
3206 rx_vlan_strip_set(port_id, on);
3207 else if(!strcmp(res->what, "stripq")){
3208 uint16_t queue_id = 0;
3210 /* No queue_id, return */
3212 printf("must specify (port,queue_id)\n");
3215 tmp = strtoul(str + i + 1, NULL, 0);
3216 /* If queue_id greater that what 16-bits can represent, return */
3220 queue_id = (uint16_t)tmp;
3221 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
3223 else if (!strcmp(res->what, "filter"))
3224 rx_vlan_filter_set(port_id, on);
3226 vlan_extend_set(port_id, on);
3231 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
3232 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3234 cmdline_parse_token_string_t cmd_vlan_offload_set =
3235 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3237 cmdline_parse_token_string_t cmd_vlan_offload_what =
3238 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3239 what, "strip#filter#qinq#stripq");
3240 cmdline_parse_token_string_t cmd_vlan_offload_on =
3241 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3243 cmdline_parse_token_string_t cmd_vlan_offload_portid =
3244 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3247 cmdline_parse_inst_t cmd_vlan_offload = {
3248 .f = cmd_vlan_offload_parsed,
3250 .help_str = "vlan set strip|filter|qinq|stripq on|off "
3251 "<port_id[,queue_id]>: "
3252 "Filter/Strip for rx side qinq(extended) for both rx/tx sides",
3254 (void *)&cmd_vlan_offload_vlan,
3255 (void *)&cmd_vlan_offload_set,
3256 (void *)&cmd_vlan_offload_what,
3257 (void *)&cmd_vlan_offload_on,
3258 (void *)&cmd_vlan_offload_portid,
3263 /* *** VLAN TPID SET ON A PORT *** */
3264 struct cmd_vlan_tpid_result {
3265 cmdline_fixed_string_t vlan;
3266 cmdline_fixed_string_t set;
3267 cmdline_fixed_string_t vlan_type;
3268 cmdline_fixed_string_t what;
3274 cmd_vlan_tpid_parsed(void *parsed_result,
3275 __attribute__((unused)) struct cmdline *cl,
3276 __attribute__((unused)) void *data)
3278 struct cmd_vlan_tpid_result *res = parsed_result;
3279 enum rte_vlan_type vlan_type;
3281 if (!strcmp(res->vlan_type, "inner"))
3282 vlan_type = ETH_VLAN_TYPE_INNER;
3283 else if (!strcmp(res->vlan_type, "outer"))
3284 vlan_type = ETH_VLAN_TYPE_OUTER;
3286 printf("Unknown vlan type\n");
3289 vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
3292 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
3293 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3295 cmdline_parse_token_string_t cmd_vlan_tpid_set =
3296 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3298 cmdline_parse_token_string_t cmd_vlan_type =
3299 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3300 vlan_type, "inner#outer");
3301 cmdline_parse_token_string_t cmd_vlan_tpid_what =
3302 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3304 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
3305 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3307 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
3308 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3311 cmdline_parse_inst_t cmd_vlan_tpid = {
3312 .f = cmd_vlan_tpid_parsed,
3314 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
3315 "Set the VLAN Ether type",
3317 (void *)&cmd_vlan_tpid_vlan,
3318 (void *)&cmd_vlan_tpid_set,
3319 (void *)&cmd_vlan_type,
3320 (void *)&cmd_vlan_tpid_what,
3321 (void *)&cmd_vlan_tpid_tpid,
3322 (void *)&cmd_vlan_tpid_portid,
3327 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
3328 struct cmd_rx_vlan_filter_result {
3329 cmdline_fixed_string_t rx_vlan;
3330 cmdline_fixed_string_t what;
3336 cmd_rx_vlan_filter_parsed(void *parsed_result,
3337 __attribute__((unused)) struct cmdline *cl,
3338 __attribute__((unused)) void *data)
3340 struct cmd_rx_vlan_filter_result *res = parsed_result;
3342 if (!strcmp(res->what, "add"))
3343 rx_vft_set(res->port_id, res->vlan_id, 1);
3345 rx_vft_set(res->port_id, res->vlan_id, 0);
3348 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
3349 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3350 rx_vlan, "rx_vlan");
3351 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
3352 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3354 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
3355 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3357 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
3358 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3361 cmdline_parse_inst_t cmd_rx_vlan_filter = {
3362 .f = cmd_rx_vlan_filter_parsed,
3364 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
3365 "Add/Remove a VLAN identifier to/from the set of VLAN "
3366 "identifiers filtered by a port",
3368 (void *)&cmd_rx_vlan_filter_rx_vlan,
3369 (void *)&cmd_rx_vlan_filter_what,
3370 (void *)&cmd_rx_vlan_filter_vlanid,
3371 (void *)&cmd_rx_vlan_filter_portid,
3376 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3377 struct cmd_tx_vlan_set_result {
3378 cmdline_fixed_string_t tx_vlan;
3379 cmdline_fixed_string_t set;
3385 cmd_tx_vlan_set_parsed(void *parsed_result,
3386 __attribute__((unused)) struct cmdline *cl,
3387 __attribute__((unused)) void *data)
3389 struct cmd_tx_vlan_set_result *res = parsed_result;
3391 if (!port_is_stopped(res->port_id)) {
3392 printf("Please stop port %d first\n", res->port_id);
3396 tx_vlan_set(res->port_id, res->vlan_id);
3398 cmd_reconfig_device_queue(res->port_id, 1, 1);
3401 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
3402 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3403 tx_vlan, "tx_vlan");
3404 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
3405 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3407 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
3408 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3410 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
3411 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3414 cmdline_parse_inst_t cmd_tx_vlan_set = {
3415 .f = cmd_tx_vlan_set_parsed,
3417 .help_str = "tx_vlan set <port_id> <vlan_id>: "
3418 "Enable hardware insertion of a single VLAN header "
3419 "with a given TAG Identifier in packets sent on a port",
3421 (void *)&cmd_tx_vlan_set_tx_vlan,
3422 (void *)&cmd_tx_vlan_set_set,
3423 (void *)&cmd_tx_vlan_set_portid,
3424 (void *)&cmd_tx_vlan_set_vlanid,
3429 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
3430 struct cmd_tx_vlan_set_qinq_result {
3431 cmdline_fixed_string_t tx_vlan;
3432 cmdline_fixed_string_t set;
3435 uint16_t vlan_id_outer;
3439 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
3440 __attribute__((unused)) struct cmdline *cl,
3441 __attribute__((unused)) void *data)
3443 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
3445 if (!port_is_stopped(res->port_id)) {
3446 printf("Please stop port %d first\n", res->port_id);
3450 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
3452 cmd_reconfig_device_queue(res->port_id, 1, 1);
3455 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
3456 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3457 tx_vlan, "tx_vlan");
3458 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
3459 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3461 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
3462 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3464 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
3465 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3467 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
3468 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3469 vlan_id_outer, UINT16);
3471 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
3472 .f = cmd_tx_vlan_set_qinq_parsed,
3474 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
3475 "Enable hardware insertion of double VLAN header "
3476 "with given TAG Identifiers in packets sent on a port",
3478 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
3479 (void *)&cmd_tx_vlan_set_qinq_set,
3480 (void *)&cmd_tx_vlan_set_qinq_portid,
3481 (void *)&cmd_tx_vlan_set_qinq_vlanid,
3482 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
3487 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
3488 struct cmd_tx_vlan_set_pvid_result {
3489 cmdline_fixed_string_t tx_vlan;
3490 cmdline_fixed_string_t set;
3491 cmdline_fixed_string_t pvid;
3494 cmdline_fixed_string_t mode;
3498 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
3499 __attribute__((unused)) struct cmdline *cl,
3500 __attribute__((unused)) void *data)
3502 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
3504 if (strcmp(res->mode, "on") == 0)
3505 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
3507 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
3510 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
3511 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3512 tx_vlan, "tx_vlan");
3513 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
3514 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3516 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
3517 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3519 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
3520 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3522 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
3523 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3525 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
3526 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3529 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
3530 .f = cmd_tx_vlan_set_pvid_parsed,
3532 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
3534 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
3535 (void *)&cmd_tx_vlan_set_pvid_set,
3536 (void *)&cmd_tx_vlan_set_pvid_pvid,
3537 (void *)&cmd_tx_vlan_set_pvid_port_id,
3538 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
3539 (void *)&cmd_tx_vlan_set_pvid_mode,
3544 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3545 struct cmd_tx_vlan_reset_result {
3546 cmdline_fixed_string_t tx_vlan;
3547 cmdline_fixed_string_t reset;
3552 cmd_tx_vlan_reset_parsed(void *parsed_result,
3553 __attribute__((unused)) struct cmdline *cl,
3554 __attribute__((unused)) void *data)
3556 struct cmd_tx_vlan_reset_result *res = parsed_result;
3558 if (!port_is_stopped(res->port_id)) {
3559 printf("Please stop port %d first\n", res->port_id);
3563 tx_vlan_reset(res->port_id);
3565 cmd_reconfig_device_queue(res->port_id, 1, 1);
3568 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
3569 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
3570 tx_vlan, "tx_vlan");
3571 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
3572 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
3574 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
3575 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
3578 cmdline_parse_inst_t cmd_tx_vlan_reset = {
3579 .f = cmd_tx_vlan_reset_parsed,
3581 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
3582 "VLAN header in packets sent on a port",
3584 (void *)&cmd_tx_vlan_reset_tx_vlan,
3585 (void *)&cmd_tx_vlan_reset_reset,
3586 (void *)&cmd_tx_vlan_reset_portid,
3592 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
3593 struct cmd_csum_result {
3594 cmdline_fixed_string_t csum;
3595 cmdline_fixed_string_t mode;
3596 cmdline_fixed_string_t proto;
3597 cmdline_fixed_string_t hwsw;
3602 csum_show(int port_id)
3604 struct rte_eth_dev_info dev_info;
3605 uint64_t tx_offloads;
3607 tx_offloads = ports[port_id].dev_conf.txmode.offloads;
3608 printf("Parse tunnel is %s\n",
3609 (ports[port_id].parse_tunnel) ? "on" : "off");
3610 printf("IP checksum offload is %s\n",
3611 (tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) ? "hw" : "sw");
3612 printf("UDP checksum offload is %s\n",
3613 (tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
3614 printf("TCP checksum offload is %s\n",
3615 (tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
3616 printf("SCTP checksum offload is %s\n",
3617 (tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
3618 printf("Outer-Ip checksum offload is %s\n",
3619 (tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) ? "hw" : "sw");
3621 /* display warnings if configuration is not supported by the NIC */
3622 rte_eth_dev_info_get(port_id, &dev_info);
3623 if ((tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) &&
3624 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
3625 printf("Warning: hardware IP checksum enabled but not "
3626 "supported by port %d\n", port_id);
3628 if ((tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) &&
3629 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
3630 printf("Warning: hardware UDP checksum enabled but not "
3631 "supported by port %d\n", port_id);
3633 if ((tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) &&
3634 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
3635 printf("Warning: hardware TCP checksum enabled but not "
3636 "supported by port %d\n", port_id);
3638 if ((tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) &&
3639 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
3640 printf("Warning: hardware SCTP checksum enabled but not "
3641 "supported by port %d\n", port_id);
3643 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) &&
3644 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
3645 printf("Warning: hardware outer IP checksum enabled but not "
3646 "supported by port %d\n", port_id);
3651 cmd_csum_parsed(void *parsed_result,
3652 __attribute__((unused)) struct cmdline *cl,
3653 __attribute__((unused)) void *data)
3655 struct cmd_csum_result *res = parsed_result;
3657 uint64_t csum_offloads = 0;
3658 struct rte_eth_dev_info dev_info;
3660 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
3661 printf("invalid port %d\n", res->port_id);
3664 if (!port_is_stopped(res->port_id)) {
3665 printf("Please stop port %d first\n", res->port_id);
3669 rte_eth_dev_info_get(res->port_id, &dev_info);
3670 if (!strcmp(res->mode, "set")) {
3672 if (!strcmp(res->hwsw, "hw"))
3675 if (!strcmp(res->proto, "ip")) {
3676 if (dev_info.tx_offload_capa &
3677 DEV_TX_OFFLOAD_IPV4_CKSUM) {
3678 csum_offloads |= DEV_TX_OFFLOAD_IPV4_CKSUM;
3680 printf("IP checksum offload is not supported "
3681 "by port %u\n", res->port_id);
3683 } else if (!strcmp(res->proto, "udp")) {
3684 if (dev_info.tx_offload_capa &
3685 DEV_TX_OFFLOAD_UDP_CKSUM) {
3686 csum_offloads |= DEV_TX_OFFLOAD_UDP_CKSUM;
3688 printf("UDP checksum offload is not supported "
3689 "by port %u\n", res->port_id);
3691 } else if (!strcmp(res->proto, "tcp")) {
3692 if (dev_info.tx_offload_capa &
3693 DEV_TX_OFFLOAD_TCP_CKSUM) {
3694 csum_offloads |= DEV_TX_OFFLOAD_TCP_CKSUM;
3696 printf("TCP checksum offload is not supported "
3697 "by port %u\n", res->port_id);
3699 } else if (!strcmp(res->proto, "sctp")) {
3700 if (dev_info.tx_offload_capa &
3701 DEV_TX_OFFLOAD_SCTP_CKSUM) {
3702 csum_offloads |= DEV_TX_OFFLOAD_SCTP_CKSUM;
3704 printf("SCTP checksum offload is not supported "
3705 "by port %u\n", res->port_id);
3707 } else if (!strcmp(res->proto, "outer-ip")) {
3708 if (dev_info.tx_offload_capa &
3709 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) {
3711 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM;
3713 printf("Outer IP checksum offload is not "
3714 "supported by port %u\n", res->port_id);
3719 ports[res->port_id].dev_conf.txmode.offloads |=
3722 ports[res->port_id].dev_conf.txmode.offloads &=
3726 csum_show(res->port_id);
3728 cmd_reconfig_device_queue(res->port_id, 1, 1);
3731 cmdline_parse_token_string_t cmd_csum_csum =
3732 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3734 cmdline_parse_token_string_t cmd_csum_mode =
3735 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3737 cmdline_parse_token_string_t cmd_csum_proto =
3738 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3739 proto, "ip#tcp#udp#sctp#outer-ip");
3740 cmdline_parse_token_string_t cmd_csum_hwsw =
3741 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3743 cmdline_parse_token_num_t cmd_csum_portid =
3744 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
3747 cmdline_parse_inst_t cmd_csum_set = {
3748 .f = cmd_csum_parsed,
3750 .help_str = "csum set ip|tcp|udp|sctp|outer-ip hw|sw <port_id>: "
3751 "Enable/Disable hardware calculation of L3/L4 checksum when "
3752 "using csum forward engine",
3754 (void *)&cmd_csum_csum,
3755 (void *)&cmd_csum_mode,
3756 (void *)&cmd_csum_proto,
3757 (void *)&cmd_csum_hwsw,
3758 (void *)&cmd_csum_portid,
3763 cmdline_parse_token_string_t cmd_csum_mode_show =
3764 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
3767 cmdline_parse_inst_t cmd_csum_show = {
3768 .f = cmd_csum_parsed,
3770 .help_str = "csum show <port_id>: Show checksum offload configuration",
3772 (void *)&cmd_csum_csum,
3773 (void *)&cmd_csum_mode_show,
3774 (void *)&cmd_csum_portid,
3779 /* Enable/disable tunnel parsing */
3780 struct cmd_csum_tunnel_result {
3781 cmdline_fixed_string_t csum;
3782 cmdline_fixed_string_t parse;
3783 cmdline_fixed_string_t onoff;
3788 cmd_csum_tunnel_parsed(void *parsed_result,
3789 __attribute__((unused)) struct cmdline *cl,
3790 __attribute__((unused)) void *data)
3792 struct cmd_csum_tunnel_result *res = parsed_result;
3794 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3797 if (!strcmp(res->onoff, "on"))
3798 ports[res->port_id].parse_tunnel = 1;
3800 ports[res->port_id].parse_tunnel = 0;
3802 csum_show(res->port_id);
3805 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
3806 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3808 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
3809 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3810 parse, "parse_tunnel");
3811 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
3812 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
3814 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
3815 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
3818 cmdline_parse_inst_t cmd_csum_tunnel = {
3819 .f = cmd_csum_tunnel_parsed,
3821 .help_str = "csum parse_tunnel on|off <port_id>: "
3822 "Enable/Disable parsing of tunnels for csum engine",
3824 (void *)&cmd_csum_tunnel_csum,
3825 (void *)&cmd_csum_tunnel_parse,
3826 (void *)&cmd_csum_tunnel_onoff,
3827 (void *)&cmd_csum_tunnel_portid,
3832 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
3833 struct cmd_tso_set_result {
3834 cmdline_fixed_string_t tso;
3835 cmdline_fixed_string_t mode;
3841 cmd_tso_set_parsed(void *parsed_result,
3842 __attribute__((unused)) struct cmdline *cl,
3843 __attribute__((unused)) void *data)
3845 struct cmd_tso_set_result *res = parsed_result;
3846 struct rte_eth_dev_info dev_info;
3848 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3850 if (!port_is_stopped(res->port_id)) {
3851 printf("Please stop port %d first\n", res->port_id);
3855 if (!strcmp(res->mode, "set"))
3856 ports[res->port_id].tso_segsz = res->tso_segsz;
3858 rte_eth_dev_info_get(res->port_id, &dev_info);
3859 if ((ports[res->port_id].tso_segsz != 0) &&
3860 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
3861 printf("Error: TSO is not supported by port %d\n",
3866 if (ports[res->port_id].tso_segsz == 0) {
3867 ports[res->port_id].dev_conf.txmode.offloads &=
3868 ~DEV_TX_OFFLOAD_TCP_TSO;
3869 printf("TSO for non-tunneled packets is disabled\n");
3871 ports[res->port_id].dev_conf.txmode.offloads |=
3872 DEV_TX_OFFLOAD_TCP_TSO;
3873 printf("TSO segment size for non-tunneled packets is %d\n",
3874 ports[res->port_id].tso_segsz);
3877 /* display warnings if configuration is not supported by the NIC */
3878 rte_eth_dev_info_get(res->port_id, &dev_info);
3879 if ((ports[res->port_id].tso_segsz != 0) &&
3880 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
3881 printf("Warning: TSO enabled but not "
3882 "supported by port %d\n", res->port_id);
3885 cmd_reconfig_device_queue(res->port_id, 1, 1);
3888 cmdline_parse_token_string_t cmd_tso_set_tso =
3889 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3891 cmdline_parse_token_string_t cmd_tso_set_mode =
3892 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3894 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
3895 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3897 cmdline_parse_token_num_t cmd_tso_set_portid =
3898 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
3901 cmdline_parse_inst_t cmd_tso_set = {
3902 .f = cmd_tso_set_parsed,
3904 .help_str = "tso set <tso_segsz> <port_id>: "
3905 "Set TSO segment size of non-tunneled packets for csum engine "
3908 (void *)&cmd_tso_set_tso,
3909 (void *)&cmd_tso_set_mode,
3910 (void *)&cmd_tso_set_tso_segsz,
3911 (void *)&cmd_tso_set_portid,
3916 cmdline_parse_token_string_t cmd_tso_show_mode =
3917 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
3921 cmdline_parse_inst_t cmd_tso_show = {
3922 .f = cmd_tso_set_parsed,
3924 .help_str = "tso show <port_id>: "
3925 "Show TSO segment size of non-tunneled packets for csum engine",
3927 (void *)&cmd_tso_set_tso,
3928 (void *)&cmd_tso_show_mode,
3929 (void *)&cmd_tso_set_portid,
3934 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
3935 struct cmd_tunnel_tso_set_result {
3936 cmdline_fixed_string_t tso;
3937 cmdline_fixed_string_t mode;
3942 static struct rte_eth_dev_info
3943 check_tunnel_tso_nic_support(portid_t port_id)
3945 struct rte_eth_dev_info dev_info;
3947 rte_eth_dev_info_get(port_id, &dev_info);
3948 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO))
3949 printf("Warning: VXLAN TUNNEL TSO not supported therefore "
3950 "not enabled for port %d\n", port_id);
3951 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO))
3952 printf("Warning: GRE TUNNEL TSO not supported therefore "
3953 "not enabled for port %d\n", port_id);
3954 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO))
3955 printf("Warning: IPIP TUNNEL TSO not supported therefore "
3956 "not enabled for port %d\n", port_id);
3957 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
3958 printf("Warning: GENEVE TUNNEL TSO not supported therefore "
3959 "not enabled for port %d\n", port_id);
3964 cmd_tunnel_tso_set_parsed(void *parsed_result,
3965 __attribute__((unused)) struct cmdline *cl,
3966 __attribute__((unused)) void *data)
3968 struct cmd_tunnel_tso_set_result *res = parsed_result;
3969 struct rte_eth_dev_info dev_info;
3971 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3973 if (!port_is_stopped(res->port_id)) {
3974 printf("Please stop port %d first\n", res->port_id);
3978 if (!strcmp(res->mode, "set"))
3979 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
3981 dev_info = check_tunnel_tso_nic_support(res->port_id);
3982 if (ports[res->port_id].tunnel_tso_segsz == 0) {
3983 ports[res->port_id].dev_conf.txmode.offloads &=
3984 ~(DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
3985 DEV_TX_OFFLOAD_GRE_TNL_TSO |
3986 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
3987 DEV_TX_OFFLOAD_GENEVE_TNL_TSO);
3988 printf("TSO for tunneled packets is disabled\n");
3990 uint64_t tso_offloads = (DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
3991 DEV_TX_OFFLOAD_GRE_TNL_TSO |
3992 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
3993 DEV_TX_OFFLOAD_GENEVE_TNL_TSO);
3995 ports[res->port_id].dev_conf.txmode.offloads |=
3996 (tso_offloads & dev_info.tx_offload_capa);
3997 printf("TSO segment size for tunneled packets is %d\n",
3998 ports[res->port_id].tunnel_tso_segsz);
4000 /* Below conditions are needed to make it work:
4001 * (1) tunnel TSO is supported by the NIC;
4002 * (2) "csum parse_tunnel" must be set so that tunneled pkts
4004 * (3) for tunneled pkts with outer L3 of IPv4,
4005 * "csum set outer-ip" must be set to hw, because after tso,
4006 * total_len of outer IP header is changed, and the checksum
4007 * of outer IP header calculated by sw should be wrong; that
4008 * is not necessary for IPv6 tunneled pkts because there's no
4009 * checksum in IP header anymore.
4012 if (!ports[res->port_id].parse_tunnel)
4013 printf("Warning: csum parse_tunnel must be set "
4014 "so that tunneled packets are recognized\n");
4015 if (!(ports[res->port_id].dev_conf.txmode.offloads &
4016 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM))
4017 printf("Warning: csum set outer-ip must be set to hw "
4018 "if outer L3 is IPv4; not necessary for IPv6\n");
4021 cmd_reconfig_device_queue(res->port_id, 1, 1);
4024 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
4025 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4027 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
4028 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4030 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
4031 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4033 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
4034 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4037 cmdline_parse_inst_t cmd_tunnel_tso_set = {
4038 .f = cmd_tunnel_tso_set_parsed,
4040 .help_str = "tunnel_tso set <tso_segsz> <port_id>: "
4041 "Set TSO segment size of tunneled packets for csum engine "
4044 (void *)&cmd_tunnel_tso_set_tso,
4045 (void *)&cmd_tunnel_tso_set_mode,
4046 (void *)&cmd_tunnel_tso_set_tso_segsz,
4047 (void *)&cmd_tunnel_tso_set_portid,
4052 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
4053 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4057 cmdline_parse_inst_t cmd_tunnel_tso_show = {
4058 .f = cmd_tunnel_tso_set_parsed,
4060 .help_str = "tunnel_tso show <port_id> "
4061 "Show TSO segment size of tunneled packets for csum engine",
4063 (void *)&cmd_tunnel_tso_set_tso,
4064 (void *)&cmd_tunnel_tso_show_mode,
4065 (void *)&cmd_tunnel_tso_set_portid,
4070 /* *** SET GRO FOR A PORT *** */
4071 struct cmd_gro_enable_result {
4072 cmdline_fixed_string_t cmd_set;
4073 cmdline_fixed_string_t cmd_port;
4074 cmdline_fixed_string_t cmd_keyword;
4075 cmdline_fixed_string_t cmd_onoff;
4080 cmd_gro_enable_parsed(void *parsed_result,
4081 __attribute__((unused)) struct cmdline *cl,
4082 __attribute__((unused)) void *data)
4084 struct cmd_gro_enable_result *res;
4086 res = parsed_result;
4087 if (!strcmp(res->cmd_keyword, "gro"))
4088 setup_gro(res->cmd_onoff, res->cmd_pid);
4091 cmdline_parse_token_string_t cmd_gro_enable_set =
4092 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4094 cmdline_parse_token_string_t cmd_gro_enable_port =
4095 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4096 cmd_keyword, "port");
4097 cmdline_parse_token_num_t cmd_gro_enable_pid =
4098 TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result,
4100 cmdline_parse_token_string_t cmd_gro_enable_keyword =
4101 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4102 cmd_keyword, "gro");
4103 cmdline_parse_token_string_t cmd_gro_enable_onoff =
4104 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4105 cmd_onoff, "on#off");
4107 cmdline_parse_inst_t cmd_gro_enable = {
4108 .f = cmd_gro_enable_parsed,
4110 .help_str = "set port <port_id> gro on|off",
4112 (void *)&cmd_gro_enable_set,
4113 (void *)&cmd_gro_enable_port,
4114 (void *)&cmd_gro_enable_pid,
4115 (void *)&cmd_gro_enable_keyword,
4116 (void *)&cmd_gro_enable_onoff,
4121 /* *** DISPLAY GRO CONFIGURATION *** */
4122 struct cmd_gro_show_result {
4123 cmdline_fixed_string_t cmd_show;
4124 cmdline_fixed_string_t cmd_port;
4125 cmdline_fixed_string_t cmd_keyword;
4130 cmd_gro_show_parsed(void *parsed_result,
4131 __attribute__((unused)) struct cmdline *cl,
4132 __attribute__((unused)) void *data)
4134 struct cmd_gro_show_result *res;
4136 res = parsed_result;
4137 if (!strcmp(res->cmd_keyword, "gro"))
4138 show_gro(res->cmd_pid);
4141 cmdline_parse_token_string_t cmd_gro_show_show =
4142 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4144 cmdline_parse_token_string_t cmd_gro_show_port =
4145 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4147 cmdline_parse_token_num_t cmd_gro_show_pid =
4148 TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result,
4150 cmdline_parse_token_string_t cmd_gro_show_keyword =
4151 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4152 cmd_keyword, "gro");
4154 cmdline_parse_inst_t cmd_gro_show = {
4155 .f = cmd_gro_show_parsed,
4157 .help_str = "show port <port_id> gro",
4159 (void *)&cmd_gro_show_show,
4160 (void *)&cmd_gro_show_port,
4161 (void *)&cmd_gro_show_pid,
4162 (void *)&cmd_gro_show_keyword,
4167 /* *** SET FLUSH CYCLES FOR GRO *** */
4168 struct cmd_gro_flush_result {
4169 cmdline_fixed_string_t cmd_set;
4170 cmdline_fixed_string_t cmd_keyword;
4171 cmdline_fixed_string_t cmd_flush;
4176 cmd_gro_flush_parsed(void *parsed_result,
4177 __attribute__((unused)) struct cmdline *cl,
4178 __attribute__((unused)) void *data)
4180 struct cmd_gro_flush_result *res;
4182 res = parsed_result;
4183 if ((!strcmp(res->cmd_keyword, "gro")) &&
4184 (!strcmp(res->cmd_flush, "flush")))
4185 setup_gro_flush_cycles(res->cmd_cycles);
4188 cmdline_parse_token_string_t cmd_gro_flush_set =
4189 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4191 cmdline_parse_token_string_t cmd_gro_flush_keyword =
4192 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4193 cmd_keyword, "gro");
4194 cmdline_parse_token_string_t cmd_gro_flush_flush =
4195 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4196 cmd_flush, "flush");
4197 cmdline_parse_token_num_t cmd_gro_flush_cycles =
4198 TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result,
4201 cmdline_parse_inst_t cmd_gro_flush = {
4202 .f = cmd_gro_flush_parsed,
4204 .help_str = "set gro flush <cycles>",
4206 (void *)&cmd_gro_flush_set,
4207 (void *)&cmd_gro_flush_keyword,
4208 (void *)&cmd_gro_flush_flush,
4209 (void *)&cmd_gro_flush_cycles,
4214 /* *** ENABLE/DISABLE GSO *** */
4215 struct cmd_gso_enable_result {
4216 cmdline_fixed_string_t cmd_set;
4217 cmdline_fixed_string_t cmd_port;
4218 cmdline_fixed_string_t cmd_keyword;
4219 cmdline_fixed_string_t cmd_mode;
4224 cmd_gso_enable_parsed(void *parsed_result,
4225 __attribute__((unused)) struct cmdline *cl,
4226 __attribute__((unused)) void *data)
4228 struct cmd_gso_enable_result *res;
4230 res = parsed_result;
4231 if (!strcmp(res->cmd_keyword, "gso"))
4232 setup_gso(res->cmd_mode, res->cmd_pid);
4235 cmdline_parse_token_string_t cmd_gso_enable_set =
4236 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4238 cmdline_parse_token_string_t cmd_gso_enable_port =
4239 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4241 cmdline_parse_token_string_t cmd_gso_enable_keyword =
4242 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4243 cmd_keyword, "gso");
4244 cmdline_parse_token_string_t cmd_gso_enable_mode =
4245 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4246 cmd_mode, "on#off");
4247 cmdline_parse_token_num_t cmd_gso_enable_pid =
4248 TOKEN_NUM_INITIALIZER(struct cmd_gso_enable_result,
4251 cmdline_parse_inst_t cmd_gso_enable = {
4252 .f = cmd_gso_enable_parsed,
4254 .help_str = "set port <port_id> gso on|off",
4256 (void *)&cmd_gso_enable_set,
4257 (void *)&cmd_gso_enable_port,
4258 (void *)&cmd_gso_enable_pid,
4259 (void *)&cmd_gso_enable_keyword,
4260 (void *)&cmd_gso_enable_mode,
4265 /* *** SET MAX PACKET LENGTH FOR GSO SEGMENTS *** */
4266 struct cmd_gso_size_result {
4267 cmdline_fixed_string_t cmd_set;
4268 cmdline_fixed_string_t cmd_keyword;
4269 cmdline_fixed_string_t cmd_segsz;
4274 cmd_gso_size_parsed(void *parsed_result,
4275 __attribute__((unused)) struct cmdline *cl,
4276 __attribute__((unused)) void *data)
4278 struct cmd_gso_size_result *res = parsed_result;
4280 if (test_done == 0) {
4281 printf("Before setting GSO segsz, please first"
4282 " stop fowarding\n");
4286 if (!strcmp(res->cmd_keyword, "gso") &&
4287 !strcmp(res->cmd_segsz, "segsz")) {
4288 if (res->cmd_size < RTE_GSO_SEG_SIZE_MIN)
4289 printf("gso_size should be larger than %zu."
4290 " Please input a legal value\n",
4291 RTE_GSO_SEG_SIZE_MIN);
4293 gso_max_segment_size = res->cmd_size;
4297 cmdline_parse_token_string_t cmd_gso_size_set =
4298 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
4300 cmdline_parse_token_string_t cmd_gso_size_keyword =
4301 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
4302 cmd_keyword, "gso");
4303 cmdline_parse_token_string_t cmd_gso_size_segsz =
4304 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
4305 cmd_segsz, "segsz");
4306 cmdline_parse_token_num_t cmd_gso_size_size =
4307 TOKEN_NUM_INITIALIZER(struct cmd_gso_size_result,
4310 cmdline_parse_inst_t cmd_gso_size = {
4311 .f = cmd_gso_size_parsed,
4313 .help_str = "set gso segsz <length>",
4315 (void *)&cmd_gso_size_set,
4316 (void *)&cmd_gso_size_keyword,
4317 (void *)&cmd_gso_size_segsz,
4318 (void *)&cmd_gso_size_size,
4323 /* *** SHOW GSO CONFIGURATION *** */
4324 struct cmd_gso_show_result {
4325 cmdline_fixed_string_t cmd_show;
4326 cmdline_fixed_string_t cmd_port;
4327 cmdline_fixed_string_t cmd_keyword;
4332 cmd_gso_show_parsed(void *parsed_result,
4333 __attribute__((unused)) struct cmdline *cl,
4334 __attribute__((unused)) void *data)
4336 struct cmd_gso_show_result *res = parsed_result;
4338 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
4339 printf("invalid port id %u\n", res->cmd_pid);
4342 if (!strcmp(res->cmd_keyword, "gso")) {
4343 if (gso_ports[res->cmd_pid].enable) {
4344 printf("Max GSO'd packet size: %uB\n"
4345 "Supported GSO types: TCP/IPv4, "
4346 "VxLAN with inner TCP/IPv4 packet, "
4347 "GRE with inner TCP/IPv4 packet\n",
4348 gso_max_segment_size);
4350 printf("GSO is not enabled on Port %u\n", res->cmd_pid);
4354 cmdline_parse_token_string_t cmd_gso_show_show =
4355 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
4357 cmdline_parse_token_string_t cmd_gso_show_port =
4358 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
4360 cmdline_parse_token_string_t cmd_gso_show_keyword =
4361 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
4362 cmd_keyword, "gso");
4363 cmdline_parse_token_num_t cmd_gso_show_pid =
4364 TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result,
4367 cmdline_parse_inst_t cmd_gso_show = {
4368 .f = cmd_gso_show_parsed,
4370 .help_str = "show port <port_id> gso",
4372 (void *)&cmd_gso_show_show,
4373 (void *)&cmd_gso_show_port,
4374 (void *)&cmd_gso_show_pid,
4375 (void *)&cmd_gso_show_keyword,
4380 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
4381 struct cmd_set_flush_rx {
4382 cmdline_fixed_string_t set;
4383 cmdline_fixed_string_t flush_rx;
4384 cmdline_fixed_string_t mode;
4388 cmd_set_flush_rx_parsed(void *parsed_result,
4389 __attribute__((unused)) struct cmdline *cl,
4390 __attribute__((unused)) void *data)
4392 struct cmd_set_flush_rx *res = parsed_result;
4393 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
4396 cmdline_parse_token_string_t cmd_setflushrx_set =
4397 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
4399 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
4400 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
4401 flush_rx, "flush_rx");
4402 cmdline_parse_token_string_t cmd_setflushrx_mode =
4403 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
4407 cmdline_parse_inst_t cmd_set_flush_rx = {
4408 .f = cmd_set_flush_rx_parsed,
4409 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
4412 (void *)&cmd_setflushrx_set,
4413 (void *)&cmd_setflushrx_flush_rx,
4414 (void *)&cmd_setflushrx_mode,
4419 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
4420 struct cmd_set_link_check {
4421 cmdline_fixed_string_t set;
4422 cmdline_fixed_string_t link_check;
4423 cmdline_fixed_string_t mode;
4427 cmd_set_link_check_parsed(void *parsed_result,
4428 __attribute__((unused)) struct cmdline *cl,
4429 __attribute__((unused)) void *data)
4431 struct cmd_set_link_check *res = parsed_result;
4432 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
4435 cmdline_parse_token_string_t cmd_setlinkcheck_set =
4436 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
4438 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
4439 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
4440 link_check, "link_check");
4441 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
4442 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
4446 cmdline_parse_inst_t cmd_set_link_check = {
4447 .f = cmd_set_link_check_parsed,
4448 .help_str = "set link_check on|off: Enable/Disable link status check "
4449 "when starting/stopping a port",
4452 (void *)&cmd_setlinkcheck_set,
4453 (void *)&cmd_setlinkcheck_link_check,
4454 (void *)&cmd_setlinkcheck_mode,
4459 /* *** SET NIC BYPASS MODE *** */
4460 struct cmd_set_bypass_mode_result {
4461 cmdline_fixed_string_t set;
4462 cmdline_fixed_string_t bypass;
4463 cmdline_fixed_string_t mode;
4464 cmdline_fixed_string_t value;
4469 cmd_set_bypass_mode_parsed(void *parsed_result,
4470 __attribute__((unused)) struct cmdline *cl,
4471 __attribute__((unused)) void *data)
4473 struct cmd_set_bypass_mode_result *res = parsed_result;
4474 portid_t port_id = res->port_id;
4475 int32_t rc = -EINVAL;
4477 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4478 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4480 if (!strcmp(res->value, "bypass"))
4481 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
4482 else if (!strcmp(res->value, "isolate"))
4483 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
4485 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4487 /* Set the bypass mode for the relevant port. */
4488 rc = rte_pmd_ixgbe_bypass_state_set(port_id, &bypass_mode);
4491 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
4494 cmdline_parse_token_string_t cmd_setbypass_mode_set =
4495 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4497 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
4498 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4500 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
4501 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4503 cmdline_parse_token_string_t cmd_setbypass_mode_value =
4504 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4505 value, "normal#bypass#isolate");
4506 cmdline_parse_token_num_t cmd_setbypass_mode_port =
4507 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
4510 cmdline_parse_inst_t cmd_set_bypass_mode = {
4511 .f = cmd_set_bypass_mode_parsed,
4512 .help_str = "set bypass mode normal|bypass|isolate <port_id>: "
4513 "Set the NIC bypass mode for port_id",
4516 (void *)&cmd_setbypass_mode_set,
4517 (void *)&cmd_setbypass_mode_bypass,
4518 (void *)&cmd_setbypass_mode_mode,
4519 (void *)&cmd_setbypass_mode_value,
4520 (void *)&cmd_setbypass_mode_port,
4525 /* *** SET NIC BYPASS EVENT *** */
4526 struct cmd_set_bypass_event_result {
4527 cmdline_fixed_string_t set;
4528 cmdline_fixed_string_t bypass;
4529 cmdline_fixed_string_t event;
4530 cmdline_fixed_string_t event_value;
4531 cmdline_fixed_string_t mode;
4532 cmdline_fixed_string_t mode_value;
4537 cmd_set_bypass_event_parsed(void *parsed_result,
4538 __attribute__((unused)) struct cmdline *cl,
4539 __attribute__((unused)) void *data)
4541 int32_t rc = -EINVAL;
4542 struct cmd_set_bypass_event_result *res = parsed_result;
4543 portid_t port_id = res->port_id;
4545 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4546 uint32_t bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
4547 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4549 if (!strcmp(res->event_value, "timeout"))
4550 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT;
4551 else if (!strcmp(res->event_value, "os_on"))
4552 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_ON;
4553 else if (!strcmp(res->event_value, "os_off"))
4554 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_OFF;
4555 else if (!strcmp(res->event_value, "power_on"))
4556 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_ON;
4557 else if (!strcmp(res->event_value, "power_off"))
4558 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_OFF;
4560 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
4562 if (!strcmp(res->mode_value, "bypass"))
4563 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
4564 else if (!strcmp(res->mode_value, "isolate"))
4565 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
4567 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4569 /* Set the watchdog timeout. */
4570 if (bypass_event == RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT) {
4573 if (RTE_PMD_IXGBE_BYPASS_TMT_VALID(bypass_timeout)) {
4574 rc = rte_pmd_ixgbe_bypass_wd_timeout_store(port_id,
4578 printf("Failed to set timeout value %u "
4579 "for port %d, errto code: %d.\n",
4580 bypass_timeout, port_id, rc);
4584 /* Set the bypass event to transition to bypass mode. */
4585 rc = rte_pmd_ixgbe_bypass_event_store(port_id, bypass_event,
4590 printf("\t Failed to set bypass event for port = %d.\n",
4594 cmdline_parse_token_string_t cmd_setbypass_event_set =
4595 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4597 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
4598 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4600 cmdline_parse_token_string_t cmd_setbypass_event_event =
4601 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4603 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
4604 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4605 event_value, "none#timeout#os_off#os_on#power_on#power_off");
4606 cmdline_parse_token_string_t cmd_setbypass_event_mode =
4607 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4609 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
4610 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
4611 mode_value, "normal#bypass#isolate");
4612 cmdline_parse_token_num_t cmd_setbypass_event_port =
4613 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
4616 cmdline_parse_inst_t cmd_set_bypass_event = {
4617 .f = cmd_set_bypass_event_parsed,
4618 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
4619 "power_off mode normal|bypass|isolate <port_id>: "
4620 "Set the NIC bypass event mode for port_id",
4623 (void *)&cmd_setbypass_event_set,
4624 (void *)&cmd_setbypass_event_bypass,
4625 (void *)&cmd_setbypass_event_event,
4626 (void *)&cmd_setbypass_event_event_value,
4627 (void *)&cmd_setbypass_event_mode,
4628 (void *)&cmd_setbypass_event_mode_value,
4629 (void *)&cmd_setbypass_event_port,
4635 /* *** SET NIC BYPASS TIMEOUT *** */
4636 struct cmd_set_bypass_timeout_result {
4637 cmdline_fixed_string_t set;
4638 cmdline_fixed_string_t bypass;
4639 cmdline_fixed_string_t timeout;
4640 cmdline_fixed_string_t value;
4644 cmd_set_bypass_timeout_parsed(void *parsed_result,
4645 __attribute__((unused)) struct cmdline *cl,
4646 __attribute__((unused)) void *data)
4648 __rte_unused struct cmd_set_bypass_timeout_result *res = parsed_result;
4650 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4651 if (!strcmp(res->value, "1.5"))
4652 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_1_5_SEC;
4653 else if (!strcmp(res->value, "2"))
4654 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_2_SEC;
4655 else if (!strcmp(res->value, "3"))
4656 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_3_SEC;
4657 else if (!strcmp(res->value, "4"))
4658 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_4_SEC;
4659 else if (!strcmp(res->value, "8"))
4660 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_8_SEC;
4661 else if (!strcmp(res->value, "16"))
4662 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_16_SEC;
4663 else if (!strcmp(res->value, "32"))
4664 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_32_SEC;
4666 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
4670 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
4671 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4673 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
4674 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4676 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
4677 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4678 timeout, "timeout");
4679 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
4680 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
4681 value, "0#1.5#2#3#4#8#16#32");
4683 cmdline_parse_inst_t cmd_set_bypass_timeout = {
4684 .f = cmd_set_bypass_timeout_parsed,
4685 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
4686 "Set the NIC bypass watchdog timeout in seconds",
4689 (void *)&cmd_setbypass_timeout_set,
4690 (void *)&cmd_setbypass_timeout_bypass,
4691 (void *)&cmd_setbypass_timeout_timeout,
4692 (void *)&cmd_setbypass_timeout_value,
4697 /* *** SHOW NIC BYPASS MODE *** */
4698 struct cmd_show_bypass_config_result {
4699 cmdline_fixed_string_t show;
4700 cmdline_fixed_string_t bypass;
4701 cmdline_fixed_string_t config;
4706 cmd_show_bypass_config_parsed(void *parsed_result,
4707 __attribute__((unused)) struct cmdline *cl,
4708 __attribute__((unused)) void *data)
4710 struct cmd_show_bypass_config_result *res = parsed_result;
4711 portid_t port_id = res->port_id;
4713 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4714 uint32_t event_mode;
4715 uint32_t bypass_mode;
4716 uint32_t timeout = bypass_timeout;
4719 static const char * const timeouts[RTE_PMD_IXGBE_BYPASS_TMT_NUM] =
4720 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
4721 static const char * const modes[RTE_PMD_IXGBE_BYPASS_MODE_NUM] =
4722 {"UNKNOWN", "normal", "bypass", "isolate"};
4723 static const char * const events[RTE_PMD_IXGBE_BYPASS_EVENT_NUM] = {
4730 int num_events = (sizeof events) / (sizeof events[0]);
4732 /* Display the bypass mode.*/
4733 if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) != 0) {
4734 printf("\tFailed to get bypass mode for port = %d\n", port_id);
4738 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(bypass_mode))
4739 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
4741 printf("\tbypass mode = %s\n", modes[bypass_mode]);
4744 /* Display the bypass timeout.*/
4745 if (!RTE_PMD_IXGBE_BYPASS_TMT_VALID(timeout))
4746 timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
4748 printf("\tbypass timeout = %s\n", timeouts[timeout]);
4750 /* Display the bypass events and associated modes. */
4751 for (i = RTE_PMD_IXGBE_BYPASS_EVENT_START; i < num_events; i++) {
4753 if (rte_pmd_ixgbe_bypass_event_show(port_id, i, &event_mode)) {
4754 printf("\tFailed to get bypass mode for event = %s\n",
4757 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(event_mode))
4758 event_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
4760 printf("\tbypass event: %-16s = %s\n", events[i],
4766 printf("\tFailed to get bypass configuration for port = %d\n",
4770 cmdline_parse_token_string_t cmd_showbypass_config_show =
4771 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4773 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
4774 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4776 cmdline_parse_token_string_t cmd_showbypass_config_config =
4777 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
4779 cmdline_parse_token_num_t cmd_showbypass_config_port =
4780 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
4783 cmdline_parse_inst_t cmd_show_bypass_config = {
4784 .f = cmd_show_bypass_config_parsed,
4785 .help_str = "show bypass config <port_id>: "
4786 "Show the NIC bypass config for port_id",
4789 (void *)&cmd_showbypass_config_show,
4790 (void *)&cmd_showbypass_config_bypass,
4791 (void *)&cmd_showbypass_config_config,
4792 (void *)&cmd_showbypass_config_port,
4797 #ifdef RTE_LIBRTE_PMD_BOND
4798 /* *** SET BONDING MODE *** */
4799 struct cmd_set_bonding_mode_result {
4800 cmdline_fixed_string_t set;
4801 cmdline_fixed_string_t bonding;
4802 cmdline_fixed_string_t mode;
4807 static void cmd_set_bonding_mode_parsed(void *parsed_result,
4808 __attribute__((unused)) struct cmdline *cl,
4809 __attribute__((unused)) void *data)
4811 struct cmd_set_bonding_mode_result *res = parsed_result;
4812 portid_t port_id = res->port_id;
4814 /* Set the bonding mode for the relevant port. */
4815 if (0 != rte_eth_bond_mode_set(port_id, res->value))
4816 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
4819 cmdline_parse_token_string_t cmd_setbonding_mode_set =
4820 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4822 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
4823 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4824 bonding, "bonding");
4825 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
4826 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
4828 cmdline_parse_token_num_t cmd_setbonding_mode_value =
4829 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
4831 cmdline_parse_token_num_t cmd_setbonding_mode_port =
4832 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
4835 cmdline_parse_inst_t cmd_set_bonding_mode = {
4836 .f = cmd_set_bonding_mode_parsed,
4837 .help_str = "set bonding mode <mode_value> <port_id>: "
4838 "Set the bonding mode for port_id",
4841 (void *) &cmd_setbonding_mode_set,
4842 (void *) &cmd_setbonding_mode_bonding,
4843 (void *) &cmd_setbonding_mode_mode,
4844 (void *) &cmd_setbonding_mode_value,
4845 (void *) &cmd_setbonding_mode_port,
4850 /* *** SET BONDING SLOW_QUEUE SW/HW *** */
4851 struct cmd_set_bonding_lacp_dedicated_queues_result {
4852 cmdline_fixed_string_t set;
4853 cmdline_fixed_string_t bonding;
4854 cmdline_fixed_string_t lacp;
4855 cmdline_fixed_string_t dedicated_queues;
4857 cmdline_fixed_string_t mode;
4860 static void cmd_set_bonding_lacp_dedicated_queues_parsed(void *parsed_result,
4861 __attribute__((unused)) struct cmdline *cl,
4862 __attribute__((unused)) void *data)
4864 struct cmd_set_bonding_lacp_dedicated_queues_result *res = parsed_result;
4865 portid_t port_id = res->port_id;
4866 struct rte_port *port;
4868 port = &ports[port_id];
4870 /** Check if the port is not started **/
4871 if (port->port_status != RTE_PORT_STOPPED) {
4872 printf("Please stop port %d first\n", port_id);
4876 if (!strcmp(res->mode, "enable")) {
4877 if (rte_eth_bond_8023ad_dedicated_queues_enable(port_id) == 0)
4878 printf("Dedicate queues for LACP control packets"
4881 printf("Enabling dedicate queues for LACP control "
4882 "packets on port %d failed\n", port_id);
4883 } else if (!strcmp(res->mode, "disable")) {
4884 if (rte_eth_bond_8023ad_dedicated_queues_disable(port_id) == 0)
4885 printf("Dedicated queues for LACP control packets "
4888 printf("Disabling dedicated queues for LACP control "
4889 "traffic on port %d failed\n", port_id);
4893 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_set =
4894 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4896 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_bonding =
4897 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4898 bonding, "bonding");
4899 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_lacp =
4900 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4902 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_dedicated_queues =
4903 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4904 dedicated_queues, "dedicated_queues");
4905 cmdline_parse_token_num_t cmd_setbonding_lacp_dedicated_queues_port_id =
4906 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4908 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_mode =
4909 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
4910 mode, "enable#disable");
4912 cmdline_parse_inst_t cmd_set_lacp_dedicated_queues = {
4913 .f = cmd_set_bonding_lacp_dedicated_queues_parsed,
4914 .help_str = "set bonding lacp dedicated_queues <port_id> "
4916 "Enable/disable dedicated queues for LACP control traffic for port_id",
4919 (void *)&cmd_setbonding_lacp_dedicated_queues_set,
4920 (void *)&cmd_setbonding_lacp_dedicated_queues_bonding,
4921 (void *)&cmd_setbonding_lacp_dedicated_queues_lacp,
4922 (void *)&cmd_setbonding_lacp_dedicated_queues_dedicated_queues,
4923 (void *)&cmd_setbonding_lacp_dedicated_queues_port_id,
4924 (void *)&cmd_setbonding_lacp_dedicated_queues_mode,
4929 /* *** SET BALANCE XMIT POLICY *** */
4930 struct cmd_set_bonding_balance_xmit_policy_result {
4931 cmdline_fixed_string_t set;
4932 cmdline_fixed_string_t bonding;
4933 cmdline_fixed_string_t balance_xmit_policy;
4935 cmdline_fixed_string_t policy;
4938 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
4939 __attribute__((unused)) struct cmdline *cl,
4940 __attribute__((unused)) void *data)
4942 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
4943 portid_t port_id = res->port_id;
4946 if (!strcmp(res->policy, "l2")) {
4947 policy = BALANCE_XMIT_POLICY_LAYER2;
4948 } else if (!strcmp(res->policy, "l23")) {
4949 policy = BALANCE_XMIT_POLICY_LAYER23;
4950 } else if (!strcmp(res->policy, "l34")) {
4951 policy = BALANCE_XMIT_POLICY_LAYER34;
4953 printf("\t Invalid xmit policy selection");
4957 /* Set the bonding mode for the relevant port. */
4958 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
4959 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
4964 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
4965 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4967 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
4968 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4969 bonding, "bonding");
4970 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
4971 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4972 balance_xmit_policy, "balance_xmit_policy");
4973 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
4974 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4976 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
4977 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
4978 policy, "l2#l23#l34");
4980 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
4981 .f = cmd_set_bonding_balance_xmit_policy_parsed,
4982 .help_str = "set bonding balance_xmit_policy <port_id> "
4984 "Set the bonding balance_xmit_policy for port_id",
4987 (void *)&cmd_setbonding_balance_xmit_policy_set,
4988 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
4989 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
4990 (void *)&cmd_setbonding_balance_xmit_policy_port,
4991 (void *)&cmd_setbonding_balance_xmit_policy_policy,
4996 /* *** SHOW NIC BONDING CONFIGURATION *** */
4997 struct cmd_show_bonding_config_result {
4998 cmdline_fixed_string_t show;
4999 cmdline_fixed_string_t bonding;
5000 cmdline_fixed_string_t config;
5004 static void cmd_show_bonding_config_parsed(void *parsed_result,
5005 __attribute__((unused)) struct cmdline *cl,
5006 __attribute__((unused)) void *data)
5008 struct cmd_show_bonding_config_result *res = parsed_result;
5009 int bonding_mode, agg_mode;
5010 portid_t slaves[RTE_MAX_ETHPORTS];
5011 int num_slaves, num_active_slaves;
5014 portid_t port_id = res->port_id;
5016 /* Display the bonding mode.*/
5017 bonding_mode = rte_eth_bond_mode_get(port_id);
5018 if (bonding_mode < 0) {
5019 printf("\tFailed to get bonding mode for port = %d\n", port_id);
5022 printf("\tBonding mode: %d\n", bonding_mode);
5024 if (bonding_mode == BONDING_MODE_BALANCE) {
5025 int balance_xmit_policy;
5027 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
5028 if (balance_xmit_policy < 0) {
5029 printf("\tFailed to get balance xmit policy for port = %d\n",
5033 printf("\tBalance Xmit Policy: ");
5035 switch (balance_xmit_policy) {
5036 case BALANCE_XMIT_POLICY_LAYER2:
5037 printf("BALANCE_XMIT_POLICY_LAYER2");
5039 case BALANCE_XMIT_POLICY_LAYER23:
5040 printf("BALANCE_XMIT_POLICY_LAYER23");
5042 case BALANCE_XMIT_POLICY_LAYER34:
5043 printf("BALANCE_XMIT_POLICY_LAYER34");
5050 if (bonding_mode == BONDING_MODE_8023AD) {
5051 agg_mode = rte_eth_bond_8023ad_agg_selection_get(port_id);
5052 printf("\tIEEE802.3AD Aggregator Mode: ");
5055 printf("bandwidth");
5067 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
5069 if (num_slaves < 0) {
5070 printf("\tFailed to get slave list for port = %d\n", port_id);
5073 if (num_slaves > 0) {
5074 printf("\tSlaves (%d): [", num_slaves);
5075 for (i = 0; i < num_slaves - 1; i++)
5076 printf("%d ", slaves[i]);
5078 printf("%d]\n", slaves[num_slaves - 1]);
5080 printf("\tSlaves: []\n");
5084 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
5087 if (num_active_slaves < 0) {
5088 printf("\tFailed to get active slave list for port = %d\n", port_id);
5091 if (num_active_slaves > 0) {
5092 printf("\tActive Slaves (%d): [", num_active_slaves);
5093 for (i = 0; i < num_active_slaves - 1; i++)
5094 printf("%d ", slaves[i]);
5096 printf("%d]\n", slaves[num_active_slaves - 1]);
5099 printf("\tActive Slaves: []\n");
5103 primary_id = rte_eth_bond_primary_get(port_id);
5104 if (primary_id < 0) {
5105 printf("\tFailed to get primary slave for port = %d\n", port_id);
5108 printf("\tPrimary: [%d]\n", primary_id);
5112 cmdline_parse_token_string_t cmd_showbonding_config_show =
5113 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5115 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
5116 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5117 bonding, "bonding");
5118 cmdline_parse_token_string_t cmd_showbonding_config_config =
5119 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5121 cmdline_parse_token_num_t cmd_showbonding_config_port =
5122 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
5125 cmdline_parse_inst_t cmd_show_bonding_config = {
5126 .f = cmd_show_bonding_config_parsed,
5127 .help_str = "show bonding config <port_id>: "
5128 "Show the bonding config for port_id",
5131 (void *)&cmd_showbonding_config_show,
5132 (void *)&cmd_showbonding_config_bonding,
5133 (void *)&cmd_showbonding_config_config,
5134 (void *)&cmd_showbonding_config_port,
5139 /* *** SET BONDING PRIMARY *** */
5140 struct cmd_set_bonding_primary_result {
5141 cmdline_fixed_string_t set;
5142 cmdline_fixed_string_t bonding;
5143 cmdline_fixed_string_t primary;
5148 static void cmd_set_bonding_primary_parsed(void *parsed_result,
5149 __attribute__((unused)) struct cmdline *cl,
5150 __attribute__((unused)) void *data)
5152 struct cmd_set_bonding_primary_result *res = parsed_result;
5153 portid_t master_port_id = res->port_id;
5154 portid_t slave_port_id = res->slave_id;
5156 /* Set the primary slave for a bonded device. */
5157 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
5158 printf("\t Failed to set primary slave for port = %d.\n",
5165 cmdline_parse_token_string_t cmd_setbonding_primary_set =
5166 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5168 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
5169 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5170 bonding, "bonding");
5171 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
5172 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5173 primary, "primary");
5174 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
5175 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
5177 cmdline_parse_token_num_t cmd_setbonding_primary_port =
5178 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
5181 cmdline_parse_inst_t cmd_set_bonding_primary = {
5182 .f = cmd_set_bonding_primary_parsed,
5183 .help_str = "set bonding primary <slave_id> <port_id>: "
5184 "Set the primary slave for port_id",
5187 (void *)&cmd_setbonding_primary_set,
5188 (void *)&cmd_setbonding_primary_bonding,
5189 (void *)&cmd_setbonding_primary_primary,
5190 (void *)&cmd_setbonding_primary_slave,
5191 (void *)&cmd_setbonding_primary_port,
5196 /* *** ADD SLAVE *** */
5197 struct cmd_add_bonding_slave_result {
5198 cmdline_fixed_string_t add;
5199 cmdline_fixed_string_t bonding;
5200 cmdline_fixed_string_t slave;
5205 static void cmd_add_bonding_slave_parsed(void *parsed_result,
5206 __attribute__((unused)) struct cmdline *cl,
5207 __attribute__((unused)) void *data)
5209 struct cmd_add_bonding_slave_result *res = parsed_result;
5210 portid_t master_port_id = res->port_id;
5211 portid_t slave_port_id = res->slave_id;
5213 /* add the slave for a bonded device. */
5214 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
5215 printf("\t Failed to add slave %d to master port = %d.\n",
5216 slave_port_id, master_port_id);
5220 set_port_slave_flag(slave_port_id);
5223 cmdline_parse_token_string_t cmd_addbonding_slave_add =
5224 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5226 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
5227 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5228 bonding, "bonding");
5229 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
5230 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5232 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
5233 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
5235 cmdline_parse_token_num_t cmd_addbonding_slave_port =
5236 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
5239 cmdline_parse_inst_t cmd_add_bonding_slave = {
5240 .f = cmd_add_bonding_slave_parsed,
5241 .help_str = "add bonding slave <slave_id> <port_id>: "
5242 "Add a slave device to a bonded device",
5245 (void *)&cmd_addbonding_slave_add,
5246 (void *)&cmd_addbonding_slave_bonding,
5247 (void *)&cmd_addbonding_slave_slave,
5248 (void *)&cmd_addbonding_slave_slaveid,
5249 (void *)&cmd_addbonding_slave_port,
5254 /* *** REMOVE SLAVE *** */
5255 struct cmd_remove_bonding_slave_result {
5256 cmdline_fixed_string_t remove;
5257 cmdline_fixed_string_t bonding;
5258 cmdline_fixed_string_t slave;
5263 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
5264 __attribute__((unused)) struct cmdline *cl,
5265 __attribute__((unused)) void *data)
5267 struct cmd_remove_bonding_slave_result *res = parsed_result;
5268 portid_t master_port_id = res->port_id;
5269 portid_t slave_port_id = res->slave_id;
5271 /* remove the slave from a bonded device. */
5272 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
5273 printf("\t Failed to remove slave %d from master port = %d.\n",
5274 slave_port_id, master_port_id);
5278 clear_port_slave_flag(slave_port_id);
5281 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
5282 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
5284 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
5285 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
5286 bonding, "bonding");
5287 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
5288 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
5290 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
5291 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
5293 cmdline_parse_token_num_t cmd_removebonding_slave_port =
5294 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
5297 cmdline_parse_inst_t cmd_remove_bonding_slave = {
5298 .f = cmd_remove_bonding_slave_parsed,
5299 .help_str = "remove bonding slave <slave_id> <port_id>: "
5300 "Remove a slave device from a bonded device",
5303 (void *)&cmd_removebonding_slave_remove,
5304 (void *)&cmd_removebonding_slave_bonding,
5305 (void *)&cmd_removebonding_slave_slave,
5306 (void *)&cmd_removebonding_slave_slaveid,
5307 (void *)&cmd_removebonding_slave_port,
5312 /* *** CREATE BONDED DEVICE *** */
5313 struct cmd_create_bonded_device_result {
5314 cmdline_fixed_string_t create;
5315 cmdline_fixed_string_t bonded;
5316 cmdline_fixed_string_t device;
5321 static int bond_dev_num = 0;
5323 static void cmd_create_bonded_device_parsed(void *parsed_result,
5324 __attribute__((unused)) struct cmdline *cl,
5325 __attribute__((unused)) void *data)
5327 struct cmd_create_bonded_device_result *res = parsed_result;
5328 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
5331 if (test_done == 0) {
5332 printf("Please stop forwarding first\n");
5336 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bonding_testpmd_%d",
5339 /* Create a new bonded device. */
5340 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
5342 printf("\t Failed to create bonded device.\n");
5345 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
5348 /* Update number of ports */
5349 nb_ports = rte_eth_dev_count();
5350 reconfig(port_id, res->socket);
5351 rte_eth_promiscuous_enable(port_id);
5356 cmdline_parse_token_string_t cmd_createbonded_device_create =
5357 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
5359 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
5360 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
5362 cmdline_parse_token_string_t cmd_createbonded_device_device =
5363 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
5365 cmdline_parse_token_num_t cmd_createbonded_device_mode =
5366 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
5368 cmdline_parse_token_num_t cmd_createbonded_device_socket =
5369 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
5372 cmdline_parse_inst_t cmd_create_bonded_device = {
5373 .f = cmd_create_bonded_device_parsed,
5374 .help_str = "create bonded device <mode> <socket>: "
5375 "Create a new bonded device with specific bonding mode and socket",
5378 (void *)&cmd_createbonded_device_create,
5379 (void *)&cmd_createbonded_device_bonded,
5380 (void *)&cmd_createbonded_device_device,
5381 (void *)&cmd_createbonded_device_mode,
5382 (void *)&cmd_createbonded_device_socket,
5387 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
5388 struct cmd_set_bond_mac_addr_result {
5389 cmdline_fixed_string_t set;
5390 cmdline_fixed_string_t bonding;
5391 cmdline_fixed_string_t mac_addr;
5393 struct ether_addr address;
5396 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
5397 __attribute__((unused)) struct cmdline *cl,
5398 __attribute__((unused)) void *data)
5400 struct cmd_set_bond_mac_addr_result *res = parsed_result;
5403 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
5406 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
5408 /* check the return value and print it if is < 0 */
5410 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
5413 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
5414 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
5415 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
5416 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
5418 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
5419 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
5421 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
5422 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result,
5424 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
5425 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
5427 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
5428 .f = cmd_set_bond_mac_addr_parsed,
5430 .help_str = "set bonding mac_addr <port_id> <mac_addr>",
5432 (void *)&cmd_set_bond_mac_addr_set,
5433 (void *)&cmd_set_bond_mac_addr_bonding,
5434 (void *)&cmd_set_bond_mac_addr_mac,
5435 (void *)&cmd_set_bond_mac_addr_portnum,
5436 (void *)&cmd_set_bond_mac_addr_addr,
5442 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
5443 struct cmd_set_bond_mon_period_result {
5444 cmdline_fixed_string_t set;
5445 cmdline_fixed_string_t bonding;
5446 cmdline_fixed_string_t mon_period;
5451 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
5452 __attribute__((unused)) struct cmdline *cl,
5453 __attribute__((unused)) void *data)
5455 struct cmd_set_bond_mon_period_result *res = parsed_result;
5458 if (res->port_num >= nb_ports) {
5459 printf("Port id %d must be less than %d\n", res->port_num, nb_ports);
5463 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
5465 /* check the return value and print it if is < 0 */
5467 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
5470 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
5471 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
5473 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
5474 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
5475 bonding, "bonding");
5476 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
5477 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
5478 mon_period, "mon_period");
5479 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
5480 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
5482 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
5483 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
5486 cmdline_parse_inst_t cmd_set_bond_mon_period = {
5487 .f = cmd_set_bond_mon_period_parsed,
5489 .help_str = "set bonding mon_period <port_id> <period_ms>",
5491 (void *)&cmd_set_bond_mon_period_set,
5492 (void *)&cmd_set_bond_mon_period_bonding,
5493 (void *)&cmd_set_bond_mon_period_mon_period,
5494 (void *)&cmd_set_bond_mon_period_portnum,
5495 (void *)&cmd_set_bond_mon_period_period_ms,
5502 struct cmd_set_bonding_agg_mode_policy_result {
5503 cmdline_fixed_string_t set;
5504 cmdline_fixed_string_t bonding;
5505 cmdline_fixed_string_t agg_mode;
5507 cmdline_fixed_string_t policy;
5512 cmd_set_bonding_agg_mode(void *parsed_result,
5513 __attribute__((unused)) struct cmdline *cl,
5514 __attribute__((unused)) void *data)
5516 struct cmd_set_bonding_agg_mode_policy_result *res = parsed_result;
5517 uint8_t policy = AGG_BANDWIDTH;
5519 if (res->port_num >= nb_ports) {
5520 printf("Port id %d must be less than %d\n",
5521 res->port_num, nb_ports);
5525 if (!strcmp(res->policy, "bandwidth"))
5526 policy = AGG_BANDWIDTH;
5527 else if (!strcmp(res->policy, "stable"))
5528 policy = AGG_STABLE;
5529 else if (!strcmp(res->policy, "count"))
5532 rte_eth_bond_8023ad_agg_selection_set(res->port_num, policy);
5536 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_set =
5537 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5539 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_bonding =
5540 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5541 bonding, "bonding");
5543 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_agg_mode =
5544 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5545 agg_mode, "agg_mode");
5547 cmdline_parse_token_num_t cmd_set_bonding_agg_mode_portnum =
5548 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5551 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_policy_string =
5552 TOKEN_STRING_INITIALIZER(
5553 struct cmd_set_bonding_balance_xmit_policy_result,
5554 policy, "stable#bandwidth#count");
5556 cmdline_parse_inst_t cmd_set_bonding_agg_mode_policy = {
5557 .f = cmd_set_bonding_agg_mode,
5559 .help_str = "set bonding mode IEEE802.3AD aggregator policy <port_id> <agg_name>",
5561 (void *)&cmd_set_bonding_agg_mode_set,
5562 (void *)&cmd_set_bonding_agg_mode_bonding,
5563 (void *)&cmd_set_bonding_agg_mode_agg_mode,
5564 (void *)&cmd_set_bonding_agg_mode_portnum,
5565 (void *)&cmd_set_bonding_agg_mode_policy_string,
5571 #endif /* RTE_LIBRTE_PMD_BOND */
5573 /* *** SET FORWARDING MODE *** */
5574 struct cmd_set_fwd_mode_result {
5575 cmdline_fixed_string_t set;
5576 cmdline_fixed_string_t fwd;
5577 cmdline_fixed_string_t mode;
5580 static void cmd_set_fwd_mode_parsed(void *parsed_result,
5581 __attribute__((unused)) struct cmdline *cl,
5582 __attribute__((unused)) void *data)
5584 struct cmd_set_fwd_mode_result *res = parsed_result;
5587 set_pkt_forwarding_mode(res->mode);
5590 cmdline_parse_token_string_t cmd_setfwd_set =
5591 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
5592 cmdline_parse_token_string_t cmd_setfwd_fwd =
5593 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
5594 cmdline_parse_token_string_t cmd_setfwd_mode =
5595 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
5596 "" /* defined at init */);
5598 cmdline_parse_inst_t cmd_set_fwd_mode = {
5599 .f = cmd_set_fwd_mode_parsed,
5601 .help_str = NULL, /* defined at init */
5603 (void *)&cmd_setfwd_set,
5604 (void *)&cmd_setfwd_fwd,
5605 (void *)&cmd_setfwd_mode,
5610 static void cmd_set_fwd_mode_init(void)
5613 static char token[128];
5614 static char help[256];
5615 cmdline_parse_token_string_t *token_struct;
5617 modes = list_pkt_forwarding_modes();
5618 snprintf(help, sizeof(help), "set fwd %s: "
5619 "Set packet forwarding mode", modes);
5620 cmd_set_fwd_mode.help_str = help;
5622 /* string token separator is # */
5623 for (c = token; *modes != '\0'; modes++)
5628 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
5629 token_struct->string_data.str = token;
5632 /* *** SET RETRY FORWARDING MODE *** */
5633 struct cmd_set_fwd_retry_mode_result {
5634 cmdline_fixed_string_t set;
5635 cmdline_fixed_string_t fwd;
5636 cmdline_fixed_string_t mode;
5637 cmdline_fixed_string_t retry;
5640 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
5641 __attribute__((unused)) struct cmdline *cl,
5642 __attribute__((unused)) void *data)
5644 struct cmd_set_fwd_retry_mode_result *res = parsed_result;
5647 set_pkt_forwarding_mode(res->mode);
5650 cmdline_parse_token_string_t cmd_setfwd_retry_set =
5651 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
5653 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
5654 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
5656 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
5657 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
5659 "" /* defined at init */);
5660 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
5661 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
5664 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
5665 .f = cmd_set_fwd_retry_mode_parsed,
5667 .help_str = NULL, /* defined at init */
5669 (void *)&cmd_setfwd_retry_set,
5670 (void *)&cmd_setfwd_retry_fwd,
5671 (void *)&cmd_setfwd_retry_mode,
5672 (void *)&cmd_setfwd_retry_retry,
5677 static void cmd_set_fwd_retry_mode_init(void)
5680 static char token[128];
5681 static char help[256];
5682 cmdline_parse_token_string_t *token_struct;
5684 modes = list_pkt_forwarding_retry_modes();
5685 snprintf(help, sizeof(help), "set fwd %s retry: "
5686 "Set packet forwarding mode with retry", modes);
5687 cmd_set_fwd_retry_mode.help_str = help;
5689 /* string token separator is # */
5690 for (c = token; *modes != '\0'; modes++)
5695 token_struct = (cmdline_parse_token_string_t *)
5696 cmd_set_fwd_retry_mode.tokens[2];
5697 token_struct->string_data.str = token;
5700 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
5701 struct cmd_set_burst_tx_retry_result {
5702 cmdline_fixed_string_t set;
5703 cmdline_fixed_string_t burst;
5704 cmdline_fixed_string_t tx;
5705 cmdline_fixed_string_t delay;
5707 cmdline_fixed_string_t retry;
5711 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
5712 __attribute__((unused)) struct cmdline *cl,
5713 __attribute__((unused)) void *data)
5715 struct cmd_set_burst_tx_retry_result *res = parsed_result;
5717 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
5718 && !strcmp(res->tx, "tx")) {
5719 if (!strcmp(res->delay, "delay"))
5720 burst_tx_delay_time = res->time;
5721 if (!strcmp(res->retry, "retry"))
5722 burst_tx_retry_num = res->retry_num;
5727 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
5728 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
5729 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
5730 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
5732 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
5733 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
5734 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
5735 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
5736 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
5737 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
5738 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
5739 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
5740 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
5741 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
5743 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
5744 .f = cmd_set_burst_tx_retry_parsed,
5745 .help_str = "set burst tx delay <delay_usec> retry <num_retry>",
5747 (void *)&cmd_set_burst_tx_retry_set,
5748 (void *)&cmd_set_burst_tx_retry_burst,
5749 (void *)&cmd_set_burst_tx_retry_tx,
5750 (void *)&cmd_set_burst_tx_retry_delay,
5751 (void *)&cmd_set_burst_tx_retry_time,
5752 (void *)&cmd_set_burst_tx_retry_retry,
5753 (void *)&cmd_set_burst_tx_retry_retry_num,
5758 /* *** SET PROMISC MODE *** */
5759 struct cmd_set_promisc_mode_result {
5760 cmdline_fixed_string_t set;
5761 cmdline_fixed_string_t promisc;
5762 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
5763 uint16_t port_num; /* valid if "allports" argument == 0 */
5764 cmdline_fixed_string_t mode;
5767 static void cmd_set_promisc_mode_parsed(void *parsed_result,
5768 __attribute__((unused)) struct cmdline *cl,
5771 struct cmd_set_promisc_mode_result *res = parsed_result;
5775 if (!strcmp(res->mode, "on"))
5782 RTE_ETH_FOREACH_DEV(i) {
5784 rte_eth_promiscuous_enable(i);
5786 rte_eth_promiscuous_disable(i);
5791 rte_eth_promiscuous_enable(res->port_num);
5793 rte_eth_promiscuous_disable(res->port_num);
5797 cmdline_parse_token_string_t cmd_setpromisc_set =
5798 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
5799 cmdline_parse_token_string_t cmd_setpromisc_promisc =
5800 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
5802 cmdline_parse_token_string_t cmd_setpromisc_portall =
5803 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
5805 cmdline_parse_token_num_t cmd_setpromisc_portnum =
5806 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
5808 cmdline_parse_token_string_t cmd_setpromisc_mode =
5809 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
5812 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
5813 .f = cmd_set_promisc_mode_parsed,
5815 .help_str = "set promisc all on|off: Set promisc mode for all ports",
5817 (void *)&cmd_setpromisc_set,
5818 (void *)&cmd_setpromisc_promisc,
5819 (void *)&cmd_setpromisc_portall,
5820 (void *)&cmd_setpromisc_mode,
5825 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
5826 .f = cmd_set_promisc_mode_parsed,
5828 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
5830 (void *)&cmd_setpromisc_set,
5831 (void *)&cmd_setpromisc_promisc,
5832 (void *)&cmd_setpromisc_portnum,
5833 (void *)&cmd_setpromisc_mode,
5838 /* *** SET ALLMULTI MODE *** */
5839 struct cmd_set_allmulti_mode_result {
5840 cmdline_fixed_string_t set;
5841 cmdline_fixed_string_t allmulti;
5842 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
5843 uint16_t port_num; /* valid if "allports" argument == 0 */
5844 cmdline_fixed_string_t mode;
5847 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
5848 __attribute__((unused)) struct cmdline *cl,
5851 struct cmd_set_allmulti_mode_result *res = parsed_result;
5855 if (!strcmp(res->mode, "on"))
5862 RTE_ETH_FOREACH_DEV(i) {
5864 rte_eth_allmulticast_enable(i);
5866 rte_eth_allmulticast_disable(i);
5871 rte_eth_allmulticast_enable(res->port_num);
5873 rte_eth_allmulticast_disable(res->port_num);
5877 cmdline_parse_token_string_t cmd_setallmulti_set =
5878 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
5879 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
5880 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
5882 cmdline_parse_token_string_t cmd_setallmulti_portall =
5883 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
5885 cmdline_parse_token_num_t cmd_setallmulti_portnum =
5886 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
5888 cmdline_parse_token_string_t cmd_setallmulti_mode =
5889 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
5892 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
5893 .f = cmd_set_allmulti_mode_parsed,
5895 .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
5897 (void *)&cmd_setallmulti_set,
5898 (void *)&cmd_setallmulti_allmulti,
5899 (void *)&cmd_setallmulti_portall,
5900 (void *)&cmd_setallmulti_mode,
5905 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
5906 .f = cmd_set_allmulti_mode_parsed,
5908 .help_str = "set allmulti <port_id> on|off: "
5909 "Set allmulti mode on port_id",
5911 (void *)&cmd_setallmulti_set,
5912 (void *)&cmd_setallmulti_allmulti,
5913 (void *)&cmd_setallmulti_portnum,
5914 (void *)&cmd_setallmulti_mode,
5919 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
5920 struct cmd_link_flow_ctrl_set_result {
5921 cmdline_fixed_string_t set;
5922 cmdline_fixed_string_t flow_ctrl;
5923 cmdline_fixed_string_t rx;
5924 cmdline_fixed_string_t rx_lfc_mode;
5925 cmdline_fixed_string_t tx;
5926 cmdline_fixed_string_t tx_lfc_mode;
5927 cmdline_fixed_string_t mac_ctrl_frame_fwd;
5928 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
5929 cmdline_fixed_string_t autoneg_str;
5930 cmdline_fixed_string_t autoneg;
5931 cmdline_fixed_string_t hw_str;
5932 uint32_t high_water;
5933 cmdline_fixed_string_t lw_str;
5935 cmdline_fixed_string_t pt_str;
5936 uint16_t pause_time;
5937 cmdline_fixed_string_t xon_str;
5942 cmdline_parse_token_string_t cmd_lfc_set_set =
5943 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5945 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
5946 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5947 flow_ctrl, "flow_ctrl");
5948 cmdline_parse_token_string_t cmd_lfc_set_rx =
5949 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5951 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
5952 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5953 rx_lfc_mode, "on#off");
5954 cmdline_parse_token_string_t cmd_lfc_set_tx =
5955 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5957 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
5958 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5959 tx_lfc_mode, "on#off");
5960 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
5961 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5962 hw_str, "high_water");
5963 cmdline_parse_token_num_t cmd_lfc_set_high_water =
5964 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5965 high_water, UINT32);
5966 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
5967 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5968 lw_str, "low_water");
5969 cmdline_parse_token_num_t cmd_lfc_set_low_water =
5970 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5972 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
5973 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5974 pt_str, "pause_time");
5975 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
5976 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5977 pause_time, UINT16);
5978 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
5979 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5980 xon_str, "send_xon");
5981 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
5982 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5984 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
5985 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5986 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
5987 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
5988 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5989 mac_ctrl_frame_fwd_mode, "on#off");
5990 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
5991 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5992 autoneg_str, "autoneg");
5993 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
5994 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
5996 cmdline_parse_token_num_t cmd_lfc_set_portid =
5997 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6000 /* forward declaration */
6002 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
6005 cmdline_parse_inst_t cmd_link_flow_control_set = {
6006 .f = cmd_link_flow_ctrl_set_parsed,
6008 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
6009 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
6010 "autoneg on|off <port_id>: Configure the Ethernet flow control",
6012 (void *)&cmd_lfc_set_set,
6013 (void *)&cmd_lfc_set_flow_ctrl,
6014 (void *)&cmd_lfc_set_rx,
6015 (void *)&cmd_lfc_set_rx_mode,
6016 (void *)&cmd_lfc_set_tx,
6017 (void *)&cmd_lfc_set_tx_mode,
6018 (void *)&cmd_lfc_set_high_water,
6019 (void *)&cmd_lfc_set_low_water,
6020 (void *)&cmd_lfc_set_pause_time,
6021 (void *)&cmd_lfc_set_send_xon,
6022 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6023 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6024 (void *)&cmd_lfc_set_autoneg_str,
6025 (void *)&cmd_lfc_set_autoneg,
6026 (void *)&cmd_lfc_set_portid,
6031 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
6032 .f = cmd_link_flow_ctrl_set_parsed,
6033 .data = (void *)&cmd_link_flow_control_set_rx,
6034 .help_str = "set flow_ctrl rx on|off <port_id>: "
6035 "Change rx flow control parameter",
6037 (void *)&cmd_lfc_set_set,
6038 (void *)&cmd_lfc_set_flow_ctrl,
6039 (void *)&cmd_lfc_set_rx,
6040 (void *)&cmd_lfc_set_rx_mode,
6041 (void *)&cmd_lfc_set_portid,
6046 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
6047 .f = cmd_link_flow_ctrl_set_parsed,
6048 .data = (void *)&cmd_link_flow_control_set_tx,
6049 .help_str = "set flow_ctrl tx on|off <port_id>: "
6050 "Change tx flow control parameter",
6052 (void *)&cmd_lfc_set_set,
6053 (void *)&cmd_lfc_set_flow_ctrl,
6054 (void *)&cmd_lfc_set_tx,
6055 (void *)&cmd_lfc_set_tx_mode,
6056 (void *)&cmd_lfc_set_portid,
6061 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
6062 .f = cmd_link_flow_ctrl_set_parsed,
6063 .data = (void *)&cmd_link_flow_control_set_hw,
6064 .help_str = "set flow_ctrl high_water <value> <port_id>: "
6065 "Change high water flow control parameter",
6067 (void *)&cmd_lfc_set_set,
6068 (void *)&cmd_lfc_set_flow_ctrl,
6069 (void *)&cmd_lfc_set_high_water_str,
6070 (void *)&cmd_lfc_set_high_water,
6071 (void *)&cmd_lfc_set_portid,
6076 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
6077 .f = cmd_link_flow_ctrl_set_parsed,
6078 .data = (void *)&cmd_link_flow_control_set_lw,
6079 .help_str = "set flow_ctrl low_water <value> <port_id>: "
6080 "Change low water flow control parameter",
6082 (void *)&cmd_lfc_set_set,
6083 (void *)&cmd_lfc_set_flow_ctrl,
6084 (void *)&cmd_lfc_set_low_water_str,
6085 (void *)&cmd_lfc_set_low_water,
6086 (void *)&cmd_lfc_set_portid,
6091 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
6092 .f = cmd_link_flow_ctrl_set_parsed,
6093 .data = (void *)&cmd_link_flow_control_set_pt,
6094 .help_str = "set flow_ctrl pause_time <value> <port_id>: "
6095 "Change pause time flow control parameter",
6097 (void *)&cmd_lfc_set_set,
6098 (void *)&cmd_lfc_set_flow_ctrl,
6099 (void *)&cmd_lfc_set_pause_time_str,
6100 (void *)&cmd_lfc_set_pause_time,
6101 (void *)&cmd_lfc_set_portid,
6106 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
6107 .f = cmd_link_flow_ctrl_set_parsed,
6108 .data = (void *)&cmd_link_flow_control_set_xon,
6109 .help_str = "set flow_ctrl send_xon <value> <port_id>: "
6110 "Change send_xon flow control parameter",
6112 (void *)&cmd_lfc_set_set,
6113 (void *)&cmd_lfc_set_flow_ctrl,
6114 (void *)&cmd_lfc_set_send_xon_str,
6115 (void *)&cmd_lfc_set_send_xon,
6116 (void *)&cmd_lfc_set_portid,
6121 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
6122 .f = cmd_link_flow_ctrl_set_parsed,
6123 .data = (void *)&cmd_link_flow_control_set_macfwd,
6124 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
6125 "Change mac ctrl fwd flow control parameter",
6127 (void *)&cmd_lfc_set_set,
6128 (void *)&cmd_lfc_set_flow_ctrl,
6129 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6130 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6131 (void *)&cmd_lfc_set_portid,
6136 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
6137 .f = cmd_link_flow_ctrl_set_parsed,
6138 .data = (void *)&cmd_link_flow_control_set_autoneg,
6139 .help_str = "set flow_ctrl autoneg on|off <port_id>: "
6140 "Change autoneg flow control parameter",
6142 (void *)&cmd_lfc_set_set,
6143 (void *)&cmd_lfc_set_flow_ctrl,
6144 (void *)&cmd_lfc_set_autoneg_str,
6145 (void *)&cmd_lfc_set_autoneg,
6146 (void *)&cmd_lfc_set_portid,
6152 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
6153 __attribute__((unused)) struct cmdline *cl,
6156 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
6157 cmdline_parse_inst_t *cmd = data;
6158 struct rte_eth_fc_conf fc_conf;
6164 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
6165 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
6166 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
6167 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
6169 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
6170 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
6173 /* Partial command line, retrieve current configuration */
6175 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
6177 printf("cannot get current flow ctrl parameters, return"
6178 "code = %d\n", ret);
6182 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
6183 (fc_conf.mode == RTE_FC_FULL))
6185 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
6186 (fc_conf.mode == RTE_FC_FULL))
6190 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
6191 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
6193 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
6194 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
6196 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
6198 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
6199 fc_conf.high_water = res->high_water;
6201 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
6202 fc_conf.low_water = res->low_water;
6204 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
6205 fc_conf.pause_time = res->pause_time;
6207 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
6208 fc_conf.send_xon = res->send_xon;
6210 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
6211 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
6212 fc_conf.mac_ctrl_frame_fwd = 1;
6214 fc_conf.mac_ctrl_frame_fwd = 0;
6217 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
6218 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
6220 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
6222 printf("bad flow contrl parameter, return code = %d \n", ret);
6225 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
6226 struct cmd_priority_flow_ctrl_set_result {
6227 cmdline_fixed_string_t set;
6228 cmdline_fixed_string_t pfc_ctrl;
6229 cmdline_fixed_string_t rx;
6230 cmdline_fixed_string_t rx_pfc_mode;
6231 cmdline_fixed_string_t tx;
6232 cmdline_fixed_string_t tx_pfc_mode;
6233 uint32_t high_water;
6235 uint16_t pause_time;
6241 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
6242 __attribute__((unused)) struct cmdline *cl,
6243 __attribute__((unused)) void *data)
6245 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
6246 struct rte_eth_pfc_conf pfc_conf;
6247 int rx_fc_enable, tx_fc_enable;
6251 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
6252 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
6253 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
6254 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
6256 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
6257 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
6260 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
6261 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
6262 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
6263 pfc_conf.fc.high_water = res->high_water;
6264 pfc_conf.fc.low_water = res->low_water;
6265 pfc_conf.fc.pause_time = res->pause_time;
6266 pfc_conf.priority = res->priority;
6268 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
6270 printf("bad priority flow contrl parameter, return code = %d \n", ret);
6273 cmdline_parse_token_string_t cmd_pfc_set_set =
6274 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6276 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
6277 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6278 pfc_ctrl, "pfc_ctrl");
6279 cmdline_parse_token_string_t cmd_pfc_set_rx =
6280 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6282 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
6283 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6284 rx_pfc_mode, "on#off");
6285 cmdline_parse_token_string_t cmd_pfc_set_tx =
6286 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6288 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
6289 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6290 tx_pfc_mode, "on#off");
6291 cmdline_parse_token_num_t cmd_pfc_set_high_water =
6292 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6293 high_water, UINT32);
6294 cmdline_parse_token_num_t cmd_pfc_set_low_water =
6295 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6297 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
6298 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6299 pause_time, UINT16);
6300 cmdline_parse_token_num_t cmd_pfc_set_priority =
6301 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6303 cmdline_parse_token_num_t cmd_pfc_set_portid =
6304 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6307 cmdline_parse_inst_t cmd_priority_flow_control_set = {
6308 .f = cmd_priority_flow_ctrl_set_parsed,
6310 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
6311 "<pause_time> <priority> <port_id>: "
6312 "Configure the Ethernet priority flow control",
6314 (void *)&cmd_pfc_set_set,
6315 (void *)&cmd_pfc_set_flow_ctrl,
6316 (void *)&cmd_pfc_set_rx,
6317 (void *)&cmd_pfc_set_rx_mode,
6318 (void *)&cmd_pfc_set_tx,
6319 (void *)&cmd_pfc_set_tx_mode,
6320 (void *)&cmd_pfc_set_high_water,
6321 (void *)&cmd_pfc_set_low_water,
6322 (void *)&cmd_pfc_set_pause_time,
6323 (void *)&cmd_pfc_set_priority,
6324 (void *)&cmd_pfc_set_portid,
6329 /* *** RESET CONFIGURATION *** */
6330 struct cmd_reset_result {
6331 cmdline_fixed_string_t reset;
6332 cmdline_fixed_string_t def;
6335 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
6337 __attribute__((unused)) void *data)
6339 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
6340 set_def_fwd_config();
6343 cmdline_parse_token_string_t cmd_reset_set =
6344 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
6345 cmdline_parse_token_string_t cmd_reset_def =
6346 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
6349 cmdline_parse_inst_t cmd_reset = {
6350 .f = cmd_reset_parsed,
6352 .help_str = "set default: Reset default forwarding configuration",
6354 (void *)&cmd_reset_set,
6355 (void *)&cmd_reset_def,
6360 /* *** START FORWARDING *** */
6361 struct cmd_start_result {
6362 cmdline_fixed_string_t start;
6365 cmdline_parse_token_string_t cmd_start_start =
6366 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
6368 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
6369 __attribute__((unused)) struct cmdline *cl,
6370 __attribute__((unused)) void *data)
6372 start_packet_forwarding(0);
6375 cmdline_parse_inst_t cmd_start = {
6376 .f = cmd_start_parsed,
6378 .help_str = "start: Start packet forwarding",
6380 (void *)&cmd_start_start,
6385 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
6386 struct cmd_start_tx_first_result {
6387 cmdline_fixed_string_t start;
6388 cmdline_fixed_string_t tx_first;
6392 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
6393 __attribute__((unused)) struct cmdline *cl,
6394 __attribute__((unused)) void *data)
6396 start_packet_forwarding(1);
6399 cmdline_parse_token_string_t cmd_start_tx_first_start =
6400 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
6402 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
6403 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
6404 tx_first, "tx_first");
6406 cmdline_parse_inst_t cmd_start_tx_first = {
6407 .f = cmd_start_tx_first_parsed,
6409 .help_str = "start tx_first: Start packet forwarding, "
6410 "after sending 1 burst of packets",
6412 (void *)&cmd_start_tx_first_start,
6413 (void *)&cmd_start_tx_first_tx_first,
6418 /* *** START FORWARDING WITH N TX BURST FIRST *** */
6419 struct cmd_start_tx_first_n_result {
6420 cmdline_fixed_string_t start;
6421 cmdline_fixed_string_t tx_first;
6426 cmd_start_tx_first_n_parsed(void *parsed_result,
6427 __attribute__((unused)) struct cmdline *cl,
6428 __attribute__((unused)) void *data)
6430 struct cmd_start_tx_first_n_result *res = parsed_result;
6432 start_packet_forwarding(res->tx_num);
6435 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
6436 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
6438 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
6439 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
6440 tx_first, "tx_first");
6441 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
6442 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
6445 cmdline_parse_inst_t cmd_start_tx_first_n = {
6446 .f = cmd_start_tx_first_n_parsed,
6448 .help_str = "start tx_first <num>: "
6449 "packet forwarding, after sending <num> bursts of packets",
6451 (void *)&cmd_start_tx_first_n_start,
6452 (void *)&cmd_start_tx_first_n_tx_first,
6453 (void *)&cmd_start_tx_first_n_tx_num,
6458 /* *** SET LINK UP *** */
6459 struct cmd_set_link_up_result {
6460 cmdline_fixed_string_t set;
6461 cmdline_fixed_string_t link_up;
6462 cmdline_fixed_string_t port;
6466 cmdline_parse_token_string_t cmd_set_link_up_set =
6467 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
6468 cmdline_parse_token_string_t cmd_set_link_up_link_up =
6469 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
6471 cmdline_parse_token_string_t cmd_set_link_up_port =
6472 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
6473 cmdline_parse_token_num_t cmd_set_link_up_port_id =
6474 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT16);
6476 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result,
6477 __attribute__((unused)) struct cmdline *cl,
6478 __attribute__((unused)) void *data)
6480 struct cmd_set_link_up_result *res = parsed_result;
6481 dev_set_link_up(res->port_id);
6484 cmdline_parse_inst_t cmd_set_link_up = {
6485 .f = cmd_set_link_up_parsed,
6487 .help_str = "set link-up port <port id>",
6489 (void *)&cmd_set_link_up_set,
6490 (void *)&cmd_set_link_up_link_up,
6491 (void *)&cmd_set_link_up_port,
6492 (void *)&cmd_set_link_up_port_id,
6497 /* *** SET LINK DOWN *** */
6498 struct cmd_set_link_down_result {
6499 cmdline_fixed_string_t set;
6500 cmdline_fixed_string_t link_down;
6501 cmdline_fixed_string_t port;
6505 cmdline_parse_token_string_t cmd_set_link_down_set =
6506 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
6507 cmdline_parse_token_string_t cmd_set_link_down_link_down =
6508 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
6510 cmdline_parse_token_string_t cmd_set_link_down_port =
6511 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
6512 cmdline_parse_token_num_t cmd_set_link_down_port_id =
6513 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT16);
6515 static void cmd_set_link_down_parsed(
6516 __attribute__((unused)) void *parsed_result,
6517 __attribute__((unused)) struct cmdline *cl,
6518 __attribute__((unused)) void *data)
6520 struct cmd_set_link_down_result *res = parsed_result;
6521 dev_set_link_down(res->port_id);
6524 cmdline_parse_inst_t cmd_set_link_down = {
6525 .f = cmd_set_link_down_parsed,
6527 .help_str = "set link-down port <port id>",
6529 (void *)&cmd_set_link_down_set,
6530 (void *)&cmd_set_link_down_link_down,
6531 (void *)&cmd_set_link_down_port,
6532 (void *)&cmd_set_link_down_port_id,
6537 /* *** SHOW CFG *** */
6538 struct cmd_showcfg_result {
6539 cmdline_fixed_string_t show;
6540 cmdline_fixed_string_t cfg;
6541 cmdline_fixed_string_t what;
6544 static void cmd_showcfg_parsed(void *parsed_result,
6545 __attribute__((unused)) struct cmdline *cl,
6546 __attribute__((unused)) void *data)
6548 struct cmd_showcfg_result *res = parsed_result;
6549 if (!strcmp(res->what, "rxtx"))
6550 rxtx_config_display();
6551 else if (!strcmp(res->what, "cores"))
6552 fwd_lcores_config_display();
6553 else if (!strcmp(res->what, "fwd"))
6554 pkt_fwd_config_display(&cur_fwd_config);
6555 else if (!strcmp(res->what, "txpkts"))
6556 show_tx_pkt_segments();
6559 cmdline_parse_token_string_t cmd_showcfg_show =
6560 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
6561 cmdline_parse_token_string_t cmd_showcfg_port =
6562 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
6563 cmdline_parse_token_string_t cmd_showcfg_what =
6564 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
6565 "rxtx#cores#fwd#txpkts");
6567 cmdline_parse_inst_t cmd_showcfg = {
6568 .f = cmd_showcfg_parsed,
6570 .help_str = "show config rxtx|cores|fwd|txpkts",
6572 (void *)&cmd_showcfg_show,
6573 (void *)&cmd_showcfg_port,
6574 (void *)&cmd_showcfg_what,
6579 /* *** SHOW ALL PORT INFO *** */
6580 struct cmd_showportall_result {
6581 cmdline_fixed_string_t show;
6582 cmdline_fixed_string_t port;
6583 cmdline_fixed_string_t what;
6584 cmdline_fixed_string_t all;
6587 static void cmd_showportall_parsed(void *parsed_result,
6588 __attribute__((unused)) struct cmdline *cl,
6589 __attribute__((unused)) void *data)
6593 struct cmd_showportall_result *res = parsed_result;
6594 if (!strcmp(res->show, "clear")) {
6595 if (!strcmp(res->what, "stats"))
6596 RTE_ETH_FOREACH_DEV(i)
6598 else if (!strcmp(res->what, "xstats"))
6599 RTE_ETH_FOREACH_DEV(i)
6600 nic_xstats_clear(i);
6601 } else if (!strcmp(res->what, "info"))
6602 RTE_ETH_FOREACH_DEV(i)
6603 port_infos_display(i);
6604 else if (!strcmp(res->what, "stats"))
6605 RTE_ETH_FOREACH_DEV(i)
6606 nic_stats_display(i);
6607 else if (!strcmp(res->what, "xstats"))
6608 RTE_ETH_FOREACH_DEV(i)
6609 nic_xstats_display(i);
6610 else if (!strcmp(res->what, "fdir"))
6611 RTE_ETH_FOREACH_DEV(i)
6613 else if (!strcmp(res->what, "stat_qmap"))
6614 RTE_ETH_FOREACH_DEV(i)
6615 nic_stats_mapping_display(i);
6616 else if (!strcmp(res->what, "dcb_tc"))
6617 RTE_ETH_FOREACH_DEV(i)
6618 port_dcb_info_display(i);
6619 else if (!strcmp(res->what, "cap"))
6620 RTE_ETH_FOREACH_DEV(i)
6621 port_offload_cap_display(i);
6624 cmdline_parse_token_string_t cmd_showportall_show =
6625 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
6627 cmdline_parse_token_string_t cmd_showportall_port =
6628 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
6629 cmdline_parse_token_string_t cmd_showportall_what =
6630 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
6631 "info#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
6632 cmdline_parse_token_string_t cmd_showportall_all =
6633 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
6634 cmdline_parse_inst_t cmd_showportall = {
6635 .f = cmd_showportall_parsed,
6637 .help_str = "show|clear port "
6638 "info|stats|xstats|fdir|stat_qmap|dcb_tc|cap all",
6640 (void *)&cmd_showportall_show,
6641 (void *)&cmd_showportall_port,
6642 (void *)&cmd_showportall_what,
6643 (void *)&cmd_showportall_all,
6648 /* *** SHOW PORT INFO *** */
6649 struct cmd_showport_result {
6650 cmdline_fixed_string_t show;
6651 cmdline_fixed_string_t port;
6652 cmdline_fixed_string_t what;
6656 static void cmd_showport_parsed(void *parsed_result,
6657 __attribute__((unused)) struct cmdline *cl,
6658 __attribute__((unused)) void *data)
6660 struct cmd_showport_result *res = parsed_result;
6661 if (!strcmp(res->show, "clear")) {
6662 if (!strcmp(res->what, "stats"))
6663 nic_stats_clear(res->portnum);
6664 else if (!strcmp(res->what, "xstats"))
6665 nic_xstats_clear(res->portnum);
6666 } else if (!strcmp(res->what, "info"))
6667 port_infos_display(res->portnum);
6668 else if (!strcmp(res->what, "stats"))
6669 nic_stats_display(res->portnum);
6670 else if (!strcmp(res->what, "xstats"))
6671 nic_xstats_display(res->portnum);
6672 else if (!strcmp(res->what, "fdir"))
6673 fdir_get_infos(res->portnum);
6674 else if (!strcmp(res->what, "stat_qmap"))
6675 nic_stats_mapping_display(res->portnum);
6676 else if (!strcmp(res->what, "dcb_tc"))
6677 port_dcb_info_display(res->portnum);
6678 else if (!strcmp(res->what, "cap"))
6679 port_offload_cap_display(res->portnum);
6682 cmdline_parse_token_string_t cmd_showport_show =
6683 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
6685 cmdline_parse_token_string_t cmd_showport_port =
6686 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
6687 cmdline_parse_token_string_t cmd_showport_what =
6688 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
6689 "info#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
6690 cmdline_parse_token_num_t cmd_showport_portnum =
6691 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT16);
6693 cmdline_parse_inst_t cmd_showport = {
6694 .f = cmd_showport_parsed,
6696 .help_str = "show|clear port "
6697 "info|stats|xstats|fdir|stat_qmap|dcb_tc|cap "
6700 (void *)&cmd_showport_show,
6701 (void *)&cmd_showport_port,
6702 (void *)&cmd_showport_what,
6703 (void *)&cmd_showport_portnum,
6708 /* *** SHOW QUEUE INFO *** */
6709 struct cmd_showqueue_result {
6710 cmdline_fixed_string_t show;
6711 cmdline_fixed_string_t type;
6712 cmdline_fixed_string_t what;
6718 cmd_showqueue_parsed(void *parsed_result,
6719 __attribute__((unused)) struct cmdline *cl,
6720 __attribute__((unused)) void *data)
6722 struct cmd_showqueue_result *res = parsed_result;
6724 if (!strcmp(res->type, "rxq"))
6725 rx_queue_infos_display(res->portnum, res->queuenum);
6726 else if (!strcmp(res->type, "txq"))
6727 tx_queue_infos_display(res->portnum, res->queuenum);
6730 cmdline_parse_token_string_t cmd_showqueue_show =
6731 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
6732 cmdline_parse_token_string_t cmd_showqueue_type =
6733 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
6734 cmdline_parse_token_string_t cmd_showqueue_what =
6735 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
6736 cmdline_parse_token_num_t cmd_showqueue_portnum =
6737 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, UINT16);
6738 cmdline_parse_token_num_t cmd_showqueue_queuenum =
6739 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, UINT16);
6741 cmdline_parse_inst_t cmd_showqueue = {
6742 .f = cmd_showqueue_parsed,
6744 .help_str = "show rxq|txq info <port_id> <queue_id>",
6746 (void *)&cmd_showqueue_show,
6747 (void *)&cmd_showqueue_type,
6748 (void *)&cmd_showqueue_what,
6749 (void *)&cmd_showqueue_portnum,
6750 (void *)&cmd_showqueue_queuenum,
6755 /* *** READ PORT REGISTER *** */
6756 struct cmd_read_reg_result {
6757 cmdline_fixed_string_t read;
6758 cmdline_fixed_string_t reg;
6764 cmd_read_reg_parsed(void *parsed_result,
6765 __attribute__((unused)) struct cmdline *cl,
6766 __attribute__((unused)) void *data)
6768 struct cmd_read_reg_result *res = parsed_result;
6769 port_reg_display(res->port_id, res->reg_off);
6772 cmdline_parse_token_string_t cmd_read_reg_read =
6773 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
6774 cmdline_parse_token_string_t cmd_read_reg_reg =
6775 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
6776 cmdline_parse_token_num_t cmd_read_reg_port_id =
6777 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT16);
6778 cmdline_parse_token_num_t cmd_read_reg_reg_off =
6779 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
6781 cmdline_parse_inst_t cmd_read_reg = {
6782 .f = cmd_read_reg_parsed,
6784 .help_str = "read reg <port_id> <reg_off>",
6786 (void *)&cmd_read_reg_read,
6787 (void *)&cmd_read_reg_reg,
6788 (void *)&cmd_read_reg_port_id,
6789 (void *)&cmd_read_reg_reg_off,
6794 /* *** READ PORT REGISTER BIT FIELD *** */
6795 struct cmd_read_reg_bit_field_result {
6796 cmdline_fixed_string_t read;
6797 cmdline_fixed_string_t regfield;
6805 cmd_read_reg_bit_field_parsed(void *parsed_result,
6806 __attribute__((unused)) struct cmdline *cl,
6807 __attribute__((unused)) void *data)
6809 struct cmd_read_reg_bit_field_result *res = parsed_result;
6810 port_reg_bit_field_display(res->port_id, res->reg_off,
6811 res->bit1_pos, res->bit2_pos);
6814 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
6815 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
6817 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
6818 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
6819 regfield, "regfield");
6820 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
6821 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
6823 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
6824 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
6826 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
6827 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
6829 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
6830 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
6833 cmdline_parse_inst_t cmd_read_reg_bit_field = {
6834 .f = cmd_read_reg_bit_field_parsed,
6836 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
6837 "Read register bit field between bit_x and bit_y included",
6839 (void *)&cmd_read_reg_bit_field_read,
6840 (void *)&cmd_read_reg_bit_field_regfield,
6841 (void *)&cmd_read_reg_bit_field_port_id,
6842 (void *)&cmd_read_reg_bit_field_reg_off,
6843 (void *)&cmd_read_reg_bit_field_bit1_pos,
6844 (void *)&cmd_read_reg_bit_field_bit2_pos,
6849 /* *** READ PORT REGISTER BIT *** */
6850 struct cmd_read_reg_bit_result {
6851 cmdline_fixed_string_t read;
6852 cmdline_fixed_string_t regbit;
6859 cmd_read_reg_bit_parsed(void *parsed_result,
6860 __attribute__((unused)) struct cmdline *cl,
6861 __attribute__((unused)) void *data)
6863 struct cmd_read_reg_bit_result *res = parsed_result;
6864 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
6867 cmdline_parse_token_string_t cmd_read_reg_bit_read =
6868 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
6869 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
6870 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
6872 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
6873 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT16);
6874 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
6875 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
6876 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
6877 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
6879 cmdline_parse_inst_t cmd_read_reg_bit = {
6880 .f = cmd_read_reg_bit_parsed,
6882 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
6884 (void *)&cmd_read_reg_bit_read,
6885 (void *)&cmd_read_reg_bit_regbit,
6886 (void *)&cmd_read_reg_bit_port_id,
6887 (void *)&cmd_read_reg_bit_reg_off,
6888 (void *)&cmd_read_reg_bit_bit_pos,
6893 /* *** WRITE PORT REGISTER *** */
6894 struct cmd_write_reg_result {
6895 cmdline_fixed_string_t write;
6896 cmdline_fixed_string_t reg;
6903 cmd_write_reg_parsed(void *parsed_result,
6904 __attribute__((unused)) struct cmdline *cl,
6905 __attribute__((unused)) void *data)
6907 struct cmd_write_reg_result *res = parsed_result;
6908 port_reg_set(res->port_id, res->reg_off, res->value);
6911 cmdline_parse_token_string_t cmd_write_reg_write =
6912 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
6913 cmdline_parse_token_string_t cmd_write_reg_reg =
6914 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
6915 cmdline_parse_token_num_t cmd_write_reg_port_id =
6916 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT16);
6917 cmdline_parse_token_num_t cmd_write_reg_reg_off =
6918 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
6919 cmdline_parse_token_num_t cmd_write_reg_value =
6920 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
6922 cmdline_parse_inst_t cmd_write_reg = {
6923 .f = cmd_write_reg_parsed,
6925 .help_str = "write reg <port_id> <reg_off> <reg_value>",
6927 (void *)&cmd_write_reg_write,
6928 (void *)&cmd_write_reg_reg,
6929 (void *)&cmd_write_reg_port_id,
6930 (void *)&cmd_write_reg_reg_off,
6931 (void *)&cmd_write_reg_value,
6936 /* *** WRITE PORT REGISTER BIT FIELD *** */
6937 struct cmd_write_reg_bit_field_result {
6938 cmdline_fixed_string_t write;
6939 cmdline_fixed_string_t regfield;
6948 cmd_write_reg_bit_field_parsed(void *parsed_result,
6949 __attribute__((unused)) struct cmdline *cl,
6950 __attribute__((unused)) void *data)
6952 struct cmd_write_reg_bit_field_result *res = parsed_result;
6953 port_reg_bit_field_set(res->port_id, res->reg_off,
6954 res->bit1_pos, res->bit2_pos, res->value);
6957 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
6958 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
6960 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
6961 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
6962 regfield, "regfield");
6963 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
6964 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
6966 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
6967 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
6969 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
6970 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
6972 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
6973 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
6975 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
6976 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
6979 cmdline_parse_inst_t cmd_write_reg_bit_field = {
6980 .f = cmd_write_reg_bit_field_parsed,
6982 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
6984 "Set register bit field between bit_x and bit_y included",
6986 (void *)&cmd_write_reg_bit_field_write,
6987 (void *)&cmd_write_reg_bit_field_regfield,
6988 (void *)&cmd_write_reg_bit_field_port_id,
6989 (void *)&cmd_write_reg_bit_field_reg_off,
6990 (void *)&cmd_write_reg_bit_field_bit1_pos,
6991 (void *)&cmd_write_reg_bit_field_bit2_pos,
6992 (void *)&cmd_write_reg_bit_field_value,
6997 /* *** WRITE PORT REGISTER BIT *** */
6998 struct cmd_write_reg_bit_result {
6999 cmdline_fixed_string_t write;
7000 cmdline_fixed_string_t regbit;
7008 cmd_write_reg_bit_parsed(void *parsed_result,
7009 __attribute__((unused)) struct cmdline *cl,
7010 __attribute__((unused)) void *data)
7012 struct cmd_write_reg_bit_result *res = parsed_result;
7013 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
7016 cmdline_parse_token_string_t cmd_write_reg_bit_write =
7017 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
7019 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
7020 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
7022 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
7023 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT16);
7024 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
7025 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
7026 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
7027 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
7028 cmdline_parse_token_num_t cmd_write_reg_bit_value =
7029 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
7031 cmdline_parse_inst_t cmd_write_reg_bit = {
7032 .f = cmd_write_reg_bit_parsed,
7034 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
7037 (void *)&cmd_write_reg_bit_write,
7038 (void *)&cmd_write_reg_bit_regbit,
7039 (void *)&cmd_write_reg_bit_port_id,
7040 (void *)&cmd_write_reg_bit_reg_off,
7041 (void *)&cmd_write_reg_bit_bit_pos,
7042 (void *)&cmd_write_reg_bit_value,
7047 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
7048 struct cmd_read_rxd_txd_result {
7049 cmdline_fixed_string_t read;
7050 cmdline_fixed_string_t rxd_txd;
7057 cmd_read_rxd_txd_parsed(void *parsed_result,
7058 __attribute__((unused)) struct cmdline *cl,
7059 __attribute__((unused)) void *data)
7061 struct cmd_read_rxd_txd_result *res = parsed_result;
7063 if (!strcmp(res->rxd_txd, "rxd"))
7064 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
7065 else if (!strcmp(res->rxd_txd, "txd"))
7066 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
7069 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
7070 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
7071 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
7072 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
7074 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
7075 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT16);
7076 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
7077 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
7078 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
7079 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
7081 cmdline_parse_inst_t cmd_read_rxd_txd = {
7082 .f = cmd_read_rxd_txd_parsed,
7084 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
7086 (void *)&cmd_read_rxd_txd_read,
7087 (void *)&cmd_read_rxd_txd_rxd_txd,
7088 (void *)&cmd_read_rxd_txd_port_id,
7089 (void *)&cmd_read_rxd_txd_queue_id,
7090 (void *)&cmd_read_rxd_txd_desc_id,
7096 struct cmd_quit_result {
7097 cmdline_fixed_string_t quit;
7100 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
7102 __attribute__((unused)) void *data)
7108 cmdline_parse_token_string_t cmd_quit_quit =
7109 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
7111 cmdline_parse_inst_t cmd_quit = {
7112 .f = cmd_quit_parsed,
7114 .help_str = "quit: Exit application",
7116 (void *)&cmd_quit_quit,
7121 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
7122 struct cmd_mac_addr_result {
7123 cmdline_fixed_string_t mac_addr_cmd;
7124 cmdline_fixed_string_t what;
7126 struct ether_addr address;
7129 static void cmd_mac_addr_parsed(void *parsed_result,
7130 __attribute__((unused)) struct cmdline *cl,
7131 __attribute__((unused)) void *data)
7133 struct cmd_mac_addr_result *res = parsed_result;
7136 if (strcmp(res->what, "add") == 0)
7137 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
7138 else if (strcmp(res->what, "set") == 0)
7139 ret = rte_eth_dev_default_mac_addr_set(res->port_num,
7142 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
7144 /* check the return value and print it if is < 0 */
7146 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
7150 cmdline_parse_token_string_t cmd_mac_addr_cmd =
7151 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
7153 cmdline_parse_token_string_t cmd_mac_addr_what =
7154 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
7156 cmdline_parse_token_num_t cmd_mac_addr_portnum =
7157 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num,
7159 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
7160 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
7162 cmdline_parse_inst_t cmd_mac_addr = {
7163 .f = cmd_mac_addr_parsed,
7165 .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
7166 "Add/Remove/Set MAC address on port_id",
7168 (void *)&cmd_mac_addr_cmd,
7169 (void *)&cmd_mac_addr_what,
7170 (void *)&cmd_mac_addr_portnum,
7171 (void *)&cmd_mac_addr_addr,
7177 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
7178 struct cmd_set_qmap_result {
7179 cmdline_fixed_string_t set;
7180 cmdline_fixed_string_t qmap;
7181 cmdline_fixed_string_t what;
7188 cmd_set_qmap_parsed(void *parsed_result,
7189 __attribute__((unused)) struct cmdline *cl,
7190 __attribute__((unused)) void *data)
7192 struct cmd_set_qmap_result *res = parsed_result;
7193 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
7195 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
7198 cmdline_parse_token_string_t cmd_setqmap_set =
7199 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7201 cmdline_parse_token_string_t cmd_setqmap_qmap =
7202 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7204 cmdline_parse_token_string_t cmd_setqmap_what =
7205 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7207 cmdline_parse_token_num_t cmd_setqmap_portid =
7208 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7210 cmdline_parse_token_num_t cmd_setqmap_queueid =
7211 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7213 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
7214 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7217 cmdline_parse_inst_t cmd_set_qmap = {
7218 .f = cmd_set_qmap_parsed,
7220 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
7221 "Set statistics mapping value on tx|rx queue_id of port_id",
7223 (void *)&cmd_setqmap_set,
7224 (void *)&cmd_setqmap_qmap,
7225 (void *)&cmd_setqmap_what,
7226 (void *)&cmd_setqmap_portid,
7227 (void *)&cmd_setqmap_queueid,
7228 (void *)&cmd_setqmap_mapvalue,
7233 /* *** SET OPTION TO HIDE ZERO VALUES FOR XSTATS DISPLAY *** */
7234 struct cmd_set_xstats_hide_zero_result {
7235 cmdline_fixed_string_t keyword;
7236 cmdline_fixed_string_t name;
7237 cmdline_fixed_string_t on_off;
7241 cmd_set_xstats_hide_zero_parsed(void *parsed_result,
7242 __attribute__((unused)) struct cmdline *cl,
7243 __attribute__((unused)) void *data)
7245 struct cmd_set_xstats_hide_zero_result *res;
7246 uint16_t on_off = 0;
7248 res = parsed_result;
7249 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
7250 set_xstats_hide_zero(on_off);
7253 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_keyword =
7254 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
7256 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_name =
7257 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
7258 name, "xstats-hide-zero");
7259 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_on_off =
7260 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
7263 cmdline_parse_inst_t cmd_set_xstats_hide_zero = {
7264 .f = cmd_set_xstats_hide_zero_parsed,
7266 .help_str = "set xstats-hide-zero on|off",
7268 (void *)&cmd_set_xstats_hide_zero_keyword,
7269 (void *)&cmd_set_xstats_hide_zero_name,
7270 (void *)&cmd_set_xstats_hide_zero_on_off,
7275 /* *** CONFIGURE UNICAST HASH TABLE *** */
7276 struct cmd_set_uc_hash_table {
7277 cmdline_fixed_string_t set;
7278 cmdline_fixed_string_t port;
7280 cmdline_fixed_string_t what;
7281 struct ether_addr address;
7282 cmdline_fixed_string_t mode;
7286 cmd_set_uc_hash_parsed(void *parsed_result,
7287 __attribute__((unused)) struct cmdline *cl,
7288 __attribute__((unused)) void *data)
7291 struct cmd_set_uc_hash_table *res = parsed_result;
7293 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7295 if (strcmp(res->what, "uta") == 0)
7296 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
7297 &res->address,(uint8_t)is_on);
7299 printf("bad unicast hash table parameter, return code = %d \n", ret);
7303 cmdline_parse_token_string_t cmd_set_uc_hash_set =
7304 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7306 cmdline_parse_token_string_t cmd_set_uc_hash_port =
7307 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7309 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
7310 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
7312 cmdline_parse_token_string_t cmd_set_uc_hash_what =
7313 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7315 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
7316 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
7318 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
7319 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7322 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
7323 .f = cmd_set_uc_hash_parsed,
7325 .help_str = "set port <port_id> uta <mac_addr> on|off)",
7327 (void *)&cmd_set_uc_hash_set,
7328 (void *)&cmd_set_uc_hash_port,
7329 (void *)&cmd_set_uc_hash_portid,
7330 (void *)&cmd_set_uc_hash_what,
7331 (void *)&cmd_set_uc_hash_mac,
7332 (void *)&cmd_set_uc_hash_mode,
7337 struct cmd_set_uc_all_hash_table {
7338 cmdline_fixed_string_t set;
7339 cmdline_fixed_string_t port;
7341 cmdline_fixed_string_t what;
7342 cmdline_fixed_string_t value;
7343 cmdline_fixed_string_t mode;
7347 cmd_set_uc_all_hash_parsed(void *parsed_result,
7348 __attribute__((unused)) struct cmdline *cl,
7349 __attribute__((unused)) void *data)
7352 struct cmd_set_uc_all_hash_table *res = parsed_result;
7354 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7356 if ((strcmp(res->what, "uta") == 0) &&
7357 (strcmp(res->value, "all") == 0))
7358 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
7360 printf("bad unicast hash table parameter,"
7361 "return code = %d \n", ret);
7364 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
7365 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7367 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
7368 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7370 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
7371 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
7373 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
7374 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7376 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
7377 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7379 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
7380 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7383 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
7384 .f = cmd_set_uc_all_hash_parsed,
7386 .help_str = "set port <port_id> uta all on|off",
7388 (void *)&cmd_set_uc_all_hash_set,
7389 (void *)&cmd_set_uc_all_hash_port,
7390 (void *)&cmd_set_uc_all_hash_portid,
7391 (void *)&cmd_set_uc_all_hash_what,
7392 (void *)&cmd_set_uc_all_hash_value,
7393 (void *)&cmd_set_uc_all_hash_mode,
7398 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
7399 struct cmd_set_vf_macvlan_filter {
7400 cmdline_fixed_string_t set;
7401 cmdline_fixed_string_t port;
7403 cmdline_fixed_string_t vf;
7405 struct ether_addr address;
7406 cmdline_fixed_string_t filter_type;
7407 cmdline_fixed_string_t mode;
7411 cmd_set_vf_macvlan_parsed(void *parsed_result,
7412 __attribute__((unused)) struct cmdline *cl,
7413 __attribute__((unused)) void *data)
7416 struct cmd_set_vf_macvlan_filter *res = parsed_result;
7417 struct rte_eth_mac_filter filter;
7419 memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
7421 rte_memcpy(&filter.mac_addr, &res->address, ETHER_ADDR_LEN);
7423 /* set VF MAC filter */
7427 filter.dst_id = res->vf_id;
7429 if (!strcmp(res->filter_type, "exact-mac"))
7430 filter.filter_type = RTE_MAC_PERFECT_MATCH;
7431 else if (!strcmp(res->filter_type, "exact-mac-vlan"))
7432 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
7433 else if (!strcmp(res->filter_type, "hashmac"))
7434 filter.filter_type = RTE_MAC_HASH_MATCH;
7435 else if (!strcmp(res->filter_type, "hashmac-vlan"))
7436 filter.filter_type = RTE_MACVLAN_HASH_MATCH;
7438 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7441 ret = rte_eth_dev_filter_ctrl(res->port_id,
7442 RTE_ETH_FILTER_MACVLAN,
7446 ret = rte_eth_dev_filter_ctrl(res->port_id,
7447 RTE_ETH_FILTER_MACVLAN,
7448 RTE_ETH_FILTER_DELETE,
7452 printf("bad set MAC hash parameter, return code = %d\n", ret);
7456 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
7457 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7459 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
7460 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7462 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
7463 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7465 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
7466 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7468 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
7469 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7471 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
7472 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7474 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
7475 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7476 filter_type, "exact-mac#exact-mac-vlan"
7477 "#hashmac#hashmac-vlan");
7478 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
7479 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7482 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
7483 .f = cmd_set_vf_macvlan_parsed,
7485 .help_str = "set port <port_id> vf <vf_id> <mac_addr> "
7486 "exact-mac|exact-mac-vlan|hashmac|hashmac-vlan on|off: "
7487 "Exact match rule: exact match of MAC or MAC and VLAN; "
7488 "hash match rule: hash match of MAC and exact match of VLAN",
7490 (void *)&cmd_set_vf_macvlan_set,
7491 (void *)&cmd_set_vf_macvlan_port,
7492 (void *)&cmd_set_vf_macvlan_portid,
7493 (void *)&cmd_set_vf_macvlan_vf,
7494 (void *)&cmd_set_vf_macvlan_vf_id,
7495 (void *)&cmd_set_vf_macvlan_mac,
7496 (void *)&cmd_set_vf_macvlan_filter_type,
7497 (void *)&cmd_set_vf_macvlan_mode,
7502 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
7503 struct cmd_set_vf_traffic {
7504 cmdline_fixed_string_t set;
7505 cmdline_fixed_string_t port;
7507 cmdline_fixed_string_t vf;
7509 cmdline_fixed_string_t what;
7510 cmdline_fixed_string_t mode;
7514 cmd_set_vf_traffic_parsed(void *parsed_result,
7515 __attribute__((unused)) struct cmdline *cl,
7516 __attribute__((unused)) void *data)
7518 struct cmd_set_vf_traffic *res = parsed_result;
7519 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
7520 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7522 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
7525 cmdline_parse_token_string_t cmd_setvf_traffic_set =
7526 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7528 cmdline_parse_token_string_t cmd_setvf_traffic_port =
7529 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7531 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
7532 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
7534 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
7535 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7537 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
7538 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
7540 cmdline_parse_token_string_t cmd_setvf_traffic_what =
7541 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7543 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
7544 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7547 cmdline_parse_inst_t cmd_set_vf_traffic = {
7548 .f = cmd_set_vf_traffic_parsed,
7550 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
7552 (void *)&cmd_setvf_traffic_set,
7553 (void *)&cmd_setvf_traffic_port,
7554 (void *)&cmd_setvf_traffic_portid,
7555 (void *)&cmd_setvf_traffic_vf,
7556 (void *)&cmd_setvf_traffic_vfid,
7557 (void *)&cmd_setvf_traffic_what,
7558 (void *)&cmd_setvf_traffic_mode,
7563 /* *** CONFIGURE VF RECEIVE MODE *** */
7564 struct cmd_set_vf_rxmode {
7565 cmdline_fixed_string_t set;
7566 cmdline_fixed_string_t port;
7568 cmdline_fixed_string_t vf;
7570 cmdline_fixed_string_t what;
7571 cmdline_fixed_string_t mode;
7572 cmdline_fixed_string_t on;
7576 cmd_set_vf_rxmode_parsed(void *parsed_result,
7577 __attribute__((unused)) struct cmdline *cl,
7578 __attribute__((unused)) void *data)
7581 uint16_t rx_mode = 0;
7582 struct cmd_set_vf_rxmode *res = parsed_result;
7584 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
7585 if (!strcmp(res->what,"rxmode")) {
7586 if (!strcmp(res->mode, "AUPE"))
7587 rx_mode |= ETH_VMDQ_ACCEPT_UNTAG;
7588 else if (!strcmp(res->mode, "ROPE"))
7589 rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC;
7590 else if (!strcmp(res->mode, "BAM"))
7591 rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST;
7592 else if (!strncmp(res->mode, "MPE",3))
7593 rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST;
7596 RTE_SET_USED(is_on);
7598 #ifdef RTE_LIBRTE_IXGBE_PMD
7599 if (ret == -ENOTSUP)
7600 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id,
7601 rx_mode, (uint8_t)is_on);
7603 #ifdef RTE_LIBRTE_BNXT_PMD
7604 if (ret == -ENOTSUP)
7605 ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id,
7606 rx_mode, (uint8_t)is_on);
7609 printf("bad VF receive mode parameter, return code = %d \n",
7613 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
7614 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7616 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
7617 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7619 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
7620 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
7622 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
7623 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7625 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
7626 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
7628 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
7629 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7631 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
7632 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7633 mode, "AUPE#ROPE#BAM#MPE");
7634 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
7635 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7638 cmdline_parse_inst_t cmd_set_vf_rxmode = {
7639 .f = cmd_set_vf_rxmode_parsed,
7641 .help_str = "set port <port_id> vf <vf_id> rxmode "
7642 "AUPE|ROPE|BAM|MPE on|off",
7644 (void *)&cmd_set_vf_rxmode_set,
7645 (void *)&cmd_set_vf_rxmode_port,
7646 (void *)&cmd_set_vf_rxmode_portid,
7647 (void *)&cmd_set_vf_rxmode_vf,
7648 (void *)&cmd_set_vf_rxmode_vfid,
7649 (void *)&cmd_set_vf_rxmode_what,
7650 (void *)&cmd_set_vf_rxmode_mode,
7651 (void *)&cmd_set_vf_rxmode_on,
7656 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
7657 struct cmd_vf_mac_addr_result {
7658 cmdline_fixed_string_t mac_addr_cmd;
7659 cmdline_fixed_string_t what;
7660 cmdline_fixed_string_t port;
7662 cmdline_fixed_string_t vf;
7664 struct ether_addr address;
7667 static void cmd_vf_mac_addr_parsed(void *parsed_result,
7668 __attribute__((unused)) struct cmdline *cl,
7669 __attribute__((unused)) void *data)
7671 struct cmd_vf_mac_addr_result *res = parsed_result;
7674 if (strcmp(res->what, "add") != 0)
7677 #ifdef RTE_LIBRTE_I40E_PMD
7678 if (ret == -ENOTSUP)
7679 ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num,
7682 #ifdef RTE_LIBRTE_BNXT_PMD
7683 if (ret == -ENOTSUP)
7684 ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address,
7689 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
7693 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
7694 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7695 mac_addr_cmd,"mac_addr");
7696 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
7697 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7699 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
7700 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7702 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
7703 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
7705 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
7706 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7708 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
7709 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
7711 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
7712 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
7715 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
7716 .f = cmd_vf_mac_addr_parsed,
7718 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
7719 "Add MAC address filtering for a VF on port_id",
7721 (void *)&cmd_vf_mac_addr_cmd,
7722 (void *)&cmd_vf_mac_addr_what,
7723 (void *)&cmd_vf_mac_addr_port,
7724 (void *)&cmd_vf_mac_addr_portnum,
7725 (void *)&cmd_vf_mac_addr_vf,
7726 (void *)&cmd_vf_mac_addr_vfnum,
7727 (void *)&cmd_vf_mac_addr_addr,
7732 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
7733 struct cmd_vf_rx_vlan_filter {
7734 cmdline_fixed_string_t rx_vlan;
7735 cmdline_fixed_string_t what;
7737 cmdline_fixed_string_t port;
7739 cmdline_fixed_string_t vf;
7744 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
7745 __attribute__((unused)) struct cmdline *cl,
7746 __attribute__((unused)) void *data)
7748 struct cmd_vf_rx_vlan_filter *res = parsed_result;
7751 __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
7753 #ifdef RTE_LIBRTE_IXGBE_PMD
7754 if (ret == -ENOTSUP)
7755 ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
7756 res->vlan_id, res->vf_mask, is_add);
7758 #ifdef RTE_LIBRTE_I40E_PMD
7759 if (ret == -ENOTSUP)
7760 ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
7761 res->vlan_id, res->vf_mask, is_add);
7763 #ifdef RTE_LIBRTE_BNXT_PMD
7764 if (ret == -ENOTSUP)
7765 ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id,
7766 res->vlan_id, res->vf_mask, is_add);
7773 printf("invalid vlan_id %d or vf_mask %"PRIu64"\n",
7774 res->vlan_id, res->vf_mask);
7777 printf("invalid port_id %d\n", res->port_id);
7780 printf("function not implemented or supported\n");
7783 printf("programming error: (%s)\n", strerror(-ret));
7787 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
7788 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7789 rx_vlan, "rx_vlan");
7790 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
7791 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7793 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
7794 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7796 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
7797 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7799 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
7800 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7802 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
7803 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7805 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
7806 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
7809 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
7810 .f = cmd_vf_rx_vlan_filter_parsed,
7812 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
7813 "(vf_mask = hexadecimal VF mask)",
7815 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
7816 (void *)&cmd_vf_rx_vlan_filter_what,
7817 (void *)&cmd_vf_rx_vlan_filter_vlanid,
7818 (void *)&cmd_vf_rx_vlan_filter_port,
7819 (void *)&cmd_vf_rx_vlan_filter_portid,
7820 (void *)&cmd_vf_rx_vlan_filter_vf,
7821 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
7826 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
7827 struct cmd_queue_rate_limit_result {
7828 cmdline_fixed_string_t set;
7829 cmdline_fixed_string_t port;
7831 cmdline_fixed_string_t queue;
7833 cmdline_fixed_string_t rate;
7837 static void cmd_queue_rate_limit_parsed(void *parsed_result,
7838 __attribute__((unused)) struct cmdline *cl,
7839 __attribute__((unused)) void *data)
7841 struct cmd_queue_rate_limit_result *res = parsed_result;
7844 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
7845 && (strcmp(res->queue, "queue") == 0)
7846 && (strcmp(res->rate, "rate") == 0))
7847 ret = set_queue_rate_limit(res->port_num, res->queue_num,
7850 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
7854 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
7855 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7857 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
7858 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7860 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
7861 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
7863 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
7864 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7866 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
7867 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
7869 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
7870 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
7872 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
7873 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
7876 cmdline_parse_inst_t cmd_queue_rate_limit = {
7877 .f = cmd_queue_rate_limit_parsed,
7879 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
7880 "Set rate limit for a queue on port_id",
7882 (void *)&cmd_queue_rate_limit_set,
7883 (void *)&cmd_queue_rate_limit_port,
7884 (void *)&cmd_queue_rate_limit_portnum,
7885 (void *)&cmd_queue_rate_limit_queue,
7886 (void *)&cmd_queue_rate_limit_queuenum,
7887 (void *)&cmd_queue_rate_limit_rate,
7888 (void *)&cmd_queue_rate_limit_ratenum,
7893 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
7894 struct cmd_vf_rate_limit_result {
7895 cmdline_fixed_string_t set;
7896 cmdline_fixed_string_t port;
7898 cmdline_fixed_string_t vf;
7900 cmdline_fixed_string_t rate;
7902 cmdline_fixed_string_t q_msk;
7906 static void cmd_vf_rate_limit_parsed(void *parsed_result,
7907 __attribute__((unused)) struct cmdline *cl,
7908 __attribute__((unused)) void *data)
7910 struct cmd_vf_rate_limit_result *res = parsed_result;
7913 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
7914 && (strcmp(res->vf, "vf") == 0)
7915 && (strcmp(res->rate, "rate") == 0)
7916 && (strcmp(res->q_msk, "queue_mask") == 0))
7917 ret = set_vf_rate_limit(res->port_num, res->vf_num,
7918 res->rate_num, res->q_msk_val);
7920 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
7924 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
7925 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7927 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
7928 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7930 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
7931 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7933 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
7934 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7936 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
7937 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7939 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
7940 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7942 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
7943 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7945 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
7946 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
7947 q_msk, "queue_mask");
7948 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
7949 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
7952 cmdline_parse_inst_t cmd_vf_rate_limit = {
7953 .f = cmd_vf_rate_limit_parsed,
7955 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
7956 "queue_mask <queue_mask_value>: "
7957 "Set rate limit for queues of VF on port_id",
7959 (void *)&cmd_vf_rate_limit_set,
7960 (void *)&cmd_vf_rate_limit_port,
7961 (void *)&cmd_vf_rate_limit_portnum,
7962 (void *)&cmd_vf_rate_limit_vf,
7963 (void *)&cmd_vf_rate_limit_vfnum,
7964 (void *)&cmd_vf_rate_limit_rate,
7965 (void *)&cmd_vf_rate_limit_ratenum,
7966 (void *)&cmd_vf_rate_limit_q_msk,
7967 (void *)&cmd_vf_rate_limit_q_msk_val,
7972 /* *** ADD TUNNEL FILTER OF A PORT *** */
7973 struct cmd_tunnel_filter_result {
7974 cmdline_fixed_string_t cmd;
7975 cmdline_fixed_string_t what;
7977 struct ether_addr outer_mac;
7978 struct ether_addr inner_mac;
7979 cmdline_ipaddr_t ip_value;
7980 uint16_t inner_vlan;
7981 cmdline_fixed_string_t tunnel_type;
7982 cmdline_fixed_string_t filter_type;
7988 cmd_tunnel_filter_parsed(void *parsed_result,
7989 __attribute__((unused)) struct cmdline *cl,
7990 __attribute__((unused)) void *data)
7992 struct cmd_tunnel_filter_result *res = parsed_result;
7993 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
7996 memset(&tunnel_filter_conf, 0, sizeof(tunnel_filter_conf));
7998 ether_addr_copy(&res->outer_mac, &tunnel_filter_conf.outer_mac);
7999 ether_addr_copy(&res->inner_mac, &tunnel_filter_conf.inner_mac);
8000 tunnel_filter_conf.inner_vlan = res->inner_vlan;
8002 if (res->ip_value.family == AF_INET) {
8003 tunnel_filter_conf.ip_addr.ipv4_addr =
8004 res->ip_value.addr.ipv4.s_addr;
8005 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
8007 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
8008 &(res->ip_value.addr.ipv6),
8009 sizeof(struct in6_addr));
8010 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
8013 if (!strcmp(res->filter_type, "imac-ivlan"))
8014 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
8015 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
8016 tunnel_filter_conf.filter_type =
8017 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
8018 else if (!strcmp(res->filter_type, "imac-tenid"))
8019 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
8020 else if (!strcmp(res->filter_type, "imac"))
8021 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
8022 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
8023 tunnel_filter_conf.filter_type =
8024 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
8025 else if (!strcmp(res->filter_type, "oip"))
8026 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_OIP;
8027 else if (!strcmp(res->filter_type, "iip"))
8028 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IIP;
8030 printf("The filter type is not supported");
8034 if (!strcmp(res->tunnel_type, "vxlan"))
8035 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
8036 else if (!strcmp(res->tunnel_type, "nvgre"))
8037 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE;
8038 else if (!strcmp(res->tunnel_type, "ipingre"))
8039 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_IP_IN_GRE;
8041 printf("The tunnel type %s not supported.\n", res->tunnel_type);
8045 tunnel_filter_conf.tenant_id = res->tenant_id;
8046 tunnel_filter_conf.queue_id = res->queue_num;
8047 if (!strcmp(res->what, "add"))
8048 ret = rte_eth_dev_filter_ctrl(res->port_id,
8049 RTE_ETH_FILTER_TUNNEL,
8051 &tunnel_filter_conf);
8053 ret = rte_eth_dev_filter_ctrl(res->port_id,
8054 RTE_ETH_FILTER_TUNNEL,
8055 RTE_ETH_FILTER_DELETE,
8056 &tunnel_filter_conf);
8058 printf("cmd_tunnel_filter_parsed error: (%s)\n",
8062 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
8063 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8064 cmd, "tunnel_filter");
8065 cmdline_parse_token_string_t cmd_tunnel_filter_what =
8066 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8068 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
8069 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8071 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
8072 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8074 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
8075 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8077 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
8078 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8079 inner_vlan, UINT16);
8080 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
8081 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8083 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
8084 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8085 tunnel_type, "vxlan#nvgre#ipingre");
8087 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
8088 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8089 filter_type, "oip#iip#imac-ivlan#imac-ivlan-tenid#imac-tenid#"
8090 "imac#omac-imac-tenid");
8091 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
8092 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8094 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
8095 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8098 cmdline_parse_inst_t cmd_tunnel_filter = {
8099 .f = cmd_tunnel_filter_parsed,
8101 .help_str = "tunnel_filter add|rm <port_id> <outer_mac> <inner_mac> "
8102 "<ip> <inner_vlan> vxlan|nvgre|ipingre oip|iip|imac-ivlan|"
8103 "imac-ivlan-tenid|imac-tenid|imac|omac-imac-tenid <tenant_id> "
8104 "<queue_id>: Add/Rm tunnel filter of a port",
8106 (void *)&cmd_tunnel_filter_cmd,
8107 (void *)&cmd_tunnel_filter_what,
8108 (void *)&cmd_tunnel_filter_port_id,
8109 (void *)&cmd_tunnel_filter_outer_mac,
8110 (void *)&cmd_tunnel_filter_inner_mac,
8111 (void *)&cmd_tunnel_filter_ip_value,
8112 (void *)&cmd_tunnel_filter_innner_vlan,
8113 (void *)&cmd_tunnel_filter_tunnel_type,
8114 (void *)&cmd_tunnel_filter_filter_type,
8115 (void *)&cmd_tunnel_filter_tenant_id,
8116 (void *)&cmd_tunnel_filter_queue_num,
8121 /* *** CONFIGURE TUNNEL UDP PORT *** */
8122 struct cmd_tunnel_udp_config {
8123 cmdline_fixed_string_t cmd;
8124 cmdline_fixed_string_t what;
8130 cmd_tunnel_udp_config_parsed(void *parsed_result,
8131 __attribute__((unused)) struct cmdline *cl,
8132 __attribute__((unused)) void *data)
8134 struct cmd_tunnel_udp_config *res = parsed_result;
8135 struct rte_eth_udp_tunnel tunnel_udp;
8138 tunnel_udp.udp_port = res->udp_port;
8140 if (!strcmp(res->cmd, "rx_vxlan_port"))
8141 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
8143 if (!strcmp(res->what, "add"))
8144 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
8147 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
8151 printf("udp tunneling add error: (%s)\n", strerror(-ret));
8154 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
8155 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
8156 cmd, "rx_vxlan_port");
8157 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
8158 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
8160 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
8161 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
8163 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
8164 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
8167 cmdline_parse_inst_t cmd_tunnel_udp_config = {
8168 .f = cmd_tunnel_udp_config_parsed,
8170 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
8171 "Add/Remove a tunneling UDP port filter",
8173 (void *)&cmd_tunnel_udp_config_cmd,
8174 (void *)&cmd_tunnel_udp_config_what,
8175 (void *)&cmd_tunnel_udp_config_udp_port,
8176 (void *)&cmd_tunnel_udp_config_port_id,
8181 /* *** GLOBAL CONFIG *** */
8182 struct cmd_global_config_result {
8183 cmdline_fixed_string_t cmd;
8185 cmdline_fixed_string_t cfg_type;
8190 cmd_global_config_parsed(void *parsed_result,
8191 __attribute__((unused)) struct cmdline *cl,
8192 __attribute__((unused)) void *data)
8194 struct cmd_global_config_result *res = parsed_result;
8195 struct rte_eth_global_cfg conf;
8198 memset(&conf, 0, sizeof(conf));
8199 conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN;
8200 conf.cfg.gre_key_len = res->len;
8201 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE,
8202 RTE_ETH_FILTER_SET, &conf);
8204 printf("Global config error\n");
8207 cmdline_parse_token_string_t cmd_global_config_cmd =
8208 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd,
8210 cmdline_parse_token_num_t cmd_global_config_port_id =
8211 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id,
8213 cmdline_parse_token_string_t cmd_global_config_type =
8214 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result,
8215 cfg_type, "gre-key-len");
8216 cmdline_parse_token_num_t cmd_global_config_gre_key_len =
8217 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result,
8220 cmdline_parse_inst_t cmd_global_config = {
8221 .f = cmd_global_config_parsed,
8222 .data = (void *)NULL,
8223 .help_str = "global_config <port_id> gre-key-len <key_len>",
8225 (void *)&cmd_global_config_cmd,
8226 (void *)&cmd_global_config_port_id,
8227 (void *)&cmd_global_config_type,
8228 (void *)&cmd_global_config_gre_key_len,
8233 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
8234 struct cmd_set_mirror_mask_result {
8235 cmdline_fixed_string_t set;
8236 cmdline_fixed_string_t port;
8238 cmdline_fixed_string_t mirror;
8240 cmdline_fixed_string_t what;
8241 cmdline_fixed_string_t value;
8242 cmdline_fixed_string_t dstpool;
8244 cmdline_fixed_string_t on;
8247 cmdline_parse_token_string_t cmd_mirror_mask_set =
8248 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8250 cmdline_parse_token_string_t cmd_mirror_mask_port =
8251 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8253 cmdline_parse_token_num_t cmd_mirror_mask_portid =
8254 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
8256 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
8257 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8258 mirror, "mirror-rule");
8259 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
8260 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
8262 cmdline_parse_token_string_t cmd_mirror_mask_what =
8263 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8264 what, "pool-mirror-up#pool-mirror-down"
8266 cmdline_parse_token_string_t cmd_mirror_mask_value =
8267 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8269 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
8270 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8271 dstpool, "dst-pool");
8272 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
8273 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
8275 cmdline_parse_token_string_t cmd_mirror_mask_on =
8276 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8280 cmd_set_mirror_mask_parsed(void *parsed_result,
8281 __attribute__((unused)) struct cmdline *cl,
8282 __attribute__((unused)) void *data)
8285 struct cmd_set_mirror_mask_result *res = parsed_result;
8286 struct rte_eth_mirror_conf mr_conf;
8288 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
8290 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
8292 mr_conf.dst_pool = res->dstpool_id;
8294 if (!strcmp(res->what, "pool-mirror-up")) {
8295 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
8296 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
8297 } else if (!strcmp(res->what, "pool-mirror-down")) {
8298 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
8299 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
8300 } else if (!strcmp(res->what, "vlan-mirror")) {
8301 mr_conf.rule_type = ETH_MIRROR_VLAN;
8302 nb_item = parse_item_list(res->value, "vlan",
8303 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
8307 for (i = 0; i < nb_item; i++) {
8308 if (vlan_list[i] > ETHER_MAX_VLAN_ID) {
8309 printf("Invalid vlan_id: must be < 4096\n");
8313 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
8314 mr_conf.vlan.vlan_mask |= 1ULL << i;
8318 if (!strcmp(res->on, "on"))
8319 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8322 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8325 printf("mirror rule add error: (%s)\n", strerror(-ret));
8328 cmdline_parse_inst_t cmd_set_mirror_mask = {
8329 .f = cmd_set_mirror_mask_parsed,
8331 .help_str = "set port <port_id> mirror-rule <rule_id> "
8332 "pool-mirror-up|pool-mirror-down|vlan-mirror "
8333 "<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off",
8335 (void *)&cmd_mirror_mask_set,
8336 (void *)&cmd_mirror_mask_port,
8337 (void *)&cmd_mirror_mask_portid,
8338 (void *)&cmd_mirror_mask_mirror,
8339 (void *)&cmd_mirror_mask_ruleid,
8340 (void *)&cmd_mirror_mask_what,
8341 (void *)&cmd_mirror_mask_value,
8342 (void *)&cmd_mirror_mask_dstpool,
8343 (void *)&cmd_mirror_mask_poolid,
8344 (void *)&cmd_mirror_mask_on,
8349 /* *** CONFIGURE VM MIRROR UPLINK/DOWNLINK RULE *** */
8350 struct cmd_set_mirror_link_result {
8351 cmdline_fixed_string_t set;
8352 cmdline_fixed_string_t port;
8354 cmdline_fixed_string_t mirror;
8356 cmdline_fixed_string_t what;
8357 cmdline_fixed_string_t dstpool;
8359 cmdline_fixed_string_t on;
8362 cmdline_parse_token_string_t cmd_mirror_link_set =
8363 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8365 cmdline_parse_token_string_t cmd_mirror_link_port =
8366 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8368 cmdline_parse_token_num_t cmd_mirror_link_portid =
8369 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
8371 cmdline_parse_token_string_t cmd_mirror_link_mirror =
8372 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8373 mirror, "mirror-rule");
8374 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
8375 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
8377 cmdline_parse_token_string_t cmd_mirror_link_what =
8378 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8379 what, "uplink-mirror#downlink-mirror");
8380 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
8381 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8382 dstpool, "dst-pool");
8383 cmdline_parse_token_num_t cmd_mirror_link_poolid =
8384 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
8386 cmdline_parse_token_string_t cmd_mirror_link_on =
8387 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8391 cmd_set_mirror_link_parsed(void *parsed_result,
8392 __attribute__((unused)) struct cmdline *cl,
8393 __attribute__((unused)) void *data)
8396 struct cmd_set_mirror_link_result *res = parsed_result;
8397 struct rte_eth_mirror_conf mr_conf;
8399 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
8400 if (!strcmp(res->what, "uplink-mirror"))
8401 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
8403 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
8405 mr_conf.dst_pool = res->dstpool_id;
8407 if (!strcmp(res->on, "on"))
8408 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8411 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8414 /* check the return value and print it if is < 0 */
8416 printf("mirror rule add error: (%s)\n", strerror(-ret));
8420 cmdline_parse_inst_t cmd_set_mirror_link = {
8421 .f = cmd_set_mirror_link_parsed,
8423 .help_str = "set port <port_id> mirror-rule <rule_id> "
8424 "uplink-mirror|downlink-mirror dst-pool <pool_id> on|off",
8426 (void *)&cmd_mirror_link_set,
8427 (void *)&cmd_mirror_link_port,
8428 (void *)&cmd_mirror_link_portid,
8429 (void *)&cmd_mirror_link_mirror,
8430 (void *)&cmd_mirror_link_ruleid,
8431 (void *)&cmd_mirror_link_what,
8432 (void *)&cmd_mirror_link_dstpool,
8433 (void *)&cmd_mirror_link_poolid,
8434 (void *)&cmd_mirror_link_on,
8439 /* *** RESET VM MIRROR RULE *** */
8440 struct cmd_rm_mirror_rule_result {
8441 cmdline_fixed_string_t reset;
8442 cmdline_fixed_string_t port;
8444 cmdline_fixed_string_t mirror;
8448 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
8449 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
8451 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
8452 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
8454 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
8455 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
8457 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
8458 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
8459 mirror, "mirror-rule");
8460 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
8461 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
8465 cmd_reset_mirror_rule_parsed(void *parsed_result,
8466 __attribute__((unused)) struct cmdline *cl,
8467 __attribute__((unused)) void *data)
8470 struct cmd_set_mirror_link_result *res = parsed_result;
8472 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
8474 printf("mirror rule remove error: (%s)\n", strerror(-ret));
8477 cmdline_parse_inst_t cmd_reset_mirror_rule = {
8478 .f = cmd_reset_mirror_rule_parsed,
8480 .help_str = "reset port <port_id> mirror-rule <rule_id>",
8482 (void *)&cmd_rm_mirror_rule_reset,
8483 (void *)&cmd_rm_mirror_rule_port,
8484 (void *)&cmd_rm_mirror_rule_portid,
8485 (void *)&cmd_rm_mirror_rule_mirror,
8486 (void *)&cmd_rm_mirror_rule_ruleid,
8491 /* ******************************************************************************** */
8493 struct cmd_dump_result {
8494 cmdline_fixed_string_t dump;
8498 dump_struct_sizes(void)
8500 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
8501 DUMP_SIZE(struct rte_mbuf);
8502 DUMP_SIZE(struct rte_mempool);
8503 DUMP_SIZE(struct rte_ring);
8507 static void cmd_dump_parsed(void *parsed_result,
8508 __attribute__((unused)) struct cmdline *cl,
8509 __attribute__((unused)) void *data)
8511 struct cmd_dump_result *res = parsed_result;
8513 if (!strcmp(res->dump, "dump_physmem"))
8514 rte_dump_physmem_layout(stdout);
8515 else if (!strcmp(res->dump, "dump_memzone"))
8516 rte_memzone_dump(stdout);
8517 else if (!strcmp(res->dump, "dump_struct_sizes"))
8518 dump_struct_sizes();
8519 else if (!strcmp(res->dump, "dump_ring"))
8520 rte_ring_list_dump(stdout);
8521 else if (!strcmp(res->dump, "dump_mempool"))
8522 rte_mempool_list_dump(stdout);
8523 else if (!strcmp(res->dump, "dump_devargs"))
8524 rte_eal_devargs_dump(stdout);
8525 else if (!strcmp(res->dump, "dump_log_types"))
8526 rte_log_dump(stdout);
8529 cmdline_parse_token_string_t cmd_dump_dump =
8530 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
8533 "dump_struct_sizes#"
8539 cmdline_parse_inst_t cmd_dump = {
8540 .f = cmd_dump_parsed, /* function to call */
8541 .data = NULL, /* 2nd arg of func */
8542 .help_str = "Dump status",
8543 .tokens = { /* token list, NULL terminated */
8544 (void *)&cmd_dump_dump,
8549 /* ******************************************************************************** */
8551 struct cmd_dump_one_result {
8552 cmdline_fixed_string_t dump;
8553 cmdline_fixed_string_t name;
8556 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
8557 __attribute__((unused)) void *data)
8559 struct cmd_dump_one_result *res = parsed_result;
8561 if (!strcmp(res->dump, "dump_ring")) {
8563 r = rte_ring_lookup(res->name);
8565 cmdline_printf(cl, "Cannot find ring\n");
8568 rte_ring_dump(stdout, r);
8569 } else if (!strcmp(res->dump, "dump_mempool")) {
8570 struct rte_mempool *mp;
8571 mp = rte_mempool_lookup(res->name);
8573 cmdline_printf(cl, "Cannot find mempool\n");
8576 rte_mempool_dump(stdout, mp);
8580 cmdline_parse_token_string_t cmd_dump_one_dump =
8581 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
8582 "dump_ring#dump_mempool");
8584 cmdline_parse_token_string_t cmd_dump_one_name =
8585 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
8587 cmdline_parse_inst_t cmd_dump_one = {
8588 .f = cmd_dump_one_parsed, /* function to call */
8589 .data = NULL, /* 2nd arg of func */
8590 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
8591 .tokens = { /* token list, NULL terminated */
8592 (void *)&cmd_dump_one_dump,
8593 (void *)&cmd_dump_one_name,
8598 /* *** Add/Del syn filter *** */
8599 struct cmd_syn_filter_result {
8600 cmdline_fixed_string_t filter;
8602 cmdline_fixed_string_t ops;
8603 cmdline_fixed_string_t priority;
8604 cmdline_fixed_string_t high;
8605 cmdline_fixed_string_t queue;
8610 cmd_syn_filter_parsed(void *parsed_result,
8611 __attribute__((unused)) struct cmdline *cl,
8612 __attribute__((unused)) void *data)
8614 struct cmd_syn_filter_result *res = parsed_result;
8615 struct rte_eth_syn_filter syn_filter;
8618 ret = rte_eth_dev_filter_supported(res->port_id,
8619 RTE_ETH_FILTER_SYN);
8621 printf("syn filter is not supported on port %u.\n",
8626 memset(&syn_filter, 0, sizeof(syn_filter));
8628 if (!strcmp(res->ops, "add")) {
8629 if (!strcmp(res->high, "high"))
8630 syn_filter.hig_pri = 1;
8632 syn_filter.hig_pri = 0;
8634 syn_filter.queue = res->queue_id;
8635 ret = rte_eth_dev_filter_ctrl(res->port_id,
8640 ret = rte_eth_dev_filter_ctrl(res->port_id,
8642 RTE_ETH_FILTER_DELETE,
8646 printf("syn filter programming error: (%s)\n",
8650 cmdline_parse_token_string_t cmd_syn_filter_filter =
8651 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8652 filter, "syn_filter");
8653 cmdline_parse_token_num_t cmd_syn_filter_port_id =
8654 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
8656 cmdline_parse_token_string_t cmd_syn_filter_ops =
8657 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8659 cmdline_parse_token_string_t cmd_syn_filter_priority =
8660 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8661 priority, "priority");
8662 cmdline_parse_token_string_t cmd_syn_filter_high =
8663 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8665 cmdline_parse_token_string_t cmd_syn_filter_queue =
8666 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
8668 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
8669 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
8672 cmdline_parse_inst_t cmd_syn_filter = {
8673 .f = cmd_syn_filter_parsed,
8675 .help_str = "syn_filter <port_id> add|del priority high|low queue "
8676 "<queue_id>: Add/Delete syn filter",
8678 (void *)&cmd_syn_filter_filter,
8679 (void *)&cmd_syn_filter_port_id,
8680 (void *)&cmd_syn_filter_ops,
8681 (void *)&cmd_syn_filter_priority,
8682 (void *)&cmd_syn_filter_high,
8683 (void *)&cmd_syn_filter_queue,
8684 (void *)&cmd_syn_filter_queue_id,
8689 /* *** queue region set *** */
8690 struct cmd_queue_region_result {
8691 cmdline_fixed_string_t set;
8692 cmdline_fixed_string_t port;
8694 cmdline_fixed_string_t cmd;
8695 cmdline_fixed_string_t region;
8697 cmdline_fixed_string_t queue_start_index;
8699 cmdline_fixed_string_t queue_num;
8700 uint8_t queue_num_value;
8704 cmd_queue_region_parsed(void *parsed_result,
8705 __attribute__((unused)) struct cmdline *cl,
8706 __attribute__((unused)) void *data)
8708 struct cmd_queue_region_result *res = parsed_result;
8710 #ifdef RTE_LIBRTE_I40E_PMD
8711 struct rte_pmd_i40e_queue_region_conf region_conf;
8712 enum rte_pmd_i40e_queue_region_op op_type;
8715 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
8718 #ifdef RTE_LIBRTE_I40E_PMD
8719 memset(®ion_conf, 0, sizeof(region_conf));
8720 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_SET;
8721 region_conf.region_id = res->region_id;
8722 region_conf.queue_num = res->queue_num_value;
8723 region_conf.queue_start_index = res->queue_id;
8725 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
8726 op_type, ®ion_conf);
8733 printf("function not implemented or supported\n");
8736 printf("queue region config error: (%s)\n", strerror(-ret));
8740 cmdline_parse_token_string_t cmd_queue_region_set =
8741 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
8743 cmdline_parse_token_string_t cmd_queue_region_port =
8744 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, port, "port");
8745 cmdline_parse_token_num_t cmd_queue_region_port_id =
8746 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
8748 cmdline_parse_token_string_t cmd_queue_region_cmd =
8749 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
8750 cmd, "queue-region");
8751 cmdline_parse_token_string_t cmd_queue_region_id =
8752 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
8753 region, "region_id");
8754 cmdline_parse_token_num_t cmd_queue_region_index =
8755 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
8757 cmdline_parse_token_string_t cmd_queue_region_queue_start_index =
8758 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
8759 queue_start_index, "queue_start_index");
8760 cmdline_parse_token_num_t cmd_queue_region_queue_id =
8761 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
8763 cmdline_parse_token_string_t cmd_queue_region_queue_num =
8764 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
8765 queue_num, "queue_num");
8766 cmdline_parse_token_num_t cmd_queue_region_queue_num_value =
8767 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
8768 queue_num_value, UINT8);
8770 cmdline_parse_inst_t cmd_queue_region = {
8771 .f = cmd_queue_region_parsed,
8773 .help_str = "set port <port_id> queue-region region_id <value> "
8774 "queue_start_index <value> queue_num <value>: Set a queue region",
8776 (void *)&cmd_queue_region_set,
8777 (void *)&cmd_queue_region_port,
8778 (void *)&cmd_queue_region_port_id,
8779 (void *)&cmd_queue_region_cmd,
8780 (void *)&cmd_queue_region_id,
8781 (void *)&cmd_queue_region_index,
8782 (void *)&cmd_queue_region_queue_start_index,
8783 (void *)&cmd_queue_region_queue_id,
8784 (void *)&cmd_queue_region_queue_num,
8785 (void *)&cmd_queue_region_queue_num_value,
8790 /* *** queue region and flowtype set *** */
8791 struct cmd_region_flowtype_result {
8792 cmdline_fixed_string_t set;
8793 cmdline_fixed_string_t port;
8795 cmdline_fixed_string_t cmd;
8796 cmdline_fixed_string_t region;
8798 cmdline_fixed_string_t flowtype;
8799 uint8_t flowtype_id;
8803 cmd_region_flowtype_parsed(void *parsed_result,
8804 __attribute__((unused)) struct cmdline *cl,
8805 __attribute__((unused)) void *data)
8807 struct cmd_region_flowtype_result *res = parsed_result;
8809 #ifdef RTE_LIBRTE_I40E_PMD
8810 struct rte_pmd_i40e_queue_region_conf region_conf;
8811 enum rte_pmd_i40e_queue_region_op op_type;
8814 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
8817 #ifdef RTE_LIBRTE_I40E_PMD
8818 memset(®ion_conf, 0, sizeof(region_conf));
8820 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_FLOWTYPE_SET;
8821 region_conf.region_id = res->region_id;
8822 region_conf.hw_flowtype = res->flowtype_id;
8824 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
8825 op_type, ®ion_conf);
8832 printf("function not implemented or supported\n");
8835 printf("region flowtype config error: (%s)\n", strerror(-ret));
8839 cmdline_parse_token_string_t cmd_region_flowtype_set =
8840 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
8842 cmdline_parse_token_string_t cmd_region_flowtype_port =
8843 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
8845 cmdline_parse_token_num_t cmd_region_flowtype_port_index =
8846 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
8848 cmdline_parse_token_string_t cmd_region_flowtype_cmd =
8849 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
8850 cmd, "queue-region");
8851 cmdline_parse_token_string_t cmd_region_flowtype_index =
8852 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
8853 region, "region_id");
8854 cmdline_parse_token_num_t cmd_region_flowtype_id =
8855 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
8857 cmdline_parse_token_string_t cmd_region_flowtype_flow_index =
8858 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
8859 flowtype, "flowtype");
8860 cmdline_parse_token_num_t cmd_region_flowtype_flow_id =
8861 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
8862 flowtype_id, UINT8);
8863 cmdline_parse_inst_t cmd_region_flowtype = {
8864 .f = cmd_region_flowtype_parsed,
8866 .help_str = "set port <port_id> queue-region region_id <value> "
8867 "flowtype <value>: Set a flowtype region index",
8869 (void *)&cmd_region_flowtype_set,
8870 (void *)&cmd_region_flowtype_port,
8871 (void *)&cmd_region_flowtype_port_index,
8872 (void *)&cmd_region_flowtype_cmd,
8873 (void *)&cmd_region_flowtype_index,
8874 (void *)&cmd_region_flowtype_id,
8875 (void *)&cmd_region_flowtype_flow_index,
8876 (void *)&cmd_region_flowtype_flow_id,
8881 /* *** User Priority (UP) to queue region (region_id) set *** */
8882 struct cmd_user_priority_region_result {
8883 cmdline_fixed_string_t set;
8884 cmdline_fixed_string_t port;
8886 cmdline_fixed_string_t cmd;
8887 cmdline_fixed_string_t user_priority;
8888 uint8_t user_priority_id;
8889 cmdline_fixed_string_t region;
8894 cmd_user_priority_region_parsed(void *parsed_result,
8895 __attribute__((unused)) struct cmdline *cl,
8896 __attribute__((unused)) void *data)
8898 struct cmd_user_priority_region_result *res = parsed_result;
8900 #ifdef RTE_LIBRTE_I40E_PMD
8901 struct rte_pmd_i40e_queue_region_conf region_conf;
8902 enum rte_pmd_i40e_queue_region_op op_type;
8905 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
8908 #ifdef RTE_LIBRTE_I40E_PMD
8909 memset(®ion_conf, 0, sizeof(region_conf));
8910 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_USER_PRIORITY_SET;
8911 region_conf.user_priority = res->user_priority_id;
8912 region_conf.region_id = res->region_id;
8914 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
8915 op_type, ®ion_conf);
8922 printf("function not implemented or supported\n");
8925 printf("user_priority region config error: (%s)\n",
8930 cmdline_parse_token_string_t cmd_user_priority_region_set =
8931 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
8933 cmdline_parse_token_string_t cmd_user_priority_region_port =
8934 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
8936 cmdline_parse_token_num_t cmd_user_priority_region_port_index =
8937 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
8939 cmdline_parse_token_string_t cmd_user_priority_region_cmd =
8940 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
8941 cmd, "queue-region");
8942 cmdline_parse_token_string_t cmd_user_priority_region_UP =
8943 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
8944 user_priority, "UP");
8945 cmdline_parse_token_num_t cmd_user_priority_region_UP_id =
8946 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
8947 user_priority_id, UINT8);
8948 cmdline_parse_token_string_t cmd_user_priority_region_region =
8949 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
8950 region, "region_id");
8951 cmdline_parse_token_num_t cmd_user_priority_region_region_id =
8952 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
8955 cmdline_parse_inst_t cmd_user_priority_region = {
8956 .f = cmd_user_priority_region_parsed,
8958 .help_str = "set port <port_id> queue-region UP <value> "
8959 "region_id <value>: Set the mapping of User Priority (UP) "
8960 "to queue region (region_id) ",
8962 (void *)&cmd_user_priority_region_set,
8963 (void *)&cmd_user_priority_region_port,
8964 (void *)&cmd_user_priority_region_port_index,
8965 (void *)&cmd_user_priority_region_cmd,
8966 (void *)&cmd_user_priority_region_UP,
8967 (void *)&cmd_user_priority_region_UP_id,
8968 (void *)&cmd_user_priority_region_region,
8969 (void *)&cmd_user_priority_region_region_id,
8974 /* *** flush all queue region related configuration *** */
8975 struct cmd_flush_queue_region_result {
8976 cmdline_fixed_string_t set;
8977 cmdline_fixed_string_t port;
8979 cmdline_fixed_string_t cmd;
8980 cmdline_fixed_string_t flush;
8981 cmdline_fixed_string_t what;
8985 cmd_flush_queue_region_parsed(void *parsed_result,
8986 __attribute__((unused)) struct cmdline *cl,
8987 __attribute__((unused)) void *data)
8989 struct cmd_flush_queue_region_result *res = parsed_result;
8991 #ifdef RTE_LIBRTE_I40E_PMD
8992 struct rte_pmd_i40e_queue_region_conf region_conf;
8993 enum rte_pmd_i40e_queue_region_op op_type;
8996 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
8999 #ifdef RTE_LIBRTE_I40E_PMD
9000 memset(®ion_conf, 0, sizeof(region_conf));
9002 if (strcmp(res->what, "on") == 0)
9003 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_ON;
9005 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_OFF;
9007 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9008 op_type, ®ion_conf);
9015 printf("function not implemented or supported\n");
9018 printf("queue region config flush error: (%s)\n",
9023 cmdline_parse_token_string_t cmd_flush_queue_region_set =
9024 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9026 cmdline_parse_token_string_t cmd_flush_queue_region_port =
9027 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9029 cmdline_parse_token_num_t cmd_flush_queue_region_port_index =
9030 TOKEN_NUM_INITIALIZER(struct cmd_flush_queue_region_result,
9032 cmdline_parse_token_string_t cmd_flush_queue_region_cmd =
9033 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9034 cmd, "queue-region");
9035 cmdline_parse_token_string_t cmd_flush_queue_region_flush =
9036 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9038 cmdline_parse_token_string_t cmd_flush_queue_region_what =
9039 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9042 cmdline_parse_inst_t cmd_flush_queue_region = {
9043 .f = cmd_flush_queue_region_parsed,
9045 .help_str = "set port <port_id> queue-region flush on|off"
9046 ": flush all queue region related configuration",
9048 (void *)&cmd_flush_queue_region_set,
9049 (void *)&cmd_flush_queue_region_port,
9050 (void *)&cmd_flush_queue_region_port_index,
9051 (void *)&cmd_flush_queue_region_cmd,
9052 (void *)&cmd_flush_queue_region_flush,
9053 (void *)&cmd_flush_queue_region_what,
9058 /* *** get all queue region related configuration info *** */
9059 struct cmd_show_queue_region_info {
9060 cmdline_fixed_string_t show;
9061 cmdline_fixed_string_t port;
9063 cmdline_fixed_string_t cmd;
9067 cmd_show_queue_region_info_parsed(void *parsed_result,
9068 __attribute__((unused)) struct cmdline *cl,
9069 __attribute__((unused)) void *data)
9071 struct cmd_show_queue_region_info *res = parsed_result;
9073 #ifdef RTE_LIBRTE_I40E_PMD
9074 struct rte_pmd_i40e_queue_regions rte_pmd_regions;
9075 enum rte_pmd_i40e_queue_region_op op_type;
9078 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9081 #ifdef RTE_LIBRTE_I40E_PMD
9082 memset(&rte_pmd_regions, 0, sizeof(rte_pmd_regions));
9084 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_INFO_GET;
9086 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9087 op_type, &rte_pmd_regions);
9089 port_queue_region_info_display(res->port_id, &rte_pmd_regions);
9096 printf("function not implemented or supported\n");
9099 printf("queue region config info show error: (%s)\n",
9104 cmdline_parse_token_string_t cmd_show_queue_region_info_get =
9105 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
9107 cmdline_parse_token_string_t cmd_show_queue_region_info_port =
9108 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
9110 cmdline_parse_token_num_t cmd_show_queue_region_info_port_index =
9111 TOKEN_NUM_INITIALIZER(struct cmd_show_queue_region_info,
9113 cmdline_parse_token_string_t cmd_show_queue_region_info_cmd =
9114 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
9115 cmd, "queue-region");
9117 cmdline_parse_inst_t cmd_show_queue_region_info_all = {
9118 .f = cmd_show_queue_region_info_parsed,
9120 .help_str = "show port <port_id> queue-region"
9121 ": show all queue region related configuration info",
9123 (void *)&cmd_show_queue_region_info_get,
9124 (void *)&cmd_show_queue_region_info_port,
9125 (void *)&cmd_show_queue_region_info_port_index,
9126 (void *)&cmd_show_queue_region_info_cmd,
9131 /* *** ADD/REMOVE A 2tuple FILTER *** */
9132 struct cmd_2tuple_filter_result {
9133 cmdline_fixed_string_t filter;
9135 cmdline_fixed_string_t ops;
9136 cmdline_fixed_string_t dst_port;
9137 uint16_t dst_port_value;
9138 cmdline_fixed_string_t protocol;
9139 uint8_t protocol_value;
9140 cmdline_fixed_string_t mask;
9142 cmdline_fixed_string_t tcp_flags;
9143 uint8_t tcp_flags_value;
9144 cmdline_fixed_string_t priority;
9145 uint8_t priority_value;
9146 cmdline_fixed_string_t queue;
9151 cmd_2tuple_filter_parsed(void *parsed_result,
9152 __attribute__((unused)) struct cmdline *cl,
9153 __attribute__((unused)) void *data)
9155 struct rte_eth_ntuple_filter filter;
9156 struct cmd_2tuple_filter_result *res = parsed_result;
9159 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
9161 printf("ntuple filter is not supported on port %u.\n",
9166 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
9168 filter.flags = RTE_2TUPLE_FLAGS;
9169 filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
9170 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
9171 filter.proto = res->protocol_value;
9172 filter.priority = res->priority_value;
9173 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
9174 printf("nonzero tcp_flags is only meaningful"
9175 " when protocol is TCP.\n");
9178 if (res->tcp_flags_value > TCP_FLAG_ALL) {
9179 printf("invalid TCP flags.\n");
9183 if (res->tcp_flags_value != 0) {
9184 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
9185 filter.tcp_flags = res->tcp_flags_value;
9188 /* need convert to big endian. */
9189 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
9190 filter.queue = res->queue_id;
9192 if (!strcmp(res->ops, "add"))
9193 ret = rte_eth_dev_filter_ctrl(res->port_id,
9194 RTE_ETH_FILTER_NTUPLE,
9198 ret = rte_eth_dev_filter_ctrl(res->port_id,
9199 RTE_ETH_FILTER_NTUPLE,
9200 RTE_ETH_FILTER_DELETE,
9203 printf("2tuple filter programming error: (%s)\n",
9208 cmdline_parse_token_string_t cmd_2tuple_filter_filter =
9209 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9210 filter, "2tuple_filter");
9211 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
9212 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9214 cmdline_parse_token_string_t cmd_2tuple_filter_ops =
9215 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9217 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
9218 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9219 dst_port, "dst_port");
9220 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
9221 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9222 dst_port_value, UINT16);
9223 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
9224 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9225 protocol, "protocol");
9226 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
9227 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9228 protocol_value, UINT8);
9229 cmdline_parse_token_string_t cmd_2tuple_filter_mask =
9230 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9232 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value =
9233 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9235 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags =
9236 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9237 tcp_flags, "tcp_flags");
9238 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value =
9239 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9240 tcp_flags_value, UINT8);
9241 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
9242 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9243 priority, "priority");
9244 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
9245 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9246 priority_value, UINT8);
9247 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
9248 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9250 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
9251 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9254 cmdline_parse_inst_t cmd_2tuple_filter = {
9255 .f = cmd_2tuple_filter_parsed,
9257 .help_str = "2tuple_filter <port_id> add|del dst_port <value> protocol "
9258 "<value> mask <value> tcp_flags <value> priority <value> queue "
9259 "<queue_id>: Add a 2tuple filter",
9261 (void *)&cmd_2tuple_filter_filter,
9262 (void *)&cmd_2tuple_filter_port_id,
9263 (void *)&cmd_2tuple_filter_ops,
9264 (void *)&cmd_2tuple_filter_dst_port,
9265 (void *)&cmd_2tuple_filter_dst_port_value,
9266 (void *)&cmd_2tuple_filter_protocol,
9267 (void *)&cmd_2tuple_filter_protocol_value,
9268 (void *)&cmd_2tuple_filter_mask,
9269 (void *)&cmd_2tuple_filter_mask_value,
9270 (void *)&cmd_2tuple_filter_tcp_flags,
9271 (void *)&cmd_2tuple_filter_tcp_flags_value,
9272 (void *)&cmd_2tuple_filter_priority,
9273 (void *)&cmd_2tuple_filter_priority_value,
9274 (void *)&cmd_2tuple_filter_queue,
9275 (void *)&cmd_2tuple_filter_queue_id,
9280 /* *** ADD/REMOVE A 5tuple FILTER *** */
9281 struct cmd_5tuple_filter_result {
9282 cmdline_fixed_string_t filter;
9284 cmdline_fixed_string_t ops;
9285 cmdline_fixed_string_t dst_ip;
9286 cmdline_ipaddr_t dst_ip_value;
9287 cmdline_fixed_string_t src_ip;
9288 cmdline_ipaddr_t src_ip_value;
9289 cmdline_fixed_string_t dst_port;
9290 uint16_t dst_port_value;
9291 cmdline_fixed_string_t src_port;
9292 uint16_t src_port_value;
9293 cmdline_fixed_string_t protocol;
9294 uint8_t protocol_value;
9295 cmdline_fixed_string_t mask;
9297 cmdline_fixed_string_t tcp_flags;
9298 uint8_t tcp_flags_value;
9299 cmdline_fixed_string_t priority;
9300 uint8_t priority_value;
9301 cmdline_fixed_string_t queue;
9306 cmd_5tuple_filter_parsed(void *parsed_result,
9307 __attribute__((unused)) struct cmdline *cl,
9308 __attribute__((unused)) void *data)
9310 struct rte_eth_ntuple_filter filter;
9311 struct cmd_5tuple_filter_result *res = parsed_result;
9314 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
9316 printf("ntuple filter is not supported on port %u.\n",
9321 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
9323 filter.flags = RTE_5TUPLE_FLAGS;
9324 filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0;
9325 filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0;
9326 filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0;
9327 filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
9328 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
9329 filter.proto = res->protocol_value;
9330 filter.priority = res->priority_value;
9331 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
9332 printf("nonzero tcp_flags is only meaningful"
9333 " when protocol is TCP.\n");
9336 if (res->tcp_flags_value > TCP_FLAG_ALL) {
9337 printf("invalid TCP flags.\n");
9341 if (res->tcp_flags_value != 0) {
9342 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
9343 filter.tcp_flags = res->tcp_flags_value;
9346 if (res->dst_ip_value.family == AF_INET)
9347 /* no need to convert, already big endian. */
9348 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
9350 if (filter.dst_ip_mask == 0) {
9351 printf("can not support ipv6 involved compare.\n");
9357 if (res->src_ip_value.family == AF_INET)
9358 /* no need to convert, already big endian. */
9359 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
9361 if (filter.src_ip_mask == 0) {
9362 printf("can not support ipv6 involved compare.\n");
9367 /* need convert to big endian. */
9368 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
9369 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
9370 filter.queue = res->queue_id;
9372 if (!strcmp(res->ops, "add"))
9373 ret = rte_eth_dev_filter_ctrl(res->port_id,
9374 RTE_ETH_FILTER_NTUPLE,
9378 ret = rte_eth_dev_filter_ctrl(res->port_id,
9379 RTE_ETH_FILTER_NTUPLE,
9380 RTE_ETH_FILTER_DELETE,
9383 printf("5tuple filter programming error: (%s)\n",
9387 cmdline_parse_token_string_t cmd_5tuple_filter_filter =
9388 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9389 filter, "5tuple_filter");
9390 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
9391 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9393 cmdline_parse_token_string_t cmd_5tuple_filter_ops =
9394 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9396 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
9397 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9399 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
9400 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
9402 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
9403 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9405 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
9406 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
9408 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
9409 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9410 dst_port, "dst_port");
9411 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
9412 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9413 dst_port_value, UINT16);
9414 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
9415 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9416 src_port, "src_port");
9417 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
9418 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9419 src_port_value, UINT16);
9420 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
9421 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9422 protocol, "protocol");
9423 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
9424 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9425 protocol_value, UINT8);
9426 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
9427 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9429 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
9430 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9432 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags =
9433 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9434 tcp_flags, "tcp_flags");
9435 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value =
9436 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9437 tcp_flags_value, UINT8);
9438 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
9439 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9440 priority, "priority");
9441 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
9442 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9443 priority_value, UINT8);
9444 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
9445 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9447 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
9448 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9451 cmdline_parse_inst_t cmd_5tuple_filter = {
9452 .f = cmd_5tuple_filter_parsed,
9454 .help_str = "5tuple_filter <port_id> add|del dst_ip <value> "
9455 "src_ip <value> dst_port <value> src_port <value> "
9456 "protocol <value> mask <value> tcp_flags <value> "
9457 "priority <value> queue <queue_id>: Add/Del a 5tuple filter",
9459 (void *)&cmd_5tuple_filter_filter,
9460 (void *)&cmd_5tuple_filter_port_id,
9461 (void *)&cmd_5tuple_filter_ops,
9462 (void *)&cmd_5tuple_filter_dst_ip,
9463 (void *)&cmd_5tuple_filter_dst_ip_value,
9464 (void *)&cmd_5tuple_filter_src_ip,
9465 (void *)&cmd_5tuple_filter_src_ip_value,
9466 (void *)&cmd_5tuple_filter_dst_port,
9467 (void *)&cmd_5tuple_filter_dst_port_value,
9468 (void *)&cmd_5tuple_filter_src_port,
9469 (void *)&cmd_5tuple_filter_src_port_value,
9470 (void *)&cmd_5tuple_filter_protocol,
9471 (void *)&cmd_5tuple_filter_protocol_value,
9472 (void *)&cmd_5tuple_filter_mask,
9473 (void *)&cmd_5tuple_filter_mask_value,
9474 (void *)&cmd_5tuple_filter_tcp_flags,
9475 (void *)&cmd_5tuple_filter_tcp_flags_value,
9476 (void *)&cmd_5tuple_filter_priority,
9477 (void *)&cmd_5tuple_filter_priority_value,
9478 (void *)&cmd_5tuple_filter_queue,
9479 (void *)&cmd_5tuple_filter_queue_id,
9484 /* *** ADD/REMOVE A flex FILTER *** */
9485 struct cmd_flex_filter_result {
9486 cmdline_fixed_string_t filter;
9487 cmdline_fixed_string_t ops;
9489 cmdline_fixed_string_t len;
9491 cmdline_fixed_string_t bytes;
9492 cmdline_fixed_string_t bytes_value;
9493 cmdline_fixed_string_t mask;
9494 cmdline_fixed_string_t mask_value;
9495 cmdline_fixed_string_t priority;
9496 uint8_t priority_value;
9497 cmdline_fixed_string_t queue;
9501 static int xdigit2val(unsigned char c)
9506 else if (isupper(c))
9514 cmd_flex_filter_parsed(void *parsed_result,
9515 __attribute__((unused)) struct cmdline *cl,
9516 __attribute__((unused)) void *data)
9519 struct rte_eth_flex_filter filter;
9520 struct cmd_flex_filter_result *res = parsed_result;
9521 char *bytes_ptr, *mask_ptr;
9522 uint16_t len, i, j = 0;
9527 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) {
9528 printf("the len exceed the max length 128\n");
9531 memset(&filter, 0, sizeof(struct rte_eth_flex_filter));
9532 filter.len = res->len_value;
9533 filter.priority = res->priority_value;
9534 filter.queue = res->queue_id;
9535 bytes_ptr = res->bytes_value;
9536 mask_ptr = res->mask_value;
9538 /* translate bytes string to array. */
9539 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
9540 (bytes_ptr[1] == 'X')))
9542 len = strnlen(bytes_ptr, res->len_value * 2);
9543 if (len == 0 || (len % 8 != 0)) {
9544 printf("please check len and bytes input\n");
9547 for (i = 0; i < len; i++) {
9549 if (isxdigit(c) == 0) {
9550 /* invalid characters. */
9551 printf("invalid input\n");
9554 val = xdigit2val(c);
9557 filter.bytes[j] = byte;
9558 printf("bytes[%d]:%02x ", j, filter.bytes[j]);
9565 /* translate mask string to uint8_t array. */
9566 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
9567 (mask_ptr[1] == 'X')))
9569 len = strnlen(mask_ptr, (res->len_value + 3) / 4);
9571 printf("invalid input\n");
9576 for (i = 0; i < len; i++) {
9578 if (isxdigit(c) == 0) {
9579 /* invalid characters. */
9580 printf("invalid input\n");
9583 val = xdigit2val(c);
9586 filter.mask[j] = byte;
9587 printf("mask[%d]:%02x ", j, filter.mask[j]);
9595 if (!strcmp(res->ops, "add"))
9596 ret = rte_eth_dev_filter_ctrl(res->port_id,
9597 RTE_ETH_FILTER_FLEXIBLE,
9601 ret = rte_eth_dev_filter_ctrl(res->port_id,
9602 RTE_ETH_FILTER_FLEXIBLE,
9603 RTE_ETH_FILTER_DELETE,
9607 printf("flex filter setting error: (%s)\n", strerror(-ret));
9610 cmdline_parse_token_string_t cmd_flex_filter_filter =
9611 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9612 filter, "flex_filter");
9613 cmdline_parse_token_num_t cmd_flex_filter_port_id =
9614 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
9616 cmdline_parse_token_string_t cmd_flex_filter_ops =
9617 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9619 cmdline_parse_token_string_t cmd_flex_filter_len =
9620 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9622 cmdline_parse_token_num_t cmd_flex_filter_len_value =
9623 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
9625 cmdline_parse_token_string_t cmd_flex_filter_bytes =
9626 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9628 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
9629 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9631 cmdline_parse_token_string_t cmd_flex_filter_mask =
9632 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9634 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
9635 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9637 cmdline_parse_token_string_t cmd_flex_filter_priority =
9638 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9639 priority, "priority");
9640 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
9641 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
9642 priority_value, UINT8);
9643 cmdline_parse_token_string_t cmd_flex_filter_queue =
9644 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
9646 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
9647 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
9649 cmdline_parse_inst_t cmd_flex_filter = {
9650 .f = cmd_flex_filter_parsed,
9652 .help_str = "flex_filter <port_id> add|del len <value> bytes "
9653 "<value> mask <value> priority <value> queue <queue_id>: "
9654 "Add/Del a flex filter",
9656 (void *)&cmd_flex_filter_filter,
9657 (void *)&cmd_flex_filter_port_id,
9658 (void *)&cmd_flex_filter_ops,
9659 (void *)&cmd_flex_filter_len,
9660 (void *)&cmd_flex_filter_len_value,
9661 (void *)&cmd_flex_filter_bytes,
9662 (void *)&cmd_flex_filter_bytes_value,
9663 (void *)&cmd_flex_filter_mask,
9664 (void *)&cmd_flex_filter_mask_value,
9665 (void *)&cmd_flex_filter_priority,
9666 (void *)&cmd_flex_filter_priority_value,
9667 (void *)&cmd_flex_filter_queue,
9668 (void *)&cmd_flex_filter_queue_id,
9673 /* *** Filters Control *** */
9675 /* *** deal with ethertype filter *** */
9676 struct cmd_ethertype_filter_result {
9677 cmdline_fixed_string_t filter;
9679 cmdline_fixed_string_t ops;
9680 cmdline_fixed_string_t mac;
9681 struct ether_addr mac_addr;
9682 cmdline_fixed_string_t ethertype;
9683 uint16_t ethertype_value;
9684 cmdline_fixed_string_t drop;
9685 cmdline_fixed_string_t queue;
9689 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
9690 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9691 filter, "ethertype_filter");
9692 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
9693 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
9695 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
9696 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9698 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
9699 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9700 mac, "mac_addr#mac_ignr");
9701 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
9702 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
9704 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
9705 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9706 ethertype, "ethertype");
9707 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
9708 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
9709 ethertype_value, UINT16);
9710 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
9711 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9713 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
9714 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
9716 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
9717 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
9721 cmd_ethertype_filter_parsed(void *parsed_result,
9722 __attribute__((unused)) struct cmdline *cl,
9723 __attribute__((unused)) void *data)
9725 struct cmd_ethertype_filter_result *res = parsed_result;
9726 struct rte_eth_ethertype_filter filter;
9729 ret = rte_eth_dev_filter_supported(res->port_id,
9730 RTE_ETH_FILTER_ETHERTYPE);
9732 printf("ethertype filter is not supported on port %u.\n",
9737 memset(&filter, 0, sizeof(filter));
9738 if (!strcmp(res->mac, "mac_addr")) {
9739 filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
9740 rte_memcpy(&filter.mac_addr, &res->mac_addr,
9741 sizeof(struct ether_addr));
9743 if (!strcmp(res->drop, "drop"))
9744 filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
9745 filter.ether_type = res->ethertype_value;
9746 filter.queue = res->queue_id;
9748 if (!strcmp(res->ops, "add"))
9749 ret = rte_eth_dev_filter_ctrl(res->port_id,
9750 RTE_ETH_FILTER_ETHERTYPE,
9754 ret = rte_eth_dev_filter_ctrl(res->port_id,
9755 RTE_ETH_FILTER_ETHERTYPE,
9756 RTE_ETH_FILTER_DELETE,
9759 printf("ethertype filter programming error: (%s)\n",
9763 cmdline_parse_inst_t cmd_ethertype_filter = {
9764 .f = cmd_ethertype_filter_parsed,
9766 .help_str = "ethertype_filter <port_id> add|del mac_addr|mac_ignr "
9767 "<mac_addr> ethertype <value> drop|fw queue <queue_id>: "
9768 "Add or delete an ethertype filter entry",
9770 (void *)&cmd_ethertype_filter_filter,
9771 (void *)&cmd_ethertype_filter_port_id,
9772 (void *)&cmd_ethertype_filter_ops,
9773 (void *)&cmd_ethertype_filter_mac,
9774 (void *)&cmd_ethertype_filter_mac_addr,
9775 (void *)&cmd_ethertype_filter_ethertype,
9776 (void *)&cmd_ethertype_filter_ethertype_value,
9777 (void *)&cmd_ethertype_filter_drop,
9778 (void *)&cmd_ethertype_filter_queue,
9779 (void *)&cmd_ethertype_filter_queue_id,
9784 /* *** deal with flow director filter *** */
9785 struct cmd_flow_director_result {
9786 cmdline_fixed_string_t flow_director_filter;
9788 cmdline_fixed_string_t mode;
9789 cmdline_fixed_string_t mode_value;
9790 cmdline_fixed_string_t ops;
9791 cmdline_fixed_string_t flow;
9792 cmdline_fixed_string_t flow_type;
9793 cmdline_fixed_string_t ether;
9794 uint16_t ether_type;
9795 cmdline_fixed_string_t src;
9796 cmdline_ipaddr_t ip_src;
9798 cmdline_fixed_string_t dst;
9799 cmdline_ipaddr_t ip_dst;
9801 cmdline_fixed_string_t verify_tag;
9802 uint32_t verify_tag_value;
9803 cmdline_ipaddr_t tos;
9805 cmdline_ipaddr_t proto;
9806 uint8_t proto_value;
9807 cmdline_ipaddr_t ttl;
9809 cmdline_fixed_string_t vlan;
9810 uint16_t vlan_value;
9811 cmdline_fixed_string_t flexbytes;
9812 cmdline_fixed_string_t flexbytes_value;
9813 cmdline_fixed_string_t pf_vf;
9814 cmdline_fixed_string_t drop;
9815 cmdline_fixed_string_t queue;
9817 cmdline_fixed_string_t fd_id;
9818 uint32_t fd_id_value;
9819 cmdline_fixed_string_t mac;
9820 struct ether_addr mac_addr;
9821 cmdline_fixed_string_t tunnel;
9822 cmdline_fixed_string_t tunnel_type;
9823 cmdline_fixed_string_t tunnel_id;
9824 uint32_t tunnel_id_value;
9828 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
9831 const char *p, *p0 = q_arg;
9833 unsigned long int_fld;
9834 char *str_fld[max_num];
9839 p = strchr(p0, '(');
9843 p0 = strchr(p, ')');
9848 if (size >= sizeof(s))
9851 snprintf(s, sizeof(s), "%.*s", size, p);
9852 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
9853 if (ret < 0 || ret > max_num)
9855 for (i = 0; i < ret; i++) {
9857 int_fld = strtoul(str_fld[i], &end, 0);
9858 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
9860 flexbytes[i] = (uint8_t)int_fld;
9866 str2flowtype(char *string)
9869 static const struct {
9872 } flowtype_str[] = {
9873 {"raw", RTE_ETH_FLOW_RAW},
9874 {"ipv4", RTE_ETH_FLOW_IPV4},
9875 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
9876 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
9877 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
9878 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
9879 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
9880 {"ipv6", RTE_ETH_FLOW_IPV6},
9881 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
9882 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
9883 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
9884 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
9885 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
9886 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
9889 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
9890 if (!strcmp(flowtype_str[i].str, string))
9891 return flowtype_str[i].type;
9894 if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64)
9895 return (uint16_t)atoi(string);
9897 return RTE_ETH_FLOW_UNKNOWN;
9900 static enum rte_eth_fdir_tunnel_type
9901 str2fdir_tunneltype(char *string)
9905 static const struct {
9907 enum rte_eth_fdir_tunnel_type type;
9908 } tunneltype_str[] = {
9909 {"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE},
9910 {"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN},
9913 for (i = 0; i < RTE_DIM(tunneltype_str); i++) {
9914 if (!strcmp(tunneltype_str[i].str, string))
9915 return tunneltype_str[i].type;
9917 return RTE_FDIR_TUNNEL_TYPE_UNKNOWN;
9920 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
9922 if ((ip_addr).family == AF_INET) \
9923 (ip) = (ip_addr).addr.ipv4.s_addr; \
9925 printf("invalid parameter.\n"); \
9930 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
9932 if ((ip_addr).family == AF_INET6) \
9934 &((ip_addr).addr.ipv6), \
9935 sizeof(struct in6_addr)); \
9937 printf("invalid parameter.\n"); \
9943 cmd_flow_director_filter_parsed(void *parsed_result,
9944 __attribute__((unused)) struct cmdline *cl,
9945 __attribute__((unused)) void *data)
9947 struct cmd_flow_director_result *res = parsed_result;
9948 struct rte_eth_fdir_filter entry;
9949 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
9951 unsigned long vf_id;
9954 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
9956 printf("flow director is not supported on port %u.\n",
9960 memset(flexbytes, 0, sizeof(flexbytes));
9961 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
9963 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
9964 if (strcmp(res->mode_value, "MAC-VLAN")) {
9965 printf("Please set mode to MAC-VLAN.\n");
9968 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
9969 if (strcmp(res->mode_value, "Tunnel")) {
9970 printf("Please set mode to Tunnel.\n");
9974 if (strcmp(res->mode_value, "IP")) {
9975 printf("Please set mode to IP.\n");
9978 entry.input.flow_type = str2flowtype(res->flow_type);
9981 ret = parse_flexbytes(res->flexbytes_value,
9983 RTE_ETH_FDIR_MAX_FLEXLEN);
9985 printf("error: Cannot parse flexbytes input.\n");
9989 switch (entry.input.flow_type) {
9990 case RTE_ETH_FLOW_FRAG_IPV4:
9991 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
9992 entry.input.flow.ip4_flow.proto = res->proto_value;
9994 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
9995 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
9996 IPV4_ADDR_TO_UINT(res->ip_dst,
9997 entry.input.flow.ip4_flow.dst_ip);
9998 IPV4_ADDR_TO_UINT(res->ip_src,
9999 entry.input.flow.ip4_flow.src_ip);
10000 entry.input.flow.ip4_flow.tos = res->tos_value;
10001 entry.input.flow.ip4_flow.ttl = res->ttl_value;
10002 /* need convert to big endian. */
10003 entry.input.flow.udp4_flow.dst_port =
10004 rte_cpu_to_be_16(res->port_dst);
10005 entry.input.flow.udp4_flow.src_port =
10006 rte_cpu_to_be_16(res->port_src);
10008 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
10009 IPV4_ADDR_TO_UINT(res->ip_dst,
10010 entry.input.flow.sctp4_flow.ip.dst_ip);
10011 IPV4_ADDR_TO_UINT(res->ip_src,
10012 entry.input.flow.sctp4_flow.ip.src_ip);
10013 entry.input.flow.ip4_flow.tos = res->tos_value;
10014 entry.input.flow.ip4_flow.ttl = res->ttl_value;
10015 /* need convert to big endian. */
10016 entry.input.flow.sctp4_flow.dst_port =
10017 rte_cpu_to_be_16(res->port_dst);
10018 entry.input.flow.sctp4_flow.src_port =
10019 rte_cpu_to_be_16(res->port_src);
10020 entry.input.flow.sctp4_flow.verify_tag =
10021 rte_cpu_to_be_32(res->verify_tag_value);
10023 case RTE_ETH_FLOW_FRAG_IPV6:
10024 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
10025 entry.input.flow.ipv6_flow.proto = res->proto_value;
10027 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
10028 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
10029 IPV6_ADDR_TO_ARRAY(res->ip_dst,
10030 entry.input.flow.ipv6_flow.dst_ip);
10031 IPV6_ADDR_TO_ARRAY(res->ip_src,
10032 entry.input.flow.ipv6_flow.src_ip);
10033 entry.input.flow.ipv6_flow.tc = res->tos_value;
10034 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
10035 /* need convert to big endian. */
10036 entry.input.flow.udp6_flow.dst_port =
10037 rte_cpu_to_be_16(res->port_dst);
10038 entry.input.flow.udp6_flow.src_port =
10039 rte_cpu_to_be_16(res->port_src);
10041 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
10042 IPV6_ADDR_TO_ARRAY(res->ip_dst,
10043 entry.input.flow.sctp6_flow.ip.dst_ip);
10044 IPV6_ADDR_TO_ARRAY(res->ip_src,
10045 entry.input.flow.sctp6_flow.ip.src_ip);
10046 entry.input.flow.ipv6_flow.tc = res->tos_value;
10047 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
10048 /* need convert to big endian. */
10049 entry.input.flow.sctp6_flow.dst_port =
10050 rte_cpu_to_be_16(res->port_dst);
10051 entry.input.flow.sctp6_flow.src_port =
10052 rte_cpu_to_be_16(res->port_src);
10053 entry.input.flow.sctp6_flow.verify_tag =
10054 rte_cpu_to_be_32(res->verify_tag_value);
10056 case RTE_ETH_FLOW_L2_PAYLOAD:
10057 entry.input.flow.l2_flow.ether_type =
10058 rte_cpu_to_be_16(res->ether_type);
10064 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN)
10065 rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr,
10067 sizeof(struct ether_addr));
10069 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
10070 rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr,
10072 sizeof(struct ether_addr));
10073 entry.input.flow.tunnel_flow.tunnel_type =
10074 str2fdir_tunneltype(res->tunnel_type);
10075 entry.input.flow.tunnel_flow.tunnel_id =
10076 rte_cpu_to_be_32(res->tunnel_id_value);
10079 rte_memcpy(entry.input.flow_ext.flexbytes,
10081 RTE_ETH_FDIR_MAX_FLEXLEN);
10083 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
10085 entry.action.flex_off = 0; /*use 0 by default */
10086 if (!strcmp(res->drop, "drop"))
10087 entry.action.behavior = RTE_ETH_FDIR_REJECT;
10089 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
10091 if (fdir_conf.mode != RTE_FDIR_MODE_PERFECT_MAC_VLAN &&
10092 fdir_conf.mode != RTE_FDIR_MODE_PERFECT_TUNNEL) {
10093 if (!strcmp(res->pf_vf, "pf"))
10094 entry.input.flow_ext.is_vf = 0;
10095 else if (!strncmp(res->pf_vf, "vf", 2)) {
10096 struct rte_eth_dev_info dev_info;
10098 memset(&dev_info, 0, sizeof(dev_info));
10099 rte_eth_dev_info_get(res->port_id, &dev_info);
10101 vf_id = strtoul(res->pf_vf + 2, &end, 10);
10102 if (errno != 0 || *end != '\0' ||
10103 vf_id >= dev_info.max_vfs) {
10104 printf("invalid parameter %s.\n", res->pf_vf);
10107 entry.input.flow_ext.is_vf = 1;
10108 entry.input.flow_ext.dst_id = (uint16_t)vf_id;
10110 printf("invalid parameter %s.\n", res->pf_vf);
10115 /* set to report FD ID by default */
10116 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
10117 entry.action.rx_queue = res->queue_id;
10118 entry.soft_id = res->fd_id_value;
10119 if (!strcmp(res->ops, "add"))
10120 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10121 RTE_ETH_FILTER_ADD, &entry);
10122 else if (!strcmp(res->ops, "del"))
10123 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10124 RTE_ETH_FILTER_DELETE, &entry);
10126 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10127 RTE_ETH_FILTER_UPDATE, &entry);
10129 printf("flow director programming error: (%s)\n",
10133 cmdline_parse_token_string_t cmd_flow_director_filter =
10134 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10135 flow_director_filter, "flow_director_filter");
10136 cmdline_parse_token_num_t cmd_flow_director_port_id =
10137 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10139 cmdline_parse_token_string_t cmd_flow_director_ops =
10140 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10141 ops, "add#del#update");
10142 cmdline_parse_token_string_t cmd_flow_director_flow =
10143 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10145 cmdline_parse_token_string_t cmd_flow_director_flow_type =
10146 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10147 flow_type, "ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
10148 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload");
10149 cmdline_parse_token_string_t cmd_flow_director_ether =
10150 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10152 cmdline_parse_token_num_t cmd_flow_director_ether_type =
10153 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10154 ether_type, UINT16);
10155 cmdline_parse_token_string_t cmd_flow_director_src =
10156 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10158 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
10159 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
10161 cmdline_parse_token_num_t cmd_flow_director_port_src =
10162 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10164 cmdline_parse_token_string_t cmd_flow_director_dst =
10165 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10167 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
10168 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
10170 cmdline_parse_token_num_t cmd_flow_director_port_dst =
10171 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10173 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
10174 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10175 verify_tag, "verify_tag");
10176 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
10177 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10178 verify_tag_value, UINT32);
10179 cmdline_parse_token_string_t cmd_flow_director_tos =
10180 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10182 cmdline_parse_token_num_t cmd_flow_director_tos_value =
10183 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10185 cmdline_parse_token_string_t cmd_flow_director_proto =
10186 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10188 cmdline_parse_token_num_t cmd_flow_director_proto_value =
10189 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10190 proto_value, UINT8);
10191 cmdline_parse_token_string_t cmd_flow_director_ttl =
10192 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10194 cmdline_parse_token_num_t cmd_flow_director_ttl_value =
10195 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10197 cmdline_parse_token_string_t cmd_flow_director_vlan =
10198 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10200 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
10201 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10202 vlan_value, UINT16);
10203 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
10204 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10205 flexbytes, "flexbytes");
10206 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
10207 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10208 flexbytes_value, NULL);
10209 cmdline_parse_token_string_t cmd_flow_director_drop =
10210 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10212 cmdline_parse_token_string_t cmd_flow_director_pf_vf =
10213 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10215 cmdline_parse_token_string_t cmd_flow_director_queue =
10216 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10218 cmdline_parse_token_num_t cmd_flow_director_queue_id =
10219 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10221 cmdline_parse_token_string_t cmd_flow_director_fd_id =
10222 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10224 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
10225 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10226 fd_id_value, UINT32);
10228 cmdline_parse_token_string_t cmd_flow_director_mode =
10229 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10231 cmdline_parse_token_string_t cmd_flow_director_mode_ip =
10232 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10234 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan =
10235 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10236 mode_value, "MAC-VLAN");
10237 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel =
10238 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10239 mode_value, "Tunnel");
10240 cmdline_parse_token_string_t cmd_flow_director_mac =
10241 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10243 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr =
10244 TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result,
10246 cmdline_parse_token_string_t cmd_flow_director_tunnel =
10247 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10249 cmdline_parse_token_string_t cmd_flow_director_tunnel_type =
10250 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10251 tunnel_type, "NVGRE#VxLAN");
10252 cmdline_parse_token_string_t cmd_flow_director_tunnel_id =
10253 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10254 tunnel_id, "tunnel-id");
10255 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value =
10256 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10257 tunnel_id_value, UINT32);
10259 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
10260 .f = cmd_flow_director_filter_parsed,
10262 .help_str = "flow_director_filter <port_id> mode IP add|del|update flow"
10263 " ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
10264 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
10265 "l2_payload src <src_ip> dst <dst_ip> tos <tos_value> "
10266 "proto <proto_value> ttl <ttl_value> vlan <vlan_value> "
10267 "flexbytes <flexbyte_values> drop|fw <pf_vf> queue <queue_id> "
10268 "fd_id <fd_id_value>: "
10269 "Add or delete an ip flow director entry on NIC",
10271 (void *)&cmd_flow_director_filter,
10272 (void *)&cmd_flow_director_port_id,
10273 (void *)&cmd_flow_director_mode,
10274 (void *)&cmd_flow_director_mode_ip,
10275 (void *)&cmd_flow_director_ops,
10276 (void *)&cmd_flow_director_flow,
10277 (void *)&cmd_flow_director_flow_type,
10278 (void *)&cmd_flow_director_src,
10279 (void *)&cmd_flow_director_ip_src,
10280 (void *)&cmd_flow_director_dst,
10281 (void *)&cmd_flow_director_ip_dst,
10282 (void *)&cmd_flow_director_tos,
10283 (void *)&cmd_flow_director_tos_value,
10284 (void *)&cmd_flow_director_proto,
10285 (void *)&cmd_flow_director_proto_value,
10286 (void *)&cmd_flow_director_ttl,
10287 (void *)&cmd_flow_director_ttl_value,
10288 (void *)&cmd_flow_director_vlan,
10289 (void *)&cmd_flow_director_vlan_value,
10290 (void *)&cmd_flow_director_flexbytes,
10291 (void *)&cmd_flow_director_flexbytes_value,
10292 (void *)&cmd_flow_director_drop,
10293 (void *)&cmd_flow_director_pf_vf,
10294 (void *)&cmd_flow_director_queue,
10295 (void *)&cmd_flow_director_queue_id,
10296 (void *)&cmd_flow_director_fd_id,
10297 (void *)&cmd_flow_director_fd_id_value,
10302 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
10303 .f = cmd_flow_director_filter_parsed,
10305 .help_str = "flow_director_filter ... : Add or delete an udp/tcp flow "
10306 "director entry on NIC",
10308 (void *)&cmd_flow_director_filter,
10309 (void *)&cmd_flow_director_port_id,
10310 (void *)&cmd_flow_director_mode,
10311 (void *)&cmd_flow_director_mode_ip,
10312 (void *)&cmd_flow_director_ops,
10313 (void *)&cmd_flow_director_flow,
10314 (void *)&cmd_flow_director_flow_type,
10315 (void *)&cmd_flow_director_src,
10316 (void *)&cmd_flow_director_ip_src,
10317 (void *)&cmd_flow_director_port_src,
10318 (void *)&cmd_flow_director_dst,
10319 (void *)&cmd_flow_director_ip_dst,
10320 (void *)&cmd_flow_director_port_dst,
10321 (void *)&cmd_flow_director_tos,
10322 (void *)&cmd_flow_director_tos_value,
10323 (void *)&cmd_flow_director_ttl,
10324 (void *)&cmd_flow_director_ttl_value,
10325 (void *)&cmd_flow_director_vlan,
10326 (void *)&cmd_flow_director_vlan_value,
10327 (void *)&cmd_flow_director_flexbytes,
10328 (void *)&cmd_flow_director_flexbytes_value,
10329 (void *)&cmd_flow_director_drop,
10330 (void *)&cmd_flow_director_pf_vf,
10331 (void *)&cmd_flow_director_queue,
10332 (void *)&cmd_flow_director_queue_id,
10333 (void *)&cmd_flow_director_fd_id,
10334 (void *)&cmd_flow_director_fd_id_value,
10339 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
10340 .f = cmd_flow_director_filter_parsed,
10342 .help_str = "flow_director_filter ... : Add or delete a sctp flow "
10343 "director entry on NIC",
10345 (void *)&cmd_flow_director_filter,
10346 (void *)&cmd_flow_director_port_id,
10347 (void *)&cmd_flow_director_mode,
10348 (void *)&cmd_flow_director_mode_ip,
10349 (void *)&cmd_flow_director_ops,
10350 (void *)&cmd_flow_director_flow,
10351 (void *)&cmd_flow_director_flow_type,
10352 (void *)&cmd_flow_director_src,
10353 (void *)&cmd_flow_director_ip_src,
10354 (void *)&cmd_flow_director_port_dst,
10355 (void *)&cmd_flow_director_dst,
10356 (void *)&cmd_flow_director_ip_dst,
10357 (void *)&cmd_flow_director_port_dst,
10358 (void *)&cmd_flow_director_verify_tag,
10359 (void *)&cmd_flow_director_verify_tag_value,
10360 (void *)&cmd_flow_director_tos,
10361 (void *)&cmd_flow_director_tos_value,
10362 (void *)&cmd_flow_director_ttl,
10363 (void *)&cmd_flow_director_ttl_value,
10364 (void *)&cmd_flow_director_vlan,
10365 (void *)&cmd_flow_director_vlan_value,
10366 (void *)&cmd_flow_director_flexbytes,
10367 (void *)&cmd_flow_director_flexbytes_value,
10368 (void *)&cmd_flow_director_drop,
10369 (void *)&cmd_flow_director_pf_vf,
10370 (void *)&cmd_flow_director_queue,
10371 (void *)&cmd_flow_director_queue_id,
10372 (void *)&cmd_flow_director_fd_id,
10373 (void *)&cmd_flow_director_fd_id_value,
10378 cmdline_parse_inst_t cmd_add_del_l2_flow_director = {
10379 .f = cmd_flow_director_filter_parsed,
10381 .help_str = "flow_director_filter ... : Add or delete a L2 flow "
10382 "director entry on NIC",
10384 (void *)&cmd_flow_director_filter,
10385 (void *)&cmd_flow_director_port_id,
10386 (void *)&cmd_flow_director_mode,
10387 (void *)&cmd_flow_director_mode_ip,
10388 (void *)&cmd_flow_director_ops,
10389 (void *)&cmd_flow_director_flow,
10390 (void *)&cmd_flow_director_flow_type,
10391 (void *)&cmd_flow_director_ether,
10392 (void *)&cmd_flow_director_ether_type,
10393 (void *)&cmd_flow_director_flexbytes,
10394 (void *)&cmd_flow_director_flexbytes_value,
10395 (void *)&cmd_flow_director_drop,
10396 (void *)&cmd_flow_director_pf_vf,
10397 (void *)&cmd_flow_director_queue,
10398 (void *)&cmd_flow_director_queue_id,
10399 (void *)&cmd_flow_director_fd_id,
10400 (void *)&cmd_flow_director_fd_id_value,
10405 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = {
10406 .f = cmd_flow_director_filter_parsed,
10408 .help_str = "flow_director_filter ... : Add or delete a MAC VLAN flow "
10409 "director entry on NIC",
10411 (void *)&cmd_flow_director_filter,
10412 (void *)&cmd_flow_director_port_id,
10413 (void *)&cmd_flow_director_mode,
10414 (void *)&cmd_flow_director_mode_mac_vlan,
10415 (void *)&cmd_flow_director_ops,
10416 (void *)&cmd_flow_director_mac,
10417 (void *)&cmd_flow_director_mac_addr,
10418 (void *)&cmd_flow_director_vlan,
10419 (void *)&cmd_flow_director_vlan_value,
10420 (void *)&cmd_flow_director_flexbytes,
10421 (void *)&cmd_flow_director_flexbytes_value,
10422 (void *)&cmd_flow_director_drop,
10423 (void *)&cmd_flow_director_queue,
10424 (void *)&cmd_flow_director_queue_id,
10425 (void *)&cmd_flow_director_fd_id,
10426 (void *)&cmd_flow_director_fd_id_value,
10431 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = {
10432 .f = cmd_flow_director_filter_parsed,
10434 .help_str = "flow_director_filter ... : Add or delete a tunnel flow "
10435 "director entry on NIC",
10437 (void *)&cmd_flow_director_filter,
10438 (void *)&cmd_flow_director_port_id,
10439 (void *)&cmd_flow_director_mode,
10440 (void *)&cmd_flow_director_mode_tunnel,
10441 (void *)&cmd_flow_director_ops,
10442 (void *)&cmd_flow_director_mac,
10443 (void *)&cmd_flow_director_mac_addr,
10444 (void *)&cmd_flow_director_vlan,
10445 (void *)&cmd_flow_director_vlan_value,
10446 (void *)&cmd_flow_director_tunnel,
10447 (void *)&cmd_flow_director_tunnel_type,
10448 (void *)&cmd_flow_director_tunnel_id,
10449 (void *)&cmd_flow_director_tunnel_id_value,
10450 (void *)&cmd_flow_director_flexbytes,
10451 (void *)&cmd_flow_director_flexbytes_value,
10452 (void *)&cmd_flow_director_drop,
10453 (void *)&cmd_flow_director_queue,
10454 (void *)&cmd_flow_director_queue_id,
10455 (void *)&cmd_flow_director_fd_id,
10456 (void *)&cmd_flow_director_fd_id_value,
10461 struct cmd_flush_flow_director_result {
10462 cmdline_fixed_string_t flush_flow_director;
10466 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
10467 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
10468 flush_flow_director, "flush_flow_director");
10469 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
10470 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
10474 cmd_flush_flow_director_parsed(void *parsed_result,
10475 __attribute__((unused)) struct cmdline *cl,
10476 __attribute__((unused)) void *data)
10478 struct cmd_flow_director_result *res = parsed_result;
10481 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
10483 printf("flow director is not supported on port %u.\n",
10488 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10489 RTE_ETH_FILTER_FLUSH, NULL);
10491 printf("flow director table flushing error: (%s)\n",
10495 cmdline_parse_inst_t cmd_flush_flow_director = {
10496 .f = cmd_flush_flow_director_parsed,
10498 .help_str = "flush_flow_director <port_id>: "
10499 "Flush all flow director entries of a device on NIC",
10501 (void *)&cmd_flush_flow_director_flush,
10502 (void *)&cmd_flush_flow_director_port_id,
10507 /* *** deal with flow director mask *** */
10508 struct cmd_flow_director_mask_result {
10509 cmdline_fixed_string_t flow_director_mask;
10511 cmdline_fixed_string_t mode;
10512 cmdline_fixed_string_t mode_value;
10513 cmdline_fixed_string_t vlan;
10514 uint16_t vlan_mask;
10515 cmdline_fixed_string_t src_mask;
10516 cmdline_ipaddr_t ipv4_src;
10517 cmdline_ipaddr_t ipv6_src;
10519 cmdline_fixed_string_t dst_mask;
10520 cmdline_ipaddr_t ipv4_dst;
10521 cmdline_ipaddr_t ipv6_dst;
10523 cmdline_fixed_string_t mac;
10524 uint8_t mac_addr_byte_mask;
10525 cmdline_fixed_string_t tunnel_id;
10526 uint32_t tunnel_id_mask;
10527 cmdline_fixed_string_t tunnel_type;
10528 uint8_t tunnel_type_mask;
10532 cmd_flow_director_mask_parsed(void *parsed_result,
10533 __attribute__((unused)) struct cmdline *cl,
10534 __attribute__((unused)) void *data)
10536 struct cmd_flow_director_mask_result *res = parsed_result;
10537 struct rte_eth_fdir_masks *mask;
10538 struct rte_port *port;
10540 if (res->port_id > nb_ports) {
10541 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
10545 port = &ports[res->port_id];
10546 /** Check if the port is not started **/
10547 if (port->port_status != RTE_PORT_STOPPED) {
10548 printf("Please stop port %d first\n", res->port_id);
10552 mask = &port->dev_conf.fdir_conf.mask;
10554 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
10555 if (strcmp(res->mode_value, "MAC-VLAN")) {
10556 printf("Please set mode to MAC-VLAN.\n");
10560 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10561 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
10562 if (strcmp(res->mode_value, "Tunnel")) {
10563 printf("Please set mode to Tunnel.\n");
10567 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10568 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
10569 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
10570 mask->tunnel_type_mask = res->tunnel_type_mask;
10572 if (strcmp(res->mode_value, "IP")) {
10573 printf("Please set mode to IP.\n");
10577 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10578 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
10579 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
10580 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
10581 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
10582 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
10583 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
10586 cmd_reconfig_device_queue(res->port_id, 1, 1);
10589 cmdline_parse_token_string_t cmd_flow_director_mask =
10590 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10591 flow_director_mask, "flow_director_mask");
10592 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
10593 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10595 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
10596 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10598 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
10599 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10600 vlan_mask, UINT16);
10601 cmdline_parse_token_string_t cmd_flow_director_mask_src =
10602 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10603 src_mask, "src_mask");
10604 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
10605 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10607 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
10608 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10610 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
10611 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10613 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
10614 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10615 dst_mask, "dst_mask");
10616 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
10617 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10619 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
10620 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10622 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
10623 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10626 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
10627 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10629 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
10630 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10632 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
10633 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10634 mode_value, "MAC-VLAN");
10635 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
10636 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10637 mode_value, "Tunnel");
10638 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
10639 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10641 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
10642 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10643 mac_addr_byte_mask, UINT8);
10644 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
10645 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10646 tunnel_type, "tunnel-type");
10647 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
10648 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10649 tunnel_type_mask, UINT8);
10650 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
10651 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10652 tunnel_id, "tunnel-id");
10653 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
10654 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10655 tunnel_id_mask, UINT32);
10657 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
10658 .f = cmd_flow_director_mask_parsed,
10660 .help_str = "flow_director_mask ... : "
10661 "Set IP mode flow director's mask on NIC",
10663 (void *)&cmd_flow_director_mask,
10664 (void *)&cmd_flow_director_mask_port_id,
10665 (void *)&cmd_flow_director_mask_mode,
10666 (void *)&cmd_flow_director_mask_mode_ip,
10667 (void *)&cmd_flow_director_mask_vlan,
10668 (void *)&cmd_flow_director_mask_vlan_value,
10669 (void *)&cmd_flow_director_mask_src,
10670 (void *)&cmd_flow_director_mask_ipv4_src,
10671 (void *)&cmd_flow_director_mask_ipv6_src,
10672 (void *)&cmd_flow_director_mask_port_src,
10673 (void *)&cmd_flow_director_mask_dst,
10674 (void *)&cmd_flow_director_mask_ipv4_dst,
10675 (void *)&cmd_flow_director_mask_ipv6_dst,
10676 (void *)&cmd_flow_director_mask_port_dst,
10681 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
10682 .f = cmd_flow_director_mask_parsed,
10684 .help_str = "flow_director_mask ... : Set MAC VLAN mode "
10685 "flow director's mask on NIC",
10687 (void *)&cmd_flow_director_mask,
10688 (void *)&cmd_flow_director_mask_port_id,
10689 (void *)&cmd_flow_director_mask_mode,
10690 (void *)&cmd_flow_director_mask_mode_mac_vlan,
10691 (void *)&cmd_flow_director_mask_vlan,
10692 (void *)&cmd_flow_director_mask_vlan_value,
10697 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
10698 .f = cmd_flow_director_mask_parsed,
10700 .help_str = "flow_director_mask ... : Set tunnel mode "
10701 "flow director's mask on NIC",
10703 (void *)&cmd_flow_director_mask,
10704 (void *)&cmd_flow_director_mask_port_id,
10705 (void *)&cmd_flow_director_mask_mode,
10706 (void *)&cmd_flow_director_mask_mode_tunnel,
10707 (void *)&cmd_flow_director_mask_vlan,
10708 (void *)&cmd_flow_director_mask_vlan_value,
10709 (void *)&cmd_flow_director_mask_mac,
10710 (void *)&cmd_flow_director_mask_mac_value,
10711 (void *)&cmd_flow_director_mask_tunnel_type,
10712 (void *)&cmd_flow_director_mask_tunnel_type_value,
10713 (void *)&cmd_flow_director_mask_tunnel_id,
10714 (void *)&cmd_flow_director_mask_tunnel_id_value,
10719 /* *** deal with flow director mask on flexible payload *** */
10720 struct cmd_flow_director_flex_mask_result {
10721 cmdline_fixed_string_t flow_director_flexmask;
10723 cmdline_fixed_string_t flow;
10724 cmdline_fixed_string_t flow_type;
10725 cmdline_fixed_string_t mask;
10729 cmd_flow_director_flex_mask_parsed(void *parsed_result,
10730 __attribute__((unused)) struct cmdline *cl,
10731 __attribute__((unused)) void *data)
10733 struct cmd_flow_director_flex_mask_result *res = parsed_result;
10734 struct rte_eth_fdir_info fdir_info;
10735 struct rte_eth_fdir_flex_mask flex_mask;
10736 struct rte_port *port;
10737 uint32_t flow_type_mask;
10741 if (res->port_id > nb_ports) {
10742 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
10746 port = &ports[res->port_id];
10747 /** Check if the port is not started **/
10748 if (port->port_status != RTE_PORT_STOPPED) {
10749 printf("Please stop port %d first\n", res->port_id);
10753 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
10754 ret = parse_flexbytes(res->mask,
10756 RTE_ETH_FDIR_MAX_FLEXLEN);
10758 printf("error: Cannot parse mask input.\n");
10762 memset(&fdir_info, 0, sizeof(fdir_info));
10763 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10764 RTE_ETH_FILTER_INFO, &fdir_info);
10766 printf("Cannot get FDir filter info\n");
10770 if (!strcmp(res->flow_type, "none")) {
10771 /* means don't specify the flow type */
10772 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN;
10773 for (i = 0; i < RTE_ETH_FLOW_MAX; i++)
10774 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i],
10775 0, sizeof(struct rte_eth_fdir_flex_mask));
10776 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1;
10777 rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0],
10779 sizeof(struct rte_eth_fdir_flex_mask));
10780 cmd_reconfig_device_queue(res->port_id, 1, 1);
10783 flow_type_mask = fdir_info.flow_types_mask[0];
10784 if (!strcmp(res->flow_type, "all")) {
10785 if (!flow_type_mask) {
10786 printf("No flow type supported\n");
10789 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
10790 if (flow_type_mask & (1 << i)) {
10791 flex_mask.flow_type = i;
10792 fdir_set_flex_mask(res->port_id, &flex_mask);
10795 cmd_reconfig_device_queue(res->port_id, 1, 1);
10798 flex_mask.flow_type = str2flowtype(res->flow_type);
10799 if (!(flow_type_mask & (1 << flex_mask.flow_type))) {
10800 printf("Flow type %s not supported on port %d\n",
10801 res->flow_type, res->port_id);
10804 fdir_set_flex_mask(res->port_id, &flex_mask);
10805 cmd_reconfig_device_queue(res->port_id, 1, 1);
10808 cmdline_parse_token_string_t cmd_flow_director_flexmask =
10809 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
10810 flow_director_flexmask,
10811 "flow_director_flex_mask");
10812 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
10813 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
10815 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
10816 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
10818 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
10819 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
10820 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
10821 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all");
10822 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
10823 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
10826 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
10827 .f = cmd_flow_director_flex_mask_parsed,
10829 .help_str = "flow_director_flex_mask ... : "
10830 "Set flow director's flex mask on NIC",
10832 (void *)&cmd_flow_director_flexmask,
10833 (void *)&cmd_flow_director_flexmask_port_id,
10834 (void *)&cmd_flow_director_flexmask_flow,
10835 (void *)&cmd_flow_director_flexmask_flow_type,
10836 (void *)&cmd_flow_director_flexmask_mask,
10841 /* *** deal with flow director flexible payload configuration *** */
10842 struct cmd_flow_director_flexpayload_result {
10843 cmdline_fixed_string_t flow_director_flexpayload;
10845 cmdline_fixed_string_t payload_layer;
10846 cmdline_fixed_string_t payload_cfg;
10850 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
10853 const char *p, *p0 = q_arg;
10855 unsigned long int_fld;
10856 char *str_fld[max_num];
10861 p = strchr(p0, '(');
10865 p0 = strchr(p, ')');
10870 if (size >= sizeof(s))
10873 snprintf(s, sizeof(s), "%.*s", size, p);
10874 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
10875 if (ret < 0 || ret > max_num)
10877 for (i = 0; i < ret; i++) {
10879 int_fld = strtoul(str_fld[i], &end, 0);
10880 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
10882 offsets[i] = (uint16_t)int_fld;
10888 cmd_flow_director_flxpld_parsed(void *parsed_result,
10889 __attribute__((unused)) struct cmdline *cl,
10890 __attribute__((unused)) void *data)
10892 struct cmd_flow_director_flexpayload_result *res = parsed_result;
10893 struct rte_eth_flex_payload_cfg flex_cfg;
10894 struct rte_port *port;
10897 if (res->port_id > nb_ports) {
10898 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
10902 port = &ports[res->port_id];
10903 /** Check if the port is not started **/
10904 if (port->port_status != RTE_PORT_STOPPED) {
10905 printf("Please stop port %d first\n", res->port_id);
10909 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
10911 if (!strcmp(res->payload_layer, "raw"))
10912 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
10913 else if (!strcmp(res->payload_layer, "l2"))
10914 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
10915 else if (!strcmp(res->payload_layer, "l3"))
10916 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
10917 else if (!strcmp(res->payload_layer, "l4"))
10918 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
10920 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
10921 RTE_ETH_FDIR_MAX_FLEXLEN);
10923 printf("error: Cannot parse flex payload input.\n");
10927 fdir_set_flex_payload(res->port_id, &flex_cfg);
10928 cmd_reconfig_device_queue(res->port_id, 1, 1);
10931 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
10932 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10933 flow_director_flexpayload,
10934 "flow_director_flex_payload");
10935 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
10936 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10938 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
10939 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10940 payload_layer, "raw#l2#l3#l4");
10941 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
10942 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10943 payload_cfg, NULL);
10945 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
10946 .f = cmd_flow_director_flxpld_parsed,
10948 .help_str = "flow_director_flexpayload ... : "
10949 "Set flow director's flex payload on NIC",
10951 (void *)&cmd_flow_director_flexpayload,
10952 (void *)&cmd_flow_director_flexpayload_port_id,
10953 (void *)&cmd_flow_director_flexpayload_payload_layer,
10954 (void *)&cmd_flow_director_flexpayload_payload_cfg,
10959 /* Generic flow interface command. */
10960 extern cmdline_parse_inst_t cmd_flow;
10962 /* *** Classification Filters Control *** */
10963 /* *** Get symmetric hash enable per port *** */
10964 struct cmd_get_sym_hash_ena_per_port_result {
10965 cmdline_fixed_string_t get_sym_hash_ena_per_port;
10970 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
10971 __rte_unused struct cmdline *cl,
10972 __rte_unused void *data)
10974 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
10975 struct rte_eth_hash_filter_info info;
10978 if (rte_eth_dev_filter_supported(res->port_id,
10979 RTE_ETH_FILTER_HASH) < 0) {
10980 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
10985 memset(&info, 0, sizeof(info));
10986 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
10987 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
10988 RTE_ETH_FILTER_GET, &info);
10991 printf("Cannot get symmetric hash enable per port "
10992 "on port %u\n", res->port_id);
10996 printf("Symmetric hash is %s on port %u\n", info.info.enable ?
10997 "enabled" : "disabled", res->port_id);
11000 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
11001 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
11002 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
11003 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
11004 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
11007 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
11008 .f = cmd_get_sym_hash_per_port_parsed,
11010 .help_str = "get_sym_hash_ena_per_port <port_id>",
11012 (void *)&cmd_get_sym_hash_ena_per_port_all,
11013 (void *)&cmd_get_sym_hash_ena_per_port_port_id,
11018 /* *** Set symmetric hash enable per port *** */
11019 struct cmd_set_sym_hash_ena_per_port_result {
11020 cmdline_fixed_string_t set_sym_hash_ena_per_port;
11021 cmdline_fixed_string_t enable;
11026 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
11027 __rte_unused struct cmdline *cl,
11028 __rte_unused void *data)
11030 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
11031 struct rte_eth_hash_filter_info info;
11034 if (rte_eth_dev_filter_supported(res->port_id,
11035 RTE_ETH_FILTER_HASH) < 0) {
11036 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
11041 memset(&info, 0, sizeof(info));
11042 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
11043 if (!strcmp(res->enable, "enable"))
11044 info.info.enable = 1;
11045 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11046 RTE_ETH_FILTER_SET, &info);
11048 printf("Cannot set symmetric hash enable per port on "
11049 "port %u\n", res->port_id);
11052 printf("Symmetric hash has been set to %s on port %u\n",
11053 res->enable, res->port_id);
11056 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
11057 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
11058 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
11059 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
11060 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
11062 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
11063 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
11064 enable, "enable#disable");
11066 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
11067 .f = cmd_set_sym_hash_per_port_parsed,
11069 .help_str = "set_sym_hash_ena_per_port <port_id> enable|disable",
11071 (void *)&cmd_set_sym_hash_ena_per_port_all,
11072 (void *)&cmd_set_sym_hash_ena_per_port_port_id,
11073 (void *)&cmd_set_sym_hash_ena_per_port_enable,
11078 /* Get global config of hash function */
11079 struct cmd_get_hash_global_config_result {
11080 cmdline_fixed_string_t get_hash_global_config;
11085 flowtype_to_str(uint16_t ftype)
11091 } ftype_table[] = {
11092 {"ipv4", RTE_ETH_FLOW_IPV4},
11093 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
11094 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
11095 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
11096 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
11097 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
11098 {"ipv6", RTE_ETH_FLOW_IPV6},
11099 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
11100 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
11101 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
11102 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
11103 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
11104 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
11105 {"port", RTE_ETH_FLOW_PORT},
11106 {"vxlan", RTE_ETH_FLOW_VXLAN},
11107 {"geneve", RTE_ETH_FLOW_GENEVE},
11108 {"nvgre", RTE_ETH_FLOW_NVGRE},
11111 for (i = 0; i < RTE_DIM(ftype_table); i++) {
11112 if (ftype_table[i].ftype == ftype)
11113 return ftype_table[i].str;
11120 cmd_get_hash_global_config_parsed(void *parsed_result,
11121 __rte_unused struct cmdline *cl,
11122 __rte_unused void *data)
11124 struct cmd_get_hash_global_config_result *res = parsed_result;
11125 struct rte_eth_hash_filter_info info;
11126 uint32_t idx, offset;
11131 if (rte_eth_dev_filter_supported(res->port_id,
11132 RTE_ETH_FILTER_HASH) < 0) {
11133 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
11138 memset(&info, 0, sizeof(info));
11139 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
11140 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11141 RTE_ETH_FILTER_GET, &info);
11143 printf("Cannot get hash global configurations by port %d\n",
11148 switch (info.info.global_conf.hash_func) {
11149 case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
11150 printf("Hash function is Toeplitz\n");
11152 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
11153 printf("Hash function is Simple XOR\n");
11156 printf("Unknown hash function\n");
11160 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) {
11161 idx = i / UINT32_BIT;
11162 offset = i % UINT32_BIT;
11163 if (!(info.info.global_conf.valid_bit_mask[idx] &
11166 str = flowtype_to_str(i);
11169 printf("Symmetric hash is %s globally for flow type %s "
11171 ((info.info.global_conf.sym_hash_enable_mask[idx] &
11172 (1UL << offset)) ? "enabled" : "disabled"), str,
11177 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
11178 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
11179 get_hash_global_config, "get_hash_global_config");
11180 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
11181 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
11184 cmdline_parse_inst_t cmd_get_hash_global_config = {
11185 .f = cmd_get_hash_global_config_parsed,
11187 .help_str = "get_hash_global_config <port_id>",
11189 (void *)&cmd_get_hash_global_config_all,
11190 (void *)&cmd_get_hash_global_config_port_id,
11195 /* Set global config of hash function */
11196 struct cmd_set_hash_global_config_result {
11197 cmdline_fixed_string_t set_hash_global_config;
11199 cmdline_fixed_string_t hash_func;
11200 cmdline_fixed_string_t flow_type;
11201 cmdline_fixed_string_t enable;
11205 cmd_set_hash_global_config_parsed(void *parsed_result,
11206 __rte_unused struct cmdline *cl,
11207 __rte_unused void *data)
11209 struct cmd_set_hash_global_config_result *res = parsed_result;
11210 struct rte_eth_hash_filter_info info;
11211 uint32_t ftype, idx, offset;
11214 if (rte_eth_dev_filter_supported(res->port_id,
11215 RTE_ETH_FILTER_HASH) < 0) {
11216 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
11220 memset(&info, 0, sizeof(info));
11221 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
11222 if (!strcmp(res->hash_func, "toeplitz"))
11223 info.info.global_conf.hash_func =
11224 RTE_ETH_HASH_FUNCTION_TOEPLITZ;
11225 else if (!strcmp(res->hash_func, "simple_xor"))
11226 info.info.global_conf.hash_func =
11227 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
11228 else if (!strcmp(res->hash_func, "default"))
11229 info.info.global_conf.hash_func =
11230 RTE_ETH_HASH_FUNCTION_DEFAULT;
11232 ftype = str2flowtype(res->flow_type);
11233 idx = ftype / (CHAR_BIT * sizeof(uint32_t));
11234 offset = ftype % (CHAR_BIT * sizeof(uint32_t));
11235 info.info.global_conf.valid_bit_mask[idx] |= (1UL << offset);
11236 if (!strcmp(res->enable, "enable"))
11237 info.info.global_conf.sym_hash_enable_mask[idx] |=
11239 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11240 RTE_ETH_FILTER_SET, &info);
11242 printf("Cannot set global hash configurations by port %d\n",
11245 printf("Global hash configurations have been set "
11246 "succcessfully by port %d\n", res->port_id);
11249 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
11250 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11251 set_hash_global_config, "set_hash_global_config");
11252 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
11253 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
11255 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
11256 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11257 hash_func, "toeplitz#simple_xor#default");
11258 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
11259 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11261 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
11262 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
11263 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
11264 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11265 enable, "enable#disable");
11267 cmdline_parse_inst_t cmd_set_hash_global_config = {
11268 .f = cmd_set_hash_global_config_parsed,
11270 .help_str = "set_hash_global_config <port_id> "
11271 "toeplitz|simple_xor|default "
11272 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
11273 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
11274 "l2_payload enable|disable",
11276 (void *)&cmd_set_hash_global_config_all,
11277 (void *)&cmd_set_hash_global_config_port_id,
11278 (void *)&cmd_set_hash_global_config_hash_func,
11279 (void *)&cmd_set_hash_global_config_flow_type,
11280 (void *)&cmd_set_hash_global_config_enable,
11285 /* Set hash input set */
11286 struct cmd_set_hash_input_set_result {
11287 cmdline_fixed_string_t set_hash_input_set;
11289 cmdline_fixed_string_t flow_type;
11290 cmdline_fixed_string_t inset_field;
11291 cmdline_fixed_string_t select;
11294 static enum rte_eth_input_set_field
11295 str2inset(char *string)
11299 static const struct {
11301 enum rte_eth_input_set_field inset;
11302 } inset_table[] = {
11303 {"ethertype", RTE_ETH_INPUT_SET_L2_ETHERTYPE},
11304 {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN},
11305 {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN},
11306 {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4},
11307 {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4},
11308 {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS},
11309 {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO},
11310 {"ipv4-ttl", RTE_ETH_INPUT_SET_L3_IP4_TTL},
11311 {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6},
11312 {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6},
11313 {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC},
11314 {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER},
11315 {"ipv6-hop-limits", RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS},
11316 {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT},
11317 {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT},
11318 {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT},
11319 {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT},
11320 {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT},
11321 {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT},
11322 {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG},
11323 {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY},
11324 {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY},
11325 {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD},
11326 {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD},
11327 {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD},
11328 {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD},
11329 {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD},
11330 {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD},
11331 {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD},
11332 {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD},
11333 {"none", RTE_ETH_INPUT_SET_NONE},
11336 for (i = 0; i < RTE_DIM(inset_table); i++) {
11337 if (!strcmp(string, inset_table[i].str))
11338 return inset_table[i].inset;
11341 return RTE_ETH_INPUT_SET_UNKNOWN;
11345 cmd_set_hash_input_set_parsed(void *parsed_result,
11346 __rte_unused struct cmdline *cl,
11347 __rte_unused void *data)
11349 struct cmd_set_hash_input_set_result *res = parsed_result;
11350 struct rte_eth_hash_filter_info info;
11352 memset(&info, 0, sizeof(info));
11353 info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT;
11354 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
11355 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
11356 info.info.input_set_conf.inset_size = 1;
11357 if (!strcmp(res->select, "select"))
11358 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
11359 else if (!strcmp(res->select, "add"))
11360 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
11361 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11362 RTE_ETH_FILTER_SET, &info);
11365 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd =
11366 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
11367 set_hash_input_set, "set_hash_input_set");
11368 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id =
11369 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result,
11371 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type =
11372 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
11374 cmdline_parse_token_string_t cmd_set_hash_input_set_field =
11375 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
11377 "ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
11378 "ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#"
11379 "udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#"
11380 "sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#"
11381 "fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#"
11383 cmdline_parse_token_string_t cmd_set_hash_input_set_select =
11384 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
11385 select, "select#add");
11387 cmdline_parse_inst_t cmd_set_hash_input_set = {
11388 .f = cmd_set_hash_input_set_parsed,
11390 .help_str = "set_hash_input_set <port_id> "
11391 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
11392 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload|<flowtype_id> "
11393 "ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|"
11394 "ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|"
11395 "tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|"
11396 "gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
11397 "fld-7th|fld-8th|none select|add",
11399 (void *)&cmd_set_hash_input_set_cmd,
11400 (void *)&cmd_set_hash_input_set_port_id,
11401 (void *)&cmd_set_hash_input_set_flow_type,
11402 (void *)&cmd_set_hash_input_set_field,
11403 (void *)&cmd_set_hash_input_set_select,
11408 /* Set flow director input set */
11409 struct cmd_set_fdir_input_set_result {
11410 cmdline_fixed_string_t set_fdir_input_set;
11412 cmdline_fixed_string_t flow_type;
11413 cmdline_fixed_string_t inset_field;
11414 cmdline_fixed_string_t select;
11418 cmd_set_fdir_input_set_parsed(void *parsed_result,
11419 __rte_unused struct cmdline *cl,
11420 __rte_unused void *data)
11422 struct cmd_set_fdir_input_set_result *res = parsed_result;
11423 struct rte_eth_fdir_filter_info info;
11425 memset(&info, 0, sizeof(info));
11426 info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT;
11427 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
11428 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
11429 info.info.input_set_conf.inset_size = 1;
11430 if (!strcmp(res->select, "select"))
11431 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
11432 else if (!strcmp(res->select, "add"))
11433 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
11434 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11435 RTE_ETH_FILTER_SET, &info);
11438 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd =
11439 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
11440 set_fdir_input_set, "set_fdir_input_set");
11441 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id =
11442 TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result,
11444 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type =
11445 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
11447 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
11448 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
11449 cmdline_parse_token_string_t cmd_set_fdir_input_set_field =
11450 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
11452 "ivlan#ethertype#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
11453 "ipv4-tos#ipv4-proto#ipv4-ttl#ipv6-tc#ipv6-next-header#"
11454 "ipv6-hop-limits#udp-src-port#udp-dst-port#"
11455 "tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#"
11456 "sctp-veri-tag#none");
11457 cmdline_parse_token_string_t cmd_set_fdir_input_set_select =
11458 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
11459 select, "select#add");
11461 cmdline_parse_inst_t cmd_set_fdir_input_set = {
11462 .f = cmd_set_fdir_input_set_parsed,
11464 .help_str = "set_fdir_input_set <port_id> "
11465 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
11466 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
11467 "ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|"
11468 "ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|ipv6-next-header|"
11469 "ipv6-hop-limits|udp-src-port|udp-dst-port|"
11470 "tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|"
11471 "sctp-veri-tag|none select|add",
11473 (void *)&cmd_set_fdir_input_set_cmd,
11474 (void *)&cmd_set_fdir_input_set_port_id,
11475 (void *)&cmd_set_fdir_input_set_flow_type,
11476 (void *)&cmd_set_fdir_input_set_field,
11477 (void *)&cmd_set_fdir_input_set_select,
11482 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
11483 struct cmd_mcast_addr_result {
11484 cmdline_fixed_string_t mcast_addr_cmd;
11485 cmdline_fixed_string_t what;
11487 struct ether_addr mc_addr;
11490 static void cmd_mcast_addr_parsed(void *parsed_result,
11491 __attribute__((unused)) struct cmdline *cl,
11492 __attribute__((unused)) void *data)
11494 struct cmd_mcast_addr_result *res = parsed_result;
11496 if (!is_multicast_ether_addr(&res->mc_addr)) {
11497 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
11498 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
11499 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
11500 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
11503 if (strcmp(res->what, "add") == 0)
11504 mcast_addr_add(res->port_num, &res->mc_addr);
11506 mcast_addr_remove(res->port_num, &res->mc_addr);
11509 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
11510 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
11511 mcast_addr_cmd, "mcast_addr");
11512 cmdline_parse_token_string_t cmd_mcast_addr_what =
11513 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
11515 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
11516 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT16);
11517 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
11518 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
11520 cmdline_parse_inst_t cmd_mcast_addr = {
11521 .f = cmd_mcast_addr_parsed,
11523 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
11524 "Add/Remove multicast MAC address on port_id",
11526 (void *)&cmd_mcast_addr_cmd,
11527 (void *)&cmd_mcast_addr_what,
11528 (void *)&cmd_mcast_addr_portnum,
11529 (void *)&cmd_mcast_addr_addr,
11534 /* l2 tunnel config
11535 * only support E-tag now.
11538 /* Ether type config */
11539 struct cmd_config_l2_tunnel_eth_type_result {
11540 cmdline_fixed_string_t port;
11541 cmdline_fixed_string_t config;
11542 cmdline_fixed_string_t all;
11544 cmdline_fixed_string_t l2_tunnel;
11545 cmdline_fixed_string_t l2_tunnel_type;
11546 cmdline_fixed_string_t eth_type;
11547 uint16_t eth_type_val;
11550 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port =
11551 TOKEN_STRING_INITIALIZER
11552 (struct cmd_config_l2_tunnel_eth_type_result,
11554 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config =
11555 TOKEN_STRING_INITIALIZER
11556 (struct cmd_config_l2_tunnel_eth_type_result,
11558 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str =
11559 TOKEN_STRING_INITIALIZER
11560 (struct cmd_config_l2_tunnel_eth_type_result,
11562 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id =
11563 TOKEN_NUM_INITIALIZER
11564 (struct cmd_config_l2_tunnel_eth_type_result,
11566 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel =
11567 TOKEN_STRING_INITIALIZER
11568 (struct cmd_config_l2_tunnel_eth_type_result,
11569 l2_tunnel, "l2-tunnel");
11570 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type =
11571 TOKEN_STRING_INITIALIZER
11572 (struct cmd_config_l2_tunnel_eth_type_result,
11573 l2_tunnel_type, "E-tag");
11574 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type =
11575 TOKEN_STRING_INITIALIZER
11576 (struct cmd_config_l2_tunnel_eth_type_result,
11577 eth_type, "ether-type");
11578 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val =
11579 TOKEN_NUM_INITIALIZER
11580 (struct cmd_config_l2_tunnel_eth_type_result,
11581 eth_type_val, UINT16);
11583 static enum rte_eth_tunnel_type
11584 str2fdir_l2_tunnel_type(char *string)
11588 static const struct {
11590 enum rte_eth_tunnel_type type;
11591 } l2_tunnel_type_str[] = {
11592 {"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG},
11595 for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) {
11596 if (!strcmp(l2_tunnel_type_str[i].str, string))
11597 return l2_tunnel_type_str[i].type;
11599 return RTE_TUNNEL_TYPE_NONE;
11602 /* ether type config for all ports */
11604 cmd_config_l2_tunnel_eth_type_all_parsed
11605 (void *parsed_result,
11606 __attribute__((unused)) struct cmdline *cl,
11607 __attribute__((unused)) void *data)
11609 struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result;
11610 struct rte_eth_l2_tunnel_conf entry;
11613 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
11614 entry.ether_type = res->eth_type_val;
11616 RTE_ETH_FOREACH_DEV(pid) {
11617 rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry);
11621 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = {
11622 .f = cmd_config_l2_tunnel_eth_type_all_parsed,
11624 .help_str = "port config all l2-tunnel E-tag ether-type <value>",
11626 (void *)&cmd_config_l2_tunnel_eth_type_port,
11627 (void *)&cmd_config_l2_tunnel_eth_type_config,
11628 (void *)&cmd_config_l2_tunnel_eth_type_all_str,
11629 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
11630 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
11631 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
11632 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
11637 /* ether type config for a specific port */
11639 cmd_config_l2_tunnel_eth_type_specific_parsed(
11640 void *parsed_result,
11641 __attribute__((unused)) struct cmdline *cl,
11642 __attribute__((unused)) void *data)
11644 struct cmd_config_l2_tunnel_eth_type_result *res =
11646 struct rte_eth_l2_tunnel_conf entry;
11648 if (port_id_is_invalid(res->id, ENABLED_WARN))
11651 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
11652 entry.ether_type = res->eth_type_val;
11654 rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry);
11657 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = {
11658 .f = cmd_config_l2_tunnel_eth_type_specific_parsed,
11660 .help_str = "port config <port_id> l2-tunnel E-tag ether-type <value>",
11662 (void *)&cmd_config_l2_tunnel_eth_type_port,
11663 (void *)&cmd_config_l2_tunnel_eth_type_config,
11664 (void *)&cmd_config_l2_tunnel_eth_type_id,
11665 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
11666 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
11667 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
11668 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
11673 /* Enable/disable l2 tunnel */
11674 struct cmd_config_l2_tunnel_en_dis_result {
11675 cmdline_fixed_string_t port;
11676 cmdline_fixed_string_t config;
11677 cmdline_fixed_string_t all;
11679 cmdline_fixed_string_t l2_tunnel;
11680 cmdline_fixed_string_t l2_tunnel_type;
11681 cmdline_fixed_string_t en_dis;
11684 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port =
11685 TOKEN_STRING_INITIALIZER
11686 (struct cmd_config_l2_tunnel_en_dis_result,
11688 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config =
11689 TOKEN_STRING_INITIALIZER
11690 (struct cmd_config_l2_tunnel_en_dis_result,
11692 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str =
11693 TOKEN_STRING_INITIALIZER
11694 (struct cmd_config_l2_tunnel_en_dis_result,
11696 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id =
11697 TOKEN_NUM_INITIALIZER
11698 (struct cmd_config_l2_tunnel_en_dis_result,
11700 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel =
11701 TOKEN_STRING_INITIALIZER
11702 (struct cmd_config_l2_tunnel_en_dis_result,
11703 l2_tunnel, "l2-tunnel");
11704 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type =
11705 TOKEN_STRING_INITIALIZER
11706 (struct cmd_config_l2_tunnel_en_dis_result,
11707 l2_tunnel_type, "E-tag");
11708 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis =
11709 TOKEN_STRING_INITIALIZER
11710 (struct cmd_config_l2_tunnel_en_dis_result,
11711 en_dis, "enable#disable");
11713 /* enable/disable l2 tunnel for all ports */
11715 cmd_config_l2_tunnel_en_dis_all_parsed(
11716 void *parsed_result,
11717 __attribute__((unused)) struct cmdline *cl,
11718 __attribute__((unused)) void *data)
11720 struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result;
11721 struct rte_eth_l2_tunnel_conf entry;
11725 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
11727 if (!strcmp("enable", res->en_dis))
11732 RTE_ETH_FOREACH_DEV(pid) {
11733 rte_eth_dev_l2_tunnel_offload_set(pid,
11735 ETH_L2_TUNNEL_ENABLE_MASK,
11740 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = {
11741 .f = cmd_config_l2_tunnel_en_dis_all_parsed,
11743 .help_str = "port config all l2-tunnel E-tag enable|disable",
11745 (void *)&cmd_config_l2_tunnel_en_dis_port,
11746 (void *)&cmd_config_l2_tunnel_en_dis_config,
11747 (void *)&cmd_config_l2_tunnel_en_dis_all_str,
11748 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
11749 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
11750 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
11755 /* enable/disable l2 tunnel for a port */
11757 cmd_config_l2_tunnel_en_dis_specific_parsed(
11758 void *parsed_result,
11759 __attribute__((unused)) struct cmdline *cl,
11760 __attribute__((unused)) void *data)
11762 struct cmd_config_l2_tunnel_en_dis_result *res =
11764 struct rte_eth_l2_tunnel_conf entry;
11766 if (port_id_is_invalid(res->id, ENABLED_WARN))
11769 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
11771 if (!strcmp("enable", res->en_dis))
11772 rte_eth_dev_l2_tunnel_offload_set(res->id,
11774 ETH_L2_TUNNEL_ENABLE_MASK,
11777 rte_eth_dev_l2_tunnel_offload_set(res->id,
11779 ETH_L2_TUNNEL_ENABLE_MASK,
11783 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = {
11784 .f = cmd_config_l2_tunnel_en_dis_specific_parsed,
11786 .help_str = "port config <port_id> l2-tunnel E-tag enable|disable",
11788 (void *)&cmd_config_l2_tunnel_en_dis_port,
11789 (void *)&cmd_config_l2_tunnel_en_dis_config,
11790 (void *)&cmd_config_l2_tunnel_en_dis_id,
11791 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
11792 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
11793 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
11798 /* E-tag configuration */
11800 /* Common result structure for all E-tag configuration */
11801 struct cmd_config_e_tag_result {
11802 cmdline_fixed_string_t e_tag;
11803 cmdline_fixed_string_t set;
11804 cmdline_fixed_string_t insertion;
11805 cmdline_fixed_string_t stripping;
11806 cmdline_fixed_string_t forwarding;
11807 cmdline_fixed_string_t filter;
11808 cmdline_fixed_string_t add;
11809 cmdline_fixed_string_t del;
11810 cmdline_fixed_string_t on;
11811 cmdline_fixed_string_t off;
11812 cmdline_fixed_string_t on_off;
11813 cmdline_fixed_string_t port_tag_id;
11814 uint32_t port_tag_id_val;
11815 cmdline_fixed_string_t e_tag_id;
11816 uint16_t e_tag_id_val;
11817 cmdline_fixed_string_t dst_pool;
11818 uint8_t dst_pool_val;
11819 cmdline_fixed_string_t port;
11821 cmdline_fixed_string_t vf;
11825 /* Common CLI fields for all E-tag configuration */
11826 cmdline_parse_token_string_t cmd_config_e_tag_e_tag =
11827 TOKEN_STRING_INITIALIZER
11828 (struct cmd_config_e_tag_result,
11830 cmdline_parse_token_string_t cmd_config_e_tag_set =
11831 TOKEN_STRING_INITIALIZER
11832 (struct cmd_config_e_tag_result,
11834 cmdline_parse_token_string_t cmd_config_e_tag_insertion =
11835 TOKEN_STRING_INITIALIZER
11836 (struct cmd_config_e_tag_result,
11837 insertion, "insertion");
11838 cmdline_parse_token_string_t cmd_config_e_tag_stripping =
11839 TOKEN_STRING_INITIALIZER
11840 (struct cmd_config_e_tag_result,
11841 stripping, "stripping");
11842 cmdline_parse_token_string_t cmd_config_e_tag_forwarding =
11843 TOKEN_STRING_INITIALIZER
11844 (struct cmd_config_e_tag_result,
11845 forwarding, "forwarding");
11846 cmdline_parse_token_string_t cmd_config_e_tag_filter =
11847 TOKEN_STRING_INITIALIZER
11848 (struct cmd_config_e_tag_result,
11850 cmdline_parse_token_string_t cmd_config_e_tag_add =
11851 TOKEN_STRING_INITIALIZER
11852 (struct cmd_config_e_tag_result,
11854 cmdline_parse_token_string_t cmd_config_e_tag_del =
11855 TOKEN_STRING_INITIALIZER
11856 (struct cmd_config_e_tag_result,
11858 cmdline_parse_token_string_t cmd_config_e_tag_on =
11859 TOKEN_STRING_INITIALIZER
11860 (struct cmd_config_e_tag_result,
11862 cmdline_parse_token_string_t cmd_config_e_tag_off =
11863 TOKEN_STRING_INITIALIZER
11864 (struct cmd_config_e_tag_result,
11866 cmdline_parse_token_string_t cmd_config_e_tag_on_off =
11867 TOKEN_STRING_INITIALIZER
11868 (struct cmd_config_e_tag_result,
11870 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id =
11871 TOKEN_STRING_INITIALIZER
11872 (struct cmd_config_e_tag_result,
11873 port_tag_id, "port-tag-id");
11874 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val =
11875 TOKEN_NUM_INITIALIZER
11876 (struct cmd_config_e_tag_result,
11877 port_tag_id_val, UINT32);
11878 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id =
11879 TOKEN_STRING_INITIALIZER
11880 (struct cmd_config_e_tag_result,
11881 e_tag_id, "e-tag-id");
11882 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val =
11883 TOKEN_NUM_INITIALIZER
11884 (struct cmd_config_e_tag_result,
11885 e_tag_id_val, UINT16);
11886 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool =
11887 TOKEN_STRING_INITIALIZER
11888 (struct cmd_config_e_tag_result,
11889 dst_pool, "dst-pool");
11890 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val =
11891 TOKEN_NUM_INITIALIZER
11892 (struct cmd_config_e_tag_result,
11893 dst_pool_val, UINT8);
11894 cmdline_parse_token_string_t cmd_config_e_tag_port =
11895 TOKEN_STRING_INITIALIZER
11896 (struct cmd_config_e_tag_result,
11898 cmdline_parse_token_num_t cmd_config_e_tag_port_id =
11899 TOKEN_NUM_INITIALIZER
11900 (struct cmd_config_e_tag_result,
11902 cmdline_parse_token_string_t cmd_config_e_tag_vf =
11903 TOKEN_STRING_INITIALIZER
11904 (struct cmd_config_e_tag_result,
11906 cmdline_parse_token_num_t cmd_config_e_tag_vf_id =
11907 TOKEN_NUM_INITIALIZER
11908 (struct cmd_config_e_tag_result,
11911 /* E-tag insertion configuration */
11913 cmd_config_e_tag_insertion_en_parsed(
11914 void *parsed_result,
11915 __attribute__((unused)) struct cmdline *cl,
11916 __attribute__((unused)) void *data)
11918 struct cmd_config_e_tag_result *res =
11920 struct rte_eth_l2_tunnel_conf entry;
11922 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11925 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
11926 entry.tunnel_id = res->port_tag_id_val;
11927 entry.vf_id = res->vf_id;
11928 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
11930 ETH_L2_TUNNEL_INSERTION_MASK,
11935 cmd_config_e_tag_insertion_dis_parsed(
11936 void *parsed_result,
11937 __attribute__((unused)) struct cmdline *cl,
11938 __attribute__((unused)) void *data)
11940 struct cmd_config_e_tag_result *res =
11942 struct rte_eth_l2_tunnel_conf entry;
11944 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11947 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
11948 entry.vf_id = res->vf_id;
11950 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
11952 ETH_L2_TUNNEL_INSERTION_MASK,
11956 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = {
11957 .f = cmd_config_e_tag_insertion_en_parsed,
11959 .help_str = "E-tag ... : E-tag insertion enable",
11961 (void *)&cmd_config_e_tag_e_tag,
11962 (void *)&cmd_config_e_tag_set,
11963 (void *)&cmd_config_e_tag_insertion,
11964 (void *)&cmd_config_e_tag_on,
11965 (void *)&cmd_config_e_tag_port_tag_id,
11966 (void *)&cmd_config_e_tag_port_tag_id_val,
11967 (void *)&cmd_config_e_tag_port,
11968 (void *)&cmd_config_e_tag_port_id,
11969 (void *)&cmd_config_e_tag_vf,
11970 (void *)&cmd_config_e_tag_vf_id,
11975 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = {
11976 .f = cmd_config_e_tag_insertion_dis_parsed,
11978 .help_str = "E-tag ... : E-tag insertion disable",
11980 (void *)&cmd_config_e_tag_e_tag,
11981 (void *)&cmd_config_e_tag_set,
11982 (void *)&cmd_config_e_tag_insertion,
11983 (void *)&cmd_config_e_tag_off,
11984 (void *)&cmd_config_e_tag_port,
11985 (void *)&cmd_config_e_tag_port_id,
11986 (void *)&cmd_config_e_tag_vf,
11987 (void *)&cmd_config_e_tag_vf_id,
11992 /* E-tag stripping configuration */
11994 cmd_config_e_tag_stripping_parsed(
11995 void *parsed_result,
11996 __attribute__((unused)) struct cmdline *cl,
11997 __attribute__((unused)) void *data)
11999 struct cmd_config_e_tag_result *res =
12001 struct rte_eth_l2_tunnel_conf entry;
12003 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12006 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12008 if (!strcmp(res->on_off, "on"))
12009 rte_eth_dev_l2_tunnel_offload_set
12012 ETH_L2_TUNNEL_STRIPPING_MASK,
12015 rte_eth_dev_l2_tunnel_offload_set
12018 ETH_L2_TUNNEL_STRIPPING_MASK,
12022 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = {
12023 .f = cmd_config_e_tag_stripping_parsed,
12025 .help_str = "E-tag ... : E-tag stripping enable/disable",
12027 (void *)&cmd_config_e_tag_e_tag,
12028 (void *)&cmd_config_e_tag_set,
12029 (void *)&cmd_config_e_tag_stripping,
12030 (void *)&cmd_config_e_tag_on_off,
12031 (void *)&cmd_config_e_tag_port,
12032 (void *)&cmd_config_e_tag_port_id,
12037 /* E-tag forwarding configuration */
12039 cmd_config_e_tag_forwarding_parsed(
12040 void *parsed_result,
12041 __attribute__((unused)) struct cmdline *cl,
12042 __attribute__((unused)) void *data)
12044 struct cmd_config_e_tag_result *res = parsed_result;
12045 struct rte_eth_l2_tunnel_conf entry;
12047 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12050 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12052 if (!strcmp(res->on_off, "on"))
12053 rte_eth_dev_l2_tunnel_offload_set
12056 ETH_L2_TUNNEL_FORWARDING_MASK,
12059 rte_eth_dev_l2_tunnel_offload_set
12062 ETH_L2_TUNNEL_FORWARDING_MASK,
12066 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = {
12067 .f = cmd_config_e_tag_forwarding_parsed,
12069 .help_str = "E-tag ... : E-tag forwarding enable/disable",
12071 (void *)&cmd_config_e_tag_e_tag,
12072 (void *)&cmd_config_e_tag_set,
12073 (void *)&cmd_config_e_tag_forwarding,
12074 (void *)&cmd_config_e_tag_on_off,
12075 (void *)&cmd_config_e_tag_port,
12076 (void *)&cmd_config_e_tag_port_id,
12081 /* E-tag filter configuration */
12083 cmd_config_e_tag_filter_add_parsed(
12084 void *parsed_result,
12085 __attribute__((unused)) struct cmdline *cl,
12086 __attribute__((unused)) void *data)
12088 struct cmd_config_e_tag_result *res = parsed_result;
12089 struct rte_eth_l2_tunnel_conf entry;
12092 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12095 if (res->e_tag_id_val > 0x3fff) {
12096 printf("e-tag-id must be equal or less than 0x3fff.\n");
12100 ret = rte_eth_dev_filter_supported(res->port_id,
12101 RTE_ETH_FILTER_L2_TUNNEL);
12103 printf("E-tag filter is not supported on port %u.\n",
12108 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12109 entry.tunnel_id = res->e_tag_id_val;
12110 entry.pool = res->dst_pool_val;
12112 ret = rte_eth_dev_filter_ctrl(res->port_id,
12113 RTE_ETH_FILTER_L2_TUNNEL,
12114 RTE_ETH_FILTER_ADD,
12117 printf("E-tag filter programming error: (%s)\n",
12121 cmdline_parse_inst_t cmd_config_e_tag_filter_add = {
12122 .f = cmd_config_e_tag_filter_add_parsed,
12124 .help_str = "E-tag ... : E-tag filter add",
12126 (void *)&cmd_config_e_tag_e_tag,
12127 (void *)&cmd_config_e_tag_set,
12128 (void *)&cmd_config_e_tag_filter,
12129 (void *)&cmd_config_e_tag_add,
12130 (void *)&cmd_config_e_tag_e_tag_id,
12131 (void *)&cmd_config_e_tag_e_tag_id_val,
12132 (void *)&cmd_config_e_tag_dst_pool,
12133 (void *)&cmd_config_e_tag_dst_pool_val,
12134 (void *)&cmd_config_e_tag_port,
12135 (void *)&cmd_config_e_tag_port_id,
12141 cmd_config_e_tag_filter_del_parsed(
12142 void *parsed_result,
12143 __attribute__((unused)) struct cmdline *cl,
12144 __attribute__((unused)) void *data)
12146 struct cmd_config_e_tag_result *res = parsed_result;
12147 struct rte_eth_l2_tunnel_conf entry;
12150 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12153 if (res->e_tag_id_val > 0x3fff) {
12154 printf("e-tag-id must be less than 0x3fff.\n");
12158 ret = rte_eth_dev_filter_supported(res->port_id,
12159 RTE_ETH_FILTER_L2_TUNNEL);
12161 printf("E-tag filter is not supported on port %u.\n",
12166 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12167 entry.tunnel_id = res->e_tag_id_val;
12169 ret = rte_eth_dev_filter_ctrl(res->port_id,
12170 RTE_ETH_FILTER_L2_TUNNEL,
12171 RTE_ETH_FILTER_DELETE,
12174 printf("E-tag filter programming error: (%s)\n",
12178 cmdline_parse_inst_t cmd_config_e_tag_filter_del = {
12179 .f = cmd_config_e_tag_filter_del_parsed,
12181 .help_str = "E-tag ... : E-tag filter delete",
12183 (void *)&cmd_config_e_tag_e_tag,
12184 (void *)&cmd_config_e_tag_set,
12185 (void *)&cmd_config_e_tag_filter,
12186 (void *)&cmd_config_e_tag_del,
12187 (void *)&cmd_config_e_tag_e_tag_id,
12188 (void *)&cmd_config_e_tag_e_tag_id_val,
12189 (void *)&cmd_config_e_tag_port,
12190 (void *)&cmd_config_e_tag_port_id,
12195 /* vf vlan anti spoof configuration */
12197 /* Common result structure for vf vlan anti spoof */
12198 struct cmd_vf_vlan_anti_spoof_result {
12199 cmdline_fixed_string_t set;
12200 cmdline_fixed_string_t vf;
12201 cmdline_fixed_string_t vlan;
12202 cmdline_fixed_string_t antispoof;
12205 cmdline_fixed_string_t on_off;
12208 /* Common CLI fields for vf vlan anti spoof enable disable */
12209 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
12210 TOKEN_STRING_INITIALIZER
12211 (struct cmd_vf_vlan_anti_spoof_result,
12213 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
12214 TOKEN_STRING_INITIALIZER
12215 (struct cmd_vf_vlan_anti_spoof_result,
12217 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
12218 TOKEN_STRING_INITIALIZER
12219 (struct cmd_vf_vlan_anti_spoof_result,
12221 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
12222 TOKEN_STRING_INITIALIZER
12223 (struct cmd_vf_vlan_anti_spoof_result,
12224 antispoof, "antispoof");
12225 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
12226 TOKEN_NUM_INITIALIZER
12227 (struct cmd_vf_vlan_anti_spoof_result,
12229 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
12230 TOKEN_NUM_INITIALIZER
12231 (struct cmd_vf_vlan_anti_spoof_result,
12233 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
12234 TOKEN_STRING_INITIALIZER
12235 (struct cmd_vf_vlan_anti_spoof_result,
12239 cmd_set_vf_vlan_anti_spoof_parsed(
12240 void *parsed_result,
12241 __attribute__((unused)) struct cmdline *cl,
12242 __attribute__((unused)) void *data)
12244 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
12245 int ret = -ENOTSUP;
12247 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12249 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12252 #ifdef RTE_LIBRTE_IXGBE_PMD
12253 if (ret == -ENOTSUP)
12254 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
12255 res->vf_id, is_on);
12257 #ifdef RTE_LIBRTE_I40E_PMD
12258 if (ret == -ENOTSUP)
12259 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
12260 res->vf_id, is_on);
12262 #ifdef RTE_LIBRTE_BNXT_PMD
12263 if (ret == -ENOTSUP)
12264 ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
12265 res->vf_id, is_on);
12272 printf("invalid vf_id %d\n", res->vf_id);
12275 printf("invalid port_id %d\n", res->port_id);
12278 printf("function not implemented\n");
12281 printf("programming error: (%s)\n", strerror(-ret));
12285 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
12286 .f = cmd_set_vf_vlan_anti_spoof_parsed,
12288 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
12290 (void *)&cmd_vf_vlan_anti_spoof_set,
12291 (void *)&cmd_vf_vlan_anti_spoof_vf,
12292 (void *)&cmd_vf_vlan_anti_spoof_vlan,
12293 (void *)&cmd_vf_vlan_anti_spoof_antispoof,
12294 (void *)&cmd_vf_vlan_anti_spoof_port_id,
12295 (void *)&cmd_vf_vlan_anti_spoof_vf_id,
12296 (void *)&cmd_vf_vlan_anti_spoof_on_off,
12301 /* vf mac anti spoof configuration */
12303 /* Common result structure for vf mac anti spoof */
12304 struct cmd_vf_mac_anti_spoof_result {
12305 cmdline_fixed_string_t set;
12306 cmdline_fixed_string_t vf;
12307 cmdline_fixed_string_t mac;
12308 cmdline_fixed_string_t antispoof;
12311 cmdline_fixed_string_t on_off;
12314 /* Common CLI fields for vf mac anti spoof enable disable */
12315 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
12316 TOKEN_STRING_INITIALIZER
12317 (struct cmd_vf_mac_anti_spoof_result,
12319 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
12320 TOKEN_STRING_INITIALIZER
12321 (struct cmd_vf_mac_anti_spoof_result,
12323 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
12324 TOKEN_STRING_INITIALIZER
12325 (struct cmd_vf_mac_anti_spoof_result,
12327 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
12328 TOKEN_STRING_INITIALIZER
12329 (struct cmd_vf_mac_anti_spoof_result,
12330 antispoof, "antispoof");
12331 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
12332 TOKEN_NUM_INITIALIZER
12333 (struct cmd_vf_mac_anti_spoof_result,
12335 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
12336 TOKEN_NUM_INITIALIZER
12337 (struct cmd_vf_mac_anti_spoof_result,
12339 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
12340 TOKEN_STRING_INITIALIZER
12341 (struct cmd_vf_mac_anti_spoof_result,
12345 cmd_set_vf_mac_anti_spoof_parsed(
12346 void *parsed_result,
12347 __attribute__((unused)) struct cmdline *cl,
12348 __attribute__((unused)) void *data)
12350 struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
12351 int ret = -ENOTSUP;
12353 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12355 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12358 #ifdef RTE_LIBRTE_IXGBE_PMD
12359 if (ret == -ENOTSUP)
12360 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
12361 res->vf_id, is_on);
12363 #ifdef RTE_LIBRTE_I40E_PMD
12364 if (ret == -ENOTSUP)
12365 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
12366 res->vf_id, is_on);
12368 #ifdef RTE_LIBRTE_BNXT_PMD
12369 if (ret == -ENOTSUP)
12370 ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
12371 res->vf_id, is_on);
12378 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12381 printf("invalid port_id %d\n", res->port_id);
12384 printf("function not implemented\n");
12387 printf("programming error: (%s)\n", strerror(-ret));
12391 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
12392 .f = cmd_set_vf_mac_anti_spoof_parsed,
12394 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
12396 (void *)&cmd_vf_mac_anti_spoof_set,
12397 (void *)&cmd_vf_mac_anti_spoof_vf,
12398 (void *)&cmd_vf_mac_anti_spoof_mac,
12399 (void *)&cmd_vf_mac_anti_spoof_antispoof,
12400 (void *)&cmd_vf_mac_anti_spoof_port_id,
12401 (void *)&cmd_vf_mac_anti_spoof_vf_id,
12402 (void *)&cmd_vf_mac_anti_spoof_on_off,
12407 /* vf vlan strip queue configuration */
12409 /* Common result structure for vf mac anti spoof */
12410 struct cmd_vf_vlan_stripq_result {
12411 cmdline_fixed_string_t set;
12412 cmdline_fixed_string_t vf;
12413 cmdline_fixed_string_t vlan;
12414 cmdline_fixed_string_t stripq;
12417 cmdline_fixed_string_t on_off;
12420 /* Common CLI fields for vf vlan strip enable disable */
12421 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
12422 TOKEN_STRING_INITIALIZER
12423 (struct cmd_vf_vlan_stripq_result,
12425 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
12426 TOKEN_STRING_INITIALIZER
12427 (struct cmd_vf_vlan_stripq_result,
12429 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
12430 TOKEN_STRING_INITIALIZER
12431 (struct cmd_vf_vlan_stripq_result,
12433 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
12434 TOKEN_STRING_INITIALIZER
12435 (struct cmd_vf_vlan_stripq_result,
12437 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
12438 TOKEN_NUM_INITIALIZER
12439 (struct cmd_vf_vlan_stripq_result,
12441 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
12442 TOKEN_NUM_INITIALIZER
12443 (struct cmd_vf_vlan_stripq_result,
12445 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
12446 TOKEN_STRING_INITIALIZER
12447 (struct cmd_vf_vlan_stripq_result,
12451 cmd_set_vf_vlan_stripq_parsed(
12452 void *parsed_result,
12453 __attribute__((unused)) struct cmdline *cl,
12454 __attribute__((unused)) void *data)
12456 struct cmd_vf_vlan_stripq_result *res = parsed_result;
12457 int ret = -ENOTSUP;
12459 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12461 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12464 #ifdef RTE_LIBRTE_IXGBE_PMD
12465 if (ret == -ENOTSUP)
12466 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
12467 res->vf_id, is_on);
12469 #ifdef RTE_LIBRTE_I40E_PMD
12470 if (ret == -ENOTSUP)
12471 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
12472 res->vf_id, is_on);
12474 #ifdef RTE_LIBRTE_BNXT_PMD
12475 if (ret == -ENOTSUP)
12476 ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
12477 res->vf_id, is_on);
12484 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12487 printf("invalid port_id %d\n", res->port_id);
12490 printf("function not implemented\n");
12493 printf("programming error: (%s)\n", strerror(-ret));
12497 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
12498 .f = cmd_set_vf_vlan_stripq_parsed,
12500 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
12502 (void *)&cmd_vf_vlan_stripq_set,
12503 (void *)&cmd_vf_vlan_stripq_vf,
12504 (void *)&cmd_vf_vlan_stripq_vlan,
12505 (void *)&cmd_vf_vlan_stripq_stripq,
12506 (void *)&cmd_vf_vlan_stripq_port_id,
12507 (void *)&cmd_vf_vlan_stripq_vf_id,
12508 (void *)&cmd_vf_vlan_stripq_on_off,
12513 /* vf vlan insert configuration */
12515 /* Common result structure for vf vlan insert */
12516 struct cmd_vf_vlan_insert_result {
12517 cmdline_fixed_string_t set;
12518 cmdline_fixed_string_t vf;
12519 cmdline_fixed_string_t vlan;
12520 cmdline_fixed_string_t insert;
12526 /* Common CLI fields for vf vlan insert enable disable */
12527 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
12528 TOKEN_STRING_INITIALIZER
12529 (struct cmd_vf_vlan_insert_result,
12531 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
12532 TOKEN_STRING_INITIALIZER
12533 (struct cmd_vf_vlan_insert_result,
12535 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
12536 TOKEN_STRING_INITIALIZER
12537 (struct cmd_vf_vlan_insert_result,
12539 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
12540 TOKEN_STRING_INITIALIZER
12541 (struct cmd_vf_vlan_insert_result,
12543 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
12544 TOKEN_NUM_INITIALIZER
12545 (struct cmd_vf_vlan_insert_result,
12547 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
12548 TOKEN_NUM_INITIALIZER
12549 (struct cmd_vf_vlan_insert_result,
12551 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
12552 TOKEN_NUM_INITIALIZER
12553 (struct cmd_vf_vlan_insert_result,
12557 cmd_set_vf_vlan_insert_parsed(
12558 void *parsed_result,
12559 __attribute__((unused)) struct cmdline *cl,
12560 __attribute__((unused)) void *data)
12562 struct cmd_vf_vlan_insert_result *res = parsed_result;
12563 int ret = -ENOTSUP;
12565 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12568 #ifdef RTE_LIBRTE_IXGBE_PMD
12569 if (ret == -ENOTSUP)
12570 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
12573 #ifdef RTE_LIBRTE_I40E_PMD
12574 if (ret == -ENOTSUP)
12575 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
12578 #ifdef RTE_LIBRTE_BNXT_PMD
12579 if (ret == -ENOTSUP)
12580 ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
12588 printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id);
12591 printf("invalid port_id %d\n", res->port_id);
12594 printf("function not implemented\n");
12597 printf("programming error: (%s)\n", strerror(-ret));
12601 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
12602 .f = cmd_set_vf_vlan_insert_parsed,
12604 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
12606 (void *)&cmd_vf_vlan_insert_set,
12607 (void *)&cmd_vf_vlan_insert_vf,
12608 (void *)&cmd_vf_vlan_insert_vlan,
12609 (void *)&cmd_vf_vlan_insert_insert,
12610 (void *)&cmd_vf_vlan_insert_port_id,
12611 (void *)&cmd_vf_vlan_insert_vf_id,
12612 (void *)&cmd_vf_vlan_insert_vlan_id,
12617 /* tx loopback configuration */
12619 /* Common result structure for tx loopback */
12620 struct cmd_tx_loopback_result {
12621 cmdline_fixed_string_t set;
12622 cmdline_fixed_string_t tx;
12623 cmdline_fixed_string_t loopback;
12625 cmdline_fixed_string_t on_off;
12628 /* Common CLI fields for tx loopback enable disable */
12629 cmdline_parse_token_string_t cmd_tx_loopback_set =
12630 TOKEN_STRING_INITIALIZER
12631 (struct cmd_tx_loopback_result,
12633 cmdline_parse_token_string_t cmd_tx_loopback_tx =
12634 TOKEN_STRING_INITIALIZER
12635 (struct cmd_tx_loopback_result,
12637 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
12638 TOKEN_STRING_INITIALIZER
12639 (struct cmd_tx_loopback_result,
12640 loopback, "loopback");
12641 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
12642 TOKEN_NUM_INITIALIZER
12643 (struct cmd_tx_loopback_result,
12645 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
12646 TOKEN_STRING_INITIALIZER
12647 (struct cmd_tx_loopback_result,
12651 cmd_set_tx_loopback_parsed(
12652 void *parsed_result,
12653 __attribute__((unused)) struct cmdline *cl,
12654 __attribute__((unused)) void *data)
12656 struct cmd_tx_loopback_result *res = parsed_result;
12657 int ret = -ENOTSUP;
12659 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12661 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12664 #ifdef RTE_LIBRTE_IXGBE_PMD
12665 if (ret == -ENOTSUP)
12666 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
12668 #ifdef RTE_LIBRTE_I40E_PMD
12669 if (ret == -ENOTSUP)
12670 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
12672 #ifdef RTE_LIBRTE_BNXT_PMD
12673 if (ret == -ENOTSUP)
12674 ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
12681 printf("invalid is_on %d\n", is_on);
12684 printf("invalid port_id %d\n", res->port_id);
12687 printf("function not implemented\n");
12690 printf("programming error: (%s)\n", strerror(-ret));
12694 cmdline_parse_inst_t cmd_set_tx_loopback = {
12695 .f = cmd_set_tx_loopback_parsed,
12697 .help_str = "set tx loopback <port_id> on|off",
12699 (void *)&cmd_tx_loopback_set,
12700 (void *)&cmd_tx_loopback_tx,
12701 (void *)&cmd_tx_loopback_loopback,
12702 (void *)&cmd_tx_loopback_port_id,
12703 (void *)&cmd_tx_loopback_on_off,
12708 /* all queues drop enable configuration */
12710 /* Common result structure for all queues drop enable */
12711 struct cmd_all_queues_drop_en_result {
12712 cmdline_fixed_string_t set;
12713 cmdline_fixed_string_t all;
12714 cmdline_fixed_string_t queues;
12715 cmdline_fixed_string_t drop;
12717 cmdline_fixed_string_t on_off;
12720 /* Common CLI fields for tx loopback enable disable */
12721 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
12722 TOKEN_STRING_INITIALIZER
12723 (struct cmd_all_queues_drop_en_result,
12725 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
12726 TOKEN_STRING_INITIALIZER
12727 (struct cmd_all_queues_drop_en_result,
12729 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
12730 TOKEN_STRING_INITIALIZER
12731 (struct cmd_all_queues_drop_en_result,
12733 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
12734 TOKEN_STRING_INITIALIZER
12735 (struct cmd_all_queues_drop_en_result,
12737 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
12738 TOKEN_NUM_INITIALIZER
12739 (struct cmd_all_queues_drop_en_result,
12741 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
12742 TOKEN_STRING_INITIALIZER
12743 (struct cmd_all_queues_drop_en_result,
12747 cmd_set_all_queues_drop_en_parsed(
12748 void *parsed_result,
12749 __attribute__((unused)) struct cmdline *cl,
12750 __attribute__((unused)) void *data)
12752 struct cmd_all_queues_drop_en_result *res = parsed_result;
12753 int ret = -ENOTSUP;
12754 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12756 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12759 #ifdef RTE_LIBRTE_IXGBE_PMD
12760 if (ret == -ENOTSUP)
12761 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
12763 #ifdef RTE_LIBRTE_BNXT_PMD
12764 if (ret == -ENOTSUP)
12765 ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
12771 printf("invalid is_on %d\n", is_on);
12774 printf("invalid port_id %d\n", res->port_id);
12777 printf("function not implemented\n");
12780 printf("programming error: (%s)\n", strerror(-ret));
12784 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
12785 .f = cmd_set_all_queues_drop_en_parsed,
12787 .help_str = "set all queues drop <port_id> on|off",
12789 (void *)&cmd_all_queues_drop_en_set,
12790 (void *)&cmd_all_queues_drop_en_all,
12791 (void *)&cmd_all_queues_drop_en_queues,
12792 (void *)&cmd_all_queues_drop_en_drop,
12793 (void *)&cmd_all_queues_drop_en_port_id,
12794 (void *)&cmd_all_queues_drop_en_on_off,
12799 /* vf split drop enable configuration */
12801 /* Common result structure for vf split drop enable */
12802 struct cmd_vf_split_drop_en_result {
12803 cmdline_fixed_string_t set;
12804 cmdline_fixed_string_t vf;
12805 cmdline_fixed_string_t split;
12806 cmdline_fixed_string_t drop;
12809 cmdline_fixed_string_t on_off;
12812 /* Common CLI fields for vf split drop enable disable */
12813 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
12814 TOKEN_STRING_INITIALIZER
12815 (struct cmd_vf_split_drop_en_result,
12817 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
12818 TOKEN_STRING_INITIALIZER
12819 (struct cmd_vf_split_drop_en_result,
12821 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
12822 TOKEN_STRING_INITIALIZER
12823 (struct cmd_vf_split_drop_en_result,
12825 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
12826 TOKEN_STRING_INITIALIZER
12827 (struct cmd_vf_split_drop_en_result,
12829 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
12830 TOKEN_NUM_INITIALIZER
12831 (struct cmd_vf_split_drop_en_result,
12833 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
12834 TOKEN_NUM_INITIALIZER
12835 (struct cmd_vf_split_drop_en_result,
12837 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
12838 TOKEN_STRING_INITIALIZER
12839 (struct cmd_vf_split_drop_en_result,
12843 cmd_set_vf_split_drop_en_parsed(
12844 void *parsed_result,
12845 __attribute__((unused)) struct cmdline *cl,
12846 __attribute__((unused)) void *data)
12848 struct cmd_vf_split_drop_en_result *res = parsed_result;
12849 int ret = -ENOTSUP;
12850 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12852 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12855 #ifdef RTE_LIBRTE_IXGBE_PMD
12856 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
12863 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12866 printf("invalid port_id %d\n", res->port_id);
12869 printf("not supported on port %d\n", res->port_id);
12872 printf("programming error: (%s)\n", strerror(-ret));
12876 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
12877 .f = cmd_set_vf_split_drop_en_parsed,
12879 .help_str = "set vf split drop <port_id> <vf_id> on|off",
12881 (void *)&cmd_vf_split_drop_en_set,
12882 (void *)&cmd_vf_split_drop_en_vf,
12883 (void *)&cmd_vf_split_drop_en_split,
12884 (void *)&cmd_vf_split_drop_en_drop,
12885 (void *)&cmd_vf_split_drop_en_port_id,
12886 (void *)&cmd_vf_split_drop_en_vf_id,
12887 (void *)&cmd_vf_split_drop_en_on_off,
12892 /* vf mac address configuration */
12894 /* Common result structure for vf mac address */
12895 struct cmd_set_vf_mac_addr_result {
12896 cmdline_fixed_string_t set;
12897 cmdline_fixed_string_t vf;
12898 cmdline_fixed_string_t mac;
12899 cmdline_fixed_string_t addr;
12902 struct ether_addr mac_addr;
12906 /* Common CLI fields for vf split drop enable disable */
12907 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
12908 TOKEN_STRING_INITIALIZER
12909 (struct cmd_set_vf_mac_addr_result,
12911 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
12912 TOKEN_STRING_INITIALIZER
12913 (struct cmd_set_vf_mac_addr_result,
12915 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
12916 TOKEN_STRING_INITIALIZER
12917 (struct cmd_set_vf_mac_addr_result,
12919 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
12920 TOKEN_STRING_INITIALIZER
12921 (struct cmd_set_vf_mac_addr_result,
12923 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
12924 TOKEN_NUM_INITIALIZER
12925 (struct cmd_set_vf_mac_addr_result,
12927 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
12928 TOKEN_NUM_INITIALIZER
12929 (struct cmd_set_vf_mac_addr_result,
12931 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
12932 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
12936 cmd_set_vf_mac_addr_parsed(
12937 void *parsed_result,
12938 __attribute__((unused)) struct cmdline *cl,
12939 __attribute__((unused)) void *data)
12941 struct cmd_set_vf_mac_addr_result *res = parsed_result;
12942 int ret = -ENOTSUP;
12944 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12947 #ifdef RTE_LIBRTE_IXGBE_PMD
12948 if (ret == -ENOTSUP)
12949 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
12952 #ifdef RTE_LIBRTE_I40E_PMD
12953 if (ret == -ENOTSUP)
12954 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
12957 #ifdef RTE_LIBRTE_BNXT_PMD
12958 if (ret == -ENOTSUP)
12959 ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
12967 printf("invalid vf_id %d or mac_addr\n", res->vf_id);
12970 printf("invalid port_id %d\n", res->port_id);
12973 printf("function not implemented\n");
12976 printf("programming error: (%s)\n", strerror(-ret));
12980 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
12981 .f = cmd_set_vf_mac_addr_parsed,
12983 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
12985 (void *)&cmd_set_vf_mac_addr_set,
12986 (void *)&cmd_set_vf_mac_addr_vf,
12987 (void *)&cmd_set_vf_mac_addr_mac,
12988 (void *)&cmd_set_vf_mac_addr_addr,
12989 (void *)&cmd_set_vf_mac_addr_port_id,
12990 (void *)&cmd_set_vf_mac_addr_vf_id,
12991 (void *)&cmd_set_vf_mac_addr_mac_addr,
12996 /* MACsec configuration */
12998 /* Common result structure for MACsec offload enable */
12999 struct cmd_macsec_offload_on_result {
13000 cmdline_fixed_string_t set;
13001 cmdline_fixed_string_t macsec;
13002 cmdline_fixed_string_t offload;
13004 cmdline_fixed_string_t on;
13005 cmdline_fixed_string_t encrypt;
13006 cmdline_fixed_string_t en_on_off;
13007 cmdline_fixed_string_t replay_protect;
13008 cmdline_fixed_string_t rp_on_off;
13011 /* Common CLI fields for MACsec offload disable */
13012 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
13013 TOKEN_STRING_INITIALIZER
13014 (struct cmd_macsec_offload_on_result,
13016 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
13017 TOKEN_STRING_INITIALIZER
13018 (struct cmd_macsec_offload_on_result,
13020 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
13021 TOKEN_STRING_INITIALIZER
13022 (struct cmd_macsec_offload_on_result,
13023 offload, "offload");
13024 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
13025 TOKEN_NUM_INITIALIZER
13026 (struct cmd_macsec_offload_on_result,
13028 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
13029 TOKEN_STRING_INITIALIZER
13030 (struct cmd_macsec_offload_on_result,
13032 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
13033 TOKEN_STRING_INITIALIZER
13034 (struct cmd_macsec_offload_on_result,
13035 encrypt, "encrypt");
13036 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
13037 TOKEN_STRING_INITIALIZER
13038 (struct cmd_macsec_offload_on_result,
13039 en_on_off, "on#off");
13040 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
13041 TOKEN_STRING_INITIALIZER
13042 (struct cmd_macsec_offload_on_result,
13043 replay_protect, "replay-protect");
13044 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
13045 TOKEN_STRING_INITIALIZER
13046 (struct cmd_macsec_offload_on_result,
13047 rp_on_off, "on#off");
13050 cmd_set_macsec_offload_on_parsed(
13051 void *parsed_result,
13052 __attribute__((unused)) struct cmdline *cl,
13053 __attribute__((unused)) void *data)
13055 struct cmd_macsec_offload_on_result *res = parsed_result;
13056 int ret = -ENOTSUP;
13057 portid_t port_id = res->port_id;
13058 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
13059 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
13060 struct rte_eth_dev_info dev_info;
13062 if (port_id_is_invalid(port_id, ENABLED_WARN))
13064 if (!port_is_stopped(port_id)) {
13065 printf("Please stop port %d first\n", port_id);
13069 rte_eth_dev_info_get(port_id, &dev_info);
13070 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
13071 #ifdef RTE_LIBRTE_IXGBE_PMD
13072 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
13080 ports[port_id].dev_conf.txmode.offloads |=
13081 DEV_TX_OFFLOAD_MACSEC_INSERT;
13082 cmd_reconfig_device_queue(port_id, 1, 1);
13085 printf("invalid port_id %d\n", port_id);
13088 printf("not supported on port %d\n", port_id);
13091 printf("programming error: (%s)\n", strerror(-ret));
13095 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
13096 .f = cmd_set_macsec_offload_on_parsed,
13098 .help_str = "set macsec offload <port_id> on "
13099 "encrypt on|off replay-protect on|off",
13101 (void *)&cmd_macsec_offload_on_set,
13102 (void *)&cmd_macsec_offload_on_macsec,
13103 (void *)&cmd_macsec_offload_on_offload,
13104 (void *)&cmd_macsec_offload_on_port_id,
13105 (void *)&cmd_macsec_offload_on_on,
13106 (void *)&cmd_macsec_offload_on_encrypt,
13107 (void *)&cmd_macsec_offload_on_en_on_off,
13108 (void *)&cmd_macsec_offload_on_replay_protect,
13109 (void *)&cmd_macsec_offload_on_rp_on_off,
13114 /* Common result structure for MACsec offload disable */
13115 struct cmd_macsec_offload_off_result {
13116 cmdline_fixed_string_t set;
13117 cmdline_fixed_string_t macsec;
13118 cmdline_fixed_string_t offload;
13120 cmdline_fixed_string_t off;
13123 /* Common CLI fields for MACsec offload disable */
13124 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
13125 TOKEN_STRING_INITIALIZER
13126 (struct cmd_macsec_offload_off_result,
13128 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
13129 TOKEN_STRING_INITIALIZER
13130 (struct cmd_macsec_offload_off_result,
13132 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
13133 TOKEN_STRING_INITIALIZER
13134 (struct cmd_macsec_offload_off_result,
13135 offload, "offload");
13136 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
13137 TOKEN_NUM_INITIALIZER
13138 (struct cmd_macsec_offload_off_result,
13140 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
13141 TOKEN_STRING_INITIALIZER
13142 (struct cmd_macsec_offload_off_result,
13146 cmd_set_macsec_offload_off_parsed(
13147 void *parsed_result,
13148 __attribute__((unused)) struct cmdline *cl,
13149 __attribute__((unused)) void *data)
13151 struct cmd_macsec_offload_off_result *res = parsed_result;
13152 int ret = -ENOTSUP;
13153 struct rte_eth_dev_info dev_info;
13154 portid_t port_id = res->port_id;
13156 if (port_id_is_invalid(port_id, ENABLED_WARN))
13158 if (!port_is_stopped(port_id)) {
13159 printf("Please stop port %d first\n", port_id);
13163 rte_eth_dev_info_get(port_id, &dev_info);
13164 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
13165 #ifdef RTE_LIBRTE_IXGBE_PMD
13166 ret = rte_pmd_ixgbe_macsec_disable(port_id);
13171 ports[port_id].dev_conf.txmode.offloads &=
13172 ~DEV_TX_OFFLOAD_MACSEC_INSERT;
13173 cmd_reconfig_device_queue(port_id, 1, 1);
13176 printf("invalid port_id %d\n", port_id);
13179 printf("not supported on port %d\n", port_id);
13182 printf("programming error: (%s)\n", strerror(-ret));
13186 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
13187 .f = cmd_set_macsec_offload_off_parsed,
13189 .help_str = "set macsec offload <port_id> off",
13191 (void *)&cmd_macsec_offload_off_set,
13192 (void *)&cmd_macsec_offload_off_macsec,
13193 (void *)&cmd_macsec_offload_off_offload,
13194 (void *)&cmd_macsec_offload_off_port_id,
13195 (void *)&cmd_macsec_offload_off_off,
13200 /* Common result structure for MACsec secure connection configure */
13201 struct cmd_macsec_sc_result {
13202 cmdline_fixed_string_t set;
13203 cmdline_fixed_string_t macsec;
13204 cmdline_fixed_string_t sc;
13205 cmdline_fixed_string_t tx_rx;
13207 struct ether_addr mac;
13211 /* Common CLI fields for MACsec secure connection configure */
13212 cmdline_parse_token_string_t cmd_macsec_sc_set =
13213 TOKEN_STRING_INITIALIZER
13214 (struct cmd_macsec_sc_result,
13216 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
13217 TOKEN_STRING_INITIALIZER
13218 (struct cmd_macsec_sc_result,
13220 cmdline_parse_token_string_t cmd_macsec_sc_sc =
13221 TOKEN_STRING_INITIALIZER
13222 (struct cmd_macsec_sc_result,
13224 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
13225 TOKEN_STRING_INITIALIZER
13226 (struct cmd_macsec_sc_result,
13228 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
13229 TOKEN_NUM_INITIALIZER
13230 (struct cmd_macsec_sc_result,
13232 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
13233 TOKEN_ETHERADDR_INITIALIZER
13234 (struct cmd_macsec_sc_result,
13236 cmdline_parse_token_num_t cmd_macsec_sc_pi =
13237 TOKEN_NUM_INITIALIZER
13238 (struct cmd_macsec_sc_result,
13242 cmd_set_macsec_sc_parsed(
13243 void *parsed_result,
13244 __attribute__((unused)) struct cmdline *cl,
13245 __attribute__((unused)) void *data)
13247 struct cmd_macsec_sc_result *res = parsed_result;
13248 int ret = -ENOTSUP;
13249 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
13251 #ifdef RTE_LIBRTE_IXGBE_PMD
13253 rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
13254 res->mac.addr_bytes) :
13255 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
13256 res->mac.addr_bytes, res->pi);
13258 RTE_SET_USED(is_tx);
13264 printf("invalid port_id %d\n", res->port_id);
13267 printf("not supported on port %d\n", res->port_id);
13270 printf("programming error: (%s)\n", strerror(-ret));
13274 cmdline_parse_inst_t cmd_set_macsec_sc = {
13275 .f = cmd_set_macsec_sc_parsed,
13277 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
13279 (void *)&cmd_macsec_sc_set,
13280 (void *)&cmd_macsec_sc_macsec,
13281 (void *)&cmd_macsec_sc_sc,
13282 (void *)&cmd_macsec_sc_tx_rx,
13283 (void *)&cmd_macsec_sc_port_id,
13284 (void *)&cmd_macsec_sc_mac,
13285 (void *)&cmd_macsec_sc_pi,
13290 /* Common result structure for MACsec secure connection configure */
13291 struct cmd_macsec_sa_result {
13292 cmdline_fixed_string_t set;
13293 cmdline_fixed_string_t macsec;
13294 cmdline_fixed_string_t sa;
13295 cmdline_fixed_string_t tx_rx;
13300 cmdline_fixed_string_t key;
13303 /* Common CLI fields for MACsec secure connection configure */
13304 cmdline_parse_token_string_t cmd_macsec_sa_set =
13305 TOKEN_STRING_INITIALIZER
13306 (struct cmd_macsec_sa_result,
13308 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
13309 TOKEN_STRING_INITIALIZER
13310 (struct cmd_macsec_sa_result,
13312 cmdline_parse_token_string_t cmd_macsec_sa_sa =
13313 TOKEN_STRING_INITIALIZER
13314 (struct cmd_macsec_sa_result,
13316 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
13317 TOKEN_STRING_INITIALIZER
13318 (struct cmd_macsec_sa_result,
13320 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
13321 TOKEN_NUM_INITIALIZER
13322 (struct cmd_macsec_sa_result,
13324 cmdline_parse_token_num_t cmd_macsec_sa_idx =
13325 TOKEN_NUM_INITIALIZER
13326 (struct cmd_macsec_sa_result,
13328 cmdline_parse_token_num_t cmd_macsec_sa_an =
13329 TOKEN_NUM_INITIALIZER
13330 (struct cmd_macsec_sa_result,
13332 cmdline_parse_token_num_t cmd_macsec_sa_pn =
13333 TOKEN_NUM_INITIALIZER
13334 (struct cmd_macsec_sa_result,
13336 cmdline_parse_token_string_t cmd_macsec_sa_key =
13337 TOKEN_STRING_INITIALIZER
13338 (struct cmd_macsec_sa_result,
13342 cmd_set_macsec_sa_parsed(
13343 void *parsed_result,
13344 __attribute__((unused)) struct cmdline *cl,
13345 __attribute__((unused)) void *data)
13347 struct cmd_macsec_sa_result *res = parsed_result;
13348 int ret = -ENOTSUP;
13349 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
13350 uint8_t key[16] = { 0 };
13356 key_len = strlen(res->key) / 2;
13360 for (i = 0; i < key_len; i++) {
13361 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
13364 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
13367 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
13370 #ifdef RTE_LIBRTE_IXGBE_PMD
13372 rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
13373 res->idx, res->an, res->pn, key) :
13374 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
13375 res->idx, res->an, res->pn, key);
13377 RTE_SET_USED(is_tx);
13384 printf("invalid idx %d or an %d\n", res->idx, res->an);
13387 printf("invalid port_id %d\n", res->port_id);
13390 printf("not supported on port %d\n", res->port_id);
13393 printf("programming error: (%s)\n", strerror(-ret));
13397 cmdline_parse_inst_t cmd_set_macsec_sa = {
13398 .f = cmd_set_macsec_sa_parsed,
13400 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
13402 (void *)&cmd_macsec_sa_set,
13403 (void *)&cmd_macsec_sa_macsec,
13404 (void *)&cmd_macsec_sa_sa,
13405 (void *)&cmd_macsec_sa_tx_rx,
13406 (void *)&cmd_macsec_sa_port_id,
13407 (void *)&cmd_macsec_sa_idx,
13408 (void *)&cmd_macsec_sa_an,
13409 (void *)&cmd_macsec_sa_pn,
13410 (void *)&cmd_macsec_sa_key,
13415 /* VF unicast promiscuous mode configuration */
13417 /* Common result structure for VF unicast promiscuous mode */
13418 struct cmd_vf_promisc_result {
13419 cmdline_fixed_string_t set;
13420 cmdline_fixed_string_t vf;
13421 cmdline_fixed_string_t promisc;
13424 cmdline_fixed_string_t on_off;
13427 /* Common CLI fields for VF unicast promiscuous mode enable disable */
13428 cmdline_parse_token_string_t cmd_vf_promisc_set =
13429 TOKEN_STRING_INITIALIZER
13430 (struct cmd_vf_promisc_result,
13432 cmdline_parse_token_string_t cmd_vf_promisc_vf =
13433 TOKEN_STRING_INITIALIZER
13434 (struct cmd_vf_promisc_result,
13436 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
13437 TOKEN_STRING_INITIALIZER
13438 (struct cmd_vf_promisc_result,
13439 promisc, "promisc");
13440 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
13441 TOKEN_NUM_INITIALIZER
13442 (struct cmd_vf_promisc_result,
13444 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
13445 TOKEN_NUM_INITIALIZER
13446 (struct cmd_vf_promisc_result,
13448 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
13449 TOKEN_STRING_INITIALIZER
13450 (struct cmd_vf_promisc_result,
13454 cmd_set_vf_promisc_parsed(
13455 void *parsed_result,
13456 __attribute__((unused)) struct cmdline *cl,
13457 __attribute__((unused)) void *data)
13459 struct cmd_vf_promisc_result *res = parsed_result;
13460 int ret = -ENOTSUP;
13462 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13464 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13467 #ifdef RTE_LIBRTE_I40E_PMD
13468 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
13469 res->vf_id, is_on);
13476 printf("invalid vf_id %d\n", res->vf_id);
13479 printf("invalid port_id %d\n", res->port_id);
13482 printf("function not implemented\n");
13485 printf("programming error: (%s)\n", strerror(-ret));
13489 cmdline_parse_inst_t cmd_set_vf_promisc = {
13490 .f = cmd_set_vf_promisc_parsed,
13492 .help_str = "set vf promisc <port_id> <vf_id> on|off: "
13493 "Set unicast promiscuous mode for a VF from the PF",
13495 (void *)&cmd_vf_promisc_set,
13496 (void *)&cmd_vf_promisc_vf,
13497 (void *)&cmd_vf_promisc_promisc,
13498 (void *)&cmd_vf_promisc_port_id,
13499 (void *)&cmd_vf_promisc_vf_id,
13500 (void *)&cmd_vf_promisc_on_off,
13505 /* VF multicast promiscuous mode configuration */
13507 /* Common result structure for VF multicast promiscuous mode */
13508 struct cmd_vf_allmulti_result {
13509 cmdline_fixed_string_t set;
13510 cmdline_fixed_string_t vf;
13511 cmdline_fixed_string_t allmulti;
13514 cmdline_fixed_string_t on_off;
13517 /* Common CLI fields for VF multicast promiscuous mode enable disable */
13518 cmdline_parse_token_string_t cmd_vf_allmulti_set =
13519 TOKEN_STRING_INITIALIZER
13520 (struct cmd_vf_allmulti_result,
13522 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
13523 TOKEN_STRING_INITIALIZER
13524 (struct cmd_vf_allmulti_result,
13526 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
13527 TOKEN_STRING_INITIALIZER
13528 (struct cmd_vf_allmulti_result,
13529 allmulti, "allmulti");
13530 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
13531 TOKEN_NUM_INITIALIZER
13532 (struct cmd_vf_allmulti_result,
13534 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
13535 TOKEN_NUM_INITIALIZER
13536 (struct cmd_vf_allmulti_result,
13538 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
13539 TOKEN_STRING_INITIALIZER
13540 (struct cmd_vf_allmulti_result,
13544 cmd_set_vf_allmulti_parsed(
13545 void *parsed_result,
13546 __attribute__((unused)) struct cmdline *cl,
13547 __attribute__((unused)) void *data)
13549 struct cmd_vf_allmulti_result *res = parsed_result;
13550 int ret = -ENOTSUP;
13552 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13554 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13557 #ifdef RTE_LIBRTE_I40E_PMD
13558 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
13559 res->vf_id, is_on);
13566 printf("invalid vf_id %d\n", res->vf_id);
13569 printf("invalid port_id %d\n", res->port_id);
13572 printf("function not implemented\n");
13575 printf("programming error: (%s)\n", strerror(-ret));
13579 cmdline_parse_inst_t cmd_set_vf_allmulti = {
13580 .f = cmd_set_vf_allmulti_parsed,
13582 .help_str = "set vf allmulti <port_id> <vf_id> on|off: "
13583 "Set multicast promiscuous mode for a VF from the PF",
13585 (void *)&cmd_vf_allmulti_set,
13586 (void *)&cmd_vf_allmulti_vf,
13587 (void *)&cmd_vf_allmulti_allmulti,
13588 (void *)&cmd_vf_allmulti_port_id,
13589 (void *)&cmd_vf_allmulti_vf_id,
13590 (void *)&cmd_vf_allmulti_on_off,
13595 /* vf broadcast mode configuration */
13597 /* Common result structure for vf broadcast */
13598 struct cmd_set_vf_broadcast_result {
13599 cmdline_fixed_string_t set;
13600 cmdline_fixed_string_t vf;
13601 cmdline_fixed_string_t broadcast;
13604 cmdline_fixed_string_t on_off;
13607 /* Common CLI fields for vf broadcast enable disable */
13608 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
13609 TOKEN_STRING_INITIALIZER
13610 (struct cmd_set_vf_broadcast_result,
13612 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
13613 TOKEN_STRING_INITIALIZER
13614 (struct cmd_set_vf_broadcast_result,
13616 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
13617 TOKEN_STRING_INITIALIZER
13618 (struct cmd_set_vf_broadcast_result,
13619 broadcast, "broadcast");
13620 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
13621 TOKEN_NUM_INITIALIZER
13622 (struct cmd_set_vf_broadcast_result,
13624 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
13625 TOKEN_NUM_INITIALIZER
13626 (struct cmd_set_vf_broadcast_result,
13628 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
13629 TOKEN_STRING_INITIALIZER
13630 (struct cmd_set_vf_broadcast_result,
13634 cmd_set_vf_broadcast_parsed(
13635 void *parsed_result,
13636 __attribute__((unused)) struct cmdline *cl,
13637 __attribute__((unused)) void *data)
13639 struct cmd_set_vf_broadcast_result *res = parsed_result;
13640 int ret = -ENOTSUP;
13642 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13644 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13647 #ifdef RTE_LIBRTE_I40E_PMD
13648 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
13649 res->vf_id, is_on);
13656 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13659 printf("invalid port_id %d\n", res->port_id);
13662 printf("function not implemented\n");
13665 printf("programming error: (%s)\n", strerror(-ret));
13669 cmdline_parse_inst_t cmd_set_vf_broadcast = {
13670 .f = cmd_set_vf_broadcast_parsed,
13672 .help_str = "set vf broadcast <port_id> <vf_id> on|off",
13674 (void *)&cmd_set_vf_broadcast_set,
13675 (void *)&cmd_set_vf_broadcast_vf,
13676 (void *)&cmd_set_vf_broadcast_broadcast,
13677 (void *)&cmd_set_vf_broadcast_port_id,
13678 (void *)&cmd_set_vf_broadcast_vf_id,
13679 (void *)&cmd_set_vf_broadcast_on_off,
13684 /* vf vlan tag configuration */
13686 /* Common result structure for vf vlan tag */
13687 struct cmd_set_vf_vlan_tag_result {
13688 cmdline_fixed_string_t set;
13689 cmdline_fixed_string_t vf;
13690 cmdline_fixed_string_t vlan;
13691 cmdline_fixed_string_t tag;
13694 cmdline_fixed_string_t on_off;
13697 /* Common CLI fields for vf vlan tag enable disable */
13698 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
13699 TOKEN_STRING_INITIALIZER
13700 (struct cmd_set_vf_vlan_tag_result,
13702 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
13703 TOKEN_STRING_INITIALIZER
13704 (struct cmd_set_vf_vlan_tag_result,
13706 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
13707 TOKEN_STRING_INITIALIZER
13708 (struct cmd_set_vf_vlan_tag_result,
13710 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
13711 TOKEN_STRING_INITIALIZER
13712 (struct cmd_set_vf_vlan_tag_result,
13714 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
13715 TOKEN_NUM_INITIALIZER
13716 (struct cmd_set_vf_vlan_tag_result,
13718 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
13719 TOKEN_NUM_INITIALIZER
13720 (struct cmd_set_vf_vlan_tag_result,
13722 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
13723 TOKEN_STRING_INITIALIZER
13724 (struct cmd_set_vf_vlan_tag_result,
13728 cmd_set_vf_vlan_tag_parsed(
13729 void *parsed_result,
13730 __attribute__((unused)) struct cmdline *cl,
13731 __attribute__((unused)) void *data)
13733 struct cmd_set_vf_vlan_tag_result *res = parsed_result;
13734 int ret = -ENOTSUP;
13736 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13738 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13741 #ifdef RTE_LIBRTE_I40E_PMD
13742 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
13743 res->vf_id, is_on);
13750 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13753 printf("invalid port_id %d\n", res->port_id);
13756 printf("function not implemented\n");
13759 printf("programming error: (%s)\n", strerror(-ret));
13763 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
13764 .f = cmd_set_vf_vlan_tag_parsed,
13766 .help_str = "set vf vlan tag <port_id> <vf_id> on|off",
13768 (void *)&cmd_set_vf_vlan_tag_set,
13769 (void *)&cmd_set_vf_vlan_tag_vf,
13770 (void *)&cmd_set_vf_vlan_tag_vlan,
13771 (void *)&cmd_set_vf_vlan_tag_tag,
13772 (void *)&cmd_set_vf_vlan_tag_port_id,
13773 (void *)&cmd_set_vf_vlan_tag_vf_id,
13774 (void *)&cmd_set_vf_vlan_tag_on_off,
13779 /* Common definition of VF and TC TX bandwidth configuration */
13780 struct cmd_vf_tc_bw_result {
13781 cmdline_fixed_string_t set;
13782 cmdline_fixed_string_t vf;
13783 cmdline_fixed_string_t tc;
13784 cmdline_fixed_string_t tx;
13785 cmdline_fixed_string_t min_bw;
13786 cmdline_fixed_string_t max_bw;
13787 cmdline_fixed_string_t strict_link_prio;
13792 cmdline_fixed_string_t bw_list;
13796 cmdline_parse_token_string_t cmd_vf_tc_bw_set =
13797 TOKEN_STRING_INITIALIZER
13798 (struct cmd_vf_tc_bw_result,
13800 cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
13801 TOKEN_STRING_INITIALIZER
13802 (struct cmd_vf_tc_bw_result,
13804 cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
13805 TOKEN_STRING_INITIALIZER
13806 (struct cmd_vf_tc_bw_result,
13808 cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
13809 TOKEN_STRING_INITIALIZER
13810 (struct cmd_vf_tc_bw_result,
13812 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio =
13813 TOKEN_STRING_INITIALIZER
13814 (struct cmd_vf_tc_bw_result,
13815 strict_link_prio, "strict-link-priority");
13816 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw =
13817 TOKEN_STRING_INITIALIZER
13818 (struct cmd_vf_tc_bw_result,
13819 min_bw, "min-bandwidth");
13820 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
13821 TOKEN_STRING_INITIALIZER
13822 (struct cmd_vf_tc_bw_result,
13823 max_bw, "max-bandwidth");
13824 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
13825 TOKEN_NUM_INITIALIZER
13826 (struct cmd_vf_tc_bw_result,
13828 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
13829 TOKEN_NUM_INITIALIZER
13830 (struct cmd_vf_tc_bw_result,
13832 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no =
13833 TOKEN_NUM_INITIALIZER
13834 (struct cmd_vf_tc_bw_result,
13836 cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
13837 TOKEN_NUM_INITIALIZER
13838 (struct cmd_vf_tc_bw_result,
13840 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
13841 TOKEN_STRING_INITIALIZER
13842 (struct cmd_vf_tc_bw_result,
13844 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map =
13845 TOKEN_NUM_INITIALIZER
13846 (struct cmd_vf_tc_bw_result,
13849 /* VF max bandwidth setting */
13851 cmd_vf_max_bw_parsed(
13852 void *parsed_result,
13853 __attribute__((unused)) struct cmdline *cl,
13854 __attribute__((unused)) void *data)
13856 struct cmd_vf_tc_bw_result *res = parsed_result;
13857 int ret = -ENOTSUP;
13859 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13862 #ifdef RTE_LIBRTE_I40E_PMD
13863 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id,
13864 res->vf_id, res->bw);
13871 printf("invalid vf_id %d or bandwidth %d\n",
13872 res->vf_id, res->bw);
13875 printf("invalid port_id %d\n", res->port_id);
13878 printf("function not implemented\n");
13881 printf("programming error: (%s)\n", strerror(-ret));
13885 cmdline_parse_inst_t cmd_vf_max_bw = {
13886 .f = cmd_vf_max_bw_parsed,
13888 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
13890 (void *)&cmd_vf_tc_bw_set,
13891 (void *)&cmd_vf_tc_bw_vf,
13892 (void *)&cmd_vf_tc_bw_tx,
13893 (void *)&cmd_vf_tc_bw_max_bw,
13894 (void *)&cmd_vf_tc_bw_port_id,
13895 (void *)&cmd_vf_tc_bw_vf_id,
13896 (void *)&cmd_vf_tc_bw_bw,
13902 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
13907 const char *p, *p0 = str;
13914 p = strchr(p0, '(');
13916 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
13920 p0 = strchr(p, ')');
13922 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
13926 if (size >= sizeof(s)) {
13927 printf("The string size exceeds the internal buffer size\n");
13930 snprintf(s, sizeof(s), "%.*s", size, p);
13931 ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
13933 printf("Failed to get the bandwidth list. ");
13937 for (i = 0; i < ret; i++)
13938 bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
13943 /* TC min bandwidth setting */
13945 cmd_vf_tc_min_bw_parsed(
13946 void *parsed_result,
13947 __attribute__((unused)) struct cmdline *cl,
13948 __attribute__((unused)) void *data)
13950 struct cmd_vf_tc_bw_result *res = parsed_result;
13953 int ret = -ENOTSUP;
13955 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13958 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
13962 #ifdef RTE_LIBRTE_I40E_PMD
13963 ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
13971 printf("invalid vf_id %d or bandwidth\n", res->vf_id);
13974 printf("invalid port_id %d\n", res->port_id);
13977 printf("function not implemented\n");
13980 printf("programming error: (%s)\n", strerror(-ret));
13984 cmdline_parse_inst_t cmd_vf_tc_min_bw = {
13985 .f = cmd_vf_tc_min_bw_parsed,
13987 .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
13988 " <bw1, bw2, ...>",
13990 (void *)&cmd_vf_tc_bw_set,
13991 (void *)&cmd_vf_tc_bw_vf,
13992 (void *)&cmd_vf_tc_bw_tc,
13993 (void *)&cmd_vf_tc_bw_tx,
13994 (void *)&cmd_vf_tc_bw_min_bw,
13995 (void *)&cmd_vf_tc_bw_port_id,
13996 (void *)&cmd_vf_tc_bw_vf_id,
13997 (void *)&cmd_vf_tc_bw_bw_list,
14003 cmd_tc_min_bw_parsed(
14004 void *parsed_result,
14005 __attribute__((unused)) struct cmdline *cl,
14006 __attribute__((unused)) void *data)
14008 struct cmd_vf_tc_bw_result *res = parsed_result;
14009 struct rte_port *port;
14012 int ret = -ENOTSUP;
14014 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14017 port = &ports[res->port_id];
14018 /** Check if the port is not started **/
14019 if (port->port_status != RTE_PORT_STOPPED) {
14020 printf("Please stop port %d first\n", res->port_id);
14024 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
14028 #ifdef RTE_LIBRTE_IXGBE_PMD
14029 ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw);
14036 printf("invalid bandwidth\n");
14039 printf("invalid port_id %d\n", res->port_id);
14042 printf("function not implemented\n");
14045 printf("programming error: (%s)\n", strerror(-ret));
14049 cmdline_parse_inst_t cmd_tc_min_bw = {
14050 .f = cmd_tc_min_bw_parsed,
14052 .help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>",
14054 (void *)&cmd_vf_tc_bw_set,
14055 (void *)&cmd_vf_tc_bw_tc,
14056 (void *)&cmd_vf_tc_bw_tx,
14057 (void *)&cmd_vf_tc_bw_min_bw,
14058 (void *)&cmd_vf_tc_bw_port_id,
14059 (void *)&cmd_vf_tc_bw_bw_list,
14064 /* TC max bandwidth setting */
14066 cmd_vf_tc_max_bw_parsed(
14067 void *parsed_result,
14068 __attribute__((unused)) struct cmdline *cl,
14069 __attribute__((unused)) void *data)
14071 struct cmd_vf_tc_bw_result *res = parsed_result;
14072 int ret = -ENOTSUP;
14074 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14077 #ifdef RTE_LIBRTE_I40E_PMD
14078 ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id,
14079 res->tc_no, res->bw);
14086 printf("invalid vf_id %d, tc_no %d or bandwidth %d\n",
14087 res->vf_id, res->tc_no, res->bw);
14090 printf("invalid port_id %d\n", res->port_id);
14093 printf("function not implemented\n");
14096 printf("programming error: (%s)\n", strerror(-ret));
14100 cmdline_parse_inst_t cmd_vf_tc_max_bw = {
14101 .f = cmd_vf_tc_max_bw_parsed,
14103 .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>"
14106 (void *)&cmd_vf_tc_bw_set,
14107 (void *)&cmd_vf_tc_bw_vf,
14108 (void *)&cmd_vf_tc_bw_tc,
14109 (void *)&cmd_vf_tc_bw_tx,
14110 (void *)&cmd_vf_tc_bw_max_bw,
14111 (void *)&cmd_vf_tc_bw_port_id,
14112 (void *)&cmd_vf_tc_bw_vf_id,
14113 (void *)&cmd_vf_tc_bw_tc_no,
14114 (void *)&cmd_vf_tc_bw_bw,
14120 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
14122 /* *** Set Port default Traffic Management Hierarchy *** */
14123 struct cmd_set_port_tm_hierarchy_default_result {
14124 cmdline_fixed_string_t set;
14125 cmdline_fixed_string_t port;
14126 cmdline_fixed_string_t tm;
14127 cmdline_fixed_string_t hierarchy;
14128 cmdline_fixed_string_t def;
14132 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_set =
14133 TOKEN_STRING_INITIALIZER(
14134 struct cmd_set_port_tm_hierarchy_default_result, set, "set");
14135 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_port =
14136 TOKEN_STRING_INITIALIZER(
14137 struct cmd_set_port_tm_hierarchy_default_result, port, "port");
14138 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_tm =
14139 TOKEN_STRING_INITIALIZER(
14140 struct cmd_set_port_tm_hierarchy_default_result, tm, "tm");
14141 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_hierarchy =
14142 TOKEN_STRING_INITIALIZER(
14143 struct cmd_set_port_tm_hierarchy_default_result,
14144 hierarchy, "hierarchy");
14145 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_default =
14146 TOKEN_STRING_INITIALIZER(
14147 struct cmd_set_port_tm_hierarchy_default_result,
14149 cmdline_parse_token_num_t cmd_set_port_tm_hierarchy_default_port_id =
14150 TOKEN_NUM_INITIALIZER(
14151 struct cmd_set_port_tm_hierarchy_default_result,
14154 static void cmd_set_port_tm_hierarchy_default_parsed(void *parsed_result,
14155 __attribute__((unused)) struct cmdline *cl,
14156 __attribute__((unused)) void *data)
14158 struct cmd_set_port_tm_hierarchy_default_result *res = parsed_result;
14159 struct rte_port *p;
14160 portid_t port_id = res->port_id;
14162 if (port_id_is_invalid(port_id, ENABLED_WARN))
14165 p = &ports[port_id];
14168 if (p->softport.tm_flag == 0) {
14169 printf(" tm not enabled on port %u (error)\n", port_id);
14173 /* Forward mode: tm */
14174 if (strcmp(cur_fwd_config.fwd_eng->fwd_mode_name, "tm")) {
14175 printf(" tm mode not enabled(error)\n");
14179 /* Set the default tm hierarchy */
14180 p->softport.tm.default_hierarchy_enable = 1;
14183 cmdline_parse_inst_t cmd_set_port_tm_hierarchy_default = {
14184 .f = cmd_set_port_tm_hierarchy_default_parsed,
14186 .help_str = "set port tm hierarchy default <port_id>",
14188 (void *)&cmd_set_port_tm_hierarchy_default_set,
14189 (void *)&cmd_set_port_tm_hierarchy_default_port,
14190 (void *)&cmd_set_port_tm_hierarchy_default_tm,
14191 (void *)&cmd_set_port_tm_hierarchy_default_hierarchy,
14192 (void *)&cmd_set_port_tm_hierarchy_default_default,
14193 (void *)&cmd_set_port_tm_hierarchy_default_port_id,
14199 /* Strict link priority scheduling mode setting */
14201 cmd_strict_link_prio_parsed(
14202 void *parsed_result,
14203 __attribute__((unused)) struct cmdline *cl,
14204 __attribute__((unused)) void *data)
14206 struct cmd_vf_tc_bw_result *res = parsed_result;
14207 int ret = -ENOTSUP;
14209 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14212 #ifdef RTE_LIBRTE_I40E_PMD
14213 ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map);
14220 printf("invalid tc_bitmap 0x%x\n", res->tc_map);
14223 printf("invalid port_id %d\n", res->port_id);
14226 printf("function not implemented\n");
14229 printf("programming error: (%s)\n", strerror(-ret));
14233 cmdline_parse_inst_t cmd_strict_link_prio = {
14234 .f = cmd_strict_link_prio_parsed,
14236 .help_str = "set tx strict-link-priority <port_id> <tc_bitmap>",
14238 (void *)&cmd_vf_tc_bw_set,
14239 (void *)&cmd_vf_tc_bw_tx,
14240 (void *)&cmd_vf_tc_bw_strict_link_prio,
14241 (void *)&cmd_vf_tc_bw_port_id,
14242 (void *)&cmd_vf_tc_bw_tc_map,
14247 /* Load dynamic device personalization*/
14248 struct cmd_ddp_add_result {
14249 cmdline_fixed_string_t ddp;
14250 cmdline_fixed_string_t add;
14255 cmdline_parse_token_string_t cmd_ddp_add_ddp =
14256 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp");
14257 cmdline_parse_token_string_t cmd_ddp_add_add =
14258 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add");
14259 cmdline_parse_token_num_t cmd_ddp_add_port_id =
14260 TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id, UINT16);
14261 cmdline_parse_token_string_t cmd_ddp_add_filepath =
14262 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL);
14265 cmd_ddp_add_parsed(
14266 void *parsed_result,
14267 __attribute__((unused)) struct cmdline *cl,
14268 __attribute__((unused)) void *data)
14270 struct cmd_ddp_add_result *res = parsed_result;
14276 int ret = -ENOTSUP;
14278 if (res->port_id > nb_ports) {
14279 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
14283 if (!all_ports_stopped()) {
14284 printf("Please stop all ports first\n");
14288 filepath = strdup(res->filepath);
14289 if (filepath == NULL) {
14290 printf("Failed to allocate memory\n");
14293 file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ',');
14295 buff = open_ddp_package_file(file_fld[0], &size);
14297 free((void *)filepath);
14301 #ifdef RTE_LIBRTE_I40E_PMD
14302 if (ret == -ENOTSUP)
14303 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
14305 RTE_PMD_I40E_PKG_OP_WR_ADD);
14308 if (ret == -EEXIST)
14309 printf("Profile has already existed.\n");
14311 printf("Failed to load profile.\n");
14312 else if (file_num == 2)
14313 save_ddp_package_file(file_fld[1], buff, size);
14315 close_ddp_package_file(buff);
14316 free((void *)filepath);
14319 cmdline_parse_inst_t cmd_ddp_add = {
14320 .f = cmd_ddp_add_parsed,
14322 .help_str = "ddp add <port_id> <profile_path[,output_path]>",
14324 (void *)&cmd_ddp_add_ddp,
14325 (void *)&cmd_ddp_add_add,
14326 (void *)&cmd_ddp_add_port_id,
14327 (void *)&cmd_ddp_add_filepath,
14332 /* Delete dynamic device personalization*/
14333 struct cmd_ddp_del_result {
14334 cmdline_fixed_string_t ddp;
14335 cmdline_fixed_string_t del;
14340 cmdline_parse_token_string_t cmd_ddp_del_ddp =
14341 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp");
14342 cmdline_parse_token_string_t cmd_ddp_del_del =
14343 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del");
14344 cmdline_parse_token_num_t cmd_ddp_del_port_id =
14345 TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, UINT16);
14346 cmdline_parse_token_string_t cmd_ddp_del_filepath =
14347 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL);
14350 cmd_ddp_del_parsed(
14351 void *parsed_result,
14352 __attribute__((unused)) struct cmdline *cl,
14353 __attribute__((unused)) void *data)
14355 struct cmd_ddp_del_result *res = parsed_result;
14358 int ret = -ENOTSUP;
14360 if (res->port_id > nb_ports) {
14361 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
14365 if (!all_ports_stopped()) {
14366 printf("Please stop all ports first\n");
14370 buff = open_ddp_package_file(res->filepath, &size);
14374 #ifdef RTE_LIBRTE_I40E_PMD
14375 if (ret == -ENOTSUP)
14376 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
14378 RTE_PMD_I40E_PKG_OP_WR_DEL);
14381 if (ret == -EACCES)
14382 printf("Profile does not exist.\n");
14384 printf("Failed to delete profile.\n");
14386 close_ddp_package_file(buff);
14389 cmdline_parse_inst_t cmd_ddp_del = {
14390 .f = cmd_ddp_del_parsed,
14392 .help_str = "ddp del <port_id> <profile_path>",
14394 (void *)&cmd_ddp_del_ddp,
14395 (void *)&cmd_ddp_del_del,
14396 (void *)&cmd_ddp_del_port_id,
14397 (void *)&cmd_ddp_del_filepath,
14402 /* Get dynamic device personalization profile info */
14403 struct cmd_ddp_info_result {
14404 cmdline_fixed_string_t ddp;
14405 cmdline_fixed_string_t get;
14406 cmdline_fixed_string_t info;
14410 cmdline_parse_token_string_t cmd_ddp_info_ddp =
14411 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp");
14412 cmdline_parse_token_string_t cmd_ddp_info_get =
14413 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get");
14414 cmdline_parse_token_string_t cmd_ddp_info_info =
14415 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info");
14416 cmdline_parse_token_string_t cmd_ddp_info_filepath =
14417 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL);
14420 cmd_ddp_info_parsed(
14421 void *parsed_result,
14422 __attribute__((unused)) struct cmdline *cl,
14423 __attribute__((unused)) void *data)
14425 struct cmd_ddp_info_result *res = parsed_result;
14428 int ret = -ENOTSUP;
14429 #ifdef RTE_LIBRTE_I40E_PMD
14432 uint32_t buff_size = 0;
14433 struct rte_pmd_i40e_profile_info info;
14434 uint32_t dev_num = 0;
14435 struct rte_pmd_i40e_ddp_device_id *devs;
14436 uint32_t proto_num = 0;
14437 struct rte_pmd_i40e_proto_info *proto = NULL;
14438 uint32_t pctype_num = 0;
14439 struct rte_pmd_i40e_ptype_info *pctype;
14440 uint32_t ptype_num = 0;
14441 struct rte_pmd_i40e_ptype_info *ptype;
14446 pkg = open_ddp_package_file(res->filepath, &pkg_size);
14450 #ifdef RTE_LIBRTE_I40E_PMD
14451 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14452 (uint8_t *)&info, sizeof(info),
14453 RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER);
14455 printf("Global Track id: 0x%x\n", info.track_id);
14456 printf("Global Version: %d.%d.%d.%d\n",
14457 info.version.major,
14458 info.version.minor,
14459 info.version.update,
14460 info.version.draft);
14461 printf("Global Package name: %s\n\n", info.name);
14464 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14465 (uint8_t *)&info, sizeof(info),
14466 RTE_PMD_I40E_PKG_INFO_HEADER);
14468 printf("i40e Profile Track id: 0x%x\n", info.track_id);
14469 printf("i40e Profile Version: %d.%d.%d.%d\n",
14470 info.version.major,
14471 info.version.minor,
14472 info.version.update,
14473 info.version.draft);
14474 printf("i40e Profile name: %s\n\n", info.name);
14477 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14478 (uint8_t *)&buff_size, sizeof(buff_size),
14479 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE);
14480 if (!ret && buff_size) {
14481 buff = (uint8_t *)malloc(buff_size);
14483 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14485 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES);
14487 printf("Package Notes:\n%s\n\n", buff);
14492 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14493 (uint8_t *)&dev_num, sizeof(dev_num),
14494 RTE_PMD_I40E_PKG_INFO_DEVID_NUM);
14495 if (!ret && dev_num) {
14496 buff_size = dev_num * sizeof(struct rte_pmd_i40e_ddp_device_id);
14497 devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(buff_size);
14499 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14500 (uint8_t *)devs, buff_size,
14501 RTE_PMD_I40E_PKG_INFO_DEVID_LIST);
14503 printf("List of supported devices:\n");
14504 for (i = 0; i < dev_num; i++) {
14505 printf(" %04X:%04X %04X:%04X\n",
14506 devs[i].vendor_dev_id >> 16,
14507 devs[i].vendor_dev_id & 0xFFFF,
14508 devs[i].sub_vendor_dev_id >> 16,
14509 devs[i].sub_vendor_dev_id & 0xFFFF);
14517 /* get information about protocols and packet types */
14518 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14519 (uint8_t *)&proto_num, sizeof(proto_num),
14520 RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM);
14521 if (ret || !proto_num)
14522 goto no_print_return;
14524 buff_size = proto_num * sizeof(struct rte_pmd_i40e_proto_info);
14525 proto = (struct rte_pmd_i40e_proto_info *)malloc(buff_size);
14527 goto no_print_return;
14529 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)proto,
14531 RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST);
14533 printf("List of used protocols:\n");
14534 for (i = 0; i < proto_num; i++)
14535 printf(" %2u: %s\n", proto[i].proto_id,
14539 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14540 (uint8_t *)&pctype_num, sizeof(pctype_num),
14541 RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM);
14542 if (ret || !pctype_num)
14543 goto no_print_pctypes;
14545 buff_size = pctype_num * sizeof(struct rte_pmd_i40e_ptype_info);
14546 pctype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
14548 goto no_print_pctypes;
14550 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)pctype,
14552 RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST);
14555 goto no_print_pctypes;
14558 printf("List of defined packet classification types:\n");
14559 for (i = 0; i < pctype_num; i++) {
14560 printf(" %2u:", pctype[i].ptype_id);
14561 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
14562 proto_id = pctype[i].protocols[j];
14563 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
14564 for (n = 0; n < proto_num; n++) {
14565 if (proto[n].proto_id == proto_id) {
14566 printf(" %s", proto[n].name);
14579 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)&ptype_num,
14581 RTE_PMD_I40E_PKG_INFO_PTYPE_NUM);
14582 if (ret || !ptype_num)
14583 goto no_print_return;
14585 buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_info);
14586 ptype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
14588 goto no_print_return;
14590 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)ptype,
14592 RTE_PMD_I40E_PKG_INFO_PTYPE_LIST);
14595 goto no_print_return;
14597 printf("List of defined packet types:\n");
14598 for (i = 0; i < ptype_num; i++) {
14599 printf(" %2u:", ptype[i].ptype_id);
14600 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
14601 proto_id = ptype[i].protocols[j];
14602 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
14603 for (n = 0; n < proto_num; n++) {
14604 if (proto[n].proto_id == proto_id) {
14605 printf(" %s", proto[n].name);
14621 if (ret == -ENOTSUP)
14622 printf("Function not supported in PMD driver\n");
14623 close_ddp_package_file(pkg);
14626 cmdline_parse_inst_t cmd_ddp_get_info = {
14627 .f = cmd_ddp_info_parsed,
14629 .help_str = "ddp get info <profile_path>",
14631 (void *)&cmd_ddp_info_ddp,
14632 (void *)&cmd_ddp_info_get,
14633 (void *)&cmd_ddp_info_info,
14634 (void *)&cmd_ddp_info_filepath,
14639 /* Get dynamic device personalization profile info list*/
14640 #define PROFILE_INFO_SIZE 48
14641 #define MAX_PROFILE_NUM 16
14643 struct cmd_ddp_get_list_result {
14644 cmdline_fixed_string_t ddp;
14645 cmdline_fixed_string_t get;
14646 cmdline_fixed_string_t list;
14650 cmdline_parse_token_string_t cmd_ddp_get_list_ddp =
14651 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp");
14652 cmdline_parse_token_string_t cmd_ddp_get_list_get =
14653 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get");
14654 cmdline_parse_token_string_t cmd_ddp_get_list_list =
14655 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list");
14656 cmdline_parse_token_num_t cmd_ddp_get_list_port_id =
14657 TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id, UINT16);
14660 cmd_ddp_get_list_parsed(
14661 void *parsed_result,
14662 __attribute__((unused)) struct cmdline *cl,
14663 __attribute__((unused)) void *data)
14665 struct cmd_ddp_get_list_result *res = parsed_result;
14666 #ifdef RTE_LIBRTE_I40E_PMD
14667 struct rte_pmd_i40e_profile_list *p_list;
14668 struct rte_pmd_i40e_profile_info *p_info;
14673 int ret = -ENOTSUP;
14675 if (res->port_id > nb_ports) {
14676 printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
14680 #ifdef RTE_LIBRTE_I40E_PMD
14681 size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4;
14682 p_list = (struct rte_pmd_i40e_profile_list *)malloc(size);
14684 printf("%s: Failed to malloc buffer\n", __func__);
14686 if (ret == -ENOTSUP)
14687 ret = rte_pmd_i40e_get_ddp_list(res->port_id,
14688 (uint8_t *)p_list, size);
14691 p_num = p_list->p_count;
14692 printf("Profile number is: %d\n\n", p_num);
14694 for (i = 0; i < p_num; i++) {
14695 p_info = &p_list->p_info[i];
14696 printf("Profile %d:\n", i);
14697 printf("Track id: 0x%x\n", p_info->track_id);
14698 printf("Version: %d.%d.%d.%d\n",
14699 p_info->version.major,
14700 p_info->version.minor,
14701 p_info->version.update,
14702 p_info->version.draft);
14703 printf("Profile name: %s\n\n", p_info->name);
14711 printf("Failed to get ddp list\n");
14714 cmdline_parse_inst_t cmd_ddp_get_list = {
14715 .f = cmd_ddp_get_list_parsed,
14717 .help_str = "ddp get list <port_id>",
14719 (void *)&cmd_ddp_get_list_ddp,
14720 (void *)&cmd_ddp_get_list_get,
14721 (void *)&cmd_ddp_get_list_list,
14722 (void *)&cmd_ddp_get_list_port_id,
14727 /* show vf stats */
14729 /* Common result structure for show vf stats */
14730 struct cmd_show_vf_stats_result {
14731 cmdline_fixed_string_t show;
14732 cmdline_fixed_string_t vf;
14733 cmdline_fixed_string_t stats;
14738 /* Common CLI fields show vf stats*/
14739 cmdline_parse_token_string_t cmd_show_vf_stats_show =
14740 TOKEN_STRING_INITIALIZER
14741 (struct cmd_show_vf_stats_result,
14743 cmdline_parse_token_string_t cmd_show_vf_stats_vf =
14744 TOKEN_STRING_INITIALIZER
14745 (struct cmd_show_vf_stats_result,
14747 cmdline_parse_token_string_t cmd_show_vf_stats_stats =
14748 TOKEN_STRING_INITIALIZER
14749 (struct cmd_show_vf_stats_result,
14751 cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
14752 TOKEN_NUM_INITIALIZER
14753 (struct cmd_show_vf_stats_result,
14755 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
14756 TOKEN_NUM_INITIALIZER
14757 (struct cmd_show_vf_stats_result,
14761 cmd_show_vf_stats_parsed(
14762 void *parsed_result,
14763 __attribute__((unused)) struct cmdline *cl,
14764 __attribute__((unused)) void *data)
14766 struct cmd_show_vf_stats_result *res = parsed_result;
14767 struct rte_eth_stats stats;
14768 int ret = -ENOTSUP;
14769 static const char *nic_stats_border = "########################";
14771 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14774 memset(&stats, 0, sizeof(stats));
14776 #ifdef RTE_LIBRTE_I40E_PMD
14777 if (ret == -ENOTSUP)
14778 ret = rte_pmd_i40e_get_vf_stats(res->port_id,
14782 #ifdef RTE_LIBRTE_BNXT_PMD
14783 if (ret == -ENOTSUP)
14784 ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
14793 printf("invalid vf_id %d\n", res->vf_id);
14796 printf("invalid port_id %d\n", res->port_id);
14799 printf("function not implemented\n");
14802 printf("programming error: (%s)\n", strerror(-ret));
14805 printf("\n %s NIC statistics for port %-2d vf %-2d %s\n",
14806 nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
14808 printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: "
14810 stats.ipackets, stats.imissed, stats.ibytes);
14811 printf(" RX-errors: %-"PRIu64"\n", stats.ierrors);
14812 printf(" RX-nombuf: %-10"PRIu64"\n",
14814 printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: "
14816 stats.opackets, stats.oerrors, stats.obytes);
14818 printf(" %s############################%s\n",
14819 nic_stats_border, nic_stats_border);
14822 cmdline_parse_inst_t cmd_show_vf_stats = {
14823 .f = cmd_show_vf_stats_parsed,
14825 .help_str = "show vf stats <port_id> <vf_id>",
14827 (void *)&cmd_show_vf_stats_show,
14828 (void *)&cmd_show_vf_stats_vf,
14829 (void *)&cmd_show_vf_stats_stats,
14830 (void *)&cmd_show_vf_stats_port_id,
14831 (void *)&cmd_show_vf_stats_vf_id,
14836 /* clear vf stats */
14838 /* Common result structure for clear vf stats */
14839 struct cmd_clear_vf_stats_result {
14840 cmdline_fixed_string_t clear;
14841 cmdline_fixed_string_t vf;
14842 cmdline_fixed_string_t stats;
14847 /* Common CLI fields clear vf stats*/
14848 cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
14849 TOKEN_STRING_INITIALIZER
14850 (struct cmd_clear_vf_stats_result,
14852 cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
14853 TOKEN_STRING_INITIALIZER
14854 (struct cmd_clear_vf_stats_result,
14856 cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
14857 TOKEN_STRING_INITIALIZER
14858 (struct cmd_clear_vf_stats_result,
14860 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
14861 TOKEN_NUM_INITIALIZER
14862 (struct cmd_clear_vf_stats_result,
14864 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
14865 TOKEN_NUM_INITIALIZER
14866 (struct cmd_clear_vf_stats_result,
14870 cmd_clear_vf_stats_parsed(
14871 void *parsed_result,
14872 __attribute__((unused)) struct cmdline *cl,
14873 __attribute__((unused)) void *data)
14875 struct cmd_clear_vf_stats_result *res = parsed_result;
14876 int ret = -ENOTSUP;
14878 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14881 #ifdef RTE_LIBRTE_I40E_PMD
14882 if (ret == -ENOTSUP)
14883 ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
14886 #ifdef RTE_LIBRTE_BNXT_PMD
14887 if (ret == -ENOTSUP)
14888 ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
14896 printf("invalid vf_id %d\n", res->vf_id);
14899 printf("invalid port_id %d\n", res->port_id);
14902 printf("function not implemented\n");
14905 printf("programming error: (%s)\n", strerror(-ret));
14909 cmdline_parse_inst_t cmd_clear_vf_stats = {
14910 .f = cmd_clear_vf_stats_parsed,
14912 .help_str = "clear vf stats <port_id> <vf_id>",
14914 (void *)&cmd_clear_vf_stats_clear,
14915 (void *)&cmd_clear_vf_stats_vf,
14916 (void *)&cmd_clear_vf_stats_stats,
14917 (void *)&cmd_clear_vf_stats_port_id,
14918 (void *)&cmd_clear_vf_stats_vf_id,
14923 /* port config pctype mapping reset */
14925 /* Common result structure for port config pctype mapping reset */
14926 struct cmd_pctype_mapping_reset_result {
14927 cmdline_fixed_string_t port;
14928 cmdline_fixed_string_t config;
14930 cmdline_fixed_string_t pctype;
14931 cmdline_fixed_string_t mapping;
14932 cmdline_fixed_string_t reset;
14935 /* Common CLI fields for port config pctype mapping reset*/
14936 cmdline_parse_token_string_t cmd_pctype_mapping_reset_port =
14937 TOKEN_STRING_INITIALIZER
14938 (struct cmd_pctype_mapping_reset_result,
14940 cmdline_parse_token_string_t cmd_pctype_mapping_reset_config =
14941 TOKEN_STRING_INITIALIZER
14942 (struct cmd_pctype_mapping_reset_result,
14944 cmdline_parse_token_num_t cmd_pctype_mapping_reset_port_id =
14945 TOKEN_NUM_INITIALIZER
14946 (struct cmd_pctype_mapping_reset_result,
14948 cmdline_parse_token_string_t cmd_pctype_mapping_reset_pctype =
14949 TOKEN_STRING_INITIALIZER
14950 (struct cmd_pctype_mapping_reset_result,
14952 cmdline_parse_token_string_t cmd_pctype_mapping_reset_mapping =
14953 TOKEN_STRING_INITIALIZER
14954 (struct cmd_pctype_mapping_reset_result,
14955 mapping, "mapping");
14956 cmdline_parse_token_string_t cmd_pctype_mapping_reset_reset =
14957 TOKEN_STRING_INITIALIZER
14958 (struct cmd_pctype_mapping_reset_result,
14962 cmd_pctype_mapping_reset_parsed(
14963 void *parsed_result,
14964 __attribute__((unused)) struct cmdline *cl,
14965 __attribute__((unused)) void *data)
14967 struct cmd_pctype_mapping_reset_result *res = parsed_result;
14968 int ret = -ENOTSUP;
14970 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14973 #ifdef RTE_LIBRTE_I40E_PMD
14974 ret = rte_pmd_i40e_flow_type_mapping_reset(res->port_id);
14981 printf("invalid port_id %d\n", res->port_id);
14984 printf("function not implemented\n");
14987 printf("programming error: (%s)\n", strerror(-ret));
14991 cmdline_parse_inst_t cmd_pctype_mapping_reset = {
14992 .f = cmd_pctype_mapping_reset_parsed,
14994 .help_str = "port config <port_id> pctype mapping reset",
14996 (void *)&cmd_pctype_mapping_reset_port,
14997 (void *)&cmd_pctype_mapping_reset_config,
14998 (void *)&cmd_pctype_mapping_reset_port_id,
14999 (void *)&cmd_pctype_mapping_reset_pctype,
15000 (void *)&cmd_pctype_mapping_reset_mapping,
15001 (void *)&cmd_pctype_mapping_reset_reset,
15006 /* show port pctype mapping */
15008 /* Common result structure for show port pctype mapping */
15009 struct cmd_pctype_mapping_get_result {
15010 cmdline_fixed_string_t show;
15011 cmdline_fixed_string_t port;
15013 cmdline_fixed_string_t pctype;
15014 cmdline_fixed_string_t mapping;
15017 /* Common CLI fields for pctype mapping get */
15018 cmdline_parse_token_string_t cmd_pctype_mapping_get_show =
15019 TOKEN_STRING_INITIALIZER
15020 (struct cmd_pctype_mapping_get_result,
15022 cmdline_parse_token_string_t cmd_pctype_mapping_get_port =
15023 TOKEN_STRING_INITIALIZER
15024 (struct cmd_pctype_mapping_get_result,
15026 cmdline_parse_token_num_t cmd_pctype_mapping_get_port_id =
15027 TOKEN_NUM_INITIALIZER
15028 (struct cmd_pctype_mapping_get_result,
15030 cmdline_parse_token_string_t cmd_pctype_mapping_get_pctype =
15031 TOKEN_STRING_INITIALIZER
15032 (struct cmd_pctype_mapping_get_result,
15034 cmdline_parse_token_string_t cmd_pctype_mapping_get_mapping =
15035 TOKEN_STRING_INITIALIZER
15036 (struct cmd_pctype_mapping_get_result,
15037 mapping, "mapping");
15040 cmd_pctype_mapping_get_parsed(
15041 void *parsed_result,
15042 __attribute__((unused)) struct cmdline *cl,
15043 __attribute__((unused)) void *data)
15045 struct cmd_pctype_mapping_get_result *res = parsed_result;
15046 int ret = -ENOTSUP;
15047 #ifdef RTE_LIBRTE_I40E_PMD
15048 struct rte_pmd_i40e_flow_type_mapping
15049 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
15050 int i, j, first_pctype;
15053 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15056 #ifdef RTE_LIBRTE_I40E_PMD
15057 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, mapping);
15064 printf("invalid port_id %d\n", res->port_id);
15067 printf("function not implemented\n");
15070 printf("programming error: (%s)\n", strerror(-ret));
15074 #ifdef RTE_LIBRTE_I40E_PMD
15075 for (i = 0; i < RTE_PMD_I40E_FLOW_TYPE_MAX; i++) {
15076 if (mapping[i].pctype != 0ULL) {
15079 printf("pctype: ");
15080 for (j = 0; j < RTE_PMD_I40E_PCTYPE_MAX; j++) {
15081 if (mapping[i].pctype & (1ULL << j)) {
15082 printf(first_pctype ?
15083 "%02d" : ",%02d", j);
15087 printf(" -> flowtype: %02d\n", mapping[i].flow_type);
15093 cmdline_parse_inst_t cmd_pctype_mapping_get = {
15094 .f = cmd_pctype_mapping_get_parsed,
15096 .help_str = "show port <port_id> pctype mapping",
15098 (void *)&cmd_pctype_mapping_get_show,
15099 (void *)&cmd_pctype_mapping_get_port,
15100 (void *)&cmd_pctype_mapping_get_port_id,
15101 (void *)&cmd_pctype_mapping_get_pctype,
15102 (void *)&cmd_pctype_mapping_get_mapping,
15107 /* port config pctype mapping update */
15109 /* Common result structure for port config pctype mapping update */
15110 struct cmd_pctype_mapping_update_result {
15111 cmdline_fixed_string_t port;
15112 cmdline_fixed_string_t config;
15114 cmdline_fixed_string_t pctype;
15115 cmdline_fixed_string_t mapping;
15116 cmdline_fixed_string_t update;
15117 cmdline_fixed_string_t pctype_list;
15118 uint16_t flow_type;
15121 /* Common CLI fields for pctype mapping update*/
15122 cmdline_parse_token_string_t cmd_pctype_mapping_update_port =
15123 TOKEN_STRING_INITIALIZER
15124 (struct cmd_pctype_mapping_update_result,
15126 cmdline_parse_token_string_t cmd_pctype_mapping_update_config =
15127 TOKEN_STRING_INITIALIZER
15128 (struct cmd_pctype_mapping_update_result,
15130 cmdline_parse_token_num_t cmd_pctype_mapping_update_port_id =
15131 TOKEN_NUM_INITIALIZER
15132 (struct cmd_pctype_mapping_update_result,
15134 cmdline_parse_token_string_t cmd_pctype_mapping_update_pctype =
15135 TOKEN_STRING_INITIALIZER
15136 (struct cmd_pctype_mapping_update_result,
15138 cmdline_parse_token_string_t cmd_pctype_mapping_update_mapping =
15139 TOKEN_STRING_INITIALIZER
15140 (struct cmd_pctype_mapping_update_result,
15141 mapping, "mapping");
15142 cmdline_parse_token_string_t cmd_pctype_mapping_update_update =
15143 TOKEN_STRING_INITIALIZER
15144 (struct cmd_pctype_mapping_update_result,
15146 cmdline_parse_token_string_t cmd_pctype_mapping_update_pc_type =
15147 TOKEN_STRING_INITIALIZER
15148 (struct cmd_pctype_mapping_update_result,
15149 pctype_list, NULL);
15150 cmdline_parse_token_num_t cmd_pctype_mapping_update_flow_type =
15151 TOKEN_NUM_INITIALIZER
15152 (struct cmd_pctype_mapping_update_result,
15153 flow_type, UINT16);
15156 cmd_pctype_mapping_update_parsed(
15157 void *parsed_result,
15158 __attribute__((unused)) struct cmdline *cl,
15159 __attribute__((unused)) void *data)
15161 struct cmd_pctype_mapping_update_result *res = parsed_result;
15162 int ret = -ENOTSUP;
15163 #ifdef RTE_LIBRTE_I40E_PMD
15164 struct rte_pmd_i40e_flow_type_mapping mapping;
15166 unsigned int nb_item;
15167 unsigned int pctype_list[RTE_PMD_I40E_PCTYPE_MAX];
15170 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15173 #ifdef RTE_LIBRTE_I40E_PMD
15174 nb_item = parse_item_list(res->pctype_list, "pctypes",
15175 RTE_PMD_I40E_PCTYPE_MAX, pctype_list, 1);
15176 mapping.flow_type = res->flow_type;
15177 for (i = 0, mapping.pctype = 0ULL; i < nb_item; i++)
15178 mapping.pctype |= (1ULL << pctype_list[i]);
15179 ret = rte_pmd_i40e_flow_type_mapping_update(res->port_id,
15189 printf("invalid pctype or flow type\n");
15192 printf("invalid port_id %d\n", res->port_id);
15195 printf("function not implemented\n");
15198 printf("programming error: (%s)\n", strerror(-ret));
15202 cmdline_parse_inst_t cmd_pctype_mapping_update = {
15203 .f = cmd_pctype_mapping_update_parsed,
15205 .help_str = "port config <port_id> pctype mapping update"
15206 " <pctype_id_0,[pctype_id_1]*> <flowtype_id>",
15208 (void *)&cmd_pctype_mapping_update_port,
15209 (void *)&cmd_pctype_mapping_update_config,
15210 (void *)&cmd_pctype_mapping_update_port_id,
15211 (void *)&cmd_pctype_mapping_update_pctype,
15212 (void *)&cmd_pctype_mapping_update_mapping,
15213 (void *)&cmd_pctype_mapping_update_update,
15214 (void *)&cmd_pctype_mapping_update_pc_type,
15215 (void *)&cmd_pctype_mapping_update_flow_type,
15220 /* ptype mapping get */
15222 /* Common result structure for ptype mapping get */
15223 struct cmd_ptype_mapping_get_result {
15224 cmdline_fixed_string_t ptype;
15225 cmdline_fixed_string_t mapping;
15226 cmdline_fixed_string_t get;
15228 uint8_t valid_only;
15231 /* Common CLI fields for ptype mapping get */
15232 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype =
15233 TOKEN_STRING_INITIALIZER
15234 (struct cmd_ptype_mapping_get_result,
15236 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping =
15237 TOKEN_STRING_INITIALIZER
15238 (struct cmd_ptype_mapping_get_result,
15239 mapping, "mapping");
15240 cmdline_parse_token_string_t cmd_ptype_mapping_get_get =
15241 TOKEN_STRING_INITIALIZER
15242 (struct cmd_ptype_mapping_get_result,
15244 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id =
15245 TOKEN_NUM_INITIALIZER
15246 (struct cmd_ptype_mapping_get_result,
15248 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only =
15249 TOKEN_NUM_INITIALIZER
15250 (struct cmd_ptype_mapping_get_result,
15251 valid_only, UINT8);
15254 cmd_ptype_mapping_get_parsed(
15255 void *parsed_result,
15256 __attribute__((unused)) struct cmdline *cl,
15257 __attribute__((unused)) void *data)
15259 struct cmd_ptype_mapping_get_result *res = parsed_result;
15260 int ret = -ENOTSUP;
15261 #ifdef RTE_LIBRTE_I40E_PMD
15262 int max_ptype_num = 256;
15263 struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num];
15268 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15271 #ifdef RTE_LIBRTE_I40E_PMD
15272 ret = rte_pmd_i40e_ptype_mapping_get(res->port_id,
15283 printf("invalid port_id %d\n", res->port_id);
15286 printf("function not implemented\n");
15289 printf("programming error: (%s)\n", strerror(-ret));
15292 #ifdef RTE_LIBRTE_I40E_PMD
15294 for (i = 0; i < count; i++)
15295 printf("%3d\t0x%08x\n",
15296 mapping[i].hw_ptype, mapping[i].sw_ptype);
15301 cmdline_parse_inst_t cmd_ptype_mapping_get = {
15302 .f = cmd_ptype_mapping_get_parsed,
15304 .help_str = "ptype mapping get <port_id> <valid_only>",
15306 (void *)&cmd_ptype_mapping_get_ptype,
15307 (void *)&cmd_ptype_mapping_get_mapping,
15308 (void *)&cmd_ptype_mapping_get_get,
15309 (void *)&cmd_ptype_mapping_get_port_id,
15310 (void *)&cmd_ptype_mapping_get_valid_only,
15315 /* ptype mapping replace */
15317 /* Common result structure for ptype mapping replace */
15318 struct cmd_ptype_mapping_replace_result {
15319 cmdline_fixed_string_t ptype;
15320 cmdline_fixed_string_t mapping;
15321 cmdline_fixed_string_t replace;
15328 /* Common CLI fields for ptype mapping replace */
15329 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype =
15330 TOKEN_STRING_INITIALIZER
15331 (struct cmd_ptype_mapping_replace_result,
15333 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping =
15334 TOKEN_STRING_INITIALIZER
15335 (struct cmd_ptype_mapping_replace_result,
15336 mapping, "mapping");
15337 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace =
15338 TOKEN_STRING_INITIALIZER
15339 (struct cmd_ptype_mapping_replace_result,
15340 replace, "replace");
15341 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id =
15342 TOKEN_NUM_INITIALIZER
15343 (struct cmd_ptype_mapping_replace_result,
15345 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target =
15346 TOKEN_NUM_INITIALIZER
15347 (struct cmd_ptype_mapping_replace_result,
15349 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask =
15350 TOKEN_NUM_INITIALIZER
15351 (struct cmd_ptype_mapping_replace_result,
15353 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type =
15354 TOKEN_NUM_INITIALIZER
15355 (struct cmd_ptype_mapping_replace_result,
15359 cmd_ptype_mapping_replace_parsed(
15360 void *parsed_result,
15361 __attribute__((unused)) struct cmdline *cl,
15362 __attribute__((unused)) void *data)
15364 struct cmd_ptype_mapping_replace_result *res = parsed_result;
15365 int ret = -ENOTSUP;
15367 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15370 #ifdef RTE_LIBRTE_I40E_PMD
15371 ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id,
15381 printf("invalid ptype 0x%8x or 0x%8x\n",
15382 res->target, res->pkt_type);
15385 printf("invalid port_id %d\n", res->port_id);
15388 printf("function not implemented\n");
15391 printf("programming error: (%s)\n", strerror(-ret));
15395 cmdline_parse_inst_t cmd_ptype_mapping_replace = {
15396 .f = cmd_ptype_mapping_replace_parsed,
15399 "ptype mapping replace <port_id> <target> <mask> <pkt_type>",
15401 (void *)&cmd_ptype_mapping_replace_ptype,
15402 (void *)&cmd_ptype_mapping_replace_mapping,
15403 (void *)&cmd_ptype_mapping_replace_replace,
15404 (void *)&cmd_ptype_mapping_replace_port_id,
15405 (void *)&cmd_ptype_mapping_replace_target,
15406 (void *)&cmd_ptype_mapping_replace_mask,
15407 (void *)&cmd_ptype_mapping_replace_pkt_type,
15412 /* ptype mapping reset */
15414 /* Common result structure for ptype mapping reset */
15415 struct cmd_ptype_mapping_reset_result {
15416 cmdline_fixed_string_t ptype;
15417 cmdline_fixed_string_t mapping;
15418 cmdline_fixed_string_t reset;
15422 /* Common CLI fields for ptype mapping reset*/
15423 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype =
15424 TOKEN_STRING_INITIALIZER
15425 (struct cmd_ptype_mapping_reset_result,
15427 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping =
15428 TOKEN_STRING_INITIALIZER
15429 (struct cmd_ptype_mapping_reset_result,
15430 mapping, "mapping");
15431 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset =
15432 TOKEN_STRING_INITIALIZER
15433 (struct cmd_ptype_mapping_reset_result,
15435 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id =
15436 TOKEN_NUM_INITIALIZER
15437 (struct cmd_ptype_mapping_reset_result,
15441 cmd_ptype_mapping_reset_parsed(
15442 void *parsed_result,
15443 __attribute__((unused)) struct cmdline *cl,
15444 __attribute__((unused)) void *data)
15446 struct cmd_ptype_mapping_reset_result *res = parsed_result;
15447 int ret = -ENOTSUP;
15449 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15452 #ifdef RTE_LIBRTE_I40E_PMD
15453 ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id);
15460 printf("invalid port_id %d\n", res->port_id);
15463 printf("function not implemented\n");
15466 printf("programming error: (%s)\n", strerror(-ret));
15470 cmdline_parse_inst_t cmd_ptype_mapping_reset = {
15471 .f = cmd_ptype_mapping_reset_parsed,
15473 .help_str = "ptype mapping reset <port_id>",
15475 (void *)&cmd_ptype_mapping_reset_ptype,
15476 (void *)&cmd_ptype_mapping_reset_mapping,
15477 (void *)&cmd_ptype_mapping_reset_reset,
15478 (void *)&cmd_ptype_mapping_reset_port_id,
15483 /* ptype mapping update */
15485 /* Common result structure for ptype mapping update */
15486 struct cmd_ptype_mapping_update_result {
15487 cmdline_fixed_string_t ptype;
15488 cmdline_fixed_string_t mapping;
15489 cmdline_fixed_string_t reset;
15495 /* Common CLI fields for ptype mapping update*/
15496 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype =
15497 TOKEN_STRING_INITIALIZER
15498 (struct cmd_ptype_mapping_update_result,
15500 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping =
15501 TOKEN_STRING_INITIALIZER
15502 (struct cmd_ptype_mapping_update_result,
15503 mapping, "mapping");
15504 cmdline_parse_token_string_t cmd_ptype_mapping_update_update =
15505 TOKEN_STRING_INITIALIZER
15506 (struct cmd_ptype_mapping_update_result,
15508 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id =
15509 TOKEN_NUM_INITIALIZER
15510 (struct cmd_ptype_mapping_update_result,
15512 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype =
15513 TOKEN_NUM_INITIALIZER
15514 (struct cmd_ptype_mapping_update_result,
15516 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype =
15517 TOKEN_NUM_INITIALIZER
15518 (struct cmd_ptype_mapping_update_result,
15522 cmd_ptype_mapping_update_parsed(
15523 void *parsed_result,
15524 __attribute__((unused)) struct cmdline *cl,
15525 __attribute__((unused)) void *data)
15527 struct cmd_ptype_mapping_update_result *res = parsed_result;
15528 int ret = -ENOTSUP;
15529 #ifdef RTE_LIBRTE_I40E_PMD
15530 struct rte_pmd_i40e_ptype_mapping mapping;
15532 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15535 #ifdef RTE_LIBRTE_I40E_PMD
15536 mapping.hw_ptype = res->hw_ptype;
15537 mapping.sw_ptype = res->sw_ptype;
15538 ret = rte_pmd_i40e_ptype_mapping_update(res->port_id,
15548 printf("invalid ptype 0x%8x\n", res->sw_ptype);
15551 printf("invalid port_id %d\n", res->port_id);
15554 printf("function not implemented\n");
15557 printf("programming error: (%s)\n", strerror(-ret));
15561 cmdline_parse_inst_t cmd_ptype_mapping_update = {
15562 .f = cmd_ptype_mapping_update_parsed,
15564 .help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>",
15566 (void *)&cmd_ptype_mapping_update_ptype,
15567 (void *)&cmd_ptype_mapping_update_mapping,
15568 (void *)&cmd_ptype_mapping_update_update,
15569 (void *)&cmd_ptype_mapping_update_port_id,
15570 (void *)&cmd_ptype_mapping_update_hw_ptype,
15571 (void *)&cmd_ptype_mapping_update_sw_ptype,
15576 /* Common result structure for file commands */
15577 struct cmd_cmdfile_result {
15578 cmdline_fixed_string_t load;
15579 cmdline_fixed_string_t filename;
15582 /* Common CLI fields for file commands */
15583 cmdline_parse_token_string_t cmd_load_cmdfile =
15584 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
15585 cmdline_parse_token_string_t cmd_load_cmdfile_filename =
15586 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
15589 cmd_load_from_file_parsed(
15590 void *parsed_result,
15591 __attribute__((unused)) struct cmdline *cl,
15592 __attribute__((unused)) void *data)
15594 struct cmd_cmdfile_result *res = parsed_result;
15596 cmdline_read_from_file(res->filename);
15599 cmdline_parse_inst_t cmd_load_from_file = {
15600 .f = cmd_load_from_file_parsed,
15602 .help_str = "load <filename>",
15604 (void *)&cmd_load_cmdfile,
15605 (void *)&cmd_load_cmdfile_filename,
15610 /* ******************************************************************************** */
15612 /* list of instructions */
15613 cmdline_parse_ctx_t main_ctx[] = {
15614 (cmdline_parse_inst_t *)&cmd_help_brief,
15615 (cmdline_parse_inst_t *)&cmd_help_long,
15616 (cmdline_parse_inst_t *)&cmd_quit,
15617 (cmdline_parse_inst_t *)&cmd_load_from_file,
15618 (cmdline_parse_inst_t *)&cmd_showport,
15619 (cmdline_parse_inst_t *)&cmd_showqueue,
15620 (cmdline_parse_inst_t *)&cmd_showportall,
15621 (cmdline_parse_inst_t *)&cmd_showcfg,
15622 (cmdline_parse_inst_t *)&cmd_start,
15623 (cmdline_parse_inst_t *)&cmd_start_tx_first,
15624 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
15625 (cmdline_parse_inst_t *)&cmd_set_link_up,
15626 (cmdline_parse_inst_t *)&cmd_set_link_down,
15627 (cmdline_parse_inst_t *)&cmd_reset,
15628 (cmdline_parse_inst_t *)&cmd_set_numbers,
15629 (cmdline_parse_inst_t *)&cmd_set_txpkts,
15630 (cmdline_parse_inst_t *)&cmd_set_txsplit,
15631 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
15632 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
15633 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
15634 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
15635 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
15636 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
15637 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
15638 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
15639 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
15640 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
15641 (cmdline_parse_inst_t *)&cmd_set_link_check,
15642 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
15643 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
15644 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
15645 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
15646 #ifdef RTE_LIBRTE_PMD_BOND
15647 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
15648 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
15649 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
15650 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
15651 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
15652 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
15653 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
15654 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
15655 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
15656 (cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues,
15657 (cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy,
15659 (cmdline_parse_inst_t *)&cmd_vlan_offload,
15660 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
15661 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
15662 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
15663 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
15664 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
15665 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
15666 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
15667 (cmdline_parse_inst_t *)&cmd_csum_set,
15668 (cmdline_parse_inst_t *)&cmd_csum_show,
15669 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
15670 (cmdline_parse_inst_t *)&cmd_tso_set,
15671 (cmdline_parse_inst_t *)&cmd_tso_show,
15672 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
15673 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
15674 (cmdline_parse_inst_t *)&cmd_gro_enable,
15675 (cmdline_parse_inst_t *)&cmd_gro_flush,
15676 (cmdline_parse_inst_t *)&cmd_gro_show,
15677 (cmdline_parse_inst_t *)&cmd_gso_enable,
15678 (cmdline_parse_inst_t *)&cmd_gso_size,
15679 (cmdline_parse_inst_t *)&cmd_gso_show,
15680 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
15681 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
15682 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
15683 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
15684 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
15685 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
15686 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
15687 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
15688 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
15689 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
15690 (cmdline_parse_inst_t *)&cmd_config_dcb,
15691 (cmdline_parse_inst_t *)&cmd_read_reg,
15692 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
15693 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
15694 (cmdline_parse_inst_t *)&cmd_write_reg,
15695 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
15696 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
15697 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
15698 (cmdline_parse_inst_t *)&cmd_stop,
15699 (cmdline_parse_inst_t *)&cmd_mac_addr,
15700 (cmdline_parse_inst_t *)&cmd_set_qmap,
15701 (cmdline_parse_inst_t *)&cmd_set_xstats_hide_zero,
15702 (cmdline_parse_inst_t *)&cmd_operate_port,
15703 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
15704 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
15705 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
15706 (cmdline_parse_inst_t *)&cmd_config_speed_all,
15707 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
15708 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
15709 (cmdline_parse_inst_t *)&cmd_config_mtu,
15710 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
15711 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
15712 (cmdline_parse_inst_t *)&cmd_config_rss,
15713 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
15714 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
15715 (cmdline_parse_inst_t *)&cmd_showport_reta,
15716 (cmdline_parse_inst_t *)&cmd_config_burst,
15717 (cmdline_parse_inst_t *)&cmd_config_thresh,
15718 (cmdline_parse_inst_t *)&cmd_config_threshold,
15719 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
15720 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
15721 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
15722 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
15723 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
15724 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
15725 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
15726 (cmdline_parse_inst_t *)&cmd_global_config,
15727 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
15728 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
15729 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
15730 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
15731 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
15732 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
15733 (cmdline_parse_inst_t *)&cmd_dump,
15734 (cmdline_parse_inst_t *)&cmd_dump_one,
15735 (cmdline_parse_inst_t *)&cmd_ethertype_filter,
15736 (cmdline_parse_inst_t *)&cmd_syn_filter,
15737 (cmdline_parse_inst_t *)&cmd_2tuple_filter,
15738 (cmdline_parse_inst_t *)&cmd_5tuple_filter,
15739 (cmdline_parse_inst_t *)&cmd_flex_filter,
15740 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
15741 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
15742 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
15743 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director,
15744 (cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director,
15745 (cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director,
15746 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
15747 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
15748 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
15749 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
15750 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
15751 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
15752 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
15753 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
15754 (cmdline_parse_inst_t *)&cmd_get_hash_global_config,
15755 (cmdline_parse_inst_t *)&cmd_set_hash_global_config,
15756 (cmdline_parse_inst_t *)&cmd_set_hash_input_set,
15757 (cmdline_parse_inst_t *)&cmd_set_fdir_input_set,
15758 (cmdline_parse_inst_t *)&cmd_flow,
15759 (cmdline_parse_inst_t *)&cmd_show_port_meter_cap,
15760 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm,
15761 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm,
15762 (cmdline_parse_inst_t *)&cmd_del_port_meter_profile,
15763 (cmdline_parse_inst_t *)&cmd_create_port_meter,
15764 (cmdline_parse_inst_t *)&cmd_enable_port_meter,
15765 (cmdline_parse_inst_t *)&cmd_disable_port_meter,
15766 (cmdline_parse_inst_t *)&cmd_del_port_meter,
15767 (cmdline_parse_inst_t *)&cmd_set_port_meter_profile,
15768 (cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table,
15769 (cmdline_parse_inst_t *)&cmd_set_port_meter_policer_action,
15770 (cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask,
15771 (cmdline_parse_inst_t *)&cmd_show_port_meter_stats,
15772 (cmdline_parse_inst_t *)&cmd_mcast_addr,
15773 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all,
15774 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific,
15775 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all,
15776 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific,
15777 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_en,
15778 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_dis,
15779 (cmdline_parse_inst_t *)&cmd_config_e_tag_stripping_en_dis,
15780 (cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis,
15781 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_add,
15782 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_del,
15783 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
15784 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
15785 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
15786 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
15787 (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
15788 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
15789 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
15790 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
15791 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
15792 (cmdline_parse_inst_t *)&cmd_set_macsec_sc,
15793 (cmdline_parse_inst_t *)&cmd_set_macsec_sa,
15794 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
15795 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
15796 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
15797 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
15798 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
15799 (cmdline_parse_inst_t *)&cmd_set_vf_promisc,
15800 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
15801 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
15802 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
15803 (cmdline_parse_inst_t *)&cmd_vf_max_bw,
15804 (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
15805 (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
15806 (cmdline_parse_inst_t *)&cmd_strict_link_prio,
15807 (cmdline_parse_inst_t *)&cmd_tc_min_bw,
15808 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
15809 (cmdline_parse_inst_t *)&cmd_set_port_tm_hierarchy_default,
15811 (cmdline_parse_inst_t *)&cmd_ddp_add,
15812 (cmdline_parse_inst_t *)&cmd_ddp_del,
15813 (cmdline_parse_inst_t *)&cmd_ddp_get_list,
15814 (cmdline_parse_inst_t *)&cmd_ddp_get_info,
15815 (cmdline_parse_inst_t *)&cmd_show_vf_stats,
15816 (cmdline_parse_inst_t *)&cmd_clear_vf_stats,
15817 (cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
15818 (cmdline_parse_inst_t *)&cmd_ptype_mapping_replace,
15819 (cmdline_parse_inst_t *)&cmd_ptype_mapping_reset,
15820 (cmdline_parse_inst_t *)&cmd_ptype_mapping_update,
15822 (cmdline_parse_inst_t *)&cmd_pctype_mapping_get,
15823 (cmdline_parse_inst_t *)&cmd_pctype_mapping_reset,
15824 (cmdline_parse_inst_t *)&cmd_pctype_mapping_update,
15825 (cmdline_parse_inst_t *)&cmd_queue_region,
15826 (cmdline_parse_inst_t *)&cmd_region_flowtype,
15827 (cmdline_parse_inst_t *)&cmd_user_priority_region,
15828 (cmdline_parse_inst_t *)&cmd_flush_queue_region,
15829 (cmdline_parse_inst_t *)&cmd_show_queue_region_info_all,
15830 (cmdline_parse_inst_t *)&cmd_show_port_tm_cap,
15831 (cmdline_parse_inst_t *)&cmd_show_port_tm_level_cap,
15832 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_cap,
15833 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_type,
15834 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_stats,
15835 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shaper_profile,
15836 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shaper_profile,
15837 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shared_shaper,
15838 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shared_shaper,
15839 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_wred_profile,
15840 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_wred_profile,
15841 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_shaper_profile,
15842 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node,
15843 (cmdline_parse_inst_t *)&cmd_add_port_tm_leaf_node,
15844 (cmdline_parse_inst_t *)&cmd_del_port_tm_node,
15845 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_parent,
15846 (cmdline_parse_inst_t *)&cmd_port_tm_hierarchy_commit,
15850 /* read cmdline commands from file */
15852 cmdline_read_from_file(const char *filename)
15854 struct cmdline *cl;
15856 cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
15858 printf("Failed to create file based cmdline context: %s\n",
15863 cmdline_interact(cl);
15868 printf("Read CLI commands from %s\n", filename);
15871 /* prompt function, called from main on MASTER lcore */
15875 /* initialize non-constant commands */
15876 cmd_set_fwd_mode_init();
15877 cmd_set_fwd_retry_mode_init();
15879 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
15880 if (testpmd_cl == NULL)
15882 cmdline_interact(testpmd_cl);
15883 cmdline_stdin_exit(testpmd_cl);
15889 if (testpmd_cl != NULL)
15890 cmdline_quit(testpmd_cl);
15894 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
15896 if (id == (portid_t)RTE_PORT_ALL) {
15899 RTE_ETH_FOREACH_DEV(pid) {
15900 /* check if need_reconfig has been set to 1 */
15901 if (ports[pid].need_reconfig == 0)
15902 ports[pid].need_reconfig = dev;
15903 /* check if need_reconfig_queues has been set to 1 */
15904 if (ports[pid].need_reconfig_queues == 0)
15905 ports[pid].need_reconfig_queues = queue;
15907 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
15908 /* check if need_reconfig has been set to 1 */
15909 if (ports[id].need_reconfig == 0)
15910 ports[id].need_reconfig = dev;
15911 /* check if need_reconfig_queues has been set to 1 */
15912 if (ports[id].need_reconfig_queues == 0)
15913 ports[id].need_reconfig_queues = queue;